@rr0/ufoathome 0.77.0 → 0.78.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist-embed-scene/{SceneNames_es-C1QdYSKO.js → SceneNames_es-B6UgSlXt.js} +1 -1
  2. package/{dist-embed-sighting/SceneNames_fr-0Wzm8zKy.js → dist-embed-scene/SceneNames_fr-BJltNyw-.js} +1 -1
  3. package/{dist-embed-sighting-editor/SceneNames_it-C5oOps-9.js → dist-embed-scene/SceneNames_it-CQKtZ4O0.js} +1 -1
  4. package/dist-embed-scene/UfoMessages_es-y8jU_0WN.js +1 -0
  5. package/dist-embed-scene/UfoMessages_fr-DTSHJJJ1.js +1 -0
  6. package/dist-embed-scene/UfoMessages_it-C-2zrCGg.js +1 -0
  7. package/dist-embed-scene/rr0-scene.mjs +93 -36
  8. package/{dist-embed-sighting-editor/SceneNames_es-C1QdYSKO.js → dist-embed-sighting/SceneNames_es-B6UgSlXt.js} +1 -1
  9. package/{dist-embed-sighting-editor/SceneNames_fr-0Wzm8zKy.js → dist-embed-sighting/SceneNames_fr-BJltNyw-.js} +1 -1
  10. package/{dist-embed-scene/SceneNames_it-C5oOps-9.js → dist-embed-sighting/SceneNames_it-CQKtZ4O0.js} +1 -1
  11. package/dist-embed-sighting/UfoMessages_es-y8jU_0WN.js +1 -0
  12. package/dist-embed-sighting/UfoMessages_fr-DTSHJJJ1.js +1 -0
  13. package/dist-embed-sighting/UfoMessages_it-C-2zrCGg.js +1 -0
  14. package/dist-embed-sighting/rr0-sighting.mjs +143 -90
  15. package/{dist-embed-sighting/SceneNames_es-C1QdYSKO.js → dist-embed-sighting-editor/SceneNames_es-B6UgSlXt.js} +1 -1
  16. package/{dist-embed-scene/SceneNames_fr-0Wzm8zKy.js → dist-embed-sighting-editor/SceneNames_fr-BJltNyw-.js} +1 -1
  17. package/{dist-embed-sighting/SceneNames_it-C5oOps-9.js → dist-embed-sighting-editor/SceneNames_it-CQKtZ4O0.js} +1 -1
  18. package/dist-embed-sighting-editor/UfoMessages_es-y8jU_0WN.js +1 -0
  19. package/dist-embed-sighting-editor/UfoMessages_fr-DTSHJJJ1.js +1 -0
  20. package/dist-embed-sighting-editor/UfoMessages_it-C-2zrCGg.js +1 -0
  21. package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +89 -32
  22. package/package.json +1 -1
  23. package/dist-embed-scene/UfoMessages_es-DYc7i3SM.js +0 -1
  24. package/dist-embed-scene/UfoMessages_fr-B7ekN0RL.js +0 -1
  25. package/dist-embed-scene/UfoMessages_it-BDc9SDxc.js +0 -1
  26. package/dist-embed-sighting/UfoMessages_es-DYc7i3SM.js +0 -1
  27. package/dist-embed-sighting/UfoMessages_fr-B7ekN0RL.js +0 -1
  28. package/dist-embed-sighting/UfoMessages_it-BDc9SDxc.js +0 -1
  29. package/dist-embed-sighting-editor/UfoMessages_es-DYc7i3SM.js +0 -1
  30. package/dist-embed-sighting-editor/UfoMessages_fr-B7ekN0RL.js +0 -1
  31. package/dist-embed-sighting-editor/UfoMessages_it-BDc9SDxc.js +0 -1
@@ -2,7 +2,12 @@ const Z1="modulepreload",J1=function(r,t){return new URL(r,t).href},Z0={},is=fun
2
2
  <div class="stage" id="stage">
3
3
  <div class="frame" id="frame">
4
4
  <canvas id="scene-canvas"></canvas>
5
- <div id="scene-loader" class="scene-loader" role="progressbar" hidden></div>
5
+ <!-- The spinner, and under it what a reader waiting on a picture may take this for: a video. It is
6
+ not one — see SceneNames.notAVideo. Both live and die with the hold on the first frame. -->
7
+ <div id="scene-loader" class="scene-loader" role="progressbar" hidden>
8
+ <div class="scene-loader-spinner"></div>
9
+ <p id="scene-loader-note" class="scene-loader-note">This is not a video: it is a simulation, computed in real time in your browser.</p>
10
+ </div>
6
11
  </div>
7
12
  <div id="ufo-slot"></div>
8
13
  <div id="hover-tooltip" class="hover-tooltip" hidden></div>
@@ -142,17 +147,42 @@ const Z1="modulepreload",J1=function(r,t){return new URL(r,t).href},Z0={},is=fun
142
147
  a moment, so a sky that is ready at once never flashes a spinner. */
143
148
  .scene-loader {
144
149
  position: absolute;
145
- top: 50%;
146
- left: 50%;
150
+ inset: 0;
151
+ display: flex;
152
+ flex-direction: column;
153
+ align-items: center;
154
+ justify-content: center;
155
+ gap: 1em;
156
+ animation: scene-loader-appear 0.2s ease-out 0.25s both;
157
+ pointer-events: none;
158
+ z-index: 1;
159
+ }
160
+ .scene-loader[hidden] {
161
+ display: none;
162
+ }
163
+ .scene-loader-spinner {
147
164
  width: 36px;
148
165
  height: 36px;
149
- margin: -18px 0 0 -18px;
150
166
  border-radius: 50%;
151
167
  border: 3px solid rgba(255, 255, 255, 0.25);
152
168
  border-top-color: rgba(255, 255, 255, 0.9);
153
- animation: scene-loader-spin 0.9s linear infinite, scene-loader-appear 0.2s ease-out 0.25s both;
154
- pointer-events: none;
155
- z-index: 1;
169
+ animation: scene-loader-spin 0.9s linear infinite;
170
+ }
171
+ /* What the waiting picture is NOT: a video. Said only while it waits, and only where there is room
172
+ for a sentence — a catalogue card's picture is too small for one. */
173
+ .scene-loader-note {
174
+ max-width: 24em;
175
+ margin: 0;
176
+ padding: 0 1.5em;
177
+ color: #fff;
178
+ font: 0.9em/1.4 sans-serif;
179
+ text-align: center;
180
+ text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
181
+ }
182
+ @container (max-width: 360px) {
183
+ .scene-loader-note {
184
+ display: none;
185
+ }
156
186
  }
157
187
  @keyframes scene-loader-spin {
158
188
  to { transform: rotate(360deg); }
@@ -300,6 +330,9 @@ const Z1="modulepreload",J1=function(r,t){return new URL(r,t).href},Z0={},is=fun
300
330
  <!-- Everything else, on one shape: the toggles parsed above land here, then the fullscreen
301
331
  button that closes the row. -->
302
332
  <div class="controls-right" id="controls-right">
333
+ <!-- Only in a player too narrow for everything: it folds the buttons below away, and unfolds
334
+ them over the ones on the left (see UfoElement.fitControls). -->
335
+ <button id="controls-more" type="button" class="controls-more" title="More" aria-label="More" aria-expanded="false"></button>
303
336
  <button id="fullscreen" type="button" title="Fullscreen" aria-label="Fullscreen"></button>
304
337
  </div>
305
338
  </div>
@@ -947,6 +980,7 @@ canvas[data-cursor="rotate"] {
947
980
  min-width: 0;
948
981
  }
949
982
  .controls-right {
983
+ margin-left: auto;
950
984
  padding: 0.25em 0.3em;
951
985
  border-radius: 1.3em;
952
986
  background: rgba(0, 0, 0, 0.45);
@@ -987,6 +1021,29 @@ canvas[data-cursor="rotate"] {
987
1021
  background-image: linear-gradient(rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.2));
988
1022
  color: #fff;
989
1023
  }
1024
+ /* A player with no room for everything (see UfoElement.fitControls): the buttons fold behind a
1025
+ chevron, the fullscreen button staying in sight; unfolded, they take the row over from the play
1026
+ button, the sound and the time, which come back when it is folded again. */
1027
+ .controls-more {
1028
+ display: none !important;
1029
+ }
1030
+ .controls.narrow .controls-more {
1031
+ display: inline-flex !important;
1032
+ }
1033
+ .controls.narrow:not(.more-open) .controls-right > :not(.controls-more):not(#fullscreen) {
1034
+ display: none !important;
1035
+ }
1036
+ .controls.narrow.more-open .controls-left {
1037
+ display: none;
1038
+ }
1039
+ /* Further steps of the same fit: the length of the recording goes from the time, then the sound. */
1040
+ .controls.compact .time-separator,
1041
+ .controls.compact #time-end {
1042
+ display: none;
1043
+ }
1044
+ .controls.tiny .volume {
1045
+ display: none;
1046
+ }
990
1047
  /* A toggle that is on says so by its glyph, solid where it was an outline — see PlayerIcons. */
991
1048
  .controls button svg {
992
1049
  display: block;
@@ -1091,17 +1148,17 @@ canvas[data-cursor="rotate"] {
1091
1148
  pointer-events: none;
1092
1149
  white-space: nowrap;
1093
1150
  }
1094
- `,jo=[{id:"eye",name:"Naked eye",flare:0,projection:"equidistant",stabilization:.97},{id:"rectilinear-lens",name:"Camera, unknown device",projection:"rectilinear",fNumber:8,fNumberRange:{min:2,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:8},apertureBlades:6},{id:"instamatic-126",name:"Instamatic, 126 film",projection:"rectilinear",frame:{widthMm:28,heightMm:28,focalLengthMm:43},fNumber:11,exposureSeconds:1/90,years:{from:1963,to:1988},apertureBlades:5,detailUm:20,medium:{kind:"negative",iso:64}},{id:"slr-35mm-50",name:"35 mm SLR, 50 mm lens",projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:50},fNumber:8,fNumberRange:{min:2,max:16},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},years:{from:1959},apertureBlades:6,detailUm:20,medium:{kind:"negative",iso:100}},{id:"slr-35mm-zoom",name:"35 mm SLR, 70-210 mm zoom",projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:135,focalRangeMm:{minMm:70,maxMm:210}},fNumber:8,fNumberRange:{min:4,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},apertureBlades:8,years:{from:1975},detailUm:20,medium:{kind:"negative",iso:100}},{id:"phone-landscape",name:"Phone, held sideways",projection:"rectilinear",frame:{widthMm:7.6,heightMm:5.7,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4,medium:{kind:"sensor",iso:100,autoExposure:!0}},{id:"phone-portrait",name:"Phone, held upright",projection:"rectilinear",frame:{widthMm:5.7,heightMm:7.6,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4,medium:{kind:"sensor",iso:100,autoExposure:!0}}];class fi{static get default(){return jo[0]}static byId(t){return jo.find(e=>e.id===t)??this.default}static UNAIDED_FIELD_DEG=60;static UNAIDED_ASPECT=16/9;static fieldOfViewDeg(t){const e=t.frame;return e?2*Math.atan(e.heightMm/(2*e.focalLengthMm))*180/Math.PI:fi.UNAIDED_FIELD_DEG}static aspectOf(t){const e=t.frame;return e?e.widthMm/e.heightMm:fi.UNAIDED_ASPECT}static frameWidthPx(t,e){return Math.round(e*fi.aspectOf(t))}static availableAt(t){return t===void 0?jo:jo.filter(e=>!e.years||t>=e.years.from&&(e.years.to===void 0||t<=e.years.to))}static fieldOfViewDegAt(t,e){const i=t.frame;if(!(!i||e<=0))return 2*Math.atan(i.heightMm/(2*e))*180/Math.PI}static focalLengthMmFor(t,e){const i=t.frame;if(!(!i||e<=0||e>=180))return i.heightMm/(2*Math.tan(e*Math.PI/360))}static bladesShowing(t,e){const i=e??t.fNumber;if(i===void 0||t.apertureBlades===void 0)return 0;const n=t.fNumberRange;return!n||n.max<=n.min?1:Math.max(0,Math.min(1,(i-n.min)/(n.max-n.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(t){return t.flare??fi.LENS_FLARE_ARTIFACTS}static starPointsOf(t){const e=t.apertureBlades;return e===void 0||e<3?0:e%2===0?e:e*2}}class xr{constructor(t){this.points=t}static STATIONARY_M=5;static of(t){const e=[];for(const i of t.observerTrack.allKeyframes){const{lat:n,lng:s,headingDeg:a}=i.pose;n===void 0||s===void 0||e.push({t:i.t,lat:n,lng:s,headingDeg:a})}if(e.length===0){const i=t.event.place?.[0];if(!i)return;e.push({t:0,lat:i.lat,lng:i.lng})}return new xr(e)}static TRAVEL_M=50;get travels(){return this.spanM>xr.TRAVEL_M}get moved(){return this.spanM>xr.STATIONARY_M}get spanM(){const t=this.box,e=(t.south+t.north)/2,i=(t.west+t.east)/2;return Math.max(Math.abs(ai(e,t.east,e,t.west).x),Math.abs(ai(t.north,i,t.south,i).z))}get center(){const t=this.box;return{lat:(t.south+t.north)/2,lng:(t.west+t.east)/2}}boundsAround(t,e){const{lat:i,lng:n}=this.center,s=Math.max(this.spanM*(1+e),t)/2;return{north:_s(0,-s,i,n).lat,south:_s(0,s,i,n).lat,east:_s(s,0,i,n).lng,west:_s(-s,0,i,n).lng}}get box(){const t=this.points.map(i=>i.lat),e=this.points.map(i=>i.lng);return{south:Math.min(...t),north:Math.max(...t),west:Math.min(...e),east:Math.max(...e)}}}class mn{constructor(t,e){this.rotationPassed=t,this.scale=e}static SWAY_M=.012;static BREATH_M=.003;static DRIFT_YAW_DEG=.5;static DRIFT_PITCH_DEG=.4;static DRIFT_ROLL_DEG=.3;static GAZE_DRIFT_SHARE=.35;static HAND_HELD_S=.5;static HZ=[.11,.23,.17,.29,.37,.07];static of(t){const e=t.event.tags?.includes("paralysis")||(t.exposure??0)>mn.HAND_HELD_S,i=t.sway??(e?0:1);if(i>0)return new mn(Math.max(1-(t.instrument.stabilization??0),mn.GAZE_DRIFT_SHARE),i)}offsetAt(t){const e=t/1e3,i=this.scale,n=(u,d)=>Math.sin(2*Math.PI*u*e+d),[s,a,o,c,l,h]=mn.HZ;return{eastM:i*mn.SWAY_M*(.7*n(s,.3)+.3*n(c,1.9)),northM:i*mn.SWAY_M*(.6*n(o,2.2)+.4*n(l,.8)),upM:i*mn.BREATH_M*n(a,0),yawDeg:i*this.rotationPassed*mn.DRIFT_YAW_DEG*(.6*n(h,1.1)+.4*n(c,2.7)),pitchDeg:i*this.rotationPassed*mn.DRIFT_PITCH_DEG*(.5*n(a,1.6)+.5*n(o,.4)),rollDeg:i*this.rotationPassed*mn.DRIFT_ROLL_DEG*n(s,2.9)}}}class _e{constructor(t,e){this.stretches=t,this.rotationPassed=e}static REFERENCE_SPEED_M_PER_S=1.4;static REFERENCE_STEP_HZ=1.9;static CADENCE_EXPONENT=.43;static RISE_M_PER_M_PER_S=.0175;static SWAY_M=.0175;static SLOWEST_WALK_M_PER_S=.2;static FASTEST_WALK_M_PER_S=2.2;static HEAD_ROLL_DEG=1.5;static HEAD_PITCH_DEG=1.25;static HEAD_YAW_DEG=1;static STOP_LURCH_M=.035;static STOP_PITCH_DEG=3;static START_LURCH_M=.015;static START_PITCH_DEG=1.2;static JOLT_HZ=1.4;static JOLT_DECAY_S=.35;static JOLT_LASTS_MS=1500;static STILL=Object.freeze({eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0});static of(t){const e=xr.of(t);if(!e||e.points.length<2)return;const i=[];let n=0;for(let s=1;s<e.points.length;s++){const a=e.points[s-1],o=e.points[s],c=(o.t-a.t)/1e3;if(c<=0)continue;const l=ai(o.lat,o.lng,a.lat,a.lng),h=l.x,u=-l.z,d=Math.hypot(h,u),f=d/c,p=_e.stepHzFor(f);i.push({startMs:a.t,endMs:o.t,speedMPerS:f,eastUnit:d>0?h/d:0,northUnit:d>0?u/d:0,stepHz:p,stepsBefore:n,rampsIn:!0,rampsOut:!0}),n+=p*c}for(let s=0;s<i.length;s++){const a=i[s-1],o=i[s+1];i[s].rampsIn=a===void 0||a.stepHz===0,i[s].rampsOut=o===void 0||o.stepHz===0}if(i.some(s=>s.stepHz>0))return new _e(i,1-(t.instrument.stabilization??0))}static bodyAt(t,e,i=!1){const n=_e.of(t)?.offsetAt(e)??_e.STILL;return i?n:_e.add(n,mn.of(t)?.offsetAt(e))}static stepHzFor(t){return t<_e.SLOWEST_WALK_M_PER_S||t>_e.FASTEST_WALK_M_PER_S?0:_e.REFERENCE_STEP_HZ*Math.pow(t/_e.REFERENCE_SPEED_M_PER_S,_e.CADENCE_EXPONENT)}offsetAt(t){return _e.add(this.cycleAt(t),this.joltAt(t))}joltAt(t){for(const e of this.stretches){if(e.stepHz===0)continue;const i=e.speedMPerS/_e.REFERENCE_SPEED_M_PER_S,n=(o,c,l,h)=>{if(o<0||o>_e.JOLT_LASTS_MS)return;const u=o/1e3,d=Math.exp(-u/_e.JOLT_DECAY_S)*Math.sin(2*Math.PI*_e.JOLT_HZ*u),f=h*c*i*d;return{eastM:f*e.eastUnit,northM:f*e.northUnit,upM:-Math.abs(f)*.3,rollDeg:0,pitchDeg:-h*l*i*d*this.rotationPassed,yawDeg:0}},s=e.rampsOut?n(t-e.endMs,_e.STOP_LURCH_M,_e.STOP_PITCH_DEG,1):void 0;if(s)return s;const a=e.rampsIn?n(t-e.startMs,_e.START_LURCH_M,_e.START_PITCH_DEG,-1):void 0;if(a)return a}}static add(t,e){return e?{eastM:t.eastM+e.eastM,northM:t.northM+e.northM,upM:t.upM+e.upM,rollDeg:t.rollDeg+e.rollDeg,pitchDeg:t.pitchDeg+e.pitchDeg,yawDeg:t.yawDeg+e.yawDeg}:t}cycleAt(t){const e=this.stretches.find(c=>t>=c.startMs&&t<=c.endMs);if(!e||e.stepHz===0)return _e.STILL;const i=e.stepsBefore+e.stepHz*(t-e.startMs)/1e3,n=2*Math.PI*i,s=this.amplitudeAt(e,t),a=_e.SWAY_M*s*Math.cos(n/2),o=s*this.rotationPassed*e.speedMPerS/_e.REFERENCE_SPEED_M_PER_S;return{eastM:a*e.northUnit,northM:-a*e.eastUnit,upM:_e.RISE_M_PER_M_PER_S*e.speedMPerS*s*Math.cos(n),rollDeg:_e.HEAD_ROLL_DEG*o*Math.cos(n/2),pitchDeg:-1.25*o*Math.cos(n),yawDeg:_e.HEAD_YAW_DEG*o*Math.cos(n/2)}}amplitudeAt(t,e){const i=1e3/t.stepHz,n=Math.min(i,(t.endMs-t.startMs)/2);if(n<=0)return 1;const s=e-t.startMs,a=t.endMs-e,o=Math.min(t.rampsIn?s/n:1,t.rampsOut?a/n:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class Te{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(t){return 2*Math.atan(t.sizeM/(2*t.distanceM))*180/Math.PI}static inMoons(t){return t/Te.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(t,e,i){if(!(!t||!e))return{widthDeg:t.widthDeg+(e.widthDeg-t.widthDeg)*i,heightDeg:t.heightDeg+(e.heightDeg-t.heightDeg)*i}}static sizeMAt(t,e){return 2*t*Math.tan(e*Math.PI/360)}static distanceMAt(t,e){return t/(2*Math.tan(e*Math.PI/360))}}function rv(r,t,e){if(!r||!t)return e<1?r:t;const i=((t.azimuthDeg-r.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((r.azimuthDeg+i*e)%360+360)%360,altitudeDeg:r.altitudeDeg+(t.altitudeDeg-r.altitudeDeg)*e}}function ov(r,t,e){const{bounds:i}=r;return t>=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i.height}function Ki(r,t,e){return r+(t-r)*e}function tf(r){const t=/^#([0-9a-f]{6})$/i.exec(r);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function cv(r){return`#${r.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function lv(r,t,e){const i=tf(r),n=tf(t);return!i||!n?e<1?r:t:cv([Ki(i[0],n[0],e),Ki(i[1],n[1],e),Ki(i[2],n[2],e)])}function hv(r,t,e){const i={x:Ki(r.bounds.x,t.bounds.x,e),y:Ki(r.bounds.y,t.bounds.y,e),width:Ki(r.bounds.width,t.bounds.width,e),height:Ki(r.bounds.height,t.bounds.height,e)},n=Ki(r.angle,t.angle,e),s=Ki(r.transparency,t.transparency,e),a=Ki(r.haloScale,t.haloScale,e),o=Ki(r.blur??0,t.blur??0,e),c=Ki(r.brightness??0,t.brightness??0,e),l=lv(r.color,t.color,e),h=Te.lerpAngular(r.angular,t.angular,e),u=rv(r.aim,t.aim,e);return r.kind==="polygon"&&t.kind==="polygon"&&r.points.length===t.points.length?{...r,bounds:i,angle:n,transparency:s,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u,points:r.points.map((d,f)=>({x:Ki(d.x,t.points[f].x,e),y:Ki(d.y,t.points[f].y,e)}))}:{...e<1?r:t,bounds:i,angle:n,transparency:s,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u}}class ga{static DEFAULT_COLOR="#e8e6df";static complete(t,e=[]){const i=new Map;return t.map((n,s)=>({keyframe:n,index:s})).sort((n,s)=>n.keyframe.t-s.keyframe.t).map(({keyframe:n,index:s})=>({t:n.t,shapes:(n.shapes??[]).map((a,o)=>{const c=`timeline.keyframes.${s}.shapes.${o}.shape`,l=ga.completed(a,i.get(a.sourceId),c,e);return i.set(a.sourceId,l),{sourceId:a.sourceId,shape:l}})}))}static completed(t,e,i,n){const s=t.shape??{},a=e??ga.firstAppearance(s,i,n),o={...a};s.bounds&&e&&(e.aim||e.angular)&&!s.aim&&!s.angular&&n.push({kind:"pixels-over-angles",path:i}),s.bounds&&(s.aim||delete o.aim,s.angular||delete o.angular);const c=s.kind??a.kind??"oval",l={...o,...s,kind:c};if(c==="polygon"&&!l.points){n.push({kind:"defaulted",path:`${i}.points`,expected:"rectangle"});const{width:h,height:u}=l.bounds;return{...l,points:[{x:0,y:0},{x:h,y:0},{x:h,y:u},{x:0,y:u}]}}return l}static firstAppearance(t,e,i){return t.kind||i.push({kind:"defaulted",path:`${e}.kind`,expected:'"oval"'}),t.color||i.push({kind:"defaulted",path:`${e}.color`,expected:`"${ga.DEFAULT_COLOR}"`}),!t.bounds&&!t.aim&&i.push({kind:"unplaced",path:e}),!t.bounds&&!t.angular&&i.push({kind:"unsized",path:e}),{kind:t.kind??"oval",bounds:{...ga.NEUTRAL_BOUNDS},color:ga.DEFAULT_COLOR,angle:0,transparency:0,haloScale:0,selected:!1}}static NEUTRAL_BOUNDS={x:Te.CANVAS_WIDTH_PX/2,y:Te.CANVAS_HEIGHT_PX/2,width:1,height:1}}class Ul{keyframes=[];order=[];groups=[];addKeyframe(t,e){const i=this.findInsertIndex(t);if(this.keyframes[i]?.t===t){const n=new Set(e.map(s=>s.sourceId));this.keyframes[i]={t,shapes:[...this.keyframes[i].shapes.filter(s=>!n.has(s.sourceId)),...e]}}else this.keyframes.splice(i,0,{t,shapes:[...e]});for(const n of e)this.order.includes(n.sourceId)||this.order.push(n.sourceId)}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e];return i?.t===t?i:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(i=>i.sourceId===e)?.shape}getLatestShapeAt(t,e){let i=this.findInsertIndex(t);for(this.keyframes[i]?.t!==t&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return n.shape}}getInterpolatedShapeAt(t,e){const i=this.findShapeAtOrBefore(t,e);if(i?.t===t)return i.shape;const n=this.findShapeAtOrAfter(t,e);return i?n?hv(i.shape,n.shape,(t-i.t)/(n.t-i.t)):i.shape:n?.shape}findShapeAtOrBefore(t,e){let i=this.findInsertIndex(t);for(this.keyframes[i]?.t!==t&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}findShapeAtOrAfter(t,e){for(let i=this.findInsertIndex(t);i<this.keyframes.length;i++){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}hitTest(t,e,i,n){const s=this.sourceIds;for(let a=s.length-1;a>=0;a--){if(n?.has(s[a]))continue;const o=this.getInterpolatedShapeAt(t,s[a]);if(o&&ov(o,e,i))return{sourceId:s[a],shape:o}}}removeSource(t){for(let e=this.keyframes.length-1;e>=0;e--){const i=this.keyframes[e].shapes.filter(n=>n.sourceId!==t);i.length===0?this.keyframes.splice(e,1):i.length!==this.keyframes[e].shapes.length&&(this.keyframes[e]={t:this.keyframes[e].t,shapes:i})}this.order=this.order.filter(e=>e!==t),this.removeFromGroup(t)}group(t){if(!(t.length<2)){for(const e of t)this.removeFromGroup(e);this.groups.push([...t])}}ungroup(t){const e=this.groups.findIndex(i=>i.includes(t));e!==-1&&this.groups.splice(e,1)}groupMembers(t){return this.groups.find(e=>e.includes(t))}removeFromGroup(t){const e=this.groups.findIndex(n=>n.includes(t));if(e===-1)return;const i=this.groups[e].filter(n=>n!==t);i.length<2?this.groups.splice(e,1):this.groups[e]=i}bringToFront(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.push(t))}sendToBack(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.unshift(t))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes,order:this.order,groups:this.groups}}static fromJSON(t,e){const i=new Ul;for(const n of ga.complete(t.keyframes??[],e))i.addKeyframe(n.t,n.shapes);if(t.order){const n=i.order.filter(s=>!t.order.includes(s));i.order=[...t.order,...n]}return t.groups&&(i.groups=t.groups.map(n=>n.filter(s=>i.order.includes(s))).filter(n=>n.length>=2)),i}}function uv(r,t,e){return Math.max(t,Math.min(e,r))}function dv(r,t,e){const i=((t-r)%360+540)%360-180;return((r+i*e)%360+360)%360}function Ha(r,t,e){return r+(t-r)*e}function fv(r,t,e){return{lat:r.lat===void 0||t.lat===void 0?void 0:Ha(r.lat,t.lat,e),lng:r.lng===void 0||t.lng===void 0?void 0:Ha(r.lng,t.lng,e),elevationM:Ha(r.elevationM,t.elevationM,e),headingDeg:r.headingDeg===void 0||t.headingDeg===void 0?void 0:dv(r.headingDeg,t.headingDeg,e),pitchDeg:Ha(r.pitchDeg,t.pitchDeg,e),rollDeg:Ha(r.rollDeg??0,t.rollDeg??0,e),fovDeg:Ha(r.fovDeg,t.fovDeg,e),fNumber:r.fNumber,focusDistanceM:r.focusDistanceM}}class Da{static at(t,e,i,n,s){const a=t[i],c=t[i+1]-a;if(c<=0)return e[i];const l=Da.tangent(t,e,i,s),h=Da.tangent(t,e,i+1,s),u=(n-a)/c,d=u*u,f=d*u;return(2*f-3*d+1)*e[i]+(f-2*d+u)*c*l+(-2*f+3*d)*e[i+1]+(f-d)*c*h}static BRAKE_S=.8;static paced(t,e,i,n){if(!i&&!n)return t;const s=e>0?Math.min(.5,Da.BRAKE_S/e):.5;if(i&&n){const o=1/(1-s);return t<=s?o*t*t/(2*s):t>=1-s?1-o*(1-t)*(1-t)/(2*s):o*(t-s/2)}const a=o=>{const c=1/(1-s/2);if(o<=1-s)return c*o;const l=o-(1-s);return c*(1-s)+c*(l-l*l/(2*s))};return n?a(t):1-a(1-t)}static tangent(t,e,i,n){const s=t.length-1,a=f=>(e[f+1]-e[f])/(t[f+1]-t[f]||1);if(i===0)return n?0:a(0);if(i===s)return n?0:a(s-1);const o=a(i-1),c=a(i);if(o*c<=0)return 0;const l=t[i]-t[i-1],h=t[i+1]-t[i],u=2*h+l,d=h+2*l;return(u+d)/(u/o+d/c)}}class Po{keyframes=[];addKeyframe(t,e){const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,pose:e}:this.keyframes.splice(i,0,{t,pose:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}getLatestPoseAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].pose:void 0}getInterpolatedPoseAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.pose;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!i)return n?.pose;if(!n)return i.pose;const s=fv(i.pose,n.pose,uv((t-i.t)/(n.t-i.t),0,1));return this.humanly(e-1,t,s)}humanly(t,e,i){const n=Math.max(0,t-1),s=Math.min(this.keyframes.length-1,t+2),a=this.keyframes.slice(n,s+1),o=t-n,c=a.map(y=>y.t),l=(y,M)=>{const b=a.map(w=>y(w.pose));if(!b.some(w=>w===void 0))return Da.at(c,b,o,e,M)},h=a.map(y=>y.pose.headingDeg);let u;if(h.every(y=>y!==void 0)){const y=[h[0]];for(let M=1;M<h.length;M++)y.push(y[M-1]+((h[M]-h[M-1])%360+540)%360-180);u=(Da.at(c,y,o,e,!0)%360+360)%360}const d=this.keyframes[t],f=this.keyframes[t+1],p=(y,M)=>y.lat===M.lat&&y.lng===M.lng&&y.elevationM===M.elevationM,v=!p(d.pose,f.pose),m=v&&t>0&&p(this.keyframes[t-1].pose,d.pose),g=v&&t+2<this.keyframes.length&&p(f.pose,this.keyframes[t+2].pose);let S;if(m||g){const y=Da.paced((e-d.t)/(f.t-d.t),(f.t-d.t)/1e3,m,g),M=(b,w)=>b===void 0||w===void 0?void 0:b+(w-b)*y;S={lat:M(d.pose.lat,f.pose.lat),lng:M(d.pose.lng,f.pose.lng),elevationM:M(d.pose.elevationM,f.pose.elevationM)}}return{...i,lat:S?S.lat:l(y=>y.lat,!1)??i.lat,lng:S?S.lng:l(y=>y.lng,!1)??i.lng,elevationM:S?S.elevationM:l(y=>y.elevationM,!1)??i.elevationM,headingDeg:u??i.headingDeg,pitchDeg:l(y=>y.pitchDeg,!0)??i.pitchDeg,rollDeg:l(y=>y.rollDeg??0,!0)??i.rollDeg,fovDeg:l(y=>y.fovDeg,!0)??i.fovDeg}}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Po;for(const i of t.keyframes)e.addKeyframe(i.t,i.pose);return e}}class Ws{static MAX_CHANGE_PER_S=.05;points;followed;constructor(t){let e="none",i=0;this.points=t.map(({t:n,weather:s})=>(s.precipitationType!=="none"&&(e=s.precipitationType,i=s.precipitationIntensity),{t:n,lastFalling:e,lastFallingIntensity:i,intensity:s.precipitationType==="none"?0:s.precipitationIntensity,type:s.precipitationType})),this.followed=[];for(let n=0;n<this.points.length;n++){if(n===0){this.followed.push(this.points[0].intensity);continue}const s=this.points[n-1],a=this.points[n];this.followed.push(Ws.follow(this.followed[n-1],s.intensity,a.intensity,(a.t-s.t)/1e3,(a.t-s.t)/1e3))}}at(t){if(this.points.length===0||t<this.points[0].t)return;let e=this.points.length-1;for(;e>0&&this.points[e].t>t;)e--;const i=this.points[e],n=this.points[e+1],s=n?Ws.follow(this.followed[e],i.intensity,n.intensity,(n.t-i.t)/1e3,(t-i.t)/1e3):Ws.follow(this.followed[e],i.intensity,i.intensity,1,(t-i.t)/1e3);return{type:Ws.typeBetween(i,n,t,s),intensity:s,character:Ws.characterBetween(i,n,t)}}static characterBetween(t,e,i){return t.type==="none"?e&&e.type!=="none"?e.intensity:t.lastFallingIntensity:!e||e.type==="none"?t.intensity:t.intensity+(e.intensity-t.intensity)*(i-t.t)/(e.t-t.t||1)}static typeBetween(t,e,i,n){return t.type==="none"?e&&e.type!=="none"&&i>t.t?e.type:n>0?t.lastFalling:"none":e&&e.type==="none"&&n<=0?"none":t.type}static follow(t,e,i,n,s){const a=Ws.MAX_CHANGE_PER_S,o=n>0?(i-e)/n:0,c=u=>e+o*Math.min(Math.max(u,0),n);let l=t,h=0;for(let u=0;u<8&&h<s;u++){const d=c(h)-l;if(Math.abs(d)<1e-9){const y=h<n?o:0;if(Math.abs(y)<=a){const b=h<n?Math.min(s,n):s;l=c(b),h=b;continue}const M=Math.min(s,n);l+=Math.sign(y)*a*(M-h),h=M;continue}const f=Math.sign(d),p=h<n?o:0,v=a-f*p,m=v>0?h+Math.abs(d)/v:1/0,g=h<n?n:1/0,S=Math.min(s,m,g);l+=f*a*(S-h),h=S,S===m&&(l=c(h))}return Math.min(1,Math.max(0,l))}}function ze(r,t,e){return r+(t-r)*e}function jd(r,t,e){const i=((t-r)%360+540)%360-180;return((r+i*e)%360+360)%360}function pv(r,t,e){return Math.max(t,Math.min(e,r))}function mv(r=[],t=[],e){if(!(!r.length&&!t.length))return[...new Set([...r.map(i=>i.id),...t.map(i=>i.id)])].map(i=>{const n=r.find(c=>c.id===i),s=t.find(c=>c.id===i),a=n??{...s,density:0},o=s??{...n,density:0};return{...a,eastM:ze(a.eastM,o.eastM,e),northM:ze(a.northM,o.northM,e),baseM:ze(a.baseM,o.baseM,e),thicknessM:ze(a.thicknessM,o.thicknessM,e),widthM:ze(a.widthM,o.widthM,e),depthM:ze(a.depthM,o.depthM,e),rotationDeg:jd(a.rotationDeg,o.rotationDeg,e),density:ze(a.density,o.density,e),darkness:ze(a.darkness??0,o.darkness??0,e)}})}function gv(r,t,e){if(r.cloudLayers===void 0&&t.cloudLayers===void 0)return;const i=dl(r),n=dl(t);return e>=1?n.map(a=>({...a})):[...new Set([...i.map(a=>a.id),...n.map(a=>a.id)])].map(a=>{const o=i.find(u=>u.id===a),c=n.find(u=>u.id===a),l=o??{...c,coverage:0},h=c??{...o,coverage:0};return{...l,instances:mv(o?.instances,c?.instances,e),baseM:ze(l.baseM,h.baseM,e),thicknessM:ze(l.thicknessM,h.thicknessM,e),coverage:ze(l.coverage,h.coverage,e),sizeM:ze(l.sizeM,h.sizeM,e),density:ze(l.density,h.density,e),darkness:ze(l.darkness??r.cloudDarkness,h.darkness??t.cloudDarkness,e),iceCrystalAlignment:l.iceCrystalAlignment===void 0||h.iceCrystalAlignment===void 0?void 0:ze(l.iceCrystalAlignment,h.iceCrystalAlignment,e),windSpeed:l.windSpeed===void 0&&h.windSpeed===void 0?void 0:ze(l.windSpeed??r.windSpeed,h.windSpeed??t.windSpeed,e),windDirectionDeg:l.windDirectionDeg===void 0&&h.windDirectionDeg===void 0?void 0:jd(l.windDirectionDeg??r.windDirectionDeg,h.windDirectionDeg??t.windDirectionDeg,e)}})}function vv(r,t,e){return{cloudLayers:gv(r,t,e),cloudCover:ze(r.cloudCover,t.cloudCover,e),cloudDarkness:ze(r.cloudDarkness,t.cloudDarkness,e),highCloudCover:r.highCloudCover===void 0||t.highCloudCover===void 0?void 0:ze(r.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:r.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:ze(r.iceCrystalAlignment,t.iceCrystalAlignment,e),lowerCloudCover:r.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:ze(r.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:r.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:ze(r.cloudBaseM,t.cloudBaseM,e),relativeHumidity:r.relativeHumidity===void 0||t.relativeHumidity===void 0?void 0:ze(r.relativeHumidity,t.relativeHumidity,e),precipitationType:e<1?r.precipitationType:t.precipitationType,precipitationIntensity:ze(r.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:jd(r.windDirectionDeg,t.windDirectionDeg,e),windSpeed:ze(r.windSpeed,t.windSpeed,e),storm:e<1?r.storm:t.storm}}class Lo{keyframes=[];ramp;addKeyframe(t,e){this.ramp=void 0;const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,weather:e}:this.keyframes.splice(i,0,{t,weather:e})}clear(){this.ramp=void 0,this.keyframes.length=0}removeKeyframeAt(t){this.ramp=void 0;const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}getLatestWeatherAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].weather:void 0}getInterpolatedWeatherAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.weather;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return i?n?vv(i.weather,n.weather,pv((t-i.t)/(n.t-i.t),0,1)):i.weather:n?.weather}getActualWeatherAt(t){const e=this.getInterpolatedWeatherAt(t);if(!e)return;const i=(this.ramp??=new Ws(this.keyframes)).at(t);if(!i)return e;const{type:n,intensity:s,character:a}=i,o=a>0?Math.min(1,s/a):n==="none"?0:1;return{...e,precipitationType:n,precipitationIntensity:a,precipitationAmount:o}}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Lo;for(const i of t.keyframes)e.addKeyframe(i.t,i.weather);return e}}class Oo{keyframes=[];addKeyframe(t,e){const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,sound:e}:this.keyframes.splice(i,0,{t,sound:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}getLatestSoundAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].sound:void 0}getInterpolatedSoundAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.sound;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!i)return n?.sound;if(!n)return i.sound;const s=(t-i.t)/(n.t-i.t);return this.lerp(i.sound,n.sound,Math.max(0,Math.min(1,s)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Oo;for(const i of t.keyframes)e.addKeyframe(i.t,i.sound);return e}lerp(t,e,i){return{kind:i<1?t.kind:e.kind,volume:t.volume+(e.volume-t.volume)*i,pitchHz:t.pitchHz+(e.pitchHz-t.pitchHz)*i,src:i<1?t.src:e.src}}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}}const Mv=100,xv={kind:"none",volume:0,pitchHz:Mv};class Mn{constructor(t){this.entries=t}static empty(){return new Mn(new Map)}get size(){return this.entries.size}at(t){return this.entries.get(t)}paths(){return[...this.entries.keys()]}set(t,e){e.basis==="stated"&&e.rationale===void 0?this.entries.delete(t):this.entries.set(t,e)}clear(t){for(const e of this.entries.keys())(e===t||e.startsWith(`${t}.`))&&this.entries.delete(e)}static strip(t){const e=new Mn(new Map);return{recording:Mn.stripValue(t,[],e),provenance:e}}static restore(t,e){if(e.size===0)return t;const i=structuredClone(t);for(const n of e.paths()){const s=e.at(n),a=n.split("."),o=Mn.holderOf(i,a);if(!o)continue;const c=a[a.length-1],l=o[c];l!==void 0&&(s.of!==void 0&&JSON.stringify(s.of)!==JSON.stringify(l)||(o[c]={value:l,...s.basis==="stated"?{}:{basis:s.basis},...s.rationale===void 0?{}:{rationale:s.rationale}}))}return i}static isWrapper(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&"value"in t}static stripValue(t,e,i){return Mn.isWrapper(t)?(i.set(e.join("."),{basis:t.basis??"stated",...t.rationale===void 0?{}:{rationale:t.rationale},of:t.value}),Mn.stripValue(t.value,e,i)):Array.isArray(t)?t.map((n,s)=>Mn.stripValue(n,[...e,String(s)],i)):typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t).map(([n,s])=>[n,Mn.stripValue(s,[...e,n],i)])):t}static holderOf(t,e){let i=t;for(const n of e.slice(0,-1)){if(typeof i!="object"||i===null)return;i=i[n]}return typeof i=="object"&&i!==null?i:void 0}}function bu(r){if(r.year!==void 0)return Date.UTC(r.year,(r.month??1)-1,r.day??1,r.hour??0,r.minute??0,r.second??0)}function ef(r){return(((r.day??0)*24+(r.hour??0))*60+(r.minute??0))*6e4+(r.second??0)*1e3}const yv=["year","month","day","hour","minute"],_v=["day","hour","minute"];function nf(r,t){return t.filter(e=>r[e]!==void 0).join(",")}function Sv(r){if(r.durationSeconds!==void 0)return r.durationSeconds*1e3;if(!r.time||!r.endTime)return;const t=r.time.year!==void 0&&r.endTime.year!==void 0,e=t?yv:_v,i=nf(r.time,e);if(!(i===""||i!==nf(r.endTime,e)))return t?bu(r.endTime)-bu(r.time):ef(r.endTime)-ef(r.time)}class kl{constructor(t,e,i,n,s,a,o,c,l=[],h,u,d,f=[],p=[],v=[]){this.event=t,this.timeline=e,this.observerTrack=i,this.weatherTrack=n,this.soundTrack=s,this.observer=a,this.id=o,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u,this.exposureSeconds=d,this.milestones=f,this.references=p,this.roads=v}provenance=Mn.empty();loadIssues=[];account;sources;interpretation;sway;lightPollution;iso;vehicle;get observerCount(){return 1+this.decor.filter(t=>t.kind==="observer").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return fi.byId(this.instrumentId)}static create(t,e,i){return new kl({eventType:"sighting",time:t,place:e},new Ul,new Po,new Lo,new Oo,i)}}const bv=0,wv=0;function di(r,t){const e=r.observerTrack.getInterpolatedPoseAt(t);if(e)return e;const i=r.event.place?.[0];if(i)return{lat:i.lat,lng:i.lng,elevationM:bv,headingDeg:void 0,pitchDeg:wv,fovDeg:fi.fieldOfViewDeg(r.instrument)}}function Gr(r,t){return r.weatherTrack.getInterpolatedWeatherAt(t)??r.weather??Jd}function sf(r,t){return r.weatherTrack.getActualWeatherAt(t)??r.weather??Jd}function Ev(r,t){return r.soundTrack.getInterpolatedSoundAt(t)??xv}class Av{constructor(t,e){this.timeline=t,this.onFrame=e}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const t=()=>{if(this.state!=="playing")return;const e=performance.now();if(this.currentT+=(e-this.lastWallTime)*this.playbackRate,this.lastWallTime=e,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(t){this.currentT=Math.max(0,Math.min(t,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(t){const e=new Map;for(const i of this.timeline.sourceIds){const n=this.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}this.onFrame(t,e)}}const sg=["nw","n","ne","e","se","s","sw","w"],Tv=24,Qo=8,Rv=3,Dv=8;function tc(r,t,e){const i=r.x-t.x,n=r.y-t.y,s=Math.cos(e),a=Math.sin(e);return{x:t.x+i*s-n*a,y:t.y+i*a+n*s}}function Vr(r){return{x:r.x+r.width/2,y:r.y+r.height/2}}const Iv={nw:{left:!0,top:!0},n:{top:!0},ne:{right:!0,top:!0},e:{right:!0},se:{right:!0,bottom:!0},s:{bottom:!0},sw:{left:!0,bottom:!0},w:{left:!0}};class cn{static handlePointsFor(t){const{x:e,y:i,width:n,height:s}=t.bounds,a={nw:{x:e,y:i},n:{x:e+n/2,y:i},ne:{x:e+n,y:i},e:{x:e+n,y:i+s/2},se:{x:e+n,y:i+s},s:{x:e+n/2,y:i+s},sw:{x:e,y:i+s},w:{x:e,y:i+s/2},rotate:{x:e+n/2,y:i-Tv}},o=Vr(t.bounds),c={};for(const l of Object.keys(a))c[l]=tc(a[l],o,t.angle);return c}static hitTestHandle(t,e,i=8,n=[...sg,"rotate"]){const s=cn.handlePointsFor(t);for(const a of n)if(Math.hypot(e.x-s[a].x,e.y-s[a].y)<=i)return a}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(t,e){const n=((cn.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,s=["ew","nwse","ns","nesw"];return s[Math.round(n)%s.length]}static resizeBounds(t,e,i,n){const s=Vr(t),a=tc(n,s,-e),{x:o,y:c,width:l,height:h}=t,u=Iv[i];let d=o,f=c,p=o+l,v=c+h;return u.left&&(d=Math.min(a.x,p-Qo)),u.right&&(p=Math.max(a.x,d+Qo)),u.top&&(f=Math.min(a.y,v-Qo)),u.bottom&&(v=Math.max(a.y,f+Qo)),{x:d,y:f,width:p-d,height:v-f}}static resizeShape(t,e,i){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:n,height:s}=t.bounds,a=cn.resizeBounds(t.bounds,t.angle,e,i);if(t.kind==="oval")return{...t,bounds:a};const o=n===0?1:a.width/n,c=s===0?1:a.height/s;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(t,e){const i=Vr(t.bounds),n=Math.atan2(e.y-i.y,e.x-i.x)+Math.PI/2;return{...t,angle:n}}static groupBoundsFor(t){const e=Math.min(...t.map(a=>a.x)),i=Math.min(...t.map(a=>a.y)),n=Math.max(...t.map(a=>a.x+a.width)),s=Math.max(...t.map(a=>a.y+a.height));return{x:e,y:i,width:n-e,height:s-i}}static vertexPointsFor(t){const e=Vr(t.bounds);return t.points.map(i=>tc({x:t.bounds.x+i.x,y:t.bounds.y+i.y},e,t.angle))}static hitTestVertex(t,e,i=Dv){const n=cn.vertexPointsFor(t);let s,a=i;return n.forEach((o,c)=>{const l=Math.hypot(e.x-o.x,e.y-o.y);l<=a&&(a=l,s=c)}),s}static toLocalPoint(t,e){const i=Vr(t.bounds),n=tc(e,i,-t.angle);return{x:n.x-t.bounds.x,y:n.y-t.bounds.y}}static moveVertex(t,e,i){const n=t.points.map((u,d)=>d===e?cn.toLocalPoint(t,i):u),s=Math.min(...n.map(u=>u.x)),a=Math.min(...n.map(u=>u.y)),o=Math.max(...n.map(u=>u.x)),c=Math.max(...n.map(u=>u.y)),l={x:t.bounds.x+s,y:t.bounds.y+a,width:o-s,height:c-a},h=n.map(u=>({x:u.x-s,y:u.y-a}));return{...t,bounds:l,points:h}}static insertVertexNear(t,e){const i=cn.toLocalPoint(t,e),{points:n}=t;let s=n.length-1,a=1/0;for(let c=0;c<n.length;c++){const l=n[c],h=n[(c+1)%n.length],u=cn.distanceToSegment(i,l,h);u<a&&(a=u,s=c)}const o=[...n.slice(0,s+1),i,...n.slice(s+1)];return{...t,points:o}}static distanceToSegment(t,e,i){const n=i.x-e.x,s=i.y-e.y,a=n*n+s*s,o=a===0?0:Math.max(0,Math.min(1,((t.x-e.x)*n+(t.y-e.y)*s)/a)),c=e.x+o*n,l=e.y+o*s;return Math.hypot(t.x-c,t.y-l)}static deleteVertex(t,e){return t.points.length<=Rv?t:{...t,points:t.points.filter((i,n)=>n!==e)}}}const wu=6,ec=wu/2,af=20,rf=24,of=9,cf=6,lf=7,hf=6,Gn=4;class No{constructor(t){this.ctx=t}starPoints=0;roll=0;clear(t,e){this.ctx.clearRect(0,0,t,e)}static paintExtent(t){const{x:e,y:i,width:n,height:s}=t.bounds,a=e+n/2,o=i+s/2,c=t.angle%(2*Math.PI)!==0,l=Math.hypot(n,s)/2,h=c?l:n/2,u=c?l:s/2,d=Math.max(n,s)/2,f=t.brightness??0,p=f>0?Math.max(d*(1+of*f),hf*f)-d:0,v=f>0?d*(1+lf*f)-d:0,m=3*rf*(t.blur??0)+1.5*af*t.haloScale,g=Math.max(p,v,0)+m+2;return{x:a-h-g,y:o-u-g,width:2*(h+g),height:2*(u+g)}}paintInto(t,e,i,n=!1){this.ctx.save(),this.ctx.scale(i,i),this.ctx.translate(-e.x,-e.y);const s=t.selected?{...t,selected:!1}:t;n?this.paintGhost(s,1.5):this.paintShape(s),this.ctx.restore()}paintShape(t){this.ctx.save(),this.ctx.globalAlpha=1-t.transparency;const e=t.blur??0;e>0&&(this.ctx.filter=`blur(${(rf*e).toFixed(2)}px)`);const i=t.brightness??0;i>0&&this.paintDazzle(t,i),t.haloScale>0&&this.paintHalo(t),this.paintBase(t),this.ctx.restore(),t.selected&&this.paintSelectionHandles(t)}setStarPoints(t){this.starPoints=Math.max(0,Math.floor(t))}setRoll(t){this.roll=t}paintDazzle(t,e){const{x:i,y:n,width:s,height:a}=t.bounds,o=i+s/2,c=n+a/2,l=Math.max(s,a)/2,h=Math.max(l*(1+of*e),hf*e);if(h<=0)return;this.ctx.save(),this.ctx.globalCompositeOperation="lighter";const u=this.ctx.createRadialGradient(o,c,0,o,c,h);for(let d=0;d<=cf;d++){const f=d/cf,p=1/(1+24*f*f);this.ctx.globalAlpha=1,u.addColorStop(f,this.withAlpha(t.color,p*e*.55))}if(this.ctx.fillStyle=u,this.ctx.beginPath(),this.ctx.arc(o,c,h,0,2*Math.PI),this.ctx.fill(),this.starPoints>0){const d=l*(1+lf*e);this.ctx.lineWidth=Math.max(1,l*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const p=f/this.starPoints*Math.PI*2+this.roll,v=o+Math.cos(p)*d,m=c+Math.sin(p)*d,g=this.ctx.createLinearGradient(o,c,v,m);g.addColorStop(0,this.withAlpha(t.color,e*.55)),g.addColorStop(.35,this.withAlpha(t.color,e*.22)),g.addColorStop(1,this.withAlpha(t.color,0)),this.ctx.strokeStyle=g,this.ctx.beginPath(),this.ctx.moveTo(o,c),this.ctx.lineTo(v,m),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(t,e){if(e<=0)return t.color;const i=/^#([0-9a-f]{6})$/i.exec(t.color.trim());if(!i)return t.color;const n=Number.parseInt(i[1],16),s=a=>Math.round(a+(255-a)*e);return`rgb(${s(n>>16&255)}, ${s(n>>8&255)}, ${s(n&255)})`}withAlpha(t,e){const i=Math.max(0,Math.min(1,e)),n=/^#([0-9a-f]{6})$/i.exec(t.trim());if(!n)return t;const s=Number.parseInt(n[1],16);return`rgba(${s>>16&255}, ${s>>8&255}, ${s&255}, ${i.toFixed(3)})`}paintBase(t){this.ctx.fillStyle=this.dazzledFill(t,t.brightness??0),this.tracePath(t),this.ctx.fill()}paintGhost(t,e){this.ctx.save(),this.tracePath(t),this.ctx.setLineDash([e*3,e*2]),this.ctx.lineWidth=e,this.ctx.strokeStyle=t.color,this.ctx.stroke(),this.ctx.restore()}tracePath(t){if(this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:i,width:n,height:s}=t.bounds,a=n/2,o=s/2;this.ctx.ellipse(e+a,i+o,a,o,t.angle,0,2*Math.PI)}else{const{x:e,y:i,width:n,height:s}=t.bounds;this.ctx.save(),this.ctx.translate(e+n/2,i+s/2),this.ctx.rotate(t.angle),this.ctx.translate(-n/2,-s/2),t.points.forEach((a,o)=>{o===0?this.ctx.moveTo(a.x,a.y):this.ctx.lineTo(a.x,a.y)}),this.ctx.closePath(),this.ctx.restore()}}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=af*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(cn.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of cn.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,Gn,Gn,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(cn.handlePointsFor(t))}paintSelectionOnly(t){this.paintSelectionHandles(t)}paintPictureFrame(t,e,i){const n=this.ctx;if(n.save(),t&&t.length===4){n.strokeStyle="#39f",n.lineWidth=1.5,n.setLineDash([6,4]),n.beginPath(),n.moveTo(t[0].x,t[0].y);for(const s of t.slice(1))n.lineTo(s.x,s.y);n.closePath(),n.stroke(),n.setLineDash([])}for(const s of e){const a=No.landmarkColour(s.residualDeg),o=s.selected?3:2;s.selected&&(n.strokeStyle="#fff",n.lineWidth=o+3,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,Gn+2,Gn+2,0,0,2*Math.PI),n.stroke()),s.scene&&(n.strokeStyle=a,n.lineWidth=1,n.beginPath(),n.moveTo(s.picture.x,s.picture.y),n.lineTo(s.scene.x,s.scene.y),n.stroke(),n.fillStyle=a,n.beginPath(),n.ellipse(s.scene.x,s.scene.y,Gn,Gn,0,0,2*Math.PI),n.fill()),n.strokeStyle=a,n.lineWidth=o,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,Gn+2,Gn+2,0,0,2*Math.PI),n.stroke(),this.paintLabel(s.label,s.picture.x+Gn+5,s.picture.y-Gn-2,a)}i&&this.paintLabel(i,8,8,"#fff",13),n.restore()}static landmarkColour(t){return t===void 0?"#ffb000":t<=1?"#3c3":t<=3?"#ffb000":"#f33"}paintLabel(t,e,i,n,s=11){const a=this.ctx;a.save(),a.font=`${s}px system-ui, sans-serif`,a.textBaseline="top";const o=a.measureText(t).width;a.fillStyle="rgba(0, 0, 0, 0.6)",a.fillRect(e-3,i-2,o+6,s+4),a.fillStyle=n,a.fillText(t,e,i),a.restore()}paintGroupHandles(t){this.paintHandleFrame(cn.handlePointsFor({bounds:t,angle:0}),{includeRotate:!0})}paintOutline(t){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(t.nw.x,t.nw.y),this.ctx.lineTo(t.ne.x,t.ne.y),this.ctx.lineTo(t.se.x,t.se.y),this.ctx.lineTo(t.sw.x,t.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(t,{includeRotate:e}){this.paintOutline(t),this.ctx.fillStyle="lightgray";for(const i of sg){const n=t[i];this.ctx.fillRect(n.x-ec,n.y-ec,wu,wu)}e&&(this.ctx.beginPath(),this.ctx.moveTo(t.n.x,t.n.y),this.ctx.lineTo(t.rotate.x,t.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(t.rotate.x,t.rotate.y,ec+1,ec+1,0,0,2*Math.PI),this.ctx.fill())}}const uf=.05,df=.08,ff=2,pf=3,Cv=14,Pv=.02;class Lv{context;voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;level=1;master;output(t){return this.master||(this.master=t.createGain(),this.master.gain.value=this.level,this.master.connect(t.destination)),this.master}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",t);return}}this.context.state==="suspended"&&this.context.resume()}setSound(t){if(this.requested=t,!this.context)return;const e=this.keyFor(t);if(!e){this.silence();return}if(this.voice?.key!==e){this.stopVoice();const i=++this.voiceToken;e.startsWith("src:")?this.buildRecordedVoice(t.src,e,i):this.voice=this.buildSynthesizedVoice(t,e)}this.applyTo(this.voice,t)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),this.context?.close(),this.context=void 0,this.master=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(t){if(!(t.volume<=0))return t.src?`src:${t.src}`:t.kind==="none"?void 0:t.kind}applyTo(t,e){const i=this.context;if(!t||!i)return;const n=i.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,n,uf);for(const{param:s,ratio:a}of t.pitch)s.setTargetAtTime(Math.min(e.pitchHz*a,i.sampleRate/2-1),n,uf)}buildSynthesizedVoice(t,e){const i=this.context;if(i)switch(t.kind){case"hum":return this.buildHum(i,e);case"whistle":return this.buildWhistle(i,e);case"rumble":return this.buildRumble(i,e);case"crackle":return this.buildCrackle(i,e);default:return}}buildHum(t,e){const i=t.createOscillator();i.type="sawtooth";const n=t.createOscillator();n.type="sawtooth";const s=t.createBiquadFilter();s.type="lowpass",s.Q.value=1;const a=t.createGain();return a.gain.value=0,i.connect(s),n.connect(s),s.connect(a).connect(this.output(t)),i.start(),n.start(),{key:e,nodes:[s,a],sources:[i,n],volumeParam:a.gain,gainScale:.16,pitch:[{param:i.frequency,ratio:1},{param:n.frequency,ratio:1.006},{param:s.frequency,ratio:6}]}}buildWhistle(t,e){const i=t.createOscillator();i.type="sine";const n=t.createOscillator();n.type="sine",n.frequency.value=5;const s=t.createGain(),a=t.createGain();return a.gain.value=0,n.connect(s).connect(i.frequency),i.connect(a).connect(this.output(t)),i.start(),n.start(),{key:e,nodes:[s,a],sources:[i,n],volumeParam:a.gain,gainScale:.22,pitch:[{param:i.frequency,ratio:1},{param:s.gain,ratio:.012}]}}buildRumble(t,e){const i=t.createBufferSource();i.buffer=this.brownNoise(t),i.loop=!0;const n=t.createBiquadFilter();n.type="lowpass",n.Q.value=.8;const s=t.createGain();return s.gain.value=0,i.connect(n).connect(s).connect(this.output(t)),i.start(),{key:e,nodes:[n,s],sources:[i],volumeParam:s.gain,gainScale:1.4,pitch:[{param:n.frequency,ratio:1}]}}buildCrackle(t,e){const i=t.createBufferSource();i.buffer=this.whiteNoise(t),i.loop=!0;const n=t.createBiquadFilter();n.type="bandpass",n.Q.value=1.2;const s=t.createGain();s.gain.value=0;const a=t.createBufferSource();a.buffer=this.crackleEnvelope(t),a.loop=!0;const o=t.createGain();return o.gain.value=0,a.connect(o).connect(s.gain),i.connect(n).connect(s).connect(this.output(t)),i.start(),a.start(),{key:e,nodes:[n,s,o],sources:[i,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:n.frequency,ratio:4}]}}async buildRecordedVoice(t,e,i){const n=this.context;if(!n)return;let s;try{s=await this.getBuffer(t)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(i!==this.voiceToken||!this.context)return;const a=n.createBufferSource();a.buffer=s,a.loop=!0;const o=n.createGain();o.gain.value=0,a.connect(o).connect(this.output(n)),a.start(),this.voice={key:e,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(t){const e=this.context;if(!e)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(t);return i||(i=fetch(t).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${t}`);return n.arrayBuffer()}).then(n=>e.decodeAudioData(n)),this.buffers.set(t,i)),i}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*ff),t.sampleRate),i=e.getChannelData(0);for(let n=0;n<i.length;n++)i[n]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*ff),t.sampleRate),i=e.getChannelData(0);let n=0,s=0;for(let a=0;a<i.length;a++)n=(n+.02*(Math.random()*2-1))/1.02,i[a]=n,s=Math.max(s,Math.abs(n));if(s>0)for(let a=0;a<i.length;a++)i[a]/=s;return e}crackleEnvelope(t){if(!this.crackleBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*pf),t.sampleRate),i=e.getChannelData(0),n=Math.max(1,Math.floor(Pv*t.sampleRate)),s=Math.round(pf*Cv);for(let a=0;a<s;a++){const o=Math.floor(Math.random()*i.length),c=.4+Math.random()*.6;for(let l=0;l<n&&o+l<i.length;l++)i[o+l]=Math.max(i[o+l],c*(1-l/n))}this.crackleBuffer=e}return this.crackleBuffer}stopVoice(){const t=this.voice,e=this.context;if(this.voice=void 0,!t||!e)return;const i=e.currentTime;t.volumeParam.cancelScheduledValues(i),t.volumeParam.setTargetAtTime(0,i,df/3);const n=i+df;for(const s of t.sources){s.onended=()=>{s.disconnect();for(const a of t.nodes)a.disconnect()};try{s.stop(n)}catch{s.disconnect();for(const a of t.nodes)a.disconnect()}}}}class ie{static svg(t){return`<svg viewBox="0 0 24 24" width="1.5em" height="1.5em" aria-hidden="true" focusable="false"><path d="${t}" fill="currentColor"/></svg>`}static outline(t){return`<svg viewBox="0 0 24 24" width="1.5em" height="1.5em" aria-hidden="true" focusable="false"><path d="${t}" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round" stroke-linecap="round"/></svg>`}static solid(t){return`<svg viewBox="0 0 24 24" width="1.5em" height="1.5em" aria-hidden="true" focusable="false"><path d="${t}" fill="currentColor" fill-rule="evenodd"/></svg>`}static BOOKMARK="M6 3.5h12a.5.5 0 0 1 .5.5v16.5L12 16.8l-6.5 3.7V4a.5.5 0 0 1 .5-.5z";static PICTURE="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z";static PICTURE_HILLS="M4.5 17.5l4.5-6 3 4 2.5-3 5 5z";static PIN="M12 21.5s-6.5-5.7-6.5-10.8a6.5 6.5 0 0 1 13 0c0 5.1-6.5 10.8-6.5 10.8z";static PIN_HOLE="M12 8.4a2.4 2.4 0 1 0 0 4.8 2.4 2.4 0 0 0 0-4.8z";static MILESTONES_OFF=ie.outline(ie.BOOKMARK);static MILESTONES_ON=ie.solid(ie.BOOKMARK);static PICTURES_OFF=ie.outline(`${ie.PICTURE}${ie.PICTURE_HILLS}`);static PICTURES_ON=ie.solid(`${ie.PICTURE}${ie.PICTURE_HILLS}`);static MAP_OFF=ie.outline(`${ie.PIN}${ie.PIN_HOLE}`);static MAP_ON=ie.solid(`${ie.PIN}${ie.PIN_HOLE}`);static PLAY=ie.svg("M7.4 5v14l11-7z");static PAUSE=ie.svg("M6 5h4v14H6zM14 5h4v14h-4z");static VOLUME=ie.svg("M2 9.5v5h3.5l4.5 4.5V5L5.5 9.5H2zm12.5 2.5A4 4 0 0 0 12.5 8.5v7A4 4 0 0 0 14.5 12zM12.5 4.2v2.1a6.5 6.5 0 0 1 0 11.4v2.1a8.6 8.6 0 0 0 0-15.6z");static MUTED=ie.svg("M2 9.5v5h3.5l4.5 4.5V5L5.5 9.5H2zM15 9.8l1.4-1.4 2.6 2.6 2.6-2.6 1.4 1.4-2.6 2.6 2.6 2.6-1.4 1.4-2.6-2.6-2.6 2.6-1.4-1.4 2.6-2.6z");static ENTER_FULLSCREEN=ie.svg("M5 5h5v2H7v3H5V5zm9 0h5v5h-2V7h-3V5zM5 14h2v3h3v2H5v-5zm12 0h2v5h-5v-2h3v-3z");static EXIT_FULLSCREEN=ie.svg("M8 5h2v5H5V8h3V5zm6 0h2v3h3v2h-5V5zM5 14h5v5H8v-3H5v-2zm9 0h5v2h-3v3h-2v-5z")}function _o(r){return[...r].sort((t,e)=>t.t-e.t)}function eh(r,t){let e;for(const i of _o(r)){if(i.t>t)break;e=i}return e}const ih=Math.PI/180,ic=180/Math.PI;class Ss{constructor(t,e,i){this.kind=t,this.canvasHeightPx=e,this.fovDeg=i;const n=i*ih/2;this.focalPx=t==="equidistant"?e/2/n:e/2/Math.tan(n)}focalPx;static of(t,e,i){return new Ss(t.projection,e,i)}degToPx(t){const e=t*ih;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*ic:2*Math.atan(t/(2*this.focalPx))*ic}angleDegToRadiusPx(t){const e=t*ih;return this.kind==="equidistant"?this.focalPx*e:this.focalPx*Math.tan(e)}halfWidthAngleDeg(t){return this.radiusPxToAngleDeg(this.canvasHeightPx*t/2)}radiusPxToAngleDeg(t){return this.kind==="equidistant"?t/this.focalPx*ic:Math.atan(t/this.focalPx)*ic}ofBounds(t){return{widthDeg:this.pxToDeg(t.width),heightDeg:this.pxToDeg(t.height)}}toBoundsSize(t){return{width:this.degToPx(t.widthDeg),height:this.degToPx(t.heightDeg)}}widthPx(t){return this.degToPx(Te.angularWidthDeg(t))}}class Ji{static fovOf(t,e){return di(t,e)?.fovDeg??fi.fieldOfViewDeg(t.instrument)}static toAngular(t){this.eachKeyframe(t,(e,i)=>({...e,angular:i.ofBounds(e.bounds)}))}static toBounds(t){this.eachKeyframe(t,(e,i)=>{if(!e.angular)return e;const{width:n,height:s}=i.toBoundsSize(e.angular),a={x:e.bounds.x+(e.bounds.width-n)/2,y:e.bounds.y+(e.bounds.height-s)/2,width:n,height:s};if(e.kind!=="polygon")return{...e,bounds:a};const o=e.bounds.width===0?1:n/e.bounds.width,c=e.bounds.height===0?1:s/e.bounds.height;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static toAim(t){this.eachKeyframe(t,(e,i,n)=>{const s=e.aim&&this.positionOf(t,e.aim,e.bounds,i,n);if(s&&Math.abs(s.x-e.bounds.x)<Ji.UNMOVED_PX&&Math.abs(s.y-e.bounds.y)<Ji.UNMOVED_PX)return e;const a=this.aimFrom(t,i,n,e.bounds);return a?{...e,aim:a}:e})}static UNMOVED_PX=.01;static aimOf(t,e,i){const n=Ss.of(t.instrument,Te.CANVAS_HEIGHT_PX,this.fovOf(t,e));return this.aimFrom(t,n,di(t,e),i)}static aimFrom(t,e,i,n){if(i?.headingDeg===void 0)return;const s=this.frameCentre(t),a=e.radiusPxToAngleDeg(n.x+n.width/2-s.x),o=e.radiusPxToAngleDeg(s.y-(n.y+n.height/2));return{azimuthDeg:((i.headingDeg+a)%360+360)%360,altitudeDeg:i.pitchDeg+o}}static toPosition(t){this.eachKeyframe(t,(e,i,n)=>{const s=e.aim&&this.positionOf(t,e.aim,e.bounds,i,n);return s?{...e,bounds:{...e.bounds,...s}}:e})}static positionOf(t,e,i,n,s){if(s?.headingDeg===void 0)return;const a=this.frameCentre(t),o=this.shortestArc(e.azimuthDeg-s.headingDeg),c=e.altitudeDeg-s.pitchDeg;return{x:a.x+this.offAxisPx(n,o)-i.width/2,y:a.y-this.offAxisPx(n,c)-i.height/2}}static frameCentre(t){return{x:fi.frameWidthPx(t.instrument,Te.CANVAS_HEIGHT_PX)/2,y:Te.CANVAS_HEIGHT_PX/2}}static shortestArc(t){return(t%360+540)%360-180}static offAxisPx(t,e){return Math.abs(e)>=Ji.OFF_CANVAS_DEG?Math.sign(e)*Ji.OFF_CANVAS_PX:t.angleDegToRadiusPx(e)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(t,e,i){const n=fi.frameWidthPx(e,Te.CANVAS_HEIGHT_PX)/2,s=fi.frameWidthPx(t.instrument,Te.CANVAS_HEIGHT_PX)/2,a=Te.CANVAS_HEIGHT_PX/2;for(const o of[...t.timeline.allKeyframes]){const c=this.fovOf(t,o.t),l=i?.get(o.t)??c,h=Ss.of(e,Te.CANVAS_HEIGHT_PX,l),u=Ss.of(t.instrument,Te.CANVAS_HEIGHT_PX,c);t.timeline.addKeyframe(o.t,o.shapes.map(d=>{const{bounds:f}=d.shape,p=f.x+f.width/2-n,v=f.y+f.height/2-a,m=Math.hypot(p,v),g=m===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(m))/m,S={...f,x:s+p*g-f.width/2,y:a+v*g-f.height/2};return{...d,shape:{...d.shape,bounds:S}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:i}=t;for(const n of[...i.allKeyframes]){const s=di(t,n.t),a=this.fovOf(t,n.t),o=Ss.of(t.instrument,Te.CANVAS_HEIGHT_PX,a);i.addKeyframe(n.t,n.shapes.map(c=>({...c,shape:e(c.shape,o,s)})))}}}function Ov(r){return Mn.restore(Nv(r),r.provenance)}function Nv(r){return Ji.toAngular(r),Ji.toAim(r),{version:1,id:r.id,time:r.event.time,endTime:r.event.endTime,durationSeconds:r.event.durationSeconds,utcOffsetHours:r.event.utcOffsetHours,timeZone:r.event.timeZone,place:r.event.place,observer:r.observer,account:r.account,sources:r.sources?.length?r.sources:void 0,sway:r.sway,vehicle:r.vehicle,description:r.event.description,tags:r.event.tags,timeline:r.timeline.toJSON(),observerTrack:r.observerTrack.toJSON(),weatherTrack:r.weatherTrack.toJSON(),soundTrack:r.soundTrack.toJSON(),weather:r.weather,decor:r.decor,milestones:r.milestones.length>0?r.milestones:void 0,references:r.references.length>0?r.references:void 0,roads:r.roads.length>0?r.roads:void 0,weatherSource:r.weatherSource,instrument:r.instrumentId,exposureSeconds:r.exposureSeconds,iso:r.iso,lightPollution:r.lightPollution,interpretation:r.interpretation}}function Fv(r){const{recording:t,provenance:e}=Mn.strip(r),i=Uv(t);return i.provenance=e,i}function Uv(r){const t=[],e=new kl({eventType:"sighting",time:r.time,endTime:r.endTime,durationSeconds:r.durationSeconds,utcOffsetHours:r.utcOffsetHours,timeZone:r.timeZone,place:r.place,description:r.description,tags:r.tags},Ul.fromJSON(r.timeline,t),r.observerTrack?Po.fromJSON(r.observerTrack):new Po,r.weatherTrack?Lo.fromJSON(r.weatherTrack):new Lo,r.soundTrack?Oo.fromJSON(r.soundTrack):new Oo,r.observer&&{id:r.observer.id,title:r.observer.title,lastName:r.observer.lastName,firstNames:r.observer.firstNames},r.id,r.weather,r.decor??[],r.weatherSource,r.instrument,r.exposureSeconds??r.observerTrack?.keyframes.map(i=>i.pose.exposureSeconds).find(i=>i!==void 0),_o(r.milestones??[]),r.references??[],r.roads??[]);return e.account=r.account,e.sources=r.sources,e.sway=r.sway,e.iso=r.iso,e.lightPollution=r.lightPollution,e.vehicle=r.vehicle,e.interpretation=r.interpretation,e.loadIssues=t,Ji.toBounds(e),Ji.toPosition(e),e}class Cr{static EN={"unknown-key":"{path}: unknown key, ignored","wrong-type":"{path}: expected {expected}, found {found}","not-in-list":"{path}: {found} is not one of {expected}",defaulted:"{path}: missing, {expected} used",unplaced:"{path}: no aim (and no bounds), drawn at the middle of the view",unsized:"{path}: no angular size (and no bounds), drawn one pixel wide","pixels-over-angles":"{path}: bounds restated without aim or angular, so the shape follows the pixels"};static text(t,e=Cr.EN){return e[t.kind].replace("{path}",t.path).replace("{expected}",t.expected??"").replace("{found}",t.found??"")}static warn(t,e){if(t.length===0)return;const i=t.map(n=>` ${Cr.text(n)}`);console.warn(`UFO@home: ${t.length} problem(s) in ${e??"this recording"}:
1151
+ `,jo=[{id:"eye",name:"Naked eye",flare:0,projection:"equidistant",stabilization:.97},{id:"rectilinear-lens",name:"Camera, unknown device",projection:"rectilinear",fNumber:8,fNumberRange:{min:2,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:8},apertureBlades:6},{id:"instamatic-126",name:"Instamatic, 126 film",projection:"rectilinear",frame:{widthMm:28,heightMm:28,focalLengthMm:43},fNumber:11,exposureSeconds:1/90,years:{from:1963,to:1988},apertureBlades:5,detailUm:20,medium:{kind:"negative",iso:64}},{id:"slr-35mm-50",name:"35 mm SLR, 50 mm lens",projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:50},fNumber:8,fNumberRange:{min:2,max:16},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},years:{from:1959},apertureBlades:6,detailUm:20,medium:{kind:"negative",iso:100}},{id:"slr-35mm-zoom",name:"35 mm SLR, 70-210 mm zoom",projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:135,focalRangeMm:{minMm:70,maxMm:210}},fNumber:8,fNumberRange:{min:4,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},apertureBlades:8,years:{from:1975},detailUm:20,medium:{kind:"negative",iso:100}},{id:"phone-landscape",name:"Phone, held sideways",projection:"rectilinear",frame:{widthMm:7.6,heightMm:5.7,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4,medium:{kind:"sensor",iso:100,autoExposure:!0}},{id:"phone-portrait",name:"Phone, held upright",projection:"rectilinear",frame:{widthMm:5.7,heightMm:7.6,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4,medium:{kind:"sensor",iso:100,autoExposure:!0}}];class fi{static get default(){return jo[0]}static byId(t){return jo.find(e=>e.id===t)??this.default}static UNAIDED_FIELD_DEG=60;static UNAIDED_ASPECT=16/9;static fieldOfViewDeg(t){const e=t.frame;return e?2*Math.atan(e.heightMm/(2*e.focalLengthMm))*180/Math.PI:fi.UNAIDED_FIELD_DEG}static aspectOf(t){const e=t.frame;return e?e.widthMm/e.heightMm:fi.UNAIDED_ASPECT}static frameWidthPx(t,e){return Math.round(e*fi.aspectOf(t))}static availableAt(t){return t===void 0?jo:jo.filter(e=>!e.years||t>=e.years.from&&(e.years.to===void 0||t<=e.years.to))}static fieldOfViewDegAt(t,e){const i=t.frame;if(!(!i||e<=0))return 2*Math.atan(i.heightMm/(2*e))*180/Math.PI}static focalLengthMmFor(t,e){const i=t.frame;if(!(!i||e<=0||e>=180))return i.heightMm/(2*Math.tan(e*Math.PI/360))}static bladesShowing(t,e){const i=e??t.fNumber;if(i===void 0||t.apertureBlades===void 0)return 0;const n=t.fNumberRange;return!n||n.max<=n.min?1:Math.max(0,Math.min(1,(i-n.min)/(n.max-n.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(t){return t.flare??fi.LENS_FLARE_ARTIFACTS}static starPointsOf(t){const e=t.apertureBlades;return e===void 0||e<3?0:e%2===0?e:e*2}}class xr{constructor(t){this.points=t}static STATIONARY_M=5;static of(t){const e=[];for(const i of t.observerTrack.allKeyframes){const{lat:n,lng:s,headingDeg:a}=i.pose;n===void 0||s===void 0||e.push({t:i.t,lat:n,lng:s,headingDeg:a})}if(e.length===0){const i=t.event.place?.[0];if(!i)return;e.push({t:0,lat:i.lat,lng:i.lng})}return new xr(e)}static TRAVEL_M=50;get travels(){return this.spanM>xr.TRAVEL_M}get moved(){return this.spanM>xr.STATIONARY_M}get spanM(){const t=this.box,e=(t.south+t.north)/2,i=(t.west+t.east)/2;return Math.max(Math.abs(ai(e,t.east,e,t.west).x),Math.abs(ai(t.north,i,t.south,i).z))}get center(){const t=this.box;return{lat:(t.south+t.north)/2,lng:(t.west+t.east)/2}}boundsAround(t,e){const{lat:i,lng:n}=this.center,s=Math.max(this.spanM*(1+e),t)/2;return{north:_s(0,-s,i,n).lat,south:_s(0,s,i,n).lat,east:_s(s,0,i,n).lng,west:_s(-s,0,i,n).lng}}get box(){const t=this.points.map(i=>i.lat),e=this.points.map(i=>i.lng);return{south:Math.min(...t),north:Math.max(...t),west:Math.min(...e),east:Math.max(...e)}}}class mn{constructor(t,e){this.rotationPassed=t,this.scale=e}static SWAY_M=.012;static BREATH_M=.003;static DRIFT_YAW_DEG=.5;static DRIFT_PITCH_DEG=.4;static DRIFT_ROLL_DEG=.3;static GAZE_DRIFT_SHARE=.35;static HAND_HELD_S=.5;static HZ=[.11,.23,.17,.29,.37,.07];static of(t){const e=t.event.tags?.includes("paralysis")||(t.exposure??0)>mn.HAND_HELD_S,i=t.sway??(e?0:1);if(i>0)return new mn(Math.max(1-(t.instrument.stabilization??0),mn.GAZE_DRIFT_SHARE),i)}offsetAt(t){const e=t/1e3,i=this.scale,n=(u,d)=>Math.sin(2*Math.PI*u*e+d),[s,a,o,c,l,h]=mn.HZ;return{eastM:i*mn.SWAY_M*(.7*n(s,.3)+.3*n(c,1.9)),northM:i*mn.SWAY_M*(.6*n(o,2.2)+.4*n(l,.8)),upM:i*mn.BREATH_M*n(a,0),yawDeg:i*this.rotationPassed*mn.DRIFT_YAW_DEG*(.6*n(h,1.1)+.4*n(c,2.7)),pitchDeg:i*this.rotationPassed*mn.DRIFT_PITCH_DEG*(.5*n(a,1.6)+.5*n(o,.4)),rollDeg:i*this.rotationPassed*mn.DRIFT_ROLL_DEG*n(s,2.9)}}}class _e{constructor(t,e){this.stretches=t,this.rotationPassed=e}static REFERENCE_SPEED_M_PER_S=1.4;static REFERENCE_STEP_HZ=1.9;static CADENCE_EXPONENT=.43;static RISE_M_PER_M_PER_S=.0175;static SWAY_M=.0175;static SLOWEST_WALK_M_PER_S=.2;static FASTEST_WALK_M_PER_S=2.2;static HEAD_ROLL_DEG=1.5;static HEAD_PITCH_DEG=1.25;static HEAD_YAW_DEG=1;static STOP_LURCH_M=.035;static STOP_PITCH_DEG=3;static START_LURCH_M=.015;static START_PITCH_DEG=1.2;static JOLT_HZ=1.4;static JOLT_DECAY_S=.35;static JOLT_LASTS_MS=1500;static STILL=Object.freeze({eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0});static of(t){const e=xr.of(t);if(!e||e.points.length<2)return;const i=[];let n=0;for(let s=1;s<e.points.length;s++){const a=e.points[s-1],o=e.points[s],c=(o.t-a.t)/1e3;if(c<=0)continue;const l=ai(o.lat,o.lng,a.lat,a.lng),h=l.x,u=-l.z,d=Math.hypot(h,u),f=d/c,p=_e.stepHzFor(f);i.push({startMs:a.t,endMs:o.t,speedMPerS:f,eastUnit:d>0?h/d:0,northUnit:d>0?u/d:0,stepHz:p,stepsBefore:n,rampsIn:!0,rampsOut:!0}),n+=p*c}for(let s=0;s<i.length;s++){const a=i[s-1],o=i[s+1];i[s].rampsIn=a===void 0||a.stepHz===0,i[s].rampsOut=o===void 0||o.stepHz===0}if(i.some(s=>s.stepHz>0))return new _e(i,1-(t.instrument.stabilization??0))}static bodyAt(t,e,i=!1){const n=_e.of(t)?.offsetAt(e)??_e.STILL;return i?n:_e.add(n,mn.of(t)?.offsetAt(e))}static stepHzFor(t){return t<_e.SLOWEST_WALK_M_PER_S||t>_e.FASTEST_WALK_M_PER_S?0:_e.REFERENCE_STEP_HZ*Math.pow(t/_e.REFERENCE_SPEED_M_PER_S,_e.CADENCE_EXPONENT)}offsetAt(t){return _e.add(this.cycleAt(t),this.joltAt(t))}joltAt(t){for(const e of this.stretches){if(e.stepHz===0)continue;const i=e.speedMPerS/_e.REFERENCE_SPEED_M_PER_S,n=(o,c,l,h)=>{if(o<0||o>_e.JOLT_LASTS_MS)return;const u=o/1e3,d=Math.exp(-u/_e.JOLT_DECAY_S)*Math.sin(2*Math.PI*_e.JOLT_HZ*u),f=h*c*i*d;return{eastM:f*e.eastUnit,northM:f*e.northUnit,upM:-Math.abs(f)*.3,rollDeg:0,pitchDeg:-h*l*i*d*this.rotationPassed,yawDeg:0}},s=e.rampsOut?n(t-e.endMs,_e.STOP_LURCH_M,_e.STOP_PITCH_DEG,1):void 0;if(s)return s;const a=e.rampsIn?n(t-e.startMs,_e.START_LURCH_M,_e.START_PITCH_DEG,-1):void 0;if(a)return a}}static add(t,e){return e?{eastM:t.eastM+e.eastM,northM:t.northM+e.northM,upM:t.upM+e.upM,rollDeg:t.rollDeg+e.rollDeg,pitchDeg:t.pitchDeg+e.pitchDeg,yawDeg:t.yawDeg+e.yawDeg}:t}cycleAt(t){const e=this.stretches.find(c=>t>=c.startMs&&t<=c.endMs);if(!e||e.stepHz===0)return _e.STILL;const i=e.stepsBefore+e.stepHz*(t-e.startMs)/1e3,n=2*Math.PI*i,s=this.amplitudeAt(e,t),a=_e.SWAY_M*s*Math.cos(n/2),o=s*this.rotationPassed*e.speedMPerS/_e.REFERENCE_SPEED_M_PER_S;return{eastM:a*e.northUnit,northM:-a*e.eastUnit,upM:_e.RISE_M_PER_M_PER_S*e.speedMPerS*s*Math.cos(n),rollDeg:_e.HEAD_ROLL_DEG*o*Math.cos(n/2),pitchDeg:-1.25*o*Math.cos(n),yawDeg:_e.HEAD_YAW_DEG*o*Math.cos(n/2)}}amplitudeAt(t,e){const i=1e3/t.stepHz,n=Math.min(i,(t.endMs-t.startMs)/2);if(n<=0)return 1;const s=e-t.startMs,a=t.endMs-e,o=Math.min(t.rampsIn?s/n:1,t.rampsOut?a/n:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class Te{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(t){return 2*Math.atan(t.sizeM/(2*t.distanceM))*180/Math.PI}static inMoons(t){return t/Te.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(t,e,i){if(!(!t||!e))return{widthDeg:t.widthDeg+(e.widthDeg-t.widthDeg)*i,heightDeg:t.heightDeg+(e.heightDeg-t.heightDeg)*i}}static sizeMAt(t,e){return 2*t*Math.tan(e*Math.PI/360)}static distanceMAt(t,e){return t/(2*Math.tan(e*Math.PI/360))}}function rv(r,t,e){if(!r||!t)return e<1?r:t;const i=((t.azimuthDeg-r.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((r.azimuthDeg+i*e)%360+360)%360,altitudeDeg:r.altitudeDeg+(t.altitudeDeg-r.altitudeDeg)*e}}function ov(r,t,e){const{bounds:i}=r;return t>=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i.height}function Ki(r,t,e){return r+(t-r)*e}function tf(r){const t=/^#([0-9a-f]{6})$/i.exec(r);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function cv(r){return`#${r.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function lv(r,t,e){const i=tf(r),n=tf(t);return!i||!n?e<1?r:t:cv([Ki(i[0],n[0],e),Ki(i[1],n[1],e),Ki(i[2],n[2],e)])}function hv(r,t,e){const i={x:Ki(r.bounds.x,t.bounds.x,e),y:Ki(r.bounds.y,t.bounds.y,e),width:Ki(r.bounds.width,t.bounds.width,e),height:Ki(r.bounds.height,t.bounds.height,e)},n=Ki(r.angle,t.angle,e),s=Ki(r.transparency,t.transparency,e),a=Ki(r.haloScale,t.haloScale,e),o=Ki(r.blur??0,t.blur??0,e),c=Ki(r.brightness??0,t.brightness??0,e),l=lv(r.color,t.color,e),h=Te.lerpAngular(r.angular,t.angular,e),u=rv(r.aim,t.aim,e);return r.kind==="polygon"&&t.kind==="polygon"&&r.points.length===t.points.length?{...r,bounds:i,angle:n,transparency:s,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u,points:r.points.map((d,f)=>({x:Ki(d.x,t.points[f].x,e),y:Ki(d.y,t.points[f].y,e)}))}:{...e<1?r:t,bounds:i,angle:n,transparency:s,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u}}class ga{static DEFAULT_COLOR="#e8e6df";static complete(t,e=[]){const i=new Map;return t.map((n,s)=>({keyframe:n,index:s})).sort((n,s)=>n.keyframe.t-s.keyframe.t).map(({keyframe:n,index:s})=>({t:n.t,shapes:(n.shapes??[]).map((a,o)=>{const c=`timeline.keyframes.${s}.shapes.${o}.shape`,l=ga.completed(a,i.get(a.sourceId),c,e);return i.set(a.sourceId,l),{sourceId:a.sourceId,shape:l}})}))}static completed(t,e,i,n){const s=t.shape??{},a=e??ga.firstAppearance(s,i,n),o={...a};s.bounds&&e&&(e.aim||e.angular)&&!s.aim&&!s.angular&&n.push({kind:"pixels-over-angles",path:i}),s.bounds&&(s.aim||delete o.aim,s.angular||delete o.angular);const c=s.kind??a.kind??"oval",l={...o,...s,kind:c};if(c==="polygon"&&!l.points){n.push({kind:"defaulted",path:`${i}.points`,expected:"rectangle"});const{width:h,height:u}=l.bounds;return{...l,points:[{x:0,y:0},{x:h,y:0},{x:h,y:u},{x:0,y:u}]}}return l}static firstAppearance(t,e,i){return t.kind||i.push({kind:"defaulted",path:`${e}.kind`,expected:'"oval"'}),t.color||i.push({kind:"defaulted",path:`${e}.color`,expected:`"${ga.DEFAULT_COLOR}"`}),!t.bounds&&!t.aim&&i.push({kind:"unplaced",path:e}),!t.bounds&&!t.angular&&i.push({kind:"unsized",path:e}),{kind:t.kind??"oval",bounds:{...ga.NEUTRAL_BOUNDS},color:ga.DEFAULT_COLOR,angle:0,transparency:0,haloScale:0,selected:!1}}static NEUTRAL_BOUNDS={x:Te.CANVAS_WIDTH_PX/2,y:Te.CANVAS_HEIGHT_PX/2,width:1,height:1}}class Ul{keyframes=[];order=[];groups=[];addKeyframe(t,e){const i=this.findInsertIndex(t);if(this.keyframes[i]?.t===t){const n=new Set(e.map(s=>s.sourceId));this.keyframes[i]={t,shapes:[...this.keyframes[i].shapes.filter(s=>!n.has(s.sourceId)),...e]}}else this.keyframes.splice(i,0,{t,shapes:[...e]});for(const n of e)this.order.includes(n.sourceId)||this.order.push(n.sourceId)}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e];return i?.t===t?i:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(i=>i.sourceId===e)?.shape}getLatestShapeAt(t,e){let i=this.findInsertIndex(t);for(this.keyframes[i]?.t!==t&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return n.shape}}getInterpolatedShapeAt(t,e){const i=this.findShapeAtOrBefore(t,e);if(i?.t===t)return i.shape;const n=this.findShapeAtOrAfter(t,e);return i?n?hv(i.shape,n.shape,(t-i.t)/(n.t-i.t)):i.shape:n?.shape}findShapeAtOrBefore(t,e){let i=this.findInsertIndex(t);for(this.keyframes[i]?.t!==t&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}findShapeAtOrAfter(t,e){for(let i=this.findInsertIndex(t);i<this.keyframes.length;i++){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}hitTest(t,e,i,n){const s=this.sourceIds;for(let a=s.length-1;a>=0;a--){if(n?.has(s[a]))continue;const o=this.getInterpolatedShapeAt(t,s[a]);if(o&&ov(o,e,i))return{sourceId:s[a],shape:o}}}removeSource(t){for(let e=this.keyframes.length-1;e>=0;e--){const i=this.keyframes[e].shapes.filter(n=>n.sourceId!==t);i.length===0?this.keyframes.splice(e,1):i.length!==this.keyframes[e].shapes.length&&(this.keyframes[e]={t:this.keyframes[e].t,shapes:i})}this.order=this.order.filter(e=>e!==t),this.removeFromGroup(t)}group(t){if(!(t.length<2)){for(const e of t)this.removeFromGroup(e);this.groups.push([...t])}}ungroup(t){const e=this.groups.findIndex(i=>i.includes(t));e!==-1&&this.groups.splice(e,1)}groupMembers(t){return this.groups.find(e=>e.includes(t))}removeFromGroup(t){const e=this.groups.findIndex(n=>n.includes(t));if(e===-1)return;const i=this.groups[e].filter(n=>n!==t);i.length<2?this.groups.splice(e,1):this.groups[e]=i}bringToFront(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.push(t))}sendToBack(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.unshift(t))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes,order:this.order,groups:this.groups}}static fromJSON(t,e){const i=new Ul;for(const n of ga.complete(t.keyframes??[],e))i.addKeyframe(n.t,n.shapes);if(t.order){const n=i.order.filter(s=>!t.order.includes(s));i.order=[...t.order,...n]}return t.groups&&(i.groups=t.groups.map(n=>n.filter(s=>i.order.includes(s))).filter(n=>n.length>=2)),i}}function uv(r,t,e){return Math.max(t,Math.min(e,r))}function dv(r,t,e){const i=((t-r)%360+540)%360-180;return((r+i*e)%360+360)%360}function Ha(r,t,e){return r+(t-r)*e}function fv(r,t,e){return{lat:r.lat===void 0||t.lat===void 0?void 0:Ha(r.lat,t.lat,e),lng:r.lng===void 0||t.lng===void 0?void 0:Ha(r.lng,t.lng,e),elevationM:Ha(r.elevationM,t.elevationM,e),headingDeg:r.headingDeg===void 0||t.headingDeg===void 0?void 0:dv(r.headingDeg,t.headingDeg,e),pitchDeg:Ha(r.pitchDeg,t.pitchDeg,e),rollDeg:Ha(r.rollDeg??0,t.rollDeg??0,e),fovDeg:Ha(r.fovDeg,t.fovDeg,e),fNumber:r.fNumber,focusDistanceM:r.focusDistanceM}}class Da{static at(t,e,i,n,s){const a=t[i],c=t[i+1]-a;if(c<=0)return e[i];const l=Da.tangent(t,e,i,s),h=Da.tangent(t,e,i+1,s),u=(n-a)/c,d=u*u,f=d*u;return(2*f-3*d+1)*e[i]+(f-2*d+u)*c*l+(-2*f+3*d)*e[i+1]+(f-d)*c*h}static BRAKE_S=.8;static paced(t,e,i,n){if(!i&&!n)return t;const s=e>0?Math.min(.5,Da.BRAKE_S/e):.5;if(i&&n){const o=1/(1-s);return t<=s?o*t*t/(2*s):t>=1-s?1-o*(1-t)*(1-t)/(2*s):o*(t-s/2)}const a=o=>{const c=1/(1-s/2);if(o<=1-s)return c*o;const l=o-(1-s);return c*(1-s)+c*(l-l*l/(2*s))};return n?a(t):1-a(1-t)}static tangent(t,e,i,n){const s=t.length-1,a=f=>(e[f+1]-e[f])/(t[f+1]-t[f]||1);if(i===0)return n?0:a(0);if(i===s)return n?0:a(s-1);const o=a(i-1),c=a(i);if(o*c<=0)return 0;const l=t[i]-t[i-1],h=t[i+1]-t[i],u=2*h+l,d=h+2*l;return(u+d)/(u/o+d/c)}}class Po{keyframes=[];addKeyframe(t,e){const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,pose:e}:this.keyframes.splice(i,0,{t,pose:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}getLatestPoseAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].pose:void 0}getInterpolatedPoseAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.pose;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!i)return n?.pose;if(!n)return i.pose;const s=fv(i.pose,n.pose,uv((t-i.t)/(n.t-i.t),0,1));return this.humanly(e-1,t,s)}humanly(t,e,i){const n=Math.max(0,t-1),s=Math.min(this.keyframes.length-1,t+2),a=this.keyframes.slice(n,s+1),o=t-n,c=a.map(y=>y.t),l=(y,M)=>{const b=a.map(w=>y(w.pose));if(!b.some(w=>w===void 0))return Da.at(c,b,o,e,M)},h=a.map(y=>y.pose.headingDeg);let u;if(h.every(y=>y!==void 0)){const y=[h[0]];for(let M=1;M<h.length;M++)y.push(y[M-1]+((h[M]-h[M-1])%360+540)%360-180);u=(Da.at(c,y,o,e,!0)%360+360)%360}const d=this.keyframes[t],f=this.keyframes[t+1],p=(y,M)=>y.lat===M.lat&&y.lng===M.lng&&y.elevationM===M.elevationM,v=!p(d.pose,f.pose),m=v&&t>0&&p(this.keyframes[t-1].pose,d.pose),g=v&&t+2<this.keyframes.length&&p(f.pose,this.keyframes[t+2].pose);let S;if(m||g){const y=Da.paced((e-d.t)/(f.t-d.t),(f.t-d.t)/1e3,m,g),M=(b,w)=>b===void 0||w===void 0?void 0:b+(w-b)*y;S={lat:M(d.pose.lat,f.pose.lat),lng:M(d.pose.lng,f.pose.lng),elevationM:M(d.pose.elevationM,f.pose.elevationM)}}return{...i,lat:S?S.lat:l(y=>y.lat,!1)??i.lat,lng:S?S.lng:l(y=>y.lng,!1)??i.lng,elevationM:S?S.elevationM:l(y=>y.elevationM,!1)??i.elevationM,headingDeg:u??i.headingDeg,pitchDeg:l(y=>y.pitchDeg,!0)??i.pitchDeg,rollDeg:l(y=>y.rollDeg??0,!0)??i.rollDeg,fovDeg:l(y=>y.fovDeg,!0)??i.fovDeg}}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Po;for(const i of t.keyframes)e.addKeyframe(i.t,i.pose);return e}}class Ws{static MAX_CHANGE_PER_S=.05;points;followed;constructor(t){let e="none",i=0;this.points=t.map(({t:n,weather:s})=>(s.precipitationType!=="none"&&(e=s.precipitationType,i=s.precipitationIntensity),{t:n,lastFalling:e,lastFallingIntensity:i,intensity:s.precipitationType==="none"?0:s.precipitationIntensity,type:s.precipitationType})),this.followed=[];for(let n=0;n<this.points.length;n++){if(n===0){this.followed.push(this.points[0].intensity);continue}const s=this.points[n-1],a=this.points[n];this.followed.push(Ws.follow(this.followed[n-1],s.intensity,a.intensity,(a.t-s.t)/1e3,(a.t-s.t)/1e3))}}at(t){if(this.points.length===0||t<this.points[0].t)return;let e=this.points.length-1;for(;e>0&&this.points[e].t>t;)e--;const i=this.points[e],n=this.points[e+1],s=n?Ws.follow(this.followed[e],i.intensity,n.intensity,(n.t-i.t)/1e3,(t-i.t)/1e3):Ws.follow(this.followed[e],i.intensity,i.intensity,1,(t-i.t)/1e3);return{type:Ws.typeBetween(i,n,t,s),intensity:s,character:Ws.characterBetween(i,n,t)}}static characterBetween(t,e,i){return t.type==="none"?e&&e.type!=="none"?e.intensity:t.lastFallingIntensity:!e||e.type==="none"?t.intensity:t.intensity+(e.intensity-t.intensity)*(i-t.t)/(e.t-t.t||1)}static typeBetween(t,e,i,n){return t.type==="none"?e&&e.type!=="none"&&i>t.t?e.type:n>0?t.lastFalling:"none":e&&e.type==="none"&&n<=0?"none":t.type}static follow(t,e,i,n,s){const a=Ws.MAX_CHANGE_PER_S,o=n>0?(i-e)/n:0,c=u=>e+o*Math.min(Math.max(u,0),n);let l=t,h=0;for(let u=0;u<8&&h<s;u++){const d=c(h)-l;if(Math.abs(d)<1e-9){const y=h<n?o:0;if(Math.abs(y)<=a){const b=h<n?Math.min(s,n):s;l=c(b),h=b;continue}const M=Math.min(s,n);l+=Math.sign(y)*a*(M-h),h=M;continue}const f=Math.sign(d),p=h<n?o:0,v=a-f*p,m=v>0?h+Math.abs(d)/v:1/0,g=h<n?n:1/0,S=Math.min(s,m,g);l+=f*a*(S-h),h=S,S===m&&(l=c(h))}return Math.min(1,Math.max(0,l))}}function ze(r,t,e){return r+(t-r)*e}function jd(r,t,e){const i=((t-r)%360+540)%360-180;return((r+i*e)%360+360)%360}function pv(r,t,e){return Math.max(t,Math.min(e,r))}function mv(r=[],t=[],e){if(!(!r.length&&!t.length))return[...new Set([...r.map(i=>i.id),...t.map(i=>i.id)])].map(i=>{const n=r.find(c=>c.id===i),s=t.find(c=>c.id===i),a=n??{...s,density:0},o=s??{...n,density:0};return{...a,eastM:ze(a.eastM,o.eastM,e),northM:ze(a.northM,o.northM,e),baseM:ze(a.baseM,o.baseM,e),thicknessM:ze(a.thicknessM,o.thicknessM,e),widthM:ze(a.widthM,o.widthM,e),depthM:ze(a.depthM,o.depthM,e),rotationDeg:jd(a.rotationDeg,o.rotationDeg,e),density:ze(a.density,o.density,e),darkness:ze(a.darkness??0,o.darkness??0,e)}})}function gv(r,t,e){if(r.cloudLayers===void 0&&t.cloudLayers===void 0)return;const i=dl(r),n=dl(t);return e>=1?n.map(a=>({...a})):[...new Set([...i.map(a=>a.id),...n.map(a=>a.id)])].map(a=>{const o=i.find(u=>u.id===a),c=n.find(u=>u.id===a),l=o??{...c,coverage:0},h=c??{...o,coverage:0};return{...l,instances:mv(o?.instances,c?.instances,e),baseM:ze(l.baseM,h.baseM,e),thicknessM:ze(l.thicknessM,h.thicknessM,e),coverage:ze(l.coverage,h.coverage,e),sizeM:ze(l.sizeM,h.sizeM,e),density:ze(l.density,h.density,e),darkness:ze(l.darkness??r.cloudDarkness,h.darkness??t.cloudDarkness,e),iceCrystalAlignment:l.iceCrystalAlignment===void 0||h.iceCrystalAlignment===void 0?void 0:ze(l.iceCrystalAlignment,h.iceCrystalAlignment,e),windSpeed:l.windSpeed===void 0&&h.windSpeed===void 0?void 0:ze(l.windSpeed??r.windSpeed,h.windSpeed??t.windSpeed,e),windDirectionDeg:l.windDirectionDeg===void 0&&h.windDirectionDeg===void 0?void 0:jd(l.windDirectionDeg??r.windDirectionDeg,h.windDirectionDeg??t.windDirectionDeg,e)}})}function vv(r,t,e){return{cloudLayers:gv(r,t,e),cloudCover:ze(r.cloudCover,t.cloudCover,e),cloudDarkness:ze(r.cloudDarkness,t.cloudDarkness,e),highCloudCover:r.highCloudCover===void 0||t.highCloudCover===void 0?void 0:ze(r.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:r.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:ze(r.iceCrystalAlignment,t.iceCrystalAlignment,e),lowerCloudCover:r.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:ze(r.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:r.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:ze(r.cloudBaseM,t.cloudBaseM,e),relativeHumidity:r.relativeHumidity===void 0||t.relativeHumidity===void 0?void 0:ze(r.relativeHumidity,t.relativeHumidity,e),precipitationType:e<1?r.precipitationType:t.precipitationType,precipitationIntensity:ze(r.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:jd(r.windDirectionDeg,t.windDirectionDeg,e),windSpeed:ze(r.windSpeed,t.windSpeed,e),storm:e<1?r.storm:t.storm}}class Lo{keyframes=[];ramp;addKeyframe(t,e){this.ramp=void 0;const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,weather:e}:this.keyframes.splice(i,0,{t,weather:e})}clear(){this.ramp=void 0,this.keyframes.length=0}removeKeyframeAt(t){this.ramp=void 0;const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}getLatestWeatherAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].weather:void 0}getInterpolatedWeatherAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.weather;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return i?n?vv(i.weather,n.weather,pv((t-i.t)/(n.t-i.t),0,1)):i.weather:n?.weather}getActualWeatherAt(t){const e=this.getInterpolatedWeatherAt(t);if(!e)return;const i=(this.ramp??=new Ws(this.keyframes)).at(t);if(!i)return e;const{type:n,intensity:s,character:a}=i,o=a>0?Math.min(1,s/a):n==="none"?0:1;return{...e,precipitationType:n,precipitationIntensity:a,precipitationAmount:o}}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Lo;for(const i of t.keyframes)e.addKeyframe(i.t,i.weather);return e}}class Oo{keyframes=[];addKeyframe(t,e){const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,sound:e}:this.keyframes.splice(i,0,{t,sound:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}getLatestSoundAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].sound:void 0}getInterpolatedSoundAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.sound;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!i)return n?.sound;if(!n)return i.sound;const s=(t-i.t)/(n.t-i.t);return this.lerp(i.sound,n.sound,Math.max(0,Math.min(1,s)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Oo;for(const i of t.keyframes)e.addKeyframe(i.t,i.sound);return e}lerp(t,e,i){return{kind:i<1?t.kind:e.kind,volume:t.volume+(e.volume-t.volume)*i,pitchHz:t.pitchHz+(e.pitchHz-t.pitchHz)*i,src:i<1?t.src:e.src}}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}}const Mv=100,xv={kind:"none",volume:0,pitchHz:Mv};class Mn{constructor(t){this.entries=t}static empty(){return new Mn(new Map)}get size(){return this.entries.size}at(t){return this.entries.get(t)}paths(){return[...this.entries.keys()]}set(t,e){e.basis==="stated"&&e.rationale===void 0?this.entries.delete(t):this.entries.set(t,e)}clear(t){for(const e of this.entries.keys())(e===t||e.startsWith(`${t}.`))&&this.entries.delete(e)}static strip(t){const e=new Mn(new Map);return{recording:Mn.stripValue(t,[],e),provenance:e}}static restore(t,e){if(e.size===0)return t;const i=structuredClone(t);for(const n of e.paths()){const s=e.at(n),a=n.split("."),o=Mn.holderOf(i,a);if(!o)continue;const c=a[a.length-1],l=o[c];l!==void 0&&(s.of!==void 0&&JSON.stringify(s.of)!==JSON.stringify(l)||(o[c]={value:l,...s.basis==="stated"?{}:{basis:s.basis},...s.rationale===void 0?{}:{rationale:s.rationale}}))}return i}static isWrapper(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&"value"in t}static stripValue(t,e,i){return Mn.isWrapper(t)?(i.set(e.join("."),{basis:t.basis??"stated",...t.rationale===void 0?{}:{rationale:t.rationale},of:t.value}),Mn.stripValue(t.value,e,i)):Array.isArray(t)?t.map((n,s)=>Mn.stripValue(n,[...e,String(s)],i)):typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t).map(([n,s])=>[n,Mn.stripValue(s,[...e,n],i)])):t}static holderOf(t,e){let i=t;for(const n of e.slice(0,-1)){if(typeof i!="object"||i===null)return;i=i[n]}return typeof i=="object"&&i!==null?i:void 0}}function bu(r){if(r.year!==void 0)return Date.UTC(r.year,(r.month??1)-1,r.day??1,r.hour??0,r.minute??0,r.second??0)}function ef(r){return(((r.day??0)*24+(r.hour??0))*60+(r.minute??0))*6e4+(r.second??0)*1e3}const yv=["year","month","day","hour","minute"],_v=["day","hour","minute"];function nf(r,t){return t.filter(e=>r[e]!==void 0).join(",")}function Sv(r){if(r.durationSeconds!==void 0)return r.durationSeconds*1e3;if(!r.time||!r.endTime)return;const t=r.time.year!==void 0&&r.endTime.year!==void 0,e=t?yv:_v,i=nf(r.time,e);if(!(i===""||i!==nf(r.endTime,e)))return t?bu(r.endTime)-bu(r.time):ef(r.endTime)-ef(r.time)}class kl{constructor(t,e,i,n,s,a,o,c,l=[],h,u,d,f=[],p=[],v=[]){this.event=t,this.timeline=e,this.observerTrack=i,this.weatherTrack=n,this.soundTrack=s,this.observer=a,this.id=o,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u,this.exposureSeconds=d,this.milestones=f,this.references=p,this.roads=v}provenance=Mn.empty();loadIssues=[];account;sources;interpretation;sway;lightPollution;iso;vehicle;get observerCount(){return 1+this.decor.filter(t=>t.kind==="observer").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return fi.byId(this.instrumentId)}static create(t,e,i){return new kl({eventType:"sighting",time:t,place:e},new Ul,new Po,new Lo,new Oo,i)}}const bv=0,wv=0;function di(r,t){const e=r.observerTrack.getInterpolatedPoseAt(t);if(e)return e;const i=r.event.place?.[0];if(i)return{lat:i.lat,lng:i.lng,elevationM:bv,headingDeg:void 0,pitchDeg:wv,fovDeg:fi.fieldOfViewDeg(r.instrument)}}function Gr(r,t){return r.weatherTrack.getInterpolatedWeatherAt(t)??r.weather??Jd}function sf(r,t){return r.weatherTrack.getActualWeatherAt(t)??r.weather??Jd}function Ev(r,t){return r.soundTrack.getInterpolatedSoundAt(t)??xv}class Av{constructor(t,e){this.timeline=t,this.onFrame=e}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const t=()=>{if(this.state!=="playing")return;const e=performance.now();if(this.currentT+=(e-this.lastWallTime)*this.playbackRate,this.lastWallTime=e,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(t){this.currentT=Math.max(0,Math.min(t,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(t){const e=new Map;for(const i of this.timeline.sourceIds){const n=this.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}this.onFrame(t,e)}}const sg=["nw","n","ne","e","se","s","sw","w"],Tv=24,Qo=8,Rv=3,Dv=8;function tc(r,t,e){const i=r.x-t.x,n=r.y-t.y,s=Math.cos(e),a=Math.sin(e);return{x:t.x+i*s-n*a,y:t.y+i*a+n*s}}function Vr(r){return{x:r.x+r.width/2,y:r.y+r.height/2}}const Iv={nw:{left:!0,top:!0},n:{top:!0},ne:{right:!0,top:!0},e:{right:!0},se:{right:!0,bottom:!0},s:{bottom:!0},sw:{left:!0,bottom:!0},w:{left:!0}};class cn{static handlePointsFor(t){const{x:e,y:i,width:n,height:s}=t.bounds,a={nw:{x:e,y:i},n:{x:e+n/2,y:i},ne:{x:e+n,y:i},e:{x:e+n,y:i+s/2},se:{x:e+n,y:i+s},s:{x:e+n/2,y:i+s},sw:{x:e,y:i+s},w:{x:e,y:i+s/2},rotate:{x:e+n/2,y:i-Tv}},o=Vr(t.bounds),c={};for(const l of Object.keys(a))c[l]=tc(a[l],o,t.angle);return c}static hitTestHandle(t,e,i=8,n=[...sg,"rotate"]){const s=cn.handlePointsFor(t);for(const a of n)if(Math.hypot(e.x-s[a].x,e.y-s[a].y)<=i)return a}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(t,e){const n=((cn.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,s=["ew","nwse","ns","nesw"];return s[Math.round(n)%s.length]}static resizeBounds(t,e,i,n){const s=Vr(t),a=tc(n,s,-e),{x:o,y:c,width:l,height:h}=t,u=Iv[i];let d=o,f=c,p=o+l,v=c+h;return u.left&&(d=Math.min(a.x,p-Qo)),u.right&&(p=Math.max(a.x,d+Qo)),u.top&&(f=Math.min(a.y,v-Qo)),u.bottom&&(v=Math.max(a.y,f+Qo)),{x:d,y:f,width:p-d,height:v-f}}static resizeShape(t,e,i){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:n,height:s}=t.bounds,a=cn.resizeBounds(t.bounds,t.angle,e,i);if(t.kind==="oval")return{...t,bounds:a};const o=n===0?1:a.width/n,c=s===0?1:a.height/s;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(t,e){const i=Vr(t.bounds),n=Math.atan2(e.y-i.y,e.x-i.x)+Math.PI/2;return{...t,angle:n}}static groupBoundsFor(t){const e=Math.min(...t.map(a=>a.x)),i=Math.min(...t.map(a=>a.y)),n=Math.max(...t.map(a=>a.x+a.width)),s=Math.max(...t.map(a=>a.y+a.height));return{x:e,y:i,width:n-e,height:s-i}}static vertexPointsFor(t){const e=Vr(t.bounds);return t.points.map(i=>tc({x:t.bounds.x+i.x,y:t.bounds.y+i.y},e,t.angle))}static hitTestVertex(t,e,i=Dv){const n=cn.vertexPointsFor(t);let s,a=i;return n.forEach((o,c)=>{const l=Math.hypot(e.x-o.x,e.y-o.y);l<=a&&(a=l,s=c)}),s}static toLocalPoint(t,e){const i=Vr(t.bounds),n=tc(e,i,-t.angle);return{x:n.x-t.bounds.x,y:n.y-t.bounds.y}}static moveVertex(t,e,i){const n=t.points.map((u,d)=>d===e?cn.toLocalPoint(t,i):u),s=Math.min(...n.map(u=>u.x)),a=Math.min(...n.map(u=>u.y)),o=Math.max(...n.map(u=>u.x)),c=Math.max(...n.map(u=>u.y)),l={x:t.bounds.x+s,y:t.bounds.y+a,width:o-s,height:c-a},h=n.map(u=>({x:u.x-s,y:u.y-a}));return{...t,bounds:l,points:h}}static insertVertexNear(t,e){const i=cn.toLocalPoint(t,e),{points:n}=t;let s=n.length-1,a=1/0;for(let c=0;c<n.length;c++){const l=n[c],h=n[(c+1)%n.length],u=cn.distanceToSegment(i,l,h);u<a&&(a=u,s=c)}const o=[...n.slice(0,s+1),i,...n.slice(s+1)];return{...t,points:o}}static distanceToSegment(t,e,i){const n=i.x-e.x,s=i.y-e.y,a=n*n+s*s,o=a===0?0:Math.max(0,Math.min(1,((t.x-e.x)*n+(t.y-e.y)*s)/a)),c=e.x+o*n,l=e.y+o*s;return Math.hypot(t.x-c,t.y-l)}static deleteVertex(t,e){return t.points.length<=Rv?t:{...t,points:t.points.filter((i,n)=>n!==e)}}}const wu=6,ec=wu/2,af=20,rf=24,of=9,cf=6,lf=7,hf=6,Gn=4;class No{constructor(t){this.ctx=t}starPoints=0;roll=0;clear(t,e){this.ctx.clearRect(0,0,t,e)}static paintExtent(t){const{x:e,y:i,width:n,height:s}=t.bounds,a=e+n/2,o=i+s/2,c=t.angle%(2*Math.PI)!==0,l=Math.hypot(n,s)/2,h=c?l:n/2,u=c?l:s/2,d=Math.max(n,s)/2,f=t.brightness??0,p=f>0?Math.max(d*(1+of*f),hf*f)-d:0,v=f>0?d*(1+lf*f)-d:0,m=3*rf*(t.blur??0)+1.5*af*t.haloScale,g=Math.max(p,v,0)+m+2;return{x:a-h-g,y:o-u-g,width:2*(h+g),height:2*(u+g)}}paintInto(t,e,i,n=!1){this.ctx.save(),this.ctx.scale(i,i),this.ctx.translate(-e.x,-e.y);const s=t.selected?{...t,selected:!1}:t;n?this.paintGhost(s,1.5):this.paintShape(s),this.ctx.restore()}paintShape(t){this.ctx.save(),this.ctx.globalAlpha=1-t.transparency;const e=t.blur??0;e>0&&(this.ctx.filter=`blur(${(rf*e).toFixed(2)}px)`);const i=t.brightness??0;i>0&&this.paintDazzle(t,i),t.haloScale>0&&this.paintHalo(t),this.paintBase(t),this.ctx.restore(),t.selected&&this.paintSelectionHandles(t)}setStarPoints(t){this.starPoints=Math.max(0,Math.floor(t))}setRoll(t){this.roll=t}paintDazzle(t,e){const{x:i,y:n,width:s,height:a}=t.bounds,o=i+s/2,c=n+a/2,l=Math.max(s,a)/2,h=Math.max(l*(1+of*e),hf*e);if(h<=0)return;this.ctx.save(),this.ctx.globalCompositeOperation="lighter";const u=this.ctx.createRadialGradient(o,c,0,o,c,h);for(let d=0;d<=cf;d++){const f=d/cf,p=1/(1+24*f*f);this.ctx.globalAlpha=1,u.addColorStop(f,this.withAlpha(t.color,p*e*.55))}if(this.ctx.fillStyle=u,this.ctx.beginPath(),this.ctx.arc(o,c,h,0,2*Math.PI),this.ctx.fill(),this.starPoints>0){const d=l*(1+lf*e);this.ctx.lineWidth=Math.max(1,l*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const p=f/this.starPoints*Math.PI*2+this.roll,v=o+Math.cos(p)*d,m=c+Math.sin(p)*d,g=this.ctx.createLinearGradient(o,c,v,m);g.addColorStop(0,this.withAlpha(t.color,e*.55)),g.addColorStop(.35,this.withAlpha(t.color,e*.22)),g.addColorStop(1,this.withAlpha(t.color,0)),this.ctx.strokeStyle=g,this.ctx.beginPath(),this.ctx.moveTo(o,c),this.ctx.lineTo(v,m),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(t,e){if(e<=0)return t.color;const i=/^#([0-9a-f]{6})$/i.exec(t.color.trim());if(!i)return t.color;const n=Number.parseInt(i[1],16),s=a=>Math.round(a+(255-a)*e);return`rgb(${s(n>>16&255)}, ${s(n>>8&255)}, ${s(n&255)})`}withAlpha(t,e){const i=Math.max(0,Math.min(1,e)),n=/^#([0-9a-f]{6})$/i.exec(t.trim());if(!n)return t;const s=Number.parseInt(n[1],16);return`rgba(${s>>16&255}, ${s>>8&255}, ${s&255}, ${i.toFixed(3)})`}paintBase(t){this.ctx.fillStyle=this.dazzledFill(t,t.brightness??0),this.tracePath(t),this.ctx.fill()}paintGhost(t,e){this.ctx.save(),this.tracePath(t),this.ctx.setLineDash([e*3,e*2]),this.ctx.lineWidth=e,this.ctx.strokeStyle=t.color,this.ctx.stroke(),this.ctx.restore()}tracePath(t){if(this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:i,width:n,height:s}=t.bounds,a=n/2,o=s/2;this.ctx.ellipse(e+a,i+o,a,o,t.angle,0,2*Math.PI)}else{const{x:e,y:i,width:n,height:s}=t.bounds;this.ctx.save(),this.ctx.translate(e+n/2,i+s/2),this.ctx.rotate(t.angle),this.ctx.translate(-n/2,-s/2),t.points.forEach((a,o)=>{o===0?this.ctx.moveTo(a.x,a.y):this.ctx.lineTo(a.x,a.y)}),this.ctx.closePath(),this.ctx.restore()}}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=af*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(cn.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of cn.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,Gn,Gn,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(cn.handlePointsFor(t))}paintSelectionOnly(t){this.paintSelectionHandles(t)}paintPictureFrame(t,e,i){const n=this.ctx;if(n.save(),t&&t.length===4){n.strokeStyle="#39f",n.lineWidth=1.5,n.setLineDash([6,4]),n.beginPath(),n.moveTo(t[0].x,t[0].y);for(const s of t.slice(1))n.lineTo(s.x,s.y);n.closePath(),n.stroke(),n.setLineDash([])}for(const s of e){const a=No.landmarkColour(s.residualDeg),o=s.selected?3:2;s.selected&&(n.strokeStyle="#fff",n.lineWidth=o+3,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,Gn+2,Gn+2,0,0,2*Math.PI),n.stroke()),s.scene&&(n.strokeStyle=a,n.lineWidth=1,n.beginPath(),n.moveTo(s.picture.x,s.picture.y),n.lineTo(s.scene.x,s.scene.y),n.stroke(),n.fillStyle=a,n.beginPath(),n.ellipse(s.scene.x,s.scene.y,Gn,Gn,0,0,2*Math.PI),n.fill()),n.strokeStyle=a,n.lineWidth=o,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,Gn+2,Gn+2,0,0,2*Math.PI),n.stroke(),this.paintLabel(s.label,s.picture.x+Gn+5,s.picture.y-Gn-2,a)}i&&this.paintLabel(i,8,8,"#fff",13),n.restore()}static landmarkColour(t){return t===void 0?"#ffb000":t<=1?"#3c3":t<=3?"#ffb000":"#f33"}paintLabel(t,e,i,n,s=11){const a=this.ctx;a.save(),a.font=`${s}px system-ui, sans-serif`,a.textBaseline="top";const o=a.measureText(t).width;a.fillStyle="rgba(0, 0, 0, 0.6)",a.fillRect(e-3,i-2,o+6,s+4),a.fillStyle=n,a.fillText(t,e,i),a.restore()}paintGroupHandles(t){this.paintHandleFrame(cn.handlePointsFor({bounds:t,angle:0}),{includeRotate:!0})}paintOutline(t){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(t.nw.x,t.nw.y),this.ctx.lineTo(t.ne.x,t.ne.y),this.ctx.lineTo(t.se.x,t.se.y),this.ctx.lineTo(t.sw.x,t.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(t,{includeRotate:e}){this.paintOutline(t),this.ctx.fillStyle="lightgray";for(const i of sg){const n=t[i];this.ctx.fillRect(n.x-ec,n.y-ec,wu,wu)}e&&(this.ctx.beginPath(),this.ctx.moveTo(t.n.x,t.n.y),this.ctx.lineTo(t.rotate.x,t.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(t.rotate.x,t.rotate.y,ec+1,ec+1,0,0,2*Math.PI),this.ctx.fill())}}const uf=.05,df=.08,ff=2,pf=3,Cv=14,Pv=.02;class Lv{context;voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;level=1;master;output(t){return this.master||(this.master=t.createGain(),this.master.gain.value=this.level,this.master.connect(t.destination)),this.master}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",t);return}}this.context.state==="suspended"&&this.context.resume()}setSound(t){if(this.requested=t,!this.context)return;const e=this.keyFor(t);if(!e){this.silence();return}if(this.voice?.key!==e){this.stopVoice();const i=++this.voiceToken;e.startsWith("src:")?this.buildRecordedVoice(t.src,e,i):this.voice=this.buildSynthesizedVoice(t,e)}this.applyTo(this.voice,t)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),this.context?.close(),this.context=void 0,this.master=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(t){if(!(t.volume<=0))return t.src?`src:${t.src}`:t.kind==="none"?void 0:t.kind}applyTo(t,e){const i=this.context;if(!t||!i)return;const n=i.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,n,uf);for(const{param:s,ratio:a}of t.pitch)s.setTargetAtTime(Math.min(e.pitchHz*a,i.sampleRate/2-1),n,uf)}buildSynthesizedVoice(t,e){const i=this.context;if(i)switch(t.kind){case"hum":return this.buildHum(i,e);case"whistle":return this.buildWhistle(i,e);case"rumble":return this.buildRumble(i,e);case"crackle":return this.buildCrackle(i,e);default:return}}buildHum(t,e){const i=t.createOscillator();i.type="sawtooth";const n=t.createOscillator();n.type="sawtooth";const s=t.createBiquadFilter();s.type="lowpass",s.Q.value=1;const a=t.createGain();return a.gain.value=0,i.connect(s),n.connect(s),s.connect(a).connect(this.output(t)),i.start(),n.start(),{key:e,nodes:[s,a],sources:[i,n],volumeParam:a.gain,gainScale:.16,pitch:[{param:i.frequency,ratio:1},{param:n.frequency,ratio:1.006},{param:s.frequency,ratio:6}]}}buildWhistle(t,e){const i=t.createOscillator();i.type="sine";const n=t.createOscillator();n.type="sine",n.frequency.value=5;const s=t.createGain(),a=t.createGain();return a.gain.value=0,n.connect(s).connect(i.frequency),i.connect(a).connect(this.output(t)),i.start(),n.start(),{key:e,nodes:[s,a],sources:[i,n],volumeParam:a.gain,gainScale:.22,pitch:[{param:i.frequency,ratio:1},{param:s.gain,ratio:.012}]}}buildRumble(t,e){const i=t.createBufferSource();i.buffer=this.brownNoise(t),i.loop=!0;const n=t.createBiquadFilter();n.type="lowpass",n.Q.value=.8;const s=t.createGain();return s.gain.value=0,i.connect(n).connect(s).connect(this.output(t)),i.start(),{key:e,nodes:[n,s],sources:[i],volumeParam:s.gain,gainScale:1.4,pitch:[{param:n.frequency,ratio:1}]}}buildCrackle(t,e){const i=t.createBufferSource();i.buffer=this.whiteNoise(t),i.loop=!0;const n=t.createBiquadFilter();n.type="bandpass",n.Q.value=1.2;const s=t.createGain();s.gain.value=0;const a=t.createBufferSource();a.buffer=this.crackleEnvelope(t),a.loop=!0;const o=t.createGain();return o.gain.value=0,a.connect(o).connect(s.gain),i.connect(n).connect(s).connect(this.output(t)),i.start(),a.start(),{key:e,nodes:[n,s,o],sources:[i,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:n.frequency,ratio:4}]}}async buildRecordedVoice(t,e,i){const n=this.context;if(!n)return;let s;try{s=await this.getBuffer(t)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(i!==this.voiceToken||!this.context)return;const a=n.createBufferSource();a.buffer=s,a.loop=!0;const o=n.createGain();o.gain.value=0,a.connect(o).connect(this.output(n)),a.start(),this.voice={key:e,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(t){const e=this.context;if(!e)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(t);return i||(i=fetch(t).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${t}`);return n.arrayBuffer()}).then(n=>e.decodeAudioData(n)),this.buffers.set(t,i)),i}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*ff),t.sampleRate),i=e.getChannelData(0);for(let n=0;n<i.length;n++)i[n]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*ff),t.sampleRate),i=e.getChannelData(0);let n=0,s=0;for(let a=0;a<i.length;a++)n=(n+.02*(Math.random()*2-1))/1.02,i[a]=n,s=Math.max(s,Math.abs(n));if(s>0)for(let a=0;a<i.length;a++)i[a]/=s;return e}crackleEnvelope(t){if(!this.crackleBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*pf),t.sampleRate),i=e.getChannelData(0),n=Math.max(1,Math.floor(Pv*t.sampleRate)),s=Math.round(pf*Cv);for(let a=0;a<s;a++){const o=Math.floor(Math.random()*i.length),c=.4+Math.random()*.6;for(let l=0;l<n&&o+l<i.length;l++)i[o+l]=Math.max(i[o+l],c*(1-l/n))}this.crackleBuffer=e}return this.crackleBuffer}stopVoice(){const t=this.voice,e=this.context;if(this.voice=void 0,!t||!e)return;const i=e.currentTime;t.volumeParam.cancelScheduledValues(i),t.volumeParam.setTargetAtTime(0,i,df/3);const n=i+df;for(const s of t.sources){s.onended=()=>{s.disconnect();for(const a of t.nodes)a.disconnect()};try{s.stop(n)}catch{s.disconnect();for(const a of t.nodes)a.disconnect()}}}}class Zt{static svg(t){return`<svg viewBox="0 0 24 24" width="1.5em" height="1.5em" aria-hidden="true" focusable="false"><path d="${t}" fill="currentColor"/></svg>`}static outline(t){return`<svg viewBox="0 0 24 24" width="1.5em" height="1.5em" aria-hidden="true" focusable="false"><path d="${t}" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round" stroke-linecap="round"/></svg>`}static solid(t){return`<svg viewBox="0 0 24 24" width="1.5em" height="1.5em" aria-hidden="true" focusable="false"><path d="${t}" fill="currentColor" fill-rule="evenodd"/></svg>`}static BOOKMARK="M6 3.5h12a.5.5 0 0 1 .5.5v16.5L12 16.8l-6.5 3.7V4a.5.5 0 0 1 .5-.5z";static PICTURE="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z";static PICTURE_HILLS="M4.5 17.5l4.5-6 3 4 2.5-3 5 5z";static PIN="M12 21.5s-6.5-5.7-6.5-10.8a6.5 6.5 0 0 1 13 0c0 5.1-6.5 10.8-6.5 10.8z";static PIN_HOLE="M12 8.4a2.4 2.4 0 1 0 0 4.8 2.4 2.4 0 0 0 0-4.8z";static MILESTONES_OFF=Zt.outline(Zt.BOOKMARK);static MILESTONES_ON=Zt.solid(Zt.BOOKMARK);static PICTURES_OFF=Zt.outline(`${Zt.PICTURE}${Zt.PICTURE_HILLS}`);static PICTURES_ON=Zt.solid(`${Zt.PICTURE}${Zt.PICTURE_HILLS}`);static MAP_OFF=Zt.outline(`${Zt.PIN}${Zt.PIN_HOLE}`);static MAP_ON=Zt.solid(`${Zt.PIN}${Zt.PIN_HOLE}`);static SHARE=Zt.outline("M14 4l7 7-7 7v-4.2C8.6 13.8 5.4 15.6 3.5 19c.6-5.6 3.4-9.6 10.5-10.8V4z");static FOLDED=Zt.svg("M15.4 7.4 14 6l-6 6 6 6 1.4-1.4L10.8 12z");static UNFOLDED=Zt.svg("M8.6 16.6 10 18l6-6-6-6-1.4 1.4 4.6 4.6z");static PLAY=Zt.svg("M7.4 5v14l11-7z");static PAUSE=Zt.svg("M6 5h4v14H6zM14 5h4v14h-4z");static VOLUME=Zt.svg("M2 9.5v5h3.5l4.5 4.5V5L5.5 9.5H2zm12.5 2.5A4 4 0 0 0 12.5 8.5v7A4 4 0 0 0 14.5 12zM12.5 4.2v2.1a6.5 6.5 0 0 1 0 11.4v2.1a8.6 8.6 0 0 0 0-15.6z");static MUTED=Zt.svg("M2 9.5v5h3.5l4.5 4.5V5L5.5 9.5H2zM15 9.8l1.4-1.4 2.6 2.6 2.6-2.6 1.4 1.4-2.6 2.6 2.6 2.6-1.4 1.4-2.6-2.6-2.6 2.6-1.4-1.4 2.6-2.6z");static ENTER_FULLSCREEN=Zt.svg("M5 5h5v2H7v3H5V5zm9 0h5v5h-2V7h-3V5zM5 14h2v3h3v2H5v-5zm12 0h2v5h-5v-2h3v-3z");static EXIT_FULLSCREEN=Zt.svg("M8 5h2v5H5V8h3V5zm6 0h2v3h3v2h-5V5zM5 14h5v5H8v-3H5v-2zm9 0h5v2h-3v3h-2v-5z")}function _o(r){return[...r].sort((t,e)=>t.t-e.t)}function eh(r,t){let e;for(const i of _o(r)){if(i.t>t)break;e=i}return e}const ih=Math.PI/180,ic=180/Math.PI;class Ss{constructor(t,e,i){this.kind=t,this.canvasHeightPx=e,this.fovDeg=i;const n=i*ih/2;this.focalPx=t==="equidistant"?e/2/n:e/2/Math.tan(n)}focalPx;static of(t,e,i){return new Ss(t.projection,e,i)}degToPx(t){const e=t*ih;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*ic:2*Math.atan(t/(2*this.focalPx))*ic}angleDegToRadiusPx(t){const e=t*ih;return this.kind==="equidistant"?this.focalPx*e:this.focalPx*Math.tan(e)}halfWidthAngleDeg(t){return this.radiusPxToAngleDeg(this.canvasHeightPx*t/2)}radiusPxToAngleDeg(t){return this.kind==="equidistant"?t/this.focalPx*ic:Math.atan(t/this.focalPx)*ic}ofBounds(t){return{widthDeg:this.pxToDeg(t.width),heightDeg:this.pxToDeg(t.height)}}toBoundsSize(t){return{width:this.degToPx(t.widthDeg),height:this.degToPx(t.heightDeg)}}widthPx(t){return this.degToPx(Te.angularWidthDeg(t))}}class Ji{static fovOf(t,e){return di(t,e)?.fovDeg??fi.fieldOfViewDeg(t.instrument)}static toAngular(t){this.eachKeyframe(t,(e,i)=>({...e,angular:i.ofBounds(e.bounds)}))}static toBounds(t){this.eachKeyframe(t,(e,i)=>{if(!e.angular)return e;const{width:n,height:s}=i.toBoundsSize(e.angular),a={x:e.bounds.x+(e.bounds.width-n)/2,y:e.bounds.y+(e.bounds.height-s)/2,width:n,height:s};if(e.kind!=="polygon")return{...e,bounds:a};const o=e.bounds.width===0?1:n/e.bounds.width,c=e.bounds.height===0?1:s/e.bounds.height;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static toAim(t){this.eachKeyframe(t,(e,i,n)=>{const s=e.aim&&this.positionOf(t,e.aim,e.bounds,i,n);if(s&&Math.abs(s.x-e.bounds.x)<Ji.UNMOVED_PX&&Math.abs(s.y-e.bounds.y)<Ji.UNMOVED_PX)return e;const a=this.aimFrom(t,i,n,e.bounds);return a?{...e,aim:a}:e})}static UNMOVED_PX=.01;static aimOf(t,e,i){const n=Ss.of(t.instrument,Te.CANVAS_HEIGHT_PX,this.fovOf(t,e));return this.aimFrom(t,n,di(t,e),i)}static aimFrom(t,e,i,n){if(i?.headingDeg===void 0)return;const s=this.frameCentre(t),a=e.radiusPxToAngleDeg(n.x+n.width/2-s.x),o=e.radiusPxToAngleDeg(s.y-(n.y+n.height/2));return{azimuthDeg:((i.headingDeg+a)%360+360)%360,altitudeDeg:i.pitchDeg+o}}static toPosition(t){this.eachKeyframe(t,(e,i,n)=>{const s=e.aim&&this.positionOf(t,e.aim,e.bounds,i,n);return s?{...e,bounds:{...e.bounds,...s}}:e})}static positionOf(t,e,i,n,s){if(s?.headingDeg===void 0)return;const a=this.frameCentre(t),o=this.shortestArc(e.azimuthDeg-s.headingDeg),c=e.altitudeDeg-s.pitchDeg;return{x:a.x+this.offAxisPx(n,o)-i.width/2,y:a.y-this.offAxisPx(n,c)-i.height/2}}static frameCentre(t){return{x:fi.frameWidthPx(t.instrument,Te.CANVAS_HEIGHT_PX)/2,y:Te.CANVAS_HEIGHT_PX/2}}static shortestArc(t){return(t%360+540)%360-180}static offAxisPx(t,e){return Math.abs(e)>=Ji.OFF_CANVAS_DEG?Math.sign(e)*Ji.OFF_CANVAS_PX:t.angleDegToRadiusPx(e)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(t,e,i){const n=fi.frameWidthPx(e,Te.CANVAS_HEIGHT_PX)/2,s=fi.frameWidthPx(t.instrument,Te.CANVAS_HEIGHT_PX)/2,a=Te.CANVAS_HEIGHT_PX/2;for(const o of[...t.timeline.allKeyframes]){const c=this.fovOf(t,o.t),l=i?.get(o.t)??c,h=Ss.of(e,Te.CANVAS_HEIGHT_PX,l),u=Ss.of(t.instrument,Te.CANVAS_HEIGHT_PX,c);t.timeline.addKeyframe(o.t,o.shapes.map(d=>{const{bounds:f}=d.shape,p=f.x+f.width/2-n,v=f.y+f.height/2-a,m=Math.hypot(p,v),g=m===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(m))/m,S={...f,x:s+p*g-f.width/2,y:a+v*g-f.height/2};return{...d,shape:{...d.shape,bounds:S}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:i}=t;for(const n of[...i.allKeyframes]){const s=di(t,n.t),a=this.fovOf(t,n.t),o=Ss.of(t.instrument,Te.CANVAS_HEIGHT_PX,a);i.addKeyframe(n.t,n.shapes.map(c=>({...c,shape:e(c.shape,o,s)})))}}}function Ov(r){return Mn.restore(Nv(r),r.provenance)}function Nv(r){return Ji.toAngular(r),Ji.toAim(r),{version:1,id:r.id,time:r.event.time,endTime:r.event.endTime,durationSeconds:r.event.durationSeconds,utcOffsetHours:r.event.utcOffsetHours,timeZone:r.event.timeZone,place:r.event.place,observer:r.observer,account:r.account,sources:r.sources?.length?r.sources:void 0,sway:r.sway,vehicle:r.vehicle,description:r.event.description,tags:r.event.tags,timeline:r.timeline.toJSON(),observerTrack:r.observerTrack.toJSON(),weatherTrack:r.weatherTrack.toJSON(),soundTrack:r.soundTrack.toJSON(),weather:r.weather,decor:r.decor,milestones:r.milestones.length>0?r.milestones:void 0,references:r.references.length>0?r.references:void 0,roads:r.roads.length>0?r.roads:void 0,weatherSource:r.weatherSource,instrument:r.instrumentId,exposureSeconds:r.exposureSeconds,iso:r.iso,lightPollution:r.lightPollution,interpretation:r.interpretation}}function Fv(r){const{recording:t,provenance:e}=Mn.strip(r),i=Uv(t);return i.provenance=e,i}function Uv(r){const t=[],e=new kl({eventType:"sighting",time:r.time,endTime:r.endTime,durationSeconds:r.durationSeconds,utcOffsetHours:r.utcOffsetHours,timeZone:r.timeZone,place:r.place,description:r.description,tags:r.tags},Ul.fromJSON(r.timeline,t),r.observerTrack?Po.fromJSON(r.observerTrack):new Po,r.weatherTrack?Lo.fromJSON(r.weatherTrack):new Lo,r.soundTrack?Oo.fromJSON(r.soundTrack):new Oo,r.observer&&{id:r.observer.id,title:r.observer.title,lastName:r.observer.lastName,firstNames:r.observer.firstNames},r.id,r.weather,r.decor??[],r.weatherSource,r.instrument,r.exposureSeconds??r.observerTrack?.keyframes.map(i=>i.pose.exposureSeconds).find(i=>i!==void 0),_o(r.milestones??[]),r.references??[],r.roads??[]);return e.account=r.account,e.sources=r.sources,e.sway=r.sway,e.iso=r.iso,e.lightPollution=r.lightPollution,e.vehicle=r.vehicle,e.interpretation=r.interpretation,e.loadIssues=t,Ji.toBounds(e),Ji.toPosition(e),e}class Cr{static EN={"unknown-key":"{path}: unknown key, ignored","wrong-type":"{path}: expected {expected}, found {found}","not-in-list":"{path}: {found} is not one of {expected}",defaulted:"{path}: missing, {expected} used",unplaced:"{path}: no aim (and no bounds), drawn at the middle of the view",unsized:"{path}: no angular size (and no bounds), drawn one pixel wide","pixels-over-angles":"{path}: bounds restated without aim or angular, so the shape follows the pixels"};static text(t,e=Cr.EN){return e[t.kind].replace("{path}",t.path).replace("{expected}",t.expected??"").replace("{found}",t.found??"")}static warn(t,e){if(t.length===0)return;const i=t.map(n=>` ${Cr.text(n)}`);console.warn(`UFO@home: ${t.length} problem(s) in ${e??"this recording"}:
1095
1152
  ${i.join(`
1096
- `)}`)}}class An{constructor(t){this.format=t}issues(t){const e=[];return this.object(t,this.format,"",e),e}object(t,e,i,n){if(!An.isObject(t)){n.push({kind:"wrong-type",path:i||"(the file)",expected:"object",found:An.typeOf(t)});return}for(const[s,a]of Object.entries(t)){const o=i?`${i}.${s}`:s,c=e[s];c?this.field(a,c,o,n):n.push({kind:"unknown-key",path:o})}}field(t,e,i,n){if(An.isStated(t)){this.field(t.value,e,i,n);return}if(!(e.loose||t===void 0||t===null))switch(e.type){case"enum":(typeof t!="string"||!e.values?.includes(t))&&n.push({kind:"not-in-list",path:i,expected:(e.values??[]).map(s=>`"${s}"`).join(", "),found:JSON.stringify(t)});return;case"object":e.fields?this.object(t,e.fields,i,n):An.isObject(t)||n.push({kind:"wrong-type",path:i,expected:"object",found:An.typeOf(t)});return;case"array":Array.isArray(t)?e.fields&&t.forEach((s,a)=>{const o=An.isStated(s)?s.value:s;this.object(o,e.fields,`${i}.${a}`,n)}):n.push({kind:"wrong-type",path:i,expected:"array",found:An.typeOf(t)});return;default:typeof t!==e.type&&n.push({kind:"wrong-type",path:i,expected:e.type,found:An.typeOf(t)})}}static isObject(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}static isStated(t){return An.isObject(t)&&"value"in t&&Object.keys(t).every(e=>e==="value"||e==="basis"||e==="rationale")}static typeOf(t){return Array.isArray(t)?"array":t===null?"null":typeof t}}class Cn{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static windowEndingAt(t,e){const i=Number.isFinite(e)?Math.max(0,e):0,n=Math.max(0,t-i*1e3),s=Math.max(0,t-n);return{fromMs:n,toMs:t,ms:s,seconds:s/1e3}}static instants(t,e,i,n,s){if(!(n>0))return 1;const a=s>0?Cn.travelDegOver(t,e,i,i+n*1e3)/s/Cn.PIXELS_PER_INSTANT:0,o=Cn.flashesOver(t,n)*Cn.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(a,o));return c<2?1:Math.min(Cn.MAX_INSTANTS,c)}static travelDegOver(t,e,i,n){let s=0;for(const a of t){if(!a.track||a.track.length<2)continue;const o=Cn.directionAt(a,e,i),c=Cn.directionAt(a,e,n),l=Math.min(1,Math.max(-1,o.x*c.x+o.y*c.y+o.z*c.z));s=Math.max(s,Math.acos(l)*180/Math.PI)}return s}static flashesOver(t,e){let i=0;for(const n of t)for(const s of n.lights??[])s.pattern.kind==="flash"&&(i=Math.max(i,s.pattern.perMinute));return i/60*e}static directionAt(t,e,i){const n=Io(t,i),s=n.eastM,a=n.altitudeM-e,o=n.northM,c=Math.hypot(s,a,o);return c===0?{x:0,y:1,z:0}:{x:s/c,y:a/c,z:o/c}}}function ag(r,t){for(const e of r){const i=e.toLowerCase().split("-")[0];if(t.includes(i))return i}return"en"}class fl{static preferencesFor(t){const e=navigator.languages??[],i=this.declaredFor(t);return i?[i,...e]:e}static declaredFor(t){for(let e=t;e;){const i=e.closest("[lang]")?.getAttribute("lang")?.trim();if(i)return i;const n=e.getRootNode();e=n instanceof ShadowRoot?n.host:void 0}}}class $s{constructor(t){this.preferences=t}read(t){if(t===void 0||typeof t=="string")return t===""?void 0:t;for(const i of this.preferences){const n=t[i]??t[$s.base(i)];if(n)return n}const e=new Set(this.preferences.map(i=>$s.base(i)));for(const[i,n]of Object.entries(t))if(n&&e.has($s.base(i)))return n;return Object.values(t).find(i=>i)??void 0}write(t,e,i){const n=e?.trim()?e.trim():void 0;if(t===void 0||typeof t=="string")return n;const s={...t},a=Object.keys(s).find(o=>o===i)??Object.keys(s).find(o=>$s.base(o)===$s.base(i))??i;return n===void 0?delete s[a]:s[a]=n,Object.keys(s).length===0?void 0:s}static base(t){return t.toLowerCase().split("-")[0]}}const rg=["en","fr","es","it"],kv={en:()=>is(()=>Promise.resolve().then(()=>Hv),void 0,import.meta.url).then(r=>r.ufoMessages_en),fr:()=>is(()=>import("./UfoMessages_fr-B7ekN0RL.js"),[],import.meta.url).then(r=>r.ufoMessages_fr),es:()=>is(()=>import("./UfoMessages_es-DYc7i3SM.js"),[],import.meta.url).then(r=>r.ufoMessages_es),it:()=>is(()=>import("./UfoMessages_it-BDc9SDxc.js"),[],import.meta.url).then(r=>r.ufoMessages_it)};function zv(r){return kv[r]()}function Bv(r){switch(r){case"fr":return is(()=>import("./SceneNames_fr-0Wzm8zKy.js"),[],import.meta.url).then(t=>t.sceneNames_fr);case"es":return is(()=>import("./SceneNames_es-C1QdYSKO.js"),[],import.meta.url).then(t=>t.sceneNames_es);case"it":return is(()=>import("./SceneNames_it-C5oOps-9.js"),[],import.meta.url).then(t=>t.sceneNames_it);default:return Promise.resolve(void 0)}}const og={play:"Play",pause:"Pause",noDuration:"No observation duration",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",mute:"Mute",unmute:"Unmute",showObserverMap:"Show where the observer was",hideObserverMap:"Hide where the observer was",mapImageryUnavailable:"Aerial imagery unavailable",zoomMapIn:"Zoom in",zoomMapOut:"Zoom out",fitMap:"Back to the whole path",placeObserverHere:"Put the observer here",showReferences:"Show the pictures of the place",hideReferences:"Hide the pictures of the place",referenceOpacity:"Picture opacity",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",observerHere:"The observer, here",decorHere:"Scenery",recordingIssues:"{count} problem(s) in this recording: it may not play as its author meant",issueTemplates:Cr.EN},Hv=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:og},Symbol.toStringTag,{value:"Module"})),cg=Math.PI/180,Gv=180/Math.PI,Vv=256,lg=19,Wv=1.25;function hg(r,t){return 156543.03392*Math.cos(r*cg)/2**t}function ug(r,t){return hg(r,t)*Vv}function Xv(r,t){let e=0;for(;e<lg&&ug(r,e+1)>=t;)e++;return e}function dg(r,t){return ug(r,t)}function Yv(r,t){const e=t*Wv;let i=0;for(;i<lg&&hg(r,i)>e;)i++;return i}function tl(r){const t=r*cg;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function fg(r,t,e){const i=2**e;return{x:(r+180)/360*i,y:tl(t)*i}}function pg(r,t,e){const i=tl(r.north),n=tl(r.south);return{x:(t-r.west)/(r.east-r.west),y:(tl(e)-i)/(n-i)}}function qv(r,t,e){const{x:i,y:n}=fg(r,t,e);return{x:Math.floor(i),y:Math.floor(n),z:e}}function $v(r){const t=2**r.z,e=r.x/t*360-180,i=(r.x+1)/t*360-180,n=mf(r.y,t);return{south:mf(r.y+1,t),north:n,west:e,east:i}}function mf(r,t){const e=r/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*Gv}function mg(r,t,e,i){const n=qv(r,t,e),s=Math.floor(i/2),a=[];for(let l=-s;l<=s;l++)for(let h=-s;h<=s;h++)a.push({x:n.x+h,y:n.y+l,z:e});const o=a.map($v),c={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:a,bounds:c}}class va{constructor(t){this.ctx=t}static SCALE_STEPS_M=[5e3,2e3,1e3,500,200,100,50,20,10,5];static MARKER_RADIUS_PX=8.5;static ON_MARKER_M=3;targets=[];hitTest(t,e){let i,n=1/0;for(const s of this.targets){const a=Math.hypot(s.x-t,s.y-e);a>s.radius||a>n||(i=s,n=a)}return i}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(t){const{ctx:e}=this;e.save(),this.targets=[],e.clearRect(0,0,this.width,this.height),this.paintGround(t),this.paintNight(t.nightFraction),this.paintPath(t),t.position?(this.paintCone(t,t.position),this.paintDecor(t),this.paintMarkers(t),this.paintObserver(t,t.position)):(this.paintDecor(t),this.paintMarkers(t)),this.paintNorth(),this.paintFooter(t.bounds,t.attribution),e.restore()}toCanvas(t,e,i){const n=pg(t,i,e);return{x:n.x*this.width,y:n.y*this.height}}paintGround(t){const{ctx:e}=this;e.fillStyle="#1d2321",e.fillRect(0,0,this.width,this.height);const i=t.imagery;if(!i)return;const n=this.toCanvas(t.bounds,i.bounds.north,i.bounds.west),s=this.toCanvas(t.bounds,i.bounds.south,i.bounds.east);e.drawImage(i.source,n.x,n.y,s.x-n.x,s.y-n.y)}paintNight(t=0){if(t<=0)return;const{ctx:e}=this;e.save(),e.fillStyle=`rgba(6, 12, 30, ${Math.min(t,1)*.78})`,e.fillRect(0,0,this.width,this.height),e.restore()}paintDecor(t){const{ctx:e}=this;for(const i of t.decor){const n=this.toCanvas(t.bounds,i.lat,i.lng);if(i.label&&this.targets.push({kind:"decor",label:i.label,lat:i.lat,lng:i.lng,x:n.x,y:n.y,radius:7}),e.beginPath(),e.rect(n.x-3.5,n.y-3.5,7,7),e.fillStyle="rgba(120, 220, 255, 0.85)",e.fill(),e.lineWidth=1.5,e.strokeStyle="rgba(0, 0, 0, 0.7)",e.stroke(),i.headingDeg===void 0)continue;const s=(i.headingDeg-90)*Math.PI/180;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x+Math.cos(s)*10,n.y+Math.sin(s)*10),e.lineWidth=3,e.strokeStyle="rgba(0, 0, 0, 0.6)",e.stroke(),e.lineWidth=1.5,e.strokeStyle="rgba(120, 220, 255, 0.9)",e.stroke()}}paintPath(t){if(!t.path.moved)return;const{ctx:e}=this,i=t.path.points.map(n=>this.toCanvas(t.bounds,n.lat,n.lng));e.beginPath(),e.moveTo(i[0].x,i[0].y);for(const n of i.slice(1))e.lineTo(n.x,n.y);e.lineJoin="round",e.lineCap="round",e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=5,e.stroke(),e.strokeStyle="rgba(255, 255, 255, 0.9)",e.lineWidth=2,e.stroke()}paintCone(t,e){const{headingDeg:i,coneHalfAngleDeg:n}=t;if(i===void 0||n===void 0)return;const{ctx:s}=this,a=this.toCanvas(t.bounds,e.lat,e.lng),o=Math.hypot(this.width,this.height),c=(i-90)*Math.PI/180,l=n*Math.PI/180;s.save(),s.beginPath(),s.moveTo(a.x,a.y),s.arc(a.x,a.y,o,c-l,c+l),s.closePath();const h=s.createRadialGradient(a.x,a.y,0,a.x,a.y,o);h.addColorStop(0,"rgba(255, 224, 130, 0.55)"),h.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),h.addColorStop(1,"rgba(255, 224, 130, 0)"),s.fillStyle=h,s.fill(),s.restore()}paintMarkers(t){const{ctx:e}=this;e.textAlign="center",e.textBaseline="middle",e.font="bold 10px sans-serif";for(const i of[...t.markers].sort((n,s)=>Number(n.current)-Number(s.current))){const n=this.toCanvas(t.bounds,i.lat,i.lng);this.targets.push({kind:"milestone",label:i.note?`${i.label} — ${i.note}`:i.label,lat:i.lat,lng:i.lng,t:i.t,x:n.x,y:n.y,radius:va.MARKER_RADIUS_PX}),e.beginPath(),e.arc(n.x,n.y,va.MARKER_RADIUS_PX,0,Math.PI*2),e.fillStyle=i.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",e.fill(),e.lineWidth=2,e.strokeStyle="rgba(255, 255, 255, 0.9)",e.stroke(),e.fillStyle=i.current?"#1d2321":"#fff",e.fillText(i.label,n.x,n.y)}}paintObserver(t,e){const{ctx:i}=this,n=this.toCanvas(t.bounds,e.lat,e.lng);t.observerLabel&&this.targets.push({kind:"observer",label:t.observerLabel,lat:e.lat,lng:e.lng,x:n.x,y:n.y,radius:8});const s=t.markers.some(a=>{if(!a.current)return!1;const o=ai(a.lat,a.lng,e.lat,e.lng);return Math.hypot(o.x,o.z)<=va.ON_MARKER_M});i.beginPath(),i.arc(n.x,n.y,s?va.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),s||(i.fillStyle="#ff5a3c",i.fill()),i.lineWidth=4,i.strokeStyle="rgba(0, 0, 0, 0.5)",i.stroke(),i.lineWidth=s?3:2.5,i.strokeStyle=s?"#ff5a3c":"#fff",i.stroke()}paintNorth(){const{ctx:t}=this,e=this.width-14,i=16;t.beginPath(),t.moveTo(e,i-9),t.lineTo(e-4.5,i+5),t.lineTo(e,i+2),t.lineTo(e+4.5,i+5),t.closePath(),t.fillStyle="rgba(255, 255, 255, 0.92)",t.strokeStyle="rgba(0, 0, 0, 0.6)",t.lineWidth=1,t.fill(),t.stroke(),t.font="bold 9px sans-serif",t.textAlign="center",t.textBaseline="top",t.strokeText("N",e,i+6),t.fillText("N",e,i+6)}paintFooter(t,e){const{ctx:i}=this;i.font="9px sans-serif",i.textBaseline="bottom";const n=e?this.wrap(e,this.width-20):[];let s=this.height-4;i.textAlign="right";for(const f of n.slice().reverse())this.paintOutlinedText(f,this.width-6,s),s-=11;const a=(t.south+t.north)/2,c=Math.abs(ai(a,t.east,a,t.west).x)/this.width,l=va.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=s-3;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.6)",i.beginPath(),i.moveTo(u,d),i.lineTo(u+h,d),i.stroke(),i.lineWidth=1.5,i.strokeStyle="rgba(255, 255, 255, 0.95)",i.stroke(),i.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,u,d-3)}paintOutlinedText(t,e,i){const{ctx:n}=this;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.75)",n.strokeText(t,e,i),n.fillStyle="#fff",n.fillText(t,e,i)}wrap(t,e){const i=[];let n="";for(const s of t.split(" ")){const a=n?`${n} ${s}`:s;n&&this.ctx.measureText(a).width>e?(i.push(n),n=s):n=a}return n&&i.push(n),i}}class Ye{static MIN_ZOOM=.25;static MAX_ZOOM=64;zoom=1;centerX=.5;centerY=.5;get changed(){return this.zoom!==1||this.centerX!==.5||this.centerY!==.5}get zoomFactor(){return this.zoom}reset(){this.zoom=1,this.centerX=.5,this.centerY=.5}zoomAt(t,e,i){const n=Math.min(Ye.MAX_ZOOM,Math.max(Ye.MIN_ZOOM,this.zoom*i)),s=this.centerX+(t-.5)/this.zoom,a=this.centerY+(e-.5)/this.zoom;this.centerX=s-(t-.5)/n,this.centerY=a-(e-.5)/n,this.zoom=n}panBy(t,e){this.centerX-=t/this.zoom,this.centerY-=e/this.zoom}refit(t,e){if(!this.changed)return;const i=this.boundsWithin(t),n=Ye.mercatorY01(e.north),s=Ye.mercatorY01(e.south),a=Ye.mercatorY01(i.north),o=Ye.mercatorY01(i.south);this.zoom=(e.east-e.west)/(i.east-i.west),this.centerX=((i.west+i.east)/2-e.west)/(e.east-e.west),this.centerY=((a+o)/2-n)/(s-n)}keepInView(t,e,i){if(!this.changed)return!1;const n=this.boundsWithin(t),s=Ye.mercatorY01(n.north),a=Ye.mercatorY01(n.south),o=(e.lng-n.west)/(n.east-n.west),c=(Ye.mercatorY01(e.lat)-s)/(a-s);return o>=i&&o<=1-i&&c>=i&&c<=1-i?!1:(this.panBy(.5-o,.5-c),!0)}boundsWithin(t){if(!this.changed)return t;const e=.5/this.zoom,i=Ye.mercatorY01(t.north),n=Ye.mercatorY01(t.south),s=t.east-t.west;return{west:t.west+(this.centerX-e)*s,east:t.west+(this.centerX+e)*s,north:Ye.latitudeAt(i+(this.centerY-e)*(n-i)),south:Ye.latitudeAt(i+(this.centerY+e)*(n-i))}}static expand(t,e){const i=t.east-t.west,n=t.north-t.south;return{west:t.west-i*e,east:t.east+i*e,south:t.south-n*e,north:t.north+n*e}}static pointAt(t,e,i){const n=Ye.mercatorY01(t.north),s=Ye.mercatorY01(t.south);return{lat:Ye.latitudeAt(n+i*(s-n)),lng:t.west+e*(t.east-t.west)}}static mercatorY01(t){const e=t*Math.PI/180;return(1-Math.log(Math.tan(e)+1/Math.cos(e))/Math.PI)/2}static latitudeAt(t){return Math.atan(Math.sinh(Math.PI*(1-2*t)))*180/Math.PI}}const fn=256,gf=3,Kv=32768;class Zv{fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(t,e){const i=(t.south+t.north)/2,n=(t.west+t.east)/2,s=Math.abs(ai(i,t.east,i,t.west).x),a=Math.abs(ai(t.north,n,t.south,n).z),o=Xv(i,Math.max(s,a)),{tiles:c}=mg(n,i,o,gf),l=gf*fn,h=new Float32Array(l*l),u=c[0];await Promise.all(c.map(f=>this.decodeTileInto(f,u,h,l)));const d=new Float32Array(e.width*e.height);for(let f=0;f<e.height;f++){const p=t.north+(t.south-t.north)*(f/(e.height-1));for(let v=0;v<e.width;v++){const m=t.west+(t.east-t.west)*(v/(e.width-1));d[f*e.width+v]=this.sampleAt(p,m,o,u,h,l)}}return{heights:d,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,i,n){const s=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),a=await this.fetchImpl(s);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${s}`);const o=await createImageBitmap(await a.blob()),c=document.createElement("canvas");c.width=fn,c.height=fn;const l=c.getContext("2d");if(!l)throw new Error("2D canvas context unavailable");l.drawImage(o,0,0);const{data:h}=l.getImageData(0,0,fn,fn),u=(t.x-e.x)*fn,d=(t.y-e.y)*fn;for(let f=0;f<fn;f++)for(let p=0;p<fn;p++){const v=(f*fn+p)*4,m=h[v]*256+h[v+1]+h[v+2]/256-Kv,g=u+p,S=d+f;i[S*n+g]=m}}sampleAt(t,e,i,n,s,a){const{x:o,y:c}=fg(e,t,i),l=(o-n.x)*fn,h=(c-n.y)*fn,u=Math.max(0,Math.min(a-1,Math.floor(l))),d=Math.max(0,Math.min(a-1,Math.floor(h))),f=Math.min(a-1,u+1),p=Math.min(a-1,d+1),v=l-u,m=h-d,g=s[d*a+u],S=s[d*a+f],y=s[p*a+u],M=s[p*a+f],b=g+(S-g)*v,w=y+(M-y)*v;return b+(w-b)*m}}const el=256,Jv=5;async function jv(r,t,e,i){const n=(r.south+r.north)/2,s=(r.west+r.east)/2,a=Math.abs(ai(n,r.east,n,r.west).x),o=Math.abs(ai(r.north,s,r.south,s).z),c=Math.max(a,o),{zoom:l,gridSize:h}=Qv(n,c,Math.max(t.width,t.height)),{tiles:u,bounds:d}=mg(s,n,l,h),f=h*el,p=document.createElement("canvas");p.width=f,p.height=f;const v=p.getContext("2d");if(!v)throw new Error("2D canvas context unavailable");const m=u[0];await Promise.all(u.map(async M=>{const b=e(M),w=await i(b);if(!w.ok)throw new Error(`Imagery tile fetch failed (${w.status}): ${b}`);const T=await createImageBitmap(await w.blob());v.drawImage(T,(M.x-m.x)*el,(M.y-m.y)*el)}));const g=Math.min(Math.max(t.width,t.height),f);if(g===f)return{source:p,width:f,height:f,bounds:d};const S=document.createElement("canvas");S.width=g,S.height=g;const y=S.getContext("2d");if(!y)throw new Error("2D canvas context unavailable");return y.drawImage(p,0,0,f,f,0,0,g,g),{source:S,width:g,height:g,bounds:d}}function Qv(r,t,e){let i=Yv(r,t/Math.max(1,e)),n=vf(r,i,t);for(;n>Jv&&i>0;)i--,n=vf(r,i,t);return{zoom:i,gridSize:n,mPerPixel:dg(r,i)/el}}function vf(r,t,e){const i=Math.ceil(e/2/dg(r,t));return Math.max(3,2*i+1)}class t2{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(t,e){return jv(t,e,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}class Tn{attribution="Roads © OpenStreetMap contributors, as surveyed today";contemporary=!0;static DRIVABLE=["motorway","trunk","primary","secondary","tertiary","unclassified","residential","service","track","motorway_link","trunk_link","primary_link","secondary_link","tertiary_link"];static WIDTH_M={motorway:11,trunk:9,primary:8,secondary:7,tertiary:6.5,unclassified:5.5,residential:5.5,service:4,track:3.5};static DEFAULT_WIDTH_M=5;static ENDPOINTS=["https://overpass-api.de/api/interpreter","https://overpass.kumi.systems/api/interpreter","https://overpass.private.coffee/api/interpreter"];fetchImpl;endpoints;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.endpoints=t.endpoints??Tn.ENDPOINTS}static queue=Promise.resolve();static RETRY_MS=4e3;async getRoads(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:30];way["highway"~"^(${Tn.DRIVABLE.join("|")})$"](${e});out geom;`;return this.waysFrom(await this.queued(()=>this.ask(i)))}waysFrom(t){const e=[];for(const i of t.elements??[]){const n=i.geometry,s=i.tags;!s||!n||n.length<2||e.push({id:`osm-${i.id??e.length}`,name:s.name,surface:Tn.surfaceOf(s),widthM:Tn.widthOf(s),points:n.map(a=>({lat:a.lat,lng:a.lon}))})}return e}queued(t){const e=Tn.queue.then(t,t);return Tn.queue=e.catch(()=>{}),e}async ask(t){let e;for(const i of this.endpoints)for(let n=0;n<2;n++){try{const s=await this.fetchImpl(`${i}?data=${encodeURIComponent(t)}`);if(s.ok)return await s.json();if(e=new Error(`${new URL(i).host} refused (${s.status})`),s.status!==429&&s.status!==504)break}catch(s){e=new Error(`${new URL(i).host} unreachable (${String(s)})`);break}await new Promise(s=>setTimeout(s,Tn.RETRY_MS))}throw e??new Error("No Overpass instance answered")}static widthOf(t){const e=Number.parseFloat(t.width??t.est_width??"");if(Number.isFinite(e)&&e>0)return e;const i=Number.parseInt(t.lanes??"",10);return Number.isFinite(i)&&i>0?i*3.5:Tn.WIDTH_M[t.highway]??Tn.DEFAULT_WIDTH_M}static surfaceOf(t){const e=t.surface;return e==="dirt"||e==="earth"||e==="mud"?"dirt":e==="gravel"||e==="fine_gravel"||e==="compacted"||e==="ground"||e==="sand"||e==="unpaved"?"gravel":e?"paved":t.highway==="track"?"gravel":"paved"}}const nh="https://ufoathome.org/roads/index.json";class Qd{attributionRead;contemporaryRead;fetchImpl;indexUrls;fallback;index;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Qd.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Roads © OpenStreetMap contributors"}get contemporary(){return this.contemporaryRead??this.fallback?.contemporary??!0}async getRoads(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getRoads(t);return this.attributionRead=this.fallback.attribution,this.contemporaryRead=this.fallback.contemporary,i}async held(t){let e;try{e=await this.load()}catch{return}const i=e.find(({entry:n})=>n.north>=t.north&&n.south<=t.south&&n.east>=t.east&&n.west<=t.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.ways)?(this.attributionRead=s.attribution,this.contemporaryRead=s.contemporary,s.ways):void 0}catch{return}}load(){return this.index??=this.fetchFirstAvailable(),this.index}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.76.0")}`,e=typeof location>"u"?void 0:new URL("/roads/index.json",location.href).href;return(e&&e!==nh?[e,nh]:[nh]).map(i=>i+t)}}function e2(){return{elevation:new Zv,imagery:gg(),roads:i2()}}function gg(){return new t2}function i2(){return new Qd({fallback:new Tn})}const n2=new Set,yr="show-observer-map",_r="hide-milestones";class ge extends HTMLElement{static get observedAttributes(){return["src",yr,_r]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;issuesBox;issuesButton;issuesPanel;playPauseButton;static OBSERVER_MAP_MIN_SPAN_M=400;static OBSERVER_MAP_MARGIN=.6;static OBSERVER_MAP_IMAGERY_PX=768;fullscreenButton;cornerButtons;observerMapButton;referencesButton;referenceOpacityInput;referencesShownState=!0;referenceOpacityTouched=!1;milestonesButton;observerMapPanel;observerMapCanvas;observerMapRenderer;mapZoomInButton;mapZoomOutButton;mapFitButton;observerMapView=new Ye;observerMapDrag;suppressObserverMapClick=!1;observerMapImageryTimer;observerPlacing=!1;seekInput;playbackFlash;milestoneMarks;milestoneCaption;timeStartLabel;timeEndLabel;timePill;muteButton;volumeInput;controlsRight;seekSegments;seekDot;seekPreview;seekPreviewCanvas;seekPreviewTitle;seekPreviewTime;observerPath;observerMapBounds;observerMapImagery;observerMapImageryBounds;observerMapImageryViewWidth=0;observerMapImageryLoading=!1;observerMapImageryCredit;observerMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=kl.create();issues=[];issueCheck=0;sightingAudio=new Lv;soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;steadyObserver=!1;selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;messages=og;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.updateMuteButton(),this.resizeObserverMap()};observerMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeObserverMap());resizeObserverMap(){this.observerMapPanel.hidden||(this.sizeObserverMapCanvas(),this.paintObserverMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=t=>{t.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),i=e&&this.shapeAt(e.x,e.y),n=this.said.read(i?.shape.title);if(!n){this.tooltip.hidden=!0;return}this.tooltip.textContent=n,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-s.left+12}px`,this.tooltip.style.top=`${t.clientY-s.top+12}px`};handleObserverMapPointerMove=t=>{if(this.dragObserverMap(t))return;const e=this.observerMapTargetFrom(t);if(!e){if(!this.observerPlacing){this.tooltip.hidden=!0,this.observerMapCanvas.style.cursor="grab";return}this.observerMapCanvas.style.cursor="crosshair",this.showObserverMapTooltip(t,this.messages.placeObserverHere);return}this.observerMapCanvas.style.cursor="pointer",this.showObserverMapTooltip(t,e.label)};showObserverMapTooltip(t,e){this.tooltip.textContent=e,this.tooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-i.left+12}px`,this.tooltip.style.top=`${t.clientY-i.top+12}px`}handleObserverMapClick=t=>{if(this.suppressObserverMapClick){this.suppressObserverMapClick=!1;return}const e=this.observerMapTargetFrom(t);if(!e){this.observerPlacing&&this.placeObserverFrom(t);return}if(e.kind==="milestone"&&e.t!==void 0){this.player.seek(e.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:e.lat,lng:e.lng,kind:e.kind},bubbles:!0,composed:!0}))};observerMapTargetFrom(t){const e=this.observerMapCanvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return this.observerMapRenderer.hitTest((t.clientX-e.left)/e.width*this.observerMapCanvas.width,(t.clientY-e.top)/e.height*this.observerMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};handleObserverMapPointerDown=t=>{t.button===0&&(this.suppressObserverMapClick=!1,this.observerMapDrag={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,moved:!1})};handleObserverMapPointerUp=t=>{const e=this.observerMapDrag;!e||e.pointerId!==t.pointerId||(this.observerMapDrag=void 0,this.observerMapCanvas.classList.remove("dragging"),e.moved&&(this.suppressObserverMapClick=!0,this.paintObserverMap(this.currentTime),this.observerMapCanvas.hasPointerCapture?.(t.pointerId)&&this.observerMapCanvas.releasePointerCapture(t.pointerId)))};dragObserverMap(t){const e=this.observerMapDrag;if(!e||e.pointerId!==t.pointerId)return!1;if(!e.moved){if(Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<ge.OBSERVER_MAP_DRAG_PX)return!1;e.moved=!0,this.tooltip.hidden=!0,this.observerMapCanvas.classList.add("dragging"),this.observerMapCanvas.setPointerCapture?.(t.pointerId)}const i=this.observerMapCanvas.getBoundingClientRect();return i.width>0&&i.height>0&&(this.observerMapView.panBy((t.clientX-e.lastX)/i.width,(t.clientY-e.lastY)/i.height),this.observerMapViewChanged()),e.lastX=t.clientX,e.lastY=t.clientY,!0}static OBSERVER_MAP_DRAG_PX=4;handleObserverMapWheel=t=>{t.preventDefault();const e=this.observerMapCanvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=t.deltaMode===0?t.deltaY:t.deltaY*40;this.zoomObserverMap((t.clientX-e.left)/e.width,(t.clientY-e.top)/e.height,Math.exp(-i*.002))};zoomObserverMap(t,e,i){this.observerMapView.zoomAt(t,e,i),this.observerMapViewChanged()}observerMapViewChanged(){this.mapFitButton.hidden=!this.observerMapView.changed,this.mapZoomInButton.disabled=this.observerMapView.zoomFactor>=Ye.MAX_ZOOM,this.mapZoomOutButton.disabled=this.observerMapView.zoomFactor<=Ye.MIN_ZOOM,this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}scheduleObserverMapImagery(){this.observerMapImageryTimer===void 0&&(this.observerMapImageryTimer=setTimeout(()=>{this.observerMapImageryTimer=void 0,this.loadObserverMapImagery()},ge.OBSERVER_MAP_IMAGERY_DELAY_MS))}static OBSERVER_MAP_FOLLOW_MARGIN=.1;static OBSERVER_MAP_IMAGERY_DELAY_MS=300;get observerMapViewBounds(){return this.observerMapBounds&&this.observerMapView.boundsWithin(this.observerMapBounds)}placeObserverFrom(t){const e=this.observerMapViewBounds,i=this.observerMapCanvas.getBoundingClientRect();if(!e||i.width===0||i.height===0)return;const n=Ye.pointAt(e,(t.clientX-i.left)/i.width,(t.clientY-i.top)/i.height);this.dispatchEvent(new CustomEvent("observerplace",{detail:n,bubbles:!0,composed:!0}))}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${av}</style>${sv}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new No(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.issuesBox=this.shadow.getElementById("issues"),this.issuesButton=this.shadow.getElementById("issues-button"),this.issuesPanel=this.shadow.getElementById("issues-panel"),this.issuesButton.addEventListener("click",e=>{e.stopPropagation(),this.issuesPanel.hidden=!this.issuesPanel.hidden,this.issuesButton.setAttribute("aria-expanded",String(!this.issuesPanel.hidden))}),this.playPauseButton=this.shadow.getElementById("play-pause"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.observerMapButton=this.shadow.getElementById("observer-map"),this.referencesButton=this.shadow.getElementById("references"),this.referenceOpacityInput=this.shadow.getElementById("reference-opacity"),this.milestonesButton=this.shadow.getElementById("milestones"),this.observerMapPanel=this.shadow.getElementById("observer-map-panel"),this.observerMapCanvas=this.shadow.getElementById("observer-map-canvas"),this.observerMapRenderer=new va(this.observerMapCanvas.getContext("2d")),this.mapZoomInButton=this.shadow.getElementById("map-zoom-in"),this.mapZoomOutButton=this.shadow.getElementById("map-zoom-out"),this.mapFitButton=this.shadow.getElementById("map-fit"),this.seekInput=this.shadow.getElementById("seek"),this.playbackFlash=this.shadow.getElementById("playback-flash"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end"),this.timePill=this.shadow.getElementById("time"),this.muteButton=this.shadow.getElementById("mute"),this.controlsRight=this.shadow.getElementById("controls-right"),this.seekSegments=this.shadow.getElementById("seek-segments"),this.seekDot=this.shadow.getElementById("seek-dot"),this.seekPreview=this.shadow.getElementById("seek-preview"),this.seekPreviewCanvas=this.shadow.getElementById("seek-preview-canvas"),this.seekPreviewTitle=this.shadow.getElementById("seek-preview-title"),this.seekPreviewTime=this.shadow.getElementById("seek-preview-time"),this.timePill.addEventListener("click",()=>this.toggleTimeDisplay()),this.timePill.addEventListener("keydown",e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.toggleTimeDisplay())}),this.volumeInput=this.shadow.getElementById("volume"),this.muteButton.addEventListener("click",()=>this.toggleMuted()),this.volumeInput.addEventListener("input",()=>{this.setVolume(Number(this.volumeInput.value))}),this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.addEventListener("keydown",this.handleFullscreenKey),this.observerMapButton.addEventListener("click",()=>this.toggleObserverMap()),this.referencesButton.addEventListener("click",()=>this.toggleReferences()),this.referenceOpacityInput.addEventListener("input",()=>{this.referenceOpacityTouched=!0,this.dispatchReferenceView()}),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.observerMapCanvas.addEventListener("pointermove",this.handleObserverMapPointerMove),this.observerMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.observerMapCanvas.addEventListener("click",this.handleObserverMapClick),this.observerMapCanvas.addEventListener("pointerdown",this.handleObserverMapPointerDown),this.observerMapCanvas.addEventListener("pointerup",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("pointercancel",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("wheel",this.handleObserverMapWheel,{passive:!1}),this.mapZoomInButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,2)),this.mapZoomOutButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,.5)),this.mapFitButton.addEventListener("click",()=>{this.observerMapView.reset(),this.observerMapViewChanged()}),this.seekInput.addEventListener("input",()=>this.player.seek(this.snapSeekToMark(Number(this.seekInput.value)))),this.seekInput.addEventListener("pointerdown",e=>{this.seekSnapArmed=!0,this.nameMarkUnder(e)}),this.seekInput.addEventListener("pointerup",()=>{this.seekSnapArmed=!1}),this.seekInput.addEventListener("pointermove",e=>{this.nameMarkUnder(e),this.hoverSeek(e)}),this.seekInput.addEventListener("pointerleave",()=>{this.seekInput.removeAttribute("title"),this.leaveSeek()}),this.seekInput.addEventListener("keydown",this.handleSeekKey),this.canvas.addEventListener("click",e=>{this.enableClickToPlay&&(e.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause())}),this.canvas.addEventListener("dblclick",e=>{this.enableClickToPlay&&(e.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.observerMapResizeObserver?.observe(this.observerMapPanel),this.hostControls(void 0),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateMilestonesButton(),this.refresh()}connectedCallback(){this.saidTexts=void 0,this.loadLocaleMessages();const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.observerMapResizeObserver?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,i){t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===yr&&this.applyObserverMapDefault(),t===_r&&this.setMilestonesShown(!this.hasAttribute(_r))}async loadFromSrc(t){this.sightingData=await ng.json(t)}get sightingData(){return Ov(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=Fv(t),this.issuesPanel.hidden=!0,this.issuesButton.setAttribute("aria-expanded","false"),this.reportIssues(t,this.currentSighting),this.observerMapView.reset(),this.mapFitButton.hidden=!0,this.observerMapAsked=!1,this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyObserverMapDefault()}get recordingIssues(){return this.issues}async reportIssues(t,e){const i=++this.issueCheck;let n=[];try{const{default:s}=await is(async()=>{const{default:a}=await import("./sightingSchema-DOOSOVWK.js");return{default:a}},[],import.meta.url);n=new An(s).issues(t)}catch{}i===this.issueCheck&&(this.issues=[...n,...e.loadIssues],Cr.warn(this.issues,e.id),this.renderIssues(),this.dispatchEvent(new CustomEvent(s2,{detail:{issues:this.issues},bubbles:!0,composed:!0})))}renderIssues(){const t=this.issues.length;this.issuesBox.hidden=t===0,this.shadow.getElementById("issues-count").textContent=String(t);const e=this.messages.recordingIssues.replace("{count}",String(t));this.issuesButton.title=e,this.issuesButton.setAttribute("aria-label",e),this.shadow.getElementById("issues-title").textContent=e,this.shadow.getElementById("issues-list").replaceChildren(...this.issues.map(i=>{const n=document.createElement("li");return n.textContent=Cr.text(i,this.messages.issueTemplates),n}))}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(t){t!==this.loopEnabled&&this.toggleLoop()}play(){this.player.seekableDuration<=0||this.playbackState==="playing"||this.togglePlayPause()}pause(){this.playbackState==="playing"&&this.togglePlayPause()}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(t){this.toolbar.classList.toggle("hidden",!t),t?this.controlsRight.appendChild(this.fullscreenButton):this.cornerButtons.appendChild(this.fullscreenButton)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(n=>this.highlightedSourceIds.has(n))||(this.highlightedSourceIds=e,this.refresh())}hasVisibleShapeAt(t,e){return this.shapeAt(t,e)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateObserverMap(),this.updateReferences(),this.player.seek(this.player.time)}hostControls(t){const e=[this.milestonesButton,this.referenceOpacityInput,this.referencesButton,this.observerMapButton];if(t)for(const i of e)t.appendChild(i);else{const i=this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null;for(const n of e)this.controlsRight.insertBefore(n,i)}}get referencesShown(){return this.referencesShownState}get referenceOpacity(){return Number(this.referenceOpacityInput.value)}toggleReferences(){this.referencesShownState=!this.referencesShownState,this.updateReferencesButton(),this.dispatchReferenceView()}updateReferences(){const t=this.currentSighting.references;!this.referenceOpacityTouched&&t.length>0&&(this.referenceOpacityInput.value=String(t[0].opacity)),this.updateReferencesButton()}updateReferencesButton(){const t=this.currentSighting.references.length>0;this.referencesButton.hidden=!t,this.referenceOpacityInput.hidden=!t||!this.referencesShownState,this.referencesButton.setAttribute("aria-pressed",String(this.referencesShownState)),ge.setIcon(this.referencesButton,this.referencesShownState?ie.PICTURES_ON:ie.PICTURES_OFF);const e=this.referencesShownState?this.messages.hideReferences:this.messages.showReferences;this.referencesButton.title=e,this.referencesButton.setAttribute("aria-label",e),this.referenceOpacityInput.title=this.messages.referenceOpacity,this.referenceOpacityInput.setAttribute("aria-label",this.messages.referenceOpacity)}dispatchReferenceView(){this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity}}))}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?_o(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(i=>{const n=document.createElement("button");n.type="button",n.className="milestone-mark",n.style.left=`${Math.min(Math.max(i.t/t,0),1)*100}%`;const s=this.said.read(i.label)??"",a=this.said.read(i.note),o=a?`${s} — ${a}`:s;return n.title=o,n.setAttribute("aria-label",o),n.dataset.t=String(i.t),n.addEventListener("click",()=>this.player.seek(i.t)),n})),this.refreshSeekSegments(t,e.map(i=>i.t))}seekSegmentList=[];refreshSeekSegments(t,e){const n=[0,...this.milestonesShown&&t>0?[...new Set(e.filter(a=>a>0&&a<t))].sort((a,o)=>a-o):[],Math.max(t,0)];this.seekSegmentList=[];const s=[];for(let a=0;a<n.length-1;a++){const o=document.createElement("div");o.className="seek-segment",o.style.flexGrow=String(Math.max(n[a+1]-n[a],1));const c=document.createElement("i");c.className="seek-hover";const l=document.createElement("i");l.className="seek-played",o.append(c,l),s.push(o),this.seekSegmentList.push({start:n[a],end:n[a+1],element:o,played:l,hover:c})}this.seekSegments.replaceChildren(...s),this.paintSeekProgress(this.player.time)}static fillOf(t,e){const i=t.end-t.start,n=i>0?(e-t.start)/i:e>=t.end?1:0;return`${Math.min(Math.max(n,0),1)*100}%`}paintSeekProgress(t){for(const i of this.seekSegmentList)i.played.style.width=ge.fillOf(i,t);const e=this.player.seekableDuration;this.seekDot.style.left=`${e>0?Math.min(Math.max(t/e,0),1)*100:0}%`}hoverSeek(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=Math.min(Math.max((t.clientX-e.left)/e.width,0),1),s=n*i,a=this.seekSegmentList.length-1;this.seekSegmentList.forEach((f,p)=>{f.hover.style.width=ge.fillOf(f,s),f.element.classList.toggle("hovered",s>=f.start&&(s<f.end||p===a))});const o=this.milestonesShown?this.sighting.milestones:[],c=o.length>0?eh(o,s):void 0,l=c?this.said.read(c.label)??"":"",h=c?this.said.read(c.note):void 0,u=h?`${l} — ${h}`:l;this.seekPreviewTitle.textContent=u,this.seekPreviewTime.textContent=this.formatPosition(s),this.seekPreview.hidden=!1;const d=this.seekPreview.offsetWidth;this.seekPreview.style.left=`${Math.min(Math.max(n*e.width-d/2,0),Math.max(e.width-d,0))}px`,this.paintSeekPreview(s)}leaveSeek(){for(const t of this.seekSegmentList)t.hover.style.width="0",t.element.classList.remove("hovered");this.seekPreview.hidden=!0}seekPreviewPainter;paintSeekPreview(t){const e=this.seekPreviewPainter;this.seekPreviewCanvas.hidden=e===void 0,e?.(t,this.seekPreviewCanvas)}seekSnapArmed=!1;static MARK_SNAP_PX=6;markNear(t){const e=this.player.seekableDuration,i=this.seekInput.getBoundingClientRect().width;if(e<=0||i<=0)return;const n=ge.MARK_SNAP_PX/i*e;let s;for(const a of this.milestoneMarks.children){const o=Number(a.dataset.t);Math.abs(o-t)>n||(!s||Math.abs(o-t)<Math.abs(s.t-t))&&(s={t:o,name:a.title})}return s}snapSeekToMark(t){return this.seekSnapArmed?(this.seekSnapArmed=!1,this.markNear(t)?.t??t):t}nameMarkUnder(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=(t.clientX-e.left)/e.width*i,s=this.markNear(n);s?this.seekInput.title=s.name:this.seekInput.removeAttribute("title")}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?eh(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,!e)return;const i=document.createElement("b");i.textContent=this.said.read(e.label)??"";const n=this.said.read(e.note),s=n?` — ${n}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(s))}exposureInstants(t){const e=this.exposureTimes(t),i=1/e.length;return e.map(n=>({shapes:this.shapesAt(n),share:i}))}exposureTimes(t=this.currentTime){const e=Cn.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<ge.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const i=Math.min(ge.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/ge.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/ge.EXPOSURE_STEP_PX),s=Math.min(ge.MAX_TRAVEL_STEPS,Math.max(i,n)),a=[];for(let o=0;o<s;o++)a.push(e.fromMs+e.ms*o/(s-1));return a}travelPxOver(t,e){const i=this.shapesAt(t),n=this.shapesAt(t+e);let s=0;for(const[a,o]of i){const c=n.get(a);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(o.bounds.y+o.bounds.height/2);s=Math.max(s,Math.hypot(l,h))}return s}shapeAt(t,e,i){for(const n of this.exposureTimes()){const s=this.currentSighting.timeline.hitTest(n,t,e,i);if(s)return s}}shapesAt(t){const e=new Map;for(const i of this.currentSighting.timeline.sourceIds){const n=this.currentSighting.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}return e}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const t=fi.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===t)return;this.canvas.width=t,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${t} / ${this.canvas.height}`)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}onFrame(t,e){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const i=this.playbackState!=="playing"?this.highlightedSourceIds:n2;this.canvasRenderer.setStarPoints(fi.starPointsOf(this.sighting.instrument));const n=(di(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const s=this.exposureInstants(t),a=this.frameShift;if(this.paintsShapes)for(const o of s)for(const[,c]of o.shapes){const l=o.share,h=l===1?c:{...c,transparency:1-(1-c.transparency)*l};this.canvasRenderer.paintShape(this.shifted(h,a))}for(const[o,c]of s[0].shapes)!this.selectionShown||!i.has(o)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...c,selected:!0}):this.canvasRenderer.paintMemberOutline(c):this.canvasRenderer.paintSelectionOnly(this.shifted(c,a)));if(this.selectionShown&&i.size>1){const o=cn.groupBoundsFor([...e].filter(([c])=>i.has(c)).map(([,c])=>c.bounds));this.canvasRenderer.paintGroupHandles(o)}this.overlayPainter?.(this.canvasRenderer),this.mapShapeBounds=s.flatMap(o=>[...o.shapes.values()].filter(c=>c.transparency<1).map(c=>this.shifted(c,a).bounds)),this.keepObserverMapClear(),this.seekInput.value=String(t),this.paintSeekProgress(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintObserverMap(t),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Ev(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}shifted(t,e){return e.x===0&&e.y===0?t:{...t,bounds:{...t.bounds,x:t.bounds.x+e.x,y:t.bounds.y+e.y}}}createPlayer(){const t=new Av(this.currentSighting.timeline,(e,i)=>this.onFrame(e,i));return t.loop=this.loopEnabled,t.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},t}static SEEK_KEY_STEP_MS=5e3;handleFullscreenKey=t=>{t.key.toLowerCase()!=="f"||t.altKey||t.ctrlKey||t.metaKey||!this.enableClickToPlay||t.composedPath().some(i=>i instanceof HTMLElement&&(i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName)&&i.type!=="range"))||(t.preventDefault(),this.toggleFullscreen())};handleSeekKey=t=>{if(t.altKey||t.ctrlKey||t.metaKey)return;const e=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0;if(e){t.preventDefault();const i=this.player.seekableDuration;this.player.seek(Math.min(i,Math.max(0,this.player.time+e*ge.SEEK_KEY_STEP_MS)))}else t.key===" "&&(t.preventDefault(),this.togglePlayPause())};togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton(),this.flashPlayback())}flashPlayback(){const t=this.playbackFlash;t.innerHTML=this.player.playbackState==="playing"?ie.PLAY:ie.PAUSE,t.classList.remove("flashing"),t.offsetWidth,t.classList.add("flashing")}static icons=new WeakMap;static setIcon(t,e){ge.icons.get(t)!==e&&(ge.icons.set(t,e),t.innerHTML=e)}updatePlayPauseButton(){const t=this.player.playbackState==="playing";ge.setIcon(this.playPauseButton,t?ie.PAUSE:ie.PLAY);const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const i=e?t?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=i,this.playPauseButton.setAttribute("aria-label",i)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.player.loop=this.loopEnabled}restorePlayback(){const t=this.playbackBeforeClick;t&&(this.currentTime=t.time,t.state==="playing"?this.play():this.pause())}get canUseNativeFullscreen(){return typeof this.fullscreenTarget.requestFullscreen=="function"&&document.fullscreenEnabled}toggleFullscreen(){if(!this.canUseNativeFullscreen){this.simulatedFullscreen?this.exitSimulatedFullscreen():this.enterSimulatedFullscreen();return}document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}enterSimulatedFullscreen(){const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=t.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const e=t.style;e.setProperty("position","fixed"),e.setProperty("inset","0"),e.setProperty("margin","0"),e.setProperty("max-width","none"),e.setProperty("max-height","none"),e.setProperty("aspect-ratio","auto"),e.setProperty("z-index","2147483647"),e.setProperty("background","#000"),e.setProperty("width","100vw"),e.setProperty("width","100dvw"),e.setProperty("height","100vh"),e.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?t.setAttribute("style",this.styleBeforeSimulatedFullscreen):t.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}toggleObserverMap(){const t=this.observerMapPanel.hidden;this.observerMapAsked=t,this.setObserverMapOpen(t),this.keepObserverMapClear()}observerMapAsked=!1;applyObserverMapDefault(){const t=this.getAttribute(yr),e=t===null?this.observerPath?.travels===!0:t!=="false";this.setObserverMapOpen(e&&this.observerPath!==void 0)}setObserverMapOpen(t){this.observerMapPanel.hidden=!t,this.observerMapPanel.removeAttribute("title"),this.observerMapButton.setAttribute("aria-pressed",String(t)),this.updateObserverMapButton(),t&&(this.sizeObserverMapCanvas(),this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime))}updateObserverMapButton(){const t=!this.observerMapPanel.hidden;ge.setIcon(this.observerMapButton,t?ie.MAP_ON:ie.MAP_OFF);const e=t?this.messages.hideObserverMap:this.messages.showObserverMap;this.observerMapButton.title=e,this.observerMapButton.setAttribute("aria-label",e);const i=[[this.mapZoomInButton,this.messages.zoomMapIn],[this.mapZoomOutButton,this.messages.zoomMapOut],[this.mapFitButton,this.messages.fitMap]];for(const[n,s]of i)n.title=s,n.setAttribute("aria-label",s)}updateObserverMap(){const t=this.observerPath!==void 0;if(this.observerPath=xr.of(this.currentSighting),this.observerMapButton.hidden=this.observerPath===void 0,!t&&this.observerPath&&this.applyObserverMapDefault(),!this.observerPath){this.setObserverMapOpen(!1),this.observerMapBounds=void 0;return}const e=this.observerPath.boundsAround(ge.OBSERVER_MAP_MIN_SPAN_M,ge.OBSERVER_MAP_MARGIN);(!this.observerMapBounds||!this.sameGround(this.observerMapBounds,e))&&(this.observerMapBounds&&this.observerMapView.refit(this.observerMapBounds,e),this.observerMapBounds=e,this.observerMapImagery=void 0,this.observerMapImageryCredit=void 0,this.observerMapImageryFailed=!1,this.observerMapImageryBounds=void 0,this.observerMapImageryLoading=!1,this.observerMapPanel.hidden||this.loadObserverMapImagery())}sameGround(t,e){const i=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<i&&Math.abs(t.south-e.south)<i&&Math.abs(t.west-e.west)<i&&Math.abs(t.east-e.east)<i}async loadObserverMapImagery(){const t=this.observerMapViewBounds;if(!t||this.observerMapPanel.hidden||this.observerMapImageryLoading||!this.observerMapImageryNeededFor(t))return;const e=this.observerMapView.changed,i=e?Ye.expand(t,ge.OBSERVER_MAP_IMAGERY_AHEAD):t,n=ge.OBSERVER_MAP_IMAGERY_PX*(e?1+2*ge.OBSERVER_MAP_IMAGERY_AHEAD:1);this.observerMapImageryBounds=i,this.observerMapImageryViewWidth=t.east-t.west,this.observerMapImageryLoading=!0;const s=gg();try{const a=await s.getImageryTexture(i,{width:n,height:n});if(this.observerMapImageryBounds!==i)return;this.observerMapImagery=a,this.observerMapImageryCredit=s.attribution,this.observerMapImageryFailed=!1}catch{if(this.observerMapImageryBounds!==i)return;this.observerMapImageryFailed=this.observerMapImagery===void 0}finally{this.observerMapImageryBounds===i&&(this.observerMapImageryLoading=!1)}this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}static OBSERVER_MAP_IMAGERY_AHEAD=.5;static OBSERVER_MAP_IMAGERY_LOOKAHEAD=.25;observerMapImageryNeededFor(t){const e=this.observerMapImageryBounds;if(!e)return!0;const i=this.observerMapImagery?.bounds??e,n=this.observerMapView.changed?Ye.expand(t,ge.OBSERVER_MAP_IMAGERY_LOOKAHEAD):t,s=n.west>=i.west&&n.east<=i.east&&n.south>=i.south&&n.north<=i.north,a=t.east-t.west>this.observerMapImageryViewWidth/2;return!s||!a}get observerMapCredit(){return this.observerMapImageryCredit}get observerMapFooterLine(){return this.observerMapImageryFailed?this.messages.mapImageryUnavailable:this.creditShownExternally?void 0:this.observerMapImageryCredit}mapShapeBounds=[];mapSceneBounds=[];setMapSubjectBounds(t){this.mapSceneBounds=t.map(e=>({x:e.x*this.canvas.width,y:e.y*this.canvas.height,width:e.width*this.canvas.width,height:e.height*this.canvas.height})),this.keepObserverMapClear()}keepObserverMapClear(){if(this.observerMapPanel.hidden)return;const t=this.observerMapBoxPx;if(!t)return;const e=[...this.mapShapeBounds,...this.mapSceneBounds],i=(l,h,u)=>{for(const d of e)if(!(d.x+d.width<l-u||d.x>h+u)&&!(d.y>t.bottom+u||d.y+d.height<t.top-u))return!0;return!1},n=[this.canvas.width-t.width,this.canvas.width],s=[0,t.width],a=ge.OBSERVER_MAP_CLEARANCE_PX,o=i(...n,0),c=i(...s,0);if(this.observerMapPanel.classList.toggle("subject-overlap",o&&c&&!this.observerMapAsked),this.observerMapPanel.classList.contains("on-the-left")){!o&&(c||!i(n[0],n[1],a))&&this.observerMapPanel.classList.remove("on-the-left");return}i(n[0],n[1],0)&&!i(s[0],s[1],0)&&this.observerMapPanel.classList.add("on-the-left")}observerMapBoxPx;static OBSERVER_MAP_CLEARANCE_PX=24;sizeObserverMapCanvas(){const t=this.observerMapPanel.clientWidth;if(t===0)return;const e=Math.round(t*(globalThis.devicePixelRatio??1));this.measureObserverMapBox(),this.observerMapCanvas.width!==e&&(this.observerMapCanvas.width=e,this.observerMapCanvas.height=e)}measureObserverMapBox(){const t=this.observerMapPanel.getBoundingClientRect(),e=this.canvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=this.canvas.width/e.width,n=this.canvas.height/e.height;this.observerMapBoxPx={width:t.width*i,top:(t.top-e.top)*n,bottom:(t.bottom-e.top)*n}}paintObserverMap(t){if(this.observerMapPanel.hidden||!this.observerPath||!this.observerMapBounds)return;const e=di(this.currentSighting,t);e?.lat!==void 0&&e.lng!==void 0&&!this.observerMapDrag?.moved&&this.observerMapView.keepInView(this.observerMapBounds,{lat:e.lat,lng:e.lng},ge.OBSERVER_MAP_FOLLOW_MARGIN)&&this.scheduleObserverMapImagery();const i=this.currentSighting.instrument,n=[],s=this.currentSighting.milestones.length>0?eh(this.currentSighting.milestones,t):void 0;for(const a of this.milestonesShown?_o(this.currentSighting.milestones):[]){const o=di(this.currentSighting,a.t);o?.lat===void 0||o.lng===void 0||n.push({label:this.said.read(a.label)??"",note:this.said.read(a.note),t:a.t,lat:o.lat,lng:o.lng,current:a===s})}this.observerMapRenderer.paint({bounds:this.observerMapViewBounds,imagery:this.observerMapImagery,path:this.observerPath,position:e?.lat!==void 0&&e.lng!==void 0?{lat:e.lat,lng:e.lng}:void 0,headingDeg:e?.headingDeg===void 0?void 0:e.headingDeg+this.lookYawDeg,coneHalfAngleDeg:e?Ss.of(i,this.canvas.height,e.fovDeg).halfWidthAngleDeg(fi.aspectOf(i)):void 0,markers:n,decor:this.observerMapDecorAt(t),observerLabel:this.said.read(this.currentSighting.observer?.title)??this.messages.observerHere,nightFraction:this.observerMapNightFraction,attribution:this.observerMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(t){this.milestonesShown=t,this.milestoneMarks.hidden=!t,this.refreshSeekSegments(this.player.seekableDuration,_o(this.sighting.milestones).map(e=>e.t)),this.milestonesButton.setAttribute("aria-pressed",String(t)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintObserverMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0,ge.setIcon(this.milestonesButton,this.milestonesShown?ie.MILESTONES_ON:ie.MILESTONES_OFF);const t=this.milestonesShown?this.messages.hideMilestones:this.messages.showMilestones;this.milestonesButton.title=t,this.milestonesButton.setAttribute("aria-label",t)}observerMapDecorAt(t){const e=di(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=Io(i,t),{lat:s,lng:a}=_s(n.eastM,-n.northM,e.lat,e.lng);return{lat:s,lng:a,headingDeg:n.headingDeg,label:this.said.read(i.title)??this.messages.decorHere}})}observerMapNightFraction;setSunAltitude(t){const e=t===void 0?void 0:Math.max(0,Math.min(1,-t/12));e!==this.observerMapNightFraction&&(this.observerMapNightFraction=e,this.paintObserverMap(this.currentTime))}setLookOffset(t,e){t===this.lookYawDeg&&e===this.lookPitchDeg||(this.lookYawDeg=t,this.lookPitchDeg=e,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const t=this.gaitAt(this.currentTime),e=this.lookYawDeg+t.yawDeg,i=this.lookPitchDeg+t.pitchDeg;if(e===0&&i===0)return{x:0,y:0};const n=di(this.currentSighting,this.currentTime),s=Ss.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(e),y:s.angleDegToRadiusPx(i)}}gaitAt(t){return _e.bodyAt(this.currentSighting,t,this.steadyObserver)}mutedState=!1;get muted(){return this.mutedState}set muted(t){t!==this.mutedState&&(this.mutedState=t,!t&&this.volumeState===0&&(this.volumeState=ge.RESTORED_VOLUME),this.applyLevel())}volumeState=1;static RESTORED_VOLUME=.5;get volume(){return this.volumeState}set volume(t){this.setVolume(t)}setVolume(t){this.volumeState=Math.min(Math.max(t,0),1),this.mutedState=this.volumeState===0,this.applyLevel()}get level(){return this.mutedState?0:this.volumeState}applyLevel(){this.sightingAudio.setLevel(this.level),this.updateMuteButton(),this.dispatchEvent(new CustomEvent("mutedchange",{bubbles:!0,composed:!0,detail:{muted:this.mutedState,volume:this.volumeState}}))}toggleMuted(){this.muted=!this.mutedState}updateMuteButton(){ge.setIcon(this.muteButton,this.mutedState?ie.MUTED:ie.VOLUME);const t=this.mutedState?this.messages.unmute:this.messages.mute;this.muteButton.title=t,this.muteButton.setAttribute("aria-label",t),this.muteButton.setAttribute("aria-pressed",String(this.mutedState)),this.volumeInput.value=String(this.level)}updateFullscreenButton(){const t=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;ge.setIcon(this.fullscreenButton,t?ie.EXIT_FULLSCREEN:ie.ENTER_FULLSCREEN),this.fullscreenButton.title=t?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new $s(fl.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=ag(fl.preferencesFor(this),rg);if(t===this.messagesLanguage||t==="en"&&this.messagesLanguage===void 0)return;this.messagesLanguage=t;const e=await zv(t);this.messagesLanguage===t&&this.applyMessages(e)}messagesLanguage;updateTimeLabelTitles(){const t=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,e=this.canSwitchTimeDisplay?` — ${t}`:"";this.timeStartLabel.title=this.messages.currentPosition+e,this.timeEndLabel.title=this.messages.duration+e,this.timePill.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(this.timePill.setAttribute("role","button"),this.timePill.setAttribute("tabindex","0")):(this.timePill.removeAttribute("role"),this.timePill.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.updateTimeLabelTitles(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateMilestonesButton(),this.renderIssues()}updateTimeLabels(){const t=this.currentSighting.event,e=Sv(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?bu(t.time):void 0;const i=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&i>0?i/this.realDurationMs:1,this.player.durationOverrideMs=i>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return nc(t);const e=this.currentSighting.timeline.duration,i=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?xf(Mf(this.realStartMs+i)):nc(i)}formatEndOfTimeline(){return this.realDurationMs===void 0?nc(this.currentSighting.timeline.duration):this.canShowClockTime?xf(Mf(this.realStartMs+this.realDurationMs)):nc(this.realDurationMs)}}function Mf(r){const t=new Date(r);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function xf(r){if(r.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return r.second?`${t(r.hour)}:${t(r.minute??0)}:${t(r.second)}`:`${t(r.hour)}:${t(r.minute??0)}`}function nc(r){const t=Math.round(r/1e3),e=Math.floor(t/60),i=t%60;return`${e}:${String(i).padStart(2,"0")}`}const Eu="rr0-ufo";function vg(){customElements.get(Eu)||customElements.define(Eu,ge)}const s2="recordingissues";/**
1153
+ `)}`)}}class An{constructor(t){this.format=t}issues(t){const e=[];return this.object(t,this.format,"",e),e}object(t,e,i,n){if(!An.isObject(t)){n.push({kind:"wrong-type",path:i||"(the file)",expected:"object",found:An.typeOf(t)});return}for(const[s,a]of Object.entries(t)){const o=i?`${i}.${s}`:s,c=e[s];c?this.field(a,c,o,n):n.push({kind:"unknown-key",path:o})}}field(t,e,i,n){if(An.isStated(t)){this.field(t.value,e,i,n);return}if(!(e.loose||t===void 0||t===null))switch(e.type){case"enum":(typeof t!="string"||!e.values?.includes(t))&&n.push({kind:"not-in-list",path:i,expected:(e.values??[]).map(s=>`"${s}"`).join(", "),found:JSON.stringify(t)});return;case"object":e.fields?this.object(t,e.fields,i,n):An.isObject(t)||n.push({kind:"wrong-type",path:i,expected:"object",found:An.typeOf(t)});return;case"array":Array.isArray(t)?e.fields&&t.forEach((s,a)=>{const o=An.isStated(s)?s.value:s;this.object(o,e.fields,`${i}.${a}`,n)}):n.push({kind:"wrong-type",path:i,expected:"array",found:An.typeOf(t)});return;default:typeof t!==e.type&&n.push({kind:"wrong-type",path:i,expected:e.type,found:An.typeOf(t)})}}static isObject(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}static isStated(t){return An.isObject(t)&&"value"in t&&Object.keys(t).every(e=>e==="value"||e==="basis"||e==="rationale")}static typeOf(t){return Array.isArray(t)?"array":t===null?"null":typeof t}}class Cn{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static windowEndingAt(t,e){const i=Number.isFinite(e)?Math.max(0,e):0,n=Math.max(0,t-i*1e3),s=Math.max(0,t-n);return{fromMs:n,toMs:t,ms:s,seconds:s/1e3}}static instants(t,e,i,n,s){if(!(n>0))return 1;const a=s>0?Cn.travelDegOver(t,e,i,i+n*1e3)/s/Cn.PIXELS_PER_INSTANT:0,o=Cn.flashesOver(t,n)*Cn.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(a,o));return c<2?1:Math.min(Cn.MAX_INSTANTS,c)}static travelDegOver(t,e,i,n){let s=0;for(const a of t){if(!a.track||a.track.length<2)continue;const o=Cn.directionAt(a,e,i),c=Cn.directionAt(a,e,n),l=Math.min(1,Math.max(-1,o.x*c.x+o.y*c.y+o.z*c.z));s=Math.max(s,Math.acos(l)*180/Math.PI)}return s}static flashesOver(t,e){let i=0;for(const n of t)for(const s of n.lights??[])s.pattern.kind==="flash"&&(i=Math.max(i,s.pattern.perMinute));return i/60*e}static directionAt(t,e,i){const n=Io(t,i),s=n.eastM,a=n.altitudeM-e,o=n.northM,c=Math.hypot(s,a,o);return c===0?{x:0,y:1,z:0}:{x:s/c,y:a/c,z:o/c}}}function ag(r,t){for(const e of r){const i=e.toLowerCase().split("-")[0];if(t.includes(i))return i}return"en"}class fl{static preferencesFor(t){const e=navigator.languages??[],i=this.declaredFor(t);return i?[i,...e]:e}static declaredFor(t){for(let e=t;e;){const i=e.closest("[lang]")?.getAttribute("lang")?.trim();if(i)return i;const n=e.getRootNode();e=n instanceof ShadowRoot?n.host:void 0}}}class $s{constructor(t){this.preferences=t}read(t){if(t===void 0||typeof t=="string")return t===""?void 0:t;for(const i of this.preferences){const n=t[i]??t[$s.base(i)];if(n)return n}const e=new Set(this.preferences.map(i=>$s.base(i)));for(const[i,n]of Object.entries(t))if(n&&e.has($s.base(i)))return n;return Object.values(t).find(i=>i)??void 0}write(t,e,i){const n=e?.trim()?e.trim():void 0;if(t===void 0||typeof t=="string")return n;const s={...t},a=Object.keys(s).find(o=>o===i)??Object.keys(s).find(o=>$s.base(o)===$s.base(i))??i;return n===void 0?delete s[a]:s[a]=n,Object.keys(s).length===0?void 0:s}static base(t){return t.toLowerCase().split("-")[0]}}const rg=["en","fr","es","it"],kv={en:()=>is(()=>Promise.resolve().then(()=>Hv),void 0,import.meta.url).then(r=>r.ufoMessages_en),fr:()=>is(()=>import("./UfoMessages_fr-DTSHJJJ1.js"),[],import.meta.url).then(r=>r.ufoMessages_fr),es:()=>is(()=>import("./UfoMessages_es-y8jU_0WN.js"),[],import.meta.url).then(r=>r.ufoMessages_es),it:()=>is(()=>import("./UfoMessages_it-C-2zrCGg.js"),[],import.meta.url).then(r=>r.ufoMessages_it)};function zv(r){return kv[r]()}function Bv(r){switch(r){case"fr":return is(()=>import("./SceneNames_fr-BJltNyw-.js"),[],import.meta.url).then(t=>t.sceneNames_fr);case"es":return is(()=>import("./SceneNames_es-B6UgSlXt.js"),[],import.meta.url).then(t=>t.sceneNames_es);case"it":return is(()=>import("./SceneNames_it-CQKtZ4O0.js"),[],import.meta.url).then(t=>t.sceneNames_it);default:return Promise.resolve(void 0)}}const og={play:"Play",pause:"Pause",noDuration:"No observation duration",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",mute:"Mute",unmute:"Unmute",moreControls:"More controls",fewerControls:"Fewer controls",showObserverMap:"Show where the observer was",hideObserverMap:"Hide where the observer was",mapImageryUnavailable:"Aerial imagery unavailable",zoomMapIn:"Zoom in",zoomMapOut:"Zoom out",fitMap:"Back to the whole path",placeObserverHere:"Put the observer here",showReferences:"Show the pictures of the place",hideReferences:"Hide the pictures of the place",referenceOpacity:"Picture opacity",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",observerHere:"The observer, here",decorHere:"Scenery",recordingIssues:"{count} problem(s) in this recording: it may not play as its author meant",issueTemplates:Cr.EN},Hv=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:og},Symbol.toStringTag,{value:"Module"})),cg=Math.PI/180,Gv=180/Math.PI,Vv=256,lg=19,Wv=1.25;function hg(r,t){return 156543.03392*Math.cos(r*cg)/2**t}function ug(r,t){return hg(r,t)*Vv}function Xv(r,t){let e=0;for(;e<lg&&ug(r,e+1)>=t;)e++;return e}function dg(r,t){return ug(r,t)}function Yv(r,t){const e=t*Wv;let i=0;for(;i<lg&&hg(r,i)>e;)i++;return i}function tl(r){const t=r*cg;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function fg(r,t,e){const i=2**e;return{x:(r+180)/360*i,y:tl(t)*i}}function pg(r,t,e){const i=tl(r.north),n=tl(r.south);return{x:(t-r.west)/(r.east-r.west),y:(tl(e)-i)/(n-i)}}function qv(r,t,e){const{x:i,y:n}=fg(r,t,e);return{x:Math.floor(i),y:Math.floor(n),z:e}}function $v(r){const t=2**r.z,e=r.x/t*360-180,i=(r.x+1)/t*360-180,n=mf(r.y,t);return{south:mf(r.y+1,t),north:n,west:e,east:i}}function mf(r,t){const e=r/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*Gv}function mg(r,t,e,i){const n=qv(r,t,e),s=Math.floor(i/2),a=[];for(let l=-s;l<=s;l++)for(let h=-s;h<=s;h++)a.push({x:n.x+h,y:n.y+l,z:e});const o=a.map($v),c={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:a,bounds:c}}class va{constructor(t){this.ctx=t}static SCALE_STEPS_M=[5e3,2e3,1e3,500,200,100,50,20,10,5];static MARKER_RADIUS_PX=8.5;static ON_MARKER_M=3;targets=[];hitTest(t,e){let i,n=1/0;for(const s of this.targets){const a=Math.hypot(s.x-t,s.y-e);a>s.radius||a>n||(i=s,n=a)}return i}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(t){const{ctx:e}=this;e.save(),this.targets=[],e.clearRect(0,0,this.width,this.height),this.paintGround(t),this.paintNight(t.nightFraction),this.paintPath(t),t.position?(this.paintCone(t,t.position),this.paintDecor(t),this.paintMarkers(t),this.paintObserver(t,t.position)):(this.paintDecor(t),this.paintMarkers(t)),this.paintNorth(),this.paintFooter(t.bounds,t.attribution),e.restore()}toCanvas(t,e,i){const n=pg(t,i,e);return{x:n.x*this.width,y:n.y*this.height}}paintGround(t){const{ctx:e}=this;e.fillStyle="#1d2321",e.fillRect(0,0,this.width,this.height);const i=t.imagery;if(!i)return;const n=this.toCanvas(t.bounds,i.bounds.north,i.bounds.west),s=this.toCanvas(t.bounds,i.bounds.south,i.bounds.east);e.drawImage(i.source,n.x,n.y,s.x-n.x,s.y-n.y)}paintNight(t=0){if(t<=0)return;const{ctx:e}=this;e.save(),e.fillStyle=`rgba(6, 12, 30, ${Math.min(t,1)*.78})`,e.fillRect(0,0,this.width,this.height),e.restore()}paintDecor(t){const{ctx:e}=this;for(const i of t.decor){const n=this.toCanvas(t.bounds,i.lat,i.lng);if(i.label&&this.targets.push({kind:"decor",label:i.label,lat:i.lat,lng:i.lng,x:n.x,y:n.y,radius:7}),e.beginPath(),e.rect(n.x-3.5,n.y-3.5,7,7),e.fillStyle="rgba(120, 220, 255, 0.85)",e.fill(),e.lineWidth=1.5,e.strokeStyle="rgba(0, 0, 0, 0.7)",e.stroke(),i.headingDeg===void 0)continue;const s=(i.headingDeg-90)*Math.PI/180;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x+Math.cos(s)*10,n.y+Math.sin(s)*10),e.lineWidth=3,e.strokeStyle="rgba(0, 0, 0, 0.6)",e.stroke(),e.lineWidth=1.5,e.strokeStyle="rgba(120, 220, 255, 0.9)",e.stroke()}}paintPath(t){if(!t.path.moved)return;const{ctx:e}=this,i=t.path.points.map(n=>this.toCanvas(t.bounds,n.lat,n.lng));e.beginPath(),e.moveTo(i[0].x,i[0].y);for(const n of i.slice(1))e.lineTo(n.x,n.y);e.lineJoin="round",e.lineCap="round",e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=5,e.stroke(),e.strokeStyle="rgba(255, 255, 255, 0.9)",e.lineWidth=2,e.stroke()}paintCone(t,e){const{headingDeg:i,coneHalfAngleDeg:n}=t;if(i===void 0||n===void 0)return;const{ctx:s}=this,a=this.toCanvas(t.bounds,e.lat,e.lng),o=Math.hypot(this.width,this.height),c=(i-90)*Math.PI/180,l=n*Math.PI/180;s.save(),s.beginPath(),s.moveTo(a.x,a.y),s.arc(a.x,a.y,o,c-l,c+l),s.closePath();const h=s.createRadialGradient(a.x,a.y,0,a.x,a.y,o);h.addColorStop(0,"rgba(255, 224, 130, 0.55)"),h.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),h.addColorStop(1,"rgba(255, 224, 130, 0)"),s.fillStyle=h,s.fill(),s.restore()}paintMarkers(t){const{ctx:e}=this;e.textAlign="center",e.textBaseline="middle",e.font="bold 10px sans-serif";for(const i of[...t.markers].sort((n,s)=>Number(n.current)-Number(s.current))){const n=this.toCanvas(t.bounds,i.lat,i.lng);this.targets.push({kind:"milestone",label:i.note?`${i.label} — ${i.note}`:i.label,lat:i.lat,lng:i.lng,t:i.t,x:n.x,y:n.y,radius:va.MARKER_RADIUS_PX}),e.beginPath(),e.arc(n.x,n.y,va.MARKER_RADIUS_PX,0,Math.PI*2),e.fillStyle=i.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",e.fill(),e.lineWidth=2,e.strokeStyle="rgba(255, 255, 255, 0.9)",e.stroke(),e.fillStyle=i.current?"#1d2321":"#fff",e.fillText(i.label,n.x,n.y)}}paintObserver(t,e){const{ctx:i}=this,n=this.toCanvas(t.bounds,e.lat,e.lng);t.observerLabel&&this.targets.push({kind:"observer",label:t.observerLabel,lat:e.lat,lng:e.lng,x:n.x,y:n.y,radius:8});const s=t.markers.some(a=>{if(!a.current)return!1;const o=ai(a.lat,a.lng,e.lat,e.lng);return Math.hypot(o.x,o.z)<=va.ON_MARKER_M});i.beginPath(),i.arc(n.x,n.y,s?va.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),s||(i.fillStyle="#ff5a3c",i.fill()),i.lineWidth=4,i.strokeStyle="rgba(0, 0, 0, 0.5)",i.stroke(),i.lineWidth=s?3:2.5,i.strokeStyle=s?"#ff5a3c":"#fff",i.stroke()}paintNorth(){const{ctx:t}=this,e=this.width-14,i=16;t.beginPath(),t.moveTo(e,i-9),t.lineTo(e-4.5,i+5),t.lineTo(e,i+2),t.lineTo(e+4.5,i+5),t.closePath(),t.fillStyle="rgba(255, 255, 255, 0.92)",t.strokeStyle="rgba(0, 0, 0, 0.6)",t.lineWidth=1,t.fill(),t.stroke(),t.font="bold 9px sans-serif",t.textAlign="center",t.textBaseline="top",t.strokeText("N",e,i+6),t.fillText("N",e,i+6)}paintFooter(t,e){const{ctx:i}=this;i.font="9px sans-serif",i.textBaseline="bottom";const n=e?this.wrap(e,this.width-20):[];let s=this.height-4;i.textAlign="right";for(const f of n.slice().reverse())this.paintOutlinedText(f,this.width-6,s),s-=11;const a=(t.south+t.north)/2,c=Math.abs(ai(a,t.east,a,t.west).x)/this.width,l=va.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=s-3;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.6)",i.beginPath(),i.moveTo(u,d),i.lineTo(u+h,d),i.stroke(),i.lineWidth=1.5,i.strokeStyle="rgba(255, 255, 255, 0.95)",i.stroke(),i.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,u,d-3)}paintOutlinedText(t,e,i){const{ctx:n}=this;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.75)",n.strokeText(t,e,i),n.fillStyle="#fff",n.fillText(t,e,i)}wrap(t,e){const i=[];let n="";for(const s of t.split(" ")){const a=n?`${n} ${s}`:s;n&&this.ctx.measureText(a).width>e?(i.push(n),n=s):n=a}return n&&i.push(n),i}}class Ye{static MIN_ZOOM=.25;static MAX_ZOOM=64;zoom=1;centerX=.5;centerY=.5;get changed(){return this.zoom!==1||this.centerX!==.5||this.centerY!==.5}get zoomFactor(){return this.zoom}reset(){this.zoom=1,this.centerX=.5,this.centerY=.5}zoomAt(t,e,i){const n=Math.min(Ye.MAX_ZOOM,Math.max(Ye.MIN_ZOOM,this.zoom*i)),s=this.centerX+(t-.5)/this.zoom,a=this.centerY+(e-.5)/this.zoom;this.centerX=s-(t-.5)/n,this.centerY=a-(e-.5)/n,this.zoom=n}panBy(t,e){this.centerX-=t/this.zoom,this.centerY-=e/this.zoom}refit(t,e){if(!this.changed)return;const i=this.boundsWithin(t),n=Ye.mercatorY01(e.north),s=Ye.mercatorY01(e.south),a=Ye.mercatorY01(i.north),o=Ye.mercatorY01(i.south);this.zoom=(e.east-e.west)/(i.east-i.west),this.centerX=((i.west+i.east)/2-e.west)/(e.east-e.west),this.centerY=((a+o)/2-n)/(s-n)}keepInView(t,e,i){if(!this.changed)return!1;const n=this.boundsWithin(t),s=Ye.mercatorY01(n.north),a=Ye.mercatorY01(n.south),o=(e.lng-n.west)/(n.east-n.west),c=(Ye.mercatorY01(e.lat)-s)/(a-s);return o>=i&&o<=1-i&&c>=i&&c<=1-i?!1:(this.panBy(.5-o,.5-c),!0)}boundsWithin(t){if(!this.changed)return t;const e=.5/this.zoom,i=Ye.mercatorY01(t.north),n=Ye.mercatorY01(t.south),s=t.east-t.west;return{west:t.west+(this.centerX-e)*s,east:t.west+(this.centerX+e)*s,north:Ye.latitudeAt(i+(this.centerY-e)*(n-i)),south:Ye.latitudeAt(i+(this.centerY+e)*(n-i))}}static expand(t,e){const i=t.east-t.west,n=t.north-t.south;return{west:t.west-i*e,east:t.east+i*e,south:t.south-n*e,north:t.north+n*e}}static pointAt(t,e,i){const n=Ye.mercatorY01(t.north),s=Ye.mercatorY01(t.south);return{lat:Ye.latitudeAt(n+i*(s-n)),lng:t.west+e*(t.east-t.west)}}static mercatorY01(t){const e=t*Math.PI/180;return(1-Math.log(Math.tan(e)+1/Math.cos(e))/Math.PI)/2}static latitudeAt(t){return Math.atan(Math.sinh(Math.PI*(1-2*t)))*180/Math.PI}}const fn=256,gf=3,Kv=32768;class Zv{fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(t,e){const i=(t.south+t.north)/2,n=(t.west+t.east)/2,s=Math.abs(ai(i,t.east,i,t.west).x),a=Math.abs(ai(t.north,n,t.south,n).z),o=Xv(i,Math.max(s,a)),{tiles:c}=mg(n,i,o,gf),l=gf*fn,h=new Float32Array(l*l),u=c[0];await Promise.all(c.map(f=>this.decodeTileInto(f,u,h,l)));const d=new Float32Array(e.width*e.height);for(let f=0;f<e.height;f++){const p=t.north+(t.south-t.north)*(f/(e.height-1));for(let v=0;v<e.width;v++){const m=t.west+(t.east-t.west)*(v/(e.width-1));d[f*e.width+v]=this.sampleAt(p,m,o,u,h,l)}}return{heights:d,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,i,n){const s=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),a=await this.fetchImpl(s);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${s}`);const o=await createImageBitmap(await a.blob()),c=document.createElement("canvas");c.width=fn,c.height=fn;const l=c.getContext("2d");if(!l)throw new Error("2D canvas context unavailable");l.drawImage(o,0,0);const{data:h}=l.getImageData(0,0,fn,fn),u=(t.x-e.x)*fn,d=(t.y-e.y)*fn;for(let f=0;f<fn;f++)for(let p=0;p<fn;p++){const v=(f*fn+p)*4,m=h[v]*256+h[v+1]+h[v+2]/256-Kv,g=u+p,S=d+f;i[S*n+g]=m}}sampleAt(t,e,i,n,s,a){const{x:o,y:c}=fg(e,t,i),l=(o-n.x)*fn,h=(c-n.y)*fn,u=Math.max(0,Math.min(a-1,Math.floor(l))),d=Math.max(0,Math.min(a-1,Math.floor(h))),f=Math.min(a-1,u+1),p=Math.min(a-1,d+1),v=l-u,m=h-d,g=s[d*a+u],S=s[d*a+f],y=s[p*a+u],M=s[p*a+f],b=g+(S-g)*v,w=y+(M-y)*v;return b+(w-b)*m}}const el=256,Jv=5;async function jv(r,t,e,i){const n=(r.south+r.north)/2,s=(r.west+r.east)/2,a=Math.abs(ai(n,r.east,n,r.west).x),o=Math.abs(ai(r.north,s,r.south,s).z),c=Math.max(a,o),{zoom:l,gridSize:h}=Qv(n,c,Math.max(t.width,t.height)),{tiles:u,bounds:d}=mg(s,n,l,h),f=h*el,p=document.createElement("canvas");p.width=f,p.height=f;const v=p.getContext("2d");if(!v)throw new Error("2D canvas context unavailable");const m=u[0];await Promise.all(u.map(async M=>{const b=e(M),w=await i(b);if(!w.ok)throw new Error(`Imagery tile fetch failed (${w.status}): ${b}`);const T=await createImageBitmap(await w.blob());v.drawImage(T,(M.x-m.x)*el,(M.y-m.y)*el)}));const g=Math.min(Math.max(t.width,t.height),f);if(g===f)return{source:p,width:f,height:f,bounds:d};const S=document.createElement("canvas");S.width=g,S.height=g;const y=S.getContext("2d");if(!y)throw new Error("2D canvas context unavailable");return y.drawImage(p,0,0,f,f,0,0,g,g),{source:S,width:g,height:g,bounds:d}}function Qv(r,t,e){let i=Yv(r,t/Math.max(1,e)),n=vf(r,i,t);for(;n>Jv&&i>0;)i--,n=vf(r,i,t);return{zoom:i,gridSize:n,mPerPixel:dg(r,i)/el}}function vf(r,t,e){const i=Math.ceil(e/2/dg(r,t));return Math.max(3,2*i+1)}class t2{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(t,e){return jv(t,e,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}class Tn{attribution="Roads © OpenStreetMap contributors, as surveyed today";contemporary=!0;static DRIVABLE=["motorway","trunk","primary","secondary","tertiary","unclassified","residential","service","track","motorway_link","trunk_link","primary_link","secondary_link","tertiary_link"];static WIDTH_M={motorway:11,trunk:9,primary:8,secondary:7,tertiary:6.5,unclassified:5.5,residential:5.5,service:4,track:3.5};static DEFAULT_WIDTH_M=5;static ENDPOINTS=["https://overpass-api.de/api/interpreter","https://overpass.kumi.systems/api/interpreter","https://overpass.private.coffee/api/interpreter"];fetchImpl;endpoints;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.endpoints=t.endpoints??Tn.ENDPOINTS}static queue=Promise.resolve();static RETRY_MS=4e3;async getRoads(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:30];way["highway"~"^(${Tn.DRIVABLE.join("|")})$"](${e});out geom;`;return this.waysFrom(await this.queued(()=>this.ask(i)))}waysFrom(t){const e=[];for(const i of t.elements??[]){const n=i.geometry,s=i.tags;!s||!n||n.length<2||e.push({id:`osm-${i.id??e.length}`,name:s.name,surface:Tn.surfaceOf(s),widthM:Tn.widthOf(s),points:n.map(a=>({lat:a.lat,lng:a.lon}))})}return e}queued(t){const e=Tn.queue.then(t,t);return Tn.queue=e.catch(()=>{}),e}async ask(t){let e;for(const i of this.endpoints)for(let n=0;n<2;n++){try{const s=await this.fetchImpl(`${i}?data=${encodeURIComponent(t)}`);if(s.ok)return await s.json();if(e=new Error(`${new URL(i).host} refused (${s.status})`),s.status!==429&&s.status!==504)break}catch(s){e=new Error(`${new URL(i).host} unreachable (${String(s)})`);break}await new Promise(s=>setTimeout(s,Tn.RETRY_MS))}throw e??new Error("No Overpass instance answered")}static widthOf(t){const e=Number.parseFloat(t.width??t.est_width??"");if(Number.isFinite(e)&&e>0)return e;const i=Number.parseInt(t.lanes??"",10);return Number.isFinite(i)&&i>0?i*3.5:Tn.WIDTH_M[t.highway]??Tn.DEFAULT_WIDTH_M}static surfaceOf(t){const e=t.surface;return e==="dirt"||e==="earth"||e==="mud"?"dirt":e==="gravel"||e==="fine_gravel"||e==="compacted"||e==="ground"||e==="sand"||e==="unpaved"?"gravel":e?"paved":t.highway==="track"?"gravel":"paved"}}const nh="https://ufoathome.org/roads/index.json";class Qd{attributionRead;contemporaryRead;fetchImpl;indexUrls;fallback;index;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Qd.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Roads © OpenStreetMap contributors"}get contemporary(){return this.contemporaryRead??this.fallback?.contemporary??!0}async getRoads(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getRoads(t);return this.attributionRead=this.fallback.attribution,this.contemporaryRead=this.fallback.contemporary,i}async held(t){let e;try{e=await this.load()}catch{return}const i=e.find(({entry:n})=>n.north>=t.north&&n.south<=t.south&&n.east>=t.east&&n.west<=t.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.ways)?(this.attributionRead=s.attribution,this.contemporaryRead=s.contemporary,s.ways):void 0}catch{return}}load(){return this.index??=this.fetchFirstAvailable(),this.index}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.78.0")}`,e=typeof location>"u"?void 0:new URL("/roads/index.json",location.href).href;return(e&&e!==nh?[e,nh]:[nh]).map(i=>i+t)}}function e2(){return{elevation:new Zv,imagery:gg(),roads:i2()}}function gg(){return new t2}function i2(){return new Qd({fallback:new Tn})}const n2=new Set,yr="show-observer-map",_r="hide-milestones";class pe extends HTMLElement{static get observedAttributes(){return["src",yr,_r]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;issuesBox;issuesButton;issuesPanel;playPauseButton;static OBSERVER_MAP_MIN_SPAN_M=400;static OBSERVER_MAP_MARGIN=.6;static OBSERVER_MAP_IMAGERY_PX=768;fullscreenButton;cornerButtons;observerMapButton;referencesButton;referenceOpacityInput;referencesShownState=!0;referenceOpacityTouched=!1;milestonesButton;observerMapPanel;observerMapCanvas;observerMapRenderer;mapZoomInButton;mapZoomOutButton;mapFitButton;observerMapView=new Ye;observerMapDrag;suppressObserverMapClick=!1;observerMapImageryTimer;observerPlacing=!1;seekInput;playbackFlash;milestoneMarks;milestoneCaption;timeStartLabel;timeEndLabel;timePill;muteButton;volumeInput;controlsRow;moreButton;controlsRight;seekSegments;seekDot;seekPreview;seekPreviewCanvas;seekPreviewTitle;seekPreviewTime;observerPath;observerMapBounds;observerMapImagery;observerMapImageryBounds;observerMapImageryViewWidth=0;observerMapImageryLoading=!1;observerMapImageryCredit;observerMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=kl.create();issues=[];issueCheck=0;sightingAudio=new Lv;soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;steadyObserver=!1;selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;messages=og;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.updateMuteButton(),this.resizeObserverMap()};controlsFitObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.fitControls());controlsMutations;fitControls(){const t=this.controlsRow,e=t.classList.contains("more-open"),i=()=>t.scrollWidth>t.clientWidth+1;if(t.classList.remove("narrow","more-open","compact","tiny"),t.clientWidth>0&&i()){t.classList.add("narrow");for(const n of["compact","tiny"]){if(!i())break;t.classList.add(n)}e&&t.classList.add("more-open")}this.updateMoreButton()}setControlsFolded(t){this.controlsRow.classList.toggle("more-open",!t),this.updateMoreButton()}updateMoreButton(){const t=this.controlsRow.classList.contains("more-open");pe.setIcon(this.moreButton,t?Zt.UNFOLDED:Zt.FOLDED);const e=t?this.messages.fewerControls:this.messages.moreControls;this.moreButton.title=e,this.moreButton.setAttribute("aria-label",e),this.moreButton.setAttribute("aria-expanded",String(t))}addControl(t){this.controlsRight.insertBefore(t,this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null),this.fitControls()}observerMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeObserverMap());resizeObserverMap(){this.observerMapPanel.hidden||(this.sizeObserverMapCanvas(),this.paintObserverMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=t=>{t.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),i=e&&this.shapeAt(e.x,e.y),n=this.said.read(i?.shape.title);if(!n){this.tooltip.hidden=!0;return}this.tooltip.textContent=n,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-s.left+12}px`,this.tooltip.style.top=`${t.clientY-s.top+12}px`};handleObserverMapPointerMove=t=>{if(this.dragObserverMap(t))return;const e=this.observerMapTargetFrom(t);if(!e){if(!this.observerPlacing){this.tooltip.hidden=!0,this.observerMapCanvas.style.cursor="grab";return}this.observerMapCanvas.style.cursor="crosshair",this.showObserverMapTooltip(t,this.messages.placeObserverHere);return}this.observerMapCanvas.style.cursor="pointer",this.showObserverMapTooltip(t,e.label)};showObserverMapTooltip(t,e){this.tooltip.textContent=e,this.tooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-i.left+12}px`,this.tooltip.style.top=`${t.clientY-i.top+12}px`}handleObserverMapClick=t=>{if(this.suppressObserverMapClick){this.suppressObserverMapClick=!1;return}const e=this.observerMapTargetFrom(t);if(!e){this.observerPlacing&&this.placeObserverFrom(t);return}if(e.kind==="milestone"&&e.t!==void 0){this.player.seek(e.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:e.lat,lng:e.lng,kind:e.kind},bubbles:!0,composed:!0}))};observerMapTargetFrom(t){const e=this.observerMapCanvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return this.observerMapRenderer.hitTest((t.clientX-e.left)/e.width*this.observerMapCanvas.width,(t.clientY-e.top)/e.height*this.observerMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};handleObserverMapPointerDown=t=>{t.button===0&&(this.suppressObserverMapClick=!1,this.observerMapDrag={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,moved:!1})};handleObserverMapPointerUp=t=>{const e=this.observerMapDrag;!e||e.pointerId!==t.pointerId||(this.observerMapDrag=void 0,this.observerMapCanvas.classList.remove("dragging"),e.moved&&(this.suppressObserverMapClick=!0,this.paintObserverMap(this.currentTime),this.observerMapCanvas.hasPointerCapture?.(t.pointerId)&&this.observerMapCanvas.releasePointerCapture(t.pointerId)))};dragObserverMap(t){const e=this.observerMapDrag;if(!e||e.pointerId!==t.pointerId)return!1;if(!e.moved){if(Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<pe.OBSERVER_MAP_DRAG_PX)return!1;e.moved=!0,this.tooltip.hidden=!0,this.observerMapCanvas.classList.add("dragging"),this.observerMapCanvas.setPointerCapture?.(t.pointerId)}const i=this.observerMapCanvas.getBoundingClientRect();return i.width>0&&i.height>0&&(this.observerMapView.panBy((t.clientX-e.lastX)/i.width,(t.clientY-e.lastY)/i.height),this.observerMapViewChanged()),e.lastX=t.clientX,e.lastY=t.clientY,!0}static OBSERVER_MAP_DRAG_PX=4;handleObserverMapWheel=t=>{t.preventDefault();const e=this.observerMapCanvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=t.deltaMode===0?t.deltaY:t.deltaY*40;this.zoomObserverMap((t.clientX-e.left)/e.width,(t.clientY-e.top)/e.height,Math.exp(-i*.002))};zoomObserverMap(t,e,i){this.observerMapView.zoomAt(t,e,i),this.observerMapViewChanged()}observerMapViewChanged(){this.mapFitButton.hidden=!this.observerMapView.changed,this.mapZoomInButton.disabled=this.observerMapView.zoomFactor>=Ye.MAX_ZOOM,this.mapZoomOutButton.disabled=this.observerMapView.zoomFactor<=Ye.MIN_ZOOM,this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}scheduleObserverMapImagery(){this.observerMapImageryTimer===void 0&&(this.observerMapImageryTimer=setTimeout(()=>{this.observerMapImageryTimer=void 0,this.loadObserverMapImagery()},pe.OBSERVER_MAP_IMAGERY_DELAY_MS))}static OBSERVER_MAP_FOLLOW_MARGIN=.1;static OBSERVER_MAP_IMAGERY_DELAY_MS=300;get observerMapViewBounds(){return this.observerMapBounds&&this.observerMapView.boundsWithin(this.observerMapBounds)}placeObserverFrom(t){const e=this.observerMapViewBounds,i=this.observerMapCanvas.getBoundingClientRect();if(!e||i.width===0||i.height===0)return;const n=Ye.pointAt(e,(t.clientX-i.left)/i.width,(t.clientY-i.top)/i.height);this.dispatchEvent(new CustomEvent("observerplace",{detail:n,bubbles:!0,composed:!0}))}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${av}</style>${sv}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new No(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.issuesBox=this.shadow.getElementById("issues"),this.issuesButton=this.shadow.getElementById("issues-button"),this.issuesPanel=this.shadow.getElementById("issues-panel"),this.issuesButton.addEventListener("click",e=>{e.stopPropagation(),this.issuesPanel.hidden=!this.issuesPanel.hidden,this.issuesButton.setAttribute("aria-expanded",String(!this.issuesPanel.hidden))}),this.playPauseButton=this.shadow.getElementById("play-pause"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.observerMapButton=this.shadow.getElementById("observer-map"),this.referencesButton=this.shadow.getElementById("references"),this.referenceOpacityInput=this.shadow.getElementById("reference-opacity"),this.milestonesButton=this.shadow.getElementById("milestones"),this.observerMapPanel=this.shadow.getElementById("observer-map-panel"),this.observerMapCanvas=this.shadow.getElementById("observer-map-canvas"),this.observerMapRenderer=new va(this.observerMapCanvas.getContext("2d")),this.mapZoomInButton=this.shadow.getElementById("map-zoom-in"),this.mapZoomOutButton=this.shadow.getElementById("map-zoom-out"),this.mapFitButton=this.shadow.getElementById("map-fit"),this.seekInput=this.shadow.getElementById("seek"),this.playbackFlash=this.shadow.getElementById("playback-flash"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end"),this.timePill=this.shadow.getElementById("time"),this.muteButton=this.shadow.getElementById("mute"),this.controlsRight=this.shadow.getElementById("controls-right"),this.seekSegments=this.shadow.getElementById("seek-segments"),this.seekDot=this.shadow.getElementById("seek-dot"),this.seekPreview=this.shadow.getElementById("seek-preview"),this.seekPreviewCanvas=this.shadow.getElementById("seek-preview-canvas"),this.seekPreviewTitle=this.shadow.getElementById("seek-preview-title"),this.seekPreviewTime=this.shadow.getElementById("seek-preview-time"),this.timePill.addEventListener("click",()=>this.toggleTimeDisplay()),this.timePill.addEventListener("keydown",e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.toggleTimeDisplay())}),this.volumeInput=this.shadow.getElementById("volume"),this.controlsRow=this.shadow.querySelector(".controls"),this.moreButton=this.shadow.getElementById("controls-more"),this.moreButton.addEventListener("click",()=>this.setControlsFolded(this.controlsRow.classList.contains("more-open"))),this.muteButton.addEventListener("click",()=>this.toggleMuted()),this.volumeInput.addEventListener("input",()=>{this.setVolume(Number(this.volumeInput.value))}),this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.addEventListener("keydown",this.handleFullscreenKey),this.observerMapButton.addEventListener("click",()=>this.toggleObserverMap()),this.referencesButton.addEventListener("click",()=>this.toggleReferences()),this.referenceOpacityInput.addEventListener("input",()=>{this.referenceOpacityTouched=!0,this.dispatchReferenceView()}),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.observerMapCanvas.addEventListener("pointermove",this.handleObserverMapPointerMove),this.observerMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.observerMapCanvas.addEventListener("click",this.handleObserverMapClick),this.observerMapCanvas.addEventListener("pointerdown",this.handleObserverMapPointerDown),this.observerMapCanvas.addEventListener("pointerup",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("pointercancel",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("wheel",this.handleObserverMapWheel,{passive:!1}),this.mapZoomInButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,2)),this.mapZoomOutButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,.5)),this.mapFitButton.addEventListener("click",()=>{this.observerMapView.reset(),this.observerMapViewChanged()}),this.seekInput.addEventListener("input",()=>this.player.seek(this.snapSeekToMark(Number(this.seekInput.value)))),this.seekInput.addEventListener("pointerdown",e=>{this.seekSnapArmed=!0,this.nameMarkUnder(e)}),this.seekInput.addEventListener("pointerup",()=>{this.seekSnapArmed=!1}),this.seekInput.addEventListener("pointermove",e=>{this.nameMarkUnder(e),this.hoverSeek(e)}),this.seekInput.addEventListener("pointerleave",()=>{this.seekInput.removeAttribute("title"),this.leaveSeek()}),this.seekInput.addEventListener("keydown",this.handleSeekKey),this.canvas.addEventListener("click",e=>{this.enableClickToPlay&&(e.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause())}),this.canvas.addEventListener("dblclick",e=>{this.enableClickToPlay&&(e.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.observerMapResizeObserver?.observe(this.observerMapPanel),this.controlsFitObserver?.observe(this.controlsRow),typeof MutationObserver<"u"&&(this.controlsMutations=new MutationObserver(()=>this.fitControls()),this.controlsMutations.observe(this.controlsRight,{attributes:!0,attributeFilter:["hidden"],childList:!0,subtree:!0})),this.hostControls(void 0),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateMilestonesButton(),this.refresh()}connectedCallback(){this.saidTexts=void 0,this.loadLocaleMessages();const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.observerMapResizeObserver?.disconnect(),this.controlsFitObserver?.disconnect(),this.controlsMutations?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,i){t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===yr&&this.applyObserverMapDefault(),t===_r&&this.setMilestonesShown(!this.hasAttribute(_r))}async loadFromSrc(t){this.sightingData=await ng.json(t)}get sightingData(){return Ov(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=Fv(t),this.issuesPanel.hidden=!0,this.issuesButton.setAttribute("aria-expanded","false"),this.reportIssues(t,this.currentSighting),this.observerMapView.reset(),this.mapFitButton.hidden=!0,this.observerMapAsked=!1,this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyObserverMapDefault()}get recordingIssues(){return this.issues}async reportIssues(t,e){const i=++this.issueCheck;let n=[];try{const{default:s}=await is(async()=>{const{default:a}=await import("./sightingSchema-DOOSOVWK.js");return{default:a}},[],import.meta.url);n=new An(s).issues(t)}catch{}i===this.issueCheck&&(this.issues=[...n,...e.loadIssues],Cr.warn(this.issues,e.id),this.renderIssues(),this.dispatchEvent(new CustomEvent(s2,{detail:{issues:this.issues},bubbles:!0,composed:!0})))}renderIssues(){const t=this.issues.length;this.issuesBox.hidden=t===0,this.shadow.getElementById("issues-count").textContent=String(t);const e=this.messages.recordingIssues.replace("{count}",String(t));this.issuesButton.title=e,this.issuesButton.setAttribute("aria-label",e),this.shadow.getElementById("issues-title").textContent=e,this.shadow.getElementById("issues-list").replaceChildren(...this.issues.map(i=>{const n=document.createElement("li");return n.textContent=Cr.text(i,this.messages.issueTemplates),n}))}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(t){t!==this.loopEnabled&&this.toggleLoop()}play(){this.player.seekableDuration<=0||this.playbackState==="playing"||this.togglePlayPause()}pause(){this.playbackState==="playing"&&this.togglePlayPause()}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(t){this.toolbar.classList.toggle("hidden",!t),t?this.controlsRight.appendChild(this.fullscreenButton):this.cornerButtons.appendChild(this.fullscreenButton)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(n=>this.highlightedSourceIds.has(n))||(this.highlightedSourceIds=e,this.refresh())}hasVisibleShapeAt(t,e){return this.shapeAt(t,e)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateObserverMap(),this.updateReferences(),this.player.seek(this.player.time)}hostControls(t){const e=[this.milestonesButton,this.referenceOpacityInput,this.referencesButton,this.observerMapButton];if(t)for(const i of e)t.appendChild(i);else{const i=this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null;for(const n of e)this.controlsRight.insertBefore(n,i)}}get referencesShown(){return this.referencesShownState}get referenceOpacity(){return Number(this.referenceOpacityInput.value)}toggleReferences(){this.referencesShownState=!this.referencesShownState,this.updateReferencesButton(),this.dispatchReferenceView()}updateReferences(){const t=this.currentSighting.references;!this.referenceOpacityTouched&&t.length>0&&(this.referenceOpacityInput.value=String(t[0].opacity)),this.updateReferencesButton()}updateReferencesButton(){const t=this.currentSighting.references.length>0;this.referencesButton.hidden=!t,this.referenceOpacityInput.hidden=!t||!this.referencesShownState,this.referencesButton.setAttribute("aria-pressed",String(this.referencesShownState)),pe.setIcon(this.referencesButton,this.referencesShownState?Zt.PICTURES_ON:Zt.PICTURES_OFF);const e=this.referencesShownState?this.messages.hideReferences:this.messages.showReferences;this.referencesButton.title=e,this.referencesButton.setAttribute("aria-label",e),this.referenceOpacityInput.title=this.messages.referenceOpacity,this.referenceOpacityInput.setAttribute("aria-label",this.messages.referenceOpacity)}dispatchReferenceView(){this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity}}))}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?_o(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(i=>{const n=document.createElement("button");n.type="button",n.className="milestone-mark",n.style.left=`${Math.min(Math.max(i.t/t,0),1)*100}%`;const s=this.said.read(i.label)??"",a=this.said.read(i.note),o=a?`${s} — ${a}`:s;return n.title=o,n.setAttribute("aria-label",o),n.dataset.t=String(i.t),n.addEventListener("click",()=>this.player.seek(i.t)),n})),this.refreshSeekSegments(t,e.map(i=>i.t))}seekSegmentList=[];refreshSeekSegments(t,e){const n=[0,...this.milestonesShown&&t>0?[...new Set(e.filter(a=>a>0&&a<t))].sort((a,o)=>a-o):[],Math.max(t,0)];this.seekSegmentList=[];const s=[];for(let a=0;a<n.length-1;a++){const o=document.createElement("div");o.className="seek-segment",o.style.flexGrow=String(Math.max(n[a+1]-n[a],1));const c=document.createElement("i");c.className="seek-hover";const l=document.createElement("i");l.className="seek-played",o.append(c,l),s.push(o),this.seekSegmentList.push({start:n[a],end:n[a+1],element:o,played:l,hover:c})}this.seekSegments.replaceChildren(...s),this.paintSeekProgress(this.player.time)}static fillOf(t,e){const i=t.end-t.start,n=i>0?(e-t.start)/i:e>=t.end?1:0;return`${Math.min(Math.max(n,0),1)*100}%`}paintSeekProgress(t){for(const i of this.seekSegmentList)i.played.style.width=pe.fillOf(i,t);const e=this.player.seekableDuration;this.seekDot.style.left=`${e>0?Math.min(Math.max(t/e,0),1)*100:0}%`}hoverSeek(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=Math.min(Math.max((t.clientX-e.left)/e.width,0),1),s=n*i,a=this.seekSegmentList.length-1;this.seekSegmentList.forEach((f,p)=>{f.hover.style.width=pe.fillOf(f,s),f.element.classList.toggle("hovered",s>=f.start&&(s<f.end||p===a))});const o=this.milestonesShown?this.sighting.milestones:[],c=o.length>0?eh(o,s):void 0,l=c?this.said.read(c.label)??"":"",h=c?this.said.read(c.note):void 0,u=h?`${l} — ${h}`:l;this.seekPreviewTitle.textContent=u,this.seekPreviewTime.textContent=this.formatPosition(s),this.seekPreview.hidden=!1;const d=this.seekPreview.offsetWidth;this.seekPreview.style.left=`${Math.min(Math.max(n*e.width-d/2,0),Math.max(e.width-d,0))}px`,this.paintSeekPreview(s)}leaveSeek(){for(const t of this.seekSegmentList)t.hover.style.width="0",t.element.classList.remove("hovered");this.seekPreview.hidden=!0}seekPreviewPainter;paintSeekPreview(t){const e=this.seekPreviewPainter;this.seekPreviewCanvas.hidden=e===void 0,e?.(t,this.seekPreviewCanvas)}seekSnapArmed=!1;static MARK_SNAP_PX=6;markNear(t){const e=this.player.seekableDuration,i=this.seekInput.getBoundingClientRect().width;if(e<=0||i<=0)return;const n=pe.MARK_SNAP_PX/i*e;let s;for(const a of this.milestoneMarks.children){const o=Number(a.dataset.t);Math.abs(o-t)>n||(!s||Math.abs(o-t)<Math.abs(s.t-t))&&(s={t:o,name:a.title})}return s}snapSeekToMark(t){return this.seekSnapArmed?(this.seekSnapArmed=!1,this.markNear(t)?.t??t):t}nameMarkUnder(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=(t.clientX-e.left)/e.width*i,s=this.markNear(n);s?this.seekInput.title=s.name:this.seekInput.removeAttribute("title")}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?eh(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,!e)return;const i=document.createElement("b");i.textContent=this.said.read(e.label)??"";const n=this.said.read(e.note),s=n?` — ${n}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(s))}exposureInstants(t){const e=this.exposureTimes(t),i=1/e.length;return e.map(n=>({shapes:this.shapesAt(n),share:i}))}exposureTimes(t=this.currentTime){const e=Cn.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<pe.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const i=Math.min(pe.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/pe.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/pe.EXPOSURE_STEP_PX),s=Math.min(pe.MAX_TRAVEL_STEPS,Math.max(i,n)),a=[];for(let o=0;o<s;o++)a.push(e.fromMs+e.ms*o/(s-1));return a}travelPxOver(t,e){const i=this.shapesAt(t),n=this.shapesAt(t+e);let s=0;for(const[a,o]of i){const c=n.get(a);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(o.bounds.y+o.bounds.height/2);s=Math.max(s,Math.hypot(l,h))}return s}shapeAt(t,e,i){for(const n of this.exposureTimes()){const s=this.currentSighting.timeline.hitTest(n,t,e,i);if(s)return s}}shapesAt(t){const e=new Map;for(const i of this.currentSighting.timeline.sourceIds){const n=this.currentSighting.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}return e}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const t=fi.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===t)return;this.canvas.width=t,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${t} / ${this.canvas.height}`)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}onFrame(t,e){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const i=this.playbackState!=="playing"?this.highlightedSourceIds:n2;this.canvasRenderer.setStarPoints(fi.starPointsOf(this.sighting.instrument));const n=(di(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const s=this.exposureInstants(t),a=this.frameShift;if(this.paintsShapes)for(const o of s)for(const[,c]of o.shapes){const l=o.share,h=l===1?c:{...c,transparency:1-(1-c.transparency)*l};this.canvasRenderer.paintShape(this.shifted(h,a))}for(const[o,c]of s[0].shapes)!this.selectionShown||!i.has(o)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...c,selected:!0}):this.canvasRenderer.paintMemberOutline(c):this.canvasRenderer.paintSelectionOnly(this.shifted(c,a)));if(this.selectionShown&&i.size>1){const o=cn.groupBoundsFor([...e].filter(([c])=>i.has(c)).map(([,c])=>c.bounds));this.canvasRenderer.paintGroupHandles(o)}this.overlayPainter?.(this.canvasRenderer),this.mapShapeBounds=s.flatMap(o=>[...o.shapes.values()].filter(c=>c.transparency<1).map(c=>this.shifted(c,a).bounds)),this.keepObserverMapClear(),this.seekInput.value=String(t),this.paintSeekProgress(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintObserverMap(t),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Ev(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}shifted(t,e){return e.x===0&&e.y===0?t:{...t,bounds:{...t.bounds,x:t.bounds.x+e.x,y:t.bounds.y+e.y}}}createPlayer(){const t=new Av(this.currentSighting.timeline,(e,i)=>this.onFrame(e,i));return t.loop=this.loopEnabled,t.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},t}static SEEK_KEY_STEP_MS=5e3;handleFullscreenKey=t=>{t.key.toLowerCase()!=="f"||t.altKey||t.ctrlKey||t.metaKey||!this.enableClickToPlay||t.composedPath().some(i=>i instanceof HTMLElement&&(i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName)&&i.type!=="range"))||(t.preventDefault(),this.toggleFullscreen())};handleSeekKey=t=>{if(t.altKey||t.ctrlKey||t.metaKey)return;const e=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0;if(e){t.preventDefault();const i=this.player.seekableDuration;this.player.seek(Math.min(i,Math.max(0,this.player.time+e*pe.SEEK_KEY_STEP_MS)))}else t.key===" "&&(t.preventDefault(),this.togglePlayPause())};togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton(),this.flashPlayback())}flashPlayback(){const t=this.playbackFlash;t.innerHTML=this.player.playbackState==="playing"?Zt.PLAY:Zt.PAUSE,t.classList.remove("flashing"),t.offsetWidth,t.classList.add("flashing")}static icons=new WeakMap;static setIcon(t,e){pe.icons.get(t)!==e&&(pe.icons.set(t,e),t.innerHTML=e)}updatePlayPauseButton(){const t=this.player.playbackState==="playing";pe.setIcon(this.playPauseButton,t?Zt.PAUSE:Zt.PLAY);const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const i=e?t?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=i,this.playPauseButton.setAttribute("aria-label",i)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.player.loop=this.loopEnabled}restorePlayback(){const t=this.playbackBeforeClick;t&&(this.currentTime=t.time,t.state==="playing"?this.play():this.pause())}get canUseNativeFullscreen(){return typeof this.fullscreenTarget.requestFullscreen=="function"&&document.fullscreenEnabled}toggleFullscreen(){if(!this.canUseNativeFullscreen){this.simulatedFullscreen?this.exitSimulatedFullscreen():this.enterSimulatedFullscreen();return}document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}enterSimulatedFullscreen(){const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=t.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const e=t.style;e.setProperty("position","fixed"),e.setProperty("inset","0"),e.setProperty("margin","0"),e.setProperty("max-width","none"),e.setProperty("max-height","none"),e.setProperty("aspect-ratio","auto"),e.setProperty("z-index","2147483647"),e.setProperty("background","#000"),e.setProperty("width","100vw"),e.setProperty("width","100dvw"),e.setProperty("height","100vh"),e.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?t.setAttribute("style",this.styleBeforeSimulatedFullscreen):t.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}toggleObserverMap(){const t=this.observerMapPanel.hidden;this.observerMapAsked=t,this.setObserverMapOpen(t),this.keepObserverMapClear()}observerMapAsked=!1;applyObserverMapDefault(){const t=this.getAttribute(yr),e=t===null?this.observerPath?.travels===!0:t!=="false";this.setObserverMapOpen(e&&this.observerPath!==void 0)}setObserverMapOpen(t){this.observerMapPanel.hidden=!t,this.observerMapPanel.removeAttribute("title"),this.observerMapButton.setAttribute("aria-pressed",String(t)),this.updateObserverMapButton(),t&&(this.sizeObserverMapCanvas(),this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime))}updateObserverMapButton(){const t=!this.observerMapPanel.hidden;pe.setIcon(this.observerMapButton,t?Zt.MAP_ON:Zt.MAP_OFF);const e=t?this.messages.hideObserverMap:this.messages.showObserverMap;this.observerMapButton.title=e,this.observerMapButton.setAttribute("aria-label",e);const i=[[this.mapZoomInButton,this.messages.zoomMapIn],[this.mapZoomOutButton,this.messages.zoomMapOut],[this.mapFitButton,this.messages.fitMap]];for(const[n,s]of i)n.title=s,n.setAttribute("aria-label",s)}updateObserverMap(){const t=this.observerPath!==void 0;if(this.observerPath=xr.of(this.currentSighting),this.observerMapButton.hidden=this.observerPath===void 0,!t&&this.observerPath&&this.applyObserverMapDefault(),!this.observerPath){this.setObserverMapOpen(!1),this.observerMapBounds=void 0;return}const e=this.observerPath.boundsAround(pe.OBSERVER_MAP_MIN_SPAN_M,pe.OBSERVER_MAP_MARGIN);(!this.observerMapBounds||!this.sameGround(this.observerMapBounds,e))&&(this.observerMapBounds&&this.observerMapView.refit(this.observerMapBounds,e),this.observerMapBounds=e,this.observerMapImagery=void 0,this.observerMapImageryCredit=void 0,this.observerMapImageryFailed=!1,this.observerMapImageryBounds=void 0,this.observerMapImageryLoading=!1,this.observerMapPanel.hidden||this.loadObserverMapImagery())}sameGround(t,e){const i=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<i&&Math.abs(t.south-e.south)<i&&Math.abs(t.west-e.west)<i&&Math.abs(t.east-e.east)<i}async loadObserverMapImagery(){const t=this.observerMapViewBounds;if(!t||this.observerMapPanel.hidden||this.observerMapImageryLoading||!this.observerMapImageryNeededFor(t))return;const e=this.observerMapView.changed,i=e?Ye.expand(t,pe.OBSERVER_MAP_IMAGERY_AHEAD):t,n=pe.OBSERVER_MAP_IMAGERY_PX*(e?1+2*pe.OBSERVER_MAP_IMAGERY_AHEAD:1);this.observerMapImageryBounds=i,this.observerMapImageryViewWidth=t.east-t.west,this.observerMapImageryLoading=!0;const s=gg();try{const a=await s.getImageryTexture(i,{width:n,height:n});if(this.observerMapImageryBounds!==i)return;this.observerMapImagery=a,this.observerMapImageryCredit=s.attribution,this.observerMapImageryFailed=!1}catch{if(this.observerMapImageryBounds!==i)return;this.observerMapImageryFailed=this.observerMapImagery===void 0}finally{this.observerMapImageryBounds===i&&(this.observerMapImageryLoading=!1)}this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}static OBSERVER_MAP_IMAGERY_AHEAD=.5;static OBSERVER_MAP_IMAGERY_LOOKAHEAD=.25;observerMapImageryNeededFor(t){const e=this.observerMapImageryBounds;if(!e)return!0;const i=this.observerMapImagery?.bounds??e,n=this.observerMapView.changed?Ye.expand(t,pe.OBSERVER_MAP_IMAGERY_LOOKAHEAD):t,s=n.west>=i.west&&n.east<=i.east&&n.south>=i.south&&n.north<=i.north,a=t.east-t.west>this.observerMapImageryViewWidth/2;return!s||!a}get observerMapCredit(){return this.observerMapImageryCredit}get observerMapFooterLine(){return this.observerMapImageryFailed?this.messages.mapImageryUnavailable:this.creditShownExternally?void 0:this.observerMapImageryCredit}mapShapeBounds=[];mapSceneBounds=[];setMapSubjectBounds(t){this.mapSceneBounds=t.map(e=>({x:e.x*this.canvas.width,y:e.y*this.canvas.height,width:e.width*this.canvas.width,height:e.height*this.canvas.height})),this.keepObserverMapClear()}keepObserverMapClear(){if(this.observerMapPanel.hidden)return;const t=this.observerMapBoxPx;if(!t)return;const e=[...this.mapShapeBounds,...this.mapSceneBounds],i=(l,h,u)=>{for(const d of e)if(!(d.x+d.width<l-u||d.x>h+u)&&!(d.y>t.bottom+u||d.y+d.height<t.top-u))return!0;return!1},n=[this.canvas.width-t.width,this.canvas.width],s=[0,t.width],a=pe.OBSERVER_MAP_CLEARANCE_PX,o=i(...n,0),c=i(...s,0);if(this.observerMapPanel.classList.toggle("subject-overlap",o&&c&&!this.observerMapAsked),this.observerMapPanel.classList.contains("on-the-left")){!o&&(c||!i(n[0],n[1],a))&&this.observerMapPanel.classList.remove("on-the-left");return}i(n[0],n[1],0)&&!i(s[0],s[1],0)&&this.observerMapPanel.classList.add("on-the-left")}observerMapBoxPx;static OBSERVER_MAP_CLEARANCE_PX=24;sizeObserverMapCanvas(){const t=this.observerMapPanel.clientWidth;if(t===0)return;const e=Math.round(t*(globalThis.devicePixelRatio??1));this.measureObserverMapBox(),this.observerMapCanvas.width!==e&&(this.observerMapCanvas.width=e,this.observerMapCanvas.height=e)}measureObserverMapBox(){const t=this.observerMapPanel.getBoundingClientRect(),e=this.canvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=this.canvas.width/e.width,n=this.canvas.height/e.height;this.observerMapBoxPx={width:t.width*i,top:(t.top-e.top)*n,bottom:(t.bottom-e.top)*n}}paintObserverMap(t){if(this.observerMapPanel.hidden||!this.observerPath||!this.observerMapBounds)return;const e=di(this.currentSighting,t);e?.lat!==void 0&&e.lng!==void 0&&!this.observerMapDrag?.moved&&this.observerMapView.keepInView(this.observerMapBounds,{lat:e.lat,lng:e.lng},pe.OBSERVER_MAP_FOLLOW_MARGIN)&&this.scheduleObserverMapImagery();const i=this.currentSighting.instrument,n=[],s=this.currentSighting.milestones.length>0?eh(this.currentSighting.milestones,t):void 0;for(const a of this.milestonesShown?_o(this.currentSighting.milestones):[]){const o=di(this.currentSighting,a.t);o?.lat===void 0||o.lng===void 0||n.push({label:this.said.read(a.label)??"",note:this.said.read(a.note),t:a.t,lat:o.lat,lng:o.lng,current:a===s})}this.observerMapRenderer.paint({bounds:this.observerMapViewBounds,imagery:this.observerMapImagery,path:this.observerPath,position:e?.lat!==void 0&&e.lng!==void 0?{lat:e.lat,lng:e.lng}:void 0,headingDeg:e?.headingDeg===void 0?void 0:e.headingDeg+this.lookYawDeg,coneHalfAngleDeg:e?Ss.of(i,this.canvas.height,e.fovDeg).halfWidthAngleDeg(fi.aspectOf(i)):void 0,markers:n,decor:this.observerMapDecorAt(t),observerLabel:this.said.read(this.currentSighting.observer?.title)??this.messages.observerHere,nightFraction:this.observerMapNightFraction,attribution:this.observerMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(t){this.milestonesShown=t,this.milestoneMarks.hidden=!t,this.refreshSeekSegments(this.player.seekableDuration,_o(this.sighting.milestones).map(e=>e.t)),this.milestonesButton.setAttribute("aria-pressed",String(t)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintObserverMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0,pe.setIcon(this.milestonesButton,this.milestonesShown?Zt.MILESTONES_ON:Zt.MILESTONES_OFF);const t=this.milestonesShown?this.messages.hideMilestones:this.messages.showMilestones;this.milestonesButton.title=t,this.milestonesButton.setAttribute("aria-label",t)}observerMapDecorAt(t){const e=di(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=Io(i,t),{lat:s,lng:a}=_s(n.eastM,-n.northM,e.lat,e.lng);return{lat:s,lng:a,headingDeg:n.headingDeg,label:this.said.read(i.title)??this.messages.decorHere}})}observerMapNightFraction;setSunAltitude(t){const e=t===void 0?void 0:Math.max(0,Math.min(1,-t/12));e!==this.observerMapNightFraction&&(this.observerMapNightFraction=e,this.paintObserverMap(this.currentTime))}setLookOffset(t,e){t===this.lookYawDeg&&e===this.lookPitchDeg||(this.lookYawDeg=t,this.lookPitchDeg=e,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const t=this.gaitAt(this.currentTime),e=this.lookYawDeg+t.yawDeg,i=this.lookPitchDeg+t.pitchDeg;if(e===0&&i===0)return{x:0,y:0};const n=di(this.currentSighting,this.currentTime),s=Ss.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(e),y:s.angleDegToRadiusPx(i)}}gaitAt(t){return _e.bodyAt(this.currentSighting,t,this.steadyObserver)}mutedState=!1;get muted(){return this.mutedState}set muted(t){t!==this.mutedState&&(this.mutedState=t,!t&&this.volumeState===0&&(this.volumeState=pe.RESTORED_VOLUME),this.applyLevel())}volumeState=1;static RESTORED_VOLUME=.5;get volume(){return this.volumeState}set volume(t){this.setVolume(t)}setVolume(t){this.volumeState=Math.min(Math.max(t,0),1),this.mutedState=this.volumeState===0,this.applyLevel()}get level(){return this.mutedState?0:this.volumeState}applyLevel(){this.sightingAudio.setLevel(this.level),this.updateMuteButton(),this.dispatchEvent(new CustomEvent("mutedchange",{bubbles:!0,composed:!0,detail:{muted:this.mutedState,volume:this.volumeState}}))}toggleMuted(){this.muted=!this.mutedState}updateMuteButton(){pe.setIcon(this.muteButton,this.mutedState?Zt.MUTED:Zt.VOLUME);const t=this.mutedState?this.messages.unmute:this.messages.mute;this.muteButton.title=t,this.muteButton.setAttribute("aria-label",t),this.muteButton.setAttribute("aria-pressed",String(this.mutedState)),this.volumeInput.value=String(this.level)}updateFullscreenButton(){const t=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;pe.setIcon(this.fullscreenButton,t?Zt.EXIT_FULLSCREEN:Zt.ENTER_FULLSCREEN),this.fullscreenButton.title=t?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new $s(fl.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=ag(fl.preferencesFor(this),rg);if(t===this.messagesLanguage||t==="en"&&this.messagesLanguage===void 0)return;this.messagesLanguage=t;const e=await zv(t);this.messagesLanguage===t&&this.applyMessages(e)}messagesLanguage;updateTimeLabelTitles(){const t=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,e=this.canSwitchTimeDisplay?` — ${t}`:"";this.timeStartLabel.title=this.messages.currentPosition+e,this.timeEndLabel.title=this.messages.duration+e,this.timePill.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(this.timePill.setAttribute("role","button"),this.timePill.setAttribute("tabindex","0")):(this.timePill.removeAttribute("role"),this.timePill.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.updateTimeLabelTitles(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateMilestonesButton(),this.renderIssues()}updateTimeLabels(){const t=this.currentSighting.event,e=Sv(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?bu(t.time):void 0;const i=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&i>0?i/this.realDurationMs:1,this.player.durationOverrideMs=i>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return nc(t);const e=this.currentSighting.timeline.duration,i=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?xf(Mf(this.realStartMs+i)):nc(i)}formatEndOfTimeline(){return this.realDurationMs===void 0?nc(this.currentSighting.timeline.duration):this.canShowClockTime?xf(Mf(this.realStartMs+this.realDurationMs)):nc(this.realDurationMs)}}function Mf(r){const t=new Date(r);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function xf(r){if(r.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return r.second?`${t(r.hour)}:${t(r.minute??0)}:${t(r.second)}`:`${t(r.hour)}:${t(r.minute??0)}`}function nc(r){const t=Math.round(r/1e3),e=Math.floor(t/60),i=t%60;return`${e}:${String(i).padStart(2,"0")}`}const Eu="rr0-ufo";function vg(){customElements.get(Eu)||customElements.define(Eu,pe)}const s2="recordingissues";/**
1097
1154
  * @license
1098
1155
  * Copyright 2010-2026 Three.js Authors
1099
1156
  * SPDX-License-Identifier: MIT
1100
- */const t0="185",a2=0,yf=1,r2=2,So=1,o2=2,mo=3,ia=0,Ve=1,ji=2,as=0,ta=1,Ni=2,_f=3,Sf=4,zl=5,Ma=100,c2=101,l2=102,h2=103,u2=104,d2=200,Fo=201,f2=202,p2=203,Au=204,Uo=205,m2=206,g2=207,v2=208,M2=209,x2=210,y2=211,_2=212,S2=213,b2=214,Tu=0,Ru=1,Du=2,Pr=3,Iu=4,Cu=5,Pu=6,Lu=7,e0=0,w2=1,E2=2,rs=0,Mg=1,xg=2,yg=3,_g=4,Sg=5,bg=6,wg=7,bf="attached",A2="detached",Eg=300,Oa=301,Lr=302,sh=303,ah=304,Bl=306,ko=1e3,wi=1001,Ou=1002,Re=1003,T2=1004,sc=1005,oe=1006,rh=1007,wa=1008,un=1009,Ag=1010,Tg=1011,zo=1012,i0=1013,Sn=1014,Oi=1015,qe=1016,n0=1017,s0=1018,Bo=1020,Rg=35902,Dg=35899,Ig=1021,Cg=1022,Ei=1023,Es=1026,Ea=1027,Hl=1028,a0=1029,Na=1030,r0=1031,o0=1033,il=33776,nl=33777,sl=33778,al=33779,Nu=35840,Fu=35841,Uu=35842,ku=35843,zu=36196,Bu=37492,Hu=37496,Gu=37488,Vu=37489,pl=37490,Wu=37491,Xu=37808,Yu=37809,qu=37810,$u=37811,Ku=37812,Zu=37813,Ju=37814,ju=37815,Qu=37816,td=37817,ed=37818,id=37819,nd=37820,sd=37821,ad=36492,rd=36494,od=36495,cd=36283,ld=36284,ml=36285,hd=36286,Pg=2200,R2=2201,D2=2202,gl=2300,ud=2301,oh=2302,wf=2303,fr=2400,pr=2401,vl=2402,c0=2500,I2=2501,JE=0,jE=1,QE=2,C2=3200,Ml=0,P2=1,Ks="",Gi="srgb",xl="srgb-linear",yl="linear",Se="srgb",Ga=7680,Ef=519,L2=512,O2=513,N2=514,l0=515,F2=516,U2=517,h0=518,k2=519,dd=35044,_l="300 es",ns=2e3,Ho=2001;function z2(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function B2(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Go(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function H2(){const r=Go("canvas");return r.style.display="block",r}const Af={};function Sl(...r){const t="THREE."+r.shift();console.log(t,...r)}function Lg(r){const t=r[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=r[1];e&&e.isStackTrace?r[0]+=" "+e.getLocation():r[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return r}function Rt(...r){r=Lg(r);const t="THREE."+r.shift();{const e=r[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...r)}}function Gt(...r){r=Lg(r);const t="THREE."+r.shift();{const e=r[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...r)}}function Sr(...r){const t=r.join(" ");t in Af||(Af[t]=!0,Rt(...r))}function G2(r,t,e){return new Promise(function(i,n){function s(){switch(r.clientWaitSync(t,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:n();break;case r.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:i()}}setTimeout(s,e)})}const V2={[Tu]:Ru,[Du]:Pu,[Iu]:Lu,[Pr]:Cu,[Ru]:Tu,[Pu]:Du,[Lu]:Iu,[Cu]:Pr};class aa{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return i===void 0?!1:i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){const i=this._listeners;if(i===void 0)return;const n=i[t];if(n!==void 0){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const i=e[t.type];if(i!==void 0){t.target=this;const n=i.slice(0);for(let s=0,a=n.length;s<a;s++)n[s].call(this,t);t.target=null}}}const Ri=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Tf=1234567;const bo=Math.PI/180,Or=180/Math.PI;function Nn(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Ri[r&255]+Ri[r>>8&255]+Ri[r>>16&255]+Ri[r>>24&255]+"-"+Ri[t&255]+Ri[t>>8&255]+"-"+Ri[t>>16&15|64]+Ri[t>>24&255]+"-"+Ri[e&63|128]+Ri[e>>8&255]+"-"+Ri[e>>16&255]+Ri[e>>24&255]+Ri[i&255]+Ri[i>>8&255]+Ri[i>>16&255]+Ri[i>>24&255]).toLowerCase()}function te(r,t,e){return Math.max(t,Math.min(e,r))}function u0(r,t){return(r%t+t)%t}function W2(r,t,e,i,n){return i+(r-t)*(n-i)/(e-t)}function X2(r,t,e){return r!==t?(e-r)/(t-r):0}function wo(r,t,e){return(1-e)*r+e*t}function Y2(r,t,e,i){return wo(r,t,1-Math.exp(-e*i))}function q2(r,t=1){return t-Math.abs(u0(r,t*2)-t)}function $2(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function K2(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function Z2(r,t){return r+Math.floor(Math.random()*(t-r+1))}function J2(r,t){return r+Math.random()*(t-r)}function j2(r){return r*(.5-Math.random())}function Q2(r){r!==void 0&&(Tf=r);let t=Tf+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function tM(r){return r*bo}function eM(r){return r*Or}function iM(r){return(r&r-1)===0&&r!==0}function nM(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function sM(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function aM(r,t,e,i,n){const s=Math.cos,a=Math.sin,o=s(e/2),c=a(e/2),l=s((t+i)/2),h=a((t+i)/2),u=s((t-i)/2),d=a((t-i)/2),f=s((i-t)/2),p=a((i-t)/2);switch(n){case"XYX":r.set(o*h,c*u,c*d,o*l);break;case"YZY":r.set(c*d,o*h,c*u,o*l);break;case"ZXZ":r.set(c*u,c*d,o*h,o*l);break;case"XZX":r.set(o*h,c*p,c*f,o*l);break;case"YXY":r.set(c*f,o*h,c*p,o*l);break;case"ZYZ":r.set(c*p,c*f,o*h,o*l);break;default:Rt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function Ln(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function be(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const tA={DEG2RAD:bo,RAD2DEG:Or,generateUUID:Nn,clamp:te,euclideanModulo:u0,mapLinear:W2,inverseLerp:X2,lerp:wo,damp:Y2,pingpong:q2,smoothstep:$2,smootherstep:K2,randInt:Z2,randFloat:J2,randFloatSpread:j2,seededRandom:Q2,degToRad:tM,radToDeg:eM,isPowerOfTwo:iM,ceilPowerOfTwo:nM,floorPowerOfTwo:sM,setQuaternionFromProperEuler:aM,normalize:be,denormalize:Ln};class xt{static{xt.prototype.isVector2=!0}constructor(t=0,e=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 new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: 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){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[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=te(this.x,t.x,e.x),this.y=te(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=te(this.x,t,e),this.y=te(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(te(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){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(te(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const 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){const i=Math.cos(e),n=Math.sin(e),s=this.x-t.x,a=this.y-t.y;return this.x=s*i-a*n+t.x,this.y=s*n+a*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Qi{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,s,a,o){let c=i[n+0],l=i[n+1],h=i[n+2],u=i[n+3],d=s[a+0],f=s[a+1],p=s[a+2],v=s[a+3];if(u!==v||c!==d||l!==f||h!==p){let m=c*d+l*f+h*p+u*v;m<0&&(d=-d,f=-f,p=-p,v=-v,m=-m);let g=1-o;if(m<.9995){const S=Math.acos(m),y=Math.sin(S);g=Math.sin(g*S)/y,o=Math.sin(o*S)/y,c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o}else{c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o;const S=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=S,l*=S,h*=S,u*=S}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,i,n,s,a){const o=i[n],c=i[n+1],l=i[n+2],h=i[n+3],u=s[a],d=s[a+1],f=s[a+2],p=s[a+3];return t[e]=o*p+h*u+c*f-l*d,t[e+1]=c*p+h*d+l*u-o*f,t[e+2]=l*p+h*f+o*d-c*u,t[e+3]=h*p-o*u-c*d-l*f,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,n){return this._x=t,this._y=e,this._z=i,this._w=n,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){const i=t._x,n=t._y,s=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(i/2),h=o(n/2),u=o(s/2),d=c(i/2),f=c(n/2),p=c(s/2);switch(a){case"XYZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"YXZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"ZXY":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"ZYX":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"YZX":this._x=d*h*u+l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u-d*f*p;break;case"XZY":this._x=d*h*u-l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u+d*f*p;break;default:Rt("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],s=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],u=e[10],d=i+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(s-l)*f,this._z=(a-n)*f}else if(i>o&&i>u){const f=2*Math.sqrt(1+i-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(n+a)/f,this._z=(s+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-i-u);this._w=(s-l)/f,this._x=(n+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-i-o);this._w=(a-n)/f,this._x=(s+l)/f,this._y=(c+h)/f,this._z=.25*f}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._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(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(te(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const n=Math.min(1,e/i);return this.slerp(t,n),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 t===0?(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){const i=t._x,n=t._y,s=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=i*h+a*o+n*l-s*c,this._y=n*h+a*c+s*o-i*l,this._z=s*h+a*l+i*c-n*o,this._w=a*h-i*o-n*c-s*l,this._onChangeCallback(),this}slerp(t,e){let i=t._x,n=t._y,s=t._z,a=t._w,o=this.dot(t);o<0&&(i=-i,n=-n,s=-s,a=-a,o=-o);let c=1-e;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,e=Math.sin(e*l)/h,this._x=this._x*c+i*e,this._y=this._y*c+n*e,this._z=this._z*c+s*e,this._w=this._w*c+a*e,this._onChangeCallback()}else this._x=this._x*c+i*e,this._y=this._y*c+n*e,this._z=this._z*c+s*e,this._w=this._w*c+a*e,this.normalize();return this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(t),n*Math.cos(t),s*Math.sin(e),s*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 R{static{R.prototype.isVector3=!0}constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(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 new Error("THREE.Vector3: 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 new Error("THREE.Vector3: 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(Rf.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Rf.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*n,this.y=s[1]*e+s[4]*i+s[7]*n,this.z=s[2]*e+s[5]*i+s[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=t.elements,a=1/(s[3]*e+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*n+s[12])*a,this.y=(s[1]*e+s[5]*i+s[9]*n+s[13])*a,this.z=(s[2]*e+s[6]*i+s[10]*n+s[14])*a,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,s=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*n-o*i),h=2*(o*e-s*n),u=2*(s*i-a*e);return this.x=e+c*l+a*u-o*h,this.y=i+c*h+o*l-s*u,this.z=n+c*u+s*h-a*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n,this.y=s[1]*e+s[5]*i+s[9]*n,this.z=s[2]*e+s[6]*i+s[10]*n,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=te(this.x,t.x,e.x),this.y=te(this.y,t.y,e.y),this.z=te(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=te(this.x,t,e),this.y=te(this.y,t,e),this.z=te(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(te(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){const i=t.x,n=t.y,s=t.z,a=e.x,o=e.y,c=e.z;return this.x=n*c-s*o,this.y=s*a-i*c,this.z=i*o-n*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return ch.copy(this).projectOnVector(t),this.sub(ch)}reflect(t){return this.sub(ch.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(te(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}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){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*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){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}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(){const t=Math.random()*Math.PI*2,e=Math.random()*2-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}}const ch=new R,Rf=new Qi;class Yt{static{Yt.prototype.isMatrix3=!0}constructor(t,e,i,n,s,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,a,o,c,l)}set(t,e,i,n,s,a,o,c,l){const h=this.elements;return h[0]=t,h[1]=n,h[2]=o,h[3]=e,h[4]=s,h[5]=c,h[6]=i,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const 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){const 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){const i=t.elements,n=e.elements,s=this.elements,a=i[0],o=i[3],c=i[6],l=i[1],h=i[4],u=i[7],d=i[2],f=i[5],p=i[8],v=n[0],m=n[3],g=n[6],S=n[1],y=n[4],M=n[7],b=n[2],w=n[5],T=n[8];return s[0]=a*v+o*S+c*b,s[3]=a*m+o*y+c*w,s[6]=a*g+o*M+c*T,s[1]=l*v+h*S+u*b,s[4]=l*m+h*y+u*w,s[7]=l*g+h*M+u*T,s[2]=d*v+f*S+p*b,s[5]=d*m+f*y+p*w,s[8]=d*g+f*M+p*T,this}multiplyScalar(t){const 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(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-i*s*h+i*o*c+n*s*l-n*a*c}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=h*a-o*l,d=o*c-h*s,f=l*s-a*c,p=e*u+i*d+n*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/p;return t[0]=u*v,t[1]=(n*l-h*i)*v,t[2]=(o*i-n*a)*v,t[3]=d*v,t[4]=(h*e-n*c)*v,t[5]=(n*s-o*e)*v,t[6]=f*v,t[7]=(i*c-l*e)*v,t[8]=(a*e-i*s)*v,this}transpose(){let t;const 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){const 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,n,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*a+l*o)+a+t,-n*l,n*c,-n*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return Sr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(lh.makeScale(t,e)),this}rotate(t){return Sr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(lh.makeRotation(-t)),this}translate(t,e){return Sr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(lh.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){const 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){const e=this.elements,i=t.elements;for(let n=0;n<9;n++)if(e[n]!==i[n])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){const 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)}}const lh=new Yt,Df=new Yt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),If=new Yt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function rM(){const r={enabled:!0,workingColorSpace:xl,spaces:{},convert:function(n,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Se&&(n.r=ws(n.r),n.g=ws(n.g),n.b=ws(n.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(n.applyMatrix3(this.spaces[s].toXYZ),n.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Se&&(n.r=br(n.r),n.g=br(n.g),n.b=br(n.b))),n},workingToColorSpace:function(n,s){return this.convert(n,this.workingColorSpace,s)},colorSpaceToWorking:function(n,s){return this.convert(n,s,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===Ks?yl:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,s=this.workingColorSpace){return n.fromArray(this.spaces[s].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,s,a){return n.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,s){return Sr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(n,s)},toWorkingColorSpace:function(n,s){return Sr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(n,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],i=[.3127,.329];return r.define({[xl]:{primaries:t,whitePoint:i,transfer:yl,toXYZ:Df,fromXYZ:If,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Gi},outputColorSpaceConfig:{drawingBufferColorSpace:Gi}},[Gi]:{primaries:t,whitePoint:i,transfer:Se,toXYZ:Df,fromXYZ:If,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Gi}}}),r}const re=rM();function ws(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function br(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Va;class oM{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{Va===void 0&&(Va=Go("canvas")),Va.width=t.width,Va.height=t.height;const n=Va.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),i=Va}return i.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Go("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),s=n.data;for(let a=0;a<s.length;a++)s[a]=ws(s[a]/255)*255;return i.putImageData(n,0,0),e}else if(t.data){const e=t.data.slice(0);for(let i=0;i<e.length;i++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[i]=Math.floor(ws(e[i]/255)*255):e[i]=ws(e[i]);return{data:e,width:t.width,height:t.height}}else return Rt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let cM=0;class d0{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:cM++}),this.uuid=Nn(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let s;if(Array.isArray(n)){s=[];for(let a=0,o=n.length;a<o;a++)n[a].isDataTexture?s.push(hh(n[a].image)):s.push(hh(n[a]))}else s=hh(n);i.url=s}return e||(t.images[this.uuid]=i),i}}function hh(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?oM.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(Rt("Texture: Unable to serialize Texture."),{})}let lM=0;const uh=new R;class bi extends aa{constructor(t=bi.DEFAULT_IMAGE,e=bi.DEFAULT_MAPPING,i=wi,n=wi,s=oe,a=wa,o=Ei,c=un,l=bi.DEFAULT_ANISOTROPY,h=Ks){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:lM++}),this.uuid=Nn(),this.name="",this.source=new d0(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new xt(0,0),this.repeat=new xt(1,1),this.center=new xt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Yt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,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,this.normalized=!1}get width(){return this.source.getSize(uh).x}get height(){return this.source.getSize(uh).y}get depth(){return this.source.getSize(uh).z}get image(){return this.source.data}set image(t){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.normalized=t.normalized,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(const e in t){const i=t[e];if(i===void 0){Rt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){Rt(`Texture.setValues(): property '${e}' does not exist.`);continue}n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const 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,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Eg)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ko:t.x=t.x-Math.floor(t.x);break;case wi:t.x=t.x<0?0:1;break;case Ou:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case ko:t.y=t.y-Math.floor(t.y);break;case wi:t.y=t.y<0?0:1;break;case Ou:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}bi.DEFAULT_IMAGE=null;bi.DEFAULT_MAPPING=Eg;bi.DEFAULT_ANISOTROPY=1;class ne{static{ne.prototype.isVector4=!0}constructor(t=0,e=0,i=0,n=1){this.x=t,this.y=e,this.z=i,this.w=n}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,n){return this.x=t,this.y=e,this.z=i,this.w=n,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 new Error("THREE.Vector4: 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 new Error("THREE.Vector4: 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=t.w!==void 0?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){const e=this.x,i=this.y,n=this.z,s=this.w,a=t.elements;return this.x=a[0]*e+a[4]*i+a[8]*n+a[12]*s,this.y=a[1]*e+a[5]*i+a[9]*n+a[13]*s,this.z=a[2]*e+a[6]*i+a[10]*n+a[14]*s,this.w=a[3]*e+a[7]*i+a[11]*n+a[15]*s,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);const 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,n,s;const c=t.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],p=c[9],v=c[2],m=c[6],g=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(p-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(p+m)<.1&&Math.abs(l+f+g-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const y=(l+1)/2,M=(f+1)/2,b=(g+1)/2,w=(h+d)/4,T=(u+v)/4,x=(p+m)/4;return y>M&&y>b?y<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(y),n=w/i,s=T/i):M>b?M<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(M),i=w/n,s=x/n):b<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(b),i=T/s,n=x/s),this.set(i,n,s,e),this}let S=Math.sqrt((m-p)*(m-p)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(S)<.001&&(S=1),this.x=(m-p)/S,this.y=(u-v)/S,this.z=(d-h)/S,this.w=Math.acos((l+f+g-1)/2),this}setFromMatrixPosition(t){const 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=te(this.x,t.x,e.x),this.y=te(this.y,t.y,e.y),this.z=te(this.z,t.z,e.z),this.w=te(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=te(this.x,t,e),this.y=te(this.y,t,e),this.z=te(this.z,t,e),this.w=te(this.w,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(te(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 hM extends aa{constructor(t=1,e=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:oe,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=i.depth,this.scissor=new ne(0,0,t,e),this.scissorTest=!1,this.viewport=new ne(0,0,t,e),this.textures=[];const n={width:t,height:e,depth:i.depth},s=new bi(n),a=i.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(t={}){const e={minFilter:oe,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,i=1){if(this.width!==t||this.height!==e||this.depth!==i){this.width=t,this.height=e,this.depth=i;for(let n=0,s=this.textures.length;n<s;n++)this.textures[n].image.width=t,this.textures[n].image.height=e,this.textures[n].image.depth=i,this.textures[n].isData3DTexture!==!0&&(this.textures[n].isArrayTexture=this.textures[n].image.depth>1);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<i;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const n=Object.assign({},t.textures[e].image);this.textures[e].source=new d0(n)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this.multiview=t.multiview,this.useArrayDepthTexture=t.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ri extends hM{constructor(t=1,e=1,i={}){super(t,e,i),this.isWebGLRenderTarget=!0}}class Og extends bi{constructor(t=null,e=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=Re,this.minFilter=Re,this.wrapR=wi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Ng extends bi{constructor(t=null,e=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=Re,this.minFilter=Re,this.wrapR=wi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Zt{static{Zt.prototype.isMatrix4=!0}constructor(t,e,i,n,s,a,o,c,l,h,u,d,f,p,v,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,a,o,c,l,h,u,d,f,p,v,m)}set(t,e,i,n,s,a,o,c,l,h,u,d,f,p,v,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=s,g[5]=a,g[9]=o,g[13]=c,g[2]=l,g[6]=h,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=v,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 Zt().fromArray(this.elements)}copy(t){const 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){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const 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 this.determinantAffine()===0?(t.set(1,0,0),e.set(0,1,0),i.set(0,0,1),this):(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(t.determinantAffine()===0)return this.identity();const e=this.elements,i=t.elements,n=1/Wa.setFromMatrixColumn(t,0).length(),s=1/Wa.setFromMatrixColumn(t,1).length(),a=1/Wa.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=0,e[8]=i[8]*a,e[9]=i[9]*a,e[10]=i[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,s=t.z,a=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){const d=a*h,f=a*u,p=o*h,v=o*u;e[0]=c*h,e[4]=-c*u,e[8]=l,e[1]=f+p*l,e[5]=d-v*l,e[9]=-o*c,e[2]=v-d*l,e[6]=p+f*l,e[10]=a*c}else if(t.order==="YXZ"){const d=c*h,f=c*u,p=l*h,v=l*u;e[0]=d+v*o,e[4]=p*o-f,e[8]=a*l,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-p,e[6]=v+d*o,e[10]=a*c}else if(t.order==="ZXY"){const d=c*h,f=c*u,p=l*h,v=l*u;e[0]=d-v*o,e[4]=-a*u,e[8]=p+f*o,e[1]=f+p*o,e[5]=a*h,e[9]=v-d*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){const d=a*h,f=a*u,p=o*h,v=o*u;e[0]=c*h,e[4]=p*l-f,e[8]=d*l+v,e[1]=c*u,e[5]=v*l+d,e[9]=f*l-p,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){const d=a*c,f=a*l,p=o*c,v=o*l;e[0]=c*h,e[4]=v-d*u,e[8]=p*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=f*u+p,e[10]=d-v*u}else if(t.order==="XZY"){const d=a*c,f=a*l,p=o*c,v=o*l;e[0]=c*h,e[4]=-u,e[8]=l*h,e[1]=d*u+v,e[5]=a*h,e[9]=f*u-p,e[2]=p*u-f,e[6]=o*h,e[10]=v*u+d}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(uM,t,dM)}lookAt(t,e,i){const n=this.elements;return en.subVectors(t,e),en.lengthSq()===0&&(en.z=1),en.normalize(),Os.crossVectors(i,en),Os.lengthSq()===0&&(Math.abs(i.z)===1?en.x+=1e-4:en.z+=1e-4,en.normalize(),Os.crossVectors(i,en)),Os.normalize(),ac.crossVectors(en,Os),n[0]=Os.x,n[4]=ac.x,n[8]=en.x,n[1]=Os.y,n[5]=ac.y,n[9]=en.y,n[2]=Os.z,n[6]=ac.z,n[10]=en.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,s=this.elements,a=i[0],o=i[4],c=i[8],l=i[12],h=i[1],u=i[5],d=i[9],f=i[13],p=i[2],v=i[6],m=i[10],g=i[14],S=i[3],y=i[7],M=i[11],b=i[15],w=n[0],T=n[4],x=n[8],A=n[12],C=n[1],I=n[5],P=n[9],V=n[13],X=n[2],L=n[6],B=n[10],k=n[14],$=n[3],tt=n[7],J=n[11],it=n[15];return s[0]=a*w+o*C+c*X+l*$,s[4]=a*T+o*I+c*L+l*tt,s[8]=a*x+o*P+c*B+l*J,s[12]=a*A+o*V+c*k+l*it,s[1]=h*w+u*C+d*X+f*$,s[5]=h*T+u*I+d*L+f*tt,s[9]=h*x+u*P+d*B+f*J,s[13]=h*A+u*V+d*k+f*it,s[2]=p*w+v*C+m*X+g*$,s[6]=p*T+v*I+m*L+g*tt,s[10]=p*x+v*P+m*B+g*J,s[14]=p*A+v*V+m*k+g*it,s[3]=S*w+y*C+M*X+b*$,s[7]=S*T+y*I+M*L+b*tt,s[11]=S*x+y*P+M*B+b*J,s[15]=S*A+y*V+M*k+b*it,this}multiplyScalar(t){const 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(){const t=this.elements,e=t[0],i=t[4],n=t[8],s=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],u=t[6],d=t[10],f=t[14],p=t[3],v=t[7],m=t[11],g=t[15],S=c*f-l*d,y=o*f-l*u,M=o*d-c*u,b=a*f-l*h,w=a*d-c*h,T=a*u-o*h;return e*(v*S-m*y+g*M)-i*(p*S-m*b+g*w)+n*(p*y-v*b+g*T)-s*(p*M-v*w+m*T)}determinantAffine(){const t=this.elements,e=t[0],i=t[4],n=t[8],s=t[1],a=t[5],o=t[9],c=t[2],l=t[6],h=t[10];return e*(a*h-o*l)-i*(s*h-o*c)+n*(s*l-a*c)}transpose(){const t=this.elements;let e;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(t,e,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=t[9],d=t[10],f=t[11],p=t[12],v=t[13],m=t[14],g=t[15],S=e*o-i*a,y=e*c-n*a,M=e*l-s*a,b=i*c-n*o,w=i*l-s*o,T=n*l-s*c,x=h*v-u*p,A=h*m-d*p,C=h*g-f*p,I=u*m-d*v,P=u*g-f*v,V=d*g-f*m,X=S*V-y*P+M*I+b*C-w*A+T*x;if(X===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const L=1/X;return t[0]=(o*V-c*P+l*I)*L,t[1]=(n*P-i*V-s*I)*L,t[2]=(v*T-m*w+g*b)*L,t[3]=(d*w-u*T-f*b)*L,t[4]=(c*C-a*V-l*A)*L,t[5]=(e*V-n*C+s*A)*L,t[6]=(m*M-p*T-g*y)*L,t[7]=(h*T-d*M+f*y)*L,t[8]=(a*P-o*C+l*x)*L,t[9]=(i*C-e*P-s*x)*L,t[10]=(p*w-v*M+g*S)*L,t[11]=(u*M-h*w-f*S)*L,t[12]=(o*A-a*I-c*x)*L,t[13]=(e*I-i*A+n*x)*L,t[14]=(v*y-p*b-m*S)*L,t[15]=(h*b-u*y+d*S)*L,this}scale(t){const e=this.elements,i=t.x,n=t.y,s=t.z;return e[0]*=i,e[4]*=n,e[8]*=s,e[1]*=i,e[5]*=n,e[9]*=s,e[2]*=i,e[6]*=n,e[10]*=s,e[3]*=i,e[7]*=n,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}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){const 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){const 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){const 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){const i=Math.cos(e),n=Math.sin(e),s=1-i,a=t.x,o=t.y,c=t.z,l=s*a,h=s*o;return this.set(l*a+i,l*o-n*c,l*c+n*o,0,l*o+n*c,h*o+i,h*c-n*a,0,l*c-n*o,h*c+n*a,s*c*c+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,n,s,a){return this.set(1,i,s,0,t,1,a,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,s=e._x,a=e._y,o=e._z,c=e._w,l=s+s,h=a+a,u=o+o,d=s*l,f=s*h,p=s*u,v=a*h,m=a*u,g=o*u,S=c*l,y=c*h,M=c*u,b=i.x,w=i.y,T=i.z;return n[0]=(1-(v+g))*b,n[1]=(f+M)*b,n[2]=(p-y)*b,n[3]=0,n[4]=(f-M)*w,n[5]=(1-(d+g))*w,n[6]=(m+S)*w,n[7]=0,n[8]=(p+y)*T,n[9]=(m-S)*T,n[10]=(1-(d+v))*T,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;t.x=n[12],t.y=n[13],t.z=n[14];const s=this.determinantAffine();if(s===0)return i.set(1,1,1),e.identity(),this;let a=Wa.set(n[0],n[1],n[2]).length();const o=Wa.set(n[4],n[5],n[6]).length(),c=Wa.set(n[8],n[9],n[10]).length();s<0&&(a=-a),bn.copy(this);const l=1/a,h=1/o,u=1/c;return bn.elements[0]*=l,bn.elements[1]*=l,bn.elements[2]*=l,bn.elements[4]*=h,bn.elements[5]*=h,bn.elements[6]*=h,bn.elements[8]*=u,bn.elements[9]*=u,bn.elements[10]*=u,e.setFromRotationMatrix(bn),i.x=a,i.y=o,i.z=c,this}makePerspective(t,e,i,n,s,a,o=ns,c=!1){const l=this.elements,h=2*s/(e-t),u=2*s/(i-n),d=(e+t)/(e-t),f=(i+n)/(i-n);let p,v;if(c)p=s/(a-s),v=a*s/(a-s);else if(o===ns)p=-(a+s)/(a-s),v=-2*a*s/(a-s);else if(o===Ho)p=-a/(a-s),v=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,i,n,s,a,o=ns,c=!1){const l=this.elements,h=2/(e-t),u=2/(i-n),d=-(e+t)/(e-t),f=-(i+n)/(i-n);let p,v;if(c)p=1/(a-s),v=a/(a-s);else if(o===ns)p=-2/(a-s),v=-(a+s)/(a-s);else if(o===Ho)p=-1/(a-s),v=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let n=0;n<16;n++)if(e[n]!==i[n])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){const 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}}const Wa=new R,bn=new Zt,uM=new R(0,0,0),dM=new R(1,1,1),Os=new R,ac=new R,en=new R,Cf=new Zt,Pf=new Qi;class As{constructor(t=0,e=0,i=0,n=As.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}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,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,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){const n=t.elements,s=n[0],a=n[4],o=n[8],c=n[1],l=n[5],h=n[9],u=n[2],d=n[6],f=n[10];switch(e){case"XYZ":this._y=Math.asin(te(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-te(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(te(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-te(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(te(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-te(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Rt("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return Cf.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Cf,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Pf.setFromEuler(this),this.setFromQuaternion(Pf,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],t[3]!==void 0&&(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}}As.DEFAULT_ORDER="XYZ";class f0{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let fM=0;const Lf=new R,Xa=new Qi,ls=new Zt,rc=new R,Wr=new R,pM=new R,mM=new Qi,Of=new R(1,0,0),Nf=new R(0,1,0),Ff=new R(0,0,1),Uf={type:"added"},gM={type:"removed"},Ya={type:"childadded",child:null},dh={type:"childremoved",child:null};class Be extends aa{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:fM++}),this.uuid=Nn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Be.DEFAULT_UP.clone();const t=new R,e=new As,i=new Qi,n=new R(1,1,1);function s(){i.setFromEuler(e,!1)}function a(){e.setFromQuaternion(i,void 0,!1)}e._onChange(s),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Zt},normalMatrix:{value:new Yt}}),this.matrix=new Zt,this.matrixWorld=new Zt,this.matrixAutoUpdate=Be.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Be.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new f0,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Xa.setFromAxisAngle(t,e),this.quaternion.multiply(Xa),this}rotateOnWorldAxis(t,e){return Xa.setFromAxisAngle(t,e),this.quaternion.premultiply(Xa),this}rotateX(t){return this.rotateOnAxis(Of,t)}rotateY(t){return this.rotateOnAxis(Nf,t)}rotateZ(t){return this.rotateOnAxis(Ff,t)}translateOnAxis(t,e){return Lf.copy(t).applyQuaternion(this.quaternion),this.position.add(Lf.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Of,t)}translateY(t){return this.translateOnAxis(Nf,t)}translateZ(t){return this.translateOnAxis(Ff,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(ls.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?rc.copy(t):rc.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Wr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ls.lookAt(Wr,rc,this.up):ls.lookAt(rc,Wr,this.up),this.quaternion.setFromRotationMatrix(ls),n&&(ls.extractRotation(n.matrixWorld),Xa.setFromRotationMatrix(ls),this.quaternion.premultiply(Xa.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Gt("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Uf),Ya.child=t,this.dispatchEvent(Ya),Ya.child=null):Gt("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(gM),dh.child=t,this.dispatchEvent(dh),dh.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),ls.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),ls.multiply(t.parent.matrixWorld)),t.applyMatrix4(ls),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Uf),Ya.child=t,this.dispatchEvent(Ya),Ya.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let i=0,n=this.children.length;i<n;i++){const a=this.children[i].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const n=this.children;for(let s=0,a=n.length;s<a;s++)n[s].getObjectsByProperty(t,e,i);return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Wr,t,pM),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Wr,mM,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,i=t.y,n=t.z,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*i-s[8]*n,s[13]+=i-s[1]*e-s[5]*i-s[9]*n,s[14]+=n-s[2]*e-s[6]*i-s[10]*n}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].updateMatrixWorld(t)}updateWorldMatrix(t,e,i=!1){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),e===!0){const s=this.children;for(let a=0,o=s.length;a<o;a++)s[a].updateWorldMatrix(!1,!0,i)}}toJSON(t){const e=t===void 0||typeof t=="string",i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),this.static!==!1&&(n.static=this.static),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.pivot!==null&&(n.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(o=>({...o})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(t),n.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];s(t.shapes,u)}else s(t.shapes,c)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(s(t.materials,this.material[c]));n.material=o}else n.material=s(t.materials,this.material);if(this.children.length>0){n.children=[];for(let o=0;o<this.children.length;o++)n.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];n.animations.push(s(t.animations,c))}}if(e){const o=a(t.geometries),c=a(t.materials),l=a(t.textures),h=a(t.images),u=a(t.shapes),d=a(t.skeletons),f=a(t.animations),p=a(t.nodes);o.length>0&&(i.geometries=o),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),h.length>0&&(i.images=h),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=n,i;function a(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}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.pivot=t.pivot!==null?t.pivot.clone():null,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.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let i=0;i<t.children.length;i++){const n=t.children[i];this.add(n.clone())}return this}}Be.DEFAULT_UP=new R(0,1,0);Be.DEFAULT_MATRIX_AUTO_UPDATE=!0;Be.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Ce extends Be{constructor(){super(),this.isGroup=!0,this.type="Group"}}const vM={type:"move"};class fh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ce,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Ce,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ce,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const 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}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,i){let n=null,s=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(const v of t.hand.values()){const m=e.getJointPose(v,i),g=this._getHandJoint(l,v);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius),g.visible=m!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,p=.005;l.inputState.pinching&&d>f+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&d<=f-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,i),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:t,target:this})));o!==null&&(n=e.getPose(t.targetRaySpace,i),n===null&&s!==null&&(n=s),n!==null&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(vM)))}return o!==null&&(o.visible=n!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const i=new Ce;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}const Fg={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ns={h:0,s:0,l:0},oc={h:0,s:0,l:0};function ph(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class st{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){if(e===void 0&&i===void 0){const n=t;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Gi){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,re.colorSpaceToWorking(this,e),this}setRGB(t,e,i,n=re.workingColorSpace){return this.r=t,this.g=e,this.b=i,re.colorSpaceToWorking(this,n),this}setHSL(t,e,i,n=re.workingColorSpace){if(t=u0(t,1),e=te(e,0,1),i=te(i,0,1),e===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+e):i+e-i*e,a=2*i-s;this.r=ph(a,s,t+1/3),this.g=ph(a,s,t),this.b=ph(a,s,t-1/3)}return re.colorSpaceToWorking(this,n),this}setStyle(t,e=Gi){function i(s){s!==void 0&&parseFloat(s)<1&&Rt("Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const a=n[1],o=n[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:Rt("Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=n[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(s,16),e);Rt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Gi){const i=Fg[t.toLowerCase()];return i!==void 0?this.setHex(i,e):Rt("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=ws(t.r),this.g=ws(t.g),this.b=ws(t.b),this}copyLinearToSRGB(t){return this.r=br(t.r),this.g=br(t.g),this.b=br(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Gi){return re.workingToColorSpace(Di.copy(this),t),Math.round(te(Di.r*255,0,255))*65536+Math.round(te(Di.g*255,0,255))*256+Math.round(te(Di.b*255,0,255))}getHexString(t=Gi){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=re.workingColorSpace){re.workingToColorSpace(Di.copy(this),e);const i=Di.r,n=Di.g,s=Di.b,a=Math.max(i,n,s),o=Math.min(i,n,s);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case i:c=(n-s)/u+(n<s?6:0);break;case n:c=(s-i)/u+2;break;case s:c=(i-n)/u+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=re.workingColorSpace){return re.workingToColorSpace(Di.copy(this),e),t.r=Di.r,t.g=Di.g,t.b=Di.b,t}getStyle(t=Gi){re.workingToColorSpace(Di.copy(this),t);const e=Di.r,i=Di.g,n=Di.b;return t!==Gi?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(t,e,i){return this.getHSL(Ns),this.setHSL(Ns.h+t,Ns.s+e,Ns.l+i)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(Ns),t.getHSL(oc);const i=wo(Ns.h,oc.h,e),n=wo(Ns.s,oc.s,e),s=wo(Ns.l,oc.l,e);return this.setHSL(i,n,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,i=this.g,n=this.b,s=t.elements;return this.r=s[0]*e+s[3]*i+s[6]*n,this.g=s[1]*e+s[4]*i+s[7]*n,this.b=s[2]*e+s[5]*i+s[8]*n,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Di=new st;st.NAMES=Fg;class p0{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new st(t),this.near=e,this.far=i}clone(){return new p0(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Ts extends Be{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 As,this.environmentIntensity=1,this.environmentRotation=new As,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(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),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const wn=new R,hs=new R,mh=new R,us=new R,qa=new R,$a=new R,kf=new R,gh=new R,vh=new R,Mh=new R,xh=new ne,yh=new ne,_h=new ne;class yn{constructor(t=new R,e=new R,i=new R){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),wn.subVectors(t,e),n.cross(wn);const s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(t,e,i,n,s){wn.subVectors(n,e),hs.subVectors(i,e),mh.subVectors(t,e);const a=wn.dot(wn),o=wn.dot(hs),c=wn.dot(mh),l=hs.dot(hs),h=hs.dot(mh),u=a*l-o*o;if(u===0)return s.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,p=(a*h-o*c)*d;return s.set(1-f-p,p,f)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,us)===null?!1:us.x>=0&&us.y>=0&&us.x+us.y<=1}static getInterpolation(t,e,i,n,s,a,o,c){return this.getBarycoord(t,e,i,n,us)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,us.x),c.addScaledVector(a,us.y),c.addScaledVector(o,us.z),c)}static getInterpolatedAttribute(t,e,i,n,s,a){return xh.setScalar(0),yh.setScalar(0),_h.setScalar(0),xh.fromBufferAttribute(t,e),yh.fromBufferAttribute(t,i),_h.fromBufferAttribute(t,n),a.setScalar(0),a.addScaledVector(xh,s.x),a.addScaledVector(yh,s.y),a.addScaledVector(_h,s.z),a}static isFrontFacing(t,e,i,n){return wn.subVectors(i,e),hs.subVectors(t,e),wn.cross(hs).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,i,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,n),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 wn.subVectors(this.c,this.b),hs.subVectors(this.a,this.b),wn.cross(hs).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return yn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return yn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,n,s){return yn.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}containsPoint(t){return yn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return yn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,n=this.b,s=this.c;let a,o;qa.subVectors(n,i),$a.subVectors(s,i),gh.subVectors(t,i);const c=qa.dot(gh),l=$a.dot(gh);if(c<=0&&l<=0)return e.copy(i);vh.subVectors(t,n);const h=qa.dot(vh),u=$a.dot(vh);if(h>=0&&u<=h)return e.copy(n);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(i).addScaledVector(qa,a);Mh.subVectors(t,s);const f=qa.dot(Mh),p=$a.dot(Mh);if(p>=0&&f<=p)return e.copy(s);const v=f*l-c*p;if(v<=0&&l>=0&&p<=0)return o=l/(l-p),e.copy(i).addScaledVector($a,o);const m=h*p-f*u;if(m<=0&&u-h>=0&&f-p>=0)return kf.subVectors(s,n),o=(u-h)/(u-h+(f-p)),e.copy(n).addScaledVector(kf,o);const g=1/(m+v+d);return a=v*g,o=d*g,e.copy(i).addScaledVector(qa,a).addScaledVector($a,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Vi{constructor(t=new R(1/0,1/0,1/0),e=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e+=3)this.expandByPoint(En.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(En.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=En.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const i=t.geometry;if(i!==void 0){const s=i.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,En):En.fromBufferAttribute(s,a),En.applyMatrix4(t.matrixWorld),this.expandByPoint(En);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),cc.copy(t.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),cc.copy(i.boundingBox)),cc.applyMatrix4(t.matrixWorld),this.union(cc)}const n=t.children;for(let s=0,a=n.length;s<a;s++)this.expandByObject(n[s],e);return this}containsPoint(t){return t.x>=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,En),En.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(Xr),lc.subVectors(this.max,Xr),Ka.subVectors(t.a,Xr),Za.subVectors(t.b,Xr),Ja.subVectors(t.c,Xr),Fs.subVectors(Za,Ka),Us.subVectors(Ja,Za),ca.subVectors(Ka,Ja);let e=[0,-Fs.z,Fs.y,0,-Us.z,Us.y,0,-ca.z,ca.y,Fs.z,0,-Fs.x,Us.z,0,-Us.x,ca.z,0,-ca.x,-Fs.y,Fs.x,0,-Us.y,Us.x,0,-ca.y,ca.x,0];return!Sh(e,Ka,Za,Ja,lc)||(e=[1,0,0,0,1,0,0,0,1],!Sh(e,Ka,Za,Ja,lc))?!1:(hc.crossVectors(Fs,Us),e=[hc.x,hc.y,hc.z],Sh(e,Ka,Za,Ja,lc))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,En).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(En).length()*.5),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()?this:(ds[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ds[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ds[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ds[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ds[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ds[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ds[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ds[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ds),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}}const ds=[new R,new R,new R,new R,new R,new R,new R,new R],En=new R,cc=new Vi,Ka=new R,Za=new R,Ja=new R,Fs=new R,Us=new R,ca=new R,Xr=new R,lc=new R,hc=new R,la=new R;function Sh(r,t,e,i,n){for(let s=0,a=r.length-3;s<=a;s+=3){la.fromArray(r,s);const o=n.x*Math.abs(la.x)+n.y*Math.abs(la.y)+n.z*Math.abs(la.z),c=t.dot(la),l=e.dot(la),h=i.dot(la);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const ys=MM();function MM(){const r=new ArrayBuffer(4),t=new Float32Array(r),e=new Uint32Array(r),i=new Uint32Array(512),n=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(i[c]=0,i[c|256]=32768,n[c]=24,n[c|256]=24):l<-14?(i[c]=1024>>-l-14,i[c|256]=1024>>-l-14|32768,n[c]=-l-1,n[c|256]=-l-1):l<=15?(i[c]=l+15<<10,i[c|256]=l+15<<10|32768,n[c]=13,n[c|256]=13):l<128?(i[c]=31744,i[c|256]=64512,n[c]=24,n[c|256]=24):(i[c]=31744,i[c|256]=64512,n[c]=13,n[c|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,s[c]=l|h}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:t,uint32View:e,baseTable:i,shiftTable:n,mantissaTable:s,exponentTable:a,offsetTable:o}}function xM(r){Math.abs(r)>65504&&Rt("DataUtils.toHalfFloat(): Value out of range."),r=te(r,-65504,65504),ys.floatView[0]=r;const t=ys.uint32View[0],e=t>>23&511;return ys.baseTable[e]+((t&8388607)>>ys.shiftTable[e])}function yM(r){const t=r>>10;return ys.uint32View[0]=ys.mantissaTable[ys.offsetTable[t]+(r&1023)]+ys.exponentTable[t],ys.floatView[0]}class Fn{static toHalfFloat(t){return xM(t)}static fromHalfFloat(t){return yM(t)}}const li=new R,uc=new xt;let _M=0;class ee extends aa{constructor(t,e,i=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:_M++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=i,this.usage=dd,this.updateRanges=[],this.gpuType=Oi,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&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 n=0,s=this.itemSize;n<s;n++)this.array[t+n]=e.array[i+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,i=this.count;e<i;e++)uc.fromBufferAttribute(this,e),uc.applyMatrix3(t),this.setXY(e,uc.x,uc.y);else if(this.itemSize===3)for(let e=0,i=this.count;e<i;e++)li.fromBufferAttribute(this,e),li.applyMatrix3(t),this.setXYZ(e,li.x,li.y,li.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)li.fromBufferAttribute(this,e),li.applyMatrix4(t),this.setXYZ(e,li.x,li.y,li.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)li.fromBufferAttribute(this,e),li.applyNormalMatrix(t),this.setXYZ(e,li.x,li.y,li.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)li.fromBufferAttribute(this,e),li.transformDirection(t),this.setXYZ(e,li.x,li.y,li.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let i=this.array[t*this.itemSize+e];return this.normalized&&(i=Ln(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=be(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ln(e,this.array)),e}setX(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ln(e,this.array)),e}setY(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Ln(e,this.array)),e}setZ(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Ln(e,this.array)),e}setW(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),i=be(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),i=be(i,this.array),n=be(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this}setXYZW(t,e,i,n,s){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),i=be(i,this.array),n=be(n,this.array),s=be(s,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==dd&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class Ug extends ee{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class m0 extends ee{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class de extends ee{constructor(t,e,i){super(new Float32Array(t),e,i)}}const SM=new Vi,Yr=new R,bh=new R;class Rs{constructor(t=new R,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){const i=this.center;e!==void 0?i.copy(e):SM.setFromPoints(t).getCenter(i);let n=0;for(let s=0,a=t.length;s<a;s++)n=Math.max(n,i.distanceToSquared(t[s]));return this.radius=Math.sqrt(n),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const i=this.center.distanceToSquared(t);return e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(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;Yr.subVectors(t,this.center);const e=Yr.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),n=(i-this.radius)*.5;this.center.addScaledVector(Yr,n/i),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(bh.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Yr.copy(t.center).add(bh)),this.expandByPoint(Yr.copy(t.center).sub(bh))),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 bM=0;const pn=new Zt,wh=new Be,ja=new R,nn=new Vi,qr=new Vi,Mi=new R;class ce extends aa{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:bM++}),this.uuid=Nn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(z2(t)?m0:Ug)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,i=0){this.groups.push({start:t,count:e,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new Yt().getNormalMatrix(t);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(t),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return pn.makeRotationFromQuaternion(t),this.applyMatrix4(pn),this}rotateX(t){return pn.makeRotationX(t),this.applyMatrix4(pn),this}rotateY(t){return pn.makeRotationY(t),this.applyMatrix4(pn),this}rotateZ(t){return pn.makeRotationZ(t),this.applyMatrix4(pn),this}translate(t,e,i){return pn.makeTranslation(t,e,i),this.applyMatrix4(pn),this}scale(t,e,i){return pn.makeScale(t,e,i),this.applyMatrix4(pn),this}lookAt(t){return wh.lookAt(t),wh.updateMatrix(),this.applyMatrix4(wh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ja).negate(),this.translate(ja.x,ja.y,ja.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const i=[];for(let n=0,s=t.length;n<s;n++){const a=t[n];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new de(i,3))}else{const i=Math.min(t.length,e.count);for(let n=0;n<i;n++){const s=t[n];e.setXYZ(n,s.x,s.y,s.z||0)}t.length>e.count&&Rt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Vi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Gt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let i=0,n=e.length;i<n;i++){const s=e[i];nn.setFromBufferAttribute(s),this.morphTargetsRelative?(Mi.addVectors(this.boundingBox.min,nn.min),this.boundingBox.expandByPoint(Mi),Mi.addVectors(this.boundingBox.max,nn.max),this.boundingBox.expandByPoint(Mi)):(this.boundingBox.expandByPoint(nn.min),this.boundingBox.expandByPoint(nn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Gt('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Rs);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Gt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(t){const i=this.boundingSphere.center;if(nn.setFromBufferAttribute(t),e)for(let s=0,a=e.length;s<a;s++){const o=e[s];qr.setFromBufferAttribute(o),this.morphTargetsRelative?(Mi.addVectors(nn.min,qr.min),nn.expandByPoint(Mi),Mi.addVectors(nn.max,qr.max),nn.expandByPoint(Mi)):(nn.expandByPoint(qr.min),nn.expandByPoint(qr.max))}nn.getCenter(i);let n=0;for(let s=0,a=t.count;s<a;s++)Mi.fromBufferAttribute(t,s),n=Math.max(n,i.distanceToSquared(Mi));if(e)for(let s=0,a=e.length;s<a;s++){const o=e[s],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)Mi.fromBufferAttribute(o,l),c&&(ja.fromBufferAttribute(t,l),Mi.add(ja)),n=Math.max(n,i.distanceToSquared(Mi))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&Gt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Gt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=e.position,n=e.normal,s=e.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==i.count)&&(a=new ee(new Float32Array(4*i.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let x=0;x<i.count;x++)o[x]=new R,c[x]=new R;const l=new R,h=new R,u=new R,d=new xt,f=new xt,p=new xt,v=new R,m=new R;function g(x,A,C){l.fromBufferAttribute(i,x),h.fromBufferAttribute(i,A),u.fromBufferAttribute(i,C),d.fromBufferAttribute(s,x),f.fromBufferAttribute(s,A),p.fromBufferAttribute(s,C),h.sub(l),u.sub(l),f.sub(d),p.sub(d);const I=1/(f.x*p.y-p.x*f.y);isFinite(I)&&(v.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(I),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(I),o[x].add(v),o[A].add(v),o[C].add(v),c[x].add(m),c[A].add(m),c[C].add(m))}let S=this.groups;S.length===0&&(S=[{start:0,count:t.count}]);for(let x=0,A=S.length;x<A;++x){const C=S[x],I=C.start,P=C.count;for(let V=I,X=I+P;V<X;V+=3)g(t.getX(V+0),t.getX(V+1),t.getX(V+2))}const y=new R,M=new R,b=new R,w=new R;function T(x){b.fromBufferAttribute(n,x),w.copy(b);const A=o[x];y.copy(A),y.sub(b.multiplyScalar(b.dot(A))).normalize(),M.crossVectors(w,A);const I=M.dot(c[x])<0?-1:1;a.setXYZW(x,y.x,y.y,y.z,I)}for(let x=0,A=S.length;x<A;++x){const C=S[x],I=C.start,P=C.count;for(let V=I,X=I+P;V<X;V+=3)T(t.getX(V+0)),T(t.getX(V+1)),T(t.getX(V+2))}this._transformed=!0}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==e.count)i=new ee(new Float32Array(e.count*3),3),this.setAttribute("normal",i);else for(let d=0,f=i.count;d<f;d++)i.setXYZ(d,0,0,0);const n=new R,s=new R,a=new R,o=new R,c=new R,l=new R,h=new R,u=new R;if(t)for(let d=0,f=t.count;d<f;d+=3){const p=t.getX(d+0),v=t.getX(d+1),m=t.getX(d+2);n.fromBufferAttribute(e,p),s.fromBufferAttribute(e,v),a.fromBufferAttribute(e,m),h.subVectors(a,s),u.subVectors(n,s),h.cross(u),o.fromBufferAttribute(i,p),c.fromBufferAttribute(i,v),l.fromBufferAttribute(i,m),o.add(h),c.add(h),l.add(h),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(v,c.x,c.y,c.z),i.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,f=e.count;d<f;d+=3)n.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,s),u.subVectors(n,s),h.cross(u),i.setXYZ(d+0,h.x,h.y,h.z),i.setXYZ(d+1,h.x,h.y,h.z),i.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)Mi.fromBufferAttribute(t,e),Mi.normalize(),t.setXYZ(e,Mi.x,Mi.y,Mi.z)}toNonIndexed(){function t(o,c){const l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h);let f=0,p=0;for(let v=0,m=c.length;v<m;v++){o.isInterleavedBufferAttribute?f=c[v]*o.data.stride+o.offset:f=c[v]*h;for(let g=0;g<h;g++)d[p++]=l[f++]}return new ee(d,h,u)}if(this.index===null)return Rt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new ce,i=this.index.array,n=this.attributes;for(const o in n){const c=n[o],l=t(c,i);e.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const c=[],l=s[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=t(d,i);c.push(f)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const c in i){const l=i[c];t.data.attributes[c]=l.toJSON(t.data)}const n={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(t.data))}h.length>0&&(n[c]=h,s=!0)}s&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.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;const e={};this.name=t.name;const i=t.index;i!==null&&this.setIndex(i.clone());const n=t.attributes;for(const l in n){const h=n[l];this.setAttribute(l,h.clone(e))}const s=t.morphAttributes;for(const l in s){const h=[],u=s[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class wM{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=dd,this.updateRanges=[],this.version=0,this.uuid=Nn()}onUploadCallback(){}set needsUpdate(t){t===!0&&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 n=0,s=this.stride;n<s;n++)this.array[t+n]=e.array[i+n];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Nn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(e,this.stride);return i.setUsage(this.usage),i}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Nn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Fi=new R;class bl{constructor(t,e,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,i=this.data.count;e<i;e++)Fi.fromBufferAttribute(this,e),Fi.applyMatrix4(t),this.setXYZ(e,Fi.x,Fi.y,Fi.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Fi.fromBufferAttribute(this,e),Fi.applyNormalMatrix(t),this.setXYZ(e,Fi.x,Fi.y,Fi.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Fi.fromBufferAttribute(this,e),Fi.transformDirection(t),this.setXYZ(e,Fi.x,Fi.y,Fi.z);return this}getComponent(t,e){let i=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(i=Ln(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=be(i,this.array)),this.data.array[t*this.data.stride+this.offset+e]=i,this}setX(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ln(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ln(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ln(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ln(e,this.array)),e}setXY(t,e,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=be(e,this.array),i=be(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this}setXYZ(t,e,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=be(e,this.array),i=be(i,this.array),n=be(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this}setXYZW(t,e,i,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=be(e,this.array),i=be(i,this.array),n=be(n,this.array),s=be(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this.data.array[t+3]=s,this}clone(t){if(t===void 0){Sl("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return new ee(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new bl(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){Sl("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let EM=0;class Ds extends aa{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:EM++}),this.uuid=Nn(),this.name="",this.type="Material",this.blending=ta,this.side=ia,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Au,this.blendDst=Uo,this.blendEquation=Ma,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new st(0,0,0),this.blendAlpha=0,this.depthFunc=Pr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ef,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ga,this.stencilZFail=Ga,this.stencilZPass=Ga,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const i=t[e];if(i===void 0){Rt(`Material: parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){Rt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector2&&i&&i.isVector2||n&&n.isEuler&&i&&i.isEuler||n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(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),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(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),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(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,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==ta&&(i.blending=this.blending),this.side!==ia&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Au&&(i.blendSrc=this.blendSrc),this.blendDst!==Uo&&(i.blendDst=this.blendDst),this.blendEquation!==Ma&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Pr&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Ef&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ga&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ga&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ga&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(s){const a=[];for(const o in s){const c=s[o];delete c.metadata,a.push(c)}return a}if(e){const s=n(t.textures),a=n(t.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}fromJSON(t,e){if(t.uuid!==void 0&&(this.uuid=t.uuid),t.name!==void 0&&(this.name=t.name),t.color!==void 0&&this.color!==void 0&&this.color.setHex(t.color),t.roughness!==void 0&&(this.roughness=t.roughness),t.metalness!==void 0&&(this.metalness=t.metalness),t.sheen!==void 0&&(this.sheen=t.sheen),t.sheenColor!==void 0&&(this.sheenColor=new st().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(this.blendSrc=t.blendSrc),t.blendDst!==void 0&&(this.blendDst=t.blendDst),t.blendEquation!==void 0&&(this.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(this.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(this.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(this.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(this.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(this.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(this.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(this.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(this.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(this.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(this.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(this.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(this.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(this.rotation=t.rotation),t.linewidth!==void 0&&(this.linewidth=t.linewidth),t.dashSize!==void 0&&(this.dashSize=t.dashSize),t.gapSize!==void 0&&(this.gapSize=t.gapSize),t.scale!==void 0&&(this.scale=t.scale),t.polygonOffset!==void 0&&(this.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(this.dithering=t.dithering),t.alphaToCoverage!==void 0&&(this.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(this.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(this.allowOverride=t.allowOverride),t.visible!==void 0&&(this.visible=t.visible),t.toneMapped!==void 0&&(this.toneMapped=t.toneMapped),t.userData!==void 0&&(this.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),t.size!==void 0&&(this.size=t.size),t.sizeAttenuation!==void 0&&(this.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(this.map=e[t.map]||null),t.matcap!==void 0&&(this.matcap=e[t.matcap]||null),t.alphaMap!==void 0&&(this.alphaMap=e[t.alphaMap]||null),t.bumpMap!==void 0&&(this.bumpMap=e[t.bumpMap]||null),t.bumpScale!==void 0&&(this.bumpScale=t.bumpScale),t.normalMap!==void 0&&(this.normalMap=e[t.normalMap]||null),t.normalMapType!==void 0&&(this.normalMapType=t.normalMapType),t.normalScale!==void 0){let i=t.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new xt().fromArray(i)}return t.displacementMap!==void 0&&(this.displacementMap=e[t.displacementMap]||null),t.displacementScale!==void 0&&(this.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(this.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(this.roughnessMap=e[t.roughnessMap]||null),t.metalnessMap!==void 0&&(this.metalnessMap=e[t.metalnessMap]||null),t.emissiveMap!==void 0&&(this.emissiveMap=e[t.emissiveMap]||null),t.emissiveIntensity!==void 0&&(this.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(this.specularMap=e[t.specularMap]||null),t.specularIntensityMap!==void 0&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),t.specularColorMap!==void 0&&(this.specularColorMap=e[t.specularColorMap]||null),t.envMap!==void 0&&(this.envMap=e[t.envMap]||null),t.envMapRotation!==void 0&&this.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(this.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(this.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(this.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(this.lightMap=e[t.lightMap]||null),t.lightMapIntensity!==void 0&&(this.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(this.aoMap=e[t.aoMap]||null),t.aoMapIntensity!==void 0&&(this.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(this.gradientMap=e[t.gradientMap]||null),t.clearcoatMap!==void 0&&(this.clearcoatMap=e[t.clearcoatMap]||null),t.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),t.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),t.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new xt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(this.iridescenceMap=e[t.iridescenceMap]||null),t.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),t.transmissionMap!==void 0&&(this.transmissionMap=e[t.transmissionMap]||null),t.thicknessMap!==void 0&&(this.thicknessMap=e[t.thicknessMap]||null),t.anisotropyMap!==void 0&&(this.anisotropyMap=e[t.anisotropyMap]||null),t.sheenColorMap!==void 0&&(this.sheenColorMap=e[t.sheenColorMap]||null),t.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}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;const e=t.clippingPlanes;let i=null;if(e!==null){const n=e.length;i=new Array(n);for(let s=0;s!==n;++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){t===!0&&this.version++}}class rl extends Ds{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new st(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let Qa;const $r=new R,tr=new R,er=new R,ir=new xt,Kr=new xt,kg=new Zt,dc=new R,Zr=new R,fc=new R,zf=new xt,Eh=new xt,Bf=new xt;class Jr extends Be{constructor(t=new rl){if(super(),this.isSprite=!0,this.type="Sprite",Qa===void 0){Qa=new ce;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new wM(e,5);Qa.setIndex([0,1,2,0,2,3]),Qa.setAttribute("position",new bl(i,3,0,!1)),Qa.setAttribute("uv",new bl(i,2,3,!1))}this.geometry=Qa,this.material=t,this.center=new xt(.5,.5),this.count=1}raycast(t,e){t.camera===null&&Gt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),tr.setFromMatrixScale(this.matrixWorld),kg.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),er.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&tr.multiplyScalar(-er.z);const i=this.material.rotation;let n,s;i!==0&&(s=Math.cos(i),n=Math.sin(i));const a=this.center;pc(dc.set(-.5,-.5,0),er,a,tr,n,s),pc(Zr.set(.5,-.5,0),er,a,tr,n,s),pc(fc.set(.5,.5,0),er,a,tr,n,s),zf.set(0,0),Eh.set(1,0),Bf.set(1,1);let o=t.ray.intersectTriangle(dc,Zr,fc,!1,$r);if(o===null&&(pc(Zr.set(-.5,.5,0),er,a,tr,n,s),Eh.set(0,1),o=t.ray.intersectTriangle(dc,fc,Zr,!1,$r),o===null))return;const c=t.ray.origin.distanceTo($r);c<t.near||c>t.far||e.push({distance:c,point:$r.clone(),uv:yn.getInterpolation($r,dc,Zr,fc,zf,Eh,Bf,new xt),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function pc(r,t,e,i,n,s){ir.subVectors(r,e).addScalar(.5).multiply(i),n!==void 0?(Kr.x=s*ir.x-n*ir.y,Kr.y=n*ir.x+s*ir.y):Kr.copy(ir),r.copy(t),r.x+=Kr.x,r.y+=Kr.y,r.applyMatrix4(kg)}const fs=new R,Ah=new R,mc=new R,ks=new R,Th=new R,gc=new R,Rh=new R;class Yo{constructor(t=new R,e=new R(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,fs)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const 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){const e=fs.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(fs.copy(this.origin).addScaledVector(this.direction,e),fs.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){Ah.copy(t).add(e).multiplyScalar(.5),mc.copy(e).sub(t).normalize(),ks.copy(this.origin).sub(Ah);const s=t.distanceTo(e)*.5,a=-this.direction.dot(mc),o=ks.dot(this.direction),c=-ks.dot(mc),l=ks.lengthSq(),h=Math.abs(1-a*a);let u,d,f,p;if(h>0)if(u=a*c-o,d=a*o-c,p=s*h,u>=0)if(d>=-p)if(d<=p){const v=1/h;u*=v,d*=v,f=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d=-s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-p?(u=Math.max(0,-(-a*s+o)),d=u>0?-s:Math.min(Math.max(-s,-c),s),f=-u*u+d*(d+2*c)+l):d<=p?(u=0,d=Math.min(Math.max(-s,-c),s),f=d*(d+2*c)+l):(u=Math.max(0,-(a*s+o)),d=u>0?s:Math.min(Math.max(-s,-c),s),f=-u*u+d*(d+2*c)+l);else d=a>0?-s:s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,u),n&&n.copy(Ah).addScaledVector(mc,d),f}intersectSphere(t,e){fs.subVectors(t.center,this.origin);const i=fs.dot(this.direction),n=fs.dot(fs)-i*i,s=t.radius*t.radius;if(n>s)return null;const a=Math.sqrt(s-n),o=i-a,c=i+a;return c<0?null:o<0?this.at(c,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,s,a,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(i=(t.min.x-d.x)*l,n=(t.max.x-d.x)*l):(i=(t.max.x-d.x)*l,n=(t.min.x-d.x)*l),h>=0?(s=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(s=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),i>a||s>n||((s>i||isNaN(i))&&(i=s),(a<n||isNaN(n))&&(n=a),u>=0?(o=(t.min.z-d.z)*u,c=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,c=(t.min.z-d.z)*u),i>c||o>n)||((o>i||i!==i)&&(i=o),(c<n||n!==n)&&(n=c),n<0)?null:this.at(i>=0?i:n,e)}intersectsBox(t){return this.intersectBox(t,fs)!==null}intersectTriangle(t,e,i,n,s){Th.subVectors(e,t),gc.subVectors(i,t),Rh.crossVectors(Th,gc);let a=this.direction.dot(Rh),o;if(a>0){if(n)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ks.subVectors(this.origin,t);const c=o*this.direction.dot(gc.crossVectors(ks,gc));if(c<0)return null;const l=o*this.direction.dot(Th.cross(ks));if(l<0||c+l>a)return null;const h=-o*ks.dot(Rh);return h<0?null:this.at(h/a,s)}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 _n extends Ds{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new st(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new As,this.combine=e0,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}}const Hf=new Zt,ha=new Yo,vc=new Rs,Gf=new R,Mc=new R,xc=new R,yc=new R,Dh=new R,_c=new R,Vf=new R,Sc=new R;class Dt extends Be{constructor(t=new ce,e=new _n){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=n.length;s<a;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const o=this.morphTargetInfluences;if(s&&o){_c.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const h=o[c],u=s[c];h!==0&&(Dh.fromBufferAttribute(u,t),a?_c.addScaledVector(Dh,h):_c.addScaledVector(Dh.sub(e),h))}e.add(_c)}return e}raycast(t,e){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),vc.copy(i.boundingSphere),vc.applyMatrix4(s),ha.copy(t.ray).recast(t.near),!(vc.containsPoint(ha.origin)===!1&&(ha.intersectSphere(vc,Gf)===null||ha.origin.distanceToSquared(Gf)>(t.far-t.near)**2))&&(Hf.copy(s).invert(),ha.copy(t.ray).applyMatrix4(Hf),!(i.boundingBox!==null&&ha.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,e,ha)))}_computeIntersections(t,e,i){let n;const s=this.geometry,a=this.material,o=s.index,c=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=a[m.materialIndex],S=Math.max(m.start,f.start),y=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let M=S,b=y;M<b;M+=3){const w=o.getX(M),T=o.getX(M+1),x=o.getX(M+2);n=bc(this,g,t,i,l,h,u,w,T,x),n&&(n.faceIndex=Math.floor(M/3),n.face.materialIndex=m.materialIndex,e.push(n))}}else{const p=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const S=o.getX(m),y=o.getX(m+1),M=o.getX(m+2);n=bc(this,a,t,i,l,h,u,S,y,M),n&&(n.faceIndex=Math.floor(m/3),e.push(n))}}else if(c!==void 0)if(Array.isArray(a))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=a[m.materialIndex],S=Math.max(m.start,f.start),y=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let M=S,b=y;M<b;M+=3){const w=M,T=M+1,x=M+2;n=bc(this,g,t,i,l,h,u,w,T,x),n&&(n.faceIndex=Math.floor(M/3),n.face.materialIndex=m.materialIndex,e.push(n))}}else{const p=Math.max(0,f.start),v=Math.min(c.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const S=m,y=m+1,M=m+2;n=bc(this,a,t,i,l,h,u,S,y,M),n&&(n.faceIndex=Math.floor(m/3),e.push(n))}}}}function AM(r,t,e,i,n,s,a,o){let c;if(t.side===Ve?c=i.intersectTriangle(a,s,n,!0,o):c=i.intersectTriangle(n,s,a,t.side===ia,o),c===null)return null;Sc.copy(o),Sc.applyMatrix4(r.matrixWorld);const l=e.ray.origin.distanceTo(Sc);return l<e.near||l>e.far?null:{distance:l,point:Sc.clone(),object:r}}function bc(r,t,e,i,n,s,a,o,c,l){r.getVertexPosition(o,Mc),r.getVertexPosition(c,xc),r.getVertexPosition(l,yc);const h=AM(r,t,e,i,Mc,xc,yc,Vf);if(h){const u=new R;yn.getBarycoord(Vf,Mc,xc,yc,u),n&&(h.uv=yn.getInterpolatedAttribute(n,o,c,l,u,new xt)),s&&(h.uv1=yn.getInterpolatedAttribute(s,o,c,l,u,new xt)),a&&(h.normal=yn.getInterpolatedAttribute(a,o,c,l,u,new R),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new R,materialIndex:0};yn.getNormal(Mc,xc,yc,d.normal),h.face=d,h.barycoord=u}return h}const jr=new ne,Wf=new ne,Xf=new ne,TM=new ne,Yf=new Zt,wc=new R,Ih=new Rs,qf=new Zt,Ch=new Yo;class eA extends Dt{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=bf,this.bindMatrix=new Zt,this.bindMatrixInverse=new Zt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new Vi),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,wc),this.boundingBox.expandByPoint(wc)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Rs),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,wc),this.boundingSphere.expandByPoint(wc)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const i=this.material,n=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ih.copy(this.boundingSphere),Ih.applyMatrix4(n),t.ray.intersectsSphere(Ih)!==!1&&(qf.copy(n).invert(),Ch.copy(t.ray).applyMatrix4(qf),!(this.boundingBox!==null&&Ch.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,Ch)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new ne,e=this.geometry.attributes.skinWeight;for(let i=0,n=e.count;i<n;i++){t.fromBufferAttribute(e,i);const s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),e.setXYZW(i,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===bf?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===A2?this.bindMatrixInverse.copy(this.bindMatrix).invert():Rt("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const i=this.skeleton,n=this.geometry;Wf.fromBufferAttribute(n.attributes.skinIndex,t),Xf.fromBufferAttribute(n.attributes.skinWeight,t),e.isVector4?(jr.copy(e),e.set(0,0,0,0)):(jr.set(...e,1),e.set(0,0,0)),jr.applyMatrix4(this.bindMatrix);for(let s=0;s<4;s++){const a=Xf.getComponent(s);if(a!==0){const o=Wf.getComponent(s);Yf.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),e.addScaledVector(TM.copy(jr).applyMatrix4(Yf),a)}}return e.isVector4&&(e.w=jr.w),e.applyMatrix4(this.bindMatrixInverse)}}class RM extends Be{constructor(){super(),this.isBone=!0,this.type="Bone"}}class ra extends bi{constructor(t=null,e=1,i=1,n,s,a,o,c,l=Re,h=Re,u,d){super(null,a,o,c,l,h,n,s,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const $f=new Zt,DM=new Zt;class zg{constructor(t=[],e=[]){this.uuid=Nn(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){Rt("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,n=this.bones.length;i<n;i++)this.boneInverses.push(new Zt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const i=new Zt;this.bones[t]&&i.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const i=this.bones[t];i&&i.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const i=this.bones[t];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const t=this.bones,e=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let s=0,a=t.length;s<a;s++){const o=t[s]?t[s].matrixWorld:DM;$f.multiplyMatrices(o,e[s]),$f.toArray(i,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new zg(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const i=new ra(e,t,t,Ei,Oi);return i.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=i,this}getBoneByName(t){for(let e=0,i=this.bones.length;e<i;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let i=0,n=t.bones.length;i<n;i++){const s=t.bones[i];let a=e[s];a===void 0&&(Rt("Skeleton: No bone found with UUID:",s),a=new RM),this.bones.push(a),this.boneInverses.push(new Zt().fromArray(t.boneInverses[i]))}return this.init(),this}toJSON(){const t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,i=this.boneInverses;for(let n=0,s=e.length;n<s;n++){const a=e[n];t.bones.push(a.uuid);const o=i[n];t.boneInverses.push(o.toArray())}return t}}class Kf extends ee{constructor(t,e,i,n=1){super(t,e,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const nr=new Zt,Zf=new Zt,Ec=[],Jf=new Vi,IM=new Zt,Qr=new Dt,to=new Rs;class iA extends Dt{constructor(t,e,i){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Kf(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,IM)}computeBoundingBox(){const t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new Vi),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,nr),Jf.copy(t.boundingBox).applyMatrix4(nr),this.boundingBox.union(Jf)}computeBoundingSphere(){const t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new Rs),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,nr),to.copy(t.boundingSphere).applyMatrix4(nr),this.boundingSphere.union(to)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){return this.instanceColor===null?e.setRGB(1,1,1):e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){return e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){const i=e.morphTargetInfluences,n=this.morphTexture.source.data.data,s=i.length+1,a=t*s+1;for(let o=0;o<i.length;o++)i[o]=n[a+o]}raycast(t,e){const i=this.matrixWorld,n=this.count;if(Qr.geometry=this.geometry,Qr.material=this.material,Qr.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),to.copy(this.boundingSphere),to.applyMatrix4(i),t.ray.intersectsSphere(to)!==!1))for(let s=0;s<n;s++){this.getMatrixAt(s,nr),Zf.multiplyMatrices(i,nr),Qr.matrixWorld=Zf,Qr.raycast(t,Ec);for(let a=0,o=Ec.length;a<o;a++){const c=Ec[a];c.instanceId=s,c.object=this,e.push(c)}Ec.length=0}}setColorAt(t,e){return this.instanceColor===null&&(this.instanceColor=new Kf(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),e.toArray(this.instanceColor.array,t*3),this}setMatrixAt(t,e){return e.toArray(this.instanceMatrix.array,t*16),this}setMorphAt(t,e){const i=e.morphTargetInfluences,n=i.length+1;this.morphTexture===null&&(this.morphTexture=new ra(new Float32Array(n*this.count),n,this.count,Hl,Oi));const s=this.morphTexture.source.data.data;let a=0;for(let l=0;l<i.length;l++)a+=i[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=n*t;return s[c]=o,s.set(i,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Ph=new R,CM=new R,PM=new Yt;class ma{constructor(t=new R(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=Ph.subVectors(i,e).cross(CM.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,i=!0){const n=t.delta(Ph),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const a=-(t.start.dot(this.normal)+this.constant)/s;return i===!0&&(a<0||a>1)?null:e.copy(t.start).addScaledVector(n,a)}intersectsLine(t){const 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){const i=e||PM.getNormalMatrix(t),n=this.coplanarPoint(Ph).applyMatrix4(t),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),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)}}const ua=new Rs,LM=new xt(.5,.5),Ac=new R;class g0{constructor(t=new ma,e=new ma,i=new ma,n=new ma,s=new ma,a=new ma){this.planes=[t,e,i,n,s,a]}set(t,e,i,n,s,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(i),o[3].copy(n),o[4].copy(s),o[5].copy(a),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=ns,i=!1){const n=this.planes,s=t.elements,a=s[0],o=s[1],c=s[2],l=s[3],h=s[4],u=s[5],d=s[6],f=s[7],p=s[8],v=s[9],m=s[10],g=s[11],S=s[12],y=s[13],M=s[14],b=s[15];if(n[0].setComponents(l-a,f-h,g-p,b-S).normalize(),n[1].setComponents(l+a,f+h,g+p,b+S).normalize(),n[2].setComponents(l+o,f+u,g+v,b+y).normalize(),n[3].setComponents(l-o,f-u,g-v,b-y).normalize(),i)n[4].setComponents(c,d,m,M).normalize(),n[5].setComponents(l-c,f-d,g-m,b-M).normalize();else if(n[4].setComponents(l-c,f-d,g-m,b-M).normalize(),e===ns)n[5].setComponents(l+c,f+d,g+m,b+M).normalize();else if(e===Ho)n[5].setComponents(c,d,m,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),ua.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),ua.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(ua)}intersectsSprite(t){ua.center.set(0,0,0);const e=LM.distanceTo(t.center);return ua.radius=.7071067811865476+e,ua.applyMatrix4(t.matrixWorld),this.intersectsSphere(ua)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(i)<n)return!1;return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const n=e[i];if(Ac.x=n.normal.x>0?t.max.x:t.min.x,Ac.y=n.normal.y>0?t.max.y:t.min.y,Ac.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(Ac)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class OM extends Ds{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new st(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const wl=new R,El=new R,jf=new Zt,eo=new Yo,Tc=new Rs,Lh=new R,Qf=new R;class Bg extends Be{constructor(t=new ce,e=new OM){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,i=[0];for(let n=1,s=e.count;n<s;n++)wl.fromBufferAttribute(e,n-1),El.fromBufferAttribute(e,n),i[n]=i[n-1],i[n]+=wl.distanceTo(El);t.setAttribute("lineDistance",new de(i,1))}else Rt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,s=t.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Tc.copy(i.boundingSphere),Tc.applyMatrix4(n),Tc.radius+=s,t.ray.intersectsSphere(Tc)===!1)return;jf.copy(n).invert(),eo.copy(t.ray).applyMatrix4(jf);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=i.index,d=i.attributes.position;if(h!==null){const f=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let v=f,m=p-1;v<m;v+=l){const g=h.getX(v),S=h.getX(v+1),y=Rc(this,t,eo,c,g,S,v);y&&e.push(y)}if(this.isLineLoop){const v=h.getX(p-1),m=h.getX(f),g=Rc(this,t,eo,c,v,m,p-1);g&&e.push(g)}}else{const f=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let v=f,m=p-1;v<m;v+=l){const g=Rc(this,t,eo,c,v,v+1,v);g&&e.push(g)}if(this.isLineLoop){const v=Rc(this,t,eo,c,p-1,f,p-1);v&&e.push(v)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=n.length;s<a;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function Rc(r,t,e,i,n,s,a){const o=r.geometry.attributes.position;if(wl.fromBufferAttribute(o,n),El.fromBufferAttribute(o,s),e.distanceSqToSegment(wl,El,Lh,Qf)>i)return;Lh.applyMatrix4(r.matrixWorld);const l=t.ray.origin.distanceTo(Lh);if(!(l<t.near||l>t.far))return{distance:l,point:Qf.clone().applyMatrix4(r.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:r}}const tp=new R,ep=new R;class nA extends Bg{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,i=[];for(let n=0,s=e.count;n<s;n+=2)tp.fromBufferAttribute(e,n),ep.fromBufferAttribute(e,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+tp.distanceTo(ep);t.setAttribute("lineDistance",new de(i,1))}else Rt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class sA extends Bg{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Hg extends Ds{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new st(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const ip=new Zt,fd=new Yo,Dc=new Rs,Ic=new R;class xs extends Be{constructor(t=new ce,e=new Hg){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,s=t.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Dc.copy(i.boundingSphere),Dc.applyMatrix4(n),Dc.radius+=s,t.ray.intersectsSphere(Dc)===!1)return;ip.copy(n).invert(),fd.copy(t.ray).applyMatrix4(ip);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=i.index,u=i.attributes.position;if(l!==null){const d=Math.max(0,a.start),f=Math.min(l.count,a.start+a.count);for(let p=d,v=f;p<v;p++){const m=l.getX(p);Ic.fromBufferAttribute(u,m),np(Ic,m,c,n,t,e,this)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let p=d,v=f;p<v;p++)Ic.fromBufferAttribute(u,p),np(Ic,p,c,n,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=n.length;s<a;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function np(r,t,e,i,n,s,a){const o=fd.distanceSqToPoint(r);if(o<e){const c=new R;fd.closestPointToPoint(r,c),c.applyMatrix4(i);const l=n.ray.origin.distanceTo(c);if(l<n.near||l>n.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}class Gg extends bi{constructor(t=[],e=Oa,i,n,s,a,o,c,l,h){super(t,e,i,n,s,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Is extends bi{constructor(t,e,i,n,s,a,o,c,l){super(t,e,i,n,s,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class na extends bi{constructor(t,e,i=Sn,n,s,a,o=Re,c=Re,l,h=Es,u=1){if(h!==Es&&h!==Ea)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,n,s,a,o,c,h,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new d0(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class NM extends na{constructor(t,e=Sn,i=Oa,n,s,a=Re,o=Re,c,l=Es){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,i,n,s,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class Vg extends bi{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Wi extends ce{constructor(t=1,e=1,i=1,n=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:s,depthSegments:a};const o=this;n=Math.floor(n),s=Math.floor(s),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,i,e,t,a,s,0),p("z","y","x",1,-1,i,e,-t,a,s,1),p("x","z","y",1,1,t,i,e,n,a,2),p("x","z","y",1,-1,t,i,-e,n,a,3),p("x","y","z",1,-1,t,e,i,n,s,4),p("x","y","z",-1,-1,t,e,-i,n,s,5),this.setIndex(c),this.setAttribute("position",new de(l,3)),this.setAttribute("normal",new de(h,3)),this.setAttribute("uv",new de(u,2));function p(v,m,g,S,y,M,b,w,T,x,A){const C=M/T,I=b/x,P=M/2,V=b/2,X=w/2,L=T+1,B=x+1;let k=0,$=0;const tt=new R;for(let J=0;J<B;J++){const it=J*I-V;for(let rt=0;rt<L;rt++){const Vt=rt*C-P;tt[v]=Vt*S,tt[m]=it*y,tt[g]=X,l.push(tt.x,tt.y,tt.z),tt[v]=0,tt[m]=0,tt[g]=w>0?1:-1,h.push(tt.x,tt.y,tt.z),u.push(rt/T),u.push(1-J/x),k+=1}}for(let J=0;J<x;J++)for(let it=0;it<T;it++){const rt=d+it+L*J,Vt=d+it+L*(J+1),Jt=d+(it+1)+L*(J+1),qt=d+(it+1)+L*J;c.push(rt,Vt,qt),c.push(Vt,Jt,qt),$+=6}o.addGroup(f,$,A),f+=$,d+=k}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Wi(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class v0 extends ce{constructor(t=1,e=32,i=0,n=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},e=Math.max(3,e);const s=[],a=[],o=[],c=[],l=new R,h=new xt;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=i+u/e*n;l.x=t*Math.cos(f),l.y=t*Math.sin(f),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/t+1)/2,h.y=(a[d+1]/t+1)/2,c.push(h.x,h.y)}for(let u=1;u<=e;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new de(a,3)),this.setAttribute("normal",new de(o,3)),this.setAttribute("uv",new de(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new v0(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class cs extends ce{constructor(t=1,e=1,i=1,n=32,s=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:c};const l=this;n=Math.floor(n),s=Math.floor(s);const h=[],u=[],d=[],f=[];let p=0;const v=[],m=i/2;let g=0;S(),a===!1&&(t>0&&y(!0),e>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new de(u,3)),this.setAttribute("normal",new de(d,3)),this.setAttribute("uv",new de(f,2));function S(){const M=new R,b=new R;let w=0;const T=(e-t)/i;for(let x=0;x<=s;x++){const A=[],C=x/s,I=C*(e-t)+t;for(let P=0;P<=n;P++){const V=P/n,X=V*c+o,L=Math.sin(X),B=Math.cos(X);b.x=I*L,b.y=-C*i+m,b.z=I*B,u.push(b.x,b.y,b.z),M.set(L,T,B).normalize(),d.push(M.x,M.y,M.z),f.push(V,1-C),A.push(p++)}v.push(A)}for(let x=0;x<n;x++)for(let A=0;A<s;A++){const C=v[A][x],I=v[A+1][x],P=v[A+1][x+1],V=v[A][x+1];(t>0||A!==0)&&(h.push(C,I,V),w+=3),(e>0||A!==s-1)&&(h.push(I,P,V),w+=3)}l.addGroup(g,w,0),g+=w}function y(M){const b=p,w=new xt,T=new R;let x=0;const A=M===!0?t:e,C=M===!0?1:-1;for(let P=1;P<=n;P++)u.push(0,m*C,0),d.push(0,C,0),f.push(.5,.5),p++;const I=p;for(let P=0;P<=n;P++){const X=P/n*c+o,L=Math.cos(X),B=Math.sin(X);T.x=A*B,T.y=m*C,T.z=A*L,u.push(T.x,T.y,T.z),d.push(0,C,0),w.x=L*.5+.5,w.y=B*.5*C+.5,f.push(w.x,w.y),p++}for(let P=0;P<n;P++){const V=b+P,X=I+P;M===!0?h.push(X,X+1,V):h.push(X+1,X,V),x+=3}l.addGroup(g,x,M===!0?1:2),g+=x}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new cs(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ur extends cs{constructor(t=1,e=1,i=32,n=1,s=!1,a=0,o=Math.PI*2){super(0,t,e,i,n,s,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(t){return new Ur(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Gl extends ce{constructor(t=[new xt(0,-.5),new xt(.5,0),new xt(0,.5)],e=12,i=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:n},e=Math.floor(e),n=te(n,0,Math.PI*2);const s=[],a=[],o=[],c=[],l=[],h=1/e,u=new R,d=new xt,f=new R,p=new R,v=new R;let m=0,g=0;for(let S=0;S<=t.length-1;S++)switch(S){case 0:m=t[S+1].x-t[S].x,g=t[S+1].y-t[S].y,f.x=g*1,f.y=-m,f.z=g*0,v.copy(f),f.normalize(),c.push(f.x,f.y,f.z);break;case t.length-1:c.push(v.x,v.y,v.z);break;default:m=t[S+1].x-t[S].x,g=t[S+1].y-t[S].y,f.x=g*1,f.y=-m,f.z=g*0,p.copy(f),f.x+=v.x,f.y+=v.y,f.z+=v.z,f.normalize(),c.push(f.x,f.y,f.z),v.copy(p)}for(let S=0;S<=e;S++){const y=i+S*h*n,M=Math.sin(y),b=Math.cos(y);for(let w=0;w<=t.length-1;w++){u.x=t[w].x*M,u.y=t[w].y,u.z=t[w].x*b,a.push(u.x,u.y,u.z),d.x=S/e,d.y=w/(t.length-1),o.push(d.x,d.y);const T=c[3*w+0]*M,x=c[3*w+1],A=c[3*w+0]*b;l.push(T,x,A)}}for(let S=0;S<e;S++)for(let y=0;y<t.length-1;y++){const M=y+S*t.length,b=M,w=M+t.length,T=M+t.length+1,x=M+1;s.push(b,w,x),s.push(T,x,w)}this.setIndex(s),this.setAttribute("position",new de(a,3)),this.setAttribute("uv",new de(o,2)),this.setAttribute("normal",new de(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Gl(t.points,t.segments,t.phiStart,t.phiLength)}}class Xi extends ce{constructor(t=1,e=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};const s=t/2,a=e/2,o=Math.floor(i),c=Math.floor(n),l=o+1,h=c+1,u=t/o,d=e/c,f=[],p=[],v=[],m=[];for(let g=0;g<h;g++){const S=g*d-a;for(let y=0;y<l;y++){const M=y*u-s;p.push(M,-S,0),v.push(0,0,1),m.push(y/o),m.push(1-g/c)}}for(let g=0;g<c;g++)for(let S=0;S<o;S++){const y=S+l*g,M=S+l*(g+1),b=S+1+l*(g+1),w=S+1+l*g;f.push(y,M,w),f.push(M,b,w)}this.setIndex(f),this.setAttribute("position",new de(p,3)),this.setAttribute("normal",new de(v,3)),this.setAttribute("uv",new de(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Xi(t.width,t.height,t.widthSegments,t.heightSegments)}}class oi extends ce{constructor(t=1,e=32,i=16,n=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:s,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const c=Math.min(a+o,Math.PI);let l=0;const h=[],u=new R,d=new R,f=[],p=[],v=[],m=[];for(let g=0;g<=i;g++){const S=[],y=g/i,M=a+y*o,b=t*Math.cos(M),w=Math.sqrt(t*t-b*b);let T=0;g===0&&a===0?T=.5/e:g===i&&c===Math.PI&&(T=-.5/e);for(let x=0;x<=e;x++){const A=x/e,C=n+A*s;u.x=-w*Math.cos(C),u.y=b,u.z=w*Math.sin(C),p.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),m.push(A+T,1-y),S.push(l++)}h.push(S)}for(let g=0;g<i;g++)for(let S=0;S<e;S++){const y=h[g][S+1],M=h[g][S],b=h[g+1][S],w=h[g+1][S+1];(g!==0||a>0)&&f.push(y,M,w),(g!==i-1||c<Math.PI)&&f.push(M,b,w)}this.setIndex(f),this.setAttribute("position",new de(p,3)),this.setAttribute("normal",new de(v,3)),this.setAttribute("uv",new de(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new oi(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class M0 extends ce{constructor(t=1,e=.4,i=12,n=48,s=Math.PI*2,a=0,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:s,thetaStart:a,thetaLength:o},i=Math.floor(i),n=Math.floor(n);const c=[],l=[],h=[],u=[],d=new R,f=new R,p=new R;for(let v=0;v<=i;v++){const m=a+v/i*o;for(let g=0;g<=n;g++){const S=g/n*s;f.x=(t+e*Math.cos(m))*Math.cos(S),f.y=(t+e*Math.cos(m))*Math.sin(S),f.z=e*Math.sin(m),l.push(f.x,f.y,f.z),d.x=t*Math.cos(S),d.y=t*Math.sin(S),p.subVectors(f,d).normalize(),h.push(p.x,p.y,p.z),u.push(g/n),u.push(v/i)}}for(let v=1;v<=i;v++)for(let m=1;m<=n;m++){const g=(n+1)*v+m-1,S=(n+1)*(v-1)+m-1,y=(n+1)*(v-1)+m,M=(n+1)*v+m;c.push(g,S,M),c.push(S,y,M)}this.setIndex(c),this.setAttribute("position",new de(l,3)),this.setAttribute("normal",new de(h,3)),this.setAttribute("uv",new de(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new M0(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}function Nr(r){const t={};for(const e in r){t[e]={};for(const i in r[e]){const n=r[e][i];if(sp(n))n.isRenderTargetTexture?(Rt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][i]=null):t[e][i]=n.clone();else if(Array.isArray(n))if(sp(n[0])){const s=[];for(let a=0,o=n.length;a<o;a++)s[a]=n[a].clone();t[e][i]=s}else t[e][i]=n.slice();else t[e][i]=n}}return t}function Ui(r){const t={};for(let e=0;e<r.length;e++){const i=Nr(r[e]);for(const n in i)t[n]=i[n]}return t}function sp(r){return r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)}function FM(r){const t=[];for(let e=0;e<r.length;e++)t.push(r[e].clone());return t}function Wg(r){const t=r.getRenderTarget();return t===null?r.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:re.workingColorSpace}const UM={clone:Nr,merge:Ui};var kM=`void main() {
1157
+ */const t0="185",a2=0,yf=1,r2=2,So=1,o2=2,mo=3,ia=0,Ve=1,ji=2,as=0,ta=1,Ni=2,_f=3,Sf=4,zl=5,Ma=100,c2=101,l2=102,h2=103,u2=104,d2=200,Fo=201,f2=202,p2=203,Au=204,Uo=205,m2=206,g2=207,v2=208,M2=209,x2=210,y2=211,_2=212,S2=213,b2=214,Tu=0,Ru=1,Du=2,Pr=3,Iu=4,Cu=5,Pu=6,Lu=7,e0=0,w2=1,E2=2,rs=0,Mg=1,xg=2,yg=3,_g=4,Sg=5,bg=6,wg=7,bf="attached",A2="detached",Eg=300,Oa=301,Lr=302,sh=303,ah=304,Bl=306,ko=1e3,wi=1001,Ou=1002,Re=1003,T2=1004,sc=1005,oe=1006,rh=1007,wa=1008,un=1009,Ag=1010,Tg=1011,zo=1012,i0=1013,Sn=1014,Oi=1015,qe=1016,n0=1017,s0=1018,Bo=1020,Rg=35902,Dg=35899,Ig=1021,Cg=1022,Ei=1023,Es=1026,Ea=1027,Hl=1028,a0=1029,Na=1030,r0=1031,o0=1033,il=33776,nl=33777,sl=33778,al=33779,Nu=35840,Fu=35841,Uu=35842,ku=35843,zu=36196,Bu=37492,Hu=37496,Gu=37488,Vu=37489,pl=37490,Wu=37491,Xu=37808,Yu=37809,qu=37810,$u=37811,Ku=37812,Zu=37813,Ju=37814,ju=37815,Qu=37816,td=37817,ed=37818,id=37819,nd=37820,sd=37821,ad=36492,rd=36494,od=36495,cd=36283,ld=36284,ml=36285,hd=36286,Pg=2200,R2=2201,D2=2202,gl=2300,ud=2301,oh=2302,wf=2303,fr=2400,pr=2401,vl=2402,c0=2500,I2=2501,JE=0,jE=1,QE=2,C2=3200,Ml=0,P2=1,Ks="",Gi="srgb",xl="srgb-linear",yl="linear",Se="srgb",Ga=7680,Ef=519,L2=512,O2=513,N2=514,l0=515,F2=516,U2=517,h0=518,k2=519,dd=35044,_l="300 es",ns=2e3,Ho=2001;function z2(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function B2(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Go(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function H2(){const r=Go("canvas");return r.style.display="block",r}const Af={};function Sl(...r){const t="THREE."+r.shift();console.log(t,...r)}function Lg(r){const t=r[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=r[1];e&&e.isStackTrace?r[0]+=" "+e.getLocation():r[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return r}function Rt(...r){r=Lg(r);const t="THREE."+r.shift();{const e=r[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...r)}}function Gt(...r){r=Lg(r);const t="THREE."+r.shift();{const e=r[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...r)}}function Sr(...r){const t=r.join(" ");t in Af||(Af[t]=!0,Rt(...r))}function G2(r,t,e){return new Promise(function(i,n){function s(){switch(r.clientWaitSync(t,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:n();break;case r.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:i()}}setTimeout(s,e)})}const V2={[Tu]:Ru,[Du]:Pu,[Iu]:Lu,[Pr]:Cu,[Ru]:Tu,[Pu]:Du,[Lu]:Iu,[Cu]:Pr};class aa{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return i===void 0?!1:i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){const i=this._listeners;if(i===void 0)return;const n=i[t];if(n!==void 0){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const i=e[t.type];if(i!==void 0){t.target=this;const n=i.slice(0);for(let s=0,a=n.length;s<a;s++)n[s].call(this,t);t.target=null}}}const Ri=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Tf=1234567;const bo=Math.PI/180,Or=180/Math.PI;function Nn(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Ri[r&255]+Ri[r>>8&255]+Ri[r>>16&255]+Ri[r>>24&255]+"-"+Ri[t&255]+Ri[t>>8&255]+"-"+Ri[t>>16&15|64]+Ri[t>>24&255]+"-"+Ri[e&63|128]+Ri[e>>8&255]+"-"+Ri[e>>16&255]+Ri[e>>24&255]+Ri[i&255]+Ri[i>>8&255]+Ri[i>>16&255]+Ri[i>>24&255]).toLowerCase()}function ee(r,t,e){return Math.max(t,Math.min(e,r))}function u0(r,t){return(r%t+t)%t}function W2(r,t,e,i,n){return i+(r-t)*(n-i)/(e-t)}function X2(r,t,e){return r!==t?(e-r)/(t-r):0}function wo(r,t,e){return(1-e)*r+e*t}function Y2(r,t,e,i){return wo(r,t,1-Math.exp(-e*i))}function q2(r,t=1){return t-Math.abs(u0(r,t*2)-t)}function $2(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function K2(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function Z2(r,t){return r+Math.floor(Math.random()*(t-r+1))}function J2(r,t){return r+Math.random()*(t-r)}function j2(r){return r*(.5-Math.random())}function Q2(r){r!==void 0&&(Tf=r);let t=Tf+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function tM(r){return r*bo}function eM(r){return r*Or}function iM(r){return(r&r-1)===0&&r!==0}function nM(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function sM(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function aM(r,t,e,i,n){const s=Math.cos,a=Math.sin,o=s(e/2),c=a(e/2),l=s((t+i)/2),h=a((t+i)/2),u=s((t-i)/2),d=a((t-i)/2),f=s((i-t)/2),p=a((i-t)/2);switch(n){case"XYX":r.set(o*h,c*u,c*d,o*l);break;case"YZY":r.set(c*d,o*h,c*u,o*l);break;case"ZXZ":r.set(c*u,c*d,o*h,o*l);break;case"XZX":r.set(o*h,c*p,c*f,o*l);break;case"YXY":r.set(c*f,o*h,c*p,o*l);break;case"ZYZ":r.set(c*p,c*f,o*h,o*l);break;default:Rt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function Ln(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function be(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const tA={DEG2RAD:bo,RAD2DEG:Or,generateUUID:Nn,clamp:ee,euclideanModulo:u0,mapLinear:W2,inverseLerp:X2,lerp:wo,damp:Y2,pingpong:q2,smoothstep:$2,smootherstep:K2,randInt:Z2,randFloat:J2,randFloatSpread:j2,seededRandom:Q2,degToRad:tM,radToDeg:eM,isPowerOfTwo:iM,ceilPowerOfTwo:nM,floorPowerOfTwo:sM,setQuaternionFromProperEuler:aM,normalize:be,denormalize:Ln};class xt{static{xt.prototype.isVector2=!0}constructor(t=0,e=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 new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: 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){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[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=ee(this.x,t.x,e.x),this.y=ee(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=ee(this.x,t,e),this.y=ee(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ee(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){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(ee(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const 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){const i=Math.cos(e),n=Math.sin(e),s=this.x-t.x,a=this.y-t.y;return this.x=s*i-a*n+t.x,this.y=s*n+a*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Qi{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,s,a,o){let c=i[n+0],l=i[n+1],h=i[n+2],u=i[n+3],d=s[a+0],f=s[a+1],p=s[a+2],v=s[a+3];if(u!==v||c!==d||l!==f||h!==p){let m=c*d+l*f+h*p+u*v;m<0&&(d=-d,f=-f,p=-p,v=-v,m=-m);let g=1-o;if(m<.9995){const S=Math.acos(m),y=Math.sin(S);g=Math.sin(g*S)/y,o=Math.sin(o*S)/y,c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o}else{c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o;const S=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=S,l*=S,h*=S,u*=S}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,i,n,s,a){const o=i[n],c=i[n+1],l=i[n+2],h=i[n+3],u=s[a],d=s[a+1],f=s[a+2],p=s[a+3];return t[e]=o*p+h*u+c*f-l*d,t[e+1]=c*p+h*d+l*u-o*f,t[e+2]=l*p+h*f+o*d-c*u,t[e+3]=h*p-o*u-c*d-l*f,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,n){return this._x=t,this._y=e,this._z=i,this._w=n,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){const i=t._x,n=t._y,s=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(i/2),h=o(n/2),u=o(s/2),d=c(i/2),f=c(n/2),p=c(s/2);switch(a){case"XYZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"YXZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"ZXY":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"ZYX":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"YZX":this._x=d*h*u+l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u-d*f*p;break;case"XZY":this._x=d*h*u-l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u+d*f*p;break;default:Rt("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],s=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],u=e[10],d=i+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(s-l)*f,this._z=(a-n)*f}else if(i>o&&i>u){const f=2*Math.sqrt(1+i-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(n+a)/f,this._z=(s+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-i-u);this._w=(s-l)/f,this._x=(n+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-i-o);this._w=(a-n)/f,this._x=(s+l)/f,this._y=(c+h)/f,this._z=.25*f}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._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(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(ee(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const n=Math.min(1,e/i);return this.slerp(t,n),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 t===0?(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){const i=t._x,n=t._y,s=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=i*h+a*o+n*l-s*c,this._y=n*h+a*c+s*o-i*l,this._z=s*h+a*l+i*c-n*o,this._w=a*h-i*o-n*c-s*l,this._onChangeCallback(),this}slerp(t,e){let i=t._x,n=t._y,s=t._z,a=t._w,o=this.dot(t);o<0&&(i=-i,n=-n,s=-s,a=-a,o=-o);let c=1-e;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,e=Math.sin(e*l)/h,this._x=this._x*c+i*e,this._y=this._y*c+n*e,this._z=this._z*c+s*e,this._w=this._w*c+a*e,this._onChangeCallback()}else this._x=this._x*c+i*e,this._y=this._y*c+n*e,this._z=this._z*c+s*e,this._w=this._w*c+a*e,this.normalize();return this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(t),n*Math.cos(t),s*Math.sin(e),s*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 R{static{R.prototype.isVector3=!0}constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(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 new Error("THREE.Vector3: 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 new Error("THREE.Vector3: 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(Rf.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Rf.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*n,this.y=s[1]*e+s[4]*i+s[7]*n,this.z=s[2]*e+s[5]*i+s[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=t.elements,a=1/(s[3]*e+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*n+s[12])*a,this.y=(s[1]*e+s[5]*i+s[9]*n+s[13])*a,this.z=(s[2]*e+s[6]*i+s[10]*n+s[14])*a,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,s=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*n-o*i),h=2*(o*e-s*n),u=2*(s*i-a*e);return this.x=e+c*l+a*u-o*h,this.y=i+c*h+o*l-s*u,this.z=n+c*u+s*h-a*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n,this.y=s[1]*e+s[5]*i+s[9]*n,this.z=s[2]*e+s[6]*i+s[10]*n,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=ee(this.x,t.x,e.x),this.y=ee(this.y,t.y,e.y),this.z=ee(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=ee(this.x,t,e),this.y=ee(this.y,t,e),this.z=ee(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ee(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){const i=t.x,n=t.y,s=t.z,a=e.x,o=e.y,c=e.z;return this.x=n*c-s*o,this.y=s*a-i*c,this.z=i*o-n*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return ch.copy(this).projectOnVector(t),this.sub(ch)}reflect(t){return this.sub(ch.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(ee(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}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){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*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){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}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(){const t=Math.random()*Math.PI*2,e=Math.random()*2-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}}const ch=new R,Rf=new Qi;class Yt{static{Yt.prototype.isMatrix3=!0}constructor(t,e,i,n,s,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,a,o,c,l)}set(t,e,i,n,s,a,o,c,l){const h=this.elements;return h[0]=t,h[1]=n,h[2]=o,h[3]=e,h[4]=s,h[5]=c,h[6]=i,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const 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){const 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){const i=t.elements,n=e.elements,s=this.elements,a=i[0],o=i[3],c=i[6],l=i[1],h=i[4],u=i[7],d=i[2],f=i[5],p=i[8],v=n[0],m=n[3],g=n[6],S=n[1],y=n[4],M=n[7],b=n[2],w=n[5],T=n[8];return s[0]=a*v+o*S+c*b,s[3]=a*m+o*y+c*w,s[6]=a*g+o*M+c*T,s[1]=l*v+h*S+u*b,s[4]=l*m+h*y+u*w,s[7]=l*g+h*M+u*T,s[2]=d*v+f*S+p*b,s[5]=d*m+f*y+p*w,s[8]=d*g+f*M+p*T,this}multiplyScalar(t){const 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(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-i*s*h+i*o*c+n*s*l-n*a*c}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=h*a-o*l,d=o*c-h*s,f=l*s-a*c,p=e*u+i*d+n*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/p;return t[0]=u*v,t[1]=(n*l-h*i)*v,t[2]=(o*i-n*a)*v,t[3]=d*v,t[4]=(h*e-n*c)*v,t[5]=(n*s-o*e)*v,t[6]=f*v,t[7]=(i*c-l*e)*v,t[8]=(a*e-i*s)*v,this}transpose(){let t;const 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){const 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,n,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*a+l*o)+a+t,-n*l,n*c,-n*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return Sr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(lh.makeScale(t,e)),this}rotate(t){return Sr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(lh.makeRotation(-t)),this}translate(t,e){return Sr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(lh.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){const 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){const e=this.elements,i=t.elements;for(let n=0;n<9;n++)if(e[n]!==i[n])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){const 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)}}const lh=new Yt,Df=new Yt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),If=new Yt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function rM(){const r={enabled:!0,workingColorSpace:xl,spaces:{},convert:function(n,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Se&&(n.r=ws(n.r),n.g=ws(n.g),n.b=ws(n.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(n.applyMatrix3(this.spaces[s].toXYZ),n.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Se&&(n.r=br(n.r),n.g=br(n.g),n.b=br(n.b))),n},workingToColorSpace:function(n,s){return this.convert(n,this.workingColorSpace,s)},colorSpaceToWorking:function(n,s){return this.convert(n,s,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===Ks?yl:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,s=this.workingColorSpace){return n.fromArray(this.spaces[s].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,s,a){return n.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,s){return Sr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(n,s)},toWorkingColorSpace:function(n,s){return Sr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(n,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],i=[.3127,.329];return r.define({[xl]:{primaries:t,whitePoint:i,transfer:yl,toXYZ:Df,fromXYZ:If,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Gi},outputColorSpaceConfig:{drawingBufferColorSpace:Gi}},[Gi]:{primaries:t,whitePoint:i,transfer:Se,toXYZ:Df,fromXYZ:If,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Gi}}}),r}const re=rM();function ws(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function br(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Va;class oM{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{Va===void 0&&(Va=Go("canvas")),Va.width=t.width,Va.height=t.height;const n=Va.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),i=Va}return i.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Go("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),s=n.data;for(let a=0;a<s.length;a++)s[a]=ws(s[a]/255)*255;return i.putImageData(n,0,0),e}else if(t.data){const e=t.data.slice(0);for(let i=0;i<e.length;i++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[i]=Math.floor(ws(e[i]/255)*255):e[i]=ws(e[i]);return{data:e,width:t.width,height:t.height}}else return Rt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let cM=0;class d0{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:cM++}),this.uuid=Nn(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let s;if(Array.isArray(n)){s=[];for(let a=0,o=n.length;a<o;a++)n[a].isDataTexture?s.push(hh(n[a].image)):s.push(hh(n[a]))}else s=hh(n);i.url=s}return e||(t.images[this.uuid]=i),i}}function hh(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?oM.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(Rt("Texture: Unable to serialize Texture."),{})}let lM=0;const uh=new R;class bi extends aa{constructor(t=bi.DEFAULT_IMAGE,e=bi.DEFAULT_MAPPING,i=wi,n=wi,s=oe,a=wa,o=Ei,c=un,l=bi.DEFAULT_ANISOTROPY,h=Ks){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:lM++}),this.uuid=Nn(),this.name="",this.source=new d0(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new xt(0,0),this.repeat=new xt(1,1),this.center=new xt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Yt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,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,this.normalized=!1}get width(){return this.source.getSize(uh).x}get height(){return this.source.getSize(uh).y}get depth(){return this.source.getSize(uh).z}get image(){return this.source.data}set image(t){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.normalized=t.normalized,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(const e in t){const i=t[e];if(i===void 0){Rt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){Rt(`Texture.setValues(): property '${e}' does not exist.`);continue}n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const 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,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Eg)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ko:t.x=t.x-Math.floor(t.x);break;case wi:t.x=t.x<0?0:1;break;case Ou:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case ko:t.y=t.y-Math.floor(t.y);break;case wi:t.y=t.y<0?0:1;break;case Ou:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}bi.DEFAULT_IMAGE=null;bi.DEFAULT_MAPPING=Eg;bi.DEFAULT_ANISOTROPY=1;class ne{static{ne.prototype.isVector4=!0}constructor(t=0,e=0,i=0,n=1){this.x=t,this.y=e,this.z=i,this.w=n}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,n){return this.x=t,this.y=e,this.z=i,this.w=n,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 new Error("THREE.Vector4: 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 new Error("THREE.Vector4: 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=t.w!==void 0?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){const e=this.x,i=this.y,n=this.z,s=this.w,a=t.elements;return this.x=a[0]*e+a[4]*i+a[8]*n+a[12]*s,this.y=a[1]*e+a[5]*i+a[9]*n+a[13]*s,this.z=a[2]*e+a[6]*i+a[10]*n+a[14]*s,this.w=a[3]*e+a[7]*i+a[11]*n+a[15]*s,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);const 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,n,s;const c=t.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],p=c[9],v=c[2],m=c[6],g=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(p-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(p+m)<.1&&Math.abs(l+f+g-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const y=(l+1)/2,M=(f+1)/2,b=(g+1)/2,w=(h+d)/4,T=(u+v)/4,x=(p+m)/4;return y>M&&y>b?y<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(y),n=w/i,s=T/i):M>b?M<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(M),i=w/n,s=x/n):b<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(b),i=T/s,n=x/s),this.set(i,n,s,e),this}let S=Math.sqrt((m-p)*(m-p)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(S)<.001&&(S=1),this.x=(m-p)/S,this.y=(u-v)/S,this.z=(d-h)/S,this.w=Math.acos((l+f+g-1)/2),this}setFromMatrixPosition(t){const 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=ee(this.x,t.x,e.x),this.y=ee(this.y,t.y,e.y),this.z=ee(this.z,t.z,e.z),this.w=ee(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=ee(this.x,t,e),this.y=ee(this.y,t,e),this.z=ee(this.z,t,e),this.w=ee(this.w,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ee(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 hM extends aa{constructor(t=1,e=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:oe,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=i.depth,this.scissor=new ne(0,0,t,e),this.scissorTest=!1,this.viewport=new ne(0,0,t,e),this.textures=[];const n={width:t,height:e,depth:i.depth},s=new bi(n),a=i.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(t={}){const e={minFilter:oe,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,i=1){if(this.width!==t||this.height!==e||this.depth!==i){this.width=t,this.height=e,this.depth=i;for(let n=0,s=this.textures.length;n<s;n++)this.textures[n].image.width=t,this.textures[n].image.height=e,this.textures[n].image.depth=i,this.textures[n].isData3DTexture!==!0&&(this.textures[n].isArrayTexture=this.textures[n].image.depth>1);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<i;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const n=Object.assign({},t.textures[e].image);this.textures[e].source=new d0(n)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this.multiview=t.multiview,this.useArrayDepthTexture=t.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ri extends hM{constructor(t=1,e=1,i={}){super(t,e,i),this.isWebGLRenderTarget=!0}}class Og extends bi{constructor(t=null,e=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=Re,this.minFilter=Re,this.wrapR=wi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Ng extends bi{constructor(t=null,e=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=Re,this.minFilter=Re,this.wrapR=wi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Jt{static{Jt.prototype.isMatrix4=!0}constructor(t,e,i,n,s,a,o,c,l,h,u,d,f,p,v,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,a,o,c,l,h,u,d,f,p,v,m)}set(t,e,i,n,s,a,o,c,l,h,u,d,f,p,v,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=s,g[5]=a,g[9]=o,g[13]=c,g[2]=l,g[6]=h,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=v,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 Jt().fromArray(this.elements)}copy(t){const 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){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const 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 this.determinantAffine()===0?(t.set(1,0,0),e.set(0,1,0),i.set(0,0,1),this):(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(t.determinantAffine()===0)return this.identity();const e=this.elements,i=t.elements,n=1/Wa.setFromMatrixColumn(t,0).length(),s=1/Wa.setFromMatrixColumn(t,1).length(),a=1/Wa.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=0,e[8]=i[8]*a,e[9]=i[9]*a,e[10]=i[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,s=t.z,a=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){const d=a*h,f=a*u,p=o*h,v=o*u;e[0]=c*h,e[4]=-c*u,e[8]=l,e[1]=f+p*l,e[5]=d-v*l,e[9]=-o*c,e[2]=v-d*l,e[6]=p+f*l,e[10]=a*c}else if(t.order==="YXZ"){const d=c*h,f=c*u,p=l*h,v=l*u;e[0]=d+v*o,e[4]=p*o-f,e[8]=a*l,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-p,e[6]=v+d*o,e[10]=a*c}else if(t.order==="ZXY"){const d=c*h,f=c*u,p=l*h,v=l*u;e[0]=d-v*o,e[4]=-a*u,e[8]=p+f*o,e[1]=f+p*o,e[5]=a*h,e[9]=v-d*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){const d=a*h,f=a*u,p=o*h,v=o*u;e[0]=c*h,e[4]=p*l-f,e[8]=d*l+v,e[1]=c*u,e[5]=v*l+d,e[9]=f*l-p,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){const d=a*c,f=a*l,p=o*c,v=o*l;e[0]=c*h,e[4]=v-d*u,e[8]=p*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=f*u+p,e[10]=d-v*u}else if(t.order==="XZY"){const d=a*c,f=a*l,p=o*c,v=o*l;e[0]=c*h,e[4]=-u,e[8]=l*h,e[1]=d*u+v,e[5]=a*h,e[9]=f*u-p,e[2]=p*u-f,e[6]=o*h,e[10]=v*u+d}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(uM,t,dM)}lookAt(t,e,i){const n=this.elements;return en.subVectors(t,e),en.lengthSq()===0&&(en.z=1),en.normalize(),Os.crossVectors(i,en),Os.lengthSq()===0&&(Math.abs(i.z)===1?en.x+=1e-4:en.z+=1e-4,en.normalize(),Os.crossVectors(i,en)),Os.normalize(),ac.crossVectors(en,Os),n[0]=Os.x,n[4]=ac.x,n[8]=en.x,n[1]=Os.y,n[5]=ac.y,n[9]=en.y,n[2]=Os.z,n[6]=ac.z,n[10]=en.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,s=this.elements,a=i[0],o=i[4],c=i[8],l=i[12],h=i[1],u=i[5],d=i[9],f=i[13],p=i[2],v=i[6],m=i[10],g=i[14],S=i[3],y=i[7],M=i[11],b=i[15],w=n[0],T=n[4],x=n[8],A=n[12],C=n[1],I=n[5],P=n[9],V=n[13],X=n[2],L=n[6],B=n[10],k=n[14],$=n[3],tt=n[7],J=n[11],it=n[15];return s[0]=a*w+o*C+c*X+l*$,s[4]=a*T+o*I+c*L+l*tt,s[8]=a*x+o*P+c*B+l*J,s[12]=a*A+o*V+c*k+l*it,s[1]=h*w+u*C+d*X+f*$,s[5]=h*T+u*I+d*L+f*tt,s[9]=h*x+u*P+d*B+f*J,s[13]=h*A+u*V+d*k+f*it,s[2]=p*w+v*C+m*X+g*$,s[6]=p*T+v*I+m*L+g*tt,s[10]=p*x+v*P+m*B+g*J,s[14]=p*A+v*V+m*k+g*it,s[3]=S*w+y*C+M*X+b*$,s[7]=S*T+y*I+M*L+b*tt,s[11]=S*x+y*P+M*B+b*J,s[15]=S*A+y*V+M*k+b*it,this}multiplyScalar(t){const 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(){const t=this.elements,e=t[0],i=t[4],n=t[8],s=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],u=t[6],d=t[10],f=t[14],p=t[3],v=t[7],m=t[11],g=t[15],S=c*f-l*d,y=o*f-l*u,M=o*d-c*u,b=a*f-l*h,w=a*d-c*h,T=a*u-o*h;return e*(v*S-m*y+g*M)-i*(p*S-m*b+g*w)+n*(p*y-v*b+g*T)-s*(p*M-v*w+m*T)}determinantAffine(){const t=this.elements,e=t[0],i=t[4],n=t[8],s=t[1],a=t[5],o=t[9],c=t[2],l=t[6],h=t[10];return e*(a*h-o*l)-i*(s*h-o*c)+n*(s*l-a*c)}transpose(){const t=this.elements;let e;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(t,e,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=t[9],d=t[10],f=t[11],p=t[12],v=t[13],m=t[14],g=t[15],S=e*o-i*a,y=e*c-n*a,M=e*l-s*a,b=i*c-n*o,w=i*l-s*o,T=n*l-s*c,x=h*v-u*p,A=h*m-d*p,C=h*g-f*p,I=u*m-d*v,P=u*g-f*v,V=d*g-f*m,X=S*V-y*P+M*I+b*C-w*A+T*x;if(X===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const L=1/X;return t[0]=(o*V-c*P+l*I)*L,t[1]=(n*P-i*V-s*I)*L,t[2]=(v*T-m*w+g*b)*L,t[3]=(d*w-u*T-f*b)*L,t[4]=(c*C-a*V-l*A)*L,t[5]=(e*V-n*C+s*A)*L,t[6]=(m*M-p*T-g*y)*L,t[7]=(h*T-d*M+f*y)*L,t[8]=(a*P-o*C+l*x)*L,t[9]=(i*C-e*P-s*x)*L,t[10]=(p*w-v*M+g*S)*L,t[11]=(u*M-h*w-f*S)*L,t[12]=(o*A-a*I-c*x)*L,t[13]=(e*I-i*A+n*x)*L,t[14]=(v*y-p*b-m*S)*L,t[15]=(h*b-u*y+d*S)*L,this}scale(t){const e=this.elements,i=t.x,n=t.y,s=t.z;return e[0]*=i,e[4]*=n,e[8]*=s,e[1]*=i,e[5]*=n,e[9]*=s,e[2]*=i,e[6]*=n,e[10]*=s,e[3]*=i,e[7]*=n,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}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){const 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){const 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){const 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){const i=Math.cos(e),n=Math.sin(e),s=1-i,a=t.x,o=t.y,c=t.z,l=s*a,h=s*o;return this.set(l*a+i,l*o-n*c,l*c+n*o,0,l*o+n*c,h*o+i,h*c-n*a,0,l*c-n*o,h*c+n*a,s*c*c+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,n,s,a){return this.set(1,i,s,0,t,1,a,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,s=e._x,a=e._y,o=e._z,c=e._w,l=s+s,h=a+a,u=o+o,d=s*l,f=s*h,p=s*u,v=a*h,m=a*u,g=o*u,S=c*l,y=c*h,M=c*u,b=i.x,w=i.y,T=i.z;return n[0]=(1-(v+g))*b,n[1]=(f+M)*b,n[2]=(p-y)*b,n[3]=0,n[4]=(f-M)*w,n[5]=(1-(d+g))*w,n[6]=(m+S)*w,n[7]=0,n[8]=(p+y)*T,n[9]=(m-S)*T,n[10]=(1-(d+v))*T,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;t.x=n[12],t.y=n[13],t.z=n[14];const s=this.determinantAffine();if(s===0)return i.set(1,1,1),e.identity(),this;let a=Wa.set(n[0],n[1],n[2]).length();const o=Wa.set(n[4],n[5],n[6]).length(),c=Wa.set(n[8],n[9],n[10]).length();s<0&&(a=-a),bn.copy(this);const l=1/a,h=1/o,u=1/c;return bn.elements[0]*=l,bn.elements[1]*=l,bn.elements[2]*=l,bn.elements[4]*=h,bn.elements[5]*=h,bn.elements[6]*=h,bn.elements[8]*=u,bn.elements[9]*=u,bn.elements[10]*=u,e.setFromRotationMatrix(bn),i.x=a,i.y=o,i.z=c,this}makePerspective(t,e,i,n,s,a,o=ns,c=!1){const l=this.elements,h=2*s/(e-t),u=2*s/(i-n),d=(e+t)/(e-t),f=(i+n)/(i-n);let p,v;if(c)p=s/(a-s),v=a*s/(a-s);else if(o===ns)p=-(a+s)/(a-s),v=-2*a*s/(a-s);else if(o===Ho)p=-a/(a-s),v=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,i,n,s,a,o=ns,c=!1){const l=this.elements,h=2/(e-t),u=2/(i-n),d=-(e+t)/(e-t),f=-(i+n)/(i-n);let p,v;if(c)p=1/(a-s),v=a/(a-s);else if(o===ns)p=-2/(a-s),v=-(a+s)/(a-s);else if(o===Ho)p=-1/(a-s),v=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let n=0;n<16;n++)if(e[n]!==i[n])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){const 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}}const Wa=new R,bn=new Jt,uM=new R(0,0,0),dM=new R(1,1,1),Os=new R,ac=new R,en=new R,Cf=new Jt,Pf=new Qi;class As{constructor(t=0,e=0,i=0,n=As.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}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,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,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){const n=t.elements,s=n[0],a=n[4],o=n[8],c=n[1],l=n[5],h=n[9],u=n[2],d=n[6],f=n[10];switch(e){case"XYZ":this._y=Math.asin(ee(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ee(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(ee(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-ee(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(ee(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-ee(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Rt("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return Cf.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Cf,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Pf.setFromEuler(this),this.setFromQuaternion(Pf,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],t[3]!==void 0&&(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}}As.DEFAULT_ORDER="XYZ";class f0{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let fM=0;const Lf=new R,Xa=new Qi,ls=new Jt,rc=new R,Wr=new R,pM=new R,mM=new Qi,Of=new R(1,0,0),Nf=new R(0,1,0),Ff=new R(0,0,1),Uf={type:"added"},gM={type:"removed"},Ya={type:"childadded",child:null},dh={type:"childremoved",child:null};class Be extends aa{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:fM++}),this.uuid=Nn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Be.DEFAULT_UP.clone();const t=new R,e=new As,i=new Qi,n=new R(1,1,1);function s(){i.setFromEuler(e,!1)}function a(){e.setFromQuaternion(i,void 0,!1)}e._onChange(s),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Jt},normalMatrix:{value:new Yt}}),this.matrix=new Jt,this.matrixWorld=new Jt,this.matrixAutoUpdate=Be.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Be.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new f0,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Xa.setFromAxisAngle(t,e),this.quaternion.multiply(Xa),this}rotateOnWorldAxis(t,e){return Xa.setFromAxisAngle(t,e),this.quaternion.premultiply(Xa),this}rotateX(t){return this.rotateOnAxis(Of,t)}rotateY(t){return this.rotateOnAxis(Nf,t)}rotateZ(t){return this.rotateOnAxis(Ff,t)}translateOnAxis(t,e){return Lf.copy(t).applyQuaternion(this.quaternion),this.position.add(Lf.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Of,t)}translateY(t){return this.translateOnAxis(Nf,t)}translateZ(t){return this.translateOnAxis(Ff,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(ls.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?rc.copy(t):rc.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Wr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ls.lookAt(Wr,rc,this.up):ls.lookAt(rc,Wr,this.up),this.quaternion.setFromRotationMatrix(ls),n&&(ls.extractRotation(n.matrixWorld),Xa.setFromRotationMatrix(ls),this.quaternion.premultiply(Xa.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Gt("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Uf),Ya.child=t,this.dispatchEvent(Ya),Ya.child=null):Gt("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(gM),dh.child=t,this.dispatchEvent(dh),dh.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),ls.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),ls.multiply(t.parent.matrixWorld)),t.applyMatrix4(ls),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Uf),Ya.child=t,this.dispatchEvent(Ya),Ya.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let i=0,n=this.children.length;i<n;i++){const a=this.children[i].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const n=this.children;for(let s=0,a=n.length;s<a;s++)n[s].getObjectsByProperty(t,e,i);return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Wr,t,pM),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Wr,mM,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,i=t.y,n=t.z,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*i-s[8]*n,s[13]+=i-s[1]*e-s[5]*i-s[9]*n,s[14]+=n-s[2]*e-s[6]*i-s[10]*n}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].updateMatrixWorld(t)}updateWorldMatrix(t,e,i=!1){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),e===!0){const s=this.children;for(let a=0,o=s.length;a<o;a++)s[a].updateWorldMatrix(!1,!0,i)}}toJSON(t){const e=t===void 0||typeof t=="string",i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),this.static!==!1&&(n.static=this.static),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.pivot!==null&&(n.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(o=>({...o})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(t),n.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];s(t.shapes,u)}else s(t.shapes,c)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(s(t.materials,this.material[c]));n.material=o}else n.material=s(t.materials,this.material);if(this.children.length>0){n.children=[];for(let o=0;o<this.children.length;o++)n.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];n.animations.push(s(t.animations,c))}}if(e){const o=a(t.geometries),c=a(t.materials),l=a(t.textures),h=a(t.images),u=a(t.shapes),d=a(t.skeletons),f=a(t.animations),p=a(t.nodes);o.length>0&&(i.geometries=o),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),h.length>0&&(i.images=h),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=n,i;function a(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}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.pivot=t.pivot!==null?t.pivot.clone():null,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.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let i=0;i<t.children.length;i++){const n=t.children[i];this.add(n.clone())}return this}}Be.DEFAULT_UP=new R(0,1,0);Be.DEFAULT_MATRIX_AUTO_UPDATE=!0;Be.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Ce extends Be{constructor(){super(),this.isGroup=!0,this.type="Group"}}const vM={type:"move"};class fh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ce,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Ce,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ce,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const 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}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,i){let n=null,s=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(const v of t.hand.values()){const m=e.getJointPose(v,i),g=this._getHandJoint(l,v);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius),g.visible=m!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,p=.005;l.inputState.pinching&&d>f+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&d<=f-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,i),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:t,target:this})));o!==null&&(n=e.getPose(t.targetRaySpace,i),n===null&&s!==null&&(n=s),n!==null&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(vM)))}return o!==null&&(o.visible=n!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const i=new Ce;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}const Fg={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ns={h:0,s:0,l:0},oc={h:0,s:0,l:0};function ph(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class st{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){if(e===void 0&&i===void 0){const n=t;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Gi){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,re.colorSpaceToWorking(this,e),this}setRGB(t,e,i,n=re.workingColorSpace){return this.r=t,this.g=e,this.b=i,re.colorSpaceToWorking(this,n),this}setHSL(t,e,i,n=re.workingColorSpace){if(t=u0(t,1),e=ee(e,0,1),i=ee(i,0,1),e===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+e):i+e-i*e,a=2*i-s;this.r=ph(a,s,t+1/3),this.g=ph(a,s,t),this.b=ph(a,s,t-1/3)}return re.colorSpaceToWorking(this,n),this}setStyle(t,e=Gi){function i(s){s!==void 0&&parseFloat(s)<1&&Rt("Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const a=n[1],o=n[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:Rt("Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=n[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(s,16),e);Rt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Gi){const i=Fg[t.toLowerCase()];return i!==void 0?this.setHex(i,e):Rt("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=ws(t.r),this.g=ws(t.g),this.b=ws(t.b),this}copyLinearToSRGB(t){return this.r=br(t.r),this.g=br(t.g),this.b=br(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Gi){return re.workingToColorSpace(Di.copy(this),t),Math.round(ee(Di.r*255,0,255))*65536+Math.round(ee(Di.g*255,0,255))*256+Math.round(ee(Di.b*255,0,255))}getHexString(t=Gi){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=re.workingColorSpace){re.workingToColorSpace(Di.copy(this),e);const i=Di.r,n=Di.g,s=Di.b,a=Math.max(i,n,s),o=Math.min(i,n,s);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case i:c=(n-s)/u+(n<s?6:0);break;case n:c=(s-i)/u+2;break;case s:c=(i-n)/u+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=re.workingColorSpace){return re.workingToColorSpace(Di.copy(this),e),t.r=Di.r,t.g=Di.g,t.b=Di.b,t}getStyle(t=Gi){re.workingToColorSpace(Di.copy(this),t);const e=Di.r,i=Di.g,n=Di.b;return t!==Gi?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(t,e,i){return this.getHSL(Ns),this.setHSL(Ns.h+t,Ns.s+e,Ns.l+i)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(Ns),t.getHSL(oc);const i=wo(Ns.h,oc.h,e),n=wo(Ns.s,oc.s,e),s=wo(Ns.l,oc.l,e);return this.setHSL(i,n,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,i=this.g,n=this.b,s=t.elements;return this.r=s[0]*e+s[3]*i+s[6]*n,this.g=s[1]*e+s[4]*i+s[7]*n,this.b=s[2]*e+s[5]*i+s[8]*n,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Di=new st;st.NAMES=Fg;class p0{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new st(t),this.near=e,this.far=i}clone(){return new p0(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Ts extends Be{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 As,this.environmentIntensity=1,this.environmentRotation=new As,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(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),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const wn=new R,hs=new R,mh=new R,us=new R,qa=new R,$a=new R,kf=new R,gh=new R,vh=new R,Mh=new R,xh=new ne,yh=new ne,_h=new ne;class yn{constructor(t=new R,e=new R,i=new R){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),wn.subVectors(t,e),n.cross(wn);const s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(t,e,i,n,s){wn.subVectors(n,e),hs.subVectors(i,e),mh.subVectors(t,e);const a=wn.dot(wn),o=wn.dot(hs),c=wn.dot(mh),l=hs.dot(hs),h=hs.dot(mh),u=a*l-o*o;if(u===0)return s.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,p=(a*h-o*c)*d;return s.set(1-f-p,p,f)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,us)===null?!1:us.x>=0&&us.y>=0&&us.x+us.y<=1}static getInterpolation(t,e,i,n,s,a,o,c){return this.getBarycoord(t,e,i,n,us)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,us.x),c.addScaledVector(a,us.y),c.addScaledVector(o,us.z),c)}static getInterpolatedAttribute(t,e,i,n,s,a){return xh.setScalar(0),yh.setScalar(0),_h.setScalar(0),xh.fromBufferAttribute(t,e),yh.fromBufferAttribute(t,i),_h.fromBufferAttribute(t,n),a.setScalar(0),a.addScaledVector(xh,s.x),a.addScaledVector(yh,s.y),a.addScaledVector(_h,s.z),a}static isFrontFacing(t,e,i,n){return wn.subVectors(i,e),hs.subVectors(t,e),wn.cross(hs).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,i,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,n),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 wn.subVectors(this.c,this.b),hs.subVectors(this.a,this.b),wn.cross(hs).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return yn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return yn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,n,s){return yn.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}containsPoint(t){return yn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return yn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,n=this.b,s=this.c;let a,o;qa.subVectors(n,i),$a.subVectors(s,i),gh.subVectors(t,i);const c=qa.dot(gh),l=$a.dot(gh);if(c<=0&&l<=0)return e.copy(i);vh.subVectors(t,n);const h=qa.dot(vh),u=$a.dot(vh);if(h>=0&&u<=h)return e.copy(n);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(i).addScaledVector(qa,a);Mh.subVectors(t,s);const f=qa.dot(Mh),p=$a.dot(Mh);if(p>=0&&f<=p)return e.copy(s);const v=f*l-c*p;if(v<=0&&l>=0&&p<=0)return o=l/(l-p),e.copy(i).addScaledVector($a,o);const m=h*p-f*u;if(m<=0&&u-h>=0&&f-p>=0)return kf.subVectors(s,n),o=(u-h)/(u-h+(f-p)),e.copy(n).addScaledVector(kf,o);const g=1/(m+v+d);return a=v*g,o=d*g,e.copy(i).addScaledVector(qa,a).addScaledVector($a,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Vi{constructor(t=new R(1/0,1/0,1/0),e=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e+=3)this.expandByPoint(En.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(En.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=En.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const i=t.geometry;if(i!==void 0){const s=i.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,En):En.fromBufferAttribute(s,a),En.applyMatrix4(t.matrixWorld),this.expandByPoint(En);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),cc.copy(t.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),cc.copy(i.boundingBox)),cc.applyMatrix4(t.matrixWorld),this.union(cc)}const n=t.children;for(let s=0,a=n.length;s<a;s++)this.expandByObject(n[s],e);return this}containsPoint(t){return t.x>=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,En),En.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(Xr),lc.subVectors(this.max,Xr),Ka.subVectors(t.a,Xr),Za.subVectors(t.b,Xr),Ja.subVectors(t.c,Xr),Fs.subVectors(Za,Ka),Us.subVectors(Ja,Za),ca.subVectors(Ka,Ja);let e=[0,-Fs.z,Fs.y,0,-Us.z,Us.y,0,-ca.z,ca.y,Fs.z,0,-Fs.x,Us.z,0,-Us.x,ca.z,0,-ca.x,-Fs.y,Fs.x,0,-Us.y,Us.x,0,-ca.y,ca.x,0];return!Sh(e,Ka,Za,Ja,lc)||(e=[1,0,0,0,1,0,0,0,1],!Sh(e,Ka,Za,Ja,lc))?!1:(hc.crossVectors(Fs,Us),e=[hc.x,hc.y,hc.z],Sh(e,Ka,Za,Ja,lc))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,En).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(En).length()*.5),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()?this:(ds[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ds[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ds[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ds[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ds[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ds[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ds[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ds[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ds),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}}const ds=[new R,new R,new R,new R,new R,new R,new R,new R],En=new R,cc=new Vi,Ka=new R,Za=new R,Ja=new R,Fs=new R,Us=new R,ca=new R,Xr=new R,lc=new R,hc=new R,la=new R;function Sh(r,t,e,i,n){for(let s=0,a=r.length-3;s<=a;s+=3){la.fromArray(r,s);const o=n.x*Math.abs(la.x)+n.y*Math.abs(la.y)+n.z*Math.abs(la.z),c=t.dot(la),l=e.dot(la),h=i.dot(la);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const ys=MM();function MM(){const r=new ArrayBuffer(4),t=new Float32Array(r),e=new Uint32Array(r),i=new Uint32Array(512),n=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(i[c]=0,i[c|256]=32768,n[c]=24,n[c|256]=24):l<-14?(i[c]=1024>>-l-14,i[c|256]=1024>>-l-14|32768,n[c]=-l-1,n[c|256]=-l-1):l<=15?(i[c]=l+15<<10,i[c|256]=l+15<<10|32768,n[c]=13,n[c|256]=13):l<128?(i[c]=31744,i[c|256]=64512,n[c]=24,n[c|256]=24):(i[c]=31744,i[c|256]=64512,n[c]=13,n[c|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,s[c]=l|h}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:t,uint32View:e,baseTable:i,shiftTable:n,mantissaTable:s,exponentTable:a,offsetTable:o}}function xM(r){Math.abs(r)>65504&&Rt("DataUtils.toHalfFloat(): Value out of range."),r=ee(r,-65504,65504),ys.floatView[0]=r;const t=ys.uint32View[0],e=t>>23&511;return ys.baseTable[e]+((t&8388607)>>ys.shiftTable[e])}function yM(r){const t=r>>10;return ys.uint32View[0]=ys.mantissaTable[ys.offsetTable[t]+(r&1023)]+ys.exponentTable[t],ys.floatView[0]}class Fn{static toHalfFloat(t){return xM(t)}static fromHalfFloat(t){return yM(t)}}const li=new R,uc=new xt;let _M=0;class ie extends aa{constructor(t,e,i=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:_M++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=i,this.usage=dd,this.updateRanges=[],this.gpuType=Oi,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&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 n=0,s=this.itemSize;n<s;n++)this.array[t+n]=e.array[i+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,i=this.count;e<i;e++)uc.fromBufferAttribute(this,e),uc.applyMatrix3(t),this.setXY(e,uc.x,uc.y);else if(this.itemSize===3)for(let e=0,i=this.count;e<i;e++)li.fromBufferAttribute(this,e),li.applyMatrix3(t),this.setXYZ(e,li.x,li.y,li.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)li.fromBufferAttribute(this,e),li.applyMatrix4(t),this.setXYZ(e,li.x,li.y,li.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)li.fromBufferAttribute(this,e),li.applyNormalMatrix(t),this.setXYZ(e,li.x,li.y,li.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)li.fromBufferAttribute(this,e),li.transformDirection(t),this.setXYZ(e,li.x,li.y,li.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let i=this.array[t*this.itemSize+e];return this.normalized&&(i=Ln(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=be(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ln(e,this.array)),e}setX(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ln(e,this.array)),e}setY(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Ln(e,this.array)),e}setZ(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Ln(e,this.array)),e}setW(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),i=be(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),i=be(i,this.array),n=be(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this}setXYZW(t,e,i,n,s){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),i=be(i,this.array),n=be(n,this.array),s=be(s,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==dd&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class Ug extends ie{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class m0 extends ie{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class de extends ie{constructor(t,e,i){super(new Float32Array(t),e,i)}}const SM=new Vi,Yr=new R,bh=new R;class Rs{constructor(t=new R,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){const i=this.center;e!==void 0?i.copy(e):SM.setFromPoints(t).getCenter(i);let n=0;for(let s=0,a=t.length;s<a;s++)n=Math.max(n,i.distanceToSquared(t[s]));return this.radius=Math.sqrt(n),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const i=this.center.distanceToSquared(t);return e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(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;Yr.subVectors(t,this.center);const e=Yr.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),n=(i-this.radius)*.5;this.center.addScaledVector(Yr,n/i),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(bh.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Yr.copy(t.center).add(bh)),this.expandByPoint(Yr.copy(t.center).sub(bh))),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 bM=0;const pn=new Jt,wh=new Be,ja=new R,nn=new Vi,qr=new Vi,Mi=new R;class ce extends aa{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:bM++}),this.uuid=Nn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(z2(t)?m0:Ug)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,i=0){this.groups.push({start:t,count:e,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new Yt().getNormalMatrix(t);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(t),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return pn.makeRotationFromQuaternion(t),this.applyMatrix4(pn),this}rotateX(t){return pn.makeRotationX(t),this.applyMatrix4(pn),this}rotateY(t){return pn.makeRotationY(t),this.applyMatrix4(pn),this}rotateZ(t){return pn.makeRotationZ(t),this.applyMatrix4(pn),this}translate(t,e,i){return pn.makeTranslation(t,e,i),this.applyMatrix4(pn),this}scale(t,e,i){return pn.makeScale(t,e,i),this.applyMatrix4(pn),this}lookAt(t){return wh.lookAt(t),wh.updateMatrix(),this.applyMatrix4(wh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ja).negate(),this.translate(ja.x,ja.y,ja.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const i=[];for(let n=0,s=t.length;n<s;n++){const a=t[n];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new de(i,3))}else{const i=Math.min(t.length,e.count);for(let n=0;n<i;n++){const s=t[n];e.setXYZ(n,s.x,s.y,s.z||0)}t.length>e.count&&Rt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Vi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Gt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let i=0,n=e.length;i<n;i++){const s=e[i];nn.setFromBufferAttribute(s),this.morphTargetsRelative?(Mi.addVectors(this.boundingBox.min,nn.min),this.boundingBox.expandByPoint(Mi),Mi.addVectors(this.boundingBox.max,nn.max),this.boundingBox.expandByPoint(Mi)):(this.boundingBox.expandByPoint(nn.min),this.boundingBox.expandByPoint(nn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Gt('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Rs);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Gt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(t){const i=this.boundingSphere.center;if(nn.setFromBufferAttribute(t),e)for(let s=0,a=e.length;s<a;s++){const o=e[s];qr.setFromBufferAttribute(o),this.morphTargetsRelative?(Mi.addVectors(nn.min,qr.min),nn.expandByPoint(Mi),Mi.addVectors(nn.max,qr.max),nn.expandByPoint(Mi)):(nn.expandByPoint(qr.min),nn.expandByPoint(qr.max))}nn.getCenter(i);let n=0;for(let s=0,a=t.count;s<a;s++)Mi.fromBufferAttribute(t,s),n=Math.max(n,i.distanceToSquared(Mi));if(e)for(let s=0,a=e.length;s<a;s++){const o=e[s],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)Mi.fromBufferAttribute(o,l),c&&(ja.fromBufferAttribute(t,l),Mi.add(ja)),n=Math.max(n,i.distanceToSquared(Mi))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&Gt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Gt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=e.position,n=e.normal,s=e.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==i.count)&&(a=new ie(new Float32Array(4*i.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let x=0;x<i.count;x++)o[x]=new R,c[x]=new R;const l=new R,h=new R,u=new R,d=new xt,f=new xt,p=new xt,v=new R,m=new R;function g(x,A,C){l.fromBufferAttribute(i,x),h.fromBufferAttribute(i,A),u.fromBufferAttribute(i,C),d.fromBufferAttribute(s,x),f.fromBufferAttribute(s,A),p.fromBufferAttribute(s,C),h.sub(l),u.sub(l),f.sub(d),p.sub(d);const I=1/(f.x*p.y-p.x*f.y);isFinite(I)&&(v.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(I),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(I),o[x].add(v),o[A].add(v),o[C].add(v),c[x].add(m),c[A].add(m),c[C].add(m))}let S=this.groups;S.length===0&&(S=[{start:0,count:t.count}]);for(let x=0,A=S.length;x<A;++x){const C=S[x],I=C.start,P=C.count;for(let V=I,X=I+P;V<X;V+=3)g(t.getX(V+0),t.getX(V+1),t.getX(V+2))}const y=new R,M=new R,b=new R,w=new R;function T(x){b.fromBufferAttribute(n,x),w.copy(b);const A=o[x];y.copy(A),y.sub(b.multiplyScalar(b.dot(A))).normalize(),M.crossVectors(w,A);const I=M.dot(c[x])<0?-1:1;a.setXYZW(x,y.x,y.y,y.z,I)}for(let x=0,A=S.length;x<A;++x){const C=S[x],I=C.start,P=C.count;for(let V=I,X=I+P;V<X;V+=3)T(t.getX(V+0)),T(t.getX(V+1)),T(t.getX(V+2))}this._transformed=!0}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==e.count)i=new ie(new Float32Array(e.count*3),3),this.setAttribute("normal",i);else for(let d=0,f=i.count;d<f;d++)i.setXYZ(d,0,0,0);const n=new R,s=new R,a=new R,o=new R,c=new R,l=new R,h=new R,u=new R;if(t)for(let d=0,f=t.count;d<f;d+=3){const p=t.getX(d+0),v=t.getX(d+1),m=t.getX(d+2);n.fromBufferAttribute(e,p),s.fromBufferAttribute(e,v),a.fromBufferAttribute(e,m),h.subVectors(a,s),u.subVectors(n,s),h.cross(u),o.fromBufferAttribute(i,p),c.fromBufferAttribute(i,v),l.fromBufferAttribute(i,m),o.add(h),c.add(h),l.add(h),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(v,c.x,c.y,c.z),i.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,f=e.count;d<f;d+=3)n.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,s),u.subVectors(n,s),h.cross(u),i.setXYZ(d+0,h.x,h.y,h.z),i.setXYZ(d+1,h.x,h.y,h.z),i.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)Mi.fromBufferAttribute(t,e),Mi.normalize(),t.setXYZ(e,Mi.x,Mi.y,Mi.z)}toNonIndexed(){function t(o,c){const l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h);let f=0,p=0;for(let v=0,m=c.length;v<m;v++){o.isInterleavedBufferAttribute?f=c[v]*o.data.stride+o.offset:f=c[v]*h;for(let g=0;g<h;g++)d[p++]=l[f++]}return new ie(d,h,u)}if(this.index===null)return Rt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new ce,i=this.index.array,n=this.attributes;for(const o in n){const c=n[o],l=t(c,i);e.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const c=[],l=s[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=t(d,i);c.push(f)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const c in i){const l=i[c];t.data.attributes[c]=l.toJSON(t.data)}const n={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(t.data))}h.length>0&&(n[c]=h,s=!0)}s&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.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;const e={};this.name=t.name;const i=t.index;i!==null&&this.setIndex(i.clone());const n=t.attributes;for(const l in n){const h=n[l];this.setAttribute(l,h.clone(e))}const s=t.morphAttributes;for(const l in s){const h=[],u=s[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class wM{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=dd,this.updateRanges=[],this.version=0,this.uuid=Nn()}onUploadCallback(){}set needsUpdate(t){t===!0&&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 n=0,s=this.stride;n<s;n++)this.array[t+n]=e.array[i+n];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Nn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(e,this.stride);return i.setUsage(this.usage),i}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Nn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Fi=new R;class bl{constructor(t,e,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,i=this.data.count;e<i;e++)Fi.fromBufferAttribute(this,e),Fi.applyMatrix4(t),this.setXYZ(e,Fi.x,Fi.y,Fi.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Fi.fromBufferAttribute(this,e),Fi.applyNormalMatrix(t),this.setXYZ(e,Fi.x,Fi.y,Fi.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Fi.fromBufferAttribute(this,e),Fi.transformDirection(t),this.setXYZ(e,Fi.x,Fi.y,Fi.z);return this}getComponent(t,e){let i=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(i=Ln(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=be(i,this.array)),this.data.array[t*this.data.stride+this.offset+e]=i,this}setX(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ln(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ln(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ln(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ln(e,this.array)),e}setXY(t,e,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=be(e,this.array),i=be(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this}setXYZ(t,e,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=be(e,this.array),i=be(i,this.array),n=be(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this}setXYZW(t,e,i,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=be(e,this.array),i=be(i,this.array),n=be(n,this.array),s=be(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this.data.array[t+3]=s,this}clone(t){if(t===void 0){Sl("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return new ie(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new bl(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){Sl("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let EM=0;class Ds extends aa{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:EM++}),this.uuid=Nn(),this.name="",this.type="Material",this.blending=ta,this.side=ia,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Au,this.blendDst=Uo,this.blendEquation=Ma,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new st(0,0,0),this.blendAlpha=0,this.depthFunc=Pr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ef,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ga,this.stencilZFail=Ga,this.stencilZPass=Ga,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const i=t[e];if(i===void 0){Rt(`Material: parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){Rt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector2&&i&&i.isVector2||n&&n.isEuler&&i&&i.isEuler||n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(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),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(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),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(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,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==ta&&(i.blending=this.blending),this.side!==ia&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Au&&(i.blendSrc=this.blendSrc),this.blendDst!==Uo&&(i.blendDst=this.blendDst),this.blendEquation!==Ma&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Pr&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Ef&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ga&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ga&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ga&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(s){const a=[];for(const o in s){const c=s[o];delete c.metadata,a.push(c)}return a}if(e){const s=n(t.textures),a=n(t.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}fromJSON(t,e){if(t.uuid!==void 0&&(this.uuid=t.uuid),t.name!==void 0&&(this.name=t.name),t.color!==void 0&&this.color!==void 0&&this.color.setHex(t.color),t.roughness!==void 0&&(this.roughness=t.roughness),t.metalness!==void 0&&(this.metalness=t.metalness),t.sheen!==void 0&&(this.sheen=t.sheen),t.sheenColor!==void 0&&(this.sheenColor=new st().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(this.blendSrc=t.blendSrc),t.blendDst!==void 0&&(this.blendDst=t.blendDst),t.blendEquation!==void 0&&(this.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(this.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(this.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(this.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(this.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(this.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(this.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(this.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(this.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(this.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(this.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(this.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(this.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(this.rotation=t.rotation),t.linewidth!==void 0&&(this.linewidth=t.linewidth),t.dashSize!==void 0&&(this.dashSize=t.dashSize),t.gapSize!==void 0&&(this.gapSize=t.gapSize),t.scale!==void 0&&(this.scale=t.scale),t.polygonOffset!==void 0&&(this.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(this.dithering=t.dithering),t.alphaToCoverage!==void 0&&(this.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(this.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(this.allowOverride=t.allowOverride),t.visible!==void 0&&(this.visible=t.visible),t.toneMapped!==void 0&&(this.toneMapped=t.toneMapped),t.userData!==void 0&&(this.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),t.size!==void 0&&(this.size=t.size),t.sizeAttenuation!==void 0&&(this.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(this.map=e[t.map]||null),t.matcap!==void 0&&(this.matcap=e[t.matcap]||null),t.alphaMap!==void 0&&(this.alphaMap=e[t.alphaMap]||null),t.bumpMap!==void 0&&(this.bumpMap=e[t.bumpMap]||null),t.bumpScale!==void 0&&(this.bumpScale=t.bumpScale),t.normalMap!==void 0&&(this.normalMap=e[t.normalMap]||null),t.normalMapType!==void 0&&(this.normalMapType=t.normalMapType),t.normalScale!==void 0){let i=t.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new xt().fromArray(i)}return t.displacementMap!==void 0&&(this.displacementMap=e[t.displacementMap]||null),t.displacementScale!==void 0&&(this.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(this.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(this.roughnessMap=e[t.roughnessMap]||null),t.metalnessMap!==void 0&&(this.metalnessMap=e[t.metalnessMap]||null),t.emissiveMap!==void 0&&(this.emissiveMap=e[t.emissiveMap]||null),t.emissiveIntensity!==void 0&&(this.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(this.specularMap=e[t.specularMap]||null),t.specularIntensityMap!==void 0&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),t.specularColorMap!==void 0&&(this.specularColorMap=e[t.specularColorMap]||null),t.envMap!==void 0&&(this.envMap=e[t.envMap]||null),t.envMapRotation!==void 0&&this.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(this.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(this.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(this.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(this.lightMap=e[t.lightMap]||null),t.lightMapIntensity!==void 0&&(this.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(this.aoMap=e[t.aoMap]||null),t.aoMapIntensity!==void 0&&(this.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(this.gradientMap=e[t.gradientMap]||null),t.clearcoatMap!==void 0&&(this.clearcoatMap=e[t.clearcoatMap]||null),t.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),t.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),t.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new xt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(this.iridescenceMap=e[t.iridescenceMap]||null),t.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),t.transmissionMap!==void 0&&(this.transmissionMap=e[t.transmissionMap]||null),t.thicknessMap!==void 0&&(this.thicknessMap=e[t.thicknessMap]||null),t.anisotropyMap!==void 0&&(this.anisotropyMap=e[t.anisotropyMap]||null),t.sheenColorMap!==void 0&&(this.sheenColorMap=e[t.sheenColorMap]||null),t.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}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;const e=t.clippingPlanes;let i=null;if(e!==null){const n=e.length;i=new Array(n);for(let s=0;s!==n;++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){t===!0&&this.version++}}class rl extends Ds{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new st(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let Qa;const $r=new R,tr=new R,er=new R,ir=new xt,Kr=new xt,kg=new Jt,dc=new R,Zr=new R,fc=new R,zf=new xt,Eh=new xt,Bf=new xt;class Jr extends Be{constructor(t=new rl){if(super(),this.isSprite=!0,this.type="Sprite",Qa===void 0){Qa=new ce;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new wM(e,5);Qa.setIndex([0,1,2,0,2,3]),Qa.setAttribute("position",new bl(i,3,0,!1)),Qa.setAttribute("uv",new bl(i,2,3,!1))}this.geometry=Qa,this.material=t,this.center=new xt(.5,.5),this.count=1}raycast(t,e){t.camera===null&&Gt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),tr.setFromMatrixScale(this.matrixWorld),kg.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),er.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&tr.multiplyScalar(-er.z);const i=this.material.rotation;let n,s;i!==0&&(s=Math.cos(i),n=Math.sin(i));const a=this.center;pc(dc.set(-.5,-.5,0),er,a,tr,n,s),pc(Zr.set(.5,-.5,0),er,a,tr,n,s),pc(fc.set(.5,.5,0),er,a,tr,n,s),zf.set(0,0),Eh.set(1,0),Bf.set(1,1);let o=t.ray.intersectTriangle(dc,Zr,fc,!1,$r);if(o===null&&(pc(Zr.set(-.5,.5,0),er,a,tr,n,s),Eh.set(0,1),o=t.ray.intersectTriangle(dc,fc,Zr,!1,$r),o===null))return;const c=t.ray.origin.distanceTo($r);c<t.near||c>t.far||e.push({distance:c,point:$r.clone(),uv:yn.getInterpolation($r,dc,Zr,fc,zf,Eh,Bf,new xt),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function pc(r,t,e,i,n,s){ir.subVectors(r,e).addScalar(.5).multiply(i),n!==void 0?(Kr.x=s*ir.x-n*ir.y,Kr.y=n*ir.x+s*ir.y):Kr.copy(ir),r.copy(t),r.x+=Kr.x,r.y+=Kr.y,r.applyMatrix4(kg)}const fs=new R,Ah=new R,mc=new R,ks=new R,Th=new R,gc=new R,Rh=new R;class Yo{constructor(t=new R,e=new R(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,fs)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const 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){const e=fs.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(fs.copy(this.origin).addScaledVector(this.direction,e),fs.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){Ah.copy(t).add(e).multiplyScalar(.5),mc.copy(e).sub(t).normalize(),ks.copy(this.origin).sub(Ah);const s=t.distanceTo(e)*.5,a=-this.direction.dot(mc),o=ks.dot(this.direction),c=-ks.dot(mc),l=ks.lengthSq(),h=Math.abs(1-a*a);let u,d,f,p;if(h>0)if(u=a*c-o,d=a*o-c,p=s*h,u>=0)if(d>=-p)if(d<=p){const v=1/h;u*=v,d*=v,f=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d=-s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-p?(u=Math.max(0,-(-a*s+o)),d=u>0?-s:Math.min(Math.max(-s,-c),s),f=-u*u+d*(d+2*c)+l):d<=p?(u=0,d=Math.min(Math.max(-s,-c),s),f=d*(d+2*c)+l):(u=Math.max(0,-(a*s+o)),d=u>0?s:Math.min(Math.max(-s,-c),s),f=-u*u+d*(d+2*c)+l);else d=a>0?-s:s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,u),n&&n.copy(Ah).addScaledVector(mc,d),f}intersectSphere(t,e){fs.subVectors(t.center,this.origin);const i=fs.dot(this.direction),n=fs.dot(fs)-i*i,s=t.radius*t.radius;if(n>s)return null;const a=Math.sqrt(s-n),o=i-a,c=i+a;return c<0?null:o<0?this.at(c,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,s,a,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(i=(t.min.x-d.x)*l,n=(t.max.x-d.x)*l):(i=(t.max.x-d.x)*l,n=(t.min.x-d.x)*l),h>=0?(s=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(s=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),i>a||s>n||((s>i||isNaN(i))&&(i=s),(a<n||isNaN(n))&&(n=a),u>=0?(o=(t.min.z-d.z)*u,c=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,c=(t.min.z-d.z)*u),i>c||o>n)||((o>i||i!==i)&&(i=o),(c<n||n!==n)&&(n=c),n<0)?null:this.at(i>=0?i:n,e)}intersectsBox(t){return this.intersectBox(t,fs)!==null}intersectTriangle(t,e,i,n,s){Th.subVectors(e,t),gc.subVectors(i,t),Rh.crossVectors(Th,gc);let a=this.direction.dot(Rh),o;if(a>0){if(n)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ks.subVectors(this.origin,t);const c=o*this.direction.dot(gc.crossVectors(ks,gc));if(c<0)return null;const l=o*this.direction.dot(Th.cross(ks));if(l<0||c+l>a)return null;const h=-o*ks.dot(Rh);return h<0?null:this.at(h/a,s)}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 _n extends Ds{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new st(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new As,this.combine=e0,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}}const Hf=new Jt,ha=new Yo,vc=new Rs,Gf=new R,Mc=new R,xc=new R,yc=new R,Dh=new R,_c=new R,Vf=new R,Sc=new R;class Dt extends Be{constructor(t=new ce,e=new _n){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=n.length;s<a;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const o=this.morphTargetInfluences;if(s&&o){_c.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const h=o[c],u=s[c];h!==0&&(Dh.fromBufferAttribute(u,t),a?_c.addScaledVector(Dh,h):_c.addScaledVector(Dh.sub(e),h))}e.add(_c)}return e}raycast(t,e){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),vc.copy(i.boundingSphere),vc.applyMatrix4(s),ha.copy(t.ray).recast(t.near),!(vc.containsPoint(ha.origin)===!1&&(ha.intersectSphere(vc,Gf)===null||ha.origin.distanceToSquared(Gf)>(t.far-t.near)**2))&&(Hf.copy(s).invert(),ha.copy(t.ray).applyMatrix4(Hf),!(i.boundingBox!==null&&ha.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,e,ha)))}_computeIntersections(t,e,i){let n;const s=this.geometry,a=this.material,o=s.index,c=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=a[m.materialIndex],S=Math.max(m.start,f.start),y=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let M=S,b=y;M<b;M+=3){const w=o.getX(M),T=o.getX(M+1),x=o.getX(M+2);n=bc(this,g,t,i,l,h,u,w,T,x),n&&(n.faceIndex=Math.floor(M/3),n.face.materialIndex=m.materialIndex,e.push(n))}}else{const p=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const S=o.getX(m),y=o.getX(m+1),M=o.getX(m+2);n=bc(this,a,t,i,l,h,u,S,y,M),n&&(n.faceIndex=Math.floor(m/3),e.push(n))}}else if(c!==void 0)if(Array.isArray(a))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=a[m.materialIndex],S=Math.max(m.start,f.start),y=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let M=S,b=y;M<b;M+=3){const w=M,T=M+1,x=M+2;n=bc(this,g,t,i,l,h,u,w,T,x),n&&(n.faceIndex=Math.floor(M/3),n.face.materialIndex=m.materialIndex,e.push(n))}}else{const p=Math.max(0,f.start),v=Math.min(c.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const S=m,y=m+1,M=m+2;n=bc(this,a,t,i,l,h,u,S,y,M),n&&(n.faceIndex=Math.floor(m/3),e.push(n))}}}}function AM(r,t,e,i,n,s,a,o){let c;if(t.side===Ve?c=i.intersectTriangle(a,s,n,!0,o):c=i.intersectTriangle(n,s,a,t.side===ia,o),c===null)return null;Sc.copy(o),Sc.applyMatrix4(r.matrixWorld);const l=e.ray.origin.distanceTo(Sc);return l<e.near||l>e.far?null:{distance:l,point:Sc.clone(),object:r}}function bc(r,t,e,i,n,s,a,o,c,l){r.getVertexPosition(o,Mc),r.getVertexPosition(c,xc),r.getVertexPosition(l,yc);const h=AM(r,t,e,i,Mc,xc,yc,Vf);if(h){const u=new R;yn.getBarycoord(Vf,Mc,xc,yc,u),n&&(h.uv=yn.getInterpolatedAttribute(n,o,c,l,u,new xt)),s&&(h.uv1=yn.getInterpolatedAttribute(s,o,c,l,u,new xt)),a&&(h.normal=yn.getInterpolatedAttribute(a,o,c,l,u,new R),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new R,materialIndex:0};yn.getNormal(Mc,xc,yc,d.normal),h.face=d,h.barycoord=u}return h}const jr=new ne,Wf=new ne,Xf=new ne,TM=new ne,Yf=new Jt,wc=new R,Ih=new Rs,qf=new Jt,Ch=new Yo;class eA extends Dt{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=bf,this.bindMatrix=new Jt,this.bindMatrixInverse=new Jt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new Vi),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,wc),this.boundingBox.expandByPoint(wc)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Rs),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,wc),this.boundingSphere.expandByPoint(wc)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const i=this.material,n=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ih.copy(this.boundingSphere),Ih.applyMatrix4(n),t.ray.intersectsSphere(Ih)!==!1&&(qf.copy(n).invert(),Ch.copy(t.ray).applyMatrix4(qf),!(this.boundingBox!==null&&Ch.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,Ch)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new ne,e=this.geometry.attributes.skinWeight;for(let i=0,n=e.count;i<n;i++){t.fromBufferAttribute(e,i);const s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),e.setXYZW(i,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===bf?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===A2?this.bindMatrixInverse.copy(this.bindMatrix).invert():Rt("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const i=this.skeleton,n=this.geometry;Wf.fromBufferAttribute(n.attributes.skinIndex,t),Xf.fromBufferAttribute(n.attributes.skinWeight,t),e.isVector4?(jr.copy(e),e.set(0,0,0,0)):(jr.set(...e,1),e.set(0,0,0)),jr.applyMatrix4(this.bindMatrix);for(let s=0;s<4;s++){const a=Xf.getComponent(s);if(a!==0){const o=Wf.getComponent(s);Yf.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),e.addScaledVector(TM.copy(jr).applyMatrix4(Yf),a)}}return e.isVector4&&(e.w=jr.w),e.applyMatrix4(this.bindMatrixInverse)}}class RM extends Be{constructor(){super(),this.isBone=!0,this.type="Bone"}}class ra extends bi{constructor(t=null,e=1,i=1,n,s,a,o,c,l=Re,h=Re,u,d){super(null,a,o,c,l,h,n,s,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const $f=new Jt,DM=new Jt;class zg{constructor(t=[],e=[]){this.uuid=Nn(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){Rt("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,n=this.bones.length;i<n;i++)this.boneInverses.push(new Jt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const i=new Jt;this.bones[t]&&i.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const i=this.bones[t];i&&i.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const i=this.bones[t];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const t=this.bones,e=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let s=0,a=t.length;s<a;s++){const o=t[s]?t[s].matrixWorld:DM;$f.multiplyMatrices(o,e[s]),$f.toArray(i,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new zg(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const i=new ra(e,t,t,Ei,Oi);return i.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=i,this}getBoneByName(t){for(let e=0,i=this.bones.length;e<i;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let i=0,n=t.bones.length;i<n;i++){const s=t.bones[i];let a=e[s];a===void 0&&(Rt("Skeleton: No bone found with UUID:",s),a=new RM),this.bones.push(a),this.boneInverses.push(new Jt().fromArray(t.boneInverses[i]))}return this.init(),this}toJSON(){const t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,i=this.boneInverses;for(let n=0,s=e.length;n<s;n++){const a=e[n];t.bones.push(a.uuid);const o=i[n];t.boneInverses.push(o.toArray())}return t}}class Kf extends ie{constructor(t,e,i,n=1){super(t,e,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const nr=new Jt,Zf=new Jt,Ec=[],Jf=new Vi,IM=new Jt,Qr=new Dt,to=new Rs;class iA extends Dt{constructor(t,e,i){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Kf(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,IM)}computeBoundingBox(){const t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new Vi),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,nr),Jf.copy(t.boundingBox).applyMatrix4(nr),this.boundingBox.union(Jf)}computeBoundingSphere(){const t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new Rs),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,nr),to.copy(t.boundingSphere).applyMatrix4(nr),this.boundingSphere.union(to)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){return this.instanceColor===null?e.setRGB(1,1,1):e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){return e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){const i=e.morphTargetInfluences,n=this.morphTexture.source.data.data,s=i.length+1,a=t*s+1;for(let o=0;o<i.length;o++)i[o]=n[a+o]}raycast(t,e){const i=this.matrixWorld,n=this.count;if(Qr.geometry=this.geometry,Qr.material=this.material,Qr.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),to.copy(this.boundingSphere),to.applyMatrix4(i),t.ray.intersectsSphere(to)!==!1))for(let s=0;s<n;s++){this.getMatrixAt(s,nr),Zf.multiplyMatrices(i,nr),Qr.matrixWorld=Zf,Qr.raycast(t,Ec);for(let a=0,o=Ec.length;a<o;a++){const c=Ec[a];c.instanceId=s,c.object=this,e.push(c)}Ec.length=0}}setColorAt(t,e){return this.instanceColor===null&&(this.instanceColor=new Kf(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),e.toArray(this.instanceColor.array,t*3),this}setMatrixAt(t,e){return e.toArray(this.instanceMatrix.array,t*16),this}setMorphAt(t,e){const i=e.morphTargetInfluences,n=i.length+1;this.morphTexture===null&&(this.morphTexture=new ra(new Float32Array(n*this.count),n,this.count,Hl,Oi));const s=this.morphTexture.source.data.data;let a=0;for(let l=0;l<i.length;l++)a+=i[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=n*t;return s[c]=o,s.set(i,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Ph=new R,CM=new R,PM=new Yt;class ma{constructor(t=new R(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=Ph.subVectors(i,e).cross(CM.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,i=!0){const n=t.delta(Ph),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const a=-(t.start.dot(this.normal)+this.constant)/s;return i===!0&&(a<0||a>1)?null:e.copy(t.start).addScaledVector(n,a)}intersectsLine(t){const 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){const i=e||PM.getNormalMatrix(t),n=this.coplanarPoint(Ph).applyMatrix4(t),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),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)}}const ua=new Rs,LM=new xt(.5,.5),Ac=new R;class g0{constructor(t=new ma,e=new ma,i=new ma,n=new ma,s=new ma,a=new ma){this.planes=[t,e,i,n,s,a]}set(t,e,i,n,s,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(i),o[3].copy(n),o[4].copy(s),o[5].copy(a),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=ns,i=!1){const n=this.planes,s=t.elements,a=s[0],o=s[1],c=s[2],l=s[3],h=s[4],u=s[5],d=s[6],f=s[7],p=s[8],v=s[9],m=s[10],g=s[11],S=s[12],y=s[13],M=s[14],b=s[15];if(n[0].setComponents(l-a,f-h,g-p,b-S).normalize(),n[1].setComponents(l+a,f+h,g+p,b+S).normalize(),n[2].setComponents(l+o,f+u,g+v,b+y).normalize(),n[3].setComponents(l-o,f-u,g-v,b-y).normalize(),i)n[4].setComponents(c,d,m,M).normalize(),n[5].setComponents(l-c,f-d,g-m,b-M).normalize();else if(n[4].setComponents(l-c,f-d,g-m,b-M).normalize(),e===ns)n[5].setComponents(l+c,f+d,g+m,b+M).normalize();else if(e===Ho)n[5].setComponents(c,d,m,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),ua.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),ua.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(ua)}intersectsSprite(t){ua.center.set(0,0,0);const e=LM.distanceTo(t.center);return ua.radius=.7071067811865476+e,ua.applyMatrix4(t.matrixWorld),this.intersectsSphere(ua)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(i)<n)return!1;return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const n=e[i];if(Ac.x=n.normal.x>0?t.max.x:t.min.x,Ac.y=n.normal.y>0?t.max.y:t.min.y,Ac.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(Ac)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class OM extends Ds{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new st(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const wl=new R,El=new R,jf=new Jt,eo=new Yo,Tc=new Rs,Lh=new R,Qf=new R;class Bg extends Be{constructor(t=new ce,e=new OM){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,i=[0];for(let n=1,s=e.count;n<s;n++)wl.fromBufferAttribute(e,n-1),El.fromBufferAttribute(e,n),i[n]=i[n-1],i[n]+=wl.distanceTo(El);t.setAttribute("lineDistance",new de(i,1))}else Rt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,s=t.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Tc.copy(i.boundingSphere),Tc.applyMatrix4(n),Tc.radius+=s,t.ray.intersectsSphere(Tc)===!1)return;jf.copy(n).invert(),eo.copy(t.ray).applyMatrix4(jf);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=i.index,d=i.attributes.position;if(h!==null){const f=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let v=f,m=p-1;v<m;v+=l){const g=h.getX(v),S=h.getX(v+1),y=Rc(this,t,eo,c,g,S,v);y&&e.push(y)}if(this.isLineLoop){const v=h.getX(p-1),m=h.getX(f),g=Rc(this,t,eo,c,v,m,p-1);g&&e.push(g)}}else{const f=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let v=f,m=p-1;v<m;v+=l){const g=Rc(this,t,eo,c,v,v+1,v);g&&e.push(g)}if(this.isLineLoop){const v=Rc(this,t,eo,c,p-1,f,p-1);v&&e.push(v)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=n.length;s<a;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function Rc(r,t,e,i,n,s,a){const o=r.geometry.attributes.position;if(wl.fromBufferAttribute(o,n),El.fromBufferAttribute(o,s),e.distanceSqToSegment(wl,El,Lh,Qf)>i)return;Lh.applyMatrix4(r.matrixWorld);const l=t.ray.origin.distanceTo(Lh);if(!(l<t.near||l>t.far))return{distance:l,point:Qf.clone().applyMatrix4(r.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:r}}const tp=new R,ep=new R;class nA extends Bg{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,i=[];for(let n=0,s=e.count;n<s;n+=2)tp.fromBufferAttribute(e,n),ep.fromBufferAttribute(e,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+tp.distanceTo(ep);t.setAttribute("lineDistance",new de(i,1))}else Rt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class sA extends Bg{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Hg extends Ds{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new st(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const ip=new Jt,fd=new Yo,Dc=new Rs,Ic=new R;class xs extends Be{constructor(t=new ce,e=new Hg){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,s=t.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Dc.copy(i.boundingSphere),Dc.applyMatrix4(n),Dc.radius+=s,t.ray.intersectsSphere(Dc)===!1)return;ip.copy(n).invert(),fd.copy(t.ray).applyMatrix4(ip);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=i.index,u=i.attributes.position;if(l!==null){const d=Math.max(0,a.start),f=Math.min(l.count,a.start+a.count);for(let p=d,v=f;p<v;p++){const m=l.getX(p);Ic.fromBufferAttribute(u,m),np(Ic,m,c,n,t,e,this)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let p=d,v=f;p<v;p++)Ic.fromBufferAttribute(u,p),np(Ic,p,c,n,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=n.length;s<a;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function np(r,t,e,i,n,s,a){const o=fd.distanceSqToPoint(r);if(o<e){const c=new R;fd.closestPointToPoint(r,c),c.applyMatrix4(i);const l=n.ray.origin.distanceTo(c);if(l<n.near||l>n.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}class Gg extends bi{constructor(t=[],e=Oa,i,n,s,a,o,c,l,h){super(t,e,i,n,s,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Is extends bi{constructor(t,e,i,n,s,a,o,c,l){super(t,e,i,n,s,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class na extends bi{constructor(t,e,i=Sn,n,s,a,o=Re,c=Re,l,h=Es,u=1){if(h!==Es&&h!==Ea)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,n,s,a,o,c,h,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new d0(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class NM extends na{constructor(t,e=Sn,i=Oa,n,s,a=Re,o=Re,c,l=Es){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,i,n,s,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class Vg extends bi{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Wi extends ce{constructor(t=1,e=1,i=1,n=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:s,depthSegments:a};const o=this;n=Math.floor(n),s=Math.floor(s),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,i,e,t,a,s,0),p("z","y","x",1,-1,i,e,-t,a,s,1),p("x","z","y",1,1,t,i,e,n,a,2),p("x","z","y",1,-1,t,i,-e,n,a,3),p("x","y","z",1,-1,t,e,i,n,s,4),p("x","y","z",-1,-1,t,e,-i,n,s,5),this.setIndex(c),this.setAttribute("position",new de(l,3)),this.setAttribute("normal",new de(h,3)),this.setAttribute("uv",new de(u,2));function p(v,m,g,S,y,M,b,w,T,x,A){const C=M/T,I=b/x,P=M/2,V=b/2,X=w/2,L=T+1,B=x+1;let k=0,$=0;const tt=new R;for(let J=0;J<B;J++){const it=J*I-V;for(let rt=0;rt<L;rt++){const Vt=rt*C-P;tt[v]=Vt*S,tt[m]=it*y,tt[g]=X,l.push(tt.x,tt.y,tt.z),tt[v]=0,tt[m]=0,tt[g]=w>0?1:-1,h.push(tt.x,tt.y,tt.z),u.push(rt/T),u.push(1-J/x),k+=1}}for(let J=0;J<x;J++)for(let it=0;it<T;it++){const rt=d+it+L*J,Vt=d+it+L*(J+1),jt=d+(it+1)+L*(J+1),qt=d+(it+1)+L*J;c.push(rt,Vt,qt),c.push(Vt,jt,qt),$+=6}o.addGroup(f,$,A),f+=$,d+=k}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Wi(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class v0 extends ce{constructor(t=1,e=32,i=0,n=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},e=Math.max(3,e);const s=[],a=[],o=[],c=[],l=new R,h=new xt;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=i+u/e*n;l.x=t*Math.cos(f),l.y=t*Math.sin(f),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/t+1)/2,h.y=(a[d+1]/t+1)/2,c.push(h.x,h.y)}for(let u=1;u<=e;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new de(a,3)),this.setAttribute("normal",new de(o,3)),this.setAttribute("uv",new de(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new v0(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class cs extends ce{constructor(t=1,e=1,i=1,n=32,s=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:c};const l=this;n=Math.floor(n),s=Math.floor(s);const h=[],u=[],d=[],f=[];let p=0;const v=[],m=i/2;let g=0;S(),a===!1&&(t>0&&y(!0),e>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new de(u,3)),this.setAttribute("normal",new de(d,3)),this.setAttribute("uv",new de(f,2));function S(){const M=new R,b=new R;let w=0;const T=(e-t)/i;for(let x=0;x<=s;x++){const A=[],C=x/s,I=C*(e-t)+t;for(let P=0;P<=n;P++){const V=P/n,X=V*c+o,L=Math.sin(X),B=Math.cos(X);b.x=I*L,b.y=-C*i+m,b.z=I*B,u.push(b.x,b.y,b.z),M.set(L,T,B).normalize(),d.push(M.x,M.y,M.z),f.push(V,1-C),A.push(p++)}v.push(A)}for(let x=0;x<n;x++)for(let A=0;A<s;A++){const C=v[A][x],I=v[A+1][x],P=v[A+1][x+1],V=v[A][x+1];(t>0||A!==0)&&(h.push(C,I,V),w+=3),(e>0||A!==s-1)&&(h.push(I,P,V),w+=3)}l.addGroup(g,w,0),g+=w}function y(M){const b=p,w=new xt,T=new R;let x=0;const A=M===!0?t:e,C=M===!0?1:-1;for(let P=1;P<=n;P++)u.push(0,m*C,0),d.push(0,C,0),f.push(.5,.5),p++;const I=p;for(let P=0;P<=n;P++){const X=P/n*c+o,L=Math.cos(X),B=Math.sin(X);T.x=A*B,T.y=m*C,T.z=A*L,u.push(T.x,T.y,T.z),d.push(0,C,0),w.x=L*.5+.5,w.y=B*.5*C+.5,f.push(w.x,w.y),p++}for(let P=0;P<n;P++){const V=b+P,X=I+P;M===!0?h.push(X,X+1,V):h.push(X+1,X,V),x+=3}l.addGroup(g,x,M===!0?1:2),g+=x}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new cs(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ur extends cs{constructor(t=1,e=1,i=32,n=1,s=!1,a=0,o=Math.PI*2){super(0,t,e,i,n,s,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(t){return new Ur(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Gl extends ce{constructor(t=[new xt(0,-.5),new xt(.5,0),new xt(0,.5)],e=12,i=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:n},e=Math.floor(e),n=ee(n,0,Math.PI*2);const s=[],a=[],o=[],c=[],l=[],h=1/e,u=new R,d=new xt,f=new R,p=new R,v=new R;let m=0,g=0;for(let S=0;S<=t.length-1;S++)switch(S){case 0:m=t[S+1].x-t[S].x,g=t[S+1].y-t[S].y,f.x=g*1,f.y=-m,f.z=g*0,v.copy(f),f.normalize(),c.push(f.x,f.y,f.z);break;case t.length-1:c.push(v.x,v.y,v.z);break;default:m=t[S+1].x-t[S].x,g=t[S+1].y-t[S].y,f.x=g*1,f.y=-m,f.z=g*0,p.copy(f),f.x+=v.x,f.y+=v.y,f.z+=v.z,f.normalize(),c.push(f.x,f.y,f.z),v.copy(p)}for(let S=0;S<=e;S++){const y=i+S*h*n,M=Math.sin(y),b=Math.cos(y);for(let w=0;w<=t.length-1;w++){u.x=t[w].x*M,u.y=t[w].y,u.z=t[w].x*b,a.push(u.x,u.y,u.z),d.x=S/e,d.y=w/(t.length-1),o.push(d.x,d.y);const T=c[3*w+0]*M,x=c[3*w+1],A=c[3*w+0]*b;l.push(T,x,A)}}for(let S=0;S<e;S++)for(let y=0;y<t.length-1;y++){const M=y+S*t.length,b=M,w=M+t.length,T=M+t.length+1,x=M+1;s.push(b,w,x),s.push(T,x,w)}this.setIndex(s),this.setAttribute("position",new de(a,3)),this.setAttribute("uv",new de(o,2)),this.setAttribute("normal",new de(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Gl(t.points,t.segments,t.phiStart,t.phiLength)}}class Xi extends ce{constructor(t=1,e=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};const s=t/2,a=e/2,o=Math.floor(i),c=Math.floor(n),l=o+1,h=c+1,u=t/o,d=e/c,f=[],p=[],v=[],m=[];for(let g=0;g<h;g++){const S=g*d-a;for(let y=0;y<l;y++){const M=y*u-s;p.push(M,-S,0),v.push(0,0,1),m.push(y/o),m.push(1-g/c)}}for(let g=0;g<c;g++)for(let S=0;S<o;S++){const y=S+l*g,M=S+l*(g+1),b=S+1+l*(g+1),w=S+1+l*g;f.push(y,M,w),f.push(M,b,w)}this.setIndex(f),this.setAttribute("position",new de(p,3)),this.setAttribute("normal",new de(v,3)),this.setAttribute("uv",new de(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Xi(t.width,t.height,t.widthSegments,t.heightSegments)}}class oi extends ce{constructor(t=1,e=32,i=16,n=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:s,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const c=Math.min(a+o,Math.PI);let l=0;const h=[],u=new R,d=new R,f=[],p=[],v=[],m=[];for(let g=0;g<=i;g++){const S=[],y=g/i,M=a+y*o,b=t*Math.cos(M),w=Math.sqrt(t*t-b*b);let T=0;g===0&&a===0?T=.5/e:g===i&&c===Math.PI&&(T=-.5/e);for(let x=0;x<=e;x++){const A=x/e,C=n+A*s;u.x=-w*Math.cos(C),u.y=b,u.z=w*Math.sin(C),p.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),m.push(A+T,1-y),S.push(l++)}h.push(S)}for(let g=0;g<i;g++)for(let S=0;S<e;S++){const y=h[g][S+1],M=h[g][S],b=h[g+1][S],w=h[g+1][S+1];(g!==0||a>0)&&f.push(y,M,w),(g!==i-1||c<Math.PI)&&f.push(M,b,w)}this.setIndex(f),this.setAttribute("position",new de(p,3)),this.setAttribute("normal",new de(v,3)),this.setAttribute("uv",new de(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new oi(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class M0 extends ce{constructor(t=1,e=.4,i=12,n=48,s=Math.PI*2,a=0,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:s,thetaStart:a,thetaLength:o},i=Math.floor(i),n=Math.floor(n);const c=[],l=[],h=[],u=[],d=new R,f=new R,p=new R;for(let v=0;v<=i;v++){const m=a+v/i*o;for(let g=0;g<=n;g++){const S=g/n*s;f.x=(t+e*Math.cos(m))*Math.cos(S),f.y=(t+e*Math.cos(m))*Math.sin(S),f.z=e*Math.sin(m),l.push(f.x,f.y,f.z),d.x=t*Math.cos(S),d.y=t*Math.sin(S),p.subVectors(f,d).normalize(),h.push(p.x,p.y,p.z),u.push(g/n),u.push(v/i)}}for(let v=1;v<=i;v++)for(let m=1;m<=n;m++){const g=(n+1)*v+m-1,S=(n+1)*(v-1)+m-1,y=(n+1)*(v-1)+m,M=(n+1)*v+m;c.push(g,S,M),c.push(S,y,M)}this.setIndex(c),this.setAttribute("position",new de(l,3)),this.setAttribute("normal",new de(h,3)),this.setAttribute("uv",new de(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new M0(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}function Nr(r){const t={};for(const e in r){t[e]={};for(const i in r[e]){const n=r[e][i];if(sp(n))n.isRenderTargetTexture?(Rt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][i]=null):t[e][i]=n.clone();else if(Array.isArray(n))if(sp(n[0])){const s=[];for(let a=0,o=n.length;a<o;a++)s[a]=n[a].clone();t[e][i]=s}else t[e][i]=n.slice();else t[e][i]=n}}return t}function Ui(r){const t={};for(let e=0;e<r.length;e++){const i=Nr(r[e]);for(const n in i)t[n]=i[n]}return t}function sp(r){return r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)}function FM(r){const t=[];for(let e=0;e<r.length;e++)t.push(r[e].clone());return t}function Wg(r){const t=r.getRenderTarget();return t===null?r.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:re.workingColorSpace}const UM={clone:Nr,merge:Ui};var kM=`void main() {
1101
1158
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
1102
1159
  }`,zM=`void main() {
1103
1160
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
1104
- }`;class le extends Ds{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=kM,this.fragmentShader=zM,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Nr(t.uniforms),this.uniformsGroups=FM(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const n in this.uniforms){const a=this.uniforms[n].value;a&&a.isTexture?e.uniforms[n]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[n]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[n]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[n]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[n]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[n]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[n]={type:"m4",value:a.toArray()}:e.uniforms[n]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const i={};for(const n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(const i in t.uniforms){const n=t.uniforms[i];switch(this.uniforms[i]={},n.type){case"t":this.uniforms[i].value=e[n.value]||null;break;case"c":this.uniforms[i].value=new st().setHex(n.value);break;case"v2":this.uniforms[i].value=new xt().fromArray(n.value);break;case"v3":this.uniforms[i].value=new R().fromArray(n.value);break;case"v4":this.uniforms[i].value=new ne().fromArray(n.value);break;case"m3":this.uniforms[i].value=new Yt().fromArray(n.value);break;case"m4":this.uniforms[i].value=new Zt().fromArray(n.value);break;default:this.uniforms[i].value=n.value}}if(t.defines!==void 0&&(this.defines=t.defines),t.vertexShader!==void 0&&(this.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(this.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(this.glslVersion=t.glslVersion),t.extensions!==void 0)for(const i in t.extensions)this.extensions[i]=t.extensions[i];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}}class Xg extends le{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class xa extends Ds{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new st(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new st(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ml,this.normalScale=new xt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new As,this.envMapIntensity=1,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.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,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.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,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 BM extends xa{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new xt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return te(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new st(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new st(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new st(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=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 kr extends Ds{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new st(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new st(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ml,this.normalScale=new xt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new As,this.combine=e0,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=t.envMapIntensity,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 HM extends Ds{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=C2,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 GM extends Ds{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}}function Cc(r,t){return!r||r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function VM(r){function t(n,s){return r[n]-r[s]}const e=r.length,i=new Array(e);for(let n=0;n!==e;++n)i[n]=n;return i.sort(t),i}function ap(r,t,e){const i=r.length,n=new r.constructor(i);for(let s=0,a=0;a!==i;++s){const o=e[s]*t;for(let c=0;c!==t;++c)n[a++]=r[o+c]}return n}function WM(r,t,e,i){let n=1,s=r[0];for(;s!==void 0&&s[i]===void 0;)s=r[n++];if(s===void 0)return;let a=s[i];if(a!==void 0)if(Array.isArray(a))do a=s[i],a!==void 0&&(t.push(s.time),e.push(...a)),s=r[n++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[i],a!==void 0&&(t.push(s.time),a.toArray(e,e.length)),s=r[n++];while(s!==void 0);else do a=s[i],a!==void 0&&(t.push(s.time),e.push(a)),s=r[n++];while(s!==void 0)}class qo{constructor(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let i=this._cachedIndex,n=e[i],s=e[i-1];t:{e:{let a;i:{n:if(!(t<n)){for(let o=i+2;;){if(n===void 0){if(t<s)break n;return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=n,n=e[++i],t<n)break e}a=e.length;break i}if(!(t>=s)){const o=e[1];t<o&&(i=2,s=o);for(let c=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(n=s,s=e[--i-1],t>=s)break e}a=i,i=0;break i}break t}for(;i<a;){const o=i+a>>>1;t<e[o]?a=o:i=o+1}if(n=e[i],s=e[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=t*n;for(let a=0;a!==n;++a)e[a]=i[s+a];return e}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class XM extends qo{constructor(t,e,i,n){super(t,e,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:fr,endingEnd:fr}}intervalChanged_(t,e,i){const n=this.parameterPositions;let s=t-2,a=t+1,o=n[s],c=n[a];if(o===void 0)switch(this.getSettings_().endingStart){case pr:s=t,o=2*e-i;break;case vl:s=n.length-2,o=e+n[s]-n[s+1];break;default:s=t,o=i}if(c===void 0)switch(this.getSettings_().endingEnd){case pr:a=t,c=2*i-e;break;case vl:a=1,c=i+n[1]-n[0];break;default:a=t-1,c=e}const l=(i-e)*.5,h=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(c-i),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(t,e,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(i-e)/(n-e),v=p*p,m=v*p,g=-d*m+2*d*v-d*p,S=(1+d)*m+(-1.5-2*d)*v+(-.5+d)*p+1,y=(-1-f)*m+(1.5+f)*v+.5*p,M=f*m-f*v;for(let b=0;b!==o;++b)s[b]=g*a[h+b]+S*a[l+b]+y*a[c+b]+M*a[u+b];return s}}class Yg extends qo{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=(i-e)/(n-e),u=1-h;for(let d=0;d!==o;++d)s[d]=a[l+d]*u+a[c+d]*h;return s}}class YM extends qo{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t){return this.copySampleValue_(t-1)}}class qM extends qo{interpolate_(t,e,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const p=(i-e)/(n-e),v=1-p;for(let m=0;m!==o;++m)s[m]=a[l+m]*v+a[c+m]*p;return s}const d=o*2,f=t-1;for(let p=0;p!==o;++p){const v=a[l+p],m=a[c+p],g=f*d+p*2,S=u[g],y=u[g+1],M=t*d+p*2,b=h[M],w=h[M+1];let T=(i-e)/(n-e),x,A,C,I,P;for(let V=0;V<8;V++){x=T*T,A=x*T,C=1-T,I=C*C,P=I*C;const L=P*e+3*I*T*S+3*C*x*b+A*n-i;if(Math.abs(L)<1e-10)break;const B=3*I*(S-e)+6*C*T*(b-S)+3*x*(n-b);if(Math.abs(B)<1e-10)break;T=T-L/B,T=Math.max(0,Math.min(1,T))}s[p]=P*v+3*I*T*y+3*C*x*w+A*m}return s}}class kn{constructor(t,e,i,n){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Cc(e,this.TimeBufferType),this.values=Cc(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let i;if(e.toJSON!==this.toJSON)i=e.toJSON(t);else{i={name:t.name,times:Cc(t.times,Array),values:Cc(t.values,Array)};const n=t.getInterpolation();n!==t.DefaultInterpolation&&(i.interpolation=n)}return i.type=t.ValueTypeName,i}InterpolantFactoryMethodDiscrete(t){return new YM(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Yg(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new XM(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){const e=new qM(this.times,this.values,this.getValueSize(),t);return this.settings&&(e.inTangents=this.settings.inTangents,e.outTangents=this.settings.outTangents),e}setInterpolation(t){let e;switch(t){case gl:e=this.InterpolantFactoryMethodDiscrete;break;case ud:e=this.InterpolantFactoryMethodLinear;break;case oh:e=this.InterpolantFactoryMethodSmooth;break;case wf:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return Rt("KeyframeTrack:",i),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return gl;case this.InterpolantFactoryMethodLinear:return ud;case this.InterpolantFactoryMethodSmooth:return oh;case this.InterpolantFactoryMethodBezier:return wf}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]*=t}return this}trim(t,e){const i=this.times,n=i.length;let s=0,a=n-1;for(;s!==n&&i[s]<t;)++s;for(;a!==-1&&i[a]>e;)--a;if(++a,s!==0||a!==n){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=i.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(Gt("KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,n=this.values,s=i.length;s===0&&(Gt("KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==s;o++){const c=i[o];if(typeof c=="number"&&isNaN(c)){Gt("KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(a!==null&&a>c){Gt("KeyframeTrack: Out of order keys.",this,o,c,a),t=!1;break}a=c}if(n!==void 0&&B2(n))for(let o=0,c=n.length;o!==c;++o){const l=n[o];if(isNaN(l)){Gt("KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===oh,s=t.length-1;let a=1;for(let o=1;o<s;++o){let c=!1;const l=t[o],h=t[o+1];if(l!==h&&(o!==1||l!==t[0]))if(n)c=!0;else{const u=o*i,d=u-i,f=u+i;for(let p=0;p!==i;++p){const v=e[u+p];if(v!==e[d+p]||v!==e[f+p]){c=!0;break}}}if(c){if(o!==a){t[a]=t[o];const u=o*i,d=a*i;for(let f=0;f!==i;++f)e[d+f]=e[u+f]}++a}}if(s>0){t[a]=t[s];for(let o=s*i,c=a*i,l=0;l!==i;++l)e[c+l]=e[o+l];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*i)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),i=this.constructor,n=new i(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}kn.prototype.ValueTypeName="";kn.prototype.TimeBufferType=Float32Array;kn.prototype.ValueBufferType=Float32Array;kn.prototype.DefaultInterpolation=ud;class zr extends kn{constructor(t,e,i){super(t,e,i)}}zr.prototype.ValueTypeName="bool";zr.prototype.ValueBufferType=Array;zr.prototype.DefaultInterpolation=gl;zr.prototype.InterpolantFactoryMethodLinear=void 0;zr.prototype.InterpolantFactoryMethodSmooth=void 0;class qg extends kn{constructor(t,e,i,n){super(t,e,i,n)}}qg.prototype.ValueTypeName="color";class x0 extends kn{constructor(t,e,i,n){super(t,e,i,n)}}x0.prototype.ValueTypeName="number";class $M extends qo{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(i-e)/(n-e);let l=t*o;for(let h=l+o;l!==h;l+=4)Qi.slerpFlat(s,0,a,l-o,a,l,c);return s}}class y0 extends kn{constructor(t,e,i,n){super(t,e,i,n)}InterpolantFactoryMethodLinear(t){return new $M(this.times,this.values,this.getValueSize(),t)}}y0.prototype.ValueTypeName="quaternion";y0.prototype.InterpolantFactoryMethodSmooth=void 0;class Br extends kn{constructor(t,e,i){super(t,e,i)}}Br.prototype.ValueTypeName="string";Br.prototype.ValueBufferType=Array;Br.prototype.DefaultInterpolation=gl;Br.prototype.InterpolantFactoryMethodLinear=void 0;Br.prototype.InterpolantFactoryMethodSmooth=void 0;class $g extends kn{constructor(t,e,i,n){super(t,e,i,n)}}$g.prototype.ValueTypeName="vector";class rp{constructor(t="",e=-1,i=[],n=c0){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=Nn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let a=0,o=i.length;a!==o;++a)e.push(ZM(i[a]).scale(n));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s.userData=JSON.parse(t.userData||"{}"),s}static toJSON(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let s=0,a=i.length;s!==a;++s)e.push(kn.toJSON(i[s]));return n}static CreateFromMorphTargetSequence(t,e,i,n){const s=e.length,a=[];for(let o=0;o<s;o++){let c=[],l=[];c.push((o+s-1)%s,o,(o+1)%s),l.push(0,1,0);const h=VM(c);c=ap(c,1,h),l=ap(l,1,h),!n&&c[0]===0&&(c.push(s),l.push(l[0])),a.push(new x0(".morphTargetInfluences["+e[o].name+"]",c,l).scale(1/i))}return new this(t,-1,a)}static findByName(t,e){let i=t;if(!Array.isArray(t)){const n=t;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===e)return i[n];return null}static CreateClipsFromMorphTargetSequences(t,e,i){const n={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,c=t.length;o<c;o++){const l=t[o],h=l.name.match(s);if(h&&h.length>1){const u=h[1];let d=n[u];d||(n[u]=d=[]),d.push(l)}}const a=[];for(const o in n)a.push(this.CreateFromMorphTargetSequence(o,n[o],e,i));return a}resetDuration(){const t=this.tracks;let e=0;for(let i=0,n=t.length;i!==n;++i){const s=this.tracks[i];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let i=0;i<this.tracks.length;i++)t.push(this.tracks[i].clone());const e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}}function KM(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return x0;case"vector":case"vector2":case"vector3":case"vector4":return $g;case"color":return qg;case"quaternion":return y0;case"bool":case"boolean":return zr;case"string":return Br}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function ZM(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=KM(r.type);if(r.times===void 0){const e=[],i=[];WM(r.keys,e,i,"value"),r.times=e,r.values=i}return t.parse!==void 0?t.parse(r):new t(r.name,r.times,r.values,r.interpolation)}const bs={enabled:!1,files:{},add:function(r,t){this.enabled!==!1&&(op(r)||(this.files[r]=t))},get:function(r){if(this.enabled!==!1&&!op(r))return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};function op(r){try{const t=r.slice(r.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}class JM{constructor(t,e,i){const n=this;let s=!1,a=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this._abortController=null,this.itemStart=function(h){o++,s===!1&&n.onStart!==void 0&&n.onStart(h,a,o),s=!0},this.itemEnd=function(h){a++,n.onProgress!==void 0&&n.onProgress(h,a,o),a===o&&(s=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(h){n.onError!==void 0&&n.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const f=l[u],p=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const jM=new JM;class $o{constructor(t){this.manager=t!==void 0?t:jM,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){const i=this;return new Promise(function(n,s){i.load(t,n,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}$o.DEFAULT_MATERIAL_NAME="__DEFAULT";const ps={};class QM extends Error{constructor(t,e){super(t),this.response=e}}class aA extends $o{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,i,n){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=bs.get(`file:${t}`);if(s!==void 0){this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0);return}if(ps[t]!==void 0){ps[t].push({onLoad:e,onProgress:i,onError:n});return}ps[t]=[],ps[t].push({onLoad:e,onProgress:i,onError:n});const a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&Rt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=ps[t],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=d?parseInt(d):0,p=f!==0;let v=0;const m=new ReadableStream({start(g){S();function S(){u.read().then(({done:y,value:M})=>{if(y)g.close();else{v+=M.byteLength;const b=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:f});for(let w=0,T=h.length;w<T;w++){const x=h[w];x.onProgress&&x.onProgress(b)}g.enqueue(M),S()}},y=>{g.error(y)})}}});return new Response(m)}else throw new QM(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o==="")return l.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return l.arrayBuffer().then(p=>f.decode(p))}}}).then(l=>{bs.add(`file:${t}`,l);const h=ps[t];delete ps[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=ps[t];if(h===void 0)throw this.manager.itemError(t),l;delete ps[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(l)}this.manager.itemError(t)}).finally(()=>{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}}const sr=new WeakMap;class tx extends $o{constructor(t){super(t)}load(t,e,i,n){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,a=bs.get(`image:${t}`);if(a!==void 0){if(a.complete===!0)s.manager.itemStart(t),setTimeout(function(){e&&e(a),s.manager.itemEnd(t)},0);else{let u=sr.get(a);u===void 0&&(u=[],sr.set(a,u)),u.push({onLoad:e,onError:n})}return a}const o=Go("img");function c(){h(),e&&e(this);const u=sr.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}sr.delete(this),s.manager.itemEnd(t)}function l(u){h(),n&&n(u),bs.remove(`image:${t}`);const d=sr.get(this)||[];for(let f=0;f<d.length;f++){const p=d[f];p.onError&&p.onError(u)}sr.delete(this),s.manager.itemError(t),s.manager.itemEnd(t)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),bs.add(`image:${t}`,o),s.manager.itemStart(t),o.src=t,o}}class rA extends $o{constructor(t){super(t)}load(t,e,i,n){const s=new bi,a=new tx(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,function(o){s.image=o,s.needsUpdate=!0,e!==void 0&&e(s)},i,n),s}}class Vl extends Be{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new st(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}class ex extends Vl{constructor(t,e,i){super(t,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Be.DEFAULT_UP),this.updateMatrix(),this.groundColor=new st(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}}const Oh=new Zt,cp=new R,lp=new R;class _0{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new xt(512,512),this.mapType=un,this.map=null,this.mapPass=null,this.matrix=new Zt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new g0,this._frameExtents=new xt(1,1),this._viewportCount=1,this._viewports=[new ne(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;cp.setFromMatrixPosition(t.matrixWorld),e.position.copy(cp),lp.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(lp),e.updateMatrixWorld(),Oh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Oh,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===Ho||e.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Oh)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const Pc=new R,Lc=new Qi,Vn=new R;class Kg extends Be{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Zt,this.projectionMatrix=new Zt,this.projectionMatrixInverse=new Zt,this.coordinateSystem=ns,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.matrixWorld.decompose(Pc,Lc,Vn),Vn.x===1&&Vn.y===1&&Vn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Pc,Lc,Vn.set(1,1,1)).invert()}updateWorldMatrix(t,e,i=!1){super.updateWorldMatrix(t,e,i),this.matrixWorld.decompose(Pc,Lc,Vn),Vn.x===1&&Vn.y===1&&Vn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Pc,Lc,Vn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const zs=new R,hp=new xt,up=new xt;class Zi extends Kg{constructor(t=50,e=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,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=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=Or*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(bo*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Or*2*Math.atan(Math.tan(bo*.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){zs.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(zs.x,zs.y).multiplyScalar(-t/zs.z),zs.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(zs.x,zs.y).multiplyScalar(-t/zs.z)}getViewSize(t,e){return this.getViewBounds(t,hp,up),e.subVectors(up,hp)}setViewOffset(t,e,i,n,s,a){this.aspect=t/e,this.view===null&&(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=n,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(bo*.5*this.fov)/this.zoom,i=2*e,n=this.aspect*i,s=-.5*n;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;s+=a.offsetX*n/c,e-=a.offsetY*i/l,n*=a.width/c,i*=a.height/l}const o=this.filmOffset;o!==0&&(s+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,e,e-i,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const 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,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class ix extends _0{constructor(){super(new Zi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,i=Or*2*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,s=t.distance||e.far;(i!==e.fov||n!==e.aspect||s!==e.far)&&(e.fov=i,e.aspect=n,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class oA extends Vl{constructor(t,e,i=0,n=Math.PI/3,s=0,a=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Be.DEFAULT_UP),this.updateMatrix(),this.target=new Be,this.distance=i,this.angle=n,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new ix}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.map=t.map,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.angle=this.angle,e.object.decay=this.decay,e.object.penumbra=this.penumbra,e.object.target=this.target.uuid,this.map&&this.map.isTexture&&(e.object.map=this.map.toJSON(t).uuid),e.object.shadow=this.shadow.toJSON(),e}}class nx extends _0{constructor(){super(new Zi(90,1,.5,500)),this.isPointLightShadow=!0}}class Zg extends Vl{constructor(t,e,i=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new nx}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}}class Un extends Kg{constructor(t=-1,e=1,i=1,n=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,i,n,s,a){this.view===null&&(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=n,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let s=i-t,a=i+t,o=n+e,c=n-e;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,a=s+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class sx extends _0{constructor(){super(new Un(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class dp extends Vl{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Be.DEFAULT_UP),this.updateMatrix(),this.target=new Be,this.shadow=new sx}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}class cA{static extractUrlBase(t){const e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||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)}}const Nh=new WeakMap;class lA extends $o{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Rt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Rt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,i,n){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,a=bs.get(`image-bitmap:${t}`);if(a!==void 0){if(s.manager.itemStart(t),a.then){a.then(l=>{Nh.has(a)===!0?(n&&n(Nh.get(a)),s.manager.itemError(t),s.manager.itemEnd(t)):(e&&e(l),s.manager.itemEnd(t))});return}setTimeout(function(){e&&e(a),s.manager.itemEnd(t)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const c=fetch(t,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){bs.add(`image-bitmap:${t}`,l),e&&e(l),s.manager.itemEnd(t)}).catch(function(l){n&&n(l),Nh.set(c,l),bs.remove(`image-bitmap:${t}`),s.manager.itemError(t),s.manager.itemEnd(t)});bs.add(`image-bitmap:${t}`,c),s.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const ar=-90,rr=1;class S0 extends Be{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new Zi(ar,rr,t,e);n.layers=this.layers,this.add(n);const s=new Zi(ar,rr,t,e);s.layers=this.layers,this.add(s);const a=new Zi(ar,rr,t,e);a.layers=this.layers,this.add(a);const o=new Zi(ar,rr,t,e);o.layers=this.layers,this.add(o);const c=new Zi(ar,rr,t,e);c.layers=this.layers,this.add(c);const l=new Zi(ar,rr,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[i,n,s,a,o,c]=e;for(const l of e)this.remove(l);if(t===ns)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===Ho)i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,c,l,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;t.isWebGLRenderer===!0?m=t.state.buffers.depth.getReversed():m=t.reversedDepthBuffer,t.setRenderTarget(i,0,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,s),t.setRenderTarget(i,1,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(i,2,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(i,3,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),t.setRenderTarget(i,4,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),i.texture.generateMipmaps=v,t.setRenderTarget(i,5,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class ax extends Zi{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class rx{constructor(t,e,i){this.binding=t,this.valueSize=i;let n,s,a;switch(e){case"quaternion":n=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":n=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:n=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const i=this.buffer,n=this.valueSize,s=t*n+n;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==n;++o)i[s+o]=i[o];a=e}else{a+=e;const o=e/a;this._mixBufferRegion(i,s,0,o,n)}this.cumulativeWeight=a}accumulateAdditive(t){const e=this.buffer,i=this.valueSize,n=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,i),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,i=this.buffer,n=t*e+e,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const c=e*this._origIndex;this._mixBufferRegion(i,n,c,1-s,e)}a>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*e,1,e);for(let c=e,l=e+e;c!==l;++c)if(i[c]!==i[c+e]){o.setValue(i,n);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,n=i*this._origIndex;t.getValue(e,n);for(let s=i,a=n;s!==a;++s)e[s]=e[n+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i<e;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[e+i]=this.buffer[t+i]}_select(t,e,i,n,s){if(n>=.5)for(let a=0;a!==s;++a)t[e+a]=t[i+a]}_slerp(t,e,i,n){Qi.slerpFlat(t,e,t,e,t,i,n)}_slerpAdditive(t,e,i,n,s){const a=this._workIndex*s;Qi.multiplyQuaternionsFlat(t,a,t,e,t,i),Qi.slerpFlat(t,e,t,e,t,a,n)}_lerp(t,e,i,n,s){const a=1-n;for(let o=0;o!==s;++o){const c=e+o;t[c]=t[c]*a+t[i+o]*n}}_lerpAdditive(t,e,i,n,s){for(let a=0;a!==s;++a){const o=e+a;t[o]=t[o]+t[i+a]*n}}}const b0="\\[\\]\\.:\\/",ox=new RegExp("["+b0+"]","g"),w0="[^"+b0+"]",cx="[^"+b0.replace("\\.","")+"]",lx=/((?:WC+[\/:])*)/.source.replace("WC",w0),hx=/(WCOD+)?/.source.replace("WCOD",cx),ux=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",w0),dx=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",w0),fx=new RegExp("^"+lx+hx+ux+dx+"$"),px=["material","materials","bones","map"];class mx{constructor(t,e,i){const n=i||we.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(t,e)}setValue(t,e){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=i.length;n!==s;++n)i[n].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}}class we{constructor(t,e,i){this.path=e,this.parsedPath=i||we.parseTrackName(e),this.node=we.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 we.Composite(t,e,i):new we(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(ox,"")}static parseTrackName(t){const e=fx.exec(t);if(e===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const s=i.nodeName.substring(n+1);px.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(i!==void 0)return i}if(t.children){const i=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===e||o.uuid===e)return o;const c=i(o.children);if(c)return c}return null},n=i(t.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)t[e++]=i[n]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,i=e.objectName,n=e.propertyName;let s=e.propertyIndex;if(t||(t=we.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){Rt("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=e.objectIndex;switch(i){case"materials":if(!t.material){Gt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){Gt("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){Gt("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===l){l=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){Gt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){Gt("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[i]===void 0){Gt("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[i]}if(l!==void 0){if(t[l]===void 0){Gt("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}const a=t[n];if(a===void 0){const l=e.nodeName;Gt("PropertyBinding: Trying to update property for track: "+l+"."+n+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(n==="morphTargetInfluences"){if(!t.geometry){Gt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){Gt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=n;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}we.Composite=mx;we.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};we.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};we.prototype.GetterByBindingType=[we.prototype._getValue_direct,we.prototype._getValue_array,we.prototype._getValue_arrayElement,we.prototype._getValue_toArray];we.prototype.SetterByBindingTypeAndVersioning=[[we.prototype._setValue_direct,we.prototype._setValue_direct_setNeedsUpdate,we.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[we.prototype._setValue_array,we.prototype._setValue_array_setNeedsUpdate,we.prototype._setValue_array_setMatrixWorldNeedsUpdate],[we.prototype._setValue_arrayElement,we.prototype._setValue_arrayElement_setNeedsUpdate,we.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[we.prototype._setValue_fromArray,we.prototype._setValue_fromArray_setNeedsUpdate,we.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class gx{constructor(t,e,i=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=n;const s=e.tracks,a=s.length,o=new Array(a),c={endingStart:fr,endingEnd:fr};for(let l=0;l!==a;++l){const h=s[l].createInterpolant(null);o[l]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=R2,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&&this.timeScale!==0&&this._startTime===null&&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),i===!0){const n=this._clip.duration,s=t._clip.duration,a=s/n,o=n/s;t._restoreTimeScale=t.timeScale,this._restoreTimeScale=this.timeScale,t.warp(1,a,e),this.warp(o,1,e)}return this}crossFadeTo(t,e,i=!1){return t.crossFadeFrom(this,e,i)}stopFading(){const t=this._weightInterpolant;return t!==null&&(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){const n=this._mixer,s=n.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=n._lendControlInterpolant(),this._timeScaleInterpolant=o);const c=o.parameterPositions,l=o.sampleValues;return c[0]=s,c[1]=s+i,l[0]=t/a,l[1]=e/a,this}stopWarping(){const t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,n){if(!this.enabled){this._updateWeight(t);return}const s=this._startTime;if(s!==null){const c=(t-s)*i;c<0||i===0?e=0:(this._startTime=null,e=i*c)}e*=this._updateTimeScale(t);const a=this._updateTime(e),o=this._updateWeight(t);if(o>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case I2:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulateAdditive(o);break;case c0:default:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulate(n,o)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(i!==null){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(e===0?this.paused=!0:(this._restoreTimeScale!==null&&(e=this._restoreTimeScale),this.timeScale=e),this.stopWarping())}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let n=this.time+t,s=this._loopCount;const a=i===D2;if(t===0)return s===-1?n:a&&(s&1)===1?e-n:n;if(i===Pg){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else if(n<0)n=0;else{this.time=n;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),n>=e||n<0){const o=Math.floor(n/e);n-=e*o,s+=Math.abs(o);const c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(c===1){const l=t<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=s,this.time=n;if(a&&(s&1)===1)return e-n}return n}_setEndings(t,e,i){const n=this._interpolantSettings;i?(n.endingStart=pr,n.endingEnd=pr):(t?n.endingStart=this.zeroSlopeAtStart?pr:fr:n.endingStart=vl,e?n.endingEnd=this.zeroSlopeAtEnd?pr:fr:n.endingEnd=vl)}_scheduleFading(t,e,i){const n=this._mixer,s=n.time;let a=this._weightInterpolant;a===null&&(a=n._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,c=a.sampleValues;return o[0]=s,c[0]=e,o[1]=s+t,c[1]=i,this}}const vx=new Float32Array(1);class Mx extends aa{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,s=n.length,a=t._propertyBindings,o=t._interpolants,c=i.uuid,l=this._bindingsByRootAndName;let h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==s;++u){const d=n[u],f=d.name;let p=h[f];if(p!==void 0)++p.referenceCount,a[u]=p;else{if(p=a[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,f));continue}const v=e&&e._propertyBindings[u].binding.parsedPath;p=new rx(we.create(i,f,v),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,f),a[u]=p}o[u].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const i=(t._localRoot||this._root).uuid,n=t._clip.uuid,s=this._actionsByClip[n];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,n,i)}const e=t._propertyBindings;for(let i=0,n=e.length;i!==n;++i){const s=e[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let i=0,n=e.length;i!==n;++i){const s=e[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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){const e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,i){const n=this._actions,s=this._actionsByClip;let a=s[e];if(a===void 0)a={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=a;else{const o=a.knownActions;t._byClipCacheIndex=o.length,o.push(t)}t._cacheIndex=n.length,n.push(t),a.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const s=t._clip.uuid,a=this._actionsByClip,o=a[s],c=o.knownActions,l=c[c.length-1],h=t._byClipCacheIndex;l._byClipCacheIndex=h,c[h]=l,c.pop(),t._byClipCacheIndex=null;const u=o.actionByRoot,d=(t._localRoot||this._root).uuid;delete u[d],c.length===0&&delete a[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let i=0,n=e.length;i!==n;++i){const s=e[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_addInactiveBinding(t,e,i){const n=this._bindingsByRootAndName,s=this._bindings;let a=n[e];a===void 0&&(a={},n[e]=a),a[i]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,o=a[n],c=e[e.length-1],l=t._cacheIndex;c._cacheIndex=l,e[l]=c,e.pop(),delete o[s],Object.keys(o).length===0&&delete a[n]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return i===void 0&&(i=new Yg(new Float32Array(2),new Float32Array(2),1,vx),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,s=e[n];t.__cacheIndex=n,e[n]=t,s.__cacheIndex=i,e[i]=s}clipAction(t,e,i){const n=e||this._root,s=n.uuid;let a=typeof t=="string"?rp.findByName(n,t):t;const o=a!==null?a.uuid:t,c=this._actionsByClip[o];let l=null;if(i===void 0&&(a!==null?i=a.blendMode:i=c0),c!==void 0){const u=c.actionByRoot[s];if(u!==void 0&&u.blendMode===i)return u;l=c.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;const h=new gx(this,a,e,i);return this._bindAction(h,l),this._addInactiveAction(h,o,s),h}existingAction(t,e){const i=e||this._root,n=i.uuid,s=typeof t=="string"?rp.findByName(i,t):t,a=s?s.uuid:t,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[n]||null}stopAllAction(){const t=this._actions,e=this._nActiveActions;for(let i=e-1;i>=0;--i)t[i].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,s=Math.sign(t),a=this._accuIndex^=1;for(let l=0;l!==i;++l)e[l]._update(n,t,s,a);const o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(a);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,s=n[i];if(s!==void 0){const a=s.knownActions;for(let o=0,c=a.length;o!==c;++o){const l=a[o];this._deactivateAction(l);const h=l._cacheIndex,u=e[e.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,e[h]=u,e.pop(),this._removeInactiveBindingsForAction(l)}delete n[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const a in i){const o=i[a].actionByRoot,c=o[e];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}const n=this._bindingsByRootAndName,s=n[e];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(t,e){const i=this.existingAction(t,e);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}const fp=new Zt;class ol{constructor(t,e,i=0,n=1/0){this.ray=new Yo(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new f0,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,e.projectionMatrix.elements[14]).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):Gt("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return fp.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(fp),this}intersectObject(t,e=!0,i=[]){return pd(t,this,i,e),i.sort(pp),i}intersectObjects(t,e=!0,i=[]){for(let n=0,s=t.length;n<s;n++)pd(t[n],this,i,e);return i.sort(pp),i}}function pp(r,t){return r.distance-t.distance}function pd(r,t,e,i){let n=!0;if(r.layers.test(t.layers)&&r.raycast(t,e)===!1&&(n=!1),n===!0&&i===!0){const s=r.children;for(let a=0,o=s.length;a<o;a++)pd(s[a],t,e,!0)}}class Jg{static{Jg.prototype.isMatrix2=!0}constructor(t,e,i,n){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,i,n)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let i=0;i<4;i++)this.elements[i]=t[i+e];return this}set(t,e,i,n){const s=this.elements;return s[0]=t,s[2]=e,s[1]=i,s[3]=n,this}}function mp(r,t,e,i){const n=xx(i);switch(e){case Ig:return r*t;case Hl:return r*t/n.components*n.byteLength;case a0:return r*t/n.components*n.byteLength;case Na:return r*t*2/n.components*n.byteLength;case r0:return r*t*2/n.components*n.byteLength;case Cg:return r*t*3/n.components*n.byteLength;case Ei:return r*t*4/n.components*n.byteLength;case o0:return r*t*4/n.components*n.byteLength;case il:case nl:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*8;case sl:case al:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case Fu:case ku:return Math.max(r,16)*Math.max(t,8)/4;case Nu:case Uu:return Math.max(r,8)*Math.max(t,8)/2;case zu:case Bu:case Gu:case Vu:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*8;case Hu:case pl:case Wu:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case Xu:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case Yu:return Math.floor((r+4)/5)*Math.floor((t+3)/4)*16;case qu:return Math.floor((r+4)/5)*Math.floor((t+4)/5)*16;case $u:return Math.floor((r+5)/6)*Math.floor((t+4)/5)*16;case Ku:return Math.floor((r+5)/6)*Math.floor((t+5)/6)*16;case Zu:return Math.floor((r+7)/8)*Math.floor((t+4)/5)*16;case Ju:return Math.floor((r+7)/8)*Math.floor((t+5)/6)*16;case ju:return Math.floor((r+7)/8)*Math.floor((t+7)/8)*16;case Qu:return Math.floor((r+9)/10)*Math.floor((t+4)/5)*16;case td:return Math.floor((r+9)/10)*Math.floor((t+5)/6)*16;case ed:return Math.floor((r+9)/10)*Math.floor((t+7)/8)*16;case id:return Math.floor((r+9)/10)*Math.floor((t+9)/10)*16;case nd:return Math.floor((r+11)/12)*Math.floor((t+9)/10)*16;case sd:return Math.floor((r+11)/12)*Math.floor((t+11)/12)*16;case ad:case rd:case od:return Math.ceil(r/4)*Math.ceil(t/4)*16;case cd:case ld:return Math.ceil(r/4)*Math.ceil(t/4)*8;case ml:case hd:return Math.ceil(r/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function xx(r){switch(r){case un:case Ag:return{byteLength:1,components:1};case zo:case Tg:case qe:return{byteLength:2,components:1};case n0:case s0:return{byteLength:2,components:4};case Sn:case i0:case Oi:return{byteLength:4,components:1};case Rg:case Dg:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${r}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t0}}));typeof window<"u"&&(window.__THREE__?Rt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=t0);/**
1161
+ }`;class le extends Ds{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=kM,this.fragmentShader=zM,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Nr(t.uniforms),this.uniformsGroups=FM(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const n in this.uniforms){const a=this.uniforms[n].value;a&&a.isTexture?e.uniforms[n]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[n]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[n]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[n]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[n]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[n]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[n]={type:"m4",value:a.toArray()}:e.uniforms[n]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const i={};for(const n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(const i in t.uniforms){const n=t.uniforms[i];switch(this.uniforms[i]={},n.type){case"t":this.uniforms[i].value=e[n.value]||null;break;case"c":this.uniforms[i].value=new st().setHex(n.value);break;case"v2":this.uniforms[i].value=new xt().fromArray(n.value);break;case"v3":this.uniforms[i].value=new R().fromArray(n.value);break;case"v4":this.uniforms[i].value=new ne().fromArray(n.value);break;case"m3":this.uniforms[i].value=new Yt().fromArray(n.value);break;case"m4":this.uniforms[i].value=new Jt().fromArray(n.value);break;default:this.uniforms[i].value=n.value}}if(t.defines!==void 0&&(this.defines=t.defines),t.vertexShader!==void 0&&(this.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(this.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(this.glslVersion=t.glslVersion),t.extensions!==void 0)for(const i in t.extensions)this.extensions[i]=t.extensions[i];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}}class Xg extends le{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class xa extends Ds{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new st(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new st(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ml,this.normalScale=new xt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new As,this.envMapIntensity=1,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.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,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.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,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 BM extends xa{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new xt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ee(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new st(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new st(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new st(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=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 kr extends Ds{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new st(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new st(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ml,this.normalScale=new xt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new As,this.combine=e0,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=t.envMapIntensity,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 HM extends Ds{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=C2,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 GM extends Ds{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}}function Cc(r,t){return!r||r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function VM(r){function t(n,s){return r[n]-r[s]}const e=r.length,i=new Array(e);for(let n=0;n!==e;++n)i[n]=n;return i.sort(t),i}function ap(r,t,e){const i=r.length,n=new r.constructor(i);for(let s=0,a=0;a!==i;++s){const o=e[s]*t;for(let c=0;c!==t;++c)n[a++]=r[o+c]}return n}function WM(r,t,e,i){let n=1,s=r[0];for(;s!==void 0&&s[i]===void 0;)s=r[n++];if(s===void 0)return;let a=s[i];if(a!==void 0)if(Array.isArray(a))do a=s[i],a!==void 0&&(t.push(s.time),e.push(...a)),s=r[n++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[i],a!==void 0&&(t.push(s.time),a.toArray(e,e.length)),s=r[n++];while(s!==void 0);else do a=s[i],a!==void 0&&(t.push(s.time),e.push(a)),s=r[n++];while(s!==void 0)}class qo{constructor(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let i=this._cachedIndex,n=e[i],s=e[i-1];t:{e:{let a;i:{n:if(!(t<n)){for(let o=i+2;;){if(n===void 0){if(t<s)break n;return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=n,n=e[++i],t<n)break e}a=e.length;break i}if(!(t>=s)){const o=e[1];t<o&&(i=2,s=o);for(let c=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(n=s,s=e[--i-1],t>=s)break e}a=i,i=0;break i}break t}for(;i<a;){const o=i+a>>>1;t<e[o]?a=o:i=o+1}if(n=e[i],s=e[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=t*n;for(let a=0;a!==n;++a)e[a]=i[s+a];return e}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class XM extends qo{constructor(t,e,i,n){super(t,e,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:fr,endingEnd:fr}}intervalChanged_(t,e,i){const n=this.parameterPositions;let s=t-2,a=t+1,o=n[s],c=n[a];if(o===void 0)switch(this.getSettings_().endingStart){case pr:s=t,o=2*e-i;break;case vl:s=n.length-2,o=e+n[s]-n[s+1];break;default:s=t,o=i}if(c===void 0)switch(this.getSettings_().endingEnd){case pr:a=t,c=2*i-e;break;case vl:a=1,c=i+n[1]-n[0];break;default:a=t-1,c=e}const l=(i-e)*.5,h=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(c-i),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(t,e,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(i-e)/(n-e),v=p*p,m=v*p,g=-d*m+2*d*v-d*p,S=(1+d)*m+(-1.5-2*d)*v+(-.5+d)*p+1,y=(-1-f)*m+(1.5+f)*v+.5*p,M=f*m-f*v;for(let b=0;b!==o;++b)s[b]=g*a[h+b]+S*a[l+b]+y*a[c+b]+M*a[u+b];return s}}class Yg extends qo{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=(i-e)/(n-e),u=1-h;for(let d=0;d!==o;++d)s[d]=a[l+d]*u+a[c+d]*h;return s}}class YM extends qo{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t){return this.copySampleValue_(t-1)}}class qM extends qo{interpolate_(t,e,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const p=(i-e)/(n-e),v=1-p;for(let m=0;m!==o;++m)s[m]=a[l+m]*v+a[c+m]*p;return s}const d=o*2,f=t-1;for(let p=0;p!==o;++p){const v=a[l+p],m=a[c+p],g=f*d+p*2,S=u[g],y=u[g+1],M=t*d+p*2,b=h[M],w=h[M+1];let T=(i-e)/(n-e),x,A,C,I,P;for(let V=0;V<8;V++){x=T*T,A=x*T,C=1-T,I=C*C,P=I*C;const L=P*e+3*I*T*S+3*C*x*b+A*n-i;if(Math.abs(L)<1e-10)break;const B=3*I*(S-e)+6*C*T*(b-S)+3*x*(n-b);if(Math.abs(B)<1e-10)break;T=T-L/B,T=Math.max(0,Math.min(1,T))}s[p]=P*v+3*I*T*y+3*C*x*w+A*m}return s}}class kn{constructor(t,e,i,n){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Cc(e,this.TimeBufferType),this.values=Cc(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let i;if(e.toJSON!==this.toJSON)i=e.toJSON(t);else{i={name:t.name,times:Cc(t.times,Array),values:Cc(t.values,Array)};const n=t.getInterpolation();n!==t.DefaultInterpolation&&(i.interpolation=n)}return i.type=t.ValueTypeName,i}InterpolantFactoryMethodDiscrete(t){return new YM(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Yg(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new XM(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){const e=new qM(this.times,this.values,this.getValueSize(),t);return this.settings&&(e.inTangents=this.settings.inTangents,e.outTangents=this.settings.outTangents),e}setInterpolation(t){let e;switch(t){case gl:e=this.InterpolantFactoryMethodDiscrete;break;case ud:e=this.InterpolantFactoryMethodLinear;break;case oh:e=this.InterpolantFactoryMethodSmooth;break;case wf:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return Rt("KeyframeTrack:",i),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return gl;case this.InterpolantFactoryMethodLinear:return ud;case this.InterpolantFactoryMethodSmooth:return oh;case this.InterpolantFactoryMethodBezier:return wf}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]*=t}return this}trim(t,e){const i=this.times,n=i.length;let s=0,a=n-1;for(;s!==n&&i[s]<t;)++s;for(;a!==-1&&i[a]>e;)--a;if(++a,s!==0||a!==n){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=i.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(Gt("KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,n=this.values,s=i.length;s===0&&(Gt("KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==s;o++){const c=i[o];if(typeof c=="number"&&isNaN(c)){Gt("KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(a!==null&&a>c){Gt("KeyframeTrack: Out of order keys.",this,o,c,a),t=!1;break}a=c}if(n!==void 0&&B2(n))for(let o=0,c=n.length;o!==c;++o){const l=n[o];if(isNaN(l)){Gt("KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===oh,s=t.length-1;let a=1;for(let o=1;o<s;++o){let c=!1;const l=t[o],h=t[o+1];if(l!==h&&(o!==1||l!==t[0]))if(n)c=!0;else{const u=o*i,d=u-i,f=u+i;for(let p=0;p!==i;++p){const v=e[u+p];if(v!==e[d+p]||v!==e[f+p]){c=!0;break}}}if(c){if(o!==a){t[a]=t[o];const u=o*i,d=a*i;for(let f=0;f!==i;++f)e[d+f]=e[u+f]}++a}}if(s>0){t[a]=t[s];for(let o=s*i,c=a*i,l=0;l!==i;++l)e[c+l]=e[o+l];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*i)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),i=this.constructor,n=new i(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}kn.prototype.ValueTypeName="";kn.prototype.TimeBufferType=Float32Array;kn.prototype.ValueBufferType=Float32Array;kn.prototype.DefaultInterpolation=ud;class zr extends kn{constructor(t,e,i){super(t,e,i)}}zr.prototype.ValueTypeName="bool";zr.prototype.ValueBufferType=Array;zr.prototype.DefaultInterpolation=gl;zr.prototype.InterpolantFactoryMethodLinear=void 0;zr.prototype.InterpolantFactoryMethodSmooth=void 0;class qg extends kn{constructor(t,e,i,n){super(t,e,i,n)}}qg.prototype.ValueTypeName="color";class x0 extends kn{constructor(t,e,i,n){super(t,e,i,n)}}x0.prototype.ValueTypeName="number";class $M extends qo{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(i-e)/(n-e);let l=t*o;for(let h=l+o;l!==h;l+=4)Qi.slerpFlat(s,0,a,l-o,a,l,c);return s}}class y0 extends kn{constructor(t,e,i,n){super(t,e,i,n)}InterpolantFactoryMethodLinear(t){return new $M(this.times,this.values,this.getValueSize(),t)}}y0.prototype.ValueTypeName="quaternion";y0.prototype.InterpolantFactoryMethodSmooth=void 0;class Br extends kn{constructor(t,e,i){super(t,e,i)}}Br.prototype.ValueTypeName="string";Br.prototype.ValueBufferType=Array;Br.prototype.DefaultInterpolation=gl;Br.prototype.InterpolantFactoryMethodLinear=void 0;Br.prototype.InterpolantFactoryMethodSmooth=void 0;class $g extends kn{constructor(t,e,i,n){super(t,e,i,n)}}$g.prototype.ValueTypeName="vector";class rp{constructor(t="",e=-1,i=[],n=c0){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=Nn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let a=0,o=i.length;a!==o;++a)e.push(ZM(i[a]).scale(n));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s.userData=JSON.parse(t.userData||"{}"),s}static toJSON(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let s=0,a=i.length;s!==a;++s)e.push(kn.toJSON(i[s]));return n}static CreateFromMorphTargetSequence(t,e,i,n){const s=e.length,a=[];for(let o=0;o<s;o++){let c=[],l=[];c.push((o+s-1)%s,o,(o+1)%s),l.push(0,1,0);const h=VM(c);c=ap(c,1,h),l=ap(l,1,h),!n&&c[0]===0&&(c.push(s),l.push(l[0])),a.push(new x0(".morphTargetInfluences["+e[o].name+"]",c,l).scale(1/i))}return new this(t,-1,a)}static findByName(t,e){let i=t;if(!Array.isArray(t)){const n=t;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===e)return i[n];return null}static CreateClipsFromMorphTargetSequences(t,e,i){const n={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,c=t.length;o<c;o++){const l=t[o],h=l.name.match(s);if(h&&h.length>1){const u=h[1];let d=n[u];d||(n[u]=d=[]),d.push(l)}}const a=[];for(const o in n)a.push(this.CreateFromMorphTargetSequence(o,n[o],e,i));return a}resetDuration(){const t=this.tracks;let e=0;for(let i=0,n=t.length;i!==n;++i){const s=this.tracks[i];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let i=0;i<this.tracks.length;i++)t.push(this.tracks[i].clone());const e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}}function KM(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return x0;case"vector":case"vector2":case"vector3":case"vector4":return $g;case"color":return qg;case"quaternion":return y0;case"bool":case"boolean":return zr;case"string":return Br}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function ZM(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=KM(r.type);if(r.times===void 0){const e=[],i=[];WM(r.keys,e,i,"value"),r.times=e,r.values=i}return t.parse!==void 0?t.parse(r):new t(r.name,r.times,r.values,r.interpolation)}const bs={enabled:!1,files:{},add:function(r,t){this.enabled!==!1&&(op(r)||(this.files[r]=t))},get:function(r){if(this.enabled!==!1&&!op(r))return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};function op(r){try{const t=r.slice(r.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}class JM{constructor(t,e,i){const n=this;let s=!1,a=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this._abortController=null,this.itemStart=function(h){o++,s===!1&&n.onStart!==void 0&&n.onStart(h,a,o),s=!0},this.itemEnd=function(h){a++,n.onProgress!==void 0&&n.onProgress(h,a,o),a===o&&(s=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(h){n.onError!==void 0&&n.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const f=l[u],p=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const jM=new JM;class $o{constructor(t){this.manager=t!==void 0?t:jM,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){const i=this;return new Promise(function(n,s){i.load(t,n,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}$o.DEFAULT_MATERIAL_NAME="__DEFAULT";const ps={};class QM extends Error{constructor(t,e){super(t),this.response=e}}class aA extends $o{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,i,n){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=bs.get(`file:${t}`);if(s!==void 0){this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0);return}if(ps[t]!==void 0){ps[t].push({onLoad:e,onProgress:i,onError:n});return}ps[t]=[],ps[t].push({onLoad:e,onProgress:i,onError:n});const a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&Rt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=ps[t],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=d?parseInt(d):0,p=f!==0;let v=0;const m=new ReadableStream({start(g){S();function S(){u.read().then(({done:y,value:M})=>{if(y)g.close();else{v+=M.byteLength;const b=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:f});for(let w=0,T=h.length;w<T;w++){const x=h[w];x.onProgress&&x.onProgress(b)}g.enqueue(M),S()}},y=>{g.error(y)})}}});return new Response(m)}else throw new QM(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o==="")return l.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return l.arrayBuffer().then(p=>f.decode(p))}}}).then(l=>{bs.add(`file:${t}`,l);const h=ps[t];delete ps[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=ps[t];if(h===void 0)throw this.manager.itemError(t),l;delete ps[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(l)}this.manager.itemError(t)}).finally(()=>{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}}const sr=new WeakMap;class tx extends $o{constructor(t){super(t)}load(t,e,i,n){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,a=bs.get(`image:${t}`);if(a!==void 0){if(a.complete===!0)s.manager.itemStart(t),setTimeout(function(){e&&e(a),s.manager.itemEnd(t)},0);else{let u=sr.get(a);u===void 0&&(u=[],sr.set(a,u)),u.push({onLoad:e,onError:n})}return a}const o=Go("img");function c(){h(),e&&e(this);const u=sr.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}sr.delete(this),s.manager.itemEnd(t)}function l(u){h(),n&&n(u),bs.remove(`image:${t}`);const d=sr.get(this)||[];for(let f=0;f<d.length;f++){const p=d[f];p.onError&&p.onError(u)}sr.delete(this),s.manager.itemError(t),s.manager.itemEnd(t)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),bs.add(`image:${t}`,o),s.manager.itemStart(t),o.src=t,o}}class rA extends $o{constructor(t){super(t)}load(t,e,i,n){const s=new bi,a=new tx(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,function(o){s.image=o,s.needsUpdate=!0,e!==void 0&&e(s)},i,n),s}}class Vl extends Be{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new st(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}class ex extends Vl{constructor(t,e,i){super(t,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Be.DEFAULT_UP),this.updateMatrix(),this.groundColor=new st(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}}const Oh=new Jt,cp=new R,lp=new R;class _0{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new xt(512,512),this.mapType=un,this.map=null,this.mapPass=null,this.matrix=new Jt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new g0,this._frameExtents=new xt(1,1),this._viewportCount=1,this._viewports=[new ne(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;cp.setFromMatrixPosition(t.matrixWorld),e.position.copy(cp),lp.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(lp),e.updateMatrixWorld(),Oh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Oh,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===Ho||e.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Oh)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const Pc=new R,Lc=new Qi,Vn=new R;class Kg extends Be{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Jt,this.projectionMatrix=new Jt,this.projectionMatrixInverse=new Jt,this.coordinateSystem=ns,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.matrixWorld.decompose(Pc,Lc,Vn),Vn.x===1&&Vn.y===1&&Vn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Pc,Lc,Vn.set(1,1,1)).invert()}updateWorldMatrix(t,e,i=!1){super.updateWorldMatrix(t,e,i),this.matrixWorld.decompose(Pc,Lc,Vn),Vn.x===1&&Vn.y===1&&Vn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Pc,Lc,Vn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const zs=new R,hp=new xt,up=new xt;class Zi extends Kg{constructor(t=50,e=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,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=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=Or*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(bo*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Or*2*Math.atan(Math.tan(bo*.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){zs.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(zs.x,zs.y).multiplyScalar(-t/zs.z),zs.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(zs.x,zs.y).multiplyScalar(-t/zs.z)}getViewSize(t,e){return this.getViewBounds(t,hp,up),e.subVectors(up,hp)}setViewOffset(t,e,i,n,s,a){this.aspect=t/e,this.view===null&&(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=n,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(bo*.5*this.fov)/this.zoom,i=2*e,n=this.aspect*i,s=-.5*n;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;s+=a.offsetX*n/c,e-=a.offsetY*i/l,n*=a.width/c,i*=a.height/l}const o=this.filmOffset;o!==0&&(s+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,e,e-i,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const 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,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class ix extends _0{constructor(){super(new Zi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,i=Or*2*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,s=t.distance||e.far;(i!==e.fov||n!==e.aspect||s!==e.far)&&(e.fov=i,e.aspect=n,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class oA extends Vl{constructor(t,e,i=0,n=Math.PI/3,s=0,a=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Be.DEFAULT_UP),this.updateMatrix(),this.target=new Be,this.distance=i,this.angle=n,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new ix}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.map=t.map,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.angle=this.angle,e.object.decay=this.decay,e.object.penumbra=this.penumbra,e.object.target=this.target.uuid,this.map&&this.map.isTexture&&(e.object.map=this.map.toJSON(t).uuid),e.object.shadow=this.shadow.toJSON(),e}}class nx extends _0{constructor(){super(new Zi(90,1,.5,500)),this.isPointLightShadow=!0}}class Zg extends Vl{constructor(t,e,i=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new nx}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}}class Un extends Kg{constructor(t=-1,e=1,i=1,n=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,i,n,s,a){this.view===null&&(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=n,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let s=i-t,a=i+t,o=n+e,c=n-e;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,a=s+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class sx extends _0{constructor(){super(new Un(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class dp extends Vl{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Be.DEFAULT_UP),this.updateMatrix(),this.target=new Be,this.shadow=new sx}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}class cA{static extractUrlBase(t){const e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||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)}}const Nh=new WeakMap;class lA extends $o{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Rt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Rt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,i,n){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,a=bs.get(`image-bitmap:${t}`);if(a!==void 0){if(s.manager.itemStart(t),a.then){a.then(l=>{Nh.has(a)===!0?(n&&n(Nh.get(a)),s.manager.itemError(t),s.manager.itemEnd(t)):(e&&e(l),s.manager.itemEnd(t))});return}setTimeout(function(){e&&e(a),s.manager.itemEnd(t)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const c=fetch(t,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){bs.add(`image-bitmap:${t}`,l),e&&e(l),s.manager.itemEnd(t)}).catch(function(l){n&&n(l),Nh.set(c,l),bs.remove(`image-bitmap:${t}`),s.manager.itemError(t),s.manager.itemEnd(t)});bs.add(`image-bitmap:${t}`,c),s.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const ar=-90,rr=1;class S0 extends Be{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new Zi(ar,rr,t,e);n.layers=this.layers,this.add(n);const s=new Zi(ar,rr,t,e);s.layers=this.layers,this.add(s);const a=new Zi(ar,rr,t,e);a.layers=this.layers,this.add(a);const o=new Zi(ar,rr,t,e);o.layers=this.layers,this.add(o);const c=new Zi(ar,rr,t,e);c.layers=this.layers,this.add(c);const l=new Zi(ar,rr,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[i,n,s,a,o,c]=e;for(const l of e)this.remove(l);if(t===ns)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===Ho)i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,c,l,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;t.isWebGLRenderer===!0?m=t.state.buffers.depth.getReversed():m=t.reversedDepthBuffer,t.setRenderTarget(i,0,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,s),t.setRenderTarget(i,1,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(i,2,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(i,3,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),t.setRenderTarget(i,4,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),i.texture.generateMipmaps=v,t.setRenderTarget(i,5,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class ax extends Zi{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class rx{constructor(t,e,i){this.binding=t,this.valueSize=i;let n,s,a;switch(e){case"quaternion":n=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":n=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:n=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const i=this.buffer,n=this.valueSize,s=t*n+n;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==n;++o)i[s+o]=i[o];a=e}else{a+=e;const o=e/a;this._mixBufferRegion(i,s,0,o,n)}this.cumulativeWeight=a}accumulateAdditive(t){const e=this.buffer,i=this.valueSize,n=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,i),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,i=this.buffer,n=t*e+e,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const c=e*this._origIndex;this._mixBufferRegion(i,n,c,1-s,e)}a>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*e,1,e);for(let c=e,l=e+e;c!==l;++c)if(i[c]!==i[c+e]){o.setValue(i,n);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,n=i*this._origIndex;t.getValue(e,n);for(let s=i,a=n;s!==a;++s)e[s]=e[n+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i<e;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[e+i]=this.buffer[t+i]}_select(t,e,i,n,s){if(n>=.5)for(let a=0;a!==s;++a)t[e+a]=t[i+a]}_slerp(t,e,i,n){Qi.slerpFlat(t,e,t,e,t,i,n)}_slerpAdditive(t,e,i,n,s){const a=this._workIndex*s;Qi.multiplyQuaternionsFlat(t,a,t,e,t,i),Qi.slerpFlat(t,e,t,e,t,a,n)}_lerp(t,e,i,n,s){const a=1-n;for(let o=0;o!==s;++o){const c=e+o;t[c]=t[c]*a+t[i+o]*n}}_lerpAdditive(t,e,i,n,s){for(let a=0;a!==s;++a){const o=e+a;t[o]=t[o]+t[i+a]*n}}}const b0="\\[\\]\\.:\\/",ox=new RegExp("["+b0+"]","g"),w0="[^"+b0+"]",cx="[^"+b0.replace("\\.","")+"]",lx=/((?:WC+[\/:])*)/.source.replace("WC",w0),hx=/(WCOD+)?/.source.replace("WCOD",cx),ux=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",w0),dx=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",w0),fx=new RegExp("^"+lx+hx+ux+dx+"$"),px=["material","materials","bones","map"];class mx{constructor(t,e,i){const n=i||we.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(t,e)}setValue(t,e){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=i.length;n!==s;++n)i[n].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}}class we{constructor(t,e,i){this.path=e,this.parsedPath=i||we.parseTrackName(e),this.node=we.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 we.Composite(t,e,i):new we(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(ox,"")}static parseTrackName(t){const e=fx.exec(t);if(e===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const s=i.nodeName.substring(n+1);px.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(i!==void 0)return i}if(t.children){const i=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===e||o.uuid===e)return o;const c=i(o.children);if(c)return c}return null},n=i(t.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)t[e++]=i[n]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,i=e.objectName,n=e.propertyName;let s=e.propertyIndex;if(t||(t=we.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){Rt("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=e.objectIndex;switch(i){case"materials":if(!t.material){Gt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){Gt("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){Gt("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===l){l=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){Gt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){Gt("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[i]===void 0){Gt("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[i]}if(l!==void 0){if(t[l]===void 0){Gt("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}const a=t[n];if(a===void 0){const l=e.nodeName;Gt("PropertyBinding: Trying to update property for track: "+l+"."+n+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(n==="morphTargetInfluences"){if(!t.geometry){Gt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){Gt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=n;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}we.Composite=mx;we.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};we.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};we.prototype.GetterByBindingType=[we.prototype._getValue_direct,we.prototype._getValue_array,we.prototype._getValue_arrayElement,we.prototype._getValue_toArray];we.prototype.SetterByBindingTypeAndVersioning=[[we.prototype._setValue_direct,we.prototype._setValue_direct_setNeedsUpdate,we.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[we.prototype._setValue_array,we.prototype._setValue_array_setNeedsUpdate,we.prototype._setValue_array_setMatrixWorldNeedsUpdate],[we.prototype._setValue_arrayElement,we.prototype._setValue_arrayElement_setNeedsUpdate,we.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[we.prototype._setValue_fromArray,we.prototype._setValue_fromArray_setNeedsUpdate,we.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class gx{constructor(t,e,i=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=n;const s=e.tracks,a=s.length,o=new Array(a),c={endingStart:fr,endingEnd:fr};for(let l=0;l!==a;++l){const h=s[l].createInterpolant(null);o[l]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=R2,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&&this.timeScale!==0&&this._startTime===null&&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),i===!0){const n=this._clip.duration,s=t._clip.duration,a=s/n,o=n/s;t._restoreTimeScale=t.timeScale,this._restoreTimeScale=this.timeScale,t.warp(1,a,e),this.warp(o,1,e)}return this}crossFadeTo(t,e,i=!1){return t.crossFadeFrom(this,e,i)}stopFading(){const t=this._weightInterpolant;return t!==null&&(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){const n=this._mixer,s=n.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=n._lendControlInterpolant(),this._timeScaleInterpolant=o);const c=o.parameterPositions,l=o.sampleValues;return c[0]=s,c[1]=s+i,l[0]=t/a,l[1]=e/a,this}stopWarping(){const t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,n){if(!this.enabled){this._updateWeight(t);return}const s=this._startTime;if(s!==null){const c=(t-s)*i;c<0||i===0?e=0:(this._startTime=null,e=i*c)}e*=this._updateTimeScale(t);const a=this._updateTime(e),o=this._updateWeight(t);if(o>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case I2:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulateAdditive(o);break;case c0:default:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulate(n,o)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(i!==null){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(e===0?this.paused=!0:(this._restoreTimeScale!==null&&(e=this._restoreTimeScale),this.timeScale=e),this.stopWarping())}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let n=this.time+t,s=this._loopCount;const a=i===D2;if(t===0)return s===-1?n:a&&(s&1)===1?e-n:n;if(i===Pg){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else if(n<0)n=0;else{this.time=n;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),n>=e||n<0){const o=Math.floor(n/e);n-=e*o,s+=Math.abs(o);const c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(c===1){const l=t<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=s,this.time=n;if(a&&(s&1)===1)return e-n}return n}_setEndings(t,e,i){const n=this._interpolantSettings;i?(n.endingStart=pr,n.endingEnd=pr):(t?n.endingStart=this.zeroSlopeAtStart?pr:fr:n.endingStart=vl,e?n.endingEnd=this.zeroSlopeAtEnd?pr:fr:n.endingEnd=vl)}_scheduleFading(t,e,i){const n=this._mixer,s=n.time;let a=this._weightInterpolant;a===null&&(a=n._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,c=a.sampleValues;return o[0]=s,c[0]=e,o[1]=s+t,c[1]=i,this}}const vx=new Float32Array(1);class Mx extends aa{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,s=n.length,a=t._propertyBindings,o=t._interpolants,c=i.uuid,l=this._bindingsByRootAndName;let h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==s;++u){const d=n[u],f=d.name;let p=h[f];if(p!==void 0)++p.referenceCount,a[u]=p;else{if(p=a[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,f));continue}const v=e&&e._propertyBindings[u].binding.parsedPath;p=new rx(we.create(i,f,v),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,f),a[u]=p}o[u].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const i=(t._localRoot||this._root).uuid,n=t._clip.uuid,s=this._actionsByClip[n];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,n,i)}const e=t._propertyBindings;for(let i=0,n=e.length;i!==n;++i){const s=e[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let i=0,n=e.length;i!==n;++i){const s=e[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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){const e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,i){const n=this._actions,s=this._actionsByClip;let a=s[e];if(a===void 0)a={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=a;else{const o=a.knownActions;t._byClipCacheIndex=o.length,o.push(t)}t._cacheIndex=n.length,n.push(t),a.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const s=t._clip.uuid,a=this._actionsByClip,o=a[s],c=o.knownActions,l=c[c.length-1],h=t._byClipCacheIndex;l._byClipCacheIndex=h,c[h]=l,c.pop(),t._byClipCacheIndex=null;const u=o.actionByRoot,d=(t._localRoot||this._root).uuid;delete u[d],c.length===0&&delete a[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let i=0,n=e.length;i!==n;++i){const s=e[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_addInactiveBinding(t,e,i){const n=this._bindingsByRootAndName,s=this._bindings;let a=n[e];a===void 0&&(a={},n[e]=a),a[i]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,o=a[n],c=e[e.length-1],l=t._cacheIndex;c._cacheIndex=l,e[l]=c,e.pop(),delete o[s],Object.keys(o).length===0&&delete a[n]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return i===void 0&&(i=new Yg(new Float32Array(2),new Float32Array(2),1,vx),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,s=e[n];t.__cacheIndex=n,e[n]=t,s.__cacheIndex=i,e[i]=s}clipAction(t,e,i){const n=e||this._root,s=n.uuid;let a=typeof t=="string"?rp.findByName(n,t):t;const o=a!==null?a.uuid:t,c=this._actionsByClip[o];let l=null;if(i===void 0&&(a!==null?i=a.blendMode:i=c0),c!==void 0){const u=c.actionByRoot[s];if(u!==void 0&&u.blendMode===i)return u;l=c.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;const h=new gx(this,a,e,i);return this._bindAction(h,l),this._addInactiveAction(h,o,s),h}existingAction(t,e){const i=e||this._root,n=i.uuid,s=typeof t=="string"?rp.findByName(i,t):t,a=s?s.uuid:t,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[n]||null}stopAllAction(){const t=this._actions,e=this._nActiveActions;for(let i=e-1;i>=0;--i)t[i].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,s=Math.sign(t),a=this._accuIndex^=1;for(let l=0;l!==i;++l)e[l]._update(n,t,s,a);const o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(a);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,s=n[i];if(s!==void 0){const a=s.knownActions;for(let o=0,c=a.length;o!==c;++o){const l=a[o];this._deactivateAction(l);const h=l._cacheIndex,u=e[e.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,e[h]=u,e.pop(),this._removeInactiveBindingsForAction(l)}delete n[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const a in i){const o=i[a].actionByRoot,c=o[e];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}const n=this._bindingsByRootAndName,s=n[e];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(t,e){const i=this.existingAction(t,e);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}const fp=new Jt;class ol{constructor(t,e,i=0,n=1/0){this.ray=new Yo(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new f0,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,e.projectionMatrix.elements[14]).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):Gt("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return fp.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(fp),this}intersectObject(t,e=!0,i=[]){return pd(t,this,i,e),i.sort(pp),i}intersectObjects(t,e=!0,i=[]){for(let n=0,s=t.length;n<s;n++)pd(t[n],this,i,e);return i.sort(pp),i}}function pp(r,t){return r.distance-t.distance}function pd(r,t,e,i){let n=!0;if(r.layers.test(t.layers)&&r.raycast(t,e)===!1&&(n=!1),n===!0&&i===!0){const s=r.children;for(let a=0,o=s.length;a<o;a++)pd(s[a],t,e,!0)}}class Jg{static{Jg.prototype.isMatrix2=!0}constructor(t,e,i,n){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,i,n)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let i=0;i<4;i++)this.elements[i]=t[i+e];return this}set(t,e,i,n){const s=this.elements;return s[0]=t,s[2]=e,s[1]=i,s[3]=n,this}}function mp(r,t,e,i){const n=xx(i);switch(e){case Ig:return r*t;case Hl:return r*t/n.components*n.byteLength;case a0:return r*t/n.components*n.byteLength;case Na:return r*t*2/n.components*n.byteLength;case r0:return r*t*2/n.components*n.byteLength;case Cg:return r*t*3/n.components*n.byteLength;case Ei:return r*t*4/n.components*n.byteLength;case o0:return r*t*4/n.components*n.byteLength;case il:case nl:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*8;case sl:case al:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case Fu:case ku:return Math.max(r,16)*Math.max(t,8)/4;case Nu:case Uu:return Math.max(r,8)*Math.max(t,8)/2;case zu:case Bu:case Gu:case Vu:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*8;case Hu:case pl:case Wu:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case Xu:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case Yu:return Math.floor((r+4)/5)*Math.floor((t+3)/4)*16;case qu:return Math.floor((r+4)/5)*Math.floor((t+4)/5)*16;case $u:return Math.floor((r+5)/6)*Math.floor((t+4)/5)*16;case Ku:return Math.floor((r+5)/6)*Math.floor((t+5)/6)*16;case Zu:return Math.floor((r+7)/8)*Math.floor((t+4)/5)*16;case Ju:return Math.floor((r+7)/8)*Math.floor((t+5)/6)*16;case ju:return Math.floor((r+7)/8)*Math.floor((t+7)/8)*16;case Qu:return Math.floor((r+9)/10)*Math.floor((t+4)/5)*16;case td:return Math.floor((r+9)/10)*Math.floor((t+5)/6)*16;case ed:return Math.floor((r+9)/10)*Math.floor((t+7)/8)*16;case id:return Math.floor((r+9)/10)*Math.floor((t+9)/10)*16;case nd:return Math.floor((r+11)/12)*Math.floor((t+9)/10)*16;case sd:return Math.floor((r+11)/12)*Math.floor((t+11)/12)*16;case ad:case rd:case od:return Math.ceil(r/4)*Math.ceil(t/4)*16;case cd:case ld:return Math.ceil(r/4)*Math.ceil(t/4)*8;case ml:case hd:return Math.ceil(r/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function xx(r){switch(r){case un:case Ag:return{byteLength:1,components:1};case zo:case Tg:case qe:return{byteLength:2,components:1};case n0:case s0:return{byteLength:2,components:4};case Sn:case i0:case Oi:return{byteLength:4,components:1};case Rg:case Dg:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${r}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t0}}));typeof window<"u"&&(window.__THREE__?Rt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=t0);/**
1105
1162
  * @license
1106
1163
  * Copyright 2010-2026 Three.js Authors
1107
1164
  * SPDX-License-Identifier: MIT
@@ -4771,7 +4828,7 @@ void main() {
4771
4828
  #include <tonemapping_fragment>
4772
4829
  #include <colorspace_fragment>
4773
4830
  #include <fog_fragment>
4774
- }`,Xt={alphahash_fragment:_x,alphahash_pars_fragment:Sx,alphamap_fragment:bx,alphamap_pars_fragment:wx,alphatest_fragment:Ex,alphatest_pars_fragment:Ax,aomap_fragment:Tx,aomap_pars_fragment:Rx,batching_pars_vertex:Dx,batching_vertex:Ix,begin_vertex:Cx,beginnormal_vertex:Px,bsdfs:Lx,iridescence_fragment:Ox,bumpmap_pars_fragment:Nx,clipping_planes_fragment:Fx,clipping_planes_pars_fragment:Ux,clipping_planes_pars_vertex:kx,clipping_planes_vertex:zx,color_fragment:Bx,color_pars_fragment:Hx,color_pars_vertex:Gx,color_vertex:Vx,common:Wx,cube_uv_reflection_fragment:Xx,defaultnormal_vertex:Yx,displacementmap_pars_vertex:qx,displacementmap_vertex:$x,emissivemap_fragment:Kx,emissivemap_pars_fragment:Zx,colorspace_fragment:Jx,colorspace_pars_fragment:jx,envmap_fragment:Qx,envmap_common_pars_fragment:ty,envmap_pars_fragment:ey,envmap_pars_vertex:iy,envmap_physical_pars_fragment:fy,envmap_vertex:ny,fog_vertex:sy,fog_pars_vertex:ay,fog_fragment:ry,fog_pars_fragment:oy,gradientmap_pars_fragment:cy,lightmap_pars_fragment:ly,lights_lambert_fragment:hy,lights_lambert_pars_fragment:uy,lights_pars_begin:dy,lights_toon_fragment:py,lights_toon_pars_fragment:my,lights_phong_fragment:gy,lights_phong_pars_fragment:vy,lights_physical_fragment:My,lights_physical_pars_fragment:xy,lights_fragment_begin:yy,lights_fragment_maps:_y,lights_fragment_end:Sy,lightprobes_pars_fragment:by,logdepthbuf_fragment:wy,logdepthbuf_pars_fragment:Ey,logdepthbuf_pars_vertex:Ay,logdepthbuf_vertex:Ty,map_fragment:Ry,map_pars_fragment:Dy,map_particle_fragment:Iy,map_particle_pars_fragment:Cy,metalnessmap_fragment:Py,metalnessmap_pars_fragment:Ly,morphinstance_vertex:Oy,morphcolor_vertex:Ny,morphnormal_vertex:Fy,morphtarget_pars_vertex:Uy,morphtarget_vertex:ky,normal_fragment_begin:zy,normal_fragment_maps:By,normal_pars_fragment:Hy,normal_pars_vertex:Gy,normal_vertex:Vy,normalmap_pars_fragment:Wy,clearcoat_normal_fragment_begin:Xy,clearcoat_normal_fragment_maps:Yy,clearcoat_pars_fragment:qy,iridescence_pars_fragment:$y,opaque_fragment:Ky,packing:Zy,premultiplied_alpha_fragment:Jy,project_vertex:jy,dithering_fragment:Qy,dithering_pars_fragment:t3,roughnessmap_fragment:e3,roughnessmap_pars_fragment:i3,shadowmap_pars_fragment:n3,shadowmap_pars_vertex:s3,shadowmap_vertex:a3,shadowmask_pars_fragment:r3,skinbase_vertex:o3,skinning_pars_vertex:c3,skinning_vertex:l3,skinnormal_vertex:h3,specularmap_fragment:u3,specularmap_pars_fragment:d3,tonemapping_fragment:f3,tonemapping_pars_fragment:p3,transmission_fragment:m3,transmission_pars_fragment:g3,uv_pars_fragment:v3,uv_pars_vertex:M3,uv_vertex:x3,worldpos_vertex:y3,background_vert:_3,background_frag:S3,backgroundCube_vert:b3,backgroundCube_frag:w3,cube_vert:E3,cube_frag:A3,depth_vert:T3,depth_frag:R3,distance_vert:D3,distance_frag:I3,equirect_vert:C3,equirect_frag:P3,linedashed_vert:L3,linedashed_frag:O3,meshbasic_vert:N3,meshbasic_frag:F3,meshlambert_vert:U3,meshlambert_frag:k3,meshmatcap_vert:z3,meshmatcap_frag:B3,meshnormal_vert:H3,meshnormal_frag:G3,meshphong_vert:V3,meshphong_frag:W3,meshphysical_vert:X3,meshphysical_frag:Y3,meshtoon_vert:q3,meshtoon_frag:$3,points_vert:K3,points_frag:Z3,shadow_vert:J3,shadow_frag:j3,sprite_vert:Q3,sprite_frag:t_},pt={common:{diffuse:{value:new st(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Yt},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Yt}},envmap:{envMap:{value:null},envMapRotation:{value:new Yt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Yt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Yt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Yt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Yt},normalScale:{value:new xt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Yt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Yt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Yt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Yt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new st(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new R},probesMax:{value:new R},probesResolution:{value:new R}},points:{diffuse:{value:new st(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0},uvTransform:{value:new Yt}},sprite:{diffuse:{value:new st(16777215)},opacity:{value:1},center:{value:new xt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Yt},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0}}},Zn={basic:{uniforms:Ui([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.fog]),vertexShader:Xt.meshbasic_vert,fragmentShader:Xt.meshbasic_frag},lambert:{uniforms:Ui([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,pt.lights,{emissive:{value:new st(0)},envMapIntensity:{value:1}}]),vertexShader:Xt.meshlambert_vert,fragmentShader:Xt.meshlambert_frag},phong:{uniforms:Ui([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,pt.lights,{emissive:{value:new st(0)},specular:{value:new st(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Xt.meshphong_vert,fragmentShader:Xt.meshphong_frag},standard:{uniforms:Ui([pt.common,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.roughnessmap,pt.metalnessmap,pt.fog,pt.lights,{emissive:{value:new st(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Xt.meshphysical_vert,fragmentShader:Xt.meshphysical_frag},toon:{uniforms:Ui([pt.common,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.gradientmap,pt.fog,pt.lights,{emissive:{value:new st(0)}}]),vertexShader:Xt.meshtoon_vert,fragmentShader:Xt.meshtoon_frag},matcap:{uniforms:Ui([pt.common,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,{matcap:{value:null}}]),vertexShader:Xt.meshmatcap_vert,fragmentShader:Xt.meshmatcap_frag},points:{uniforms:Ui([pt.points,pt.fog]),vertexShader:Xt.points_vert,fragmentShader:Xt.points_frag},dashed:{uniforms:Ui([pt.common,pt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Xt.linedashed_vert,fragmentShader:Xt.linedashed_frag},depth:{uniforms:Ui([pt.common,pt.displacementmap]),vertexShader:Xt.depth_vert,fragmentShader:Xt.depth_frag},normal:{uniforms:Ui([pt.common,pt.bumpmap,pt.normalmap,pt.displacementmap,{opacity:{value:1}}]),vertexShader:Xt.meshnormal_vert,fragmentShader:Xt.meshnormal_frag},sprite:{uniforms:Ui([pt.sprite,pt.fog]),vertexShader:Xt.sprite_vert,fragmentShader:Xt.sprite_frag},background:{uniforms:{uvTransform:{value:new Yt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Xt.background_vert,fragmentShader:Xt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Yt}},vertexShader:Xt.backgroundCube_vert,fragmentShader:Xt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Xt.cube_vert,fragmentShader:Xt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Xt.equirect_vert,fragmentShader:Xt.equirect_frag},distance:{uniforms:Ui([pt.common,pt.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Xt.distance_vert,fragmentShader:Xt.distance_frag},shadow:{uniforms:Ui([pt.lights,pt.fog,{color:{value:new st(0)},opacity:{value:1}}]),vertexShader:Xt.shadow_vert,fragmentShader:Xt.shadow_frag}};Zn.physical={uniforms:Ui([Zn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Yt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Yt},clearcoatNormalScale:{value:new xt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Yt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Yt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Yt},sheen:{value:0},sheenColor:{value:new st(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Yt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Yt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Yt},transmissionSamplerSize:{value:new xt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Yt},attenuationDistance:{value:0},attenuationColor:{value:new st(0)},specularColor:{value:new st(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Yt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Yt},anisotropyVector:{value:new xt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Yt}}]),vertexShader:Xt.meshphysical_vert,fragmentShader:Xt.meshphysical_frag};const Oc={r:0,b:0,g:0},e_=new Zt,Qg=new Yt;Qg.set(-1,0,0,0,1,0,0,0,1);function i_(r,t,e,i,n,s){const a=new st(0);let o=n===!0?0:1,c,l,h=null,u=0,d=null;function f(S){let y=S.isScene===!0?S.background:null;if(y&&y.isTexture){const M=S.backgroundBlurriness>0;y=t.get(y,M)}return y}function p(S){let y=!1;const M=f(S);M===null?m(a,o):M&&M.isColor&&(m(M,1),y=!0);const b=r.xr.getEnvironmentBlendMode();b==="additive"?e.buffers.color.setClear(0,0,0,1,s):b==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,s),(r.autoClear||y)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function v(S,y){const M=f(y);M&&(M.isCubeTexture||M.mapping===Bl)?(l===void 0&&(l=new Dt(new Wi(1,1,1),new le({name:"BackgroundCubeMaterial",uniforms:Nr(Zn.backgroundCube.uniforms),vertexShader:Zn.backgroundCube.vertexShader,fragmentShader:Zn.backgroundCube.fragmentShader,side:Ve,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(b,w,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(e_.makeRotationFromEuler(y.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Qg),l.material.toneMapped=re.getTransfer(M.colorSpace)!==Se,(h!==M||u!==M.version||d!==r.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=r.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new Dt(new Xi(2,2),new le({name:"BackgroundMaterial",uniforms:Nr(Zn.background.uniforms),vertexShader:Zn.background.vertexShader,fragmentShader:Zn.background.fragmentShader,side:ia,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=re.getTransfer(M.colorSpace)!==Se,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||u!==M.version||d!==r.toneMapping)&&(c.material.needsUpdate=!0,h=M,u=M.version,d=r.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null))}function m(S,y){S.getRGB(Oc,Wg(r)),e.buffers.color.setClear(Oc.r,Oc.g,Oc.b,y,s)}function g(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(S,y=1){a.set(S),o=y,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,m(a,o)},render:p,addToRenderList:v,dispose:g}}function n_(r,t){const e=r.getParameter(r.MAX_VERTEX_ATTRIBS),i={},n=d(null);let s=n,a=!1;function o(I,P,V,X,L){let B=!1;const k=u(I,X,V,P);s!==k&&(s=k,l(s.object)),B=f(I,X,V,L),B&&p(I,X,V,L),L!==null&&t.update(L,r.ELEMENT_ARRAY_BUFFER),(B||a)&&(a=!1,M(I,P,V,X),L!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(L).buffer))}function c(){return r.createVertexArray()}function l(I){return r.bindVertexArray(I)}function h(I){return r.deleteVertexArray(I)}function u(I,P,V,X){const L=X.wireframe===!0;let B=i[P.id];B===void 0&&(B={},i[P.id]=B);const k=I.isInstancedMesh===!0?I.id:0;let $=B[k];$===void 0&&($={},B[k]=$);let tt=$[V.id];tt===void 0&&(tt={},$[V.id]=tt);let J=tt[L];return J===void 0&&(J=d(c()),tt[L]=J),J}function d(I){const P=[],V=[],X=[];for(let L=0;L<e;L++)P[L]=0,V[L]=0,X[L]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:V,attributeDivisors:X,object:I,attributes:{},index:null}}function f(I,P,V,X){const L=s.attributes,B=P.attributes;let k=0;const $=V.getAttributes();for(const tt in $)if($[tt].location>=0){const it=L[tt];let rt=B[tt];if(rt===void 0&&(tt==="instanceMatrix"&&I.instanceMatrix&&(rt=I.instanceMatrix),tt==="instanceColor"&&I.instanceColor&&(rt=I.instanceColor)),it===void 0||it.attribute!==rt||rt&&it.data!==rt.data)return!0;k++}return s.attributesNum!==k||s.index!==X}function p(I,P,V,X){const L={},B=P.attributes;let k=0;const $=V.getAttributes();for(const tt in $)if($[tt].location>=0){let it=B[tt];it===void 0&&(tt==="instanceMatrix"&&I.instanceMatrix&&(it=I.instanceMatrix),tt==="instanceColor"&&I.instanceColor&&(it=I.instanceColor));const rt={};rt.attribute=it,it&&it.data&&(rt.data=it.data),L[tt]=rt,k++}s.attributes=L,s.attributesNum=k,s.index=X}function v(){const I=s.newAttributes;for(let P=0,V=I.length;P<V;P++)I[P]=0}function m(I){g(I,0)}function g(I,P){const V=s.newAttributes,X=s.enabledAttributes,L=s.attributeDivisors;V[I]=1,X[I]===0&&(r.enableVertexAttribArray(I),X[I]=1),L[I]!==P&&(r.vertexAttribDivisor(I,P),L[I]=P)}function S(){const I=s.newAttributes,P=s.enabledAttributes;for(let V=0,X=P.length;V<X;V++)P[V]!==I[V]&&(r.disableVertexAttribArray(V),P[V]=0)}function y(I,P,V,X,L,B,k){k===!0?r.vertexAttribIPointer(I,P,V,L,B):r.vertexAttribPointer(I,P,V,X,L,B)}function M(I,P,V,X){v();const L=X.attributes,B=V.getAttributes(),k=P.defaultAttributeValues;for(const $ in B){const tt=B[$];if(tt.location>=0){let J=L[$];if(J===void 0&&($==="instanceMatrix"&&I.instanceMatrix&&(J=I.instanceMatrix),$==="instanceColor"&&I.instanceColor&&(J=I.instanceColor)),J!==void 0){const it=J.normalized,rt=J.itemSize,Vt=t.get(J);if(Vt===void 0)continue;const Jt=Vt.buffer,qt=Vt.type,q=Vt.bytesPerElement,at=qt===r.INT||qt===r.UNSIGNED_INT||J.gpuType===i0;if(J.isInterleavedBufferAttribute){const nt=J.data,z=nt.stride,Tt=J.offset;if(nt.isInstancedInterleavedBuffer){for(let Nt=0;Nt<tt.locationSize;Nt++)g(tt.location+Nt,nt.meshPerAttribute);I.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=nt.meshPerAttribute*nt.count)}else for(let Nt=0;Nt<tt.locationSize;Nt++)m(tt.location+Nt);r.bindBuffer(r.ARRAY_BUFFER,Jt);for(let Nt=0;Nt<tt.locationSize;Nt++)y(tt.location+Nt,rt/tt.locationSize,qt,it,z*q,(Tt+rt/tt.locationSize*Nt)*q,at)}else{if(J.isInstancedBufferAttribute){for(let nt=0;nt<tt.locationSize;nt++)g(tt.location+nt,J.meshPerAttribute);I.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let nt=0;nt<tt.locationSize;nt++)m(tt.location+nt);r.bindBuffer(r.ARRAY_BUFFER,Jt);for(let nt=0;nt<tt.locationSize;nt++)y(tt.location+nt,rt/tt.locationSize,qt,it,rt*q,rt/tt.locationSize*nt*q,at)}}else if(k!==void 0){const it=k[$];if(it!==void 0)switch(it.length){case 2:r.vertexAttrib2fv(tt.location,it);break;case 3:r.vertexAttrib3fv(tt.location,it);break;case 4:r.vertexAttrib4fv(tt.location,it);break;default:r.vertexAttrib1fv(tt.location,it)}}}}S()}function b(){A();for(const I in i){const P=i[I];for(const V in P){const X=P[V];for(const L in X){const B=X[L];for(const k in B)h(B[k].object),delete B[k];delete X[L]}}delete i[I]}}function w(I){if(i[I.id]===void 0)return;const P=i[I.id];for(const V in P){const X=P[V];for(const L in X){const B=X[L];for(const k in B)h(B[k].object),delete B[k];delete X[L]}}delete i[I.id]}function T(I){for(const P in i){const V=i[P];for(const X in V){const L=V[X];if(L[I.id]===void 0)continue;const B=L[I.id];for(const k in B)h(B[k].object),delete B[k];delete L[I.id]}}}function x(I){for(const P in i){const V=i[P],X=I.isInstancedMesh===!0?I.id:0,L=V[X];if(L!==void 0){for(const B in L){const k=L[B];for(const $ in k)h(k[$].object),delete k[$];delete L[B]}delete V[X],Object.keys(V).length===0&&delete i[P]}}}function A(){C(),a=!0,s!==n&&(s=n,l(s.object))}function C(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:o,reset:A,resetDefaultState:C,dispose:b,releaseStatesOfGeometry:w,releaseStatesOfObject:x,releaseStatesOfProgram:T,initAttributes:v,enableAttribute:m,disableUnusedAttributes:S}}function s_(r,t,e){let i;function n(c){i=c}function s(c,l){r.drawArrays(i,c,l),e.update(l,i,1)}function a(c,l,h){h!==0&&(r.drawArraysInstanced(i,c,l,h),e.update(l,i,h))}function o(c,l,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];e.update(d,i,1)}this.setMode=n,this.render=s,this.renderInstances=a,this.renderMultiDraw=o}function a_(r,t,e,i){let n;function s(){if(n!==void 0)return n;if(t.has("EXT_texture_filter_anisotropic")===!0){const T=t.get("EXT_texture_filter_anisotropic");n=r.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function a(T){return!(T!==Ei&&i.convert(T)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(T){const x=T===qe&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(T!==un&&i.convert(T)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==Oi&&!x)}function c(T){if(T==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp";const h=c(l);h!==l&&(Rt("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&d===!1&&Rt("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),p=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=r.getParameter(r.MAX_TEXTURE_SIZE),m=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),g=r.getParameter(r.MAX_VERTEX_ATTRIBS),S=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),y=r.getParameter(r.MAX_VARYING_VECTORS),M=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),b=r.getParameter(r.MAX_SAMPLES),w=r.getParameter(r.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:v,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:S,maxVaryings:y,maxFragmentUniforms:M,maxSamples:b,samples:w}}function r_(r){const t=this;let e=null,i=0,n=!1,s=!1;const a=new ma,o=new Yt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||i!==0||n;return n=d,i=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,v=u.clipIntersection,m=u.clipShadows,g=r.get(u);if(!n||p===null||p.length===0||s&&!m)s?h(null):l();else{const S=s?0:i,y=S*4;let M=g.clippingState||null;c.value=M,M=h(p,d,y,f);for(let b=0;b!==y;++b)M[b]=e[b];g.clippingState=M,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=S}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function h(u,d,f,p){const v=u!==null?u.length:0;let m=null;if(v!==0){if(m=c.value,p!==!0||m===null){const g=f+v*4,S=d.matrixWorldInverse;o.getNormalMatrix(S),(m===null||m.length<g)&&(m=new Float32Array(g));for(let y=0,M=f;y!==v;++y,M+=4)a.copy(u[y]).applyMatrix4(S,o),a.normal.toArray(m,M),m[M+3]=a.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,m}}const Zs=4,gp=[.125,.215,.35,.446,.526,.582],ya=20,o_=256,io=new Un,vp=new st;let Fh=null,Uh=0,kh=0,zh=!1;const c_=new R;class md{constructor(t){this._renderer=t,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(t,e=0,i=.1,n=100,s={}){const{size:a=256,position:o=c_}=s;Fh=this._renderer.getRenderTarget(),Uh=this._renderer.getActiveCubeFace(),kh=this._renderer.getActiveMipmapLevel(),zh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,i,n,c,o),e>0&&this._blur(c,0,0,e),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=yp(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=xp(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(Fh,Uh,kh),this._renderer.xr.enabled=zh,t.scissorTest=!1,or(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Oa||t.mapping===Lr?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Fh=this._renderer.getRenderTarget(),Uh=this._renderer.getActiveCubeFace(),kh=this._renderer.getActiveMipmapLevel(),zh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:oe,minFilter:oe,generateMipmaps:!1,type:qe,format:Ei,colorSpace:xl,depthBuffer:!1},n=Mp(t,e,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Mp(t,e,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=l_(s)),this._blurMaterial=u_(s,t,e),this._ggxMaterial=h_(s,t,e)}return n}_compileMaterial(t){const e=new Dt(new ce,t);this._renderer.compile(e,io)}_sceneToCubeUV(t,e,i,n,s){const c=new Zi(90,1,e,i),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(vp),u.toneMapping=rs,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(n),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Dt(new Wi,new _n({name:"PMREM.Background",side:Ve,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let g=!1;const S=t.background;S?S.isColor&&(m.color.copy(S),t.background=null,g=!0):(m.color.copy(vp),g=!0);for(let y=0;y<6;y++){const M=y%3;M===0?(c.up.set(0,l[y],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+h[y],s.y,s.z)):M===1?(c.up.set(0,0,l[y]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+h[y],s.z)):(c.up.set(0,l[y],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+h[y]));const b=this._cubeSize;or(n,M*b,y>2?b:0,b,b),u.setRenderTarget(n),g&&u.render(v,c),u.render(t,c)}u.toneMapping=f,u.autoClear=d,t.background=S}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===Oa||t.mapping===Lr;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=yp()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=xp());const s=n?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=t;const c=this._cubeSize;or(e,0,0,3*c,2*c),i.setRenderTarget(e),i.render(a,io)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;const n=this._lodMeshes.length;for(let s=1;s<n;s++)this._applyGGXFilter(t,s-1,s);e.autoClear=i}_applyGGXFilter(t,e,i){const n=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const c=a.uniforms,l=i/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=0+l*1.25,f=u*d,{_lodMax:p}=this,v=this._sizeLods[i],m=3*v*(i>p-Zs?i-p+Zs:0),g=4*(this._cubeSize-v);c.envMap.value=t.texture,c.roughness.value=f,c.mipInt.value=p-e,or(s,m,g,3*v,2*v),n.setRenderTarget(s),n.render(o,io),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=p-i,or(t,m,g,3*v,2*v),n.setRenderTarget(t),n.render(o,io)}_blur(t,e,i,n,s){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,i,n,"latitudinal",s),this._halfBlur(a,t,i,i,n,"longitudinal",s)}_halfBlur(t,e,i,n,s,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Gt("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[n];u.material=l;const d=l.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*ya-1),v=s/p,m=isFinite(s)?1+Math.floor(h*v):ya;m>ya&&Rt(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ya}`);const g=[];let S=0;for(let T=0;T<ya;++T){const x=T/v,A=Math.exp(-x*x/2);g.push(A),T===0?S+=A:T<m&&(S+=2*A)}for(let T=0;T<g.length;T++)g[T]=g[T]/S;d.envMap.value=t.texture,d.samples.value=m,d.weights.value=g,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:y}=this;d.dTheta.value=p,d.mipInt.value=y-i;const M=this._sizeLods[n],b=3*M*(n>y-Zs?n-y+Zs:0),w=4*(this._cubeSize-M);or(e,b,w,3*M,2*M),c.setRenderTarget(e),c.render(u,io)}}function l_(r){const t=[],e=[],i=[];let n=r;const s=r-Zs+1+gp.length;for(let a=0;a<s;a++){const o=Math.pow(2,n);t.push(o);let c=1/o;a>r-Zs?c=gp[a-r+Zs-1]:a===0&&(c=0),e.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,p=6,v=3,m=2,g=1,S=new Float32Array(v*p*f),y=new Float32Array(m*p*f),M=new Float32Array(g*p*f);for(let w=0;w<f;w++){const T=w%3*2/3-1,x=w>2?0:-1,A=[T,x,0,T+2/3,x,0,T+2/3,x+1,0,T,x,0,T+2/3,x+1,0,T,x+1,0];S.set(A,v*p*w),y.set(d,m*p*w);const C=[w,w,w,w,w,w];M.set(C,g*p*w)}const b=new ce;b.setAttribute("position",new ee(S,v)),b.setAttribute("uv",new ee(y,m)),b.setAttribute("faceIndex",new ee(M,g)),i.push(new Dt(b,null)),n>Zs&&n--}return{lodMeshes:i,sizeLods:t,sigmas:e}}function Mp(r,t,e){const i=new ri(r,t,e);return i.texture.mapping=Bl,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function or(r,t,e,i,n){r.viewport.set(t,e,i,n),r.scissor.set(t,e,i,n)}function h_(r,t,e){return new le({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:o_,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Wl(),fragmentShader:`
4831
+ }`,Xt={alphahash_fragment:_x,alphahash_pars_fragment:Sx,alphamap_fragment:bx,alphamap_pars_fragment:wx,alphatest_fragment:Ex,alphatest_pars_fragment:Ax,aomap_fragment:Tx,aomap_pars_fragment:Rx,batching_pars_vertex:Dx,batching_vertex:Ix,begin_vertex:Cx,beginnormal_vertex:Px,bsdfs:Lx,iridescence_fragment:Ox,bumpmap_pars_fragment:Nx,clipping_planes_fragment:Fx,clipping_planes_pars_fragment:Ux,clipping_planes_pars_vertex:kx,clipping_planes_vertex:zx,color_fragment:Bx,color_pars_fragment:Hx,color_pars_vertex:Gx,color_vertex:Vx,common:Wx,cube_uv_reflection_fragment:Xx,defaultnormal_vertex:Yx,displacementmap_pars_vertex:qx,displacementmap_vertex:$x,emissivemap_fragment:Kx,emissivemap_pars_fragment:Zx,colorspace_fragment:Jx,colorspace_pars_fragment:jx,envmap_fragment:Qx,envmap_common_pars_fragment:ty,envmap_pars_fragment:ey,envmap_pars_vertex:iy,envmap_physical_pars_fragment:fy,envmap_vertex:ny,fog_vertex:sy,fog_pars_vertex:ay,fog_fragment:ry,fog_pars_fragment:oy,gradientmap_pars_fragment:cy,lightmap_pars_fragment:ly,lights_lambert_fragment:hy,lights_lambert_pars_fragment:uy,lights_pars_begin:dy,lights_toon_fragment:py,lights_toon_pars_fragment:my,lights_phong_fragment:gy,lights_phong_pars_fragment:vy,lights_physical_fragment:My,lights_physical_pars_fragment:xy,lights_fragment_begin:yy,lights_fragment_maps:_y,lights_fragment_end:Sy,lightprobes_pars_fragment:by,logdepthbuf_fragment:wy,logdepthbuf_pars_fragment:Ey,logdepthbuf_pars_vertex:Ay,logdepthbuf_vertex:Ty,map_fragment:Ry,map_pars_fragment:Dy,map_particle_fragment:Iy,map_particle_pars_fragment:Cy,metalnessmap_fragment:Py,metalnessmap_pars_fragment:Ly,morphinstance_vertex:Oy,morphcolor_vertex:Ny,morphnormal_vertex:Fy,morphtarget_pars_vertex:Uy,morphtarget_vertex:ky,normal_fragment_begin:zy,normal_fragment_maps:By,normal_pars_fragment:Hy,normal_pars_vertex:Gy,normal_vertex:Vy,normalmap_pars_fragment:Wy,clearcoat_normal_fragment_begin:Xy,clearcoat_normal_fragment_maps:Yy,clearcoat_pars_fragment:qy,iridescence_pars_fragment:$y,opaque_fragment:Ky,packing:Zy,premultiplied_alpha_fragment:Jy,project_vertex:jy,dithering_fragment:Qy,dithering_pars_fragment:t3,roughnessmap_fragment:e3,roughnessmap_pars_fragment:i3,shadowmap_pars_fragment:n3,shadowmap_pars_vertex:s3,shadowmap_vertex:a3,shadowmask_pars_fragment:r3,skinbase_vertex:o3,skinning_pars_vertex:c3,skinning_vertex:l3,skinnormal_vertex:h3,specularmap_fragment:u3,specularmap_pars_fragment:d3,tonemapping_fragment:f3,tonemapping_pars_fragment:p3,transmission_fragment:m3,transmission_pars_fragment:g3,uv_pars_fragment:v3,uv_pars_vertex:M3,uv_vertex:x3,worldpos_vertex:y3,background_vert:_3,background_frag:S3,backgroundCube_vert:b3,backgroundCube_frag:w3,cube_vert:E3,cube_frag:A3,depth_vert:T3,depth_frag:R3,distance_vert:D3,distance_frag:I3,equirect_vert:C3,equirect_frag:P3,linedashed_vert:L3,linedashed_frag:O3,meshbasic_vert:N3,meshbasic_frag:F3,meshlambert_vert:U3,meshlambert_frag:k3,meshmatcap_vert:z3,meshmatcap_frag:B3,meshnormal_vert:H3,meshnormal_frag:G3,meshphong_vert:V3,meshphong_frag:W3,meshphysical_vert:X3,meshphysical_frag:Y3,meshtoon_vert:q3,meshtoon_frag:$3,points_vert:K3,points_frag:Z3,shadow_vert:J3,shadow_frag:j3,sprite_vert:Q3,sprite_frag:t_},pt={common:{diffuse:{value:new st(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Yt},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Yt}},envmap:{envMap:{value:null},envMapRotation:{value:new Yt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Yt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Yt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Yt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Yt},normalScale:{value:new xt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Yt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Yt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Yt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Yt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new st(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new R},probesMax:{value:new R},probesResolution:{value:new R}},points:{diffuse:{value:new st(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0},uvTransform:{value:new Yt}},sprite:{diffuse:{value:new st(16777215)},opacity:{value:1},center:{value:new xt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Yt},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0}}},Zn={basic:{uniforms:Ui([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.fog]),vertexShader:Xt.meshbasic_vert,fragmentShader:Xt.meshbasic_frag},lambert:{uniforms:Ui([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,pt.lights,{emissive:{value:new st(0)},envMapIntensity:{value:1}}]),vertexShader:Xt.meshlambert_vert,fragmentShader:Xt.meshlambert_frag},phong:{uniforms:Ui([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,pt.lights,{emissive:{value:new st(0)},specular:{value:new st(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Xt.meshphong_vert,fragmentShader:Xt.meshphong_frag},standard:{uniforms:Ui([pt.common,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.roughnessmap,pt.metalnessmap,pt.fog,pt.lights,{emissive:{value:new st(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Xt.meshphysical_vert,fragmentShader:Xt.meshphysical_frag},toon:{uniforms:Ui([pt.common,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.gradientmap,pt.fog,pt.lights,{emissive:{value:new st(0)}}]),vertexShader:Xt.meshtoon_vert,fragmentShader:Xt.meshtoon_frag},matcap:{uniforms:Ui([pt.common,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,{matcap:{value:null}}]),vertexShader:Xt.meshmatcap_vert,fragmentShader:Xt.meshmatcap_frag},points:{uniforms:Ui([pt.points,pt.fog]),vertexShader:Xt.points_vert,fragmentShader:Xt.points_frag},dashed:{uniforms:Ui([pt.common,pt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Xt.linedashed_vert,fragmentShader:Xt.linedashed_frag},depth:{uniforms:Ui([pt.common,pt.displacementmap]),vertexShader:Xt.depth_vert,fragmentShader:Xt.depth_frag},normal:{uniforms:Ui([pt.common,pt.bumpmap,pt.normalmap,pt.displacementmap,{opacity:{value:1}}]),vertexShader:Xt.meshnormal_vert,fragmentShader:Xt.meshnormal_frag},sprite:{uniforms:Ui([pt.sprite,pt.fog]),vertexShader:Xt.sprite_vert,fragmentShader:Xt.sprite_frag},background:{uniforms:{uvTransform:{value:new Yt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Xt.background_vert,fragmentShader:Xt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Yt}},vertexShader:Xt.backgroundCube_vert,fragmentShader:Xt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Xt.cube_vert,fragmentShader:Xt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Xt.equirect_vert,fragmentShader:Xt.equirect_frag},distance:{uniforms:Ui([pt.common,pt.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Xt.distance_vert,fragmentShader:Xt.distance_frag},shadow:{uniforms:Ui([pt.lights,pt.fog,{color:{value:new st(0)},opacity:{value:1}}]),vertexShader:Xt.shadow_vert,fragmentShader:Xt.shadow_frag}};Zn.physical={uniforms:Ui([Zn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Yt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Yt},clearcoatNormalScale:{value:new xt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Yt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Yt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Yt},sheen:{value:0},sheenColor:{value:new st(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Yt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Yt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Yt},transmissionSamplerSize:{value:new xt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Yt},attenuationDistance:{value:0},attenuationColor:{value:new st(0)},specularColor:{value:new st(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Yt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Yt},anisotropyVector:{value:new xt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Yt}}]),vertexShader:Xt.meshphysical_vert,fragmentShader:Xt.meshphysical_frag};const Oc={r:0,b:0,g:0},e_=new Jt,Qg=new Yt;Qg.set(-1,0,0,0,1,0,0,0,1);function i_(r,t,e,i,n,s){const a=new st(0);let o=n===!0?0:1,c,l,h=null,u=0,d=null;function f(S){let y=S.isScene===!0?S.background:null;if(y&&y.isTexture){const M=S.backgroundBlurriness>0;y=t.get(y,M)}return y}function p(S){let y=!1;const M=f(S);M===null?m(a,o):M&&M.isColor&&(m(M,1),y=!0);const b=r.xr.getEnvironmentBlendMode();b==="additive"?e.buffers.color.setClear(0,0,0,1,s):b==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,s),(r.autoClear||y)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function v(S,y){const M=f(y);M&&(M.isCubeTexture||M.mapping===Bl)?(l===void 0&&(l=new Dt(new Wi(1,1,1),new le({name:"BackgroundCubeMaterial",uniforms:Nr(Zn.backgroundCube.uniforms),vertexShader:Zn.backgroundCube.vertexShader,fragmentShader:Zn.backgroundCube.fragmentShader,side:Ve,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(b,w,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(e_.makeRotationFromEuler(y.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Qg),l.material.toneMapped=re.getTransfer(M.colorSpace)!==Se,(h!==M||u!==M.version||d!==r.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=r.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new Dt(new Xi(2,2),new le({name:"BackgroundMaterial",uniforms:Nr(Zn.background.uniforms),vertexShader:Zn.background.vertexShader,fragmentShader:Zn.background.fragmentShader,side:ia,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=re.getTransfer(M.colorSpace)!==Se,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||u!==M.version||d!==r.toneMapping)&&(c.material.needsUpdate=!0,h=M,u=M.version,d=r.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null))}function m(S,y){S.getRGB(Oc,Wg(r)),e.buffers.color.setClear(Oc.r,Oc.g,Oc.b,y,s)}function g(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(S,y=1){a.set(S),o=y,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,m(a,o)},render:p,addToRenderList:v,dispose:g}}function n_(r,t){const e=r.getParameter(r.MAX_VERTEX_ATTRIBS),i={},n=d(null);let s=n,a=!1;function o(I,P,V,X,L){let B=!1;const k=u(I,X,V,P);s!==k&&(s=k,l(s.object)),B=f(I,X,V,L),B&&p(I,X,V,L),L!==null&&t.update(L,r.ELEMENT_ARRAY_BUFFER),(B||a)&&(a=!1,M(I,P,V,X),L!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(L).buffer))}function c(){return r.createVertexArray()}function l(I){return r.bindVertexArray(I)}function h(I){return r.deleteVertexArray(I)}function u(I,P,V,X){const L=X.wireframe===!0;let B=i[P.id];B===void 0&&(B={},i[P.id]=B);const k=I.isInstancedMesh===!0?I.id:0;let $=B[k];$===void 0&&($={},B[k]=$);let tt=$[V.id];tt===void 0&&(tt={},$[V.id]=tt);let J=tt[L];return J===void 0&&(J=d(c()),tt[L]=J),J}function d(I){const P=[],V=[],X=[];for(let L=0;L<e;L++)P[L]=0,V[L]=0,X[L]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:V,attributeDivisors:X,object:I,attributes:{},index:null}}function f(I,P,V,X){const L=s.attributes,B=P.attributes;let k=0;const $=V.getAttributes();for(const tt in $)if($[tt].location>=0){const it=L[tt];let rt=B[tt];if(rt===void 0&&(tt==="instanceMatrix"&&I.instanceMatrix&&(rt=I.instanceMatrix),tt==="instanceColor"&&I.instanceColor&&(rt=I.instanceColor)),it===void 0||it.attribute!==rt||rt&&it.data!==rt.data)return!0;k++}return s.attributesNum!==k||s.index!==X}function p(I,P,V,X){const L={},B=P.attributes;let k=0;const $=V.getAttributes();for(const tt in $)if($[tt].location>=0){let it=B[tt];it===void 0&&(tt==="instanceMatrix"&&I.instanceMatrix&&(it=I.instanceMatrix),tt==="instanceColor"&&I.instanceColor&&(it=I.instanceColor));const rt={};rt.attribute=it,it&&it.data&&(rt.data=it.data),L[tt]=rt,k++}s.attributes=L,s.attributesNum=k,s.index=X}function v(){const I=s.newAttributes;for(let P=0,V=I.length;P<V;P++)I[P]=0}function m(I){g(I,0)}function g(I,P){const V=s.newAttributes,X=s.enabledAttributes,L=s.attributeDivisors;V[I]=1,X[I]===0&&(r.enableVertexAttribArray(I),X[I]=1),L[I]!==P&&(r.vertexAttribDivisor(I,P),L[I]=P)}function S(){const I=s.newAttributes,P=s.enabledAttributes;for(let V=0,X=P.length;V<X;V++)P[V]!==I[V]&&(r.disableVertexAttribArray(V),P[V]=0)}function y(I,P,V,X,L,B,k){k===!0?r.vertexAttribIPointer(I,P,V,L,B):r.vertexAttribPointer(I,P,V,X,L,B)}function M(I,P,V,X){v();const L=X.attributes,B=V.getAttributes(),k=P.defaultAttributeValues;for(const $ in B){const tt=B[$];if(tt.location>=0){let J=L[$];if(J===void 0&&($==="instanceMatrix"&&I.instanceMatrix&&(J=I.instanceMatrix),$==="instanceColor"&&I.instanceColor&&(J=I.instanceColor)),J!==void 0){const it=J.normalized,rt=J.itemSize,Vt=t.get(J);if(Vt===void 0)continue;const jt=Vt.buffer,qt=Vt.type,q=Vt.bytesPerElement,at=qt===r.INT||qt===r.UNSIGNED_INT||J.gpuType===i0;if(J.isInterleavedBufferAttribute){const nt=J.data,z=nt.stride,Tt=J.offset;if(nt.isInstancedInterleavedBuffer){for(let Nt=0;Nt<tt.locationSize;Nt++)g(tt.location+Nt,nt.meshPerAttribute);I.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=nt.meshPerAttribute*nt.count)}else for(let Nt=0;Nt<tt.locationSize;Nt++)m(tt.location+Nt);r.bindBuffer(r.ARRAY_BUFFER,jt);for(let Nt=0;Nt<tt.locationSize;Nt++)y(tt.location+Nt,rt/tt.locationSize,qt,it,z*q,(Tt+rt/tt.locationSize*Nt)*q,at)}else{if(J.isInstancedBufferAttribute){for(let nt=0;nt<tt.locationSize;nt++)g(tt.location+nt,J.meshPerAttribute);I.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let nt=0;nt<tt.locationSize;nt++)m(tt.location+nt);r.bindBuffer(r.ARRAY_BUFFER,jt);for(let nt=0;nt<tt.locationSize;nt++)y(tt.location+nt,rt/tt.locationSize,qt,it,rt*q,rt/tt.locationSize*nt*q,at)}}else if(k!==void 0){const it=k[$];if(it!==void 0)switch(it.length){case 2:r.vertexAttrib2fv(tt.location,it);break;case 3:r.vertexAttrib3fv(tt.location,it);break;case 4:r.vertexAttrib4fv(tt.location,it);break;default:r.vertexAttrib1fv(tt.location,it)}}}}S()}function b(){A();for(const I in i){const P=i[I];for(const V in P){const X=P[V];for(const L in X){const B=X[L];for(const k in B)h(B[k].object),delete B[k];delete X[L]}}delete i[I]}}function w(I){if(i[I.id]===void 0)return;const P=i[I.id];for(const V in P){const X=P[V];for(const L in X){const B=X[L];for(const k in B)h(B[k].object),delete B[k];delete X[L]}}delete i[I.id]}function T(I){for(const P in i){const V=i[P];for(const X in V){const L=V[X];if(L[I.id]===void 0)continue;const B=L[I.id];for(const k in B)h(B[k].object),delete B[k];delete L[I.id]}}}function x(I){for(const P in i){const V=i[P],X=I.isInstancedMesh===!0?I.id:0,L=V[X];if(L!==void 0){for(const B in L){const k=L[B];for(const $ in k)h(k[$].object),delete k[$];delete L[B]}delete V[X],Object.keys(V).length===0&&delete i[P]}}}function A(){C(),a=!0,s!==n&&(s=n,l(s.object))}function C(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:o,reset:A,resetDefaultState:C,dispose:b,releaseStatesOfGeometry:w,releaseStatesOfObject:x,releaseStatesOfProgram:T,initAttributes:v,enableAttribute:m,disableUnusedAttributes:S}}function s_(r,t,e){let i;function n(c){i=c}function s(c,l){r.drawArrays(i,c,l),e.update(l,i,1)}function a(c,l,h){h!==0&&(r.drawArraysInstanced(i,c,l,h),e.update(l,i,h))}function o(c,l,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];e.update(d,i,1)}this.setMode=n,this.render=s,this.renderInstances=a,this.renderMultiDraw=o}function a_(r,t,e,i){let n;function s(){if(n!==void 0)return n;if(t.has("EXT_texture_filter_anisotropic")===!0){const T=t.get("EXT_texture_filter_anisotropic");n=r.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function a(T){return!(T!==Ei&&i.convert(T)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(T){const x=T===qe&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(T!==un&&i.convert(T)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==Oi&&!x)}function c(T){if(T==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp";const h=c(l);h!==l&&(Rt("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&d===!1&&Rt("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),p=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=r.getParameter(r.MAX_TEXTURE_SIZE),m=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),g=r.getParameter(r.MAX_VERTEX_ATTRIBS),S=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),y=r.getParameter(r.MAX_VARYING_VECTORS),M=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),b=r.getParameter(r.MAX_SAMPLES),w=r.getParameter(r.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:v,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:S,maxVaryings:y,maxFragmentUniforms:M,maxSamples:b,samples:w}}function r_(r){const t=this;let e=null,i=0,n=!1,s=!1;const a=new ma,o=new Yt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||i!==0||n;return n=d,i=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,v=u.clipIntersection,m=u.clipShadows,g=r.get(u);if(!n||p===null||p.length===0||s&&!m)s?h(null):l();else{const S=s?0:i,y=S*4;let M=g.clippingState||null;c.value=M,M=h(p,d,y,f);for(let b=0;b!==y;++b)M[b]=e[b];g.clippingState=M,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=S}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function h(u,d,f,p){const v=u!==null?u.length:0;let m=null;if(v!==0){if(m=c.value,p!==!0||m===null){const g=f+v*4,S=d.matrixWorldInverse;o.getNormalMatrix(S),(m===null||m.length<g)&&(m=new Float32Array(g));for(let y=0,M=f;y!==v;++y,M+=4)a.copy(u[y]).applyMatrix4(S,o),a.normal.toArray(m,M),m[M+3]=a.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,m}}const Zs=4,gp=[.125,.215,.35,.446,.526,.582],ya=20,o_=256,io=new Un,vp=new st;let Fh=null,Uh=0,kh=0,zh=!1;const c_=new R;class md{constructor(t){this._renderer=t,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(t,e=0,i=.1,n=100,s={}){const{size:a=256,position:o=c_}=s;Fh=this._renderer.getRenderTarget(),Uh=this._renderer.getActiveCubeFace(),kh=this._renderer.getActiveMipmapLevel(),zh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,i,n,c,o),e>0&&this._blur(c,0,0,e),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=yp(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=xp(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(Fh,Uh,kh),this._renderer.xr.enabled=zh,t.scissorTest=!1,or(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Oa||t.mapping===Lr?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Fh=this._renderer.getRenderTarget(),Uh=this._renderer.getActiveCubeFace(),kh=this._renderer.getActiveMipmapLevel(),zh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:oe,minFilter:oe,generateMipmaps:!1,type:qe,format:Ei,colorSpace:xl,depthBuffer:!1},n=Mp(t,e,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Mp(t,e,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=l_(s)),this._blurMaterial=u_(s,t,e),this._ggxMaterial=h_(s,t,e)}return n}_compileMaterial(t){const e=new Dt(new ce,t);this._renderer.compile(e,io)}_sceneToCubeUV(t,e,i,n,s){const c=new Zi(90,1,e,i),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(vp),u.toneMapping=rs,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(n),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Dt(new Wi,new _n({name:"PMREM.Background",side:Ve,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let g=!1;const S=t.background;S?S.isColor&&(m.color.copy(S),t.background=null,g=!0):(m.color.copy(vp),g=!0);for(let y=0;y<6;y++){const M=y%3;M===0?(c.up.set(0,l[y],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+h[y],s.y,s.z)):M===1?(c.up.set(0,0,l[y]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+h[y],s.z)):(c.up.set(0,l[y],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+h[y]));const b=this._cubeSize;or(n,M*b,y>2?b:0,b,b),u.setRenderTarget(n),g&&u.render(v,c),u.render(t,c)}u.toneMapping=f,u.autoClear=d,t.background=S}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===Oa||t.mapping===Lr;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=yp()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=xp());const s=n?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=t;const c=this._cubeSize;or(e,0,0,3*c,2*c),i.setRenderTarget(e),i.render(a,io)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;const n=this._lodMeshes.length;for(let s=1;s<n;s++)this._applyGGXFilter(t,s-1,s);e.autoClear=i}_applyGGXFilter(t,e,i){const n=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const c=a.uniforms,l=i/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=0+l*1.25,f=u*d,{_lodMax:p}=this,v=this._sizeLods[i],m=3*v*(i>p-Zs?i-p+Zs:0),g=4*(this._cubeSize-v);c.envMap.value=t.texture,c.roughness.value=f,c.mipInt.value=p-e,or(s,m,g,3*v,2*v),n.setRenderTarget(s),n.render(o,io),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=p-i,or(t,m,g,3*v,2*v),n.setRenderTarget(t),n.render(o,io)}_blur(t,e,i,n,s){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,i,n,"latitudinal",s),this._halfBlur(a,t,i,i,n,"longitudinal",s)}_halfBlur(t,e,i,n,s,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Gt("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[n];u.material=l;const d=l.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*ya-1),v=s/p,m=isFinite(s)?1+Math.floor(h*v):ya;m>ya&&Rt(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ya}`);const g=[];let S=0;for(let T=0;T<ya;++T){const x=T/v,A=Math.exp(-x*x/2);g.push(A),T===0?S+=A:T<m&&(S+=2*A)}for(let T=0;T<g.length;T++)g[T]=g[T]/S;d.envMap.value=t.texture,d.samples.value=m,d.weights.value=g,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:y}=this;d.dTheta.value=p,d.mipInt.value=y-i;const M=this._sizeLods[n],b=3*M*(n>y-Zs?n-y+Zs:0),w=4*(this._cubeSize-M);or(e,b,w,3*M,2*M),c.setRenderTarget(e),c.render(u,io)}}function l_(r){const t=[],e=[],i=[];let n=r;const s=r-Zs+1+gp.length;for(let a=0;a<s;a++){const o=Math.pow(2,n);t.push(o);let c=1/o;a>r-Zs?c=gp[a-r+Zs-1]:a===0&&(c=0),e.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,p=6,v=3,m=2,g=1,S=new Float32Array(v*p*f),y=new Float32Array(m*p*f),M=new Float32Array(g*p*f);for(let w=0;w<f;w++){const T=w%3*2/3-1,x=w>2?0:-1,A=[T,x,0,T+2/3,x,0,T+2/3,x+1,0,T,x,0,T+2/3,x+1,0,T,x+1,0];S.set(A,v*p*w),y.set(d,m*p*w);const C=[w,w,w,w,w,w];M.set(C,g*p*w)}const b=new ce;b.setAttribute("position",new ie(S,v)),b.setAttribute("uv",new ie(y,m)),b.setAttribute("faceIndex",new ie(M,g)),i.push(new Dt(b,null)),n>Zs&&n--}return{lodMeshes:i,sizeLods:t,sigmas:e}}function Mp(r,t,e){const i=new ri(r,t,e);return i.texture.mapping=Bl,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function or(r,t,e,i,n){r.viewport.set(t,e,i,n),r.scissor.set(t,e,i,n)}function h_(r,t,e){return new le({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:o_,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Wl(),fragmentShader:`
4775
4832
 
4776
4833
  precision highp float;
4777
4834
  precision highp int;
@@ -5157,7 +5214,7 @@ Material Type: `+I.type+`
5157
5214
 
5158
5215
  Program Info Log: `+L+`
5159
5216
  `+J+`
5160
- `+it)}else L!==""?Rt("WebGLProgram: Program Info Log:",L):(B===""||k==="")&&(tt=!1);tt&&(I.diagnostics={runnable:$,programLog:L,vertexShader:{log:B,prefix:m},fragmentShader:{log:k,prefix:g}})}n.deleteShader(b),n.deleteShader(w),x=new cl(n,v),A=_S(n,v)}let x;this.getUniforms=function(){return x===void 0&&T(this),x};let A;this.getAttributes=function(){return A===void 0&&T(this),A};let C=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return C===!1&&(C=n.getProgramParameter(v,uS)),C},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=dS++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=b,this.fragmentShader=w,this}let US=0;class kS{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,i){const n=this._getShaderCacheForMaterial(t);return n.has(e)===!1&&(n.add(e),e.usedTimes++),n.has(i)===!1&&(n.add(i),i.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const i of e)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let i=e.get(t);return i===void 0&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return i===void 0&&(i=new zS(t),e.set(t,i)),i}}class zS{constructor(t){this.id=US++,this.code=t,this.usedTimes=0}}function BS(r){return r===Na||r===pl||r===ml}function HS(r,t,e,i,n,s){const a=new f0,o=new kS,c=new Set,l=[],h=new Map,u=i.logarithmicDepthBuffer;let d=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(x){return c.add(x),x===0?"uv":`uv${x}`}function v(x,A,C,I,P,V){const X=I.fog,L=P.geometry,B=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?I.environment:null,k=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,$=t.get(x.envMap||B,k),tt=$&&$.mapping===Bl?$.image.height:null,J=f[x.type];x.precision!==null&&(d=i.getMaxPrecision(x.precision),d!==x.precision&&Rt("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));const it=L.morphAttributes.position||L.morphAttributes.normal||L.morphAttributes.color,rt=it!==void 0?it.length:0;let Vt=0;L.morphAttributes.position!==void 0&&(Vt=1),L.morphAttributes.normal!==void 0&&(Vt=2),L.morphAttributes.color!==void 0&&(Vt=3);let Jt,qt,q,at;if(J){const bt=Zn[J];Jt=bt.vertexShader,qt=bt.fragmentShader}else{Jt=x.vertexShader,qt=x.fragmentShader;const bt=o.getVertexShaderStage(x),Je=o.getFragmentShaderStage(x);o.update(x,bt,Je),q=bt.id,at=Je.id}const nt=r.getRenderTarget(),z=r.state.buffers.depth.getReversed(),Tt=P.isInstancedMesh===!0,Nt=P.isBatchedMesh===!0,Ct=!!x.map,_t=!!x.matcap,kt=!!$,zt=!!x.aoMap,Bt=!!x.lightMap,Me=!!x.bumpMap&&x.wireframe===!1,xe=!!x.normalMap,Ke=!!x.displacementMap,He=!!x.emissiveMap,Ze=!!x.metalnessMap,ci=!!x.roughnessMap,N=x.anisotropy>0,Yi=x.clearcoat>0,ye=x.dispersion>0,D=x.iridescence>0,_=x.sheen>0,U=x.transmission>0,W=N&&!!x.anisotropyMap,K=Yi&&!!x.clearcoatMap,ot=Yi&&!!x.clearcoatNormalMap,lt=Yi&&!!x.clearcoatRoughnessMap,Z=D&&!!x.iridescenceMap,Q=D&&!!x.iridescenceThicknessMap,ht=_&&!!x.sheenColorMap,Pt=_&&!!x.sheenRoughnessMap,ft=!!x.specularMap,ut=!!x.specularColorMap,Ut=!!x.specularIntensityMap,Ht=U&&!!x.transmissionMap,$t=U&&!!x.thicknessMap,O=!!x.gradientMap,ct=!!x.alphaMap,j=x.alphaTest>0,dt=!!x.alphaHash,vt=!!x.extensions;let et=rs;x.toneMapped&&(nt===null||nt.isXRRenderTarget===!0)&&(et=r.toneMapping);const It={shaderID:J,shaderType:x.type,shaderName:x.name,vertexShader:Jt,fragmentShader:qt,defines:x.defines,customVertexShaderID:q,customFragmentShaderID:at,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:Nt,batchingColor:Nt&&P._colorsTexture!==null,instancing:Tt,instancingColor:Tt&&P.instanceColor!==null,instancingMorph:Tt&&P.morphTexture!==null,outputColorSpace:nt===null?r.outputColorSpace:nt.isXRRenderTarget===!0?nt.texture.colorSpace:re.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Ct,matcap:_t,envMap:kt,envMapMode:kt&&$.mapping,envMapCubeUVHeight:tt,aoMap:zt,lightMap:Bt,bumpMap:Me,normalMap:xe,displacementMap:Ke,emissiveMap:He,normalMapObjectSpace:xe&&x.normalMapType===P2,normalMapTangentSpace:xe&&x.normalMapType===Ml,packedNormalMap:xe&&x.normalMapType===Ml&&BS(x.normalMap.format),metalnessMap:Ze,roughnessMap:ci,anisotropy:N,anisotropyMap:W,clearcoat:Yi,clearcoatMap:K,clearcoatNormalMap:ot,clearcoatRoughnessMap:lt,dispersion:ye,iridescence:D,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:_,sheenColorMap:ht,sheenRoughnessMap:Pt,specularMap:ft,specularColorMap:ut,specularIntensityMap:Ut,transmission:U,transmissionMap:Ht,thicknessMap:$t,gradientMap:O,opaque:x.transparent===!1&&x.blending===ta&&x.alphaToCoverage===!1,alphaMap:ct,alphaTest:j,alphaHash:dt,combine:x.combine,mapUv:Ct&&p(x.map.channel),aoMapUv:zt&&p(x.aoMap.channel),lightMapUv:Bt&&p(x.lightMap.channel),bumpMapUv:Me&&p(x.bumpMap.channel),normalMapUv:xe&&p(x.normalMap.channel),displacementMapUv:Ke&&p(x.displacementMap.channel),emissiveMapUv:He&&p(x.emissiveMap.channel),metalnessMapUv:Ze&&p(x.metalnessMap.channel),roughnessMapUv:ci&&p(x.roughnessMap.channel),anisotropyMapUv:W&&p(x.anisotropyMap.channel),clearcoatMapUv:K&&p(x.clearcoatMap.channel),clearcoatNormalMapUv:ot&&p(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:lt&&p(x.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&p(x.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&p(x.iridescenceThicknessMap.channel),sheenColorMapUv:ht&&p(x.sheenColorMap.channel),sheenRoughnessMapUv:Pt&&p(x.sheenRoughnessMap.channel),specularMapUv:ft&&p(x.specularMap.channel),specularColorMapUv:ut&&p(x.specularColorMap.channel),specularIntensityMapUv:Ut&&p(x.specularIntensityMap.channel),transmissionMapUv:Ht&&p(x.transmissionMap.channel),thicknessMapUv:$t&&p(x.thicknessMap.channel),alphaMapUv:ct&&p(x.alphaMap.channel),vertexTangents:!!L.attributes.tangent&&(xe||N),vertexNormals:!!L.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!L.attributes.color&&L.attributes.color.itemSize===4,pointsUvs:P.isPoints===!0&&!!L.attributes.uv&&(Ct||ct),fog:!!X,useFog:x.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||L.attributes.normal===void 0&&xe===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:z,skinning:P.isSkinnedMesh===!0,hasPositionAttribute:L.attributes.position!==void 0,morphTargets:L.morphAttributes.position!==void 0,morphNormals:L.morphAttributes.normal!==void 0,morphColors:L.morphAttributes.color!==void 0,morphTargetsCount:rt,morphTextureStride:Vt,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:V.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:r.shadowMap.enabled&&C.length>0,shadowMapType:r.shadowMap.type,toneMapping:et,decodeVideoTexture:Ct&&x.map.isVideoTexture===!0&&re.getTransfer(x.map.colorSpace)===Se,decodeVideoTextureEmissive:He&&x.emissiveMap.isVideoTexture===!0&&re.getTransfer(x.emissiveMap.colorSpace)===Se,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===ji,flipSided:x.side===Ve,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:vt&&x.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(vt&&x.extensions.multiDraw===!0||Nt)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return It.vertexUv1s=c.has(1),It.vertexUv2s=c.has(2),It.vertexUv3s=c.has(3),c.clear(),It}function m(x){const A=[];if(x.shaderID?A.push(x.shaderID):(A.push(x.customVertexShaderID),A.push(x.customFragmentShaderID)),x.defines!==void 0)for(const C in x.defines)A.push(C),A.push(x.defines[C]);return x.isRawShaderMaterial===!1&&(g(A,x),S(A,x),A.push(r.outputColorSpace)),A.push(x.customProgramCacheKey),A.join()}function g(x,A){x.push(A.precision),x.push(A.outputColorSpace),x.push(A.envMapMode),x.push(A.envMapCubeUVHeight),x.push(A.mapUv),x.push(A.alphaMapUv),x.push(A.lightMapUv),x.push(A.aoMapUv),x.push(A.bumpMapUv),x.push(A.normalMapUv),x.push(A.displacementMapUv),x.push(A.emissiveMapUv),x.push(A.metalnessMapUv),x.push(A.roughnessMapUv),x.push(A.anisotropyMapUv),x.push(A.clearcoatMapUv),x.push(A.clearcoatNormalMapUv),x.push(A.clearcoatRoughnessMapUv),x.push(A.iridescenceMapUv),x.push(A.iridescenceThicknessMapUv),x.push(A.sheenColorMapUv),x.push(A.sheenRoughnessMapUv),x.push(A.specularMapUv),x.push(A.specularColorMapUv),x.push(A.specularIntensityMapUv),x.push(A.transmissionMapUv),x.push(A.thicknessMapUv),x.push(A.combine),x.push(A.fogExp2),x.push(A.sizeAttenuation),x.push(A.morphTargetsCount),x.push(A.morphAttributeCount),x.push(A.numDirLights),x.push(A.numPointLights),x.push(A.numSpotLights),x.push(A.numSpotLightMaps),x.push(A.numHemiLights),x.push(A.numRectAreaLights),x.push(A.numDirLightShadows),x.push(A.numPointLightShadows),x.push(A.numSpotLightShadows),x.push(A.numSpotLightShadowsWithMaps),x.push(A.numLightProbes),x.push(A.shadowMapType),x.push(A.toneMapping),x.push(A.numClippingPlanes),x.push(A.numClipIntersection),x.push(A.depthPacking)}function S(x,A){a.disableAll(),A.instancing&&a.enable(0),A.instancingColor&&a.enable(1),A.instancingMorph&&a.enable(2),A.matcap&&a.enable(3),A.envMap&&a.enable(4),A.normalMapObjectSpace&&a.enable(5),A.normalMapTangentSpace&&a.enable(6),A.clearcoat&&a.enable(7),A.iridescence&&a.enable(8),A.alphaTest&&a.enable(9),A.vertexColors&&a.enable(10),A.vertexAlphas&&a.enable(11),A.vertexUv1s&&a.enable(12),A.vertexUv2s&&a.enable(13),A.vertexUv3s&&a.enable(14),A.vertexTangents&&a.enable(15),A.anisotropy&&a.enable(16),A.alphaHash&&a.enable(17),A.batching&&a.enable(18),A.dispersion&&a.enable(19),A.batchingColor&&a.enable(20),A.gradientMap&&a.enable(21),A.packedNormalMap&&a.enable(22),A.vertexNormals&&a.enable(23),x.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.reversedDepthBuffer&&a.enable(4),A.skinning&&a.enable(5),A.morphTargets&&a.enable(6),A.morphNormals&&a.enable(7),A.morphColors&&a.enable(8),A.premultipliedAlpha&&a.enable(9),A.shadowMapEnabled&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),A.decodeVideoTextureEmissive&&a.enable(20),A.alphaToCoverage&&a.enable(21),A.numLightProbeGrids>0&&a.enable(22),A.hasPositionAttribute&&a.enable(23),x.push(a.mask)}function y(x){const A=f[x.type];let C;if(A){const I=Zn[A];C=UM.clone(I.uniforms)}else C=x.uniforms;return C}function M(x,A){let C=h.get(A);return C!==void 0?++C.usedTimes:(C=new FS(r,A,x,n),l.push(C),h.set(A,C)),C}function b(x){if(--x.usedTimes===0){const A=l.indexOf(x);l[A]=l[l.length-1],l.pop(),h.delete(x.cacheKey),x.destroy()}}function w(x){o.remove(x)}function T(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:y,acquireProgram:M,releaseProgram:b,releaseShaderCache:w,programs:l,dispose:T}}function GS(){let r=new WeakMap;function t(a){return r.has(a)}function e(a){let o=r.get(a);return o===void 0&&(o={},r.set(a,o)),o}function i(a){r.delete(a)}function n(a,o,c){r.get(a)[o]=c}function s(){r=new WeakMap}return{has:t,get:e,remove:i,update:n,dispose:s}}function VS(r,t){return r.groupOrder!==t.groupOrder?r.groupOrder-t.groupOrder:r.renderOrder!==t.renderOrder?r.renderOrder-t.renderOrder:r.material.id!==t.material.id?r.material.id-t.material.id:r.materialVariant!==t.materialVariant?r.materialVariant-t.materialVariant:r.z!==t.z?r.z-t.z:r.id-t.id}function Op(r,t){return r.groupOrder!==t.groupOrder?r.groupOrder-t.groupOrder:r.renderOrder!==t.renderOrder?r.renderOrder-t.renderOrder:r.z!==t.z?t.z-r.z:r.id-t.id}function Np(){const r=[];let t=0;const e=[],i=[],n=[];function s(){t=0,e.length=0,i.length=0,n.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,p,v,m,g){let S=r[t];return S===void 0?(S={id:d.id,object:d,geometry:f,material:p,materialVariant:a(d),groupOrder:v,renderOrder:d.renderOrder,z:m,group:g},r[t]=S):(S.id=d.id,S.object=d,S.geometry=f,S.material=p,S.materialVariant=a(d),S.groupOrder=v,S.renderOrder=d.renderOrder,S.z=m,S.group=g),t++,S}function c(d,f,p,v,m,g){const S=o(d,f,p,v,m,g);p.transmission>0?i.push(S):p.transparent===!0?n.push(S):e.push(S)}function l(d,f,p,v,m,g){const S=o(d,f,p,v,m,g);p.transmission>0?i.unshift(S):p.transparent===!0?n.unshift(S):e.unshift(S)}function h(d,f,p){e.length>1&&e.sort(d||VS),i.length>1&&i.sort(f||Op),n.length>1&&n.sort(f||Op),p&&(e.reverse(),i.reverse(),n.reverse())}function u(){for(let d=t,f=r.length;d<f;d++){const p=r[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:e,transmissive:i,transparent:n,init:s,push:c,unshift:l,finish:u,sort:h}}function WS(){let r=new WeakMap;function t(i,n){const s=r.get(i);let a;return s===void 0?(a=new Np,r.set(i,[a])):n>=s.length?(a=new Np,s.push(a)):a=s[n],a}function e(){r=new WeakMap}return{get:t,dispose:e}}function XS(){const r={};return{get:function(t){if(r[t.id]!==void 0)return r[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new R,color:new st};break;case"SpotLight":e={position:new R,direction:new R,color:new st,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new R,color:new st,distance:0,decay:0};break;case"HemisphereLight":e={direction:new R,skyColor:new st,groundColor:new st};break;case"RectAreaLight":e={color:new st,position:new R,halfWidth:new R,halfHeight:new R};break}return r[t.id]=e,e}}}function YS(){const r={};return{get:function(t){if(r[t.id]!==void 0)return r[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xt,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[t.id]=e,e}}}let qS=0;function $S(r,t){return(t.castShadow?2:0)-(r.castShadow?2:0)+(t.map?1:0)-(r.map?1:0)}function KS(r){const t=new XS,e=YS(),i={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 l=0;l<9;l++)i.probe.push(new R);const n=new R,s=new Zt,a=new Zt;function o(l){let h=0,u=0,d=0;for(let A=0;A<9;A++)i.probe[A].set(0,0,0);let f=0,p=0,v=0,m=0,g=0,S=0,y=0,M=0,b=0,w=0,T=0;l.sort($S);for(let A=0,C=l.length;A<C;A++){const I=l[A],P=I.color,V=I.intensity,X=I.distance;let L=null;if(I.shadow&&I.shadow.map&&(I.shadow.map.texture.format===Na?L=I.shadow.map.texture:L=I.shadow.map.depthTexture||I.shadow.map.texture),I.isAmbientLight)h+=P.r*V,u+=P.g*V,d+=P.b*V;else if(I.isLightProbe){for(let B=0;B<9;B++)i.probe[B].addScaledVector(I.sh.coefficients[B],V);T++}else if(I.isDirectionalLight){const B=t.get(I);if(B.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){const k=I.shadow,$=e.get(I);$.shadowIntensity=k.intensity,$.shadowBias=k.bias,$.shadowNormalBias=k.normalBias,$.shadowRadius=k.radius,$.shadowMapSize=k.mapSize,i.directionalShadow[f]=$,i.directionalShadowMap[f]=L,i.directionalShadowMatrix[f]=I.shadow.matrix,S++}i.directional[f]=B,f++}else if(I.isSpotLight){const B=t.get(I);B.position.setFromMatrixPosition(I.matrixWorld),B.color.copy(P).multiplyScalar(V),B.distance=X,B.coneCos=Math.cos(I.angle),B.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),B.decay=I.decay,i.spot[v]=B;const k=I.shadow;if(I.map&&(i.spotLightMap[b]=I.map,b++,k.updateMatrices(I),I.castShadow&&w++),i.spotLightMatrix[v]=k.matrix,I.castShadow){const $=e.get(I);$.shadowIntensity=k.intensity,$.shadowBias=k.bias,$.shadowNormalBias=k.normalBias,$.shadowRadius=k.radius,$.shadowMapSize=k.mapSize,i.spotShadow[v]=$,i.spotShadowMap[v]=L,M++}v++}else if(I.isRectAreaLight){const B=t.get(I);B.color.copy(P).multiplyScalar(V),B.halfWidth.set(I.width*.5,0,0),B.halfHeight.set(0,I.height*.5,0),i.rectArea[m]=B,m++}else if(I.isPointLight){const B=t.get(I);if(B.color.copy(I.color).multiplyScalar(I.intensity),B.distance=I.distance,B.decay=I.decay,I.castShadow){const k=I.shadow,$=e.get(I);$.shadowIntensity=k.intensity,$.shadowBias=k.bias,$.shadowNormalBias=k.normalBias,$.shadowRadius=k.radius,$.shadowMapSize=k.mapSize,$.shadowCameraNear=k.camera.near,$.shadowCameraFar=k.camera.far,i.pointShadow[p]=$,i.pointShadowMap[p]=L,i.pointShadowMatrix[p]=I.shadow.matrix,y++}i.point[p]=B,p++}else if(I.isHemisphereLight){const B=t.get(I);B.skyColor.copy(I.color).multiplyScalar(V),B.groundColor.copy(I.groundColor).multiplyScalar(V),i.hemi[g]=B,g++}}m>0&&(r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=pt.LTC_FLOAT_1,i.rectAreaLTC2=pt.LTC_FLOAT_2):(i.rectAreaLTC1=pt.LTC_HALF_1,i.rectAreaLTC2=pt.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=u,i.ambient[2]=d;const x=i.hash;(x.directionalLength!==f||x.pointLength!==p||x.spotLength!==v||x.rectAreaLength!==m||x.hemiLength!==g||x.numDirectionalShadows!==S||x.numPointShadows!==y||x.numSpotShadows!==M||x.numSpotMaps!==b||x.numLightProbes!==T)&&(i.directional.length=f,i.spot.length=v,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=S,i.directionalShadowMap.length=S,i.pointShadow.length=y,i.pointShadowMap.length=y,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=S,i.pointShadowMatrix.length=y,i.spotLightMatrix.length=M+b-w,i.spotLightMap.length=b,i.numSpotLightShadowsWithMaps=w,i.numLightProbes=T,x.directionalLength=f,x.pointLength=p,x.spotLength=v,x.rectAreaLength=m,x.hemiLength=g,x.numDirectionalShadows=S,x.numPointShadows=y,x.numSpotShadows=M,x.numSpotMaps=b,x.numLightProbes=T,i.version=qS++)}function c(l,h){let u=0,d=0,f=0,p=0,v=0;const m=h.matrixWorldInverse;for(let g=0,S=l.length;g<S;g++){const y=l[g];if(y.isDirectionalLight){const M=i.directional[u];M.direction.setFromMatrixPosition(y.matrixWorld),n.setFromMatrixPosition(y.target.matrixWorld),M.direction.sub(n),M.direction.transformDirection(m),u++}else if(y.isSpotLight){const M=i.spot[f];M.position.setFromMatrixPosition(y.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(y.matrixWorld),n.setFromMatrixPosition(y.target.matrixWorld),M.direction.sub(n),M.direction.transformDirection(m),f++}else if(y.isRectAreaLight){const M=i.rectArea[p];M.position.setFromMatrixPosition(y.matrixWorld),M.position.applyMatrix4(m),a.identity(),s.copy(y.matrixWorld),s.premultiply(m),a.extractRotation(s),M.halfWidth.set(y.width*.5,0,0),M.halfHeight.set(0,y.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),p++}else if(y.isPointLight){const M=i.point[d];M.position.setFromMatrixPosition(y.matrixWorld),M.position.applyMatrix4(m),d++}else if(y.isHemisphereLight){const M=i.hemi[v];M.direction.setFromMatrixPosition(y.matrixWorld),M.direction.transformDirection(m),v++}}}return{setup:o,setupView:c,state:i}}function Fp(r){const t=new KS(r),e=[],i=[],n=[];function s(d){u.camera=d,e.length=0,i.length=0,n.length=0}function a(d){e.push(d)}function o(d){i.push(d)}function c(d){n.push(d)}function l(){t.setup(e)}function h(d){t.setupView(e,d)}const u={lightsArray:e,shadowsArray:i,lightProbeGridArray:n,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function ZS(r){let t=new WeakMap;function e(n,s=0){const a=t.get(n);let o;return a===void 0?(o=new Fp(r),t.set(n,[o])):s>=a.length?(o=new Fp(r),a.push(o)):o=a[s],o}function i(){t=new WeakMap}return{get:e,dispose:i}}const JS=`void main() {
5217
+ `+it)}else L!==""?Rt("WebGLProgram: Program Info Log:",L):(B===""||k==="")&&(tt=!1);tt&&(I.diagnostics={runnable:$,programLog:L,vertexShader:{log:B,prefix:m},fragmentShader:{log:k,prefix:g}})}n.deleteShader(b),n.deleteShader(w),x=new cl(n,v),A=_S(n,v)}let x;this.getUniforms=function(){return x===void 0&&T(this),x};let A;this.getAttributes=function(){return A===void 0&&T(this),A};let C=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return C===!1&&(C=n.getProgramParameter(v,uS)),C},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=dS++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=b,this.fragmentShader=w,this}let US=0;class kS{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,i){const n=this._getShaderCacheForMaterial(t);return n.has(e)===!1&&(n.add(e),e.usedTimes++),n.has(i)===!1&&(n.add(i),i.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const i of e)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let i=e.get(t);return i===void 0&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return i===void 0&&(i=new zS(t),e.set(t,i)),i}}class zS{constructor(t){this.id=US++,this.code=t,this.usedTimes=0}}function BS(r){return r===Na||r===pl||r===ml}function HS(r,t,e,i,n,s){const a=new f0,o=new kS,c=new Set,l=[],h=new Map,u=i.logarithmicDepthBuffer;let d=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(x){return c.add(x),x===0?"uv":`uv${x}`}function v(x,A,C,I,P,V){const X=I.fog,L=P.geometry,B=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?I.environment:null,k=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,$=t.get(x.envMap||B,k),tt=$&&$.mapping===Bl?$.image.height:null,J=f[x.type];x.precision!==null&&(d=i.getMaxPrecision(x.precision),d!==x.precision&&Rt("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));const it=L.morphAttributes.position||L.morphAttributes.normal||L.morphAttributes.color,rt=it!==void 0?it.length:0;let Vt=0;L.morphAttributes.position!==void 0&&(Vt=1),L.morphAttributes.normal!==void 0&&(Vt=2),L.morphAttributes.color!==void 0&&(Vt=3);let jt,qt,q,at;if(J){const bt=Zn[J];jt=bt.vertexShader,qt=bt.fragmentShader}else{jt=x.vertexShader,qt=x.fragmentShader;const bt=o.getVertexShaderStage(x),Je=o.getFragmentShaderStage(x);o.update(x,bt,Je),q=bt.id,at=Je.id}const nt=r.getRenderTarget(),z=r.state.buffers.depth.getReversed(),Tt=P.isInstancedMesh===!0,Nt=P.isBatchedMesh===!0,Ct=!!x.map,_t=!!x.matcap,kt=!!$,zt=!!x.aoMap,Bt=!!x.lightMap,Me=!!x.bumpMap&&x.wireframe===!1,xe=!!x.normalMap,Ke=!!x.displacementMap,He=!!x.emissiveMap,Ze=!!x.metalnessMap,ci=!!x.roughnessMap,N=x.anisotropy>0,Yi=x.clearcoat>0,ye=x.dispersion>0,D=x.iridescence>0,_=x.sheen>0,U=x.transmission>0,W=N&&!!x.anisotropyMap,K=Yi&&!!x.clearcoatMap,ot=Yi&&!!x.clearcoatNormalMap,lt=Yi&&!!x.clearcoatRoughnessMap,Z=D&&!!x.iridescenceMap,Q=D&&!!x.iridescenceThicknessMap,ht=_&&!!x.sheenColorMap,Pt=_&&!!x.sheenRoughnessMap,ft=!!x.specularMap,ut=!!x.specularColorMap,Ut=!!x.specularIntensityMap,Ht=U&&!!x.transmissionMap,$t=U&&!!x.thicknessMap,O=!!x.gradientMap,ct=!!x.alphaMap,j=x.alphaTest>0,dt=!!x.alphaHash,vt=!!x.extensions;let et=rs;x.toneMapped&&(nt===null||nt.isXRRenderTarget===!0)&&(et=r.toneMapping);const It={shaderID:J,shaderType:x.type,shaderName:x.name,vertexShader:jt,fragmentShader:qt,defines:x.defines,customVertexShaderID:q,customFragmentShaderID:at,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:Nt,batchingColor:Nt&&P._colorsTexture!==null,instancing:Tt,instancingColor:Tt&&P.instanceColor!==null,instancingMorph:Tt&&P.morphTexture!==null,outputColorSpace:nt===null?r.outputColorSpace:nt.isXRRenderTarget===!0?nt.texture.colorSpace:re.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Ct,matcap:_t,envMap:kt,envMapMode:kt&&$.mapping,envMapCubeUVHeight:tt,aoMap:zt,lightMap:Bt,bumpMap:Me,normalMap:xe,displacementMap:Ke,emissiveMap:He,normalMapObjectSpace:xe&&x.normalMapType===P2,normalMapTangentSpace:xe&&x.normalMapType===Ml,packedNormalMap:xe&&x.normalMapType===Ml&&BS(x.normalMap.format),metalnessMap:Ze,roughnessMap:ci,anisotropy:N,anisotropyMap:W,clearcoat:Yi,clearcoatMap:K,clearcoatNormalMap:ot,clearcoatRoughnessMap:lt,dispersion:ye,iridescence:D,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:_,sheenColorMap:ht,sheenRoughnessMap:Pt,specularMap:ft,specularColorMap:ut,specularIntensityMap:Ut,transmission:U,transmissionMap:Ht,thicknessMap:$t,gradientMap:O,opaque:x.transparent===!1&&x.blending===ta&&x.alphaToCoverage===!1,alphaMap:ct,alphaTest:j,alphaHash:dt,combine:x.combine,mapUv:Ct&&p(x.map.channel),aoMapUv:zt&&p(x.aoMap.channel),lightMapUv:Bt&&p(x.lightMap.channel),bumpMapUv:Me&&p(x.bumpMap.channel),normalMapUv:xe&&p(x.normalMap.channel),displacementMapUv:Ke&&p(x.displacementMap.channel),emissiveMapUv:He&&p(x.emissiveMap.channel),metalnessMapUv:Ze&&p(x.metalnessMap.channel),roughnessMapUv:ci&&p(x.roughnessMap.channel),anisotropyMapUv:W&&p(x.anisotropyMap.channel),clearcoatMapUv:K&&p(x.clearcoatMap.channel),clearcoatNormalMapUv:ot&&p(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:lt&&p(x.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&p(x.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&p(x.iridescenceThicknessMap.channel),sheenColorMapUv:ht&&p(x.sheenColorMap.channel),sheenRoughnessMapUv:Pt&&p(x.sheenRoughnessMap.channel),specularMapUv:ft&&p(x.specularMap.channel),specularColorMapUv:ut&&p(x.specularColorMap.channel),specularIntensityMapUv:Ut&&p(x.specularIntensityMap.channel),transmissionMapUv:Ht&&p(x.transmissionMap.channel),thicknessMapUv:$t&&p(x.thicknessMap.channel),alphaMapUv:ct&&p(x.alphaMap.channel),vertexTangents:!!L.attributes.tangent&&(xe||N),vertexNormals:!!L.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!L.attributes.color&&L.attributes.color.itemSize===4,pointsUvs:P.isPoints===!0&&!!L.attributes.uv&&(Ct||ct),fog:!!X,useFog:x.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||L.attributes.normal===void 0&&xe===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:z,skinning:P.isSkinnedMesh===!0,hasPositionAttribute:L.attributes.position!==void 0,morphTargets:L.morphAttributes.position!==void 0,morphNormals:L.morphAttributes.normal!==void 0,morphColors:L.morphAttributes.color!==void 0,morphTargetsCount:rt,morphTextureStride:Vt,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:V.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:r.shadowMap.enabled&&C.length>0,shadowMapType:r.shadowMap.type,toneMapping:et,decodeVideoTexture:Ct&&x.map.isVideoTexture===!0&&re.getTransfer(x.map.colorSpace)===Se,decodeVideoTextureEmissive:He&&x.emissiveMap.isVideoTexture===!0&&re.getTransfer(x.emissiveMap.colorSpace)===Se,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===ji,flipSided:x.side===Ve,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:vt&&x.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(vt&&x.extensions.multiDraw===!0||Nt)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return It.vertexUv1s=c.has(1),It.vertexUv2s=c.has(2),It.vertexUv3s=c.has(3),c.clear(),It}function m(x){const A=[];if(x.shaderID?A.push(x.shaderID):(A.push(x.customVertexShaderID),A.push(x.customFragmentShaderID)),x.defines!==void 0)for(const C in x.defines)A.push(C),A.push(x.defines[C]);return x.isRawShaderMaterial===!1&&(g(A,x),S(A,x),A.push(r.outputColorSpace)),A.push(x.customProgramCacheKey),A.join()}function g(x,A){x.push(A.precision),x.push(A.outputColorSpace),x.push(A.envMapMode),x.push(A.envMapCubeUVHeight),x.push(A.mapUv),x.push(A.alphaMapUv),x.push(A.lightMapUv),x.push(A.aoMapUv),x.push(A.bumpMapUv),x.push(A.normalMapUv),x.push(A.displacementMapUv),x.push(A.emissiveMapUv),x.push(A.metalnessMapUv),x.push(A.roughnessMapUv),x.push(A.anisotropyMapUv),x.push(A.clearcoatMapUv),x.push(A.clearcoatNormalMapUv),x.push(A.clearcoatRoughnessMapUv),x.push(A.iridescenceMapUv),x.push(A.iridescenceThicknessMapUv),x.push(A.sheenColorMapUv),x.push(A.sheenRoughnessMapUv),x.push(A.specularMapUv),x.push(A.specularColorMapUv),x.push(A.specularIntensityMapUv),x.push(A.transmissionMapUv),x.push(A.thicknessMapUv),x.push(A.combine),x.push(A.fogExp2),x.push(A.sizeAttenuation),x.push(A.morphTargetsCount),x.push(A.morphAttributeCount),x.push(A.numDirLights),x.push(A.numPointLights),x.push(A.numSpotLights),x.push(A.numSpotLightMaps),x.push(A.numHemiLights),x.push(A.numRectAreaLights),x.push(A.numDirLightShadows),x.push(A.numPointLightShadows),x.push(A.numSpotLightShadows),x.push(A.numSpotLightShadowsWithMaps),x.push(A.numLightProbes),x.push(A.shadowMapType),x.push(A.toneMapping),x.push(A.numClippingPlanes),x.push(A.numClipIntersection),x.push(A.depthPacking)}function S(x,A){a.disableAll(),A.instancing&&a.enable(0),A.instancingColor&&a.enable(1),A.instancingMorph&&a.enable(2),A.matcap&&a.enable(3),A.envMap&&a.enable(4),A.normalMapObjectSpace&&a.enable(5),A.normalMapTangentSpace&&a.enable(6),A.clearcoat&&a.enable(7),A.iridescence&&a.enable(8),A.alphaTest&&a.enable(9),A.vertexColors&&a.enable(10),A.vertexAlphas&&a.enable(11),A.vertexUv1s&&a.enable(12),A.vertexUv2s&&a.enable(13),A.vertexUv3s&&a.enable(14),A.vertexTangents&&a.enable(15),A.anisotropy&&a.enable(16),A.alphaHash&&a.enable(17),A.batching&&a.enable(18),A.dispersion&&a.enable(19),A.batchingColor&&a.enable(20),A.gradientMap&&a.enable(21),A.packedNormalMap&&a.enable(22),A.vertexNormals&&a.enable(23),x.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.reversedDepthBuffer&&a.enable(4),A.skinning&&a.enable(5),A.morphTargets&&a.enable(6),A.morphNormals&&a.enable(7),A.morphColors&&a.enable(8),A.premultipliedAlpha&&a.enable(9),A.shadowMapEnabled&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),A.decodeVideoTextureEmissive&&a.enable(20),A.alphaToCoverage&&a.enable(21),A.numLightProbeGrids>0&&a.enable(22),A.hasPositionAttribute&&a.enable(23),x.push(a.mask)}function y(x){const A=f[x.type];let C;if(A){const I=Zn[A];C=UM.clone(I.uniforms)}else C=x.uniforms;return C}function M(x,A){let C=h.get(A);return C!==void 0?++C.usedTimes:(C=new FS(r,A,x,n),l.push(C),h.set(A,C)),C}function b(x){if(--x.usedTimes===0){const A=l.indexOf(x);l[A]=l[l.length-1],l.pop(),h.delete(x.cacheKey),x.destroy()}}function w(x){o.remove(x)}function T(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:y,acquireProgram:M,releaseProgram:b,releaseShaderCache:w,programs:l,dispose:T}}function GS(){let r=new WeakMap;function t(a){return r.has(a)}function e(a){let o=r.get(a);return o===void 0&&(o={},r.set(a,o)),o}function i(a){r.delete(a)}function n(a,o,c){r.get(a)[o]=c}function s(){r=new WeakMap}return{has:t,get:e,remove:i,update:n,dispose:s}}function VS(r,t){return r.groupOrder!==t.groupOrder?r.groupOrder-t.groupOrder:r.renderOrder!==t.renderOrder?r.renderOrder-t.renderOrder:r.material.id!==t.material.id?r.material.id-t.material.id:r.materialVariant!==t.materialVariant?r.materialVariant-t.materialVariant:r.z!==t.z?r.z-t.z:r.id-t.id}function Op(r,t){return r.groupOrder!==t.groupOrder?r.groupOrder-t.groupOrder:r.renderOrder!==t.renderOrder?r.renderOrder-t.renderOrder:r.z!==t.z?t.z-r.z:r.id-t.id}function Np(){const r=[];let t=0;const e=[],i=[],n=[];function s(){t=0,e.length=0,i.length=0,n.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,p,v,m,g){let S=r[t];return S===void 0?(S={id:d.id,object:d,geometry:f,material:p,materialVariant:a(d),groupOrder:v,renderOrder:d.renderOrder,z:m,group:g},r[t]=S):(S.id=d.id,S.object=d,S.geometry=f,S.material=p,S.materialVariant=a(d),S.groupOrder=v,S.renderOrder=d.renderOrder,S.z=m,S.group=g),t++,S}function c(d,f,p,v,m,g){const S=o(d,f,p,v,m,g);p.transmission>0?i.push(S):p.transparent===!0?n.push(S):e.push(S)}function l(d,f,p,v,m,g){const S=o(d,f,p,v,m,g);p.transmission>0?i.unshift(S):p.transparent===!0?n.unshift(S):e.unshift(S)}function h(d,f,p){e.length>1&&e.sort(d||VS),i.length>1&&i.sort(f||Op),n.length>1&&n.sort(f||Op),p&&(e.reverse(),i.reverse(),n.reverse())}function u(){for(let d=t,f=r.length;d<f;d++){const p=r[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:e,transmissive:i,transparent:n,init:s,push:c,unshift:l,finish:u,sort:h}}function WS(){let r=new WeakMap;function t(i,n){const s=r.get(i);let a;return s===void 0?(a=new Np,r.set(i,[a])):n>=s.length?(a=new Np,s.push(a)):a=s[n],a}function e(){r=new WeakMap}return{get:t,dispose:e}}function XS(){const r={};return{get:function(t){if(r[t.id]!==void 0)return r[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new R,color:new st};break;case"SpotLight":e={position:new R,direction:new R,color:new st,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new R,color:new st,distance:0,decay:0};break;case"HemisphereLight":e={direction:new R,skyColor:new st,groundColor:new st};break;case"RectAreaLight":e={color:new st,position:new R,halfWidth:new R,halfHeight:new R};break}return r[t.id]=e,e}}}function YS(){const r={};return{get:function(t){if(r[t.id]!==void 0)return r[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xt,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[t.id]=e,e}}}let qS=0;function $S(r,t){return(t.castShadow?2:0)-(r.castShadow?2:0)+(t.map?1:0)-(r.map?1:0)}function KS(r){const t=new XS,e=YS(),i={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 l=0;l<9;l++)i.probe.push(new R);const n=new R,s=new Jt,a=new Jt;function o(l){let h=0,u=0,d=0;for(let A=0;A<9;A++)i.probe[A].set(0,0,0);let f=0,p=0,v=0,m=0,g=0,S=0,y=0,M=0,b=0,w=0,T=0;l.sort($S);for(let A=0,C=l.length;A<C;A++){const I=l[A],P=I.color,V=I.intensity,X=I.distance;let L=null;if(I.shadow&&I.shadow.map&&(I.shadow.map.texture.format===Na?L=I.shadow.map.texture:L=I.shadow.map.depthTexture||I.shadow.map.texture),I.isAmbientLight)h+=P.r*V,u+=P.g*V,d+=P.b*V;else if(I.isLightProbe){for(let B=0;B<9;B++)i.probe[B].addScaledVector(I.sh.coefficients[B],V);T++}else if(I.isDirectionalLight){const B=t.get(I);if(B.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){const k=I.shadow,$=e.get(I);$.shadowIntensity=k.intensity,$.shadowBias=k.bias,$.shadowNormalBias=k.normalBias,$.shadowRadius=k.radius,$.shadowMapSize=k.mapSize,i.directionalShadow[f]=$,i.directionalShadowMap[f]=L,i.directionalShadowMatrix[f]=I.shadow.matrix,S++}i.directional[f]=B,f++}else if(I.isSpotLight){const B=t.get(I);B.position.setFromMatrixPosition(I.matrixWorld),B.color.copy(P).multiplyScalar(V),B.distance=X,B.coneCos=Math.cos(I.angle),B.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),B.decay=I.decay,i.spot[v]=B;const k=I.shadow;if(I.map&&(i.spotLightMap[b]=I.map,b++,k.updateMatrices(I),I.castShadow&&w++),i.spotLightMatrix[v]=k.matrix,I.castShadow){const $=e.get(I);$.shadowIntensity=k.intensity,$.shadowBias=k.bias,$.shadowNormalBias=k.normalBias,$.shadowRadius=k.radius,$.shadowMapSize=k.mapSize,i.spotShadow[v]=$,i.spotShadowMap[v]=L,M++}v++}else if(I.isRectAreaLight){const B=t.get(I);B.color.copy(P).multiplyScalar(V),B.halfWidth.set(I.width*.5,0,0),B.halfHeight.set(0,I.height*.5,0),i.rectArea[m]=B,m++}else if(I.isPointLight){const B=t.get(I);if(B.color.copy(I.color).multiplyScalar(I.intensity),B.distance=I.distance,B.decay=I.decay,I.castShadow){const k=I.shadow,$=e.get(I);$.shadowIntensity=k.intensity,$.shadowBias=k.bias,$.shadowNormalBias=k.normalBias,$.shadowRadius=k.radius,$.shadowMapSize=k.mapSize,$.shadowCameraNear=k.camera.near,$.shadowCameraFar=k.camera.far,i.pointShadow[p]=$,i.pointShadowMap[p]=L,i.pointShadowMatrix[p]=I.shadow.matrix,y++}i.point[p]=B,p++}else if(I.isHemisphereLight){const B=t.get(I);B.skyColor.copy(I.color).multiplyScalar(V),B.groundColor.copy(I.groundColor).multiplyScalar(V),i.hemi[g]=B,g++}}m>0&&(r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=pt.LTC_FLOAT_1,i.rectAreaLTC2=pt.LTC_FLOAT_2):(i.rectAreaLTC1=pt.LTC_HALF_1,i.rectAreaLTC2=pt.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=u,i.ambient[2]=d;const x=i.hash;(x.directionalLength!==f||x.pointLength!==p||x.spotLength!==v||x.rectAreaLength!==m||x.hemiLength!==g||x.numDirectionalShadows!==S||x.numPointShadows!==y||x.numSpotShadows!==M||x.numSpotMaps!==b||x.numLightProbes!==T)&&(i.directional.length=f,i.spot.length=v,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=S,i.directionalShadowMap.length=S,i.pointShadow.length=y,i.pointShadowMap.length=y,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=S,i.pointShadowMatrix.length=y,i.spotLightMatrix.length=M+b-w,i.spotLightMap.length=b,i.numSpotLightShadowsWithMaps=w,i.numLightProbes=T,x.directionalLength=f,x.pointLength=p,x.spotLength=v,x.rectAreaLength=m,x.hemiLength=g,x.numDirectionalShadows=S,x.numPointShadows=y,x.numSpotShadows=M,x.numSpotMaps=b,x.numLightProbes=T,i.version=qS++)}function c(l,h){let u=0,d=0,f=0,p=0,v=0;const m=h.matrixWorldInverse;for(let g=0,S=l.length;g<S;g++){const y=l[g];if(y.isDirectionalLight){const M=i.directional[u];M.direction.setFromMatrixPosition(y.matrixWorld),n.setFromMatrixPosition(y.target.matrixWorld),M.direction.sub(n),M.direction.transformDirection(m),u++}else if(y.isSpotLight){const M=i.spot[f];M.position.setFromMatrixPosition(y.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(y.matrixWorld),n.setFromMatrixPosition(y.target.matrixWorld),M.direction.sub(n),M.direction.transformDirection(m),f++}else if(y.isRectAreaLight){const M=i.rectArea[p];M.position.setFromMatrixPosition(y.matrixWorld),M.position.applyMatrix4(m),a.identity(),s.copy(y.matrixWorld),s.premultiply(m),a.extractRotation(s),M.halfWidth.set(y.width*.5,0,0),M.halfHeight.set(0,y.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),p++}else if(y.isPointLight){const M=i.point[d];M.position.setFromMatrixPosition(y.matrixWorld),M.position.applyMatrix4(m),d++}else if(y.isHemisphereLight){const M=i.hemi[v];M.direction.setFromMatrixPosition(y.matrixWorld),M.direction.transformDirection(m),v++}}}return{setup:o,setupView:c,state:i}}function Fp(r){const t=new KS(r),e=[],i=[],n=[];function s(d){u.camera=d,e.length=0,i.length=0,n.length=0}function a(d){e.push(d)}function o(d){i.push(d)}function c(d){n.push(d)}function l(){t.setup(e)}function h(d){t.setupView(e,d)}const u={lightsArray:e,shadowsArray:i,lightProbeGridArray:n,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function ZS(r){let t=new WeakMap;function e(n,s=0){const a=t.get(n);let o;return a===void 0?(o=new Fp(r),t.set(n,[o])):s>=a.length?(o=new Fp(r),a.push(o)):o=a[s],o}function i(){t=new WeakMap}return{get:e,dispose:i}}const JS=`void main() {
5161
5218
  gl_Position = vec4( position, 1.0 );
5162
5219
  }`,jS=`uniform sampler2D shadow_pass;
5163
5220
  uniform vec2 resolution;
@@ -5184,7 +5241,7 @@ void main() {
5184
5241
  squared_mean = squared_mean / samples;
5185
5242
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
5186
5243
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
5187
- }`,QS=[new R(1,0,0),new R(-1,0,0),new R(0,1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1)],tb=[new R(0,-1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1),new R(0,-1,0),new R(0,-1,0)],Up=new Zt,no=new R,Hh=new R;function eb(r,t,e){let i=new g0;const n=new xt,s=new xt,a=new ne,o=new HM,c=new GM,l={},h=e.maxTextureSize,u={[ia]:Ve,[Ve]:ia,[ji]:ji},d=new le({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new xt},radius:{value:4}},vertexShader:JS,fragmentShader:jS}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new ce;p.setAttribute("position",new ee(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Dt(p,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=So;let g=this.type;this.render=function(w,T,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;this.type===o2&&(Rt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=So);const A=r.getRenderTarget(),C=r.getActiveCubeFace(),I=r.getActiveMipmapLevel(),P=r.state;P.setBlending(as),P.buffers.depth.getReversed()===!0?P.buffers.color.setClear(0,0,0,0):P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);const V=g!==this.type;V&&T.traverse(function(X){X.material&&(Array.isArray(X.material)?X.material.forEach(L=>L.needsUpdate=!0):X.material.needsUpdate=!0)});for(let X=0,L=w.length;X<L;X++){const B=w[X],k=B.shadow;if(k===void 0){Rt("WebGLShadowMap:",B,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;n.copy(k.mapSize);const $=k.getFrameExtents();n.multiply($),s.copy(k.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(s.x=Math.floor(h/$.x),n.x=s.x*$.x,k.mapSize.x=s.x),n.y>h&&(s.y=Math.floor(h/$.y),n.y=s.y*$.y,k.mapSize.y=s.y));const tt=r.state.buffers.depth.getReversed();if(k.camera._reversedDepth=tt,k.map===null||V===!0){if(k.map!==null&&(k.map.depthTexture!==null&&(k.map.depthTexture.dispose(),k.map.depthTexture=null),k.map.dispose()),this.type===mo){if(B.isPointLight){Rt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}k.map=new ri(n.x,n.y,{format:Na,type:qe,minFilter:oe,magFilter:oe,generateMipmaps:!1}),k.map.texture.name=B.name+".shadowMap",k.map.depthTexture=new na(n.x,n.y,Oi),k.map.depthTexture.name=B.name+".shadowMapDepth",k.map.depthTexture.format=Es,k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=Re,k.map.depthTexture.magFilter=Re}else B.isPointLight?(k.map=new Vo(n.x),k.map.depthTexture=new NM(n.x,Sn)):(k.map=new ri(n.x,n.y),k.map.depthTexture=new na(n.x,n.y,Sn)),k.map.depthTexture.name=B.name+".shadowMap",k.map.depthTexture.format=Es,this.type===So?(k.map.depthTexture.compareFunction=tt?h0:l0,k.map.depthTexture.minFilter=oe,k.map.depthTexture.magFilter=oe):(k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=Re,k.map.depthTexture.magFilter=Re);k.camera.updateProjectionMatrix()}const J=k.map.isWebGLCubeRenderTarget?6:1;for(let it=0;it<J;it++){if(k.map.isWebGLCubeRenderTarget)r.setRenderTarget(k.map,it),r.clear();else{it===0&&(r.setRenderTarget(k.map),r.clear());const rt=k.getViewport(it);a.set(s.x*rt.x,s.y*rt.y,s.x*rt.z,s.y*rt.w),P.viewport(a)}if(B.isPointLight){const rt=k.camera,Vt=k.matrix,Jt=B.distance||rt.far;Jt!==rt.far&&(rt.far=Jt,rt.updateProjectionMatrix()),no.setFromMatrixPosition(B.matrixWorld),rt.position.copy(no),Hh.copy(rt.position),Hh.add(QS[it]),rt.up.copy(tb[it]),rt.lookAt(Hh),rt.updateMatrixWorld(),Vt.makeTranslation(-no.x,-no.y,-no.z),Up.multiplyMatrices(rt.projectionMatrix,rt.matrixWorldInverse),k._frustum.setFromProjectionMatrix(Up,rt.coordinateSystem,rt.reversedDepth)}else k.updateMatrices(B);i=k.getFrustum(),M(T,x,k.camera,B,this.type)}k.isPointLightShadow!==!0&&this.type===mo&&S(k,x),k.needsUpdate=!1}g=this.type,m.needsUpdate=!1,r.setRenderTarget(A,C,I)};function S(w,T){const x=t.update(v);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new ri(n.x,n.y,{format:Na,type:qe})),d.uniforms.shadow_pass.value=w.map.depthTexture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,r.setRenderTarget(w.mapPass),r.clear(),r.renderBufferDirect(T,null,x,d,v,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,r.setRenderTarget(w.map),r.clear(),r.renderBufferDirect(T,null,x,f,v,null)}function y(w,T,x,A){let C=null;const I=x.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(I!==void 0)C=I;else if(C=x.isPointLight===!0?c:o,r.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0||T.alphaToCoverage===!0){const P=C.uuid,V=T.uuid;let X=l[P];X===void 0&&(X={},l[P]=X);let L=X[V];L===void 0&&(L=C.clone(),X[V]=L,T.addEventListener("dispose",b)),C=L}if(C.visible=T.visible,C.wireframe=T.wireframe,A===mo?C.side=T.shadowSide!==null?T.shadowSide:T.side:C.side=T.shadowSide!==null?T.shadowSide:u[T.side],C.alphaMap=T.alphaMap,C.alphaTest=T.alphaToCoverage===!0?.5:T.alphaTest,C.map=T.map,C.clipShadows=T.clipShadows,C.clippingPlanes=T.clippingPlanes,C.clipIntersection=T.clipIntersection,C.displacementMap=T.displacementMap,C.displacementScale=T.displacementScale,C.displacementBias=T.displacementBias,C.wireframeLinewidth=T.wireframeLinewidth,C.linewidth=T.linewidth,x.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const P=r.properties.get(C);P.light=x}return C}function M(w,T,x,A,C){if(w.visible===!1)return;if(w.layers.test(T.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&C===mo)&&(!w.frustumCulled||i.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,w.matrixWorld);const V=t.update(w),X=w.material;if(Array.isArray(X)){const L=V.groups;for(let B=0,k=L.length;B<k;B++){const $=L[B],tt=X[$.materialIndex];if(tt&&tt.visible){const J=y(w,tt,A,C);w.onBeforeShadow(r,w,T,x,V,J,$),r.renderBufferDirect(x,null,V,J,w,$),w.onAfterShadow(r,w,T,x,V,J,$)}}}else if(X.visible){const L=y(w,X,A,C);w.onBeforeShadow(r,w,T,x,V,L,null),r.renderBufferDirect(x,null,V,L,w,null),w.onAfterShadow(r,w,T,x,V,L,null)}}const P=w.children;for(let V=0,X=P.length;V<X;V++)M(P[V],T,x,A,C)}function b(w){w.target.removeEventListener("dispose",b);for(const x in l){const A=l[x],C=w.target.uuid;C in A&&(A[C].dispose(),delete A[C])}}}function ib(r,t){function e(){let O=!1;const ct=new ne;let j=null;const dt=new ne(0,0,0,0);return{setMask:function(vt){j!==vt&&!O&&(r.colorMask(vt,vt,vt,vt),j=vt)},setLocked:function(vt){O=vt},setClear:function(vt,et,It,bt,Je){Je===!0&&(vt*=bt,et*=bt,It*=bt),ct.set(vt,et,It,bt),dt.equals(ct)===!1&&(r.clearColor(vt,et,It,bt),dt.copy(ct))},reset:function(){O=!1,j=null,dt.set(-1,0,0,0)}}}function i(){let O=!1,ct=!1,j=null,dt=null,vt=null;return{setReversed:function(et){if(ct!==et){const It=t.get("EXT_clip_control");et?It.clipControlEXT(It.LOWER_LEFT_EXT,It.ZERO_TO_ONE_EXT):It.clipControlEXT(It.LOWER_LEFT_EXT,It.NEGATIVE_ONE_TO_ONE_EXT),ct=et;const bt=vt;vt=null,this.setClear(bt)}},getReversed:function(){return ct},setTest:function(et){et?nt(r.DEPTH_TEST):z(r.DEPTH_TEST)},setMask:function(et){j!==et&&!O&&(r.depthMask(et),j=et)},setFunc:function(et){if(ct&&(et=V2[et]),dt!==et){switch(et){case Tu:r.depthFunc(r.NEVER);break;case Ru:r.depthFunc(r.ALWAYS);break;case Du:r.depthFunc(r.LESS);break;case Pr:r.depthFunc(r.LEQUAL);break;case Iu:r.depthFunc(r.EQUAL);break;case Cu:r.depthFunc(r.GEQUAL);break;case Pu:r.depthFunc(r.GREATER);break;case Lu:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}dt=et}},setLocked:function(et){O=et},setClear:function(et){vt!==et&&(vt=et,ct&&(et=1-et),r.clearDepth(et))},reset:function(){O=!1,j=null,dt=null,vt=null,ct=!1}}}function n(){let O=!1,ct=null,j=null,dt=null,vt=null,et=null,It=null,bt=null,Je=null;return{setTest:function(Pe){O||(Pe?nt(r.STENCIL_TEST):z(r.STENCIL_TEST))},setMask:function(Pe){ct!==Pe&&!O&&(r.stencilMask(Pe),ct=Pe)},setFunc:function(Pe,zn,Bn){(j!==Pe||dt!==zn||vt!==Bn)&&(r.stencilFunc(Pe,zn,Bn),j=Pe,dt=zn,vt=Bn)},setOp:function(Pe,zn,Bn){(et!==Pe||It!==zn||bt!==Bn)&&(r.stencilOp(Pe,zn,Bn),et=Pe,It=zn,bt=Bn)},setLocked:function(Pe){O=Pe},setClear:function(Pe){Je!==Pe&&(r.clearStencil(Pe),Je=Pe)},reset:function(){O=!1,ct=null,j=null,dt=null,vt=null,et=null,It=null,bt=null,Je=null}}}const s=new e,a=new i,o=new n,c=new WeakMap,l=new WeakMap;let h={},u={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,S=null,y=null,M=null,b=null,w=null,T=null,x=new st(0,0,0),A=0,C=!1,I=null,P=null,V=null,X=null,L=null;const B=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,$=0;const tt=r.getParameter(r.VERSION);tt.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(tt)[1]),k=$>=1):tt.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(tt)[1]),k=$>=2);let J=null,it={};const rt=r.getParameter(r.SCISSOR_BOX),Vt=r.getParameter(r.VIEWPORT),Jt=new ne().fromArray(rt),qt=new ne().fromArray(Vt);function q(O,ct,j,dt){const vt=new Uint8Array(4),et=r.createTexture();r.bindTexture(O,et),r.texParameteri(O,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(O,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let It=0;It<j;It++)O===r.TEXTURE_3D||O===r.TEXTURE_2D_ARRAY?r.texImage3D(ct,0,r.RGBA,1,1,dt,0,r.RGBA,r.UNSIGNED_BYTE,vt):r.texImage2D(ct+It,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,vt);return et}const at={};at[r.TEXTURE_2D]=q(r.TEXTURE_2D,r.TEXTURE_2D,1),at[r.TEXTURE_CUBE_MAP]=q(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),at[r.TEXTURE_2D_ARRAY]=q(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),at[r.TEXTURE_3D]=q(r.TEXTURE_3D,r.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),nt(r.DEPTH_TEST),a.setFunc(Pr),Me(!1),xe(yf),nt(r.CULL_FACE),zt(as);function nt(O){h[O]!==!0&&(r.enable(O),h[O]=!0)}function z(O){h[O]!==!1&&(r.disable(O),h[O]=!1)}function Tt(O,ct){return d[O]!==ct?(r.bindFramebuffer(O,ct),d[O]=ct,O===r.DRAW_FRAMEBUFFER&&(d[r.FRAMEBUFFER]=ct),O===r.FRAMEBUFFER&&(d[r.DRAW_FRAMEBUFFER]=ct),!0):!1}function Nt(O,ct){let j=p,dt=!1;if(O){j=f.get(ct),j===void 0&&(j=[],f.set(ct,j));const vt=O.textures;if(j.length!==vt.length||j[0]!==r.COLOR_ATTACHMENT0){for(let et=0,It=vt.length;et<It;et++)j[et]=r.COLOR_ATTACHMENT0+et;j.length=vt.length,dt=!0}}else j[0]!==r.BACK&&(j[0]=r.BACK,dt=!0);dt&&r.drawBuffers(j)}function Ct(O){return v!==O?(r.useProgram(O),v=O,!0):!1}const _t={[Ma]:r.FUNC_ADD,[c2]:r.FUNC_SUBTRACT,[l2]:r.FUNC_REVERSE_SUBTRACT};_t[h2]=r.MIN,_t[u2]=r.MAX;const kt={[d2]:r.ZERO,[Fo]:r.ONE,[f2]:r.SRC_COLOR,[Au]:r.SRC_ALPHA,[x2]:r.SRC_ALPHA_SATURATE,[v2]:r.DST_COLOR,[m2]:r.DST_ALPHA,[p2]:r.ONE_MINUS_SRC_COLOR,[Uo]:r.ONE_MINUS_SRC_ALPHA,[M2]:r.ONE_MINUS_DST_COLOR,[g2]:r.ONE_MINUS_DST_ALPHA,[y2]:r.CONSTANT_COLOR,[_2]:r.ONE_MINUS_CONSTANT_COLOR,[S2]:r.CONSTANT_ALPHA,[b2]:r.ONE_MINUS_CONSTANT_ALPHA};function zt(O,ct,j,dt,vt,et,It,bt,Je,Pe){if(O===as){m===!0&&(z(r.BLEND),m=!1);return}if(m===!1&&(nt(r.BLEND),m=!0),O!==zl){if(O!==g||Pe!==C){if((S!==Ma||b!==Ma)&&(r.blendEquation(r.FUNC_ADD),S=Ma,b=Ma),Pe)switch(O){case ta:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Ni:r.blendFunc(r.ONE,r.ONE);break;case _f:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Sf:r.blendFuncSeparate(r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:Gt("WebGLState: Invalid blending: ",O);break}else switch(O){case ta:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Ni:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE,r.ONE,r.ONE);break;case _f:Gt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Sf:Gt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Gt("WebGLState: Invalid blending: ",O);break}y=null,M=null,w=null,T=null,x.set(0,0,0),A=0,g=O,C=Pe}return}vt=vt||ct,et=et||j,It=It||dt,(ct!==S||vt!==b)&&(r.blendEquationSeparate(_t[ct],_t[vt]),S=ct,b=vt),(j!==y||dt!==M||et!==w||It!==T)&&(r.blendFuncSeparate(kt[j],kt[dt],kt[et],kt[It]),y=j,M=dt,w=et,T=It),(bt.equals(x)===!1||Je!==A)&&(r.blendColor(bt.r,bt.g,bt.b,Je),x.copy(bt),A=Je),g=O,C=!1}function Bt(O,ct){O.side===ji?z(r.CULL_FACE):nt(r.CULL_FACE);let j=O.side===Ve;ct&&(j=!j),Me(j),O.blending===ta&&O.transparent===!1?zt(as):zt(O.blending,O.blendEquation,O.blendSrc,O.blendDst,O.blendEquationAlpha,O.blendSrcAlpha,O.blendDstAlpha,O.blendColor,O.blendAlpha,O.premultipliedAlpha),a.setFunc(O.depthFunc),a.setTest(O.depthTest),a.setMask(O.depthWrite),s.setMask(O.colorWrite);const dt=O.stencilWrite;o.setTest(dt),dt&&(o.setMask(O.stencilWriteMask),o.setFunc(O.stencilFunc,O.stencilRef,O.stencilFuncMask),o.setOp(O.stencilFail,O.stencilZFail,O.stencilZPass)),He(O.polygonOffset,O.polygonOffsetFactor,O.polygonOffsetUnits),O.alphaToCoverage===!0?nt(r.SAMPLE_ALPHA_TO_COVERAGE):z(r.SAMPLE_ALPHA_TO_COVERAGE)}function Me(O){I!==O&&(O?r.frontFace(r.CW):r.frontFace(r.CCW),I=O)}function xe(O){O!==a2?(nt(r.CULL_FACE),O!==P&&(O===yf?r.cullFace(r.BACK):O===r2?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):z(r.CULL_FACE),P=O}function Ke(O){O!==V&&(k&&r.lineWidth(O),V=O)}function He(O,ct,j){O?(nt(r.POLYGON_OFFSET_FILL),(X!==ct||L!==j)&&(X=ct,L=j,a.getReversed()&&(ct=-ct),r.polygonOffset(ct,j))):z(r.POLYGON_OFFSET_FILL)}function Ze(O){O?nt(r.SCISSOR_TEST):z(r.SCISSOR_TEST)}function ci(O){O===void 0&&(O=r.TEXTURE0+B-1),J!==O&&(r.activeTexture(O),J=O)}function N(O,ct,j){j===void 0&&(J===null?j=r.TEXTURE0+B-1:j=J);let dt=it[j];dt===void 0&&(dt={type:void 0,texture:void 0},it[j]=dt),(dt.type!==O||dt.texture!==ct)&&(J!==j&&(r.activeTexture(j),J=j),r.bindTexture(O,ct||at[O]),dt.type=O,dt.texture=ct)}function Yi(){const O=it[J];O!==void 0&&O.type!==void 0&&(r.bindTexture(O.type,null),O.type=void 0,O.texture=void 0)}function ye(){try{r.compressedTexImage2D(...arguments)}catch(O){Gt("WebGLState:",O)}}function D(){try{r.compressedTexImage3D(...arguments)}catch(O){Gt("WebGLState:",O)}}function _(){try{r.texSubImage2D(...arguments)}catch(O){Gt("WebGLState:",O)}}function U(){try{r.texSubImage3D(...arguments)}catch(O){Gt("WebGLState:",O)}}function W(){try{r.compressedTexSubImage2D(...arguments)}catch(O){Gt("WebGLState:",O)}}function K(){try{r.compressedTexSubImage3D(...arguments)}catch(O){Gt("WebGLState:",O)}}function ot(){try{r.texStorage2D(...arguments)}catch(O){Gt("WebGLState:",O)}}function lt(){try{r.texStorage3D(...arguments)}catch(O){Gt("WebGLState:",O)}}function Z(){try{r.texImage2D(...arguments)}catch(O){Gt("WebGLState:",O)}}function Q(){try{r.texImage3D(...arguments)}catch(O){Gt("WebGLState:",O)}}function ht(O){return u[O]!==void 0?u[O]:r.getParameter(O)}function Pt(O,ct){u[O]!==ct&&(r.pixelStorei(O,ct),u[O]=ct)}function ft(O){Jt.equals(O)===!1&&(r.scissor(O.x,O.y,O.z,O.w),Jt.copy(O))}function ut(O){qt.equals(O)===!1&&(r.viewport(O.x,O.y,O.z,O.w),qt.copy(O))}function Ut(O,ct){let j=l.get(ct);j===void 0&&(j=new WeakMap,l.set(ct,j));let dt=j.get(O);dt===void 0&&(dt=r.getUniformBlockIndex(ct,O.name),j.set(O,dt))}function Ht(O,ct){const dt=l.get(ct).get(O);c.get(ct)!==dt&&(r.uniformBlockBinding(ct,dt,O.__bindingPointIndex),c.set(ct,dt))}function $t(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),a.setReversed(!1),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),r.pixelStorei(r.PACK_ALIGNMENT,4),r.pixelStorei(r.UNPACK_ALIGNMENT,4),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.BROWSER_DEFAULT_WEBGL),r.pixelStorei(r.PACK_ROW_LENGTH,0),r.pixelStorei(r.PACK_SKIP_PIXELS,0),r.pixelStorei(r.PACK_SKIP_ROWS,0),r.pixelStorei(r.UNPACK_ROW_LENGTH,0),r.pixelStorei(r.UNPACK_IMAGE_HEIGHT,0),r.pixelStorei(r.UNPACK_SKIP_PIXELS,0),r.pixelStorei(r.UNPACK_SKIP_ROWS,0),r.pixelStorei(r.UNPACK_SKIP_IMAGES,0),h={},u={},J=null,it={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,S=null,y=null,M=null,b=null,w=null,T=null,x=new st(0,0,0),A=0,C=!1,I=null,P=null,V=null,X=null,L=null,Jt.set(0,0,r.canvas.width,r.canvas.height),qt.set(0,0,r.canvas.width,r.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:nt,disable:z,bindFramebuffer:Tt,drawBuffers:Nt,useProgram:Ct,setBlending:zt,setMaterial:Bt,setFlipSided:Me,setCullFace:xe,setLineWidth:Ke,setPolygonOffset:He,setScissorTest:Ze,activeTexture:ci,bindTexture:N,unbindTexture:Yi,compressedTexImage2D:ye,compressedTexImage3D:D,texImage2D:Z,texImage3D:Q,pixelStorei:Pt,getParameter:ht,updateUBOMapping:Ut,uniformBlockBinding:Ht,texStorage2D:ot,texStorage3D:lt,texSubImage2D:_,texSubImage3D:U,compressedTexSubImage2D:W,compressedTexSubImage3D:K,scissor:ft,viewport:ut,reset:$t}}function nb(r,t,e,i,n,s,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new xt,h=new WeakMap,u=new Set;let d;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(D,_){return p?new OffscreenCanvas(D,_):Go("canvas")}function m(D,_,U){let W=1;const K=ye(D);if((K.width>U||K.height>U)&&(W=U/Math.max(K.width,K.height)),W<1)if(typeof HTMLImageElement<"u"&&D instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&D instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&D instanceof ImageBitmap||typeof VideoFrame<"u"&&D instanceof VideoFrame){const ot=Math.floor(W*K.width),lt=Math.floor(W*K.height);d===void 0&&(d=v(ot,lt));const Z=_?v(ot,lt):d;return Z.width=ot,Z.height=lt,Z.getContext("2d").drawImage(D,0,0,ot,lt),Rt("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+ot+"x"+lt+")."),Z}else return"data"in D&&Rt("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),D;return D}function g(D){return D.generateMipmaps}function S(D){r.generateMipmap(D)}function y(D){return D.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:D.isWebGL3DRenderTarget?r.TEXTURE_3D:D.isWebGLArrayRenderTarget||D.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function M(D,_,U,W,K,ot=!1){if(D!==null){if(r[D]!==void 0)return r[D];Rt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+D+"'")}let lt;W&&(lt=t.get("EXT_texture_norm16"),lt||Rt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=_;if(_===r.RED&&(U===r.FLOAT&&(Z=r.R32F),U===r.HALF_FLOAT&&(Z=r.R16F),U===r.UNSIGNED_BYTE&&(Z=r.R8),U===r.UNSIGNED_SHORT&&lt&&(Z=lt.R16_EXT),U===r.SHORT&&lt&&(Z=lt.R16_SNORM_EXT)),_===r.RED_INTEGER&&(U===r.UNSIGNED_BYTE&&(Z=r.R8UI),U===r.UNSIGNED_SHORT&&(Z=r.R16UI),U===r.UNSIGNED_INT&&(Z=r.R32UI),U===r.BYTE&&(Z=r.R8I),U===r.SHORT&&(Z=r.R16I),U===r.INT&&(Z=r.R32I)),_===r.RG&&(U===r.FLOAT&&(Z=r.RG32F),U===r.HALF_FLOAT&&(Z=r.RG16F),U===r.UNSIGNED_BYTE&&(Z=r.RG8),U===r.UNSIGNED_SHORT&&lt&&(Z=lt.RG16_EXT),U===r.SHORT&&lt&&(Z=lt.RG16_SNORM_EXT)),_===r.RG_INTEGER&&(U===r.UNSIGNED_BYTE&&(Z=r.RG8UI),U===r.UNSIGNED_SHORT&&(Z=r.RG16UI),U===r.UNSIGNED_INT&&(Z=r.RG32UI),U===r.BYTE&&(Z=r.RG8I),U===r.SHORT&&(Z=r.RG16I),U===r.INT&&(Z=r.RG32I)),_===r.RGB_INTEGER&&(U===r.UNSIGNED_BYTE&&(Z=r.RGB8UI),U===r.UNSIGNED_SHORT&&(Z=r.RGB16UI),U===r.UNSIGNED_INT&&(Z=r.RGB32UI),U===r.BYTE&&(Z=r.RGB8I),U===r.SHORT&&(Z=r.RGB16I),U===r.INT&&(Z=r.RGB32I)),_===r.RGBA_INTEGER&&(U===r.UNSIGNED_BYTE&&(Z=r.RGBA8UI),U===r.UNSIGNED_SHORT&&(Z=r.RGBA16UI),U===r.UNSIGNED_INT&&(Z=r.RGBA32UI),U===r.BYTE&&(Z=r.RGBA8I),U===r.SHORT&&(Z=r.RGBA16I),U===r.INT&&(Z=r.RGBA32I)),_===r.RGB&&(U===r.UNSIGNED_SHORT&&lt&&(Z=lt.RGB16_EXT),U===r.SHORT&&lt&&(Z=lt.RGB16_SNORM_EXT),U===r.UNSIGNED_INT_5_9_9_9_REV&&(Z=r.RGB9_E5),U===r.UNSIGNED_INT_10F_11F_11F_REV&&(Z=r.R11F_G11F_B10F)),_===r.RGBA){const Q=ot?yl:re.getTransfer(K);U===r.FLOAT&&(Z=r.RGBA32F),U===r.HALF_FLOAT&&(Z=r.RGBA16F),U===r.UNSIGNED_BYTE&&(Z=Q===Se?r.SRGB8_ALPHA8:r.RGBA8),U===r.UNSIGNED_SHORT&&lt&&(Z=lt.RGBA16_EXT),U===r.SHORT&&lt&&(Z=lt.RGBA16_SNORM_EXT),U===r.UNSIGNED_SHORT_4_4_4_4&&(Z=r.RGBA4),U===r.UNSIGNED_SHORT_5_5_5_1&&(Z=r.RGB5_A1)}return(Z===r.R16F||Z===r.R32F||Z===r.RG16F||Z===r.RG32F||Z===r.RGBA16F||Z===r.RGBA32F)&&t.get("EXT_color_buffer_float"),Z}function b(D,_){let U;return D?_===null||_===Sn||_===Bo?U=r.DEPTH24_STENCIL8:_===Oi?U=r.DEPTH32F_STENCIL8:_===zo&&(U=r.DEPTH24_STENCIL8,Rt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===Sn||_===Bo?U=r.DEPTH_COMPONENT24:_===Oi?U=r.DEPTH_COMPONENT32F:_===zo&&(U=r.DEPTH_COMPONENT16),U}function w(D,_){return g(D)===!0||D.isFramebufferTexture&&D.minFilter!==Re&&D.minFilter!==oe?Math.log2(Math.max(_.width,_.height))+1:D.mipmaps!==void 0&&D.mipmaps.length>0?D.mipmaps.length:D.isCompressedTexture&&Array.isArray(D.image)?_.mipmaps.length:1}function T(D){const _=D.target;_.removeEventListener("dispose",T),A(_),_.isVideoTexture&&h.delete(_),_.isHTMLTexture&&u.delete(_)}function x(D){const _=D.target;_.removeEventListener("dispose",x),I(_)}function A(D){const _=i.get(D);if(_.__webglInit===void 0)return;const U=D.source,W=f.get(U);if(W){const K=W[_.__cacheKey];K.usedTimes--,K.usedTimes===0&&C(D),Object.keys(W).length===0&&f.delete(U)}i.remove(D)}function C(D){const _=i.get(D);r.deleteTexture(_.__webglTexture);const U=D.source,W=f.get(U);delete W[_.__cacheKey],a.memory.textures--}function I(D){const _=i.get(D);if(D.depthTexture&&(D.depthTexture.dispose(),i.remove(D.depthTexture)),D.isWebGLCubeRenderTarget)for(let W=0;W<6;W++){if(Array.isArray(_.__webglFramebuffer[W]))for(let K=0;K<_.__webglFramebuffer[W].length;K++)r.deleteFramebuffer(_.__webglFramebuffer[W][K]);else r.deleteFramebuffer(_.__webglFramebuffer[W]);_.__webglDepthbuffer&&r.deleteRenderbuffer(_.__webglDepthbuffer[W])}else{if(Array.isArray(_.__webglFramebuffer))for(let W=0;W<_.__webglFramebuffer.length;W++)r.deleteFramebuffer(_.__webglFramebuffer[W]);else r.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&r.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&r.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let W=0;W<_.__webglColorRenderbuffer.length;W++)_.__webglColorRenderbuffer[W]&&r.deleteRenderbuffer(_.__webglColorRenderbuffer[W]);_.__webglDepthRenderbuffer&&r.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const U=D.textures;for(let W=0,K=U.length;W<K;W++){const ot=i.get(U[W]);ot.__webglTexture&&(r.deleteTexture(ot.__webglTexture),a.memory.textures--),i.remove(U[W])}i.remove(D)}let P=0;function V(){P=0}function X(){return P}function L(D){P=D}function B(){const D=P;return D>=n.maxTextures&&Rt("WebGLTextures: Trying to use "+D+" texture units while this GPU supports only "+n.maxTextures),P+=1,D}function k(D){const _=[];return _.push(D.wrapS),_.push(D.wrapT),_.push(D.wrapR||0),_.push(D.magFilter),_.push(D.minFilter),_.push(D.anisotropy),_.push(D.internalFormat),_.push(D.format),_.push(D.type),_.push(D.generateMipmaps),_.push(D.premultiplyAlpha),_.push(D.flipY),_.push(D.unpackAlignment),_.push(D.colorSpace),_.join()}function $(D,_){const U=i.get(D);if(D.isVideoTexture&&N(D),D.isRenderTargetTexture===!1&&D.isExternalTexture!==!0&&D.version>0&&U.__version!==D.version){const W=D.image;if(W===null)Rt("WebGLRenderer: Texture marked for update but no image data found.");else if(W.complete===!1)Rt("WebGLRenderer: Texture marked for update but image is incomplete");else{z(U,D,_);return}}else D.isExternalTexture&&(U.__webglTexture=D.sourceTexture?D.sourceTexture:null);e.bindTexture(r.TEXTURE_2D,U.__webglTexture,r.TEXTURE0+_)}function tt(D,_){const U=i.get(D);if(D.isRenderTargetTexture===!1&&D.version>0&&U.__version!==D.version){z(U,D,_);return}else D.isExternalTexture&&(U.__webglTexture=D.sourceTexture?D.sourceTexture:null);e.bindTexture(r.TEXTURE_2D_ARRAY,U.__webglTexture,r.TEXTURE0+_)}function J(D,_){const U=i.get(D);if(D.isRenderTargetTexture===!1&&D.version>0&&U.__version!==D.version){z(U,D,_);return}e.bindTexture(r.TEXTURE_3D,U.__webglTexture,r.TEXTURE0+_)}function it(D,_){const U=i.get(D);if(D.isCubeDepthTexture!==!0&&D.version>0&&U.__version!==D.version){Tt(U,D,_);return}e.bindTexture(r.TEXTURE_CUBE_MAP,U.__webglTexture,r.TEXTURE0+_)}const rt={[ko]:r.REPEAT,[wi]:r.CLAMP_TO_EDGE,[Ou]:r.MIRRORED_REPEAT},Vt={[Re]:r.NEAREST,[T2]:r.NEAREST_MIPMAP_NEAREST,[sc]:r.NEAREST_MIPMAP_LINEAR,[oe]:r.LINEAR,[rh]:r.LINEAR_MIPMAP_NEAREST,[wa]:r.LINEAR_MIPMAP_LINEAR},Jt={[L2]:r.NEVER,[k2]:r.ALWAYS,[O2]:r.LESS,[l0]:r.LEQUAL,[N2]:r.EQUAL,[h0]:r.GEQUAL,[F2]:r.GREATER,[U2]:r.NOTEQUAL};function qt(D,_){if(_.type===Oi&&t.has("OES_texture_float_linear")===!1&&(_.magFilter===oe||_.magFilter===rh||_.magFilter===sc||_.magFilter===wa||_.minFilter===oe||_.minFilter===rh||_.minFilter===sc||_.minFilter===wa)&&Rt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(D,r.TEXTURE_WRAP_S,rt[_.wrapS]),r.texParameteri(D,r.TEXTURE_WRAP_T,rt[_.wrapT]),(D===r.TEXTURE_3D||D===r.TEXTURE_2D_ARRAY)&&r.texParameteri(D,r.TEXTURE_WRAP_R,rt[_.wrapR]),r.texParameteri(D,r.TEXTURE_MAG_FILTER,Vt[_.magFilter]),r.texParameteri(D,r.TEXTURE_MIN_FILTER,Vt[_.minFilter]),_.compareFunction&&(r.texParameteri(D,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(D,r.TEXTURE_COMPARE_FUNC,Jt[_.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===Re||_.minFilter!==sc&&_.minFilter!==wa||_.type===Oi&&t.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||i.get(_).__currentAnisotropy){const U=t.get("EXT_texture_filter_anisotropic");r.texParameterf(D,U.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,n.getMaxAnisotropy())),i.get(_).__currentAnisotropy=_.anisotropy}}}function q(D,_){let U=!1;D.__webglInit===void 0&&(D.__webglInit=!0,_.addEventListener("dispose",T));const W=_.source;let K=f.get(W);K===void 0&&(K={},f.set(W,K));const ot=k(_);if(ot!==D.__cacheKey){K[ot]===void 0&&(K[ot]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,U=!0),K[ot].usedTimes++;const lt=K[D.__cacheKey];lt!==void 0&&(K[D.__cacheKey].usedTimes--,lt.usedTimes===0&&C(_)),D.__cacheKey=ot,D.__webglTexture=K[ot].texture}return U}function at(D,_,U){return Math.floor(Math.floor(D/U)/_)}function nt(D,_,U,W){const ot=D.updateRanges;if(ot.length===0)e.texSubImage2D(r.TEXTURE_2D,0,0,0,_.width,_.height,U,W,_.data);else{ot.sort((Pt,ft)=>Pt.start-ft.start);let lt=0;for(let Pt=1;Pt<ot.length;Pt++){const ft=ot[lt],ut=ot[Pt],Ut=ft.start+ft.count,Ht=at(ut.start,_.width,4),$t=at(ft.start,_.width,4);ut.start<=Ut+1&&Ht===$t&&at(ut.start+ut.count-1,_.width,4)===Ht?ft.count=Math.max(ft.count,ut.start+ut.count-ft.start):(++lt,ot[lt]=ut)}ot.length=lt+1;const Z=e.getParameter(r.UNPACK_ROW_LENGTH),Q=e.getParameter(r.UNPACK_SKIP_PIXELS),ht=e.getParameter(r.UNPACK_SKIP_ROWS);e.pixelStorei(r.UNPACK_ROW_LENGTH,_.width);for(let Pt=0,ft=ot.length;Pt<ft;Pt++){const ut=ot[Pt],Ut=Math.floor(ut.start/4),Ht=Math.ceil(ut.count/4),$t=Ut%_.width,O=Math.floor(Ut/_.width),ct=Ht,j=1;e.pixelStorei(r.UNPACK_SKIP_PIXELS,$t),e.pixelStorei(r.UNPACK_SKIP_ROWS,O),e.texSubImage2D(r.TEXTURE_2D,0,$t,O,ct,j,U,W,_.data)}D.clearUpdateRanges(),e.pixelStorei(r.UNPACK_ROW_LENGTH,Z),e.pixelStorei(r.UNPACK_SKIP_PIXELS,Q),e.pixelStorei(r.UNPACK_SKIP_ROWS,ht)}}function z(D,_,U){let W=r.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(W=r.TEXTURE_2D_ARRAY),_.isData3DTexture&&(W=r.TEXTURE_3D);const K=q(D,_),ot=_.source;e.bindTexture(W,D.__webglTexture,r.TEXTURE0+U);const lt=i.get(ot);if(ot.version!==lt.__version||K===!0){if(e.activeTexture(r.TEXTURE0+U),(typeof ImageBitmap<"u"&&_.image instanceof ImageBitmap)===!1){const j=re.getPrimaries(re.workingColorSpace),dt=_.colorSpace===Ks?null:re.getPrimaries(_.colorSpace),vt=_.colorSpace===Ks||j===dt?r.NONE:r.BROWSER_DEFAULT_WEBGL;e.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,_.flipY),e.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),e.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,vt)}e.pixelStorei(r.UNPACK_ALIGNMENT,_.unpackAlignment);let Q=m(_.image,!1,n.maxTextureSize);Q=Yi(_,Q);const ht=s.convert(_.format,_.colorSpace),Pt=s.convert(_.type);let ft=M(_.internalFormat,ht,Pt,_.normalized,_.colorSpace,_.isVideoTexture);qt(W,_);let ut;const Ut=_.mipmaps,Ht=_.isVideoTexture!==!0,$t=lt.__version===void 0||K===!0,O=ot.dataReady,ct=w(_,Q);if(_.isDepthTexture)ft=b(_.format===Ea,_.type),$t&&(Ht?e.texStorage2D(r.TEXTURE_2D,1,ft,Q.width,Q.height):e.texImage2D(r.TEXTURE_2D,0,ft,Q.width,Q.height,0,ht,Pt,null));else if(_.isDataTexture)if(Ut.length>0){Ht&&$t&&e.texStorage2D(r.TEXTURE_2D,ct,ft,Ut[0].width,Ut[0].height);for(let j=0,dt=Ut.length;j<dt;j++)ut=Ut[j],Ht?O&&e.texSubImage2D(r.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,Pt,ut.data):e.texImage2D(r.TEXTURE_2D,j,ft,ut.width,ut.height,0,ht,Pt,ut.data);_.generateMipmaps=!1}else Ht?($t&&e.texStorage2D(r.TEXTURE_2D,ct,ft,Q.width,Q.height),O&&nt(_,Q,ht,Pt)):e.texImage2D(r.TEXTURE_2D,0,ft,Q.width,Q.height,0,ht,Pt,Q.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){Ht&&$t&&e.texStorage3D(r.TEXTURE_2D_ARRAY,ct,ft,Ut[0].width,Ut[0].height,Q.depth);for(let j=0,dt=Ut.length;j<dt;j++)if(ut=Ut[j],_.format!==Ei)if(ht!==null)if(Ht){if(O)if(_.layerUpdates.size>0){const vt=mp(ut.width,ut.height,_.format,_.type);for(const et of _.layerUpdates){const It=ut.data.subarray(et*vt/ut.data.BYTES_PER_ELEMENT,(et+1)*vt/ut.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,j,0,0,et,ut.width,ut.height,1,ht,It)}_.clearLayerUpdates()}else e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,j,0,0,0,ut.width,ut.height,Q.depth,ht,ut.data)}else e.compressedTexImage3D(r.TEXTURE_2D_ARRAY,j,ft,ut.width,ut.height,Q.depth,0,ut.data,0,0);else Rt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ht?O&&e.texSubImage3D(r.TEXTURE_2D_ARRAY,j,0,0,0,ut.width,ut.height,Q.depth,ht,Pt,ut.data):e.texImage3D(r.TEXTURE_2D_ARRAY,j,ft,ut.width,ut.height,Q.depth,0,ht,Pt,ut.data)}else{Ht&&$t&&e.texStorage2D(r.TEXTURE_2D,ct,ft,Ut[0].width,Ut[0].height);for(let j=0,dt=Ut.length;j<dt;j++)ut=Ut[j],_.format!==Ei?ht!==null?Ht?O&&e.compressedTexSubImage2D(r.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,ut.data):e.compressedTexImage2D(r.TEXTURE_2D,j,ft,ut.width,ut.height,0,ut.data):Rt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ht?O&&e.texSubImage2D(r.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,Pt,ut.data):e.texImage2D(r.TEXTURE_2D,j,ft,ut.width,ut.height,0,ht,Pt,ut.data)}else if(_.isDataArrayTexture)if(Ht){if($t&&e.texStorage3D(r.TEXTURE_2D_ARRAY,ct,ft,Q.width,Q.height,Q.depth),O)if(_.layerUpdates.size>0){const j=mp(Q.width,Q.height,_.format,_.type);for(const dt of _.layerUpdates){const vt=Q.data.subarray(dt*j/Q.data.BYTES_PER_ELEMENT,(dt+1)*j/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,dt,Q.width,Q.height,1,ht,Pt,vt)}_.clearLayerUpdates()}else e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ht,Pt,Q.data)}else e.texImage3D(r.TEXTURE_2D_ARRAY,0,ft,Q.width,Q.height,Q.depth,0,ht,Pt,Q.data);else if(_.isData3DTexture)Ht?($t&&e.texStorage3D(r.TEXTURE_3D,ct,ft,Q.width,Q.height,Q.depth),O&&e.texSubImage3D(r.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ht,Pt,Q.data)):e.texImage3D(r.TEXTURE_3D,0,ft,Q.width,Q.height,Q.depth,0,ht,Pt,Q.data);else if(_.isFramebufferTexture){if($t)if(Ht)e.texStorage2D(r.TEXTURE_2D,ct,ft,Q.width,Q.height);else{let j=Q.width,dt=Q.height;for(let vt=0;vt<ct;vt++)e.texImage2D(r.TEXTURE_2D,vt,ft,j,dt,0,ht,Pt,null),j>>=1,dt>>=1}}else if(_.isHTMLTexture){if("texElementImage2D"in r){const j=r.canvas;if(j.hasAttribute("layoutsubtree")||j.setAttribute("layoutsubtree","true"),Q.parentNode!==j){j.appendChild(Q),u.add(_),j.onpaint=dt=>{const vt=dt.changedElements;for(const et of u)vt.includes(et.image)&&(et.needsUpdate=!0)},j.requestPaint();return}if(r.texElementImage2D.length===3)r.texElementImage2D(r.TEXTURE_2D,r.RGBA8,Q);else{const vt=r.RGBA,et=r.RGBA,It=r.UNSIGNED_BYTE;r.texElementImage2D(r.TEXTURE_2D,0,vt,et,It,Q)}r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE)}}else if(Ut.length>0){if(Ht&&$t){const j=ye(Ut[0]);e.texStorage2D(r.TEXTURE_2D,ct,ft,j.width,j.height)}for(let j=0,dt=Ut.length;j<dt;j++)ut=Ut[j],Ht?O&&e.texSubImage2D(r.TEXTURE_2D,j,0,0,ht,Pt,ut):e.texImage2D(r.TEXTURE_2D,j,ft,ht,Pt,ut);_.generateMipmaps=!1}else if(Ht){if($t){const j=ye(Q);e.texStorage2D(r.TEXTURE_2D,ct,ft,j.width,j.height)}O&&e.texSubImage2D(r.TEXTURE_2D,0,0,0,ht,Pt,Q)}else e.texImage2D(r.TEXTURE_2D,0,ft,ht,Pt,Q);g(_)&&S(W),lt.__version=ot.version,_.onUpdate&&_.onUpdate(_)}D.__version=_.version}function Tt(D,_,U){if(_.image.length!==6)return;const W=q(D,_),K=_.source;e.bindTexture(r.TEXTURE_CUBE_MAP,D.__webglTexture,r.TEXTURE0+U);const ot=i.get(K);if(K.version!==ot.__version||W===!0){e.activeTexture(r.TEXTURE0+U);const lt=re.getPrimaries(re.workingColorSpace),Z=_.colorSpace===Ks?null:re.getPrimaries(_.colorSpace),Q=_.colorSpace===Ks||lt===Z?r.NONE:r.BROWSER_DEFAULT_WEBGL;e.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,_.flipY),e.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),e.pixelStorei(r.UNPACK_ALIGNMENT,_.unpackAlignment),e.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const ht=_.isCompressedTexture||_.image[0].isCompressedTexture,Pt=_.image[0]&&_.image[0].isDataTexture,ft=[];for(let et=0;et<6;et++)!ht&&!Pt?ft[et]=m(_.image[et],!0,n.maxCubemapSize):ft[et]=Pt?_.image[et].image:_.image[et],ft[et]=Yi(_,ft[et]);const ut=ft[0],Ut=s.convert(_.format,_.colorSpace),Ht=s.convert(_.type),$t=M(_.internalFormat,Ut,Ht,_.normalized,_.colorSpace),O=_.isVideoTexture!==!0,ct=ot.__version===void 0||W===!0,j=K.dataReady;let dt=w(_,ut);qt(r.TEXTURE_CUBE_MAP,_);let vt;if(ht){O&&ct&&e.texStorage2D(r.TEXTURE_CUBE_MAP,dt,$t,ut.width,ut.height);for(let et=0;et<6;et++){vt=ft[et].mipmaps;for(let It=0;It<vt.length;It++){const bt=vt[It];_.format!==Ei?Ut!==null?O?j&&e.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It,0,0,bt.width,bt.height,Ut,bt.data):e.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It,$t,bt.width,bt.height,0,bt.data):Rt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):O?j&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It,0,0,bt.width,bt.height,Ut,Ht,bt.data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It,$t,bt.width,bt.height,0,Ut,Ht,bt.data)}}}else{if(vt=_.mipmaps,O&&ct){vt.length>0&&dt++;const et=ye(ft[0]);e.texStorage2D(r.TEXTURE_CUBE_MAP,dt,$t,et.width,et.height)}for(let et=0;et<6;et++)if(Pt){O?j&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,0,0,ft[et].width,ft[et].height,Ut,Ht,ft[et].data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,$t,ft[et].width,ft[et].height,0,Ut,Ht,ft[et].data);for(let It=0;It<vt.length;It++){const Je=vt[It].image[et].image;O?j&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It+1,0,0,Je.width,Je.height,Ut,Ht,Je.data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It+1,$t,Je.width,Je.height,0,Ut,Ht,Je.data)}}else{O?j&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,0,0,Ut,Ht,ft[et]):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,$t,Ut,Ht,ft[et]);for(let It=0;It<vt.length;It++){const bt=vt[It];O?j&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It+1,0,0,Ut,Ht,bt.image[et]):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It+1,$t,Ut,Ht,bt.image[et])}}}g(_)&&S(r.TEXTURE_CUBE_MAP),ot.__version=K.version,_.onUpdate&&_.onUpdate(_)}D.__version=_.version}function Nt(D,_,U,W,K,ot){const lt=s.convert(U.format,U.colorSpace),Z=s.convert(U.type),Q=M(U.internalFormat,lt,Z,U.normalized,U.colorSpace),ht=i.get(_),Pt=i.get(U);if(Pt.__renderTarget=_,!ht.__hasExternalTextures){const ft=Math.max(1,_.width>>ot),ut=Math.max(1,_.height>>ot);K===r.TEXTURE_3D||K===r.TEXTURE_2D_ARRAY?e.texImage3D(K,ot,Q,ft,ut,_.depth,0,lt,Z,null):e.texImage2D(K,ot,Q,ft,ut,0,lt,Z,null)}e.bindFramebuffer(r.FRAMEBUFFER,D),ci(_)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,W,K,Pt.__webglTexture,0,Ze(_)):(K===r.TEXTURE_2D||K>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,W,K,Pt.__webglTexture,ot),e.bindFramebuffer(r.FRAMEBUFFER,null)}function Ct(D,_,U){if(r.bindRenderbuffer(r.RENDERBUFFER,D),_.depthBuffer){const W=_.depthTexture,K=W&&W.isDepthTexture?W.type:null,ot=b(_.stencilBuffer,K),lt=_.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;ci(_)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Ze(_),ot,_.width,_.height):U?r.renderbufferStorageMultisample(r.RENDERBUFFER,Ze(_),ot,_.width,_.height):r.renderbufferStorage(r.RENDERBUFFER,ot,_.width,_.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,lt,r.RENDERBUFFER,D)}else{const W=_.textures;for(let K=0;K<W.length;K++){const ot=W[K],lt=s.convert(ot.format,ot.colorSpace),Z=s.convert(ot.type),Q=M(ot.internalFormat,lt,Z,ot.normalized,ot.colorSpace);ci(_)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Ze(_),Q,_.width,_.height):U?r.renderbufferStorageMultisample(r.RENDERBUFFER,Ze(_),Q,_.width,_.height):r.renderbufferStorage(r.RENDERBUFFER,Q,_.width,_.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function _t(D,_,U){const W=_.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(r.FRAMEBUFFER,D),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const K=i.get(_.depthTexture);if(K.__renderTarget=_,(!K.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),W){if(K.__webglInit===void 0&&(K.__webglInit=!0,_.depthTexture.addEventListener("dispose",T)),K.__webglTexture===void 0){K.__webglTexture=r.createTexture(),e.bindTexture(r.TEXTURE_CUBE_MAP,K.__webglTexture),qt(r.TEXTURE_CUBE_MAP,_.depthTexture);const ht=s.convert(_.depthTexture.format),Pt=s.convert(_.depthTexture.type);let ft;_.depthTexture.format===Es?ft=r.DEPTH_COMPONENT24:_.depthTexture.format===Ea&&(ft=r.DEPTH24_STENCIL8);for(let ut=0;ut<6;ut++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,ft,_.width,_.height,0,ht,Pt,null)}}else $(_.depthTexture,0);const ot=K.__webglTexture,lt=Ze(_),Z=W?r.TEXTURE_CUBE_MAP_POSITIVE_X+U:r.TEXTURE_2D,Q=_.depthTexture.format===Ea?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;if(_.depthTexture.format===Es)ci(_)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Q,Z,ot,0,lt):r.framebufferTexture2D(r.FRAMEBUFFER,Q,Z,ot,0);else if(_.depthTexture.format===Ea)ci(_)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Q,Z,ot,0,lt):r.framebufferTexture2D(r.FRAMEBUFFER,Q,Z,ot,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function kt(D){const _=i.get(D),U=D.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==D.depthTexture){const W=D.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),W){const K=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,W.removeEventListener("dispose",K)};W.addEventListener("dispose",K),_.__depthDisposeCallback=K}_.__boundDepthTexture=W}if(D.depthTexture&&!_.__autoAllocateDepthBuffer)if(U)for(let W=0;W<6;W++)_t(_.__webglFramebuffer[W],D,W);else{const W=D.texture.mipmaps;W&&W.length>0?_t(_.__webglFramebuffer[0],D,0):_t(_.__webglFramebuffer,D,0)}else if(U){_.__webglDepthbuffer=[];for(let W=0;W<6;W++)if(e.bindFramebuffer(r.FRAMEBUFFER,_.__webglFramebuffer[W]),_.__webglDepthbuffer[W]===void 0)_.__webglDepthbuffer[W]=r.createRenderbuffer(),Ct(_.__webglDepthbuffer[W],D,!1);else{const K=D.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ot=_.__webglDepthbuffer[W];r.bindRenderbuffer(r.RENDERBUFFER,ot),r.framebufferRenderbuffer(r.FRAMEBUFFER,K,r.RENDERBUFFER,ot)}}else{const W=D.texture.mipmaps;if(W&&W.length>0?e.bindFramebuffer(r.FRAMEBUFFER,_.__webglFramebuffer[0]):e.bindFramebuffer(r.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=r.createRenderbuffer(),Ct(_.__webglDepthbuffer,D,!1);else{const K=D.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ot=_.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,ot),r.framebufferRenderbuffer(r.FRAMEBUFFER,K,r.RENDERBUFFER,ot)}}e.bindFramebuffer(r.FRAMEBUFFER,null)}function zt(D,_,U){const W=i.get(D);_!==void 0&&Nt(W.__webglFramebuffer,D,D.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),U!==void 0&&kt(D)}function Bt(D){const _=D.texture,U=i.get(D),W=i.get(_);D.addEventListener("dispose",x);const K=D.textures,ot=D.isWebGLCubeRenderTarget===!0,lt=K.length>1;if(lt||(W.__webglTexture===void 0&&(W.__webglTexture=r.createTexture()),W.__version=_.version,a.memory.textures++),ot){U.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(_.mipmaps&&_.mipmaps.length>0){U.__webglFramebuffer[Z]=[];for(let Q=0;Q<_.mipmaps.length;Q++)U.__webglFramebuffer[Z][Q]=r.createFramebuffer()}else U.__webglFramebuffer[Z]=r.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){U.__webglFramebuffer=[];for(let Z=0;Z<_.mipmaps.length;Z++)U.__webglFramebuffer[Z]=r.createFramebuffer()}else U.__webglFramebuffer=r.createFramebuffer();if(lt)for(let Z=0,Q=K.length;Z<Q;Z++){const ht=i.get(K[Z]);ht.__webglTexture===void 0&&(ht.__webglTexture=r.createTexture(),a.memory.textures++)}if(D.samples>0&&ci(D)===!1){U.__webglMultisampledFramebuffer=r.createFramebuffer(),U.__webglColorRenderbuffer=[],e.bindFramebuffer(r.FRAMEBUFFER,U.__webglMultisampledFramebuffer);for(let Z=0;Z<K.length;Z++){const Q=K[Z];U.__webglColorRenderbuffer[Z]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,U.__webglColorRenderbuffer[Z]);const ht=s.convert(Q.format,Q.colorSpace),Pt=s.convert(Q.type),ft=M(Q.internalFormat,ht,Pt,Q.normalized,Q.colorSpace,D.isXRRenderTarget===!0),ut=Ze(D);r.renderbufferStorageMultisample(r.RENDERBUFFER,ut,ft,D.width,D.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Z,r.RENDERBUFFER,U.__webglColorRenderbuffer[Z])}r.bindRenderbuffer(r.RENDERBUFFER,null),D.depthBuffer&&(U.__webglDepthRenderbuffer=r.createRenderbuffer(),Ct(U.__webglDepthRenderbuffer,D,!0)),e.bindFramebuffer(r.FRAMEBUFFER,null)}}if(ot){e.bindTexture(r.TEXTURE_CUBE_MAP,W.__webglTexture),qt(r.TEXTURE_CUBE_MAP,_);for(let Z=0;Z<6;Z++)if(_.mipmaps&&_.mipmaps.length>0)for(let Q=0;Q<_.mipmaps.length;Q++)Nt(U.__webglFramebuffer[Z][Q],D,_,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Nt(U.__webglFramebuffer[Z],D,_,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);g(_)&&S(r.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(lt){for(let Z=0,Q=K.length;Z<Q;Z++){const ht=K[Z],Pt=i.get(ht);let ft=r.TEXTURE_2D;(D.isWebGL3DRenderTarget||D.isWebGLArrayRenderTarget)&&(ft=D.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),e.bindTexture(ft,Pt.__webglTexture),qt(ft,ht),Nt(U.__webglFramebuffer,D,ht,r.COLOR_ATTACHMENT0+Z,ft,0),g(ht)&&S(ft)}e.unbindTexture()}else{let Z=r.TEXTURE_2D;if((D.isWebGL3DRenderTarget||D.isWebGLArrayRenderTarget)&&(Z=D.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),e.bindTexture(Z,W.__webglTexture),qt(Z,_),_.mipmaps&&_.mipmaps.length>0)for(let Q=0;Q<_.mipmaps.length;Q++)Nt(U.__webglFramebuffer[Q],D,_,r.COLOR_ATTACHMENT0,Z,Q);else Nt(U.__webglFramebuffer,D,_,r.COLOR_ATTACHMENT0,Z,0);g(_)&&S(Z),e.unbindTexture()}D.depthBuffer&&kt(D)}function Me(D){const _=D.textures;for(let U=0,W=_.length;U<W;U++){const K=_[U];if(g(K)){const ot=y(D),lt=i.get(K).__webglTexture;e.bindTexture(ot,lt),S(ot),e.unbindTexture()}}}const xe=[],Ke=[];function He(D){if(D.samples>0){if(ci(D)===!1){const _=D.textures,U=D.width,W=D.height;let K=r.COLOR_BUFFER_BIT;const ot=D.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,lt=i.get(D),Z=_.length>1;if(Z)for(let ht=0;ht<_.length;ht++)e.bindFramebuffer(r.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ht,r.RENDERBUFFER,null),e.bindFramebuffer(r.FRAMEBUFFER,lt.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+ht,r.TEXTURE_2D,null,0);e.bindFramebuffer(r.READ_FRAMEBUFFER,lt.__webglMultisampledFramebuffer);const Q=D.texture.mipmaps;Q&&Q.length>0?e.bindFramebuffer(r.DRAW_FRAMEBUFFER,lt.__webglFramebuffer[0]):e.bindFramebuffer(r.DRAW_FRAMEBUFFER,lt.__webglFramebuffer);for(let ht=0;ht<_.length;ht++){if(D.resolveDepthBuffer&&(D.depthBuffer&&(K|=r.DEPTH_BUFFER_BIT),D.stencilBuffer&&D.resolveStencilBuffer&&(K|=r.STENCIL_BUFFER_BIT)),Z){r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,lt.__webglColorRenderbuffer[ht]);const Pt=i.get(_[ht]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,Pt,0)}r.blitFramebuffer(0,0,U,W,0,0,U,W,K,r.NEAREST),c===!0&&(xe.length=0,Ke.length=0,xe.push(r.COLOR_ATTACHMENT0+ht),D.depthBuffer&&D.resolveDepthBuffer===!1&&(xe.push(ot),Ke.push(ot),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,Ke)),r.invalidateFramebuffer(r.READ_FRAMEBUFFER,xe))}if(e.bindFramebuffer(r.READ_FRAMEBUFFER,null),e.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),Z)for(let ht=0;ht<_.length;ht++){e.bindFramebuffer(r.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ht,r.RENDERBUFFER,lt.__webglColorRenderbuffer[ht]);const Pt=i.get(_[ht]).__webglTexture;e.bindFramebuffer(r.FRAMEBUFFER,lt.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+ht,r.TEXTURE_2D,Pt,0)}e.bindFramebuffer(r.DRAW_FRAMEBUFFER,lt.__webglMultisampledFramebuffer)}else if(D.depthBuffer&&D.resolveDepthBuffer===!1&&c){const _=D.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[_])}}}function Ze(D){return Math.min(n.maxSamples,D.samples)}function ci(D){const _=i.get(D);return D.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function N(D){const _=a.render.frame;h.get(D)!==_&&(h.set(D,_),D.update())}function Yi(D,_){const U=D.colorSpace,W=D.format,K=D.type;return D.isCompressedTexture===!0||D.isVideoTexture===!0||U!==xl&&U!==Ks&&(re.getTransfer(U)===Se?(W!==Ei||K!==un)&&Rt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Gt("WebGLTextures: Unsupported texture color space:",U)),_}function ye(D){return typeof HTMLImageElement<"u"&&D instanceof HTMLImageElement?(l.width=D.naturalWidth||D.width,l.height=D.naturalHeight||D.height):typeof VideoFrame<"u"&&D instanceof VideoFrame?(l.width=D.displayWidth,l.height=D.displayHeight):(l.width=D.width,l.height=D.height),l}this.allocateTextureUnit=B,this.resetTextureUnits=V,this.getTextureUnits=X,this.setTextureUnits=L,this.setTexture2D=$,this.setTexture2DArray=tt,this.setTexture3D=J,this.setTextureCube=it,this.rebindTextures=zt,this.setupRenderTarget=Bt,this.updateRenderTargetMipmap=Me,this.updateMultisampleRenderTarget=He,this.setupDepthRenderbuffer=kt,this.setupFrameBufferTexture=Nt,this.useMultisampledRTT=ci,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function sb(r,t){function e(i,n=Ks){let s;const a=re.getTransfer(n);if(i===un)return r.UNSIGNED_BYTE;if(i===n0)return r.UNSIGNED_SHORT_4_4_4_4;if(i===s0)return r.UNSIGNED_SHORT_5_5_5_1;if(i===Rg)return r.UNSIGNED_INT_5_9_9_9_REV;if(i===Dg)return r.UNSIGNED_INT_10F_11F_11F_REV;if(i===Ag)return r.BYTE;if(i===Tg)return r.SHORT;if(i===zo)return r.UNSIGNED_SHORT;if(i===i0)return r.INT;if(i===Sn)return r.UNSIGNED_INT;if(i===Oi)return r.FLOAT;if(i===qe)return r.HALF_FLOAT;if(i===Ig)return r.ALPHA;if(i===Cg)return r.RGB;if(i===Ei)return r.RGBA;if(i===Es)return r.DEPTH_COMPONENT;if(i===Ea)return r.DEPTH_STENCIL;if(i===Hl)return r.RED;if(i===a0)return r.RED_INTEGER;if(i===Na)return r.RG;if(i===r0)return r.RG_INTEGER;if(i===o0)return r.RGBA_INTEGER;if(i===il||i===nl||i===sl||i===al)if(a===Se)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===il)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===nl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===sl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===al)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===il)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===nl)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===sl)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===al)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Nu||i===Fu||i===Uu||i===ku)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Nu)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Fu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Uu)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===ku)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===zu||i===Bu||i===Hu||i===Gu||i===Vu||i===pl||i===Wu)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===zu||i===Bu)return a===Se?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Hu)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Gu)return s.COMPRESSED_R11_EAC;if(i===Vu)return s.COMPRESSED_SIGNED_R11_EAC;if(i===pl)return s.COMPRESSED_RG11_EAC;if(i===Wu)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Xu||i===Yu||i===qu||i===$u||i===Ku||i===Zu||i===Ju||i===ju||i===Qu||i===td||i===ed||i===id||i===nd||i===sd)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Xu)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Yu)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===qu)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$u)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Ku)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Zu)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ju)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ju)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Qu)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===td)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ed)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===id)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===nd)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===sd)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===ad||i===rd||i===od)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===ad)return a===Se?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===rd)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===od)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===cd||i===ld||i===ml||i===hd)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===cd)return s.COMPRESSED_RED_RGTC1_EXT;if(i===ld)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ml)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===hd)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Bo?r.UNSIGNED_INT_24_8:r[i]!==void 0?r[i]:null}return{convert:e}}const ab=`
5244
+ }`,QS=[new R(1,0,0),new R(-1,0,0),new R(0,1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1)],tb=[new R(0,-1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1),new R(0,-1,0),new R(0,-1,0)],Up=new Jt,no=new R,Hh=new R;function eb(r,t,e){let i=new g0;const n=new xt,s=new xt,a=new ne,o=new HM,c=new GM,l={},h=e.maxTextureSize,u={[ia]:Ve,[Ve]:ia,[ji]:ji},d=new le({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new xt},radius:{value:4}},vertexShader:JS,fragmentShader:jS}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new ce;p.setAttribute("position",new ie(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Dt(p,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=So;let g=this.type;this.render=function(w,T,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;this.type===o2&&(Rt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=So);const A=r.getRenderTarget(),C=r.getActiveCubeFace(),I=r.getActiveMipmapLevel(),P=r.state;P.setBlending(as),P.buffers.depth.getReversed()===!0?P.buffers.color.setClear(0,0,0,0):P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);const V=g!==this.type;V&&T.traverse(function(X){X.material&&(Array.isArray(X.material)?X.material.forEach(L=>L.needsUpdate=!0):X.material.needsUpdate=!0)});for(let X=0,L=w.length;X<L;X++){const B=w[X],k=B.shadow;if(k===void 0){Rt("WebGLShadowMap:",B,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;n.copy(k.mapSize);const $=k.getFrameExtents();n.multiply($),s.copy(k.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(s.x=Math.floor(h/$.x),n.x=s.x*$.x,k.mapSize.x=s.x),n.y>h&&(s.y=Math.floor(h/$.y),n.y=s.y*$.y,k.mapSize.y=s.y));const tt=r.state.buffers.depth.getReversed();if(k.camera._reversedDepth=tt,k.map===null||V===!0){if(k.map!==null&&(k.map.depthTexture!==null&&(k.map.depthTexture.dispose(),k.map.depthTexture=null),k.map.dispose()),this.type===mo){if(B.isPointLight){Rt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}k.map=new ri(n.x,n.y,{format:Na,type:qe,minFilter:oe,magFilter:oe,generateMipmaps:!1}),k.map.texture.name=B.name+".shadowMap",k.map.depthTexture=new na(n.x,n.y,Oi),k.map.depthTexture.name=B.name+".shadowMapDepth",k.map.depthTexture.format=Es,k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=Re,k.map.depthTexture.magFilter=Re}else B.isPointLight?(k.map=new Vo(n.x),k.map.depthTexture=new NM(n.x,Sn)):(k.map=new ri(n.x,n.y),k.map.depthTexture=new na(n.x,n.y,Sn)),k.map.depthTexture.name=B.name+".shadowMap",k.map.depthTexture.format=Es,this.type===So?(k.map.depthTexture.compareFunction=tt?h0:l0,k.map.depthTexture.minFilter=oe,k.map.depthTexture.magFilter=oe):(k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=Re,k.map.depthTexture.magFilter=Re);k.camera.updateProjectionMatrix()}const J=k.map.isWebGLCubeRenderTarget?6:1;for(let it=0;it<J;it++){if(k.map.isWebGLCubeRenderTarget)r.setRenderTarget(k.map,it),r.clear();else{it===0&&(r.setRenderTarget(k.map),r.clear());const rt=k.getViewport(it);a.set(s.x*rt.x,s.y*rt.y,s.x*rt.z,s.y*rt.w),P.viewport(a)}if(B.isPointLight){const rt=k.camera,Vt=k.matrix,jt=B.distance||rt.far;jt!==rt.far&&(rt.far=jt,rt.updateProjectionMatrix()),no.setFromMatrixPosition(B.matrixWorld),rt.position.copy(no),Hh.copy(rt.position),Hh.add(QS[it]),rt.up.copy(tb[it]),rt.lookAt(Hh),rt.updateMatrixWorld(),Vt.makeTranslation(-no.x,-no.y,-no.z),Up.multiplyMatrices(rt.projectionMatrix,rt.matrixWorldInverse),k._frustum.setFromProjectionMatrix(Up,rt.coordinateSystem,rt.reversedDepth)}else k.updateMatrices(B);i=k.getFrustum(),M(T,x,k.camera,B,this.type)}k.isPointLightShadow!==!0&&this.type===mo&&S(k,x),k.needsUpdate=!1}g=this.type,m.needsUpdate=!1,r.setRenderTarget(A,C,I)};function S(w,T){const x=t.update(v);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new ri(n.x,n.y,{format:Na,type:qe})),d.uniforms.shadow_pass.value=w.map.depthTexture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,r.setRenderTarget(w.mapPass),r.clear(),r.renderBufferDirect(T,null,x,d,v,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,r.setRenderTarget(w.map),r.clear(),r.renderBufferDirect(T,null,x,f,v,null)}function y(w,T,x,A){let C=null;const I=x.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(I!==void 0)C=I;else if(C=x.isPointLight===!0?c:o,r.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0||T.alphaToCoverage===!0){const P=C.uuid,V=T.uuid;let X=l[P];X===void 0&&(X={},l[P]=X);let L=X[V];L===void 0&&(L=C.clone(),X[V]=L,T.addEventListener("dispose",b)),C=L}if(C.visible=T.visible,C.wireframe=T.wireframe,A===mo?C.side=T.shadowSide!==null?T.shadowSide:T.side:C.side=T.shadowSide!==null?T.shadowSide:u[T.side],C.alphaMap=T.alphaMap,C.alphaTest=T.alphaToCoverage===!0?.5:T.alphaTest,C.map=T.map,C.clipShadows=T.clipShadows,C.clippingPlanes=T.clippingPlanes,C.clipIntersection=T.clipIntersection,C.displacementMap=T.displacementMap,C.displacementScale=T.displacementScale,C.displacementBias=T.displacementBias,C.wireframeLinewidth=T.wireframeLinewidth,C.linewidth=T.linewidth,x.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const P=r.properties.get(C);P.light=x}return C}function M(w,T,x,A,C){if(w.visible===!1)return;if(w.layers.test(T.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&C===mo)&&(!w.frustumCulled||i.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,w.matrixWorld);const V=t.update(w),X=w.material;if(Array.isArray(X)){const L=V.groups;for(let B=0,k=L.length;B<k;B++){const $=L[B],tt=X[$.materialIndex];if(tt&&tt.visible){const J=y(w,tt,A,C);w.onBeforeShadow(r,w,T,x,V,J,$),r.renderBufferDirect(x,null,V,J,w,$),w.onAfterShadow(r,w,T,x,V,J,$)}}}else if(X.visible){const L=y(w,X,A,C);w.onBeforeShadow(r,w,T,x,V,L,null),r.renderBufferDirect(x,null,V,L,w,null),w.onAfterShadow(r,w,T,x,V,L,null)}}const P=w.children;for(let V=0,X=P.length;V<X;V++)M(P[V],T,x,A,C)}function b(w){w.target.removeEventListener("dispose",b);for(const x in l){const A=l[x],C=w.target.uuid;C in A&&(A[C].dispose(),delete A[C])}}}function ib(r,t){function e(){let O=!1;const ct=new ne;let j=null;const dt=new ne(0,0,0,0);return{setMask:function(vt){j!==vt&&!O&&(r.colorMask(vt,vt,vt,vt),j=vt)},setLocked:function(vt){O=vt},setClear:function(vt,et,It,bt,Je){Je===!0&&(vt*=bt,et*=bt,It*=bt),ct.set(vt,et,It,bt),dt.equals(ct)===!1&&(r.clearColor(vt,et,It,bt),dt.copy(ct))},reset:function(){O=!1,j=null,dt.set(-1,0,0,0)}}}function i(){let O=!1,ct=!1,j=null,dt=null,vt=null;return{setReversed:function(et){if(ct!==et){const It=t.get("EXT_clip_control");et?It.clipControlEXT(It.LOWER_LEFT_EXT,It.ZERO_TO_ONE_EXT):It.clipControlEXT(It.LOWER_LEFT_EXT,It.NEGATIVE_ONE_TO_ONE_EXT),ct=et;const bt=vt;vt=null,this.setClear(bt)}},getReversed:function(){return ct},setTest:function(et){et?nt(r.DEPTH_TEST):z(r.DEPTH_TEST)},setMask:function(et){j!==et&&!O&&(r.depthMask(et),j=et)},setFunc:function(et){if(ct&&(et=V2[et]),dt!==et){switch(et){case Tu:r.depthFunc(r.NEVER);break;case Ru:r.depthFunc(r.ALWAYS);break;case Du:r.depthFunc(r.LESS);break;case Pr:r.depthFunc(r.LEQUAL);break;case Iu:r.depthFunc(r.EQUAL);break;case Cu:r.depthFunc(r.GEQUAL);break;case Pu:r.depthFunc(r.GREATER);break;case Lu:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}dt=et}},setLocked:function(et){O=et},setClear:function(et){vt!==et&&(vt=et,ct&&(et=1-et),r.clearDepth(et))},reset:function(){O=!1,j=null,dt=null,vt=null,ct=!1}}}function n(){let O=!1,ct=null,j=null,dt=null,vt=null,et=null,It=null,bt=null,Je=null;return{setTest:function(Pe){O||(Pe?nt(r.STENCIL_TEST):z(r.STENCIL_TEST))},setMask:function(Pe){ct!==Pe&&!O&&(r.stencilMask(Pe),ct=Pe)},setFunc:function(Pe,zn,Bn){(j!==Pe||dt!==zn||vt!==Bn)&&(r.stencilFunc(Pe,zn,Bn),j=Pe,dt=zn,vt=Bn)},setOp:function(Pe,zn,Bn){(et!==Pe||It!==zn||bt!==Bn)&&(r.stencilOp(Pe,zn,Bn),et=Pe,It=zn,bt=Bn)},setLocked:function(Pe){O=Pe},setClear:function(Pe){Je!==Pe&&(r.clearStencil(Pe),Je=Pe)},reset:function(){O=!1,ct=null,j=null,dt=null,vt=null,et=null,It=null,bt=null,Je=null}}}const s=new e,a=new i,o=new n,c=new WeakMap,l=new WeakMap;let h={},u={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,S=null,y=null,M=null,b=null,w=null,T=null,x=new st(0,0,0),A=0,C=!1,I=null,P=null,V=null,X=null,L=null;const B=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,$=0;const tt=r.getParameter(r.VERSION);tt.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(tt)[1]),k=$>=1):tt.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(tt)[1]),k=$>=2);let J=null,it={};const rt=r.getParameter(r.SCISSOR_BOX),Vt=r.getParameter(r.VIEWPORT),jt=new ne().fromArray(rt),qt=new ne().fromArray(Vt);function q(O,ct,j,dt){const vt=new Uint8Array(4),et=r.createTexture();r.bindTexture(O,et),r.texParameteri(O,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(O,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let It=0;It<j;It++)O===r.TEXTURE_3D||O===r.TEXTURE_2D_ARRAY?r.texImage3D(ct,0,r.RGBA,1,1,dt,0,r.RGBA,r.UNSIGNED_BYTE,vt):r.texImage2D(ct+It,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,vt);return et}const at={};at[r.TEXTURE_2D]=q(r.TEXTURE_2D,r.TEXTURE_2D,1),at[r.TEXTURE_CUBE_MAP]=q(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),at[r.TEXTURE_2D_ARRAY]=q(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),at[r.TEXTURE_3D]=q(r.TEXTURE_3D,r.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),nt(r.DEPTH_TEST),a.setFunc(Pr),Me(!1),xe(yf),nt(r.CULL_FACE),zt(as);function nt(O){h[O]!==!0&&(r.enable(O),h[O]=!0)}function z(O){h[O]!==!1&&(r.disable(O),h[O]=!1)}function Tt(O,ct){return d[O]!==ct?(r.bindFramebuffer(O,ct),d[O]=ct,O===r.DRAW_FRAMEBUFFER&&(d[r.FRAMEBUFFER]=ct),O===r.FRAMEBUFFER&&(d[r.DRAW_FRAMEBUFFER]=ct),!0):!1}function Nt(O,ct){let j=p,dt=!1;if(O){j=f.get(ct),j===void 0&&(j=[],f.set(ct,j));const vt=O.textures;if(j.length!==vt.length||j[0]!==r.COLOR_ATTACHMENT0){for(let et=0,It=vt.length;et<It;et++)j[et]=r.COLOR_ATTACHMENT0+et;j.length=vt.length,dt=!0}}else j[0]!==r.BACK&&(j[0]=r.BACK,dt=!0);dt&&r.drawBuffers(j)}function Ct(O){return v!==O?(r.useProgram(O),v=O,!0):!1}const _t={[Ma]:r.FUNC_ADD,[c2]:r.FUNC_SUBTRACT,[l2]:r.FUNC_REVERSE_SUBTRACT};_t[h2]=r.MIN,_t[u2]=r.MAX;const kt={[d2]:r.ZERO,[Fo]:r.ONE,[f2]:r.SRC_COLOR,[Au]:r.SRC_ALPHA,[x2]:r.SRC_ALPHA_SATURATE,[v2]:r.DST_COLOR,[m2]:r.DST_ALPHA,[p2]:r.ONE_MINUS_SRC_COLOR,[Uo]:r.ONE_MINUS_SRC_ALPHA,[M2]:r.ONE_MINUS_DST_COLOR,[g2]:r.ONE_MINUS_DST_ALPHA,[y2]:r.CONSTANT_COLOR,[_2]:r.ONE_MINUS_CONSTANT_COLOR,[S2]:r.CONSTANT_ALPHA,[b2]:r.ONE_MINUS_CONSTANT_ALPHA};function zt(O,ct,j,dt,vt,et,It,bt,Je,Pe){if(O===as){m===!0&&(z(r.BLEND),m=!1);return}if(m===!1&&(nt(r.BLEND),m=!0),O!==zl){if(O!==g||Pe!==C){if((S!==Ma||b!==Ma)&&(r.blendEquation(r.FUNC_ADD),S=Ma,b=Ma),Pe)switch(O){case ta:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Ni:r.blendFunc(r.ONE,r.ONE);break;case _f:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Sf:r.blendFuncSeparate(r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:Gt("WebGLState: Invalid blending: ",O);break}else switch(O){case ta:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Ni:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE,r.ONE,r.ONE);break;case _f:Gt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Sf:Gt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Gt("WebGLState: Invalid blending: ",O);break}y=null,M=null,w=null,T=null,x.set(0,0,0),A=0,g=O,C=Pe}return}vt=vt||ct,et=et||j,It=It||dt,(ct!==S||vt!==b)&&(r.blendEquationSeparate(_t[ct],_t[vt]),S=ct,b=vt),(j!==y||dt!==M||et!==w||It!==T)&&(r.blendFuncSeparate(kt[j],kt[dt],kt[et],kt[It]),y=j,M=dt,w=et,T=It),(bt.equals(x)===!1||Je!==A)&&(r.blendColor(bt.r,bt.g,bt.b,Je),x.copy(bt),A=Je),g=O,C=!1}function Bt(O,ct){O.side===ji?z(r.CULL_FACE):nt(r.CULL_FACE);let j=O.side===Ve;ct&&(j=!j),Me(j),O.blending===ta&&O.transparent===!1?zt(as):zt(O.blending,O.blendEquation,O.blendSrc,O.blendDst,O.blendEquationAlpha,O.blendSrcAlpha,O.blendDstAlpha,O.blendColor,O.blendAlpha,O.premultipliedAlpha),a.setFunc(O.depthFunc),a.setTest(O.depthTest),a.setMask(O.depthWrite),s.setMask(O.colorWrite);const dt=O.stencilWrite;o.setTest(dt),dt&&(o.setMask(O.stencilWriteMask),o.setFunc(O.stencilFunc,O.stencilRef,O.stencilFuncMask),o.setOp(O.stencilFail,O.stencilZFail,O.stencilZPass)),He(O.polygonOffset,O.polygonOffsetFactor,O.polygonOffsetUnits),O.alphaToCoverage===!0?nt(r.SAMPLE_ALPHA_TO_COVERAGE):z(r.SAMPLE_ALPHA_TO_COVERAGE)}function Me(O){I!==O&&(O?r.frontFace(r.CW):r.frontFace(r.CCW),I=O)}function xe(O){O!==a2?(nt(r.CULL_FACE),O!==P&&(O===yf?r.cullFace(r.BACK):O===r2?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):z(r.CULL_FACE),P=O}function Ke(O){O!==V&&(k&&r.lineWidth(O),V=O)}function He(O,ct,j){O?(nt(r.POLYGON_OFFSET_FILL),(X!==ct||L!==j)&&(X=ct,L=j,a.getReversed()&&(ct=-ct),r.polygonOffset(ct,j))):z(r.POLYGON_OFFSET_FILL)}function Ze(O){O?nt(r.SCISSOR_TEST):z(r.SCISSOR_TEST)}function ci(O){O===void 0&&(O=r.TEXTURE0+B-1),J!==O&&(r.activeTexture(O),J=O)}function N(O,ct,j){j===void 0&&(J===null?j=r.TEXTURE0+B-1:j=J);let dt=it[j];dt===void 0&&(dt={type:void 0,texture:void 0},it[j]=dt),(dt.type!==O||dt.texture!==ct)&&(J!==j&&(r.activeTexture(j),J=j),r.bindTexture(O,ct||at[O]),dt.type=O,dt.texture=ct)}function Yi(){const O=it[J];O!==void 0&&O.type!==void 0&&(r.bindTexture(O.type,null),O.type=void 0,O.texture=void 0)}function ye(){try{r.compressedTexImage2D(...arguments)}catch(O){Gt("WebGLState:",O)}}function D(){try{r.compressedTexImage3D(...arguments)}catch(O){Gt("WebGLState:",O)}}function _(){try{r.texSubImage2D(...arguments)}catch(O){Gt("WebGLState:",O)}}function U(){try{r.texSubImage3D(...arguments)}catch(O){Gt("WebGLState:",O)}}function W(){try{r.compressedTexSubImage2D(...arguments)}catch(O){Gt("WebGLState:",O)}}function K(){try{r.compressedTexSubImage3D(...arguments)}catch(O){Gt("WebGLState:",O)}}function ot(){try{r.texStorage2D(...arguments)}catch(O){Gt("WebGLState:",O)}}function lt(){try{r.texStorage3D(...arguments)}catch(O){Gt("WebGLState:",O)}}function Z(){try{r.texImage2D(...arguments)}catch(O){Gt("WebGLState:",O)}}function Q(){try{r.texImage3D(...arguments)}catch(O){Gt("WebGLState:",O)}}function ht(O){return u[O]!==void 0?u[O]:r.getParameter(O)}function Pt(O,ct){u[O]!==ct&&(r.pixelStorei(O,ct),u[O]=ct)}function ft(O){jt.equals(O)===!1&&(r.scissor(O.x,O.y,O.z,O.w),jt.copy(O))}function ut(O){qt.equals(O)===!1&&(r.viewport(O.x,O.y,O.z,O.w),qt.copy(O))}function Ut(O,ct){let j=l.get(ct);j===void 0&&(j=new WeakMap,l.set(ct,j));let dt=j.get(O);dt===void 0&&(dt=r.getUniformBlockIndex(ct,O.name),j.set(O,dt))}function Ht(O,ct){const dt=l.get(ct).get(O);c.get(ct)!==dt&&(r.uniformBlockBinding(ct,dt,O.__bindingPointIndex),c.set(ct,dt))}function $t(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),a.setReversed(!1),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),r.pixelStorei(r.PACK_ALIGNMENT,4),r.pixelStorei(r.UNPACK_ALIGNMENT,4),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.BROWSER_DEFAULT_WEBGL),r.pixelStorei(r.PACK_ROW_LENGTH,0),r.pixelStorei(r.PACK_SKIP_PIXELS,0),r.pixelStorei(r.PACK_SKIP_ROWS,0),r.pixelStorei(r.UNPACK_ROW_LENGTH,0),r.pixelStorei(r.UNPACK_IMAGE_HEIGHT,0),r.pixelStorei(r.UNPACK_SKIP_PIXELS,0),r.pixelStorei(r.UNPACK_SKIP_ROWS,0),r.pixelStorei(r.UNPACK_SKIP_IMAGES,0),h={},u={},J=null,it={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,S=null,y=null,M=null,b=null,w=null,T=null,x=new st(0,0,0),A=0,C=!1,I=null,P=null,V=null,X=null,L=null,jt.set(0,0,r.canvas.width,r.canvas.height),qt.set(0,0,r.canvas.width,r.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:nt,disable:z,bindFramebuffer:Tt,drawBuffers:Nt,useProgram:Ct,setBlending:zt,setMaterial:Bt,setFlipSided:Me,setCullFace:xe,setLineWidth:Ke,setPolygonOffset:He,setScissorTest:Ze,activeTexture:ci,bindTexture:N,unbindTexture:Yi,compressedTexImage2D:ye,compressedTexImage3D:D,texImage2D:Z,texImage3D:Q,pixelStorei:Pt,getParameter:ht,updateUBOMapping:Ut,uniformBlockBinding:Ht,texStorage2D:ot,texStorage3D:lt,texSubImage2D:_,texSubImage3D:U,compressedTexSubImage2D:W,compressedTexSubImage3D:K,scissor:ft,viewport:ut,reset:$t}}function nb(r,t,e,i,n,s,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new xt,h=new WeakMap,u=new Set;let d;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(D,_){return p?new OffscreenCanvas(D,_):Go("canvas")}function m(D,_,U){let W=1;const K=ye(D);if((K.width>U||K.height>U)&&(W=U/Math.max(K.width,K.height)),W<1)if(typeof HTMLImageElement<"u"&&D instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&D instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&D instanceof ImageBitmap||typeof VideoFrame<"u"&&D instanceof VideoFrame){const ot=Math.floor(W*K.width),lt=Math.floor(W*K.height);d===void 0&&(d=v(ot,lt));const Z=_?v(ot,lt):d;return Z.width=ot,Z.height=lt,Z.getContext("2d").drawImage(D,0,0,ot,lt),Rt("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+ot+"x"+lt+")."),Z}else return"data"in D&&Rt("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),D;return D}function g(D){return D.generateMipmaps}function S(D){r.generateMipmap(D)}function y(D){return D.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:D.isWebGL3DRenderTarget?r.TEXTURE_3D:D.isWebGLArrayRenderTarget||D.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function M(D,_,U,W,K,ot=!1){if(D!==null){if(r[D]!==void 0)return r[D];Rt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+D+"'")}let lt;W&&(lt=t.get("EXT_texture_norm16"),lt||Rt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=_;if(_===r.RED&&(U===r.FLOAT&&(Z=r.R32F),U===r.HALF_FLOAT&&(Z=r.R16F),U===r.UNSIGNED_BYTE&&(Z=r.R8),U===r.UNSIGNED_SHORT&&lt&&(Z=lt.R16_EXT),U===r.SHORT&&lt&&(Z=lt.R16_SNORM_EXT)),_===r.RED_INTEGER&&(U===r.UNSIGNED_BYTE&&(Z=r.R8UI),U===r.UNSIGNED_SHORT&&(Z=r.R16UI),U===r.UNSIGNED_INT&&(Z=r.R32UI),U===r.BYTE&&(Z=r.R8I),U===r.SHORT&&(Z=r.R16I),U===r.INT&&(Z=r.R32I)),_===r.RG&&(U===r.FLOAT&&(Z=r.RG32F),U===r.HALF_FLOAT&&(Z=r.RG16F),U===r.UNSIGNED_BYTE&&(Z=r.RG8),U===r.UNSIGNED_SHORT&&lt&&(Z=lt.RG16_EXT),U===r.SHORT&&lt&&(Z=lt.RG16_SNORM_EXT)),_===r.RG_INTEGER&&(U===r.UNSIGNED_BYTE&&(Z=r.RG8UI),U===r.UNSIGNED_SHORT&&(Z=r.RG16UI),U===r.UNSIGNED_INT&&(Z=r.RG32UI),U===r.BYTE&&(Z=r.RG8I),U===r.SHORT&&(Z=r.RG16I),U===r.INT&&(Z=r.RG32I)),_===r.RGB_INTEGER&&(U===r.UNSIGNED_BYTE&&(Z=r.RGB8UI),U===r.UNSIGNED_SHORT&&(Z=r.RGB16UI),U===r.UNSIGNED_INT&&(Z=r.RGB32UI),U===r.BYTE&&(Z=r.RGB8I),U===r.SHORT&&(Z=r.RGB16I),U===r.INT&&(Z=r.RGB32I)),_===r.RGBA_INTEGER&&(U===r.UNSIGNED_BYTE&&(Z=r.RGBA8UI),U===r.UNSIGNED_SHORT&&(Z=r.RGBA16UI),U===r.UNSIGNED_INT&&(Z=r.RGBA32UI),U===r.BYTE&&(Z=r.RGBA8I),U===r.SHORT&&(Z=r.RGBA16I),U===r.INT&&(Z=r.RGBA32I)),_===r.RGB&&(U===r.UNSIGNED_SHORT&&lt&&(Z=lt.RGB16_EXT),U===r.SHORT&&lt&&(Z=lt.RGB16_SNORM_EXT),U===r.UNSIGNED_INT_5_9_9_9_REV&&(Z=r.RGB9_E5),U===r.UNSIGNED_INT_10F_11F_11F_REV&&(Z=r.R11F_G11F_B10F)),_===r.RGBA){const Q=ot?yl:re.getTransfer(K);U===r.FLOAT&&(Z=r.RGBA32F),U===r.HALF_FLOAT&&(Z=r.RGBA16F),U===r.UNSIGNED_BYTE&&(Z=Q===Se?r.SRGB8_ALPHA8:r.RGBA8),U===r.UNSIGNED_SHORT&&lt&&(Z=lt.RGBA16_EXT),U===r.SHORT&&lt&&(Z=lt.RGBA16_SNORM_EXT),U===r.UNSIGNED_SHORT_4_4_4_4&&(Z=r.RGBA4),U===r.UNSIGNED_SHORT_5_5_5_1&&(Z=r.RGB5_A1)}return(Z===r.R16F||Z===r.R32F||Z===r.RG16F||Z===r.RG32F||Z===r.RGBA16F||Z===r.RGBA32F)&&t.get("EXT_color_buffer_float"),Z}function b(D,_){let U;return D?_===null||_===Sn||_===Bo?U=r.DEPTH24_STENCIL8:_===Oi?U=r.DEPTH32F_STENCIL8:_===zo&&(U=r.DEPTH24_STENCIL8,Rt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===Sn||_===Bo?U=r.DEPTH_COMPONENT24:_===Oi?U=r.DEPTH_COMPONENT32F:_===zo&&(U=r.DEPTH_COMPONENT16),U}function w(D,_){return g(D)===!0||D.isFramebufferTexture&&D.minFilter!==Re&&D.minFilter!==oe?Math.log2(Math.max(_.width,_.height))+1:D.mipmaps!==void 0&&D.mipmaps.length>0?D.mipmaps.length:D.isCompressedTexture&&Array.isArray(D.image)?_.mipmaps.length:1}function T(D){const _=D.target;_.removeEventListener("dispose",T),A(_),_.isVideoTexture&&h.delete(_),_.isHTMLTexture&&u.delete(_)}function x(D){const _=D.target;_.removeEventListener("dispose",x),I(_)}function A(D){const _=i.get(D);if(_.__webglInit===void 0)return;const U=D.source,W=f.get(U);if(W){const K=W[_.__cacheKey];K.usedTimes--,K.usedTimes===0&&C(D),Object.keys(W).length===0&&f.delete(U)}i.remove(D)}function C(D){const _=i.get(D);r.deleteTexture(_.__webglTexture);const U=D.source,W=f.get(U);delete W[_.__cacheKey],a.memory.textures--}function I(D){const _=i.get(D);if(D.depthTexture&&(D.depthTexture.dispose(),i.remove(D.depthTexture)),D.isWebGLCubeRenderTarget)for(let W=0;W<6;W++){if(Array.isArray(_.__webglFramebuffer[W]))for(let K=0;K<_.__webglFramebuffer[W].length;K++)r.deleteFramebuffer(_.__webglFramebuffer[W][K]);else r.deleteFramebuffer(_.__webglFramebuffer[W]);_.__webglDepthbuffer&&r.deleteRenderbuffer(_.__webglDepthbuffer[W])}else{if(Array.isArray(_.__webglFramebuffer))for(let W=0;W<_.__webglFramebuffer.length;W++)r.deleteFramebuffer(_.__webglFramebuffer[W]);else r.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&r.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&r.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let W=0;W<_.__webglColorRenderbuffer.length;W++)_.__webglColorRenderbuffer[W]&&r.deleteRenderbuffer(_.__webglColorRenderbuffer[W]);_.__webglDepthRenderbuffer&&r.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const U=D.textures;for(let W=0,K=U.length;W<K;W++){const ot=i.get(U[W]);ot.__webglTexture&&(r.deleteTexture(ot.__webglTexture),a.memory.textures--),i.remove(U[W])}i.remove(D)}let P=0;function V(){P=0}function X(){return P}function L(D){P=D}function B(){const D=P;return D>=n.maxTextures&&Rt("WebGLTextures: Trying to use "+D+" texture units while this GPU supports only "+n.maxTextures),P+=1,D}function k(D){const _=[];return _.push(D.wrapS),_.push(D.wrapT),_.push(D.wrapR||0),_.push(D.magFilter),_.push(D.minFilter),_.push(D.anisotropy),_.push(D.internalFormat),_.push(D.format),_.push(D.type),_.push(D.generateMipmaps),_.push(D.premultiplyAlpha),_.push(D.flipY),_.push(D.unpackAlignment),_.push(D.colorSpace),_.join()}function $(D,_){const U=i.get(D);if(D.isVideoTexture&&N(D),D.isRenderTargetTexture===!1&&D.isExternalTexture!==!0&&D.version>0&&U.__version!==D.version){const W=D.image;if(W===null)Rt("WebGLRenderer: Texture marked for update but no image data found.");else if(W.complete===!1)Rt("WebGLRenderer: Texture marked for update but image is incomplete");else{z(U,D,_);return}}else D.isExternalTexture&&(U.__webglTexture=D.sourceTexture?D.sourceTexture:null);e.bindTexture(r.TEXTURE_2D,U.__webglTexture,r.TEXTURE0+_)}function tt(D,_){const U=i.get(D);if(D.isRenderTargetTexture===!1&&D.version>0&&U.__version!==D.version){z(U,D,_);return}else D.isExternalTexture&&(U.__webglTexture=D.sourceTexture?D.sourceTexture:null);e.bindTexture(r.TEXTURE_2D_ARRAY,U.__webglTexture,r.TEXTURE0+_)}function J(D,_){const U=i.get(D);if(D.isRenderTargetTexture===!1&&D.version>0&&U.__version!==D.version){z(U,D,_);return}e.bindTexture(r.TEXTURE_3D,U.__webglTexture,r.TEXTURE0+_)}function it(D,_){const U=i.get(D);if(D.isCubeDepthTexture!==!0&&D.version>0&&U.__version!==D.version){Tt(U,D,_);return}e.bindTexture(r.TEXTURE_CUBE_MAP,U.__webglTexture,r.TEXTURE0+_)}const rt={[ko]:r.REPEAT,[wi]:r.CLAMP_TO_EDGE,[Ou]:r.MIRRORED_REPEAT},Vt={[Re]:r.NEAREST,[T2]:r.NEAREST_MIPMAP_NEAREST,[sc]:r.NEAREST_MIPMAP_LINEAR,[oe]:r.LINEAR,[rh]:r.LINEAR_MIPMAP_NEAREST,[wa]:r.LINEAR_MIPMAP_LINEAR},jt={[L2]:r.NEVER,[k2]:r.ALWAYS,[O2]:r.LESS,[l0]:r.LEQUAL,[N2]:r.EQUAL,[h0]:r.GEQUAL,[F2]:r.GREATER,[U2]:r.NOTEQUAL};function qt(D,_){if(_.type===Oi&&t.has("OES_texture_float_linear")===!1&&(_.magFilter===oe||_.magFilter===rh||_.magFilter===sc||_.magFilter===wa||_.minFilter===oe||_.minFilter===rh||_.minFilter===sc||_.minFilter===wa)&&Rt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(D,r.TEXTURE_WRAP_S,rt[_.wrapS]),r.texParameteri(D,r.TEXTURE_WRAP_T,rt[_.wrapT]),(D===r.TEXTURE_3D||D===r.TEXTURE_2D_ARRAY)&&r.texParameteri(D,r.TEXTURE_WRAP_R,rt[_.wrapR]),r.texParameteri(D,r.TEXTURE_MAG_FILTER,Vt[_.magFilter]),r.texParameteri(D,r.TEXTURE_MIN_FILTER,Vt[_.minFilter]),_.compareFunction&&(r.texParameteri(D,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(D,r.TEXTURE_COMPARE_FUNC,jt[_.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===Re||_.minFilter!==sc&&_.minFilter!==wa||_.type===Oi&&t.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||i.get(_).__currentAnisotropy){const U=t.get("EXT_texture_filter_anisotropic");r.texParameterf(D,U.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,n.getMaxAnisotropy())),i.get(_).__currentAnisotropy=_.anisotropy}}}function q(D,_){let U=!1;D.__webglInit===void 0&&(D.__webglInit=!0,_.addEventListener("dispose",T));const W=_.source;let K=f.get(W);K===void 0&&(K={},f.set(W,K));const ot=k(_);if(ot!==D.__cacheKey){K[ot]===void 0&&(K[ot]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,U=!0),K[ot].usedTimes++;const lt=K[D.__cacheKey];lt!==void 0&&(K[D.__cacheKey].usedTimes--,lt.usedTimes===0&&C(_)),D.__cacheKey=ot,D.__webglTexture=K[ot].texture}return U}function at(D,_,U){return Math.floor(Math.floor(D/U)/_)}function nt(D,_,U,W){const ot=D.updateRanges;if(ot.length===0)e.texSubImage2D(r.TEXTURE_2D,0,0,0,_.width,_.height,U,W,_.data);else{ot.sort((Pt,ft)=>Pt.start-ft.start);let lt=0;for(let Pt=1;Pt<ot.length;Pt++){const ft=ot[lt],ut=ot[Pt],Ut=ft.start+ft.count,Ht=at(ut.start,_.width,4),$t=at(ft.start,_.width,4);ut.start<=Ut+1&&Ht===$t&&at(ut.start+ut.count-1,_.width,4)===Ht?ft.count=Math.max(ft.count,ut.start+ut.count-ft.start):(++lt,ot[lt]=ut)}ot.length=lt+1;const Z=e.getParameter(r.UNPACK_ROW_LENGTH),Q=e.getParameter(r.UNPACK_SKIP_PIXELS),ht=e.getParameter(r.UNPACK_SKIP_ROWS);e.pixelStorei(r.UNPACK_ROW_LENGTH,_.width);for(let Pt=0,ft=ot.length;Pt<ft;Pt++){const ut=ot[Pt],Ut=Math.floor(ut.start/4),Ht=Math.ceil(ut.count/4),$t=Ut%_.width,O=Math.floor(Ut/_.width),ct=Ht,j=1;e.pixelStorei(r.UNPACK_SKIP_PIXELS,$t),e.pixelStorei(r.UNPACK_SKIP_ROWS,O),e.texSubImage2D(r.TEXTURE_2D,0,$t,O,ct,j,U,W,_.data)}D.clearUpdateRanges(),e.pixelStorei(r.UNPACK_ROW_LENGTH,Z),e.pixelStorei(r.UNPACK_SKIP_PIXELS,Q),e.pixelStorei(r.UNPACK_SKIP_ROWS,ht)}}function z(D,_,U){let W=r.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(W=r.TEXTURE_2D_ARRAY),_.isData3DTexture&&(W=r.TEXTURE_3D);const K=q(D,_),ot=_.source;e.bindTexture(W,D.__webglTexture,r.TEXTURE0+U);const lt=i.get(ot);if(ot.version!==lt.__version||K===!0){if(e.activeTexture(r.TEXTURE0+U),(typeof ImageBitmap<"u"&&_.image instanceof ImageBitmap)===!1){const j=re.getPrimaries(re.workingColorSpace),dt=_.colorSpace===Ks?null:re.getPrimaries(_.colorSpace),vt=_.colorSpace===Ks||j===dt?r.NONE:r.BROWSER_DEFAULT_WEBGL;e.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,_.flipY),e.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),e.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,vt)}e.pixelStorei(r.UNPACK_ALIGNMENT,_.unpackAlignment);let Q=m(_.image,!1,n.maxTextureSize);Q=Yi(_,Q);const ht=s.convert(_.format,_.colorSpace),Pt=s.convert(_.type);let ft=M(_.internalFormat,ht,Pt,_.normalized,_.colorSpace,_.isVideoTexture);qt(W,_);let ut;const Ut=_.mipmaps,Ht=_.isVideoTexture!==!0,$t=lt.__version===void 0||K===!0,O=ot.dataReady,ct=w(_,Q);if(_.isDepthTexture)ft=b(_.format===Ea,_.type),$t&&(Ht?e.texStorage2D(r.TEXTURE_2D,1,ft,Q.width,Q.height):e.texImage2D(r.TEXTURE_2D,0,ft,Q.width,Q.height,0,ht,Pt,null));else if(_.isDataTexture)if(Ut.length>0){Ht&&$t&&e.texStorage2D(r.TEXTURE_2D,ct,ft,Ut[0].width,Ut[0].height);for(let j=0,dt=Ut.length;j<dt;j++)ut=Ut[j],Ht?O&&e.texSubImage2D(r.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,Pt,ut.data):e.texImage2D(r.TEXTURE_2D,j,ft,ut.width,ut.height,0,ht,Pt,ut.data);_.generateMipmaps=!1}else Ht?($t&&e.texStorage2D(r.TEXTURE_2D,ct,ft,Q.width,Q.height),O&&nt(_,Q,ht,Pt)):e.texImage2D(r.TEXTURE_2D,0,ft,Q.width,Q.height,0,ht,Pt,Q.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){Ht&&$t&&e.texStorage3D(r.TEXTURE_2D_ARRAY,ct,ft,Ut[0].width,Ut[0].height,Q.depth);for(let j=0,dt=Ut.length;j<dt;j++)if(ut=Ut[j],_.format!==Ei)if(ht!==null)if(Ht){if(O)if(_.layerUpdates.size>0){const vt=mp(ut.width,ut.height,_.format,_.type);for(const et of _.layerUpdates){const It=ut.data.subarray(et*vt/ut.data.BYTES_PER_ELEMENT,(et+1)*vt/ut.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,j,0,0,et,ut.width,ut.height,1,ht,It)}_.clearLayerUpdates()}else e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,j,0,0,0,ut.width,ut.height,Q.depth,ht,ut.data)}else e.compressedTexImage3D(r.TEXTURE_2D_ARRAY,j,ft,ut.width,ut.height,Q.depth,0,ut.data,0,0);else Rt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ht?O&&e.texSubImage3D(r.TEXTURE_2D_ARRAY,j,0,0,0,ut.width,ut.height,Q.depth,ht,Pt,ut.data):e.texImage3D(r.TEXTURE_2D_ARRAY,j,ft,ut.width,ut.height,Q.depth,0,ht,Pt,ut.data)}else{Ht&&$t&&e.texStorage2D(r.TEXTURE_2D,ct,ft,Ut[0].width,Ut[0].height);for(let j=0,dt=Ut.length;j<dt;j++)ut=Ut[j],_.format!==Ei?ht!==null?Ht?O&&e.compressedTexSubImage2D(r.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,ut.data):e.compressedTexImage2D(r.TEXTURE_2D,j,ft,ut.width,ut.height,0,ut.data):Rt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ht?O&&e.texSubImage2D(r.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,Pt,ut.data):e.texImage2D(r.TEXTURE_2D,j,ft,ut.width,ut.height,0,ht,Pt,ut.data)}else if(_.isDataArrayTexture)if(Ht){if($t&&e.texStorage3D(r.TEXTURE_2D_ARRAY,ct,ft,Q.width,Q.height,Q.depth),O)if(_.layerUpdates.size>0){const j=mp(Q.width,Q.height,_.format,_.type);for(const dt of _.layerUpdates){const vt=Q.data.subarray(dt*j/Q.data.BYTES_PER_ELEMENT,(dt+1)*j/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,dt,Q.width,Q.height,1,ht,Pt,vt)}_.clearLayerUpdates()}else e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ht,Pt,Q.data)}else e.texImage3D(r.TEXTURE_2D_ARRAY,0,ft,Q.width,Q.height,Q.depth,0,ht,Pt,Q.data);else if(_.isData3DTexture)Ht?($t&&e.texStorage3D(r.TEXTURE_3D,ct,ft,Q.width,Q.height,Q.depth),O&&e.texSubImage3D(r.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ht,Pt,Q.data)):e.texImage3D(r.TEXTURE_3D,0,ft,Q.width,Q.height,Q.depth,0,ht,Pt,Q.data);else if(_.isFramebufferTexture){if($t)if(Ht)e.texStorage2D(r.TEXTURE_2D,ct,ft,Q.width,Q.height);else{let j=Q.width,dt=Q.height;for(let vt=0;vt<ct;vt++)e.texImage2D(r.TEXTURE_2D,vt,ft,j,dt,0,ht,Pt,null),j>>=1,dt>>=1}}else if(_.isHTMLTexture){if("texElementImage2D"in r){const j=r.canvas;if(j.hasAttribute("layoutsubtree")||j.setAttribute("layoutsubtree","true"),Q.parentNode!==j){j.appendChild(Q),u.add(_),j.onpaint=dt=>{const vt=dt.changedElements;for(const et of u)vt.includes(et.image)&&(et.needsUpdate=!0)},j.requestPaint();return}if(r.texElementImage2D.length===3)r.texElementImage2D(r.TEXTURE_2D,r.RGBA8,Q);else{const vt=r.RGBA,et=r.RGBA,It=r.UNSIGNED_BYTE;r.texElementImage2D(r.TEXTURE_2D,0,vt,et,It,Q)}r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE)}}else if(Ut.length>0){if(Ht&&$t){const j=ye(Ut[0]);e.texStorage2D(r.TEXTURE_2D,ct,ft,j.width,j.height)}for(let j=0,dt=Ut.length;j<dt;j++)ut=Ut[j],Ht?O&&e.texSubImage2D(r.TEXTURE_2D,j,0,0,ht,Pt,ut):e.texImage2D(r.TEXTURE_2D,j,ft,ht,Pt,ut);_.generateMipmaps=!1}else if(Ht){if($t){const j=ye(Q);e.texStorage2D(r.TEXTURE_2D,ct,ft,j.width,j.height)}O&&e.texSubImage2D(r.TEXTURE_2D,0,0,0,ht,Pt,Q)}else e.texImage2D(r.TEXTURE_2D,0,ft,ht,Pt,Q);g(_)&&S(W),lt.__version=ot.version,_.onUpdate&&_.onUpdate(_)}D.__version=_.version}function Tt(D,_,U){if(_.image.length!==6)return;const W=q(D,_),K=_.source;e.bindTexture(r.TEXTURE_CUBE_MAP,D.__webglTexture,r.TEXTURE0+U);const ot=i.get(K);if(K.version!==ot.__version||W===!0){e.activeTexture(r.TEXTURE0+U);const lt=re.getPrimaries(re.workingColorSpace),Z=_.colorSpace===Ks?null:re.getPrimaries(_.colorSpace),Q=_.colorSpace===Ks||lt===Z?r.NONE:r.BROWSER_DEFAULT_WEBGL;e.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,_.flipY),e.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),e.pixelStorei(r.UNPACK_ALIGNMENT,_.unpackAlignment),e.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const ht=_.isCompressedTexture||_.image[0].isCompressedTexture,Pt=_.image[0]&&_.image[0].isDataTexture,ft=[];for(let et=0;et<6;et++)!ht&&!Pt?ft[et]=m(_.image[et],!0,n.maxCubemapSize):ft[et]=Pt?_.image[et].image:_.image[et],ft[et]=Yi(_,ft[et]);const ut=ft[0],Ut=s.convert(_.format,_.colorSpace),Ht=s.convert(_.type),$t=M(_.internalFormat,Ut,Ht,_.normalized,_.colorSpace),O=_.isVideoTexture!==!0,ct=ot.__version===void 0||W===!0,j=K.dataReady;let dt=w(_,ut);qt(r.TEXTURE_CUBE_MAP,_);let vt;if(ht){O&&ct&&e.texStorage2D(r.TEXTURE_CUBE_MAP,dt,$t,ut.width,ut.height);for(let et=0;et<6;et++){vt=ft[et].mipmaps;for(let It=0;It<vt.length;It++){const bt=vt[It];_.format!==Ei?Ut!==null?O?j&&e.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It,0,0,bt.width,bt.height,Ut,bt.data):e.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It,$t,bt.width,bt.height,0,bt.data):Rt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):O?j&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It,0,0,bt.width,bt.height,Ut,Ht,bt.data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It,$t,bt.width,bt.height,0,Ut,Ht,bt.data)}}}else{if(vt=_.mipmaps,O&&ct){vt.length>0&&dt++;const et=ye(ft[0]);e.texStorage2D(r.TEXTURE_CUBE_MAP,dt,$t,et.width,et.height)}for(let et=0;et<6;et++)if(Pt){O?j&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,0,0,ft[et].width,ft[et].height,Ut,Ht,ft[et].data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,$t,ft[et].width,ft[et].height,0,Ut,Ht,ft[et].data);for(let It=0;It<vt.length;It++){const Je=vt[It].image[et].image;O?j&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It+1,0,0,Je.width,Je.height,Ut,Ht,Je.data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It+1,$t,Je.width,Je.height,0,Ut,Ht,Je.data)}}else{O?j&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,0,0,Ut,Ht,ft[et]):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,$t,Ut,Ht,ft[et]);for(let It=0;It<vt.length;It++){const bt=vt[It];O?j&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It+1,0,0,Ut,Ht,bt.image[et]):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+et,It+1,$t,Ut,Ht,bt.image[et])}}}g(_)&&S(r.TEXTURE_CUBE_MAP),ot.__version=K.version,_.onUpdate&&_.onUpdate(_)}D.__version=_.version}function Nt(D,_,U,W,K,ot){const lt=s.convert(U.format,U.colorSpace),Z=s.convert(U.type),Q=M(U.internalFormat,lt,Z,U.normalized,U.colorSpace),ht=i.get(_),Pt=i.get(U);if(Pt.__renderTarget=_,!ht.__hasExternalTextures){const ft=Math.max(1,_.width>>ot),ut=Math.max(1,_.height>>ot);K===r.TEXTURE_3D||K===r.TEXTURE_2D_ARRAY?e.texImage3D(K,ot,Q,ft,ut,_.depth,0,lt,Z,null):e.texImage2D(K,ot,Q,ft,ut,0,lt,Z,null)}e.bindFramebuffer(r.FRAMEBUFFER,D),ci(_)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,W,K,Pt.__webglTexture,0,Ze(_)):(K===r.TEXTURE_2D||K>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,W,K,Pt.__webglTexture,ot),e.bindFramebuffer(r.FRAMEBUFFER,null)}function Ct(D,_,U){if(r.bindRenderbuffer(r.RENDERBUFFER,D),_.depthBuffer){const W=_.depthTexture,K=W&&W.isDepthTexture?W.type:null,ot=b(_.stencilBuffer,K),lt=_.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;ci(_)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Ze(_),ot,_.width,_.height):U?r.renderbufferStorageMultisample(r.RENDERBUFFER,Ze(_),ot,_.width,_.height):r.renderbufferStorage(r.RENDERBUFFER,ot,_.width,_.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,lt,r.RENDERBUFFER,D)}else{const W=_.textures;for(let K=0;K<W.length;K++){const ot=W[K],lt=s.convert(ot.format,ot.colorSpace),Z=s.convert(ot.type),Q=M(ot.internalFormat,lt,Z,ot.normalized,ot.colorSpace);ci(_)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Ze(_),Q,_.width,_.height):U?r.renderbufferStorageMultisample(r.RENDERBUFFER,Ze(_),Q,_.width,_.height):r.renderbufferStorage(r.RENDERBUFFER,Q,_.width,_.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function _t(D,_,U){const W=_.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(r.FRAMEBUFFER,D),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const K=i.get(_.depthTexture);if(K.__renderTarget=_,(!K.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),W){if(K.__webglInit===void 0&&(K.__webglInit=!0,_.depthTexture.addEventListener("dispose",T)),K.__webglTexture===void 0){K.__webglTexture=r.createTexture(),e.bindTexture(r.TEXTURE_CUBE_MAP,K.__webglTexture),qt(r.TEXTURE_CUBE_MAP,_.depthTexture);const ht=s.convert(_.depthTexture.format),Pt=s.convert(_.depthTexture.type);let ft;_.depthTexture.format===Es?ft=r.DEPTH_COMPONENT24:_.depthTexture.format===Ea&&(ft=r.DEPTH24_STENCIL8);for(let ut=0;ut<6;ut++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,ft,_.width,_.height,0,ht,Pt,null)}}else $(_.depthTexture,0);const ot=K.__webglTexture,lt=Ze(_),Z=W?r.TEXTURE_CUBE_MAP_POSITIVE_X+U:r.TEXTURE_2D,Q=_.depthTexture.format===Ea?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;if(_.depthTexture.format===Es)ci(_)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Q,Z,ot,0,lt):r.framebufferTexture2D(r.FRAMEBUFFER,Q,Z,ot,0);else if(_.depthTexture.format===Ea)ci(_)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Q,Z,ot,0,lt):r.framebufferTexture2D(r.FRAMEBUFFER,Q,Z,ot,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function kt(D){const _=i.get(D),U=D.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==D.depthTexture){const W=D.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),W){const K=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,W.removeEventListener("dispose",K)};W.addEventListener("dispose",K),_.__depthDisposeCallback=K}_.__boundDepthTexture=W}if(D.depthTexture&&!_.__autoAllocateDepthBuffer)if(U)for(let W=0;W<6;W++)_t(_.__webglFramebuffer[W],D,W);else{const W=D.texture.mipmaps;W&&W.length>0?_t(_.__webglFramebuffer[0],D,0):_t(_.__webglFramebuffer,D,0)}else if(U){_.__webglDepthbuffer=[];for(let W=0;W<6;W++)if(e.bindFramebuffer(r.FRAMEBUFFER,_.__webglFramebuffer[W]),_.__webglDepthbuffer[W]===void 0)_.__webglDepthbuffer[W]=r.createRenderbuffer(),Ct(_.__webglDepthbuffer[W],D,!1);else{const K=D.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ot=_.__webglDepthbuffer[W];r.bindRenderbuffer(r.RENDERBUFFER,ot),r.framebufferRenderbuffer(r.FRAMEBUFFER,K,r.RENDERBUFFER,ot)}}else{const W=D.texture.mipmaps;if(W&&W.length>0?e.bindFramebuffer(r.FRAMEBUFFER,_.__webglFramebuffer[0]):e.bindFramebuffer(r.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=r.createRenderbuffer(),Ct(_.__webglDepthbuffer,D,!1);else{const K=D.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ot=_.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,ot),r.framebufferRenderbuffer(r.FRAMEBUFFER,K,r.RENDERBUFFER,ot)}}e.bindFramebuffer(r.FRAMEBUFFER,null)}function zt(D,_,U){const W=i.get(D);_!==void 0&&Nt(W.__webglFramebuffer,D,D.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),U!==void 0&&kt(D)}function Bt(D){const _=D.texture,U=i.get(D),W=i.get(_);D.addEventListener("dispose",x);const K=D.textures,ot=D.isWebGLCubeRenderTarget===!0,lt=K.length>1;if(lt||(W.__webglTexture===void 0&&(W.__webglTexture=r.createTexture()),W.__version=_.version,a.memory.textures++),ot){U.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(_.mipmaps&&_.mipmaps.length>0){U.__webglFramebuffer[Z]=[];for(let Q=0;Q<_.mipmaps.length;Q++)U.__webglFramebuffer[Z][Q]=r.createFramebuffer()}else U.__webglFramebuffer[Z]=r.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){U.__webglFramebuffer=[];for(let Z=0;Z<_.mipmaps.length;Z++)U.__webglFramebuffer[Z]=r.createFramebuffer()}else U.__webglFramebuffer=r.createFramebuffer();if(lt)for(let Z=0,Q=K.length;Z<Q;Z++){const ht=i.get(K[Z]);ht.__webglTexture===void 0&&(ht.__webglTexture=r.createTexture(),a.memory.textures++)}if(D.samples>0&&ci(D)===!1){U.__webglMultisampledFramebuffer=r.createFramebuffer(),U.__webglColorRenderbuffer=[],e.bindFramebuffer(r.FRAMEBUFFER,U.__webglMultisampledFramebuffer);for(let Z=0;Z<K.length;Z++){const Q=K[Z];U.__webglColorRenderbuffer[Z]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,U.__webglColorRenderbuffer[Z]);const ht=s.convert(Q.format,Q.colorSpace),Pt=s.convert(Q.type),ft=M(Q.internalFormat,ht,Pt,Q.normalized,Q.colorSpace,D.isXRRenderTarget===!0),ut=Ze(D);r.renderbufferStorageMultisample(r.RENDERBUFFER,ut,ft,D.width,D.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Z,r.RENDERBUFFER,U.__webglColorRenderbuffer[Z])}r.bindRenderbuffer(r.RENDERBUFFER,null),D.depthBuffer&&(U.__webglDepthRenderbuffer=r.createRenderbuffer(),Ct(U.__webglDepthRenderbuffer,D,!0)),e.bindFramebuffer(r.FRAMEBUFFER,null)}}if(ot){e.bindTexture(r.TEXTURE_CUBE_MAP,W.__webglTexture),qt(r.TEXTURE_CUBE_MAP,_);for(let Z=0;Z<6;Z++)if(_.mipmaps&&_.mipmaps.length>0)for(let Q=0;Q<_.mipmaps.length;Q++)Nt(U.__webglFramebuffer[Z][Q],D,_,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Nt(U.__webglFramebuffer[Z],D,_,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);g(_)&&S(r.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(lt){for(let Z=0,Q=K.length;Z<Q;Z++){const ht=K[Z],Pt=i.get(ht);let ft=r.TEXTURE_2D;(D.isWebGL3DRenderTarget||D.isWebGLArrayRenderTarget)&&(ft=D.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),e.bindTexture(ft,Pt.__webglTexture),qt(ft,ht),Nt(U.__webglFramebuffer,D,ht,r.COLOR_ATTACHMENT0+Z,ft,0),g(ht)&&S(ft)}e.unbindTexture()}else{let Z=r.TEXTURE_2D;if((D.isWebGL3DRenderTarget||D.isWebGLArrayRenderTarget)&&(Z=D.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),e.bindTexture(Z,W.__webglTexture),qt(Z,_),_.mipmaps&&_.mipmaps.length>0)for(let Q=0;Q<_.mipmaps.length;Q++)Nt(U.__webglFramebuffer[Q],D,_,r.COLOR_ATTACHMENT0,Z,Q);else Nt(U.__webglFramebuffer,D,_,r.COLOR_ATTACHMENT0,Z,0);g(_)&&S(Z),e.unbindTexture()}D.depthBuffer&&kt(D)}function Me(D){const _=D.textures;for(let U=0,W=_.length;U<W;U++){const K=_[U];if(g(K)){const ot=y(D),lt=i.get(K).__webglTexture;e.bindTexture(ot,lt),S(ot),e.unbindTexture()}}}const xe=[],Ke=[];function He(D){if(D.samples>0){if(ci(D)===!1){const _=D.textures,U=D.width,W=D.height;let K=r.COLOR_BUFFER_BIT;const ot=D.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,lt=i.get(D),Z=_.length>1;if(Z)for(let ht=0;ht<_.length;ht++)e.bindFramebuffer(r.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ht,r.RENDERBUFFER,null),e.bindFramebuffer(r.FRAMEBUFFER,lt.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+ht,r.TEXTURE_2D,null,0);e.bindFramebuffer(r.READ_FRAMEBUFFER,lt.__webglMultisampledFramebuffer);const Q=D.texture.mipmaps;Q&&Q.length>0?e.bindFramebuffer(r.DRAW_FRAMEBUFFER,lt.__webglFramebuffer[0]):e.bindFramebuffer(r.DRAW_FRAMEBUFFER,lt.__webglFramebuffer);for(let ht=0;ht<_.length;ht++){if(D.resolveDepthBuffer&&(D.depthBuffer&&(K|=r.DEPTH_BUFFER_BIT),D.stencilBuffer&&D.resolveStencilBuffer&&(K|=r.STENCIL_BUFFER_BIT)),Z){r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,lt.__webglColorRenderbuffer[ht]);const Pt=i.get(_[ht]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,Pt,0)}r.blitFramebuffer(0,0,U,W,0,0,U,W,K,r.NEAREST),c===!0&&(xe.length=0,Ke.length=0,xe.push(r.COLOR_ATTACHMENT0+ht),D.depthBuffer&&D.resolveDepthBuffer===!1&&(xe.push(ot),Ke.push(ot),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,Ke)),r.invalidateFramebuffer(r.READ_FRAMEBUFFER,xe))}if(e.bindFramebuffer(r.READ_FRAMEBUFFER,null),e.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),Z)for(let ht=0;ht<_.length;ht++){e.bindFramebuffer(r.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ht,r.RENDERBUFFER,lt.__webglColorRenderbuffer[ht]);const Pt=i.get(_[ht]).__webglTexture;e.bindFramebuffer(r.FRAMEBUFFER,lt.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+ht,r.TEXTURE_2D,Pt,0)}e.bindFramebuffer(r.DRAW_FRAMEBUFFER,lt.__webglMultisampledFramebuffer)}else if(D.depthBuffer&&D.resolveDepthBuffer===!1&&c){const _=D.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[_])}}}function Ze(D){return Math.min(n.maxSamples,D.samples)}function ci(D){const _=i.get(D);return D.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function N(D){const _=a.render.frame;h.get(D)!==_&&(h.set(D,_),D.update())}function Yi(D,_){const U=D.colorSpace,W=D.format,K=D.type;return D.isCompressedTexture===!0||D.isVideoTexture===!0||U!==xl&&U!==Ks&&(re.getTransfer(U)===Se?(W!==Ei||K!==un)&&Rt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Gt("WebGLTextures: Unsupported texture color space:",U)),_}function ye(D){return typeof HTMLImageElement<"u"&&D instanceof HTMLImageElement?(l.width=D.naturalWidth||D.width,l.height=D.naturalHeight||D.height):typeof VideoFrame<"u"&&D instanceof VideoFrame?(l.width=D.displayWidth,l.height=D.displayHeight):(l.width=D.width,l.height=D.height),l}this.allocateTextureUnit=B,this.resetTextureUnits=V,this.getTextureUnits=X,this.setTextureUnits=L,this.setTexture2D=$,this.setTexture2DArray=tt,this.setTexture3D=J,this.setTextureCube=it,this.rebindTextures=zt,this.setupRenderTarget=Bt,this.updateRenderTargetMipmap=Me,this.updateMultisampleRenderTarget=He,this.setupDepthRenderbuffer=kt,this.setupFrameBufferTexture=Nt,this.useMultisampledRTT=ci,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function sb(r,t){function e(i,n=Ks){let s;const a=re.getTransfer(n);if(i===un)return r.UNSIGNED_BYTE;if(i===n0)return r.UNSIGNED_SHORT_4_4_4_4;if(i===s0)return r.UNSIGNED_SHORT_5_5_5_1;if(i===Rg)return r.UNSIGNED_INT_5_9_9_9_REV;if(i===Dg)return r.UNSIGNED_INT_10F_11F_11F_REV;if(i===Ag)return r.BYTE;if(i===Tg)return r.SHORT;if(i===zo)return r.UNSIGNED_SHORT;if(i===i0)return r.INT;if(i===Sn)return r.UNSIGNED_INT;if(i===Oi)return r.FLOAT;if(i===qe)return r.HALF_FLOAT;if(i===Ig)return r.ALPHA;if(i===Cg)return r.RGB;if(i===Ei)return r.RGBA;if(i===Es)return r.DEPTH_COMPONENT;if(i===Ea)return r.DEPTH_STENCIL;if(i===Hl)return r.RED;if(i===a0)return r.RED_INTEGER;if(i===Na)return r.RG;if(i===r0)return r.RG_INTEGER;if(i===o0)return r.RGBA_INTEGER;if(i===il||i===nl||i===sl||i===al)if(a===Se)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===il)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===nl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===sl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===al)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===il)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===nl)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===sl)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===al)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Nu||i===Fu||i===Uu||i===ku)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Nu)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Fu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Uu)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===ku)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===zu||i===Bu||i===Hu||i===Gu||i===Vu||i===pl||i===Wu)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===zu||i===Bu)return a===Se?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Hu)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Gu)return s.COMPRESSED_R11_EAC;if(i===Vu)return s.COMPRESSED_SIGNED_R11_EAC;if(i===pl)return s.COMPRESSED_RG11_EAC;if(i===Wu)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Xu||i===Yu||i===qu||i===$u||i===Ku||i===Zu||i===Ju||i===ju||i===Qu||i===td||i===ed||i===id||i===nd||i===sd)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Xu)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Yu)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===qu)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$u)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Ku)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Zu)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ju)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ju)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Qu)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===td)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ed)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===id)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===nd)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===sd)return a===Se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===ad||i===rd||i===od)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===ad)return a===Se?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===rd)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===od)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===cd||i===ld||i===ml||i===hd)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===cd)return s.COMPRESSED_RED_RGTC1_EXT;if(i===ld)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ml)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===hd)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Bo?r.UNSIGNED_INT_24_8:r[i]!==void 0?r[i]:null}return{convert:e}}const ab=`
5188
5245
  void main() {
5189
5246
 
5190
5247
  gl_Position = vec4( position, 1.0 );
@@ -5208,7 +5265,7 @@ void main() {
5208
5265
 
5209
5266
  }
5210
5267
 
5211
- }`;class ob{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const i=new Vg(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,i=new le({vertexShader:ab,fragmentShader:rb,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Dt(new Xi(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class cb extends aa{constructor(t,e){super();const i=this;let n=null,s=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,p=null;const v=typeof XRWebGLBinding<"u",m=new ob,g={},S=e.getContextAttributes();let y=null,M=null;const b=[],w=[],T=new xt;let x=null;const A=new Zi;A.viewport=new ne;const C=new Zi;C.viewport=new ne;const I=[A,C],P=new ax;let V=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let at=b[q];return at===void 0&&(at=new fh,b[q]=at),at.getTargetRaySpace()},this.getControllerGrip=function(q){let at=b[q];return at===void 0&&(at=new fh,b[q]=at),at.getGripSpace()},this.getHand=function(q){let at=b[q];return at===void 0&&(at=new fh,b[q]=at),at.getHandSpace()};function L(q){const at=w.indexOf(q.inputSource);if(at===-1)return;const nt=b[at];nt!==void 0&&(nt.update(q.inputSource,q.frame,l||a),nt.dispatchEvent({type:q.type,data:q.inputSource}))}function B(){n.removeEventListener("select",L),n.removeEventListener("selectstart",L),n.removeEventListener("selectend",L),n.removeEventListener("squeeze",L),n.removeEventListener("squeezestart",L),n.removeEventListener("squeezeend",L),n.removeEventListener("end",B),n.removeEventListener("inputsourceschange",k);for(let q=0;q<b.length;q++){const at=w[q];at!==null&&(w[q]=null,b[q].disconnect(at))}V=null,X=null,m.reset();for(const q in g)delete g[q];t.setRenderTarget(y),f=null,d=null,u=null,n=null,M=null,qt.stop(),i.isPresenting=!1,t.setPixelRatio(x),t.setSize(T.width,T.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(q){s=q,i.isPresenting===!0&&Rt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(q){o=q,i.isPresenting===!0&&Rt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(q){l=q},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&v&&(u=new XRWebGLBinding(n,e)),u},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(q){if(n=q,n!==null){if(y=t.getRenderTarget(),n.addEventListener("select",L),n.addEventListener("selectstart",L),n.addEventListener("selectend",L),n.addEventListener("squeeze",L),n.addEventListener("squeezestart",L),n.addEventListener("squeezeend",L),n.addEventListener("end",B),n.addEventListener("inputsourceschange",k),S.xrCompatible!==!0&&await e.makeXRCompatible(),x=t.getPixelRatio(),t.getSize(T),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let nt=null,z=null,Tt=null;S.depth&&(Tt=S.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,nt=S.stencil?Ea:Es,z=S.stencil?Bo:Sn);const Nt={colorFormat:e.RGBA8,depthFormat:Tt,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Nt),n.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),M=new ri(d.textureWidth,d.textureHeight,{format:Ei,type:un,depthTexture:new na(d.textureWidth,d.textureHeight,z,void 0,void 0,void 0,void 0,void 0,void 0,nt),stencilBuffer:S.stencil,colorSpace:t.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const nt={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,e,nt),n.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),M=new ri(f.framebufferWidth,f.framebufferHeight,{format:Ei,type:un,colorSpace:t.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await n.requestReferenceSpace(o),qt.setContext(n),qt.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function k(q){for(let at=0;at<q.removed.length;at++){const nt=q.removed[at],z=w.indexOf(nt);z>=0&&(w[z]=null,b[z].disconnect(nt))}for(let at=0;at<q.added.length;at++){const nt=q.added[at];let z=w.indexOf(nt);if(z===-1){for(let Nt=0;Nt<b.length;Nt++)if(Nt>=w.length){w.push(nt),z=Nt;break}else if(w[Nt]===null){w[Nt]=nt,z=Nt;break}if(z===-1)break}const Tt=b[z];Tt&&Tt.connect(nt)}}const $=new R,tt=new R;function J(q,at,nt){$.setFromMatrixPosition(at.matrixWorld),tt.setFromMatrixPosition(nt.matrixWorld);const z=$.distanceTo(tt),Tt=at.projectionMatrix.elements,Nt=nt.projectionMatrix.elements,Ct=Tt[14]/(Tt[10]-1),_t=Tt[14]/(Tt[10]+1),kt=(Tt[9]+1)/Tt[5],zt=(Tt[9]-1)/Tt[5],Bt=(Tt[8]-1)/Tt[0],Me=(Nt[8]+1)/Nt[0],xe=Ct*Bt,Ke=Ct*Me,He=z/(-Bt+Me),Ze=He*-Bt;if(at.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(Ze),q.translateZ(He),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),Tt[10]===-1)q.projectionMatrix.copy(at.projectionMatrix),q.projectionMatrixInverse.copy(at.projectionMatrixInverse);else{const ci=Ct+He,N=_t+He,Yi=xe-Ze,ye=Ke+(z-Ze),D=kt*_t/N*ci,_=zt*_t/N*ci;q.projectionMatrix.makePerspective(Yi,ye,D,_,ci,N),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}function it(q,at){at===null?q.matrixWorld.copy(q.matrix):q.matrixWorld.multiplyMatrices(at.matrixWorld,q.matrix),q.matrixWorldInverse.copy(q.matrixWorld).invert()}this.updateCamera=function(q){if(n===null)return;let at=q.near,nt=q.far;m.texture!==null&&(m.depthNear>0&&(at=m.depthNear),m.depthFar>0&&(nt=m.depthFar)),P.near=C.near=A.near=at,P.far=C.far=A.far=nt,(V!==P.near||X!==P.far)&&(n.updateRenderState({depthNear:P.near,depthFar:P.far}),V=P.near,X=P.far),P.layers.mask=q.layers.mask|6,A.layers.mask=P.layers.mask&-5,C.layers.mask=P.layers.mask&-3;const z=q.parent,Tt=P.cameras;it(P,z);for(let Nt=0;Nt<Tt.length;Nt++)it(Tt[Nt],z);Tt.length===2?J(P,A,C):P.projectionMatrix.copy(A.projectionMatrix),rt(q,P,z)};function rt(q,at,nt){nt===null?q.matrix.copy(at.matrixWorld):(q.matrix.copy(nt.matrixWorld),q.matrix.invert(),q.matrix.multiply(at.matrixWorld)),q.matrix.decompose(q.position,q.quaternion,q.scale),q.updateMatrixWorld(!0),q.projectionMatrix.copy(at.projectionMatrix),q.projectionMatrixInverse.copy(at.projectionMatrixInverse),q.isPerspectiveCamera&&(q.fov=Or*2*Math.atan(1/q.projectionMatrix.elements[5]),q.zoom=1)}this.getCamera=function(){return P},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(q){c=q,d!==null&&(d.fixedFoveation=q),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=q)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(P)},this.getCameraTexture=function(q){return g[q]};let Vt=null;function Jt(q,at){if(h=at.getViewerPose(l||a),p=at,h!==null){const nt=h.views;f!==null&&(t.setRenderTargetFramebuffer(M,f.framebuffer),t.setRenderTarget(M));let z=!1;nt.length!==P.cameras.length&&(P.cameras.length=0,z=!0);for(let _t=0;_t<nt.length;_t++){const kt=nt[_t];let zt=null;if(f!==null)zt=f.getViewport(kt);else{const Me=u.getViewSubImage(d,kt);zt=Me.viewport,_t===0&&(t.setRenderTargetTextures(M,Me.colorTexture,Me.depthStencilTexture),t.setRenderTarget(M))}let Bt=I[_t];Bt===void 0&&(Bt=new Zi,Bt.layers.enable(_t),Bt.viewport=new ne,I[_t]=Bt),Bt.matrix.fromArray(kt.transform.matrix),Bt.matrix.decompose(Bt.position,Bt.quaternion,Bt.scale),Bt.projectionMatrix.fromArray(kt.projectionMatrix),Bt.projectionMatrixInverse.copy(Bt.projectionMatrix).invert(),Bt.viewport.set(zt.x,zt.y,zt.width,zt.height),_t===0&&(P.matrix.copy(Bt.matrix),P.matrix.decompose(P.position,P.quaternion,P.scale)),z===!0&&P.cameras.push(Bt)}const Tt=n.enabledFeatures;if(Tt&&Tt.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&v){u=i.getBinding();const _t=u.getDepthInformation(nt[0]);_t&&_t.isValid&&_t.texture&&m.init(_t,n.renderState)}if(Tt&&Tt.includes("camera-access")&&v){t.state.unbindTexture(),u=i.getBinding();for(let _t=0;_t<nt.length;_t++){const kt=nt[_t].camera;if(kt){let zt=g[kt];zt||(zt=new Vg,g[kt]=zt);const Bt=u.getCameraImage(kt);zt.sourceTexture=Bt}}}}for(let nt=0;nt<b.length;nt++){const z=w[nt],Tt=b[nt];z!==null&&Tt!==void 0&&Tt.update(z,at,l||a)}Vt&&Vt(q,at),at.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:at}),p=null}const qt=new jg;qt.setAnimationLoop(Jt),this.setAnimationLoop=function(q){Vt=q},this.dispose=function(){}}}const lb=new Zt,s1=new Yt;s1.set(-1,0,0,0,1,0,0,0,1);function hb(r,t){function e(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function i(m,g){g.color.getRGB(m.fogColor.value,Wg(r)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,S,y,M){g.isNodeMaterial?g.uniformsNeedUpdate=!1:g.isMeshBasicMaterial?s(m,g):g.isMeshLambertMaterial?(s(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(s(m,g),u(m,g)):g.isMeshPhongMaterial?(s(m,g),h(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(s(m,g),d(m,g),g.isMeshPhysicalMaterial&&f(m,g,M)):g.isMeshMatcapMaterial?(s(m,g),p(m,g)):g.isMeshDepthMaterial?s(m,g):g.isMeshDistanceMaterial?(s(m,g),v(m,g)):g.isMeshNormalMaterial?s(m,g):g.isLineBasicMaterial?(a(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?c(m,g,S,y):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map,e(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,e(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,e(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===Ve&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,e(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===Ve&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,e(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,e(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,e(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const S=t.get(g),y=S.envMap,M=S.envMapRotation;y&&(m.envMap.value=y,m.envMapRotation.value.setFromMatrix4(lb.makeRotationFromEuler(M)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(s1),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,e(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,e(g.aoMap,m.aoMapTransform))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,e(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function c(m,g,S,y){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*S,m.scale.value=y*.5,g.map&&(m.map.value=g.map,e(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,e(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,e(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,e(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,e(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,e(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,S){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,e(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,e(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,e(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,e(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,e(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===Ve&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,e(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,e(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=S.texture,m.transmissionSamplerSize.value.set(S.width,S.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,e(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,e(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,e(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,e(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,e(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function v(m,g){const S=t.get(g).light;m.referencePosition.value.setFromMatrixPosition(S.matrixWorld),m.nearDistance.value=S.shadow.camera.near,m.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function ub(r,t,e,i){let n={},s={},a=[];const o=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,b){const w=b.program;i.uniformBlockBinding(M,w)}function l(M,b){let w=n[M.id];w===void 0&&(m(M),w=h(M),n[M.id]=w,M.addEventListener("dispose",S));const T=b.program;i.updateUBOMapping(M,T);const x=t.render.frame;s[M.id]!==x&&(d(M),s[M.id]=x)}function h(M){const b=u();M.__bindingPointIndex=b;const w=r.createBuffer(),T=M.__size,x=M.usage;return r.bindBuffer(r.UNIFORM_BUFFER,w),r.bufferData(r.UNIFORM_BUFFER,T,x),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,b,w),w}function u(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return Gt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const b=n[M.id],w=M.uniforms,T=M.__cache;r.bindBuffer(r.UNIFORM_BUFFER,b);for(let x=0,A=w.length;x<A;x++){const C=w[x];if(Array.isArray(C))for(let I=0,P=C.length;I<P;I++)f(C[I],x,I,T);else f(C,x,0,T)}r.bindBuffer(r.UNIFORM_BUFFER,null)}function f(M,b,w,T){if(v(M,b,w,T)===!0){const x=M.__offset,A=M.value;if(Array.isArray(A)){let C=0;for(let I=0;I<A.length;I++){const P=A[I],V=g(P);p(P,M.__data,C),typeof P!="number"&&typeof P!="boolean"&&!P.isMatrix3&&!ArrayBuffer.isView(P)&&(C+=V.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(A,M.__data,0);r.bufferSubData(r.UNIFORM_BUFFER,x,M.__data)}}function p(M,b,w){typeof M=="number"||typeof M=="boolean"?b[0]=M:M.isMatrix3?(b[0]=M.elements[0],b[1]=M.elements[1],b[2]=M.elements[2],b[3]=0,b[4]=M.elements[3],b[5]=M.elements[4],b[6]=M.elements[5],b[7]=0,b[8]=M.elements[6],b[9]=M.elements[7],b[10]=M.elements[8],b[11]=0):ArrayBuffer.isView(M)?b.set(new M.constructor(M.buffer,M.byteOffset,b.length)):M.toArray(b,w)}function v(M,b,w,T){const x=M.value,A=b+"_"+w;if(T[A]===void 0)return typeof x=="number"||typeof x=="boolean"?T[A]=x:ArrayBuffer.isView(x)?T[A]=x.slice():T[A]=x.clone(),!0;{const C=T[A];if(typeof x=="number"||typeof x=="boolean"){if(C!==x)return T[A]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(C.equals(x)===!1)return C.copy(x),!0}}return!1}function m(M){const b=M.uniforms;let w=0;const T=16;for(let A=0,C=b.length;A<C;A++){const I=Array.isArray(b[A])?b[A]:[b[A]];for(let P=0,V=I.length;P<V;P++){const X=I[P],L=Array.isArray(X.value)?X.value:[X.value];for(let B=0,k=L.length;B<k;B++){const $=L[B],tt=g($),J=w%T,it=J%tt.boundary,rt=J+it;w+=it,rt!==0&&T-rt<tt.storage&&(w+=T-rt),X.__data=new Float32Array(tt.storage/Float32Array.BYTES_PER_ELEMENT),X.__offset=w,w+=tt.storage}}}const x=w%T;return x>0&&(w+=T-x),M.__size=w,M.__cache={},this}function g(M){const b={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(b.boundary=4,b.storage=4):M.isVector2?(b.boundary=8,b.storage=8):M.isVector3||M.isColor?(b.boundary=16,b.storage=12):M.isVector4?(b.boundary=16,b.storage=16):M.isMatrix3?(b.boundary=48,b.storage=48):M.isMatrix4?(b.boundary=64,b.storage=64):M.isTexture?Rt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(b.boundary=16,b.storage=M.byteLength):Rt("WebGLRenderer: Unsupported uniform value type.",M),b}function S(M){const b=M.target;b.removeEventListener("dispose",S);const w=a.indexOf(b.__bindingPointIndex);a.splice(w,1),r.deleteBuffer(n[b.id]),delete n[b.id],delete s[b.id]}function y(){for(const M in n)r.deleteBuffer(n[M]);a=[],n={},s={}}return{bind:c,update:l,dispose:y}}const db=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Wn=null;function fb(){return Wn===null&&(Wn=new ra(db,16,16,Na,qe),Wn.name="DFG_LUT",Wn.minFilter=oe,Wn.magFilter=oe,Wn.wrapS=wi,Wn.wrapT=wi,Wn.generateMipmaps=!1,Wn.needsUpdate=!0),Wn}class pb{constructor(t={}){const{canvas:e=H2(),context:i=null,depth:n=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=un}=t;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=a;const v=f,m=new Set([o0,r0,a0]),g=new Set([un,Sn,zo,Bo,n0,s0]),S=new Uint32Array(4),y=new Int32Array(4),M=new R;let b=null,w=null;const T=[],x=[];let A=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=rs,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let I=!1,P=null,V=null,X=null,L=null;this._outputColorSpace=Gi;let B=0,k=0,$=null,tt=-1,J=null;const it=new ne,rt=new ne;let Vt=null;const Jt=new st(0);let qt=0,q=e.width,at=e.height,nt=1,z=null,Tt=null;const Nt=new ne(0,0,q,at),Ct=new ne(0,0,q,at);let _t=!1;const kt=new g0;let zt=!1,Bt=!1;const Me=new Zt,xe=new R,Ke=new ne,He={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ze=!1;function ci(){return $===null?nt:1}let N=i;function Yi(E,F){return e.getContext(E,F)}try{const E={alpha:!0,depth:n,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${t0}`),e.addEventListener("webglcontextlost",Je,!1),e.addEventListener("webglcontextrestored",Pe,!1),e.addEventListener("webglcontextcreationerror",zn,!1),N===null){const F="webgl2";if(N=Yi(F,E),N===null)throw Yi(F)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(E){throw Gt("WebGLRenderer: "+E.message),E}let ye,D,_,U,W,K,ot,lt,Z,Q,ht,Pt,ft,ut,Ut,Ht,$t,O,ct,j,dt,vt,et;function It(){ye=new f_(N),ye.init(),dt=new sb(N,ye),D=new a_(N,ye,t,dt),_=new ib(N,ye),D.reversedDepthBuffer&&d&&_.buffers.depth.setReversed(!0),V=N.createFramebuffer(),X=N.createFramebuffer(),L=N.createFramebuffer(),U=new g_(N),W=new GS,K=new nb(N,ye,_,W,D,dt,U),ot=new d_(C),lt=new yx(N),vt=new n_(N,lt),Z=new p_(N,lt,U,vt),Q=new M_(N,Z,lt,vt,U),O=new v_(N,D,K),Ut=new r_(W),ht=new HS(C,ot,ye,D,vt,Ut),Pt=new hb(C,W),ft=new WS,ut=new ZS(ye),$t=new i_(C,ot,_,Q,p,c),Ht=new eb(C,Q,D),et=new ub(N,U,D,_),ct=new s_(N,ye,U),j=new m_(N,ye,U),U.programs=ht.programs,C.capabilities=D,C.extensions=ye,C.properties=W,C.renderLists=ft,C.shadowMap=Ht,C.state=_,C.info=U}It(),v!==un&&(A=new y_(v,e.width,e.height,o,n,s));const bt=new cb(C,N);this.xr=bt,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){const E=ye.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=ye.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return nt},this.setPixelRatio=function(E){E!==void 0&&(nt=E,this.setSize(q,at,!1))},this.getSize=function(E){return E.set(q,at)},this.setSize=function(E,F,Y=!0){if(bt.isPresenting){Rt("WebGLRenderer: Can't change size while VR device is presenting.");return}q=E,at=F,e.width=Math.floor(E*nt),e.height=Math.floor(F*nt),Y===!0&&(e.style.width=E+"px",e.style.height=F+"px"),A!==null&&A.setSize(e.width,e.height),this.setViewport(0,0,E,F)},this.getDrawingBufferSize=function(E){return E.set(q*nt,at*nt).floor()},this.setDrawingBufferSize=function(E,F,Y){q=E,at=F,nt=Y,e.width=Math.floor(E*Y),e.height=Math.floor(F*Y),this.setViewport(0,0,E,F)},this.setEffects=function(E){if(v===un){Gt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let F=0;F<E.length;F++)if(E[F].isOutputPass===!0){Rt("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(E||[])},this.getCurrentViewport=function(E){return E.copy(it)},this.getViewport=function(E){return E.copy(Nt)},this.setViewport=function(E,F,Y,H){E.isVector4?Nt.set(E.x,E.y,E.z,E.w):Nt.set(E,F,Y,H),_.viewport(it.copy(Nt).multiplyScalar(nt).round())},this.getScissor=function(E){return E.copy(Ct)},this.setScissor=function(E,F,Y,H){E.isVector4?Ct.set(E.x,E.y,E.z,E.w):Ct.set(E,F,Y,H),_.scissor(rt.copy(Ct).multiplyScalar(nt).round())},this.getScissorTest=function(){return _t},this.setScissorTest=function(E){_.setScissorTest(_t=E)},this.setOpaqueSort=function(E){z=E},this.setTransparentSort=function(E){Tt=E},this.getClearColor=function(E){return E.copy($t.getClearColor())},this.setClearColor=function(){$t.setClearColor(...arguments)},this.getClearAlpha=function(){return $t.getClearAlpha()},this.setClearAlpha=function(){$t.setClearAlpha(...arguments)},this.clear=function(E=!0,F=!0,Y=!0){let H=0;if(E){let G=!1;if($!==null){const gt=$.texture.format;G=m.has(gt)}if(G){const gt=$.texture.type,St=g.has(gt),mt=$t.getClearColor(),Et=$t.getClearAlpha(),Lt=mt.r,Kt=mt.g,jt=mt.b;St?(S[0]=Lt,S[1]=Kt,S[2]=jt,S[3]=Et,N.clearBufferuiv(N.COLOR,0,S)):(y[0]=Lt,y[1]=Kt,y[2]=jt,y[3]=Et,N.clearBufferiv(N.COLOR,0,y))}else H|=N.COLOR_BUFFER_BIT}F&&(H|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Y&&(H|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H!==0&&N.clear(H)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(E){E.setRenderer(this),P=E},this.dispose=function(){e.removeEventListener("webglcontextlost",Je,!1),e.removeEventListener("webglcontextrestored",Pe,!1),e.removeEventListener("webglcontextcreationerror",zn,!1),$t.dispose(),ft.dispose(),ut.dispose(),W.dispose(),ot.dispose(),Q.dispose(),vt.dispose(),et.dispose(),ht.dispose(),bt.dispose(),bt.removeEventListener("sessionstart",G0),bt.removeEventListener("sessionend",V0),oa.stop()};function Je(E){E.preventDefault(),Sl("WebGLRenderer: Context Lost."),I=!0}function Pe(){Sl("WebGLRenderer: Context Restored."),I=!1;const E=U.autoReset,F=Ht.enabled,Y=Ht.autoUpdate,H=Ht.needsUpdate,G=Ht.type;It(),U.autoReset=E,Ht.enabled=F,Ht.autoUpdate=Y,Ht.needsUpdate=H,Ht.type=G}function zn(E){Gt("WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Bn(E){const F=E.target;F.removeEventListener("dispose",Bn),V1(F)}function V1(E){W1(E),W.remove(E)}function W1(E){const F=W.get(E).programs;F!==void 0&&(F.forEach(function(Y){ht.releaseProgram(Y)}),E.isShaderMaterial&&ht.releaseShaderCache(E))}this.renderBufferDirect=function(E,F,Y,H,G,gt){F===null&&(F=He);const St=G.isMesh&&G.matrixWorld.determinantAffine()<0,mt=q1(E,F,Y,H,G);_.setMaterial(H,St);let Et=Y.index,Lt=1;if(H.wireframe===!0){if(Et=Z.getWireframeAttribute(Y),Et===void 0)return;Lt=2}const Kt=Y.drawRange,jt=Y.attributes.position;let Ot=Kt.start*Lt,Ae=(Kt.start+Kt.count)*Lt;gt!==null&&(Ot=Math.max(Ot,gt.start*Lt),Ae=Math.min(Ae,(gt.start+gt.count)*Lt)),Et!==null?(Ot=Math.max(Ot,0),Ae=Math.min(Ae,Et.count)):jt!=null&&(Ot=Math.max(Ot,0),Ae=Math.min(Ae,jt.count));const ei=Ae-Ot;if(ei<0||ei===1/0)return;vt.setup(G,H,mt,Y,Et);let je,De=ct;if(Et!==null&&(je=lt.get(Et),De=j,De.setIndex(je)),G.isMesh)H.wireframe===!0?(_.setLineWidth(H.wireframeLinewidth*ci()),De.setMode(N.LINES)):De.setMode(N.TRIANGLES);else if(G.isLine){let Ti=H.linewidth;Ti===void 0&&(Ti=1),_.setLineWidth(Ti*ci()),G.isLineSegments?De.setMode(N.LINES):G.isLineLoop?De.setMode(N.LINE_LOOP):De.setMode(N.LINE_STRIP)}else G.isPoints?De.setMode(N.POINTS):G.isSprite&&De.setMode(N.TRIANGLES);if(G.isBatchedMesh)if(ye.get("WEBGL_multi_draw"))De.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{const Ti=G._multiDrawStarts,yt=G._multiDrawCounts,tn=G._multiDrawCount,he=Et?lt.get(Et).bytesPerElement:1,dn=W.get(H).currentProgram.getUniforms();for(let Hn=0;Hn<tn;Hn++)dn.setValue(N,"_gl_DrawID",Hn),De.render(Ti[Hn]/he,yt[Hn])}else if(G.isInstancedMesh)De.renderInstances(Ot,ei,G.count);else if(Y.isInstancedBufferGeometry){const Ti=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,yt=Math.min(Y.instanceCount,Ti);De.renderInstances(Ot,ei,yt)}else De.render(Ot,ei)};function H0(E,F,Y){E.transparent===!0&&E.side===ji&&E.forceSinglePass===!1?(E.side=Ve,E.needsUpdate=!0,Jo(E,F,Y),E.side=ia,E.needsUpdate=!0,Jo(E,F,Y),E.side=ji):Jo(E,F,Y)}this.compile=function(E,F,Y=null){Y===null&&(Y=E),w=ut.get(Y),w.init(F),x.push(w),Y.traverseVisible(function(G){G.isLight&&G.layers.test(F.layers)&&(w.pushLight(G),G.castShadow&&w.pushShadow(G))}),E!==Y&&E.traverseVisible(function(G){G.isLight&&G.layers.test(F.layers)&&(w.pushLight(G),G.castShadow&&w.pushShadow(G))}),w.setupLights();const H=new Set;return E.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;const gt=G.material;if(gt)if(Array.isArray(gt))for(let St=0;St<gt.length;St++){const mt=gt[St];H0(mt,Y,G),H.add(mt)}else H0(gt,Y,G),H.add(gt)}),w=x.pop(),H},this.compileAsync=function(E,F,Y=null){const H=this.compile(E,F,Y);return new Promise(G=>{function gt(){if(H.forEach(function(St){W.get(St).currentProgram.isReady()&&H.delete(St)}),H.size===0){G(E);return}setTimeout(gt,10)}ye.get("KHR_parallel_shader_compile")!==null?gt():setTimeout(gt,10)})};let Ql=null;function X1(E){Ql&&Ql(E)}function G0(){oa.stop()}function V0(){oa.start()}const oa=new jg;oa.setAnimationLoop(X1),typeof self<"u"&&oa.setContext(self),this.setAnimationLoop=function(E){Ql=E,bt.setAnimationLoop(E),E===null?oa.stop():oa.start()},bt.addEventListener("sessionstart",G0),bt.addEventListener("sessionend",V0),this.render=function(E,F){if(F!==void 0&&F.isCamera!==!0){Gt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(I===!0)return;P!==null&&P.renderStart(E,F);const Y=bt.enabled===!0&&bt.isPresenting===!0,H=A!==null&&($===null||Y)&&A.begin(C,$);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),bt.enabled===!0&&bt.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(bt.cameraAutoUpdate===!0&&bt.updateCamera(F),F=bt.getCamera()),E.isScene===!0&&E.onBeforeRender(C,E,F,$),w=ut.get(E,x.length),w.init(F),w.state.textureUnits=K.getTextureUnits(),x.push(w),Me.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),kt.setFromProjectionMatrix(Me,ns,F.reversedDepth),Bt=this.localClippingEnabled,zt=Ut.init(this.clippingPlanes,Bt),b=ft.get(E,T.length),b.init(),T.push(b),bt.enabled===!0&&bt.isPresenting===!0){const St=C.xr.getDepthSensingMesh();St!==null&&th(St,F,-1/0,C.sortObjects)}th(E,F,0,C.sortObjects),b.finish(),C.sortObjects===!0&&b.sort(z,Tt,F.reversedDepth),Ze=bt.enabled===!1||bt.isPresenting===!1||bt.hasDepthSensing()===!1,Ze&&$t.addToRenderList(b,E),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),zt===!0&&Ut.beginShadows();const G=w.state.shadowsArray;if(Ht.render(G,E,F),zt===!0&&Ut.endShadows(),(H&&A.hasRenderPass())===!1){const St=b.opaque,mt=b.transmissive;if(w.setupLights(),F.isArrayCamera){const Et=F.cameras;if(mt.length>0)for(let Lt=0,Kt=Et.length;Lt<Kt;Lt++){const jt=Et[Lt];X0(St,mt,E,jt)}Ze&&$t.render(E);for(let Lt=0,Kt=Et.length;Lt<Kt;Lt++){const jt=Et[Lt];W0(b,E,jt,jt.viewport)}}else mt.length>0&&X0(St,mt,E,F),Ze&&$t.render(E),W0(b,E,F)}$!==null&&k===0&&(K.updateMultisampleRenderTarget($),K.updateRenderTargetMipmap($)),H&&A.end(C),E.isScene===!0&&E.onAfterRender(C,E,F),vt.resetDefaultState(),tt=-1,J=null,x.pop(),x.length>0?(w=x[x.length-1],K.setTextureUnits(w.state.textureUnits),zt===!0&&Ut.setGlobalState(C.clippingPlanes,w.state.camera)):w=null,T.pop(),T.length>0?b=T[T.length-1]:b=null,P!==null&&P.renderEnd()};function th(E,F,Y,H){if(E.visible===!1)return;if(E.layers.test(F.layers)){if(E.isGroup)Y=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(F);else if(E.isLightProbeGrid)w.pushLightProbeGrid(E);else if(E.isLight)w.pushLight(E),E.castShadow&&w.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||kt.intersectsSprite(E)){H&&Ke.setFromMatrixPosition(E.matrixWorld).applyMatrix4(Me);const St=Q.update(E),mt=E.material;mt.visible&&b.push(E,St,mt,Y,Ke.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||kt.intersectsObject(E))){const St=Q.update(E),mt=E.material;if(H&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),Ke.copy(E.boundingSphere.center)):(St.boundingSphere===null&&St.computeBoundingSphere(),Ke.copy(St.boundingSphere.center)),Ke.applyMatrix4(E.matrixWorld).applyMatrix4(Me)),Array.isArray(mt)){const Et=St.groups;for(let Lt=0,Kt=Et.length;Lt<Kt;Lt++){const jt=Et[Lt],Ot=mt[jt.materialIndex];Ot&&Ot.visible&&b.push(E,St,Ot,Y,Ke.z,jt)}}else mt.visible&&b.push(E,St,mt,Y,Ke.z,null)}}const gt=E.children;for(let St=0,mt=gt.length;St<mt;St++)th(gt[St],F,Y,H)}function W0(E,F,Y,H){const{opaque:G,transmissive:gt,transparent:St}=E;w.setupLightsView(Y),zt===!0&&Ut.setGlobalState(C.clippingPlanes,Y),H&&_.viewport(it.copy(H)),G.length>0&&Zo(G,F,Y),gt.length>0&&Zo(gt,F,Y),St.length>0&&Zo(St,F,Y),_.buffers.depth.setTest(!0),_.buffers.depth.setMask(!0),_.buffers.color.setMask(!0),_.setPolygonOffset(!1)}function X0(E,F,Y,H){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[H.id]===void 0){const Ot=ye.has("EXT_color_buffer_half_float")||ye.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[H.id]=new ri(1,1,{generateMipmaps:!0,type:Ot?qe:un,minFilter:wa,samples:Math.max(4,D.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:re.workingColorSpace})}const gt=w.state.transmissionRenderTarget[H.id],St=H.viewport||it;gt.setSize(St.z*C.transmissionResolutionScale,St.w*C.transmissionResolutionScale);const mt=C.getRenderTarget(),Et=C.getActiveCubeFace(),Lt=C.getActiveMipmapLevel();C.setRenderTarget(gt),C.getClearColor(Jt),qt=C.getClearAlpha(),qt<1&&C.setClearColor(16777215,.5),C.clear(),Ze&&$t.render(Y);const Kt=C.toneMapping;C.toneMapping=rs;const jt=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),w.setupLightsView(H),zt===!0&&Ut.setGlobalState(C.clippingPlanes,H),Zo(E,Y,H),K.updateMultisampleRenderTarget(gt),K.updateRenderTargetMipmap(gt),ye.has("WEBGL_multisampled_render_to_texture")===!1){let Ot=!1;for(let Ae=0,ei=F.length;Ae<ei;Ae++){const je=F[Ae],{object:De,geometry:Ti,material:yt,group:tn}=je;if(yt.side===ji&&De.layers.test(H.layers)){const he=yt.side;yt.side=Ve,yt.needsUpdate=!0,Y0(De,Y,H,Ti,yt,tn),yt.side=he,yt.needsUpdate=!0,Ot=!0}}Ot===!0&&(K.updateMultisampleRenderTarget(gt),K.updateRenderTargetMipmap(gt))}C.setRenderTarget(mt,Et,Lt),C.setClearColor(Jt,qt),jt!==void 0&&(H.viewport=jt),C.toneMapping=Kt}function Zo(E,F,Y){const H=F.isScene===!0?F.overrideMaterial:null;for(let G=0,gt=E.length;G<gt;G++){const St=E[G],{object:mt,geometry:Et,group:Lt}=St;let Kt=St.material;Kt.allowOverride===!0&&H!==null&&(Kt=H),mt.layers.test(Y.layers)&&Y0(mt,F,Y,Et,Kt,Lt)}}function Y0(E,F,Y,H,G,gt){E.onBeforeRender(C,F,Y,H,G,gt),E.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),G.onBeforeRender(C,F,Y,H,E,gt),G.transparent===!0&&G.side===ji&&G.forceSinglePass===!1?(G.side=Ve,G.needsUpdate=!0,C.renderBufferDirect(Y,F,H,G,E,gt),G.side=ia,G.needsUpdate=!0,C.renderBufferDirect(Y,F,H,G,E,gt),G.side=ji):C.renderBufferDirect(Y,F,H,G,E,gt),E.onAfterRender(C,F,Y,H,G,gt)}function Jo(E,F,Y){F.isScene!==!0&&(F=He);const H=W.get(E),G=w.state.lights,gt=w.state.shadowsArray,St=G.state.version,mt=ht.getParameters(E,G.state,gt,F,Y,w.state.lightProbeGridArray),Et=ht.getProgramCacheKey(mt);let Lt=H.programs;H.environment=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?F.environment:null,H.fog=F.fog;const Kt=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap;H.envMap=ot.get(E.envMap||H.environment,Kt),H.envMapRotation=H.environment!==null&&E.envMap===null?F.environmentRotation:E.envMapRotation,Lt===void 0&&(E.addEventListener("dispose",Bn),Lt=new Map,H.programs=Lt);let jt=Lt.get(Et);if(jt!==void 0){if(H.currentProgram===jt&&H.lightsStateVersion===St)return $0(E,mt),jt}else mt.uniforms=ht.getUniforms(E),P!==null&&E.isNodeMaterial&&P.build(E,Y,mt),E.onBeforeCompile(mt,C),jt=ht.acquireProgram(mt,Et),Lt.set(Et,jt),H.uniforms=mt.uniforms;const Ot=H.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Ot.clippingPlanes=Ut.uniform),$0(E,mt),H.needsLights=K1(E),H.lightsStateVersion=St,H.needsLights&&(Ot.ambientLightColor.value=G.state.ambient,Ot.lightProbe.value=G.state.probe,Ot.directionalLights.value=G.state.directional,Ot.directionalLightShadows.value=G.state.directionalShadow,Ot.spotLights.value=G.state.spot,Ot.spotLightShadows.value=G.state.spotShadow,Ot.rectAreaLights.value=G.state.rectArea,Ot.ltc_1.value=G.state.rectAreaLTC1,Ot.ltc_2.value=G.state.rectAreaLTC2,Ot.pointLights.value=G.state.point,Ot.pointLightShadows.value=G.state.pointShadow,Ot.hemisphereLights.value=G.state.hemi,Ot.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Ot.spotLightMatrix.value=G.state.spotLightMatrix,Ot.spotLightMap.value=G.state.spotLightMap,Ot.pointShadowMatrix.value=G.state.pointShadowMatrix),H.lightProbeGrid=w.state.lightProbeGridArray.length>0,H.currentProgram=jt,H.uniformsList=null,jt}function q0(E){if(E.uniformsList===null){const F=E.currentProgram.getUniforms();E.uniformsList=cl.seqWithValue(F.seq,E.uniforms)}return E.uniformsList}function $0(E,F){const Y=W.get(E);Y.outputColorSpace=F.outputColorSpace,Y.batching=F.batching,Y.batchingColor=F.batchingColor,Y.instancing=F.instancing,Y.instancingColor=F.instancingColor,Y.instancingMorph=F.instancingMorph,Y.skinning=F.skinning,Y.morphTargets=F.morphTargets,Y.morphNormals=F.morphNormals,Y.morphColors=F.morphColors,Y.morphTargetsCount=F.morphTargetsCount,Y.numClippingPlanes=F.numClippingPlanes,Y.numIntersection=F.numClipIntersection,Y.vertexAlphas=F.vertexAlphas,Y.vertexTangents=F.vertexTangents,Y.toneMapping=F.toneMapping}function Y1(E,F){if(E.length===0)return null;if(E.length===1)return E[0].texture!==null?E[0]:null;M.setFromMatrixPosition(F.matrixWorld);for(let Y=0,H=E.length;Y<H;Y++){const G=E[Y];if(G.texture!==null&&G.boundingBox.containsPoint(M))return G}return null}function q1(E,F,Y,H,G){F.isScene!==!0&&(F=He),K.resetTextureUnits();const gt=F.fog,St=H.isMeshStandardMaterial||H.isMeshLambertMaterial||H.isMeshPhongMaterial?F.environment:null,mt=$===null?C.outputColorSpace:$.isXRRenderTarget===!0?$.texture.colorSpace:re.workingColorSpace,Et=H.isMeshStandardMaterial||H.isMeshLambertMaterial&&!H.envMap||H.isMeshPhongMaterial&&!H.envMap,Lt=ot.get(H.envMap||St,Et),Kt=H.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,jt=!!Y.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Ot=!!Y.morphAttributes.position,Ae=!!Y.morphAttributes.normal,ei=!!Y.morphAttributes.color;let je=rs;H.toneMapped&&($===null||$.isXRRenderTarget===!0)&&(je=C.toneMapping);const De=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,Ti=De!==void 0?De.length:0,yt=W.get(H),tn=w.state.lights;if(zt===!0&&(Bt===!0||E!==J)){const Le=E===J&&H.id===tt;Ut.setState(H,E,Le)}let he=!1;H.version===yt.__version?(yt.needsLights&&yt.lightsStateVersion!==tn.state.version||yt.outputColorSpace!==mt||G.isBatchedMesh&&yt.batching===!1||!G.isBatchedMesh&&yt.batching===!0||G.isBatchedMesh&&yt.batchingColor===!0&&G.colorTexture===null||G.isBatchedMesh&&yt.batchingColor===!1&&G.colorTexture!==null||G.isInstancedMesh&&yt.instancing===!1||!G.isInstancedMesh&&yt.instancing===!0||G.isSkinnedMesh&&yt.skinning===!1||!G.isSkinnedMesh&&yt.skinning===!0||G.isInstancedMesh&&yt.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&yt.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&yt.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&yt.instancingMorph===!1&&G.morphTexture!==null||yt.envMap!==Lt||H.fog===!0&&yt.fog!==gt||yt.numClippingPlanes!==void 0&&(yt.numClippingPlanes!==Ut.numPlanes||yt.numIntersection!==Ut.numIntersection)||yt.vertexAlphas!==Kt||yt.vertexTangents!==jt||yt.morphTargets!==Ot||yt.morphNormals!==Ae||yt.morphColors!==ei||yt.toneMapping!==je||yt.morphTargetsCount!==Ti||!!yt.lightProbeGrid!=w.state.lightProbeGridArray.length>0)&&(he=!0):(he=!0,yt.__version=H.version);let dn=yt.currentProgram;he===!0&&(dn=Jo(H,F,G),P&&H.isNodeMaterial&&P.onUpdateProgram(H,dn,yt));let Hn=!1,Cs=!1,ka=!1;const Ie=dn.getUniforms(),ii=yt.uniforms;if(_.useProgram(dn.program)&&(Hn=!0,Cs=!0,ka=!0),H.id!==tt&&(tt=H.id,Cs=!0),yt.needsLights){const Le=Y1(w.state.lightProbeGridArray,G);yt.lightProbeGrid!==Le&&(yt.lightProbeGrid=Le,Cs=!0)}if(Hn||J!==E){_.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),Ie.setValue(N,"projectionMatrix",E.projectionMatrix),Ie.setValue(N,"viewMatrix",E.matrixWorldInverse);const Ls=Ie.map.cameraPosition;Ls!==void 0&&Ls.setValue(N,xe.setFromMatrixPosition(E.matrixWorld)),D.logarithmicDepthBuffer&&Ie.setValue(N,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&Ie.setValue(N,"isOrthographic",E.isOrthographicCamera===!0),J!==E&&(J=E,Cs=!0,ka=!0)}if(yt.needsLights&&(tn.state.directionalShadowMap.length>0&&Ie.setValue(N,"directionalShadowMap",tn.state.directionalShadowMap,K),tn.state.spotShadowMap.length>0&&Ie.setValue(N,"spotShadowMap",tn.state.spotShadowMap,K),tn.state.pointShadowMap.length>0&&Ie.setValue(N,"pointShadowMap",tn.state.pointShadowMap,K)),G.isSkinnedMesh){Ie.setOptional(N,G,"bindMatrix"),Ie.setOptional(N,G,"bindMatrixInverse");const Le=G.skeleton;Le&&(Le.boneTexture===null&&Le.computeBoneTexture(),Ie.setValue(N,"boneTexture",Le.boneTexture,K))}G.isBatchedMesh&&(Ie.setOptional(N,G,"batchingTexture"),Ie.setValue(N,"batchingTexture",G._matricesTexture,K),Ie.setOptional(N,G,"batchingIdTexture"),Ie.setValue(N,"batchingIdTexture",G._indirectTexture,K),Ie.setOptional(N,G,"batchingColorTexture"),G._colorsTexture!==null&&Ie.setValue(N,"batchingColorTexture",G._colorsTexture,K));const Ps=Y.morphAttributes;if((Ps.position!==void 0||Ps.normal!==void 0||Ps.color!==void 0)&&O.update(G,Y,dn),(Cs||yt.receiveShadow!==G.receiveShadow)&&(yt.receiveShadow=G.receiveShadow,Ie.setValue(N,"receiveShadow",G.receiveShadow)),(H.isMeshStandardMaterial||H.isMeshLambertMaterial||H.isMeshPhongMaterial)&&H.envMap===null&&F.environment!==null&&(ii.envMapIntensity.value=F.environmentIntensity),ii.dfgLUT!==void 0&&(ii.dfgLUT.value=fb()),Cs){if(Ie.setValue(N,"toneMappingExposure",C.toneMappingExposure),yt.needsLights&&$1(ii,ka),gt&&H.fog===!0&&Pt.refreshFogUniforms(ii,gt),Pt.refreshMaterialUniforms(ii,H,nt,at,w.state.transmissionRenderTarget[E.id]),yt.needsLights&&yt.lightProbeGrid){const Le=yt.lightProbeGrid;ii.probesSH.value=Le.texture,ii.probesMin.value.copy(Le.boundingBox.min),ii.probesMax.value.copy(Le.boundingBox.max),ii.probesResolution.value.copy(Le.resolution)}cl.upload(N,q0(yt),ii,K)}if(H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(cl.upload(N,q0(yt),ii,K),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&Ie.setValue(N,"center",G.center),Ie.setValue(N,"modelViewMatrix",G.modelViewMatrix),Ie.setValue(N,"normalMatrix",G.normalMatrix),Ie.setValue(N,"modelMatrix",G.matrixWorld),H.uniformsGroups!==void 0){const Le=H.uniformsGroups;for(let Ls=0,za=Le.length;Ls<za;Ls++){const K0=Le[Ls];et.update(K0,dn),et.bind(K0,dn)}}return dn}function $1(E,F){E.ambientLightColor.needsUpdate=F,E.lightProbe.needsUpdate=F,E.directionalLights.needsUpdate=F,E.directionalLightShadows.needsUpdate=F,E.pointLights.needsUpdate=F,E.pointLightShadows.needsUpdate=F,E.spotLights.needsUpdate=F,E.spotLightShadows.needsUpdate=F,E.rectAreaLights.needsUpdate=F,E.hemisphereLights.needsUpdate=F}function K1(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return B},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return $},this.setRenderTargetTextures=function(E,F,Y){const H=W.get(E);H.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,H.__autoAllocateDepthBuffer===!1&&(H.__useRenderToTexture=!1),W.get(E.texture).__webglTexture=F,W.get(E.depthTexture).__webglTexture=H.__autoAllocateDepthBuffer?void 0:Y,H.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,F){const Y=W.get(E);Y.__webglFramebuffer=F,Y.__useDefaultFramebuffer=F===void 0},this.setRenderTarget=function(E,F=0,Y=0){$=E,B=F,k=Y;let H=null,G=!1,gt=!1;if(E){const mt=W.get(E);if(mt.__useDefaultFramebuffer!==void 0){_.bindFramebuffer(N.FRAMEBUFFER,mt.__webglFramebuffer),it.copy(E.viewport),rt.copy(E.scissor),Vt=E.scissorTest,_.viewport(it),_.scissor(rt),_.setScissorTest(Vt),tt=-1;return}else if(mt.__webglFramebuffer===void 0)K.setupRenderTarget(E);else if(mt.__hasExternalTextures)K.rebindTextures(E,W.get(E.texture).__webglTexture,W.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const Kt=E.depthTexture;if(mt.__boundDepthTexture!==Kt){if(Kt!==null&&W.has(Kt)&&(E.width!==Kt.image.width||E.height!==Kt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(E)}}const Et=E.texture;(Et.isData3DTexture||Et.isDataArrayTexture||Et.isCompressedArrayTexture)&&(gt=!0);const Lt=W.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Lt[F])?H=Lt[F][Y]:H=Lt[F],G=!0):E.samples>0&&K.useMultisampledRTT(E)===!1?H=W.get(E).__webglMultisampledFramebuffer:Array.isArray(Lt)?H=Lt[Y]:H=Lt,it.copy(E.viewport),rt.copy(E.scissor),Vt=E.scissorTest}else it.copy(Nt).multiplyScalar(nt).floor(),rt.copy(Ct).multiplyScalar(nt).floor(),Vt=_t;if(Y!==0&&(H=V),_.bindFramebuffer(N.FRAMEBUFFER,H)&&_.drawBuffers(E,H),_.viewport(it),_.scissor(rt),_.setScissorTest(Vt),G){const mt=W.get(E.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+F,mt.__webglTexture,Y)}else if(gt){const mt=F;for(let Et=0;Et<E.textures.length;Et++){const Lt=W.get(E.textures[Et]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+Et,Lt.__webglTexture,Y,mt)}}else if(E!==null&&Y!==0){const mt=W.get(E.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,mt.__webglTexture,Y)}tt=-1},this.readRenderTargetPixels=function(E,F,Y,H,G,gt,St,mt=0){if(!(E&&E.isWebGLRenderTarget)){Gt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Et=W.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&St!==void 0&&(Et=Et[St]),Et){_.bindFramebuffer(N.FRAMEBUFFER,Et);try{const Lt=E.textures[mt],Kt=Lt.format,jt=Lt.type;if(E.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+mt),!D.textureFormatReadable(Kt)){Gt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!D.textureTypeReadable(jt)){Gt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=E.width-H&&Y>=0&&Y<=E.height-G&&N.readPixels(F,Y,H,G,dt.convert(Kt),dt.convert(jt),gt)}finally{const Lt=$!==null?W.get($).__webglFramebuffer:null;_.bindFramebuffer(N.FRAMEBUFFER,Lt)}}},this.readRenderTargetPixelsAsync=async function(E,F,Y,H,G,gt,St,mt=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Et=W.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&St!==void 0&&(Et=Et[St]),Et)if(F>=0&&F<=E.width-H&&Y>=0&&Y<=E.height-G){_.bindFramebuffer(N.FRAMEBUFFER,Et);const Lt=E.textures[mt],Kt=Lt.format,jt=Lt.type;if(E.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+mt),!D.textureFormatReadable(Kt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!D.textureTypeReadable(jt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ot=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Ot),N.bufferData(N.PIXEL_PACK_BUFFER,gt.byteLength,N.STREAM_READ),N.readPixels(F,Y,H,G,dt.convert(Kt),dt.convert(jt),0);const Ae=$!==null?W.get($).__webglFramebuffer:null;_.bindFramebuffer(N.FRAMEBUFFER,Ae);const ei=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await G2(N,ei,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Ot),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,gt),N.deleteBuffer(Ot),N.deleteSync(ei),gt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,F=null,Y=0){const H=Math.pow(2,-Y),G=Math.floor(E.image.width*H),gt=Math.floor(E.image.height*H),St=F!==null?F.x:0,mt=F!==null?F.y:0;K.setTexture2D(E,0),N.copyTexSubImage2D(N.TEXTURE_2D,Y,0,0,St,mt,G,gt),_.unbindTexture()},this.copyTextureToTexture=function(E,F,Y=null,H=null,G=0,gt=0){let St,mt,Et,Lt,Kt,jt,Ot,Ae,ei;const je=E.isCompressedTexture?E.mipmaps[gt]:E.image;if(Y!==null)St=Y.max.x-Y.min.x,mt=Y.max.y-Y.min.y,Et=Y.isBox3?Y.max.z-Y.min.z:1,Lt=Y.min.x,Kt=Y.min.y,jt=Y.isBox3?Y.min.z:0;else{const ii=Math.pow(2,-G);St=Math.floor(je.width*ii),mt=Math.floor(je.height*ii),E.isDataArrayTexture?Et=je.depth:E.isData3DTexture?Et=Math.floor(je.depth*ii):Et=1,Lt=0,Kt=0,jt=0}H!==null?(Ot=H.x,Ae=H.y,ei=H.z):(Ot=0,Ae=0,ei=0);const De=dt.convert(F.format),Ti=dt.convert(F.type);let yt;F.isData3DTexture?(K.setTexture3D(F,0),yt=N.TEXTURE_3D):F.isDataArrayTexture||F.isCompressedArrayTexture?(K.setTexture2DArray(F,0),yt=N.TEXTURE_2D_ARRAY):(K.setTexture2D(F,0),yt=N.TEXTURE_2D),_.activeTexture(N.TEXTURE0),_.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,F.flipY),_.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),_.pixelStorei(N.UNPACK_ALIGNMENT,F.unpackAlignment);const tn=_.getParameter(N.UNPACK_ROW_LENGTH),he=_.getParameter(N.UNPACK_IMAGE_HEIGHT),dn=_.getParameter(N.UNPACK_SKIP_PIXELS),Hn=_.getParameter(N.UNPACK_SKIP_ROWS),Cs=_.getParameter(N.UNPACK_SKIP_IMAGES);_.pixelStorei(N.UNPACK_ROW_LENGTH,je.width),_.pixelStorei(N.UNPACK_IMAGE_HEIGHT,je.height),_.pixelStorei(N.UNPACK_SKIP_PIXELS,Lt),_.pixelStorei(N.UNPACK_SKIP_ROWS,Kt),_.pixelStorei(N.UNPACK_SKIP_IMAGES,jt);const ka=E.isDataArrayTexture||E.isData3DTexture,Ie=F.isDataArrayTexture||F.isData3DTexture;if(E.isDepthTexture){const ii=W.get(E),Ps=W.get(F),Le=W.get(ii.__renderTarget),Ls=W.get(Ps.__renderTarget);_.bindFramebuffer(N.READ_FRAMEBUFFER,Le.__webglFramebuffer),_.bindFramebuffer(N.DRAW_FRAMEBUFFER,Ls.__webglFramebuffer);for(let za=0;za<Et;za++)ka&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,W.get(E).__webglTexture,G,jt+za),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,W.get(F).__webglTexture,gt,ei+za)),N.blitFramebuffer(Lt,Kt,St,mt,Ot,Ae,St,mt,N.DEPTH_BUFFER_BIT,N.NEAREST);_.bindFramebuffer(N.READ_FRAMEBUFFER,null),_.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(G!==0||E.isRenderTargetTexture||W.has(E)){const ii=W.get(E),Ps=W.get(F);_.bindFramebuffer(N.READ_FRAMEBUFFER,X),_.bindFramebuffer(N.DRAW_FRAMEBUFFER,L);for(let Le=0;Le<Et;Le++)ka?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,ii.__webglTexture,G,jt+Le):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,ii.__webglTexture,G),Ie?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Ps.__webglTexture,gt,ei+Le):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Ps.__webglTexture,gt),G!==0?N.blitFramebuffer(Lt,Kt,St,mt,Ot,Ae,St,mt,N.COLOR_BUFFER_BIT,N.NEAREST):Ie?N.copyTexSubImage3D(yt,gt,Ot,Ae,ei+Le,Lt,Kt,St,mt):N.copyTexSubImage2D(yt,gt,Ot,Ae,Lt,Kt,St,mt);_.bindFramebuffer(N.READ_FRAMEBUFFER,null),_.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else Ie?E.isDataTexture||E.isData3DTexture?N.texSubImage3D(yt,gt,Ot,Ae,ei,St,mt,Et,De,Ti,je.data):F.isCompressedArrayTexture?N.compressedTexSubImage3D(yt,gt,Ot,Ae,ei,St,mt,Et,De,je.data):N.texSubImage3D(yt,gt,Ot,Ae,ei,St,mt,Et,De,Ti,je):E.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,gt,Ot,Ae,St,mt,De,Ti,je.data):E.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,gt,Ot,Ae,je.width,je.height,De,je.data):N.texSubImage2D(N.TEXTURE_2D,gt,Ot,Ae,St,mt,De,Ti,je);_.pixelStorei(N.UNPACK_ROW_LENGTH,tn),_.pixelStorei(N.UNPACK_IMAGE_HEIGHT,he),_.pixelStorei(N.UNPACK_SKIP_PIXELS,dn),_.pixelStorei(N.UNPACK_SKIP_ROWS,Hn),_.pixelStorei(N.UNPACK_SKIP_IMAGES,Cs),gt===0&&F.generateMipmaps&&N.generateMipmap(yt),_.unbindTexture()},this.initRenderTarget=function(E){W.get(E).__webglFramebuffer===void 0&&K.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?K.setTextureCube(E,0):E.isData3DTexture?K.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?K.setTexture2DArray(E,0):K.setTexture2D(E,0),_.unbindTexture()},this.resetState=function(){B=0,k=0,$=null,_.reset(),vt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ns}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=re._getDrawingBufferColorSpace(t),e.unpackColorSpace=re._getUnpackColorSpace()}}const mb=`
5268
+ }`;class ob{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const i=new Vg(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,i=new le({vertexShader:ab,fragmentShader:rb,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Dt(new Xi(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class cb extends aa{constructor(t,e){super();const i=this;let n=null,s=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,p=null;const v=typeof XRWebGLBinding<"u",m=new ob,g={},S=e.getContextAttributes();let y=null,M=null;const b=[],w=[],T=new xt;let x=null;const A=new Zi;A.viewport=new ne;const C=new Zi;C.viewport=new ne;const I=[A,C],P=new ax;let V=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let at=b[q];return at===void 0&&(at=new fh,b[q]=at),at.getTargetRaySpace()},this.getControllerGrip=function(q){let at=b[q];return at===void 0&&(at=new fh,b[q]=at),at.getGripSpace()},this.getHand=function(q){let at=b[q];return at===void 0&&(at=new fh,b[q]=at),at.getHandSpace()};function L(q){const at=w.indexOf(q.inputSource);if(at===-1)return;const nt=b[at];nt!==void 0&&(nt.update(q.inputSource,q.frame,l||a),nt.dispatchEvent({type:q.type,data:q.inputSource}))}function B(){n.removeEventListener("select",L),n.removeEventListener("selectstart",L),n.removeEventListener("selectend",L),n.removeEventListener("squeeze",L),n.removeEventListener("squeezestart",L),n.removeEventListener("squeezeend",L),n.removeEventListener("end",B),n.removeEventListener("inputsourceschange",k);for(let q=0;q<b.length;q++){const at=w[q];at!==null&&(w[q]=null,b[q].disconnect(at))}V=null,X=null,m.reset();for(const q in g)delete g[q];t.setRenderTarget(y),f=null,d=null,u=null,n=null,M=null,qt.stop(),i.isPresenting=!1,t.setPixelRatio(x),t.setSize(T.width,T.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(q){s=q,i.isPresenting===!0&&Rt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(q){o=q,i.isPresenting===!0&&Rt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(q){l=q},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&v&&(u=new XRWebGLBinding(n,e)),u},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(q){if(n=q,n!==null){if(y=t.getRenderTarget(),n.addEventListener("select",L),n.addEventListener("selectstart",L),n.addEventListener("selectend",L),n.addEventListener("squeeze",L),n.addEventListener("squeezestart",L),n.addEventListener("squeezeend",L),n.addEventListener("end",B),n.addEventListener("inputsourceschange",k),S.xrCompatible!==!0&&await e.makeXRCompatible(),x=t.getPixelRatio(),t.getSize(T),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let nt=null,z=null,Tt=null;S.depth&&(Tt=S.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,nt=S.stencil?Ea:Es,z=S.stencil?Bo:Sn);const Nt={colorFormat:e.RGBA8,depthFormat:Tt,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Nt),n.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),M=new ri(d.textureWidth,d.textureHeight,{format:Ei,type:un,depthTexture:new na(d.textureWidth,d.textureHeight,z,void 0,void 0,void 0,void 0,void 0,void 0,nt),stencilBuffer:S.stencil,colorSpace:t.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const nt={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,e,nt),n.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),M=new ri(f.framebufferWidth,f.framebufferHeight,{format:Ei,type:un,colorSpace:t.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await n.requestReferenceSpace(o),qt.setContext(n),qt.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function k(q){for(let at=0;at<q.removed.length;at++){const nt=q.removed[at],z=w.indexOf(nt);z>=0&&(w[z]=null,b[z].disconnect(nt))}for(let at=0;at<q.added.length;at++){const nt=q.added[at];let z=w.indexOf(nt);if(z===-1){for(let Nt=0;Nt<b.length;Nt++)if(Nt>=w.length){w.push(nt),z=Nt;break}else if(w[Nt]===null){w[Nt]=nt,z=Nt;break}if(z===-1)break}const Tt=b[z];Tt&&Tt.connect(nt)}}const $=new R,tt=new R;function J(q,at,nt){$.setFromMatrixPosition(at.matrixWorld),tt.setFromMatrixPosition(nt.matrixWorld);const z=$.distanceTo(tt),Tt=at.projectionMatrix.elements,Nt=nt.projectionMatrix.elements,Ct=Tt[14]/(Tt[10]-1),_t=Tt[14]/(Tt[10]+1),kt=(Tt[9]+1)/Tt[5],zt=(Tt[9]-1)/Tt[5],Bt=(Tt[8]-1)/Tt[0],Me=(Nt[8]+1)/Nt[0],xe=Ct*Bt,Ke=Ct*Me,He=z/(-Bt+Me),Ze=He*-Bt;if(at.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(Ze),q.translateZ(He),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),Tt[10]===-1)q.projectionMatrix.copy(at.projectionMatrix),q.projectionMatrixInverse.copy(at.projectionMatrixInverse);else{const ci=Ct+He,N=_t+He,Yi=xe-Ze,ye=Ke+(z-Ze),D=kt*_t/N*ci,_=zt*_t/N*ci;q.projectionMatrix.makePerspective(Yi,ye,D,_,ci,N),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}function it(q,at){at===null?q.matrixWorld.copy(q.matrix):q.matrixWorld.multiplyMatrices(at.matrixWorld,q.matrix),q.matrixWorldInverse.copy(q.matrixWorld).invert()}this.updateCamera=function(q){if(n===null)return;let at=q.near,nt=q.far;m.texture!==null&&(m.depthNear>0&&(at=m.depthNear),m.depthFar>0&&(nt=m.depthFar)),P.near=C.near=A.near=at,P.far=C.far=A.far=nt,(V!==P.near||X!==P.far)&&(n.updateRenderState({depthNear:P.near,depthFar:P.far}),V=P.near,X=P.far),P.layers.mask=q.layers.mask|6,A.layers.mask=P.layers.mask&-5,C.layers.mask=P.layers.mask&-3;const z=q.parent,Tt=P.cameras;it(P,z);for(let Nt=0;Nt<Tt.length;Nt++)it(Tt[Nt],z);Tt.length===2?J(P,A,C):P.projectionMatrix.copy(A.projectionMatrix),rt(q,P,z)};function rt(q,at,nt){nt===null?q.matrix.copy(at.matrixWorld):(q.matrix.copy(nt.matrixWorld),q.matrix.invert(),q.matrix.multiply(at.matrixWorld)),q.matrix.decompose(q.position,q.quaternion,q.scale),q.updateMatrixWorld(!0),q.projectionMatrix.copy(at.projectionMatrix),q.projectionMatrixInverse.copy(at.projectionMatrixInverse),q.isPerspectiveCamera&&(q.fov=Or*2*Math.atan(1/q.projectionMatrix.elements[5]),q.zoom=1)}this.getCamera=function(){return P},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(q){c=q,d!==null&&(d.fixedFoveation=q),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=q)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(P)},this.getCameraTexture=function(q){return g[q]};let Vt=null;function jt(q,at){if(h=at.getViewerPose(l||a),p=at,h!==null){const nt=h.views;f!==null&&(t.setRenderTargetFramebuffer(M,f.framebuffer),t.setRenderTarget(M));let z=!1;nt.length!==P.cameras.length&&(P.cameras.length=0,z=!0);for(let _t=0;_t<nt.length;_t++){const kt=nt[_t];let zt=null;if(f!==null)zt=f.getViewport(kt);else{const Me=u.getViewSubImage(d,kt);zt=Me.viewport,_t===0&&(t.setRenderTargetTextures(M,Me.colorTexture,Me.depthStencilTexture),t.setRenderTarget(M))}let Bt=I[_t];Bt===void 0&&(Bt=new Zi,Bt.layers.enable(_t),Bt.viewport=new ne,I[_t]=Bt),Bt.matrix.fromArray(kt.transform.matrix),Bt.matrix.decompose(Bt.position,Bt.quaternion,Bt.scale),Bt.projectionMatrix.fromArray(kt.projectionMatrix),Bt.projectionMatrixInverse.copy(Bt.projectionMatrix).invert(),Bt.viewport.set(zt.x,zt.y,zt.width,zt.height),_t===0&&(P.matrix.copy(Bt.matrix),P.matrix.decompose(P.position,P.quaternion,P.scale)),z===!0&&P.cameras.push(Bt)}const Tt=n.enabledFeatures;if(Tt&&Tt.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&v){u=i.getBinding();const _t=u.getDepthInformation(nt[0]);_t&&_t.isValid&&_t.texture&&m.init(_t,n.renderState)}if(Tt&&Tt.includes("camera-access")&&v){t.state.unbindTexture(),u=i.getBinding();for(let _t=0;_t<nt.length;_t++){const kt=nt[_t].camera;if(kt){let zt=g[kt];zt||(zt=new Vg,g[kt]=zt);const Bt=u.getCameraImage(kt);zt.sourceTexture=Bt}}}}for(let nt=0;nt<b.length;nt++){const z=w[nt],Tt=b[nt];z!==null&&Tt!==void 0&&Tt.update(z,at,l||a)}Vt&&Vt(q,at),at.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:at}),p=null}const qt=new jg;qt.setAnimationLoop(jt),this.setAnimationLoop=function(q){Vt=q},this.dispose=function(){}}}const lb=new Jt,s1=new Yt;s1.set(-1,0,0,0,1,0,0,0,1);function hb(r,t){function e(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function i(m,g){g.color.getRGB(m.fogColor.value,Wg(r)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,S,y,M){g.isNodeMaterial?g.uniformsNeedUpdate=!1:g.isMeshBasicMaterial?s(m,g):g.isMeshLambertMaterial?(s(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(s(m,g),u(m,g)):g.isMeshPhongMaterial?(s(m,g),h(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(s(m,g),d(m,g),g.isMeshPhysicalMaterial&&f(m,g,M)):g.isMeshMatcapMaterial?(s(m,g),p(m,g)):g.isMeshDepthMaterial?s(m,g):g.isMeshDistanceMaterial?(s(m,g),v(m,g)):g.isMeshNormalMaterial?s(m,g):g.isLineBasicMaterial?(a(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?c(m,g,S,y):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map,e(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,e(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,e(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===Ve&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,e(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===Ve&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,e(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,e(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,e(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const S=t.get(g),y=S.envMap,M=S.envMapRotation;y&&(m.envMap.value=y,m.envMapRotation.value.setFromMatrix4(lb.makeRotationFromEuler(M)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(s1),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,e(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,e(g.aoMap,m.aoMapTransform))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,e(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function c(m,g,S,y){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*S,m.scale.value=y*.5,g.map&&(m.map.value=g.map,e(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,e(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,e(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,e(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,e(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,e(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,S){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,e(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,e(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,e(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,e(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,e(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===Ve&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,e(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,e(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=S.texture,m.transmissionSamplerSize.value.set(S.width,S.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,e(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,e(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,e(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,e(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,e(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function v(m,g){const S=t.get(g).light;m.referencePosition.value.setFromMatrixPosition(S.matrixWorld),m.nearDistance.value=S.shadow.camera.near,m.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function ub(r,t,e,i){let n={},s={},a=[];const o=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,b){const w=b.program;i.uniformBlockBinding(M,w)}function l(M,b){let w=n[M.id];w===void 0&&(m(M),w=h(M),n[M.id]=w,M.addEventListener("dispose",S));const T=b.program;i.updateUBOMapping(M,T);const x=t.render.frame;s[M.id]!==x&&(d(M),s[M.id]=x)}function h(M){const b=u();M.__bindingPointIndex=b;const w=r.createBuffer(),T=M.__size,x=M.usage;return r.bindBuffer(r.UNIFORM_BUFFER,w),r.bufferData(r.UNIFORM_BUFFER,T,x),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,b,w),w}function u(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return Gt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const b=n[M.id],w=M.uniforms,T=M.__cache;r.bindBuffer(r.UNIFORM_BUFFER,b);for(let x=0,A=w.length;x<A;x++){const C=w[x];if(Array.isArray(C))for(let I=0,P=C.length;I<P;I++)f(C[I],x,I,T);else f(C,x,0,T)}r.bindBuffer(r.UNIFORM_BUFFER,null)}function f(M,b,w,T){if(v(M,b,w,T)===!0){const x=M.__offset,A=M.value;if(Array.isArray(A)){let C=0;for(let I=0;I<A.length;I++){const P=A[I],V=g(P);p(P,M.__data,C),typeof P!="number"&&typeof P!="boolean"&&!P.isMatrix3&&!ArrayBuffer.isView(P)&&(C+=V.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(A,M.__data,0);r.bufferSubData(r.UNIFORM_BUFFER,x,M.__data)}}function p(M,b,w){typeof M=="number"||typeof M=="boolean"?b[0]=M:M.isMatrix3?(b[0]=M.elements[0],b[1]=M.elements[1],b[2]=M.elements[2],b[3]=0,b[4]=M.elements[3],b[5]=M.elements[4],b[6]=M.elements[5],b[7]=0,b[8]=M.elements[6],b[9]=M.elements[7],b[10]=M.elements[8],b[11]=0):ArrayBuffer.isView(M)?b.set(new M.constructor(M.buffer,M.byteOffset,b.length)):M.toArray(b,w)}function v(M,b,w,T){const x=M.value,A=b+"_"+w;if(T[A]===void 0)return typeof x=="number"||typeof x=="boolean"?T[A]=x:ArrayBuffer.isView(x)?T[A]=x.slice():T[A]=x.clone(),!0;{const C=T[A];if(typeof x=="number"||typeof x=="boolean"){if(C!==x)return T[A]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(C.equals(x)===!1)return C.copy(x),!0}}return!1}function m(M){const b=M.uniforms;let w=0;const T=16;for(let A=0,C=b.length;A<C;A++){const I=Array.isArray(b[A])?b[A]:[b[A]];for(let P=0,V=I.length;P<V;P++){const X=I[P],L=Array.isArray(X.value)?X.value:[X.value];for(let B=0,k=L.length;B<k;B++){const $=L[B],tt=g($),J=w%T,it=J%tt.boundary,rt=J+it;w+=it,rt!==0&&T-rt<tt.storage&&(w+=T-rt),X.__data=new Float32Array(tt.storage/Float32Array.BYTES_PER_ELEMENT),X.__offset=w,w+=tt.storage}}}const x=w%T;return x>0&&(w+=T-x),M.__size=w,M.__cache={},this}function g(M){const b={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(b.boundary=4,b.storage=4):M.isVector2?(b.boundary=8,b.storage=8):M.isVector3||M.isColor?(b.boundary=16,b.storage=12):M.isVector4?(b.boundary=16,b.storage=16):M.isMatrix3?(b.boundary=48,b.storage=48):M.isMatrix4?(b.boundary=64,b.storage=64):M.isTexture?Rt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(b.boundary=16,b.storage=M.byteLength):Rt("WebGLRenderer: Unsupported uniform value type.",M),b}function S(M){const b=M.target;b.removeEventListener("dispose",S);const w=a.indexOf(b.__bindingPointIndex);a.splice(w,1),r.deleteBuffer(n[b.id]),delete n[b.id],delete s[b.id]}function y(){for(const M in n)r.deleteBuffer(n[M]);a=[],n={},s={}}return{bind:c,update:l,dispose:y}}const db=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Wn=null;function fb(){return Wn===null&&(Wn=new ra(db,16,16,Na,qe),Wn.name="DFG_LUT",Wn.minFilter=oe,Wn.magFilter=oe,Wn.wrapS=wi,Wn.wrapT=wi,Wn.generateMipmaps=!1,Wn.needsUpdate=!0),Wn}class pb{constructor(t={}){const{canvas:e=H2(),context:i=null,depth:n=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=un}=t;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=a;const v=f,m=new Set([o0,r0,a0]),g=new Set([un,Sn,zo,Bo,n0,s0]),S=new Uint32Array(4),y=new Int32Array(4),M=new R;let b=null,w=null;const T=[],x=[];let A=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=rs,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let I=!1,P=null,V=null,X=null,L=null;this._outputColorSpace=Gi;let B=0,k=0,$=null,tt=-1,J=null;const it=new ne,rt=new ne;let Vt=null;const jt=new st(0);let qt=0,q=e.width,at=e.height,nt=1,z=null,Tt=null;const Nt=new ne(0,0,q,at),Ct=new ne(0,0,q,at);let _t=!1;const kt=new g0;let zt=!1,Bt=!1;const Me=new Jt,xe=new R,Ke=new ne,He={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ze=!1;function ci(){return $===null?nt:1}let N=i;function Yi(E,F){return e.getContext(E,F)}try{const E={alpha:!0,depth:n,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${t0}`),e.addEventListener("webglcontextlost",Je,!1),e.addEventListener("webglcontextrestored",Pe,!1),e.addEventListener("webglcontextcreationerror",zn,!1),N===null){const F="webgl2";if(N=Yi(F,E),N===null)throw Yi(F)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(E){throw Gt("WebGLRenderer: "+E.message),E}let ye,D,_,U,W,K,ot,lt,Z,Q,ht,Pt,ft,ut,Ut,Ht,$t,O,ct,j,dt,vt,et;function It(){ye=new f_(N),ye.init(),dt=new sb(N,ye),D=new a_(N,ye,t,dt),_=new ib(N,ye),D.reversedDepthBuffer&&d&&_.buffers.depth.setReversed(!0),V=N.createFramebuffer(),X=N.createFramebuffer(),L=N.createFramebuffer(),U=new g_(N),W=new GS,K=new nb(N,ye,_,W,D,dt,U),ot=new d_(C),lt=new yx(N),vt=new n_(N,lt),Z=new p_(N,lt,U,vt),Q=new M_(N,Z,lt,vt,U),O=new v_(N,D,K),Ut=new r_(W),ht=new HS(C,ot,ye,D,vt,Ut),Pt=new hb(C,W),ft=new WS,ut=new ZS(ye),$t=new i_(C,ot,_,Q,p,c),Ht=new eb(C,Q,D),et=new ub(N,U,D,_),ct=new s_(N,ye,U),j=new m_(N,ye,U),U.programs=ht.programs,C.capabilities=D,C.extensions=ye,C.properties=W,C.renderLists=ft,C.shadowMap=Ht,C.state=_,C.info=U}It(),v!==un&&(A=new y_(v,e.width,e.height,o,n,s));const bt=new cb(C,N);this.xr=bt,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){const E=ye.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=ye.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return nt},this.setPixelRatio=function(E){E!==void 0&&(nt=E,this.setSize(q,at,!1))},this.getSize=function(E){return E.set(q,at)},this.setSize=function(E,F,Y=!0){if(bt.isPresenting){Rt("WebGLRenderer: Can't change size while VR device is presenting.");return}q=E,at=F,e.width=Math.floor(E*nt),e.height=Math.floor(F*nt),Y===!0&&(e.style.width=E+"px",e.style.height=F+"px"),A!==null&&A.setSize(e.width,e.height),this.setViewport(0,0,E,F)},this.getDrawingBufferSize=function(E){return E.set(q*nt,at*nt).floor()},this.setDrawingBufferSize=function(E,F,Y){q=E,at=F,nt=Y,e.width=Math.floor(E*Y),e.height=Math.floor(F*Y),this.setViewport(0,0,E,F)},this.setEffects=function(E){if(v===un){Gt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let F=0;F<E.length;F++)if(E[F].isOutputPass===!0){Rt("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(E||[])},this.getCurrentViewport=function(E){return E.copy(it)},this.getViewport=function(E){return E.copy(Nt)},this.setViewport=function(E,F,Y,H){E.isVector4?Nt.set(E.x,E.y,E.z,E.w):Nt.set(E,F,Y,H),_.viewport(it.copy(Nt).multiplyScalar(nt).round())},this.getScissor=function(E){return E.copy(Ct)},this.setScissor=function(E,F,Y,H){E.isVector4?Ct.set(E.x,E.y,E.z,E.w):Ct.set(E,F,Y,H),_.scissor(rt.copy(Ct).multiplyScalar(nt).round())},this.getScissorTest=function(){return _t},this.setScissorTest=function(E){_.setScissorTest(_t=E)},this.setOpaqueSort=function(E){z=E},this.setTransparentSort=function(E){Tt=E},this.getClearColor=function(E){return E.copy($t.getClearColor())},this.setClearColor=function(){$t.setClearColor(...arguments)},this.getClearAlpha=function(){return $t.getClearAlpha()},this.setClearAlpha=function(){$t.setClearAlpha(...arguments)},this.clear=function(E=!0,F=!0,Y=!0){let H=0;if(E){let G=!1;if($!==null){const gt=$.texture.format;G=m.has(gt)}if(G){const gt=$.texture.type,St=g.has(gt),mt=$t.getClearColor(),Et=$t.getClearAlpha(),Lt=mt.r,Kt=mt.g,Qt=mt.b;St?(S[0]=Lt,S[1]=Kt,S[2]=Qt,S[3]=Et,N.clearBufferuiv(N.COLOR,0,S)):(y[0]=Lt,y[1]=Kt,y[2]=Qt,y[3]=Et,N.clearBufferiv(N.COLOR,0,y))}else H|=N.COLOR_BUFFER_BIT}F&&(H|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Y&&(H|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H!==0&&N.clear(H)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(E){E.setRenderer(this),P=E},this.dispose=function(){e.removeEventListener("webglcontextlost",Je,!1),e.removeEventListener("webglcontextrestored",Pe,!1),e.removeEventListener("webglcontextcreationerror",zn,!1),$t.dispose(),ft.dispose(),ut.dispose(),W.dispose(),ot.dispose(),Q.dispose(),vt.dispose(),et.dispose(),ht.dispose(),bt.dispose(),bt.removeEventListener("sessionstart",G0),bt.removeEventListener("sessionend",V0),oa.stop()};function Je(E){E.preventDefault(),Sl("WebGLRenderer: Context Lost."),I=!0}function Pe(){Sl("WebGLRenderer: Context Restored."),I=!1;const E=U.autoReset,F=Ht.enabled,Y=Ht.autoUpdate,H=Ht.needsUpdate,G=Ht.type;It(),U.autoReset=E,Ht.enabled=F,Ht.autoUpdate=Y,Ht.needsUpdate=H,Ht.type=G}function zn(E){Gt("WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Bn(E){const F=E.target;F.removeEventListener("dispose",Bn),V1(F)}function V1(E){W1(E),W.remove(E)}function W1(E){const F=W.get(E).programs;F!==void 0&&(F.forEach(function(Y){ht.releaseProgram(Y)}),E.isShaderMaterial&&ht.releaseShaderCache(E))}this.renderBufferDirect=function(E,F,Y,H,G,gt){F===null&&(F=He);const St=G.isMesh&&G.matrixWorld.determinantAffine()<0,mt=q1(E,F,Y,H,G);_.setMaterial(H,St);let Et=Y.index,Lt=1;if(H.wireframe===!0){if(Et=Z.getWireframeAttribute(Y),Et===void 0)return;Lt=2}const Kt=Y.drawRange,Qt=Y.attributes.position;let Ot=Kt.start*Lt,Ae=(Kt.start+Kt.count)*Lt;gt!==null&&(Ot=Math.max(Ot,gt.start*Lt),Ae=Math.min(Ae,(gt.start+gt.count)*Lt)),Et!==null?(Ot=Math.max(Ot,0),Ae=Math.min(Ae,Et.count)):Qt!=null&&(Ot=Math.max(Ot,0),Ae=Math.min(Ae,Qt.count));const ei=Ae-Ot;if(ei<0||ei===1/0)return;vt.setup(G,H,mt,Y,Et);let je,De=ct;if(Et!==null&&(je=lt.get(Et),De=j,De.setIndex(je)),G.isMesh)H.wireframe===!0?(_.setLineWidth(H.wireframeLinewidth*ci()),De.setMode(N.LINES)):De.setMode(N.TRIANGLES);else if(G.isLine){let Ti=H.linewidth;Ti===void 0&&(Ti=1),_.setLineWidth(Ti*ci()),G.isLineSegments?De.setMode(N.LINES):G.isLineLoop?De.setMode(N.LINE_LOOP):De.setMode(N.LINE_STRIP)}else G.isPoints?De.setMode(N.POINTS):G.isSprite&&De.setMode(N.TRIANGLES);if(G.isBatchedMesh)if(ye.get("WEBGL_multi_draw"))De.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{const Ti=G._multiDrawStarts,yt=G._multiDrawCounts,tn=G._multiDrawCount,he=Et?lt.get(Et).bytesPerElement:1,dn=W.get(H).currentProgram.getUniforms();for(let Hn=0;Hn<tn;Hn++)dn.setValue(N,"_gl_DrawID",Hn),De.render(Ti[Hn]/he,yt[Hn])}else if(G.isInstancedMesh)De.renderInstances(Ot,ei,G.count);else if(Y.isInstancedBufferGeometry){const Ti=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,yt=Math.min(Y.instanceCount,Ti);De.renderInstances(Ot,ei,yt)}else De.render(Ot,ei)};function H0(E,F,Y){E.transparent===!0&&E.side===ji&&E.forceSinglePass===!1?(E.side=Ve,E.needsUpdate=!0,Jo(E,F,Y),E.side=ia,E.needsUpdate=!0,Jo(E,F,Y),E.side=ji):Jo(E,F,Y)}this.compile=function(E,F,Y=null){Y===null&&(Y=E),w=ut.get(Y),w.init(F),x.push(w),Y.traverseVisible(function(G){G.isLight&&G.layers.test(F.layers)&&(w.pushLight(G),G.castShadow&&w.pushShadow(G))}),E!==Y&&E.traverseVisible(function(G){G.isLight&&G.layers.test(F.layers)&&(w.pushLight(G),G.castShadow&&w.pushShadow(G))}),w.setupLights();const H=new Set;return E.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;const gt=G.material;if(gt)if(Array.isArray(gt))for(let St=0;St<gt.length;St++){const mt=gt[St];H0(mt,Y,G),H.add(mt)}else H0(gt,Y,G),H.add(gt)}),w=x.pop(),H},this.compileAsync=function(E,F,Y=null){const H=this.compile(E,F,Y);return new Promise(G=>{function gt(){if(H.forEach(function(St){W.get(St).currentProgram.isReady()&&H.delete(St)}),H.size===0){G(E);return}setTimeout(gt,10)}ye.get("KHR_parallel_shader_compile")!==null?gt():setTimeout(gt,10)})};let Ql=null;function X1(E){Ql&&Ql(E)}function G0(){oa.stop()}function V0(){oa.start()}const oa=new jg;oa.setAnimationLoop(X1),typeof self<"u"&&oa.setContext(self),this.setAnimationLoop=function(E){Ql=E,bt.setAnimationLoop(E),E===null?oa.stop():oa.start()},bt.addEventListener("sessionstart",G0),bt.addEventListener("sessionend",V0),this.render=function(E,F){if(F!==void 0&&F.isCamera!==!0){Gt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(I===!0)return;P!==null&&P.renderStart(E,F);const Y=bt.enabled===!0&&bt.isPresenting===!0,H=A!==null&&($===null||Y)&&A.begin(C,$);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),bt.enabled===!0&&bt.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(bt.cameraAutoUpdate===!0&&bt.updateCamera(F),F=bt.getCamera()),E.isScene===!0&&E.onBeforeRender(C,E,F,$),w=ut.get(E,x.length),w.init(F),w.state.textureUnits=K.getTextureUnits(),x.push(w),Me.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),kt.setFromProjectionMatrix(Me,ns,F.reversedDepth),Bt=this.localClippingEnabled,zt=Ut.init(this.clippingPlanes,Bt),b=ft.get(E,T.length),b.init(),T.push(b),bt.enabled===!0&&bt.isPresenting===!0){const St=C.xr.getDepthSensingMesh();St!==null&&th(St,F,-1/0,C.sortObjects)}th(E,F,0,C.sortObjects),b.finish(),C.sortObjects===!0&&b.sort(z,Tt,F.reversedDepth),Ze=bt.enabled===!1||bt.isPresenting===!1||bt.hasDepthSensing()===!1,Ze&&$t.addToRenderList(b,E),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),zt===!0&&Ut.beginShadows();const G=w.state.shadowsArray;if(Ht.render(G,E,F),zt===!0&&Ut.endShadows(),(H&&A.hasRenderPass())===!1){const St=b.opaque,mt=b.transmissive;if(w.setupLights(),F.isArrayCamera){const Et=F.cameras;if(mt.length>0)for(let Lt=0,Kt=Et.length;Lt<Kt;Lt++){const Qt=Et[Lt];X0(St,mt,E,Qt)}Ze&&$t.render(E);for(let Lt=0,Kt=Et.length;Lt<Kt;Lt++){const Qt=Et[Lt];W0(b,E,Qt,Qt.viewport)}}else mt.length>0&&X0(St,mt,E,F),Ze&&$t.render(E),W0(b,E,F)}$!==null&&k===0&&(K.updateMultisampleRenderTarget($),K.updateRenderTargetMipmap($)),H&&A.end(C),E.isScene===!0&&E.onAfterRender(C,E,F),vt.resetDefaultState(),tt=-1,J=null,x.pop(),x.length>0?(w=x[x.length-1],K.setTextureUnits(w.state.textureUnits),zt===!0&&Ut.setGlobalState(C.clippingPlanes,w.state.camera)):w=null,T.pop(),T.length>0?b=T[T.length-1]:b=null,P!==null&&P.renderEnd()};function th(E,F,Y,H){if(E.visible===!1)return;if(E.layers.test(F.layers)){if(E.isGroup)Y=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(F);else if(E.isLightProbeGrid)w.pushLightProbeGrid(E);else if(E.isLight)w.pushLight(E),E.castShadow&&w.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||kt.intersectsSprite(E)){H&&Ke.setFromMatrixPosition(E.matrixWorld).applyMatrix4(Me);const St=Q.update(E),mt=E.material;mt.visible&&b.push(E,St,mt,Y,Ke.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||kt.intersectsObject(E))){const St=Q.update(E),mt=E.material;if(H&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),Ke.copy(E.boundingSphere.center)):(St.boundingSphere===null&&St.computeBoundingSphere(),Ke.copy(St.boundingSphere.center)),Ke.applyMatrix4(E.matrixWorld).applyMatrix4(Me)),Array.isArray(mt)){const Et=St.groups;for(let Lt=0,Kt=Et.length;Lt<Kt;Lt++){const Qt=Et[Lt],Ot=mt[Qt.materialIndex];Ot&&Ot.visible&&b.push(E,St,Ot,Y,Ke.z,Qt)}}else mt.visible&&b.push(E,St,mt,Y,Ke.z,null)}}const gt=E.children;for(let St=0,mt=gt.length;St<mt;St++)th(gt[St],F,Y,H)}function W0(E,F,Y,H){const{opaque:G,transmissive:gt,transparent:St}=E;w.setupLightsView(Y),zt===!0&&Ut.setGlobalState(C.clippingPlanes,Y),H&&_.viewport(it.copy(H)),G.length>0&&Zo(G,F,Y),gt.length>0&&Zo(gt,F,Y),St.length>0&&Zo(St,F,Y),_.buffers.depth.setTest(!0),_.buffers.depth.setMask(!0),_.buffers.color.setMask(!0),_.setPolygonOffset(!1)}function X0(E,F,Y,H){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[H.id]===void 0){const Ot=ye.has("EXT_color_buffer_half_float")||ye.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[H.id]=new ri(1,1,{generateMipmaps:!0,type:Ot?qe:un,minFilter:wa,samples:Math.max(4,D.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:re.workingColorSpace})}const gt=w.state.transmissionRenderTarget[H.id],St=H.viewport||it;gt.setSize(St.z*C.transmissionResolutionScale,St.w*C.transmissionResolutionScale);const mt=C.getRenderTarget(),Et=C.getActiveCubeFace(),Lt=C.getActiveMipmapLevel();C.setRenderTarget(gt),C.getClearColor(jt),qt=C.getClearAlpha(),qt<1&&C.setClearColor(16777215,.5),C.clear(),Ze&&$t.render(Y);const Kt=C.toneMapping;C.toneMapping=rs;const Qt=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),w.setupLightsView(H),zt===!0&&Ut.setGlobalState(C.clippingPlanes,H),Zo(E,Y,H),K.updateMultisampleRenderTarget(gt),K.updateRenderTargetMipmap(gt),ye.has("WEBGL_multisampled_render_to_texture")===!1){let Ot=!1;for(let Ae=0,ei=F.length;Ae<ei;Ae++){const je=F[Ae],{object:De,geometry:Ti,material:yt,group:tn}=je;if(yt.side===ji&&De.layers.test(H.layers)){const he=yt.side;yt.side=Ve,yt.needsUpdate=!0,Y0(De,Y,H,Ti,yt,tn),yt.side=he,yt.needsUpdate=!0,Ot=!0}}Ot===!0&&(K.updateMultisampleRenderTarget(gt),K.updateRenderTargetMipmap(gt))}C.setRenderTarget(mt,Et,Lt),C.setClearColor(jt,qt),Qt!==void 0&&(H.viewport=Qt),C.toneMapping=Kt}function Zo(E,F,Y){const H=F.isScene===!0?F.overrideMaterial:null;for(let G=0,gt=E.length;G<gt;G++){const St=E[G],{object:mt,geometry:Et,group:Lt}=St;let Kt=St.material;Kt.allowOverride===!0&&H!==null&&(Kt=H),mt.layers.test(Y.layers)&&Y0(mt,F,Y,Et,Kt,Lt)}}function Y0(E,F,Y,H,G,gt){E.onBeforeRender(C,F,Y,H,G,gt),E.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),G.onBeforeRender(C,F,Y,H,E,gt),G.transparent===!0&&G.side===ji&&G.forceSinglePass===!1?(G.side=Ve,G.needsUpdate=!0,C.renderBufferDirect(Y,F,H,G,E,gt),G.side=ia,G.needsUpdate=!0,C.renderBufferDirect(Y,F,H,G,E,gt),G.side=ji):C.renderBufferDirect(Y,F,H,G,E,gt),E.onAfterRender(C,F,Y,H,G,gt)}function Jo(E,F,Y){F.isScene!==!0&&(F=He);const H=W.get(E),G=w.state.lights,gt=w.state.shadowsArray,St=G.state.version,mt=ht.getParameters(E,G.state,gt,F,Y,w.state.lightProbeGridArray),Et=ht.getProgramCacheKey(mt);let Lt=H.programs;H.environment=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?F.environment:null,H.fog=F.fog;const Kt=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap;H.envMap=ot.get(E.envMap||H.environment,Kt),H.envMapRotation=H.environment!==null&&E.envMap===null?F.environmentRotation:E.envMapRotation,Lt===void 0&&(E.addEventListener("dispose",Bn),Lt=new Map,H.programs=Lt);let Qt=Lt.get(Et);if(Qt!==void 0){if(H.currentProgram===Qt&&H.lightsStateVersion===St)return $0(E,mt),Qt}else mt.uniforms=ht.getUniforms(E),P!==null&&E.isNodeMaterial&&P.build(E,Y,mt),E.onBeforeCompile(mt,C),Qt=ht.acquireProgram(mt,Et),Lt.set(Et,Qt),H.uniforms=mt.uniforms;const Ot=H.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Ot.clippingPlanes=Ut.uniform),$0(E,mt),H.needsLights=K1(E),H.lightsStateVersion=St,H.needsLights&&(Ot.ambientLightColor.value=G.state.ambient,Ot.lightProbe.value=G.state.probe,Ot.directionalLights.value=G.state.directional,Ot.directionalLightShadows.value=G.state.directionalShadow,Ot.spotLights.value=G.state.spot,Ot.spotLightShadows.value=G.state.spotShadow,Ot.rectAreaLights.value=G.state.rectArea,Ot.ltc_1.value=G.state.rectAreaLTC1,Ot.ltc_2.value=G.state.rectAreaLTC2,Ot.pointLights.value=G.state.point,Ot.pointLightShadows.value=G.state.pointShadow,Ot.hemisphereLights.value=G.state.hemi,Ot.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Ot.spotLightMatrix.value=G.state.spotLightMatrix,Ot.spotLightMap.value=G.state.spotLightMap,Ot.pointShadowMatrix.value=G.state.pointShadowMatrix),H.lightProbeGrid=w.state.lightProbeGridArray.length>0,H.currentProgram=Qt,H.uniformsList=null,Qt}function q0(E){if(E.uniformsList===null){const F=E.currentProgram.getUniforms();E.uniformsList=cl.seqWithValue(F.seq,E.uniforms)}return E.uniformsList}function $0(E,F){const Y=W.get(E);Y.outputColorSpace=F.outputColorSpace,Y.batching=F.batching,Y.batchingColor=F.batchingColor,Y.instancing=F.instancing,Y.instancingColor=F.instancingColor,Y.instancingMorph=F.instancingMorph,Y.skinning=F.skinning,Y.morphTargets=F.morphTargets,Y.morphNormals=F.morphNormals,Y.morphColors=F.morphColors,Y.morphTargetsCount=F.morphTargetsCount,Y.numClippingPlanes=F.numClippingPlanes,Y.numIntersection=F.numClipIntersection,Y.vertexAlphas=F.vertexAlphas,Y.vertexTangents=F.vertexTangents,Y.toneMapping=F.toneMapping}function Y1(E,F){if(E.length===0)return null;if(E.length===1)return E[0].texture!==null?E[0]:null;M.setFromMatrixPosition(F.matrixWorld);for(let Y=0,H=E.length;Y<H;Y++){const G=E[Y];if(G.texture!==null&&G.boundingBox.containsPoint(M))return G}return null}function q1(E,F,Y,H,G){F.isScene!==!0&&(F=He),K.resetTextureUnits();const gt=F.fog,St=H.isMeshStandardMaterial||H.isMeshLambertMaterial||H.isMeshPhongMaterial?F.environment:null,mt=$===null?C.outputColorSpace:$.isXRRenderTarget===!0?$.texture.colorSpace:re.workingColorSpace,Et=H.isMeshStandardMaterial||H.isMeshLambertMaterial&&!H.envMap||H.isMeshPhongMaterial&&!H.envMap,Lt=ot.get(H.envMap||St,Et),Kt=H.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,Qt=!!Y.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Ot=!!Y.morphAttributes.position,Ae=!!Y.morphAttributes.normal,ei=!!Y.morphAttributes.color;let je=rs;H.toneMapped&&($===null||$.isXRRenderTarget===!0)&&(je=C.toneMapping);const De=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,Ti=De!==void 0?De.length:0,yt=W.get(H),tn=w.state.lights;if(zt===!0&&(Bt===!0||E!==J)){const Le=E===J&&H.id===tt;Ut.setState(H,E,Le)}let he=!1;H.version===yt.__version?(yt.needsLights&&yt.lightsStateVersion!==tn.state.version||yt.outputColorSpace!==mt||G.isBatchedMesh&&yt.batching===!1||!G.isBatchedMesh&&yt.batching===!0||G.isBatchedMesh&&yt.batchingColor===!0&&G.colorTexture===null||G.isBatchedMesh&&yt.batchingColor===!1&&G.colorTexture!==null||G.isInstancedMesh&&yt.instancing===!1||!G.isInstancedMesh&&yt.instancing===!0||G.isSkinnedMesh&&yt.skinning===!1||!G.isSkinnedMesh&&yt.skinning===!0||G.isInstancedMesh&&yt.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&yt.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&yt.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&yt.instancingMorph===!1&&G.morphTexture!==null||yt.envMap!==Lt||H.fog===!0&&yt.fog!==gt||yt.numClippingPlanes!==void 0&&(yt.numClippingPlanes!==Ut.numPlanes||yt.numIntersection!==Ut.numIntersection)||yt.vertexAlphas!==Kt||yt.vertexTangents!==Qt||yt.morphTargets!==Ot||yt.morphNormals!==Ae||yt.morphColors!==ei||yt.toneMapping!==je||yt.morphTargetsCount!==Ti||!!yt.lightProbeGrid!=w.state.lightProbeGridArray.length>0)&&(he=!0):(he=!0,yt.__version=H.version);let dn=yt.currentProgram;he===!0&&(dn=Jo(H,F,G),P&&H.isNodeMaterial&&P.onUpdateProgram(H,dn,yt));let Hn=!1,Cs=!1,ka=!1;const Ie=dn.getUniforms(),ii=yt.uniforms;if(_.useProgram(dn.program)&&(Hn=!0,Cs=!0,ka=!0),H.id!==tt&&(tt=H.id,Cs=!0),yt.needsLights){const Le=Y1(w.state.lightProbeGridArray,G);yt.lightProbeGrid!==Le&&(yt.lightProbeGrid=Le,Cs=!0)}if(Hn||J!==E){_.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),Ie.setValue(N,"projectionMatrix",E.projectionMatrix),Ie.setValue(N,"viewMatrix",E.matrixWorldInverse);const Ls=Ie.map.cameraPosition;Ls!==void 0&&Ls.setValue(N,xe.setFromMatrixPosition(E.matrixWorld)),D.logarithmicDepthBuffer&&Ie.setValue(N,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&Ie.setValue(N,"isOrthographic",E.isOrthographicCamera===!0),J!==E&&(J=E,Cs=!0,ka=!0)}if(yt.needsLights&&(tn.state.directionalShadowMap.length>0&&Ie.setValue(N,"directionalShadowMap",tn.state.directionalShadowMap,K),tn.state.spotShadowMap.length>0&&Ie.setValue(N,"spotShadowMap",tn.state.spotShadowMap,K),tn.state.pointShadowMap.length>0&&Ie.setValue(N,"pointShadowMap",tn.state.pointShadowMap,K)),G.isSkinnedMesh){Ie.setOptional(N,G,"bindMatrix"),Ie.setOptional(N,G,"bindMatrixInverse");const Le=G.skeleton;Le&&(Le.boneTexture===null&&Le.computeBoneTexture(),Ie.setValue(N,"boneTexture",Le.boneTexture,K))}G.isBatchedMesh&&(Ie.setOptional(N,G,"batchingTexture"),Ie.setValue(N,"batchingTexture",G._matricesTexture,K),Ie.setOptional(N,G,"batchingIdTexture"),Ie.setValue(N,"batchingIdTexture",G._indirectTexture,K),Ie.setOptional(N,G,"batchingColorTexture"),G._colorsTexture!==null&&Ie.setValue(N,"batchingColorTexture",G._colorsTexture,K));const Ps=Y.morphAttributes;if((Ps.position!==void 0||Ps.normal!==void 0||Ps.color!==void 0)&&O.update(G,Y,dn),(Cs||yt.receiveShadow!==G.receiveShadow)&&(yt.receiveShadow=G.receiveShadow,Ie.setValue(N,"receiveShadow",G.receiveShadow)),(H.isMeshStandardMaterial||H.isMeshLambertMaterial||H.isMeshPhongMaterial)&&H.envMap===null&&F.environment!==null&&(ii.envMapIntensity.value=F.environmentIntensity),ii.dfgLUT!==void 0&&(ii.dfgLUT.value=fb()),Cs){if(Ie.setValue(N,"toneMappingExposure",C.toneMappingExposure),yt.needsLights&&$1(ii,ka),gt&&H.fog===!0&&Pt.refreshFogUniforms(ii,gt),Pt.refreshMaterialUniforms(ii,H,nt,at,w.state.transmissionRenderTarget[E.id]),yt.needsLights&&yt.lightProbeGrid){const Le=yt.lightProbeGrid;ii.probesSH.value=Le.texture,ii.probesMin.value.copy(Le.boundingBox.min),ii.probesMax.value.copy(Le.boundingBox.max),ii.probesResolution.value.copy(Le.resolution)}cl.upload(N,q0(yt),ii,K)}if(H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(cl.upload(N,q0(yt),ii,K),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&Ie.setValue(N,"center",G.center),Ie.setValue(N,"modelViewMatrix",G.modelViewMatrix),Ie.setValue(N,"normalMatrix",G.normalMatrix),Ie.setValue(N,"modelMatrix",G.matrixWorld),H.uniformsGroups!==void 0){const Le=H.uniformsGroups;for(let Ls=0,za=Le.length;Ls<za;Ls++){const K0=Le[Ls];et.update(K0,dn),et.bind(K0,dn)}}return dn}function $1(E,F){E.ambientLightColor.needsUpdate=F,E.lightProbe.needsUpdate=F,E.directionalLights.needsUpdate=F,E.directionalLightShadows.needsUpdate=F,E.pointLights.needsUpdate=F,E.pointLightShadows.needsUpdate=F,E.spotLights.needsUpdate=F,E.spotLightShadows.needsUpdate=F,E.rectAreaLights.needsUpdate=F,E.hemisphereLights.needsUpdate=F}function K1(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return B},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return $},this.setRenderTargetTextures=function(E,F,Y){const H=W.get(E);H.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,H.__autoAllocateDepthBuffer===!1&&(H.__useRenderToTexture=!1),W.get(E.texture).__webglTexture=F,W.get(E.depthTexture).__webglTexture=H.__autoAllocateDepthBuffer?void 0:Y,H.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,F){const Y=W.get(E);Y.__webglFramebuffer=F,Y.__useDefaultFramebuffer=F===void 0},this.setRenderTarget=function(E,F=0,Y=0){$=E,B=F,k=Y;let H=null,G=!1,gt=!1;if(E){const mt=W.get(E);if(mt.__useDefaultFramebuffer!==void 0){_.bindFramebuffer(N.FRAMEBUFFER,mt.__webglFramebuffer),it.copy(E.viewport),rt.copy(E.scissor),Vt=E.scissorTest,_.viewport(it),_.scissor(rt),_.setScissorTest(Vt),tt=-1;return}else if(mt.__webglFramebuffer===void 0)K.setupRenderTarget(E);else if(mt.__hasExternalTextures)K.rebindTextures(E,W.get(E.texture).__webglTexture,W.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const Kt=E.depthTexture;if(mt.__boundDepthTexture!==Kt){if(Kt!==null&&W.has(Kt)&&(E.width!==Kt.image.width||E.height!==Kt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(E)}}const Et=E.texture;(Et.isData3DTexture||Et.isDataArrayTexture||Et.isCompressedArrayTexture)&&(gt=!0);const Lt=W.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Lt[F])?H=Lt[F][Y]:H=Lt[F],G=!0):E.samples>0&&K.useMultisampledRTT(E)===!1?H=W.get(E).__webglMultisampledFramebuffer:Array.isArray(Lt)?H=Lt[Y]:H=Lt,it.copy(E.viewport),rt.copy(E.scissor),Vt=E.scissorTest}else it.copy(Nt).multiplyScalar(nt).floor(),rt.copy(Ct).multiplyScalar(nt).floor(),Vt=_t;if(Y!==0&&(H=V),_.bindFramebuffer(N.FRAMEBUFFER,H)&&_.drawBuffers(E,H),_.viewport(it),_.scissor(rt),_.setScissorTest(Vt),G){const mt=W.get(E.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+F,mt.__webglTexture,Y)}else if(gt){const mt=F;for(let Et=0;Et<E.textures.length;Et++){const Lt=W.get(E.textures[Et]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+Et,Lt.__webglTexture,Y,mt)}}else if(E!==null&&Y!==0){const mt=W.get(E.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,mt.__webglTexture,Y)}tt=-1},this.readRenderTargetPixels=function(E,F,Y,H,G,gt,St,mt=0){if(!(E&&E.isWebGLRenderTarget)){Gt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Et=W.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&St!==void 0&&(Et=Et[St]),Et){_.bindFramebuffer(N.FRAMEBUFFER,Et);try{const Lt=E.textures[mt],Kt=Lt.format,Qt=Lt.type;if(E.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+mt),!D.textureFormatReadable(Kt)){Gt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!D.textureTypeReadable(Qt)){Gt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=E.width-H&&Y>=0&&Y<=E.height-G&&N.readPixels(F,Y,H,G,dt.convert(Kt),dt.convert(Qt),gt)}finally{const Lt=$!==null?W.get($).__webglFramebuffer:null;_.bindFramebuffer(N.FRAMEBUFFER,Lt)}}},this.readRenderTargetPixelsAsync=async function(E,F,Y,H,G,gt,St,mt=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Et=W.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&St!==void 0&&(Et=Et[St]),Et)if(F>=0&&F<=E.width-H&&Y>=0&&Y<=E.height-G){_.bindFramebuffer(N.FRAMEBUFFER,Et);const Lt=E.textures[mt],Kt=Lt.format,Qt=Lt.type;if(E.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+mt),!D.textureFormatReadable(Kt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!D.textureTypeReadable(Qt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ot=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Ot),N.bufferData(N.PIXEL_PACK_BUFFER,gt.byteLength,N.STREAM_READ),N.readPixels(F,Y,H,G,dt.convert(Kt),dt.convert(Qt),0);const Ae=$!==null?W.get($).__webglFramebuffer:null;_.bindFramebuffer(N.FRAMEBUFFER,Ae);const ei=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await G2(N,ei,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Ot),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,gt),N.deleteBuffer(Ot),N.deleteSync(ei),gt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,F=null,Y=0){const H=Math.pow(2,-Y),G=Math.floor(E.image.width*H),gt=Math.floor(E.image.height*H),St=F!==null?F.x:0,mt=F!==null?F.y:0;K.setTexture2D(E,0),N.copyTexSubImage2D(N.TEXTURE_2D,Y,0,0,St,mt,G,gt),_.unbindTexture()},this.copyTextureToTexture=function(E,F,Y=null,H=null,G=0,gt=0){let St,mt,Et,Lt,Kt,Qt,Ot,Ae,ei;const je=E.isCompressedTexture?E.mipmaps[gt]:E.image;if(Y!==null)St=Y.max.x-Y.min.x,mt=Y.max.y-Y.min.y,Et=Y.isBox3?Y.max.z-Y.min.z:1,Lt=Y.min.x,Kt=Y.min.y,Qt=Y.isBox3?Y.min.z:0;else{const ii=Math.pow(2,-G);St=Math.floor(je.width*ii),mt=Math.floor(je.height*ii),E.isDataArrayTexture?Et=je.depth:E.isData3DTexture?Et=Math.floor(je.depth*ii):Et=1,Lt=0,Kt=0,Qt=0}H!==null?(Ot=H.x,Ae=H.y,ei=H.z):(Ot=0,Ae=0,ei=0);const De=dt.convert(F.format),Ti=dt.convert(F.type);let yt;F.isData3DTexture?(K.setTexture3D(F,0),yt=N.TEXTURE_3D):F.isDataArrayTexture||F.isCompressedArrayTexture?(K.setTexture2DArray(F,0),yt=N.TEXTURE_2D_ARRAY):(K.setTexture2D(F,0),yt=N.TEXTURE_2D),_.activeTexture(N.TEXTURE0),_.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,F.flipY),_.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),_.pixelStorei(N.UNPACK_ALIGNMENT,F.unpackAlignment);const tn=_.getParameter(N.UNPACK_ROW_LENGTH),he=_.getParameter(N.UNPACK_IMAGE_HEIGHT),dn=_.getParameter(N.UNPACK_SKIP_PIXELS),Hn=_.getParameter(N.UNPACK_SKIP_ROWS),Cs=_.getParameter(N.UNPACK_SKIP_IMAGES);_.pixelStorei(N.UNPACK_ROW_LENGTH,je.width),_.pixelStorei(N.UNPACK_IMAGE_HEIGHT,je.height),_.pixelStorei(N.UNPACK_SKIP_PIXELS,Lt),_.pixelStorei(N.UNPACK_SKIP_ROWS,Kt),_.pixelStorei(N.UNPACK_SKIP_IMAGES,Qt);const ka=E.isDataArrayTexture||E.isData3DTexture,Ie=F.isDataArrayTexture||F.isData3DTexture;if(E.isDepthTexture){const ii=W.get(E),Ps=W.get(F),Le=W.get(ii.__renderTarget),Ls=W.get(Ps.__renderTarget);_.bindFramebuffer(N.READ_FRAMEBUFFER,Le.__webglFramebuffer),_.bindFramebuffer(N.DRAW_FRAMEBUFFER,Ls.__webglFramebuffer);for(let za=0;za<Et;za++)ka&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,W.get(E).__webglTexture,G,Qt+za),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,W.get(F).__webglTexture,gt,ei+za)),N.blitFramebuffer(Lt,Kt,St,mt,Ot,Ae,St,mt,N.DEPTH_BUFFER_BIT,N.NEAREST);_.bindFramebuffer(N.READ_FRAMEBUFFER,null),_.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(G!==0||E.isRenderTargetTexture||W.has(E)){const ii=W.get(E),Ps=W.get(F);_.bindFramebuffer(N.READ_FRAMEBUFFER,X),_.bindFramebuffer(N.DRAW_FRAMEBUFFER,L);for(let Le=0;Le<Et;Le++)ka?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,ii.__webglTexture,G,Qt+Le):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,ii.__webglTexture,G),Ie?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Ps.__webglTexture,gt,ei+Le):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Ps.__webglTexture,gt),G!==0?N.blitFramebuffer(Lt,Kt,St,mt,Ot,Ae,St,mt,N.COLOR_BUFFER_BIT,N.NEAREST):Ie?N.copyTexSubImage3D(yt,gt,Ot,Ae,ei+Le,Lt,Kt,St,mt):N.copyTexSubImage2D(yt,gt,Ot,Ae,Lt,Kt,St,mt);_.bindFramebuffer(N.READ_FRAMEBUFFER,null),_.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else Ie?E.isDataTexture||E.isData3DTexture?N.texSubImage3D(yt,gt,Ot,Ae,ei,St,mt,Et,De,Ti,je.data):F.isCompressedArrayTexture?N.compressedTexSubImage3D(yt,gt,Ot,Ae,ei,St,mt,Et,De,je.data):N.texSubImage3D(yt,gt,Ot,Ae,ei,St,mt,Et,De,Ti,je):E.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,gt,Ot,Ae,St,mt,De,Ti,je.data):E.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,gt,Ot,Ae,je.width,je.height,De,je.data):N.texSubImage2D(N.TEXTURE_2D,gt,Ot,Ae,St,mt,De,Ti,je);_.pixelStorei(N.UNPACK_ROW_LENGTH,tn),_.pixelStorei(N.UNPACK_IMAGE_HEIGHT,he),_.pixelStorei(N.UNPACK_SKIP_PIXELS,dn),_.pixelStorei(N.UNPACK_SKIP_ROWS,Hn),_.pixelStorei(N.UNPACK_SKIP_IMAGES,Cs),gt===0&&F.generateMipmaps&&N.generateMipmap(yt),_.unbindTexture()},this.initRenderTarget=function(E){W.get(E).__webglFramebuffer===void 0&&K.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?K.setTextureCube(E,0):E.isData3DTexture?K.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?K.setTexture2DArray(E,0):K.setTexture2D(E,0),_.unbindTexture()},this.resetState=function(){B=0,k=0,$=null,_.reset(),vt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ns}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=re._getDrawingBufferColorSpace(t),e.unpackColorSpace=re._getUnpackColorSpace()}}const mb=`
5212
5269
  varying vec3 vDir;
5213
5270
  varying vec3 vWorldDir;
5214
5271
 
@@ -5517,7 +5574,7 @@ void main() {
5517
5574
  // what is behind: exactly what the display drawn first and the deck laid over it gave.
5518
5575
  gl_FragColor = uPremultiplied > 0.5 ? vec4(color * alpha + halo * (1.0 - alpha), alpha) : vec4(color, alpha);
5519
5576
  }
5520
- `;function xd(r,t,e,i=0){const n={sunDir:{value:new R(0,1,0)},sunColor:{value:new st(1,1,1)},ambientColor:{value:new st(.5,.5,.5)},baseColor:{value:r},coverage:{value:t},opticalDensity:{value:1},darkness:{value:0},layerHeight:{value:e},fieldOffset:{value:new R},fibrous:{value:i},uHaloShown:{value:0},uPremultiplied:{value:0},uSource:{value:new R(0,1,0)},uUp:{value:new R(0,1,0)},uStrength:{value:0},uTint:{value:new R(1,1,1)},uMap:{value:null},uGain:{value:0}};return{material:new le({uniforms:n,vertexShader:mb,fragmentShader:gb,transparent:!0,depthWrite:!1,depthTest:!0,side:Ve}),uniforms:n}}function yd(r){return new oi(r,48,24,0,Math.PI*2,0,Math.PI/2)}class me{static OCTAVES=4;static GAIN=.55;static LACUNARITY=2.03;static fract(t){return t-Math.floor(t)}static hash3(t,e,i){const n=t*127.1+e*311.7+i*74.7,s=t*269.5+e*183.3+i*246.1,a=t*113.5+e*271.9+i*124.6;return[me.fract(Math.sin(n)*43758.5453)*2-1,me.fract(Math.sin(s)*43758.5453)*2-1,me.fract(Math.sin(a)*43758.5453)*2-1]}static noise3D(t,e,i){const n=Math.floor(t),s=Math.floor(e),a=Math.floor(i),o=t-n,c=e-s,l=i-a,h=o*o*(3-2*o),u=c*c*(3-2*c),d=l*l*(3-2*l),f=(v,m,g)=>{const[S,y,M]=me.hash3(n+v,s+m,a+g);return S*(o-v)+y*(c-m)+M*(l-g)},p=(v,m,g)=>v+(m-v)*g;return p(p(p(f(0,0,0),f(1,0,0),h),p(f(0,1,0),f(1,1,0),h),u),p(p(f(0,0,1),f(1,0,1),h),p(f(0,1,1),f(1,1,1),h),u),d)}static thresholdFor(t,e,i){const n=Math.min(.999,Math.max(.001,t));return e-i*(Math.sqrt(3)/Math.PI)*Math.log(n/(1-n))}static fbm(t,e,i){let n=0,s=me.GAIN;for(let a=0;a<me.OCTAVES;a++)n+=me.noise3D(t,e,i)*s,t*=me.LACUNARITY,e*=me.LACUNARITY,i*=me.LACUNARITY,s*=me.GAIN;return n}static worley(t,e,i){const n=Math.floor(t),s=Math.floor(e),a=Math.floor(i),o=t-n,c=e-s,l=i-a;let h=1/0;for(let u=-1;u<=1;u++)for(let d=-1;d<=1;d++)for(let f=-1;f<=1;f++){const[p,v,m]=me.hash3(n+u,s+d,a+f),g=u+(p*.5+.5)-o,S=d+(v*.5+.5)-c,y=f+(m*.5+.5)-l;h=Math.min(h,g*g+S*S+y*y)}return Math.sqrt(h)}static alphaAt(t,e,i,n={x:0,z:0}){if(i<=0)return 0;const[s,a,o]=me.warpedAt(t,e,n),c=me.fbm(s*.014,a*.014,o*.014)*.5+.5,l=1-me.worley(s*.011,a*.011,o*.011),h=c+(l-c)*.4,u=me.thresholdFor(i,r1,E0),d=me.smoothstep(u-Al,u+Al,h);return d+(1-d)*me.smoothstep(.82,1,i)}static iceAlphaAt(t,e,i,n={x:0,z:0}){if(i<=0)return 0;const[s,a,o]=me.warpedAt(t,e,n),c=s*.0016,l=a*.02,h=o*.045,u=me.fbm(c,l,h)*.5+.5,d=me.fbm(c*3.1+7,l*3.1+7,h*3.1+7)*.5+.5,f=me.thresholdFor(i,A0,Yl);return me.smoothstep(f-Md,f+Md,u*.72+d*.28)}static warpedAt(t,e,i){const n=Math.abs(t.y),s=e/Math.max(n,.04),a=t.x*s+i.x,o=t.y*s,c=t.z*s+i.z,l=a*.006,h=o*.006,u=c*.006;return[a+me.fbm(l+12.3,h+12.3,u+12.3)*40,o+me.fbm(l+47.1,h+47.1,u+47.1)*40,c+me.fbm(l+91.7,h+91.7,u+91.7)*40]}static smoothstep(t,e,i){const n=Math.min(1,Math.max(0,(i-t)/(e-t)));return n*n*(3-2*n)}}const Js=6371e3,si=64,so=8,Gh=.2787;function _d(r){if(r.seed!==void 0)return r.seed;let t=2166136261;for(const e of r.id)t=Math.imul(t^e.charCodeAt(0),16777619);return t>>>0}function vb(){const r=new Uint8Array(si**3),t=(n,s,a,o)=>{let c=Math.imul(n%o+1,374761393)^Math.imul(s%o+1,668265263)^Math.imul(a%o+1,1274126177);return c=Math.imul(c^c>>>13,1274126177),((c^c>>>16)>>>0)/4294967295},e=(n,s,a,o)=>{const c=Math.floor(n),l=Math.floor(s),h=Math.floor(a),u=m=>m*m*(3-2*m),d=u(n-c),f=u(s-l),p=u(a-h);let v=0;for(let m=0;m<2;m++)for(let g=0;g<2;g++)for(let S=0;S<2;S++)v+=t(c+S,l+g,h+m,o)*(S?d:1-d)*(g?f:1-f)*(m?p:1-p);return v};for(let n=0;n<si;n++)for(let s=0;s<si;s++)for(let a=0;a<si;a++){let o=0;for(const[c,l]of[[4,.65],[8,.25],[16,.1]])o+=e(a/si*c,s/si*c,n/si*c,c)*l;r[a+si*(s+si*n)]=Math.round(o*255)}const i=new Ng(r,si,si,si);return i.format=Hl,i.minFilter=i.magFilter=oe,i.wrapS=i.wrapT=i.wrapR=ko,i.needsUpdate=!0,i}function Mb(r,t,e,i){const n=h=>{const u=(Js+t)*r,d=(t-h)*(2*Js+t+h),f=u*u-d;if(f<0)return;const p=-u-(u>=0?1:-1)*Math.sqrt(f),v=p===0?0:d/p;return[Math.min(p,v),Math.max(p,v)]},s=n(e+i);if(!s||s[1]<=0)return;let a=Math.max(0,s[0]),o=s[1];const c=n(e);c&&(a>=c[0]&&a<c[1]?a=c[1]:c[0]>a&&(o=Math.min(o,c[0])));const l=n(0);return l&&l[0]>=0&&(o=Math.min(o,l[0])),o>a?[a,o]:void 0}const xb=`varying vec3 vCloudDirection;
5577
+ `;function xd(r,t,e,i=0){const n={sunDir:{value:new R(0,1,0)},sunColor:{value:new st(1,1,1)},ambientColor:{value:new st(.5,.5,.5)},baseColor:{value:r},coverage:{value:t},opticalDensity:{value:1},darkness:{value:0},layerHeight:{value:e},fieldOffset:{value:new R},fibrous:{value:i},uHaloShown:{value:0},uPremultiplied:{value:0},uSource:{value:new R(0,1,0)},uUp:{value:new R(0,1,0)},uStrength:{value:0},uTint:{value:new R(1,1,1)},uMap:{value:null},uGain:{value:0}};return{material:new le({uniforms:n,vertexShader:mb,fragmentShader:gb,transparent:!0,depthWrite:!1,depthTest:!0,side:Ve}),uniforms:n}}function yd(r){return new oi(r,48,24,0,Math.PI*2,0,Math.PI/2)}class ge{static OCTAVES=4;static GAIN=.55;static LACUNARITY=2.03;static fract(t){return t-Math.floor(t)}static hash3(t,e,i){const n=t*127.1+e*311.7+i*74.7,s=t*269.5+e*183.3+i*246.1,a=t*113.5+e*271.9+i*124.6;return[ge.fract(Math.sin(n)*43758.5453)*2-1,ge.fract(Math.sin(s)*43758.5453)*2-1,ge.fract(Math.sin(a)*43758.5453)*2-1]}static noise3D(t,e,i){const n=Math.floor(t),s=Math.floor(e),a=Math.floor(i),o=t-n,c=e-s,l=i-a,h=o*o*(3-2*o),u=c*c*(3-2*c),d=l*l*(3-2*l),f=(v,m,g)=>{const[S,y,M]=ge.hash3(n+v,s+m,a+g);return S*(o-v)+y*(c-m)+M*(l-g)},p=(v,m,g)=>v+(m-v)*g;return p(p(p(f(0,0,0),f(1,0,0),h),p(f(0,1,0),f(1,1,0),h),u),p(p(f(0,0,1),f(1,0,1),h),p(f(0,1,1),f(1,1,1),h),u),d)}static thresholdFor(t,e,i){const n=Math.min(.999,Math.max(.001,t));return e-i*(Math.sqrt(3)/Math.PI)*Math.log(n/(1-n))}static fbm(t,e,i){let n=0,s=ge.GAIN;for(let a=0;a<ge.OCTAVES;a++)n+=ge.noise3D(t,e,i)*s,t*=ge.LACUNARITY,e*=ge.LACUNARITY,i*=ge.LACUNARITY,s*=ge.GAIN;return n}static worley(t,e,i){const n=Math.floor(t),s=Math.floor(e),a=Math.floor(i),o=t-n,c=e-s,l=i-a;let h=1/0;for(let u=-1;u<=1;u++)for(let d=-1;d<=1;d++)for(let f=-1;f<=1;f++){const[p,v,m]=ge.hash3(n+u,s+d,a+f),g=u+(p*.5+.5)-o,S=d+(v*.5+.5)-c,y=f+(m*.5+.5)-l;h=Math.min(h,g*g+S*S+y*y)}return Math.sqrt(h)}static alphaAt(t,e,i,n={x:0,z:0}){if(i<=0)return 0;const[s,a,o]=ge.warpedAt(t,e,n),c=ge.fbm(s*.014,a*.014,o*.014)*.5+.5,l=1-ge.worley(s*.011,a*.011,o*.011),h=c+(l-c)*.4,u=ge.thresholdFor(i,r1,E0),d=ge.smoothstep(u-Al,u+Al,h);return d+(1-d)*ge.smoothstep(.82,1,i)}static iceAlphaAt(t,e,i,n={x:0,z:0}){if(i<=0)return 0;const[s,a,o]=ge.warpedAt(t,e,n),c=s*.0016,l=a*.02,h=o*.045,u=ge.fbm(c,l,h)*.5+.5,d=ge.fbm(c*3.1+7,l*3.1+7,h*3.1+7)*.5+.5,f=ge.thresholdFor(i,A0,Yl);return ge.smoothstep(f-Md,f+Md,u*.72+d*.28)}static warpedAt(t,e,i){const n=Math.abs(t.y),s=e/Math.max(n,.04),a=t.x*s+i.x,o=t.y*s,c=t.z*s+i.z,l=a*.006,h=o*.006,u=c*.006;return[a+ge.fbm(l+12.3,h+12.3,u+12.3)*40,o+ge.fbm(l+47.1,h+47.1,u+47.1)*40,c+ge.fbm(l+91.7,h+91.7,u+91.7)*40]}static smoothstep(t,e,i){const n=Math.min(1,Math.max(0,(i-t)/(e-t)));return n*n*(3-2*n)}}const Js=6371e3,si=64,so=8,Gh=.2787;function _d(r){if(r.seed!==void 0)return r.seed;let t=2166136261;for(const e of r.id)t=Math.imul(t^e.charCodeAt(0),16777619);return t>>>0}function vb(){const r=new Uint8Array(si**3),t=(n,s,a,o)=>{let c=Math.imul(n%o+1,374761393)^Math.imul(s%o+1,668265263)^Math.imul(a%o+1,1274126177);return c=Math.imul(c^c>>>13,1274126177),((c^c>>>16)>>>0)/4294967295},e=(n,s,a,o)=>{const c=Math.floor(n),l=Math.floor(s),h=Math.floor(a),u=m=>m*m*(3-2*m),d=u(n-c),f=u(s-l),p=u(a-h);let v=0;for(let m=0;m<2;m++)for(let g=0;g<2;g++)for(let S=0;S<2;S++)v+=t(c+S,l+g,h+m,o)*(S?d:1-d)*(g?f:1-f)*(m?p:1-p);return v};for(let n=0;n<si;n++)for(let s=0;s<si;s++)for(let a=0;a<si;a++){let o=0;for(const[c,l]of[[4,.65],[8,.25],[16,.1]])o+=e(a/si*c,s/si*c,n/si*c,c)*l;r[a+si*(s+si*n)]=Math.round(o*255)}const i=new Ng(r,si,si,si);return i.format=Hl,i.minFilter=i.magFilter=oe,i.wrapS=i.wrapT=i.wrapR=ko,i.needsUpdate=!0,i}function Mb(r,t,e,i){const n=h=>{const u=(Js+t)*r,d=(t-h)*(2*Js+t+h),f=u*u-d;if(f<0)return;const p=-u-(u>=0?1:-1)*Math.sqrt(f),v=p===0?0:d/p;return[Math.min(p,v),Math.max(p,v)]},s=n(e+i);if(!s||s[1]<=0)return;let a=Math.max(0,s[0]),o=s[1];const c=n(e);c&&(a>=c[0]&&a<c[1]?a=c[1]:c[0]>a&&(o=Math.min(o,c[0])));const l=n(0);return l&&l[0]>=0&&(o=Math.min(o,l[0])),o>a?[a,o]:void 0}const xb=`varying vec3 vCloudDirection;
5521
5578
  void main() {
5522
5579
  vCloudDirection = position;
5523
5580
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
@@ -5733,7 +5790,7 @@ float transmissionAt(vec3 dir, float distanceM) {
5733
5790
  if (transmission < 0.015) break;
5734
5791
  }
5735
5792
  return transmission;
5736
- }`,i=/\b(noiseMap|sunDir|sunColor|ambientColor|hazeColor|offsetM|seedOffset|localCenter|localSize|localRotation|baseM|thicknessM|eyeM|coverage|sizeM|density|darkness|flatness|SLICE|MAX_HOLES|holeCount|holeCenter|holeSize|holeRotation|R|roots|altitude|coverageThreshold|ellipsoidRadius|clipLocal|densityAt|transmissionAt)\b/g;return(t+e).replace(i,n=>r+n)}class Tl{mesh;uniforms;constructor(t,e){this.uniforms={noiseMap:{value:t},sunDir:{value:new R(0,1,0)},sunColor:{value:new st(1,1,1)},ambientColor:{value:new st(.4,.45,.5)},hazeColor:{value:new st(.5,.6,.7)},offsetM:{value:new R},seedOffset:{value:new R},localCenter:{value:new R},localSize:{value:new R},localRotation:{value:0},holeCount:{value:0},holeCenter:{value:Array.from({length:so},()=>new R)},holeSize:{value:Array.from({length:so},()=>new R)},holeRotation:{value:new Array(so).fill(0)},baseM:{value:1e3},thicknessM:{value:650},eyeM:{value:1.6},coverage:{value:.5},sizeM:{value:1400},density:{value:1},darkness:{value:0},flatness:{value:0}};const i=new le({uniforms:this.uniforms,vertexShader:xb,fragmentShader:Sd,transparent:!0,depthWrite:!1,depthTest:!0,side:Ve});this.mesh=new Dt(new oi(e,32,16),i),this.mesh.frustumCulled=!1}update(t,e,i,n=[]){const s=this.uniforms;s.localSize.value.set(i?.widthM??0,i?.thicknessM??0,i?.depthM??0),s.localCenter.value.set(i?.eastM??0,i?i.baseM+i.thicknessM/2:0,-(i?.northM??0)),s.localRotation.value=(i?.rotationDeg??0)*Math.PI/180,s.holeCount.value=Math.min(so,n.length),n.slice(0,so).forEach((o,c)=>{s.holeCenter.value[c].set(o.eastM,o.baseM+o.thicknessM/2,-o.northM),s.holeSize.value[c].set(o.widthM,o.thicknessM,o.depthM),s.holeRotation.value[c]=o.rotationDeg*Math.PI/180}),s.baseM.value=Math.max(0,t.baseM),s.thicknessM.value=Math.max(10,t.thicknessM),s.coverage.value=Math.max(0,Math.min(1,t.coverage)),s.sizeM.value=Math.max(50,t.sizeM),s.density.value=Math.max(0,Math.min(2,t.density)),s.darkness.value=Math.max(0,Math.min(1,t.darkness??0)),s.eyeM.value=Math.max(.1,e),s.flatness.value=t.type==="stratus"?1:t.type==="stratocumulus"?.45:0;const a=_d(t);s.seedOffset.value.set(a%97/97,a%61/61,a%37/37),this.mesh.visible=s.density.value>0&&(i!==void 0||s.coverage.value>0)}static thresholdFor(t){const e=Math.min(.999,Math.max(.001,t));return .564-.2516*(Math.sqrt(3)/Math.PI)*Math.log(e/(1-e))}densityAt(t){const e=this.uniforms,i=(L,B,k)=>{const $=Math.max(0,Math.min(1,(k-L)/(B-L)));return $*$*(3-2*$)},n=(L,B,k)=>L+(B-L)*k,s=e.eyeM.value+t.y,a=2*Js*s+t.x**2+s**2+t.z**2,o=a/(Math.sqrt(Js**2+a)+Js),c=(o-e.baseM.value)/e.thicknessM.value,l=e.localSize.value.x>0;if(c<=0||c>=1||e.coverage.value<=0&&!l)return 0;const h=(L,B,k)=>{const $=t.x+e.offsetM.value.x-L.x,tt=t.z+e.offsetM.value.z-L.z,J=Math.cos(k),it=Math.sin(k);return Math.hypot((J*$-it*tt)/(B.x*.5),(o-L.y)/(B.y*.5),(it*$+J*tt)/(B.z*.5))},u=l?h(e.localCenter.value,e.localSize.value,e.localRotation.value):0;if(u>1.3)return 0;const d=[t.x,t.y,t.z].map((L,B)=>(L+e.offsetM.value.getComponent(B))/(e.sizeM.value*4)+e.seedOffset.value.getComponent(B)),f=e.noiseMap.value.image.data,p=(L,B,k)=>{const $=[L,B,k].map(rt=>(rt%1+1)%1*si-.5),tt=$.map(Math.floor),J=$.map((rt,Vt)=>rt-tt[Vt]);let it=0;for(let rt=0;rt<2;rt++)for(let Vt=0;Vt<2;Vt++)for(let Jt=0;Jt<2;Jt++){const qt=(tt[0]+Jt+si)%si,q=(tt[1]+Vt+si)%si,at=(tt[2]+rt+si)%si;it+=f[qt+si*(q+si*at)]/255*(Jt?J[0]:1-J[0])*(Vt?J[1]:1-J[1])*(rt?J[2]:1-J[2])}return it},v=[d[0]*.173,Gh,d[2]*.173];d[0]+=(p(v[0]+.13,v[1]+.27,v[2]+.41)-.5)*1.3,d[2]+=(p(v[0]+.67,v[1]+.53,v[2]+.19)-.5)*1.3;const m=(d[0]*.731+d[2]*.682)*1.371,g=(-d[0]*.682+d[2]*.731)*1.371;let S=i(.2,.8,p(d[0],Gh,d[2])*.65+p(m,Gh+.37,g)*.35);const y=i(8e3,4e4,Math.hypot(t.x,t.y,t.z)),M=n(p(d[0]*2,d[1]*3,d[2]*2),.5,y),b=n(p(d[0]*7,d[1]*7,d[2]*7),.5,y);let w=Tl.thresholdFor(e.coverage.value),T=1,x=0;if(l){const L=u+(M-.5)*.18;x=1-i(.35,1,L),T=1-i(.85,1.15,L),S=n(S,1,x),w=Math.min(w,Tl.thresholdFor(.5))}for(let L=0;L<e.holeCount.value;L++)T*=i(.85,1.15,h(e.holeCenter.value[L],e.holeSize.value[L],e.holeRotation.value[L])+(M-.5)*.18);if(T<.001)return 0;const A=(1-e.flatness.value)*.3*c*c;let C=i(w-.1+A,w+.1+A,S+(M-.5)*.12*c);if(C=n(C,1,i(.92,1,e.coverage.value)),C=n(C,Math.max(e.coverage.value,x),y),C<.001)return 0;const I=n(.45+.55*M,.96,e.flatness.value),P=i(0,.09,c)*(1-i(I-.22,I,c)),V=n(Math.max(0,C-(1-M)*.38-(1-b)*.1),C*.8,e.flatness.value),X=n(1-y,1,i(.5,.92,e.coverage.value));return P*V*e.density.value*T*X}transmissionAt(t,e=1/0){const i=this.uniforms,n=Mb(t.y,i.eyeM.value,i.baseM.value,i.thicknessM.value);if(!n)return 1;let[s,a]=n;if(i.localSize.value.x>0){const h=i.localCenter.value.clone().sub(i.offsetM.value);h.y-=i.eyeM.value+(h.x**2+h.z**2)/(2*Js);const u=i.localSize.value.length()*.5+25,d=t.x*h.x+t.y*h.y+t.z*h.z,f=d*d-h.lengthSq()+u*u;if(f<0)return 1;s=Math.max(s,d-Math.sqrt(f)),a=Math.min(a,d+Math.sqrt(f))}const o=Math.min(a,e,s+18e3);if(o<=s)return 1;const c=(o-s)/48;let l=1;for(let h=0;h<48;h++){const u=s+(h+.5)*c;if(l*=Math.exp(-this.densityAt({x:t.x*u,y:t.y*u,z:t.z*u})*c*.006),l<.015)break}return l}dispose(){this.mesh.removeFromParent(),this.mesh.geometry.dispose(),this.mesh.material.dispose()}}class mi{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=mi.build(24);static build(t){const e=[];let i=0,n=0,s=0;for(let a=0;a<t;a++){const o=mi.VIOLET_NM+(a+.5)/t*(mi.DEEP_RED_NM-mi.VIOLET_NM),[c,l,h]=mi.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*c-1.5372*l-.4986*h),g:Math.max(0,-.9689*c+1.8758*l+.0415*h),b:Math.max(0,.0557*c-.204*l+1.057*h)};i+=u.r,n+=u.g,s+=u.b,e.push(u)}for(const a of e)a.r/=i,a.g/=n,a.b/=s;return e}static tristimulus(t,e,i){let n=0,s=0,a=0;for(let c=0;c<t.length;c++){const[l,h,u]=mi.colourMatching(t[c]);n+=l*e[c],s+=h*e[c],a+=u*e[c]}const o=683*i;return[n*o,s*o,a*o]}static scotopic(t){const e=t/1e3;return .992*Math.exp(-321.9*(e-.5)**2)}static linearSrgbOf([t,e,i]){return[3.2406*t-1.5372*e-.4986*i,-.9689*t+1.8758*e+.0415*i,.0557*t-.204*e+1.057*i]}static colourMatching(t){const e=(i,n,s)=>{const a=(t-i)/(t<i?n:s);return Math.exp(-.5*a*a)};return[1.056*e(599.8,37.9,31)+.362*e(442,16,26.7)-.065*e(501.1,20.4,26.2),.821*e(568.8,46.9,40.5)+.286*e(530.9,16.3,31.1),1.217*e(437,11.8,36)+.681*e(459,26,13.8)]}}class Rl{static reflectance(t,e,i){const s=e/i*Math.sqrt(Math.max(0,1-t*t));if(s>=1)return 1;const a=Math.sqrt(Math.max(0,1-s*s)),o=(i*t-e*a)/(i*t+e*a),c=(e*t-i*a)/(e*t+i*a);return(o*o+c*c)/2}}class _i{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(_i.ANCHOR_BLUE-_i.ANCHOR_RED)/(1/(_i.BLUE_NM*_i.BLUE_NM)-1/(_i.RED_NM*_i.RED_NM));static A=_i.ANCHOR_RED-_i.B/(_i.RED_NM*_i.RED_NM);static indexAt(t){return _i.A+_i.B/(t*t)}}class wr{static MAX_CHORDS=4;index=1.333;set refractiveIndex(t){this.index=t}trace(t,e){const i=Math.min(1,Math.max(0,t)),n=Math.sqrt(Math.max(0,1-i*i)),s=i/this.index,a=Math.sqrt(Math.max(0,1-s*s)),o=Math.asin(i),c=Math.asin(s),l=Rl.reflectance(n,1,this.index);let h=0;e[h].chords=0,e[h].scatteringAngle=wr.folded(Math.PI-2*o),e[h].weight=l,h++;const u=Rl.reflectance(a,this.index,1);let d=1-l;for(let f=1;f<=wr.MAX_CHORDS&&h<e.length;f++){const p=2*(o-c)+(f-1)*(Math.PI-2*c);e[h].chords=f,e[h].scatteringAngle=wr.folded(p),e[h].weight=d*(1-u),h++,d*=u}return h}static folded(t){const e=2*Math.PI;let i=t%e;return i<0&&(i+=e),i>Math.PI?e-i:i}}class ni{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new wr;previous=ni.emergences();current=ni.emergences();tally=new Float32Array(ni.BINS*3);radiance=new Float32Array(ni.BINS*3);scratch=new Float32Array(ni.BINS*3);static emergences(){return Array.from({length:wr.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const t of mi.SAMPLES)this.sweep(t);return this.toRadiance(),this.blurBySourceDisc(),{bins:ni.BINS,data:this.radiance,binDeg:180/ni.BINS}}sweep(t){this.drop.refractiveIndex=_i.indexAt(t.wavelengthNm);const e=ni.IMPACT_STEPS;let i=this.drop.trace(0,this.previous);const n=1/e;for(let s=1;s<=e;s++){const a=this.drop.trace(Math.sqrt(s/e),this.current);for(let o=0;o<Math.min(a,i);o++){const c=this.previous[o],l=this.current[o];c.chords===l.chords&&this.deposit(c.scatteringAngle,l.scatteringAngle,(c.weight+l.weight)/2*n,t)}i=a,this.copyInto(this.current,this.previous)}}copyInto(t,e){for(let i=0;i<t.length;i++)e[i].chords=t[i].chords,e[i].scatteringAngle=t[i].scatteringAngle,e[i].weight=t[i].weight}deposit(t,e,i,n){if(i<=0)return;const s=ni.BINS,a=Math.PI/s,o=Math.min(t,e),c=Math.max(t,e),l=c-o,h=Math.min(s-1,Math.max(0,Math.floor(o/a))),u=Math.min(s-1,Math.max(0,Math.floor(c/a)));if(l<=0||h===u){this.add(h,i,n);return}for(let d=h;d<=u;d++){const f=Math.min(c,(d+1)*a)-Math.max(o,d*a);f>0&&this.add(d,i*f/l,n)}}add(t,e,i){const n=t*3,s=e*mi.SAMPLES.length;this.tally[n]+=s*i.r,this.tally[n+1]+=s*i.g,this.tally[n+2]+=s*i.b}toRadiance(){const t=ni.BINS,e=Math.PI/t;for(let i=0;i<t;i++){const n=2*Math.PI*(Math.cos(i*e)-Math.cos((i+1)*e)),s=n>0?this.backwardShare((i+.5)*(180/t))/n:0,a=i*3;this.radiance[a]=this.tally[a]*s,this.radiance[a+1]=this.tally[a+1]*s,this.radiance[a+2]=this.tally[a+2]*s}}backwardShare(t){const e=180-t;if(e<=ni.FULL_UNTIL_DEG)return 1;if(e>=ni.FADED_BY_DEG)return 0;const i=(e-ni.FULL_UNTIL_DEG)/(ni.FADED_BY_DEG-ni.FULL_UNTIL_DEG);return Math.cos(i*Math.PI/2)**2}blurBySourceDisc(){const t=ni.BINS,e=ni.SOURCE_RADIUS_DEG*t/180,i=Math.max(1,Math.ceil(e)),n=[];let s=0;for(let a=-i;a<=i;a++){const o=Math.max(0,e*e-a*a),c=Math.sqrt(o);n.push(c),s+=c}if(!(s<=0)){this.scratch.set(this.radiance);for(let a=0;a<t;a++){let o=0,c=0,l=0;for(let u=-i;u<=i;u++){const d=Math.min(t-1,Math.max(0,a+u))*3,f=n[u+i];o+=this.scratch[d]*f,c+=this.scratch[d+1]*f,l+=this.scratch[d+2]*f}const h=a*3;this.radiance[h]=o/s,this.radiance[h+1]=c/s,this.radiance[h+2]=l/s}}}}class Aa{static RADIUS=880;static RENDER_ORDER=5.5;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new ni;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(ni.BINS*4),this.texture=new ra(this.texels,ni.BINS,1,Ei,qe),this.texture.minFilter=oe,this.texture.magFilter=oe,this.texture.wrapS=wi,this.texture.wrapT=wi,this.texture.needsUpdate=!0,this.material=new le({uniforms:{uSource:{value:new R(0,1,0)},uStrength:{value:0},uTint:{value:new R(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:Aa.GAIN}},vertexShader:`
5793
+ }`,i=/\b(noiseMap|sunDir|sunColor|ambientColor|hazeColor|offsetM|seedOffset|localCenter|localSize|localRotation|baseM|thicknessM|eyeM|coverage|sizeM|density|darkness|flatness|SLICE|MAX_HOLES|holeCount|holeCenter|holeSize|holeRotation|R|roots|altitude|coverageThreshold|ellipsoidRadius|clipLocal|densityAt|transmissionAt)\b/g;return(t+e).replace(i,n=>r+n)}class Tl{mesh;uniforms;constructor(t,e){this.uniforms={noiseMap:{value:t},sunDir:{value:new R(0,1,0)},sunColor:{value:new st(1,1,1)},ambientColor:{value:new st(.4,.45,.5)},hazeColor:{value:new st(.5,.6,.7)},offsetM:{value:new R},seedOffset:{value:new R},localCenter:{value:new R},localSize:{value:new R},localRotation:{value:0},holeCount:{value:0},holeCenter:{value:Array.from({length:so},()=>new R)},holeSize:{value:Array.from({length:so},()=>new R)},holeRotation:{value:new Array(so).fill(0)},baseM:{value:1e3},thicknessM:{value:650},eyeM:{value:1.6},coverage:{value:.5},sizeM:{value:1400},density:{value:1},darkness:{value:0},flatness:{value:0}};const i=new le({uniforms:this.uniforms,vertexShader:xb,fragmentShader:Sd,transparent:!0,depthWrite:!1,depthTest:!0,side:Ve});this.mesh=new Dt(new oi(e,32,16),i),this.mesh.frustumCulled=!1}update(t,e,i,n=[]){const s=this.uniforms;s.localSize.value.set(i?.widthM??0,i?.thicknessM??0,i?.depthM??0),s.localCenter.value.set(i?.eastM??0,i?i.baseM+i.thicknessM/2:0,-(i?.northM??0)),s.localRotation.value=(i?.rotationDeg??0)*Math.PI/180,s.holeCount.value=Math.min(so,n.length),n.slice(0,so).forEach((o,c)=>{s.holeCenter.value[c].set(o.eastM,o.baseM+o.thicknessM/2,-o.northM),s.holeSize.value[c].set(o.widthM,o.thicknessM,o.depthM),s.holeRotation.value[c]=o.rotationDeg*Math.PI/180}),s.baseM.value=Math.max(0,t.baseM),s.thicknessM.value=Math.max(10,t.thicknessM),s.coverage.value=Math.max(0,Math.min(1,t.coverage)),s.sizeM.value=Math.max(50,t.sizeM),s.density.value=Math.max(0,Math.min(2,t.density)),s.darkness.value=Math.max(0,Math.min(1,t.darkness??0)),s.eyeM.value=Math.max(.1,e),s.flatness.value=t.type==="stratus"?1:t.type==="stratocumulus"?.45:0;const a=_d(t);s.seedOffset.value.set(a%97/97,a%61/61,a%37/37),this.mesh.visible=s.density.value>0&&(i!==void 0||s.coverage.value>0)}static thresholdFor(t){const e=Math.min(.999,Math.max(.001,t));return .564-.2516*(Math.sqrt(3)/Math.PI)*Math.log(e/(1-e))}densityAt(t){const e=this.uniforms,i=(L,B,k)=>{const $=Math.max(0,Math.min(1,(k-L)/(B-L)));return $*$*(3-2*$)},n=(L,B,k)=>L+(B-L)*k,s=e.eyeM.value+t.y,a=2*Js*s+t.x**2+s**2+t.z**2,o=a/(Math.sqrt(Js**2+a)+Js),c=(o-e.baseM.value)/e.thicknessM.value,l=e.localSize.value.x>0;if(c<=0||c>=1||e.coverage.value<=0&&!l)return 0;const h=(L,B,k)=>{const $=t.x+e.offsetM.value.x-L.x,tt=t.z+e.offsetM.value.z-L.z,J=Math.cos(k),it=Math.sin(k);return Math.hypot((J*$-it*tt)/(B.x*.5),(o-L.y)/(B.y*.5),(it*$+J*tt)/(B.z*.5))},u=l?h(e.localCenter.value,e.localSize.value,e.localRotation.value):0;if(u>1.3)return 0;const d=[t.x,t.y,t.z].map((L,B)=>(L+e.offsetM.value.getComponent(B))/(e.sizeM.value*4)+e.seedOffset.value.getComponent(B)),f=e.noiseMap.value.image.data,p=(L,B,k)=>{const $=[L,B,k].map(rt=>(rt%1+1)%1*si-.5),tt=$.map(Math.floor),J=$.map((rt,Vt)=>rt-tt[Vt]);let it=0;for(let rt=0;rt<2;rt++)for(let Vt=0;Vt<2;Vt++)for(let jt=0;jt<2;jt++){const qt=(tt[0]+jt+si)%si,q=(tt[1]+Vt+si)%si,at=(tt[2]+rt+si)%si;it+=f[qt+si*(q+si*at)]/255*(jt?J[0]:1-J[0])*(Vt?J[1]:1-J[1])*(rt?J[2]:1-J[2])}return it},v=[d[0]*.173,Gh,d[2]*.173];d[0]+=(p(v[0]+.13,v[1]+.27,v[2]+.41)-.5)*1.3,d[2]+=(p(v[0]+.67,v[1]+.53,v[2]+.19)-.5)*1.3;const m=(d[0]*.731+d[2]*.682)*1.371,g=(-d[0]*.682+d[2]*.731)*1.371;let S=i(.2,.8,p(d[0],Gh,d[2])*.65+p(m,Gh+.37,g)*.35);const y=i(8e3,4e4,Math.hypot(t.x,t.y,t.z)),M=n(p(d[0]*2,d[1]*3,d[2]*2),.5,y),b=n(p(d[0]*7,d[1]*7,d[2]*7),.5,y);let w=Tl.thresholdFor(e.coverage.value),T=1,x=0;if(l){const L=u+(M-.5)*.18;x=1-i(.35,1,L),T=1-i(.85,1.15,L),S=n(S,1,x),w=Math.min(w,Tl.thresholdFor(.5))}for(let L=0;L<e.holeCount.value;L++)T*=i(.85,1.15,h(e.holeCenter.value[L],e.holeSize.value[L],e.holeRotation.value[L])+(M-.5)*.18);if(T<.001)return 0;const A=(1-e.flatness.value)*.3*c*c;let C=i(w-.1+A,w+.1+A,S+(M-.5)*.12*c);if(C=n(C,1,i(.92,1,e.coverage.value)),C=n(C,Math.max(e.coverage.value,x),y),C<.001)return 0;const I=n(.45+.55*M,.96,e.flatness.value),P=i(0,.09,c)*(1-i(I-.22,I,c)),V=n(Math.max(0,C-(1-M)*.38-(1-b)*.1),C*.8,e.flatness.value),X=n(1-y,1,i(.5,.92,e.coverage.value));return P*V*e.density.value*T*X}transmissionAt(t,e=1/0){const i=this.uniforms,n=Mb(t.y,i.eyeM.value,i.baseM.value,i.thicknessM.value);if(!n)return 1;let[s,a]=n;if(i.localSize.value.x>0){const h=i.localCenter.value.clone().sub(i.offsetM.value);h.y-=i.eyeM.value+(h.x**2+h.z**2)/(2*Js);const u=i.localSize.value.length()*.5+25,d=t.x*h.x+t.y*h.y+t.z*h.z,f=d*d-h.lengthSq()+u*u;if(f<0)return 1;s=Math.max(s,d-Math.sqrt(f)),a=Math.min(a,d+Math.sqrt(f))}const o=Math.min(a,e,s+18e3);if(o<=s)return 1;const c=(o-s)/48;let l=1;for(let h=0;h<48;h++){const u=s+(h+.5)*c;if(l*=Math.exp(-this.densityAt({x:t.x*u,y:t.y*u,z:t.z*u})*c*.006),l<.015)break}return l}dispose(){this.mesh.removeFromParent(),this.mesh.geometry.dispose(),this.mesh.material.dispose()}}class mi{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=mi.build(24);static build(t){const e=[];let i=0,n=0,s=0;for(let a=0;a<t;a++){const o=mi.VIOLET_NM+(a+.5)/t*(mi.DEEP_RED_NM-mi.VIOLET_NM),[c,l,h]=mi.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*c-1.5372*l-.4986*h),g:Math.max(0,-.9689*c+1.8758*l+.0415*h),b:Math.max(0,.0557*c-.204*l+1.057*h)};i+=u.r,n+=u.g,s+=u.b,e.push(u)}for(const a of e)a.r/=i,a.g/=n,a.b/=s;return e}static tristimulus(t,e,i){let n=0,s=0,a=0;for(let c=0;c<t.length;c++){const[l,h,u]=mi.colourMatching(t[c]);n+=l*e[c],s+=h*e[c],a+=u*e[c]}const o=683*i;return[n*o,s*o,a*o]}static scotopic(t){const e=t/1e3;return .992*Math.exp(-321.9*(e-.5)**2)}static linearSrgbOf([t,e,i]){return[3.2406*t-1.5372*e-.4986*i,-.9689*t+1.8758*e+.0415*i,.0557*t-.204*e+1.057*i]}static colourMatching(t){const e=(i,n,s)=>{const a=(t-i)/(t<i?n:s);return Math.exp(-.5*a*a)};return[1.056*e(599.8,37.9,31)+.362*e(442,16,26.7)-.065*e(501.1,20.4,26.2),.821*e(568.8,46.9,40.5)+.286*e(530.9,16.3,31.1),1.217*e(437,11.8,36)+.681*e(459,26,13.8)]}}class Rl{static reflectance(t,e,i){const s=e/i*Math.sqrt(Math.max(0,1-t*t));if(s>=1)return 1;const a=Math.sqrt(Math.max(0,1-s*s)),o=(i*t-e*a)/(i*t+e*a),c=(e*t-i*a)/(e*t+i*a);return(o*o+c*c)/2}}class _i{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(_i.ANCHOR_BLUE-_i.ANCHOR_RED)/(1/(_i.BLUE_NM*_i.BLUE_NM)-1/(_i.RED_NM*_i.RED_NM));static A=_i.ANCHOR_RED-_i.B/(_i.RED_NM*_i.RED_NM);static indexAt(t){return _i.A+_i.B/(t*t)}}class wr{static MAX_CHORDS=4;index=1.333;set refractiveIndex(t){this.index=t}trace(t,e){const i=Math.min(1,Math.max(0,t)),n=Math.sqrt(Math.max(0,1-i*i)),s=i/this.index,a=Math.sqrt(Math.max(0,1-s*s)),o=Math.asin(i),c=Math.asin(s),l=Rl.reflectance(n,1,this.index);let h=0;e[h].chords=0,e[h].scatteringAngle=wr.folded(Math.PI-2*o),e[h].weight=l,h++;const u=Rl.reflectance(a,this.index,1);let d=1-l;for(let f=1;f<=wr.MAX_CHORDS&&h<e.length;f++){const p=2*(o-c)+(f-1)*(Math.PI-2*c);e[h].chords=f,e[h].scatteringAngle=wr.folded(p),e[h].weight=d*(1-u),h++,d*=u}return h}static folded(t){const e=2*Math.PI;let i=t%e;return i<0&&(i+=e),i>Math.PI?e-i:i}}class ni{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new wr;previous=ni.emergences();current=ni.emergences();tally=new Float32Array(ni.BINS*3);radiance=new Float32Array(ni.BINS*3);scratch=new Float32Array(ni.BINS*3);static emergences(){return Array.from({length:wr.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const t of mi.SAMPLES)this.sweep(t);return this.toRadiance(),this.blurBySourceDisc(),{bins:ni.BINS,data:this.radiance,binDeg:180/ni.BINS}}sweep(t){this.drop.refractiveIndex=_i.indexAt(t.wavelengthNm);const e=ni.IMPACT_STEPS;let i=this.drop.trace(0,this.previous);const n=1/e;for(let s=1;s<=e;s++){const a=this.drop.trace(Math.sqrt(s/e),this.current);for(let o=0;o<Math.min(a,i);o++){const c=this.previous[o],l=this.current[o];c.chords===l.chords&&this.deposit(c.scatteringAngle,l.scatteringAngle,(c.weight+l.weight)/2*n,t)}i=a,this.copyInto(this.current,this.previous)}}copyInto(t,e){for(let i=0;i<t.length;i++)e[i].chords=t[i].chords,e[i].scatteringAngle=t[i].scatteringAngle,e[i].weight=t[i].weight}deposit(t,e,i,n){if(i<=0)return;const s=ni.BINS,a=Math.PI/s,o=Math.min(t,e),c=Math.max(t,e),l=c-o,h=Math.min(s-1,Math.max(0,Math.floor(o/a))),u=Math.min(s-1,Math.max(0,Math.floor(c/a)));if(l<=0||h===u){this.add(h,i,n);return}for(let d=h;d<=u;d++){const f=Math.min(c,(d+1)*a)-Math.max(o,d*a);f>0&&this.add(d,i*f/l,n)}}add(t,e,i){const n=t*3,s=e*mi.SAMPLES.length;this.tally[n]+=s*i.r,this.tally[n+1]+=s*i.g,this.tally[n+2]+=s*i.b}toRadiance(){const t=ni.BINS,e=Math.PI/t;for(let i=0;i<t;i++){const n=2*Math.PI*(Math.cos(i*e)-Math.cos((i+1)*e)),s=n>0?this.backwardShare((i+.5)*(180/t))/n:0,a=i*3;this.radiance[a]=this.tally[a]*s,this.radiance[a+1]=this.tally[a+1]*s,this.radiance[a+2]=this.tally[a+2]*s}}backwardShare(t){const e=180-t;if(e<=ni.FULL_UNTIL_DEG)return 1;if(e>=ni.FADED_BY_DEG)return 0;const i=(e-ni.FULL_UNTIL_DEG)/(ni.FADED_BY_DEG-ni.FULL_UNTIL_DEG);return Math.cos(i*Math.PI/2)**2}blurBySourceDisc(){const t=ni.BINS,e=ni.SOURCE_RADIUS_DEG*t/180,i=Math.max(1,Math.ceil(e)),n=[];let s=0;for(let a=-i;a<=i;a++){const o=Math.max(0,e*e-a*a),c=Math.sqrt(o);n.push(c),s+=c}if(!(s<=0)){this.scratch.set(this.radiance);for(let a=0;a<t;a++){let o=0,c=0,l=0;for(let u=-i;u<=i;u++){const d=Math.min(t-1,Math.max(0,a+u))*3,f=n[u+i];o+=this.scratch[d]*f,c+=this.scratch[d+1]*f,l+=this.scratch[d+2]*f}const h=a*3;this.radiance[h]=o/s,this.radiance[h+1]=c/s,this.radiance[h+2]=l/s}}}}class Aa{static RADIUS=880;static RENDER_ORDER=5.5;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new ni;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(ni.BINS*4),this.texture=new ra(this.texels,ni.BINS,1,Ei,qe),this.texture.minFilter=oe,this.texture.magFilter=oe,this.texture.wrapS=wi,this.texture.wrapT=wi,this.texture.needsUpdate=!0,this.material=new le({uniforms:{uSource:{value:new R(0,1,0)},uStrength:{value:0},uTint:{value:new R(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:Aa.GAIN}},vertexShader:`
5737
5794
  varying vec3 vDirection;
5738
5795
  void main() {
5739
5796
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -5761,7 +5818,7 @@ float transmissionAt(vec3 dir, float distanceM) {
5761
5818
  light = mix(vec3(grey), light, uSaturation);
5762
5819
  gl_FragColor = vec4(light * uStrength, 1.0);
5763
5820
  }
5764
- `,transparent:!0,blending:Ni,depthWrite:!1,depthTest:!0,side:Ve,fog:!1}),this.object=new Dt(new oi(Aa.RADIUS,64,32),this.material),this.object.renderOrder=Aa.RENDER_ORDER,this.object.frustumCulled=!1,this.object.visible=!1}update(t,e,i,n){const s=this.material.uniforms;if(e<=0){s.uStrength.value=0,this.object.visible=!1;return}this.computed||this.publish(),s.uSource.value.set(t.x,t.y,t.z).normalize(),s.uStrength.value=e,s.uTint.value.set(i[0],i[1],i[2]),s.uSaturation.value=n?1:Aa.MOON_SATURATION,this.object.visible=!0}publish(){const e=this.sky.compute().data;for(let i=0,n=0;n<e.length;i+=4,n+=3)this.texels[i]=Fn.toHalfFloat(e[n]),this.texels[i+1]=Fn.toHalfFloat(e[n+1]),this.texels[i+2]=Fn.toHalfFloat(e[n+2]),this.texels[i+3]=1;this.texture.needsUpdate=!0,this.computed=!0}dispose(){this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Er{constructor(t,e,i){this.group=t,this.radius=e,this.mode=i}decks=new Map;noise;halo;update(t,e){const i=dl(t).flatMap(a=>{const o={...a,darkness:a.darkness??t.cloudDarkness};return[{layer:o,parentId:o.id,key:JSON.stringify([o.id]),instance:void 0},...(o.instances??[]).map(c=>({parentId:o.id,key:JSON.stringify([o.id,c.id]),instance:c,layer:{...o,id:`${o.id}/${c.id}`,baseM:c.baseM,thicknessM:c.thicknessM,density:c.density,darkness:c.darkness??o.darkness,seed:c.seed??_d(o),instances:void 0}}))]}),n=new Set(i.map(a=>a.key));for(const[a,o]of this.decks)n.has(a)||(this.disposeDeck(o),this.decks.delete(a));[...i].sort((a,o)=>Math.abs(o.layer.baseM+o.layer.thicknessM/2-e)-Math.abs(a.layer.baseM+a.layer.thicknessM/2-e)).forEach(({layer:a,key:o,instance:c,parentId:l},h)=>{const u=c!==void 0||a.type!=="cirrus"&&(this.mode==="volume"||(a.instances?.length??0)>0);let d=this.decks.get(o);if(d&&!!d.volume!==u&&(this.disposeDeck(d),this.decks.delete(o),d=void 0),!d){if(d={layer:a,parentId:l,instance:c},u)this.noise??=vb(),d.volume=new Tl(this.noise,this.radius),this.group.add(d.volume.mesh);else{const p=xd(new st(1,1,1),a.coverage,Math.max(1,Math.abs(a.baseM-e)*.25*1400/Math.max(50,a.sizeM)),a.type==="cirrus"?1:0);d.uniforms=p.uniforms,d.surface=new Dt(yd(this.radius),p.material),this.group.add(d.surface)}this.decks.set(o,d)}d.layer=a,d.instance=c;const f=Er.deckOrder(a.baseM<e,h,i.length);d.volume&&(d.volume.update(a,e,c,c?[]:a.instances??[]),d.volume.mesh.renderOrder=f),d.surface&&d.uniforms&&(d.surface.renderOrder=f,d.surface.scale.y=a.baseM<e?-1:1,d.surface.visible=a.coverage>0&&a.density>0,d.uniforms.coverage.value=a.coverage,d.uniforms.opticalDensity.value=a.type==="cirrus"?a.density/.35:a.density,d.uniforms.darkness.value=Math.max(0,Math.min(1,a.darkness??t.cloudDarkness)),d.uniforms.layerHeight.value=Math.max(1,Math.abs(a.baseM-e)*.25*1400/Math.max(50,a.sizeM)),d.uniforms.fibrous.value=a.type==="cirrus"?1:0)}),this.halo&&this.hostHalo(this.halo)}hostHalo(t){this.halo=t;const e=t?this.cirrusDeck:void 0;for(const i of this.decks.values())i.surface&&Er.carryHalo(i.surface.material,i===e?t:void 0);t&&(t.hosted=e!==void 0)}static carryHalo(t,e){const i=t.uniforms;if(e){if(i.uHaloShown===e.deckUniforms.uHaloShown)return;Object.assign(i,e.deckUniforms),i.uPremultiplied.value=1,t.blending=zl,t.blendSrc=t.blendSrcAlpha=Fo,t.blendDst=t.blendDstAlpha=Uo}else{if(i.uPremultiplied.value===0)return;i.uHaloShown={value:0},i.uPremultiplied.value=0,t.blending=ta}}static deckOrder(t,e,i){const n=e/Math.max(1,i);return t?Aa.RENDER_ORDER+.1+.3*n:4+n}setOffsets(t,e){for(const i of this.decks.values()){const n=e[i.parentId]??t;i.volume?.uniforms.offsetM.value.set(n.x,0,n.z);const s=.25*1400/Math.max(50,i.layer.sizeM),a=_d(i.layer);i.uniforms?.fieldOffset.value.set(n.x*s+a%97,0,n.z*s+a%37)}}static sunVisibility(t,e){const i=Math.acos(Js/(Js+Math.max(0,e)))*180/Math.PI,n=Math.min(1,Math.max(0,(t+i+.84)/1.14));return n*n*(3-2*n)}setLighting(t,e,i,n){const s=Math.asin(Math.max(-1,Math.min(1,t.y/Math.max(1e-9,t.length()))))*180/Math.PI;for(const a of this.decks.values()){const o=a.volume?.uniforms??a.uniforms;o.sunDir.value.copy(t),o.sunColor.value.copy(e),a.volume||o.sunColor.value.multiplyScalar(Er.sunVisibility(s,a.layer.baseM)),o.ambientColor.value.copy(i),a.volume?.uniforms.hazeColor.value.copy(n)}}get cirrusMask(){const t=this.cirrusDeck;return t?.uniforms?{cover:t.layer.coverage,layerHeight:t.uniforms.layerHeight.value,offset:t.uniforms.fieldOffset.value,iceCrystalAlignment:t.layer.iceCrystalAlignment}:void 0}get cirrusDeck(){return[...this.decks.values()].filter(t=>t.layer.type==="cirrus"&&t.uniforms).sort((t,e)=>e.layer.coverage-t.layer.coverage)[0]}get volumes(){return[...this.decks.values()].flatMap(t=>t.volume?.mesh.visible?[t.volume]:[])}pickInstance(t){let e=1/0,i;for(const n of this.decks.values()){if(!n.instance||!n.volume?.mesh.visible)continue;const s=n.volume.uniforms,a=s.localCenter.value.clone().sub(s.offsetM.value);a.y-=s.eyeM.value+(a.x**2+a.z**2)/(2*6371e3);const o=a.dot(t);o<=0||o>=e||n.volume.transmissionAt(t)>.98||(e=o,i={layerId:n.parentId,instanceId:n.instance.id,center:a})}return i}transmissionAt(t,e=!1){let i=1;for(const n of this.decks.values())e&&n.layer.type==="cirrus"||(n.volume?i*=n.volume.transmissionAt(t):n.uniforms&&(i*=1-(n.layer.type==="cirrus"?me.iceAlphaAt:me.alphaAt)(t,n.uniforms.layerHeight.value,n.layer.coverage,n.uniforms.fieldOffset.value)*(n.layer.type==="cirrus"?.2:.95)));return i}disposeDeck(t){t.volume?.dispose(),t.surface&&(t.surface.removeFromParent(),t.surface.geometry.dispose(),t.surface.material.dispose())}dispose(){this.halo&&(this.halo.hosted=!1),this.halo=void 0;for(const t of this.decks.values())this.disposeDeck(t);this.decks.clear(),this.noise?.dispose()}}class At{static RESPONSE_EXPONENT=.74;static DAYLIGHT_ANCHOR_CD_M2=3e3;static DAYLIGHT_ANCHOR_RESPONSE=.42;static NIGHT_ANCHOR_CD_M2=172e-6;static NIGHT_ANCHOR_RESPONSE=.006;static anchoredSemiSaturation(t,e){const i=At.anchorResponse(e);return t*(1/i-1)**(1/At.RESPONSE_EXPONENT)}static anchorResponse(t){return At.lightnessOf(t)}static fromLightness(t){const e=(100*t+16)/116;return e>6/29?e**3:3*(6/29)**2*(e-4/29)}static lightnessOf(t){const e=Math.max(t,0);return(e>216/24389?116*Math.cbrt(e)-16:24389/27*e)/100}static get ADAPTATION_EXPONENT(){const t=At.anchoredSemiSaturation(At.DAYLIGHT_ANCHOR_CD_M2,At.DAYLIGHT_ANCHOR_RESPONSE),e=At.anchoredSemiSaturation(At.NIGHT_ANCHOR_CD_M2,At.NIGHT_ANCHOR_RESPONSE);return Math.log(t/e)/Math.log(At.DAYLIGHT_ANCHOR_CD_M2/At.NIGHT_ANCHOR_CD_M2)}static ROD_HALF_LUMINANCE_CD_M2=.04;static SCOTOPIC_TINT=[.853,.995,1.483];static get SEMI_SATURATION_SCALE(){return At.anchoredSemiSaturation(At.DAYLIGHT_ANCHOR_CD_M2,At.DAYLIGHT_ANCHOR_RESPONSE)/At.DAYLIGHT_ANCHOR_CD_M2**At.ADAPTATION_EXPONENT}static rodShare(t){return At.ROD_HALF_LUMINANCE_CD_M2/(At.ROD_HALF_LUMINANCE_CD_M2+Math.max(t,0))}static MOONLIT_ANCHOR_CD_M2=.0035;static MOONLIT_ANCHOR_RESPONSE=.0075;static semiSaturation(t){const e=At.MOONLIT_ANCHOR_RESPONSE,i=Math.max(t,1e-9),s=[[At.NIGHT_ANCHOR_CD_M2,At.NIGHT_ANCHOR_RESPONSE],[At.MOONLIT_ANCHOR_CD_M2,e],[At.DAYLIGHT_ANCHOR_CD_M2,At.DAYLIGHT_ANCHOR_RESPONSE]].map(([l,h])=>[Math.log(l),Math.log(At.anchoredSemiSaturation(l,h))]),a=Math.log(i),[o,c]=a<s[1][0]?[s[0],s[1]]:[s[1],s[2]];return Math.exp(o[1]+(c[1]-o[1])*(a-o[0])/(c[0]-o[0]))}static response(t,e){const i=At.RESPONSE_EXPONENT,n=Math.max(t,0)**i;return n/(n+At.semiSaturation(e)**i)}static displayOf(t,e,i,n=At.rodShare(i)){const s=(1-n)*t[1]+n*e,a=At.response(s,i),[o,c,l]=mi.linearSrgbOf(t),h=Math.max(t[1],1e-12),u=At.SCOTOPIC_TINT,d=.2126*u[0]+.7152*u[1]+.0722*u[2],f=(p,v)=>Math.max(0,(1-n)*p/h+n*v/d)*a;return[f(o,u[0]),f(c,u[1]),f(l,u[2])]}static relativeOf(t,e,i,n=At.rodShare(i)){const s=(1-n)*t[1]+n*e,a=Math.max(s,0)/At.semiSaturation(i),[o,c,l]=mi.linearSrgbOf(t),h=Math.max(t[1],1e-12),u=At.SCOTOPIC_TINT,d=.2126*u[0]+.7152*u[1]+.0722*u[2],f=(p,v)=>Math.max(0,(1-n)*p/h+n*v/d)*a;return[f(o,u[0]),f(c,u[1]),f(l,u[2])]}static respond(t){const e=Math.max(t,0)**At.RESPONSE_EXPONENT;return e/(e+1)}static relativeOfResponse(t){const e=Math.min(Math.max(t,0),.995);return(e/(1-e))**(1/At.RESPONSE_EXPONENT)}static finish(t){const e=.2126*t[0]+.7152*t[1]+.0722*t[2];if(!(e>0))return[0,0,0];const i=At.fromLightness(At.respond(e)),n=i/e,s=[t[0]*n,t[1]*n,t[2]*n],a=Math.max(...s);if(a<=1)return s;const o=(1-i)/(a-i);return s.map(c=>i+(c-i)*o)}}const l1=`
5821
+ `,transparent:!0,blending:Ni,depthWrite:!1,depthTest:!0,side:Ve,fog:!1}),this.object=new Dt(new oi(Aa.RADIUS,64,32),this.material),this.object.renderOrder=Aa.RENDER_ORDER,this.object.frustumCulled=!1,this.object.visible=!1}update(t,e,i,n){const s=this.material.uniforms;if(e<=0){s.uStrength.value=0,this.object.visible=!1;return}this.computed||this.publish(),s.uSource.value.set(t.x,t.y,t.z).normalize(),s.uStrength.value=e,s.uTint.value.set(i[0],i[1],i[2]),s.uSaturation.value=n?1:Aa.MOON_SATURATION,this.object.visible=!0}publish(){const e=this.sky.compute().data;for(let i=0,n=0;n<e.length;i+=4,n+=3)this.texels[i]=Fn.toHalfFloat(e[n]),this.texels[i+1]=Fn.toHalfFloat(e[n+1]),this.texels[i+2]=Fn.toHalfFloat(e[n+2]),this.texels[i+3]=1;this.texture.needsUpdate=!0,this.computed=!0}dispose(){this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Er{constructor(t,e,i){this.group=t,this.radius=e,this.mode=i}decks=new Map;noise;halo;update(t,e){const i=dl(t).flatMap(a=>{const o={...a,darkness:a.darkness??t.cloudDarkness};return[{layer:o,parentId:o.id,key:JSON.stringify([o.id]),instance:void 0},...(o.instances??[]).map(c=>({parentId:o.id,key:JSON.stringify([o.id,c.id]),instance:c,layer:{...o,id:`${o.id}/${c.id}`,baseM:c.baseM,thicknessM:c.thicknessM,density:c.density,darkness:c.darkness??o.darkness,seed:c.seed??_d(o),instances:void 0}}))]}),n=new Set(i.map(a=>a.key));for(const[a,o]of this.decks)n.has(a)||(this.disposeDeck(o),this.decks.delete(a));[...i].sort((a,o)=>Math.abs(o.layer.baseM+o.layer.thicknessM/2-e)-Math.abs(a.layer.baseM+a.layer.thicknessM/2-e)).forEach(({layer:a,key:o,instance:c,parentId:l},h)=>{const u=c!==void 0||a.type!=="cirrus"&&(this.mode==="volume"||(a.instances?.length??0)>0);let d=this.decks.get(o);if(d&&!!d.volume!==u&&(this.disposeDeck(d),this.decks.delete(o),d=void 0),!d){if(d={layer:a,parentId:l,instance:c},u)this.noise??=vb(),d.volume=new Tl(this.noise,this.radius),this.group.add(d.volume.mesh);else{const p=xd(new st(1,1,1),a.coverage,Math.max(1,Math.abs(a.baseM-e)*.25*1400/Math.max(50,a.sizeM)),a.type==="cirrus"?1:0);d.uniforms=p.uniforms,d.surface=new Dt(yd(this.radius),p.material),this.group.add(d.surface)}this.decks.set(o,d)}d.layer=a,d.instance=c;const f=Er.deckOrder(a.baseM<e,h,i.length);d.volume&&(d.volume.update(a,e,c,c?[]:a.instances??[]),d.volume.mesh.renderOrder=f),d.surface&&d.uniforms&&(d.surface.renderOrder=f,d.surface.scale.y=a.baseM<e?-1:1,d.surface.visible=a.coverage>0&&a.density>0,d.uniforms.coverage.value=a.coverage,d.uniforms.opticalDensity.value=a.type==="cirrus"?a.density/.35:a.density,d.uniforms.darkness.value=Math.max(0,Math.min(1,a.darkness??t.cloudDarkness)),d.uniforms.layerHeight.value=Math.max(1,Math.abs(a.baseM-e)*.25*1400/Math.max(50,a.sizeM)),d.uniforms.fibrous.value=a.type==="cirrus"?1:0)}),this.halo&&this.hostHalo(this.halo)}hostHalo(t){this.halo=t;const e=t?this.cirrusDeck:void 0;for(const i of this.decks.values())i.surface&&Er.carryHalo(i.surface.material,i===e?t:void 0);t&&(t.hosted=e!==void 0)}static carryHalo(t,e){const i=t.uniforms;if(e){if(i.uHaloShown===e.deckUniforms.uHaloShown)return;Object.assign(i,e.deckUniforms),i.uPremultiplied.value=1,t.blending=zl,t.blendSrc=t.blendSrcAlpha=Fo,t.blendDst=t.blendDstAlpha=Uo}else{if(i.uPremultiplied.value===0)return;i.uHaloShown={value:0},i.uPremultiplied.value=0,t.blending=ta}}static deckOrder(t,e,i){const n=e/Math.max(1,i);return t?Aa.RENDER_ORDER+.1+.3*n:4+n}setOffsets(t,e){for(const i of this.decks.values()){const n=e[i.parentId]??t;i.volume?.uniforms.offsetM.value.set(n.x,0,n.z);const s=.25*1400/Math.max(50,i.layer.sizeM),a=_d(i.layer);i.uniforms?.fieldOffset.value.set(n.x*s+a%97,0,n.z*s+a%37)}}static sunVisibility(t,e){const i=Math.acos(Js/(Js+Math.max(0,e)))*180/Math.PI,n=Math.min(1,Math.max(0,(t+i+.84)/1.14));return n*n*(3-2*n)}setLighting(t,e,i,n){const s=Math.asin(Math.max(-1,Math.min(1,t.y/Math.max(1e-9,t.length()))))*180/Math.PI;for(const a of this.decks.values()){const o=a.volume?.uniforms??a.uniforms;o.sunDir.value.copy(t),o.sunColor.value.copy(e),a.volume||o.sunColor.value.multiplyScalar(Er.sunVisibility(s,a.layer.baseM)),o.ambientColor.value.copy(i),a.volume?.uniforms.hazeColor.value.copy(n)}}get cirrusMask(){const t=this.cirrusDeck;return t?.uniforms?{cover:t.layer.coverage,layerHeight:t.uniforms.layerHeight.value,offset:t.uniforms.fieldOffset.value,iceCrystalAlignment:t.layer.iceCrystalAlignment}:void 0}get cirrusDeck(){return[...this.decks.values()].filter(t=>t.layer.type==="cirrus"&&t.uniforms).sort((t,e)=>e.layer.coverage-t.layer.coverage)[0]}get volumes(){return[...this.decks.values()].flatMap(t=>t.volume?.mesh.visible?[t.volume]:[])}pickInstance(t){let e=1/0,i;for(const n of this.decks.values()){if(!n.instance||!n.volume?.mesh.visible)continue;const s=n.volume.uniforms,a=s.localCenter.value.clone().sub(s.offsetM.value);a.y-=s.eyeM.value+(a.x**2+a.z**2)/(2*6371e3);const o=a.dot(t);o<=0||o>=e||n.volume.transmissionAt(t)>.98||(e=o,i={layerId:n.parentId,instanceId:n.instance.id,center:a})}return i}transmissionAt(t,e=!1){let i=1;for(const n of this.decks.values())e&&n.layer.type==="cirrus"||(n.volume?i*=n.volume.transmissionAt(t):n.uniforms&&(i*=1-(n.layer.type==="cirrus"?ge.iceAlphaAt:ge.alphaAt)(t,n.uniforms.layerHeight.value,n.layer.coverage,n.uniforms.fieldOffset.value)*(n.layer.type==="cirrus"?.2:.95)));return i}disposeDeck(t){t.volume?.dispose(),t.surface&&(t.surface.removeFromParent(),t.surface.geometry.dispose(),t.surface.material.dispose())}dispose(){this.halo&&(this.halo.hosted=!1),this.halo=void 0;for(const t of this.decks.values())this.disposeDeck(t);this.decks.clear(),this.noise?.dispose()}}class At{static RESPONSE_EXPONENT=.74;static DAYLIGHT_ANCHOR_CD_M2=3e3;static DAYLIGHT_ANCHOR_RESPONSE=.42;static NIGHT_ANCHOR_CD_M2=172e-6;static NIGHT_ANCHOR_RESPONSE=.006;static anchoredSemiSaturation(t,e){const i=At.anchorResponse(e);return t*(1/i-1)**(1/At.RESPONSE_EXPONENT)}static anchorResponse(t){return At.lightnessOf(t)}static fromLightness(t){const e=(100*t+16)/116;return e>6/29?e**3:3*(6/29)**2*(e-4/29)}static lightnessOf(t){const e=Math.max(t,0);return(e>216/24389?116*Math.cbrt(e)-16:24389/27*e)/100}static get ADAPTATION_EXPONENT(){const t=At.anchoredSemiSaturation(At.DAYLIGHT_ANCHOR_CD_M2,At.DAYLIGHT_ANCHOR_RESPONSE),e=At.anchoredSemiSaturation(At.NIGHT_ANCHOR_CD_M2,At.NIGHT_ANCHOR_RESPONSE);return Math.log(t/e)/Math.log(At.DAYLIGHT_ANCHOR_CD_M2/At.NIGHT_ANCHOR_CD_M2)}static ROD_HALF_LUMINANCE_CD_M2=.04;static SCOTOPIC_TINT=[.853,.995,1.483];static get SEMI_SATURATION_SCALE(){return At.anchoredSemiSaturation(At.DAYLIGHT_ANCHOR_CD_M2,At.DAYLIGHT_ANCHOR_RESPONSE)/At.DAYLIGHT_ANCHOR_CD_M2**At.ADAPTATION_EXPONENT}static rodShare(t){return At.ROD_HALF_LUMINANCE_CD_M2/(At.ROD_HALF_LUMINANCE_CD_M2+Math.max(t,0))}static MOONLIT_ANCHOR_CD_M2=.0035;static MOONLIT_ANCHOR_RESPONSE=.0075;static semiSaturation(t){const e=At.MOONLIT_ANCHOR_RESPONSE,i=Math.max(t,1e-9),s=[[At.NIGHT_ANCHOR_CD_M2,At.NIGHT_ANCHOR_RESPONSE],[At.MOONLIT_ANCHOR_CD_M2,e],[At.DAYLIGHT_ANCHOR_CD_M2,At.DAYLIGHT_ANCHOR_RESPONSE]].map(([l,h])=>[Math.log(l),Math.log(At.anchoredSemiSaturation(l,h))]),a=Math.log(i),[o,c]=a<s[1][0]?[s[0],s[1]]:[s[1],s[2]];return Math.exp(o[1]+(c[1]-o[1])*(a-o[0])/(c[0]-o[0]))}static response(t,e){const i=At.RESPONSE_EXPONENT,n=Math.max(t,0)**i;return n/(n+At.semiSaturation(e)**i)}static displayOf(t,e,i,n=At.rodShare(i)){const s=(1-n)*t[1]+n*e,a=At.response(s,i),[o,c,l]=mi.linearSrgbOf(t),h=Math.max(t[1],1e-12),u=At.SCOTOPIC_TINT,d=.2126*u[0]+.7152*u[1]+.0722*u[2],f=(p,v)=>Math.max(0,(1-n)*p/h+n*v/d)*a;return[f(o,u[0]),f(c,u[1]),f(l,u[2])]}static relativeOf(t,e,i,n=At.rodShare(i)){const s=(1-n)*t[1]+n*e,a=Math.max(s,0)/At.semiSaturation(i),[o,c,l]=mi.linearSrgbOf(t),h=Math.max(t[1],1e-12),u=At.SCOTOPIC_TINT,d=.2126*u[0]+.7152*u[1]+.0722*u[2],f=(p,v)=>Math.max(0,(1-n)*p/h+n*v/d)*a;return[f(o,u[0]),f(c,u[1]),f(l,u[2])]}static respond(t){const e=Math.max(t,0)**At.RESPONSE_EXPONENT;return e/(e+1)}static relativeOfResponse(t){const e=Math.min(Math.max(t,0),.995);return(e/(1-e))**(1/At.RESPONSE_EXPONENT)}static finish(t){const e=.2126*t[0]+.7152*t[1]+.0722*t[2];if(!(e>0))return[0,0,0];const i=At.fromLightness(At.respond(e)),n=i/e,s=[t[0]*n,t[1]*n,t[2]*n],a=Math.max(...s);if(a<=1)return s;const o=(1-i)/(a-i);return s.map(c=>i+(c-i)*o)}}const l1=`
5765
5822
  vec3 encodeSrgb(vec3 linear) {
5766
5823
  vec3 clamped = max(linear, vec3(0.0));
5767
5824
  vec3 low = clamped * 12.92;
@@ -5927,7 +5984,7 @@ vec3 finish(vec3 relative, vec4 overlay) {
5927
5984
  * @fileoverview Astronomy calculation library for browser scripting and Node.js.
5928
5985
  * @author Don Cross <cosinekitty@gmail.com>
5929
5986
  * @license MIT
5930
- */const T0=173.1446326846693,_a=14959787069098932e-8,Ee=.017453292519943295,Vp=.26179938779914946,os=57.29577951308232,u1=3.819718634205488,Fb=365.24217,Wp=new Date("2000-01-01T12:00:00Z"),ms=2*Math.PI,Hs=3600*(180/Math.PI),mr=484813681109536e-20,d1=10800*60,Ub=2*d1,Xp=7292115e-11,kb=d1/Math.PI,zb=-.17-5*Math.log10(kb),Ad=.996647180302104,Bb=Ad*Ad,Td=6378.1366,Hb=Td/_a,f1=81.30056,R0=.0002959122082855911,Rd=2825345909524226e-22,Dd=8459715185680659e-23,Id=1292024916781969e-23,Cd=1524358900784276e-23;function Il(r){if(r!==!0&&r!==!1)throw console.trace(),`Value is not boolean: ${r}`;return r}function Si(r){if(!Number.isFinite(r))throw console.trace(),`Value is not a finite number: ${r}`;return r}function cr(r){return r-Math.floor(r)}function Gb(r,t){const e=r.x*r.x+r.y*r.y+r.z*r.z;if(Math.abs(e)<1e-8)throw"AngleBetween: first vector is too short.";const i=t.x*t.x+t.y*t.y+t.z*t.z;if(Math.abs(i)<1e-8)throw"AngleBetween: second vector is too short.";const n=(r.x*t.x+r.y*t.y+r.z*t.z)/Math.sqrt(e*i);return n<=-1?180:n>=1?0:os*Math.acos(n)}var wt;(function(r){r.Sun="Sun",r.Moon="Moon",r.Mercury="Mercury",r.Venus="Venus",r.Earth="Earth",r.Mars="Mars",r.Jupiter="Jupiter",r.Saturn="Saturn",r.Uranus="Uranus",r.Neptune="Neptune",r.Pluto="Pluto",r.SSB="SSB",r.EMB="EMB",r.Star1="Star1",r.Star2="Star2",r.Star3="Star3",r.Star4="Star4",r.Star5="Star5",r.Star6="Star6",r.Star7="Star7",r.Star8="Star8"})(wt||(wt={}));const Vb=[wt.Star1,wt.Star2,wt.Star3,wt.Star4,wt.Star5,wt.Star6,wt.Star7,wt.Star8],Wb=[{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0}];function Xb(r){const t=Vb.indexOf(r);return t>=0?Wb[t]:null}function D0(r){const t=Xb(r);return t&&t.dist>0?t:null}var Ai;(function(r){r[r.From2000=0]="From2000",r[r.Into2000=1]="Into2000"})(Ai||(Ai={}));const ss={Mercury:[[[[4.40250710144,0,0],[.40989414977,1.48302034195,26087.9031415742],[.050462942,4.47785489551,52175.8062831484],[.00855346844,1.16520322459,78263.70942472259],[.00165590362,4.11969163423,104351.61256629678],[.00034561897,.77930768443,130439.51570787099],[7583476e-11,3.71348404924,156527.41884944518]],[[26087.90313685529,0,0],[.01131199811,6.21874197797,26087.9031415742],[.00292242298,3.04449355541,52175.8062831484],[.00075775081,6.08568821653,78263.70942472259],[.00019676525,2.80965111777,104351.61256629678]]],[[[.11737528961,1.98357498767,26087.9031415742],[.02388076996,5.03738959686,52175.8062831484],[.01222839532,3.14159265359,0],[.0054325181,1.79644363964,78263.70942472259],[.0012977877,4.83232503958,104351.61256629678],[.00031866927,1.58088495658,130439.51570787099],[7963301e-11,4.60972126127,156527.41884944518]],[[.00274646065,3.95008450011,26087.9031415742],[.00099737713,3.14159265359,0]]],[[[.39528271651,0,0],[.07834131818,6.19233722598,26087.9031415742],[.00795525558,2.95989690104,52175.8062831484],[.00121281764,6.01064153797,78263.70942472259],[.00021921969,2.77820093972,104351.61256629678],[4354065e-11,5.82894543774,130439.51570787099]],[[.0021734774,4.65617158665,26087.9031415742],[.00044141826,1.42385544001,52175.8062831484]]]],Venus:[[[[3.17614666774,0,0],[.01353968419,5.59313319619,10213.285546211],[.00089891645,5.30650047764,20426.571092422],[5477194e-11,4.41630661466,7860.4193924392],[3455741e-11,2.6996444782,11790.6290886588],[2372061e-11,2.99377542079,3930.2096962196],[1317168e-11,5.18668228402,26.2983197998],[1664146e-11,4.25018630147,1577.3435424478],[1438387e-11,4.15745084182,9683.5945811164],[1200521e-11,6.15357116043,30639.856638633]],[[10213.28554621638,0,0],[.00095617813,2.4640651111,10213.285546211],[7787201e-11,.6247848222,20426.571092422]]],[[[.05923638472,.26702775812,10213.285546211],[.00040107978,1.14737178112,20426.571092422],[.00032814918,3.14159265359,0]],[[.00287821243,1.88964962838,10213.285546211]]],[[[.72334820891,0,0],[.00489824182,4.02151831717,10213.285546211],[1658058e-11,4.90206728031,20426.571092422],[1378043e-11,1.12846591367,11790.6290886588],[1632096e-11,2.84548795207,7860.4193924392],[498395e-11,2.58682193892,9683.5945811164],[221985e-11,2.01346696541,19367.1891622328],[237454e-11,2.55136053886,15720.8387848784]],[[.00034551041,.89198706276,10213.285546211]]]],Earth:[[[[1.75347045673,0,0],[.03341656453,4.66925680415,6283.0758499914],[.00034894275,4.62610242189,12566.1516999828],[3417572e-11,2.82886579754,3.523118349],[3497056e-11,2.74411783405,5753.3848848968],[3135899e-11,3.62767041756,77713.7714681205],[2676218e-11,4.41808345438,7860.4193924392],[2342691e-11,6.13516214446,3930.2096962196],[1273165e-11,2.03709657878,529.6909650946],[1324294e-11,.74246341673,11506.7697697936],[901854e-11,2.04505446477,26.2983197998],[1199167e-11,1.10962946234,1577.3435424478],[857223e-11,3.50849152283,398.1490034082],[779786e-11,1.17882681962,5223.6939198022],[99025e-10,5.23268072088,5884.9268465832],[753141e-11,2.53339052847,5507.5532386674],[505267e-11,4.58292599973,18849.2275499742],[492392e-11,4.20505711826,775.522611324],[356672e-11,2.91954114478,.0673103028],[284125e-11,1.89869240932,796.2980068164],[242879e-11,.34481445893,5486.777843175],[317087e-11,5.84901948512,11790.6290886588],[271112e-11,.31486255375,10977.078804699],[206217e-11,4.80646631478,2544.3144198834],[205478e-11,1.86953770281,5573.1428014331],[202318e-11,2.45767790232,6069.7767545534],[126225e-11,1.08295459501,20.7753954924],[155516e-11,.83306084617,213.299095438]],[[6283.0758499914,0,0],[.00206058863,2.67823455808,6283.0758499914],[4303419e-11,2.63512233481,12566.1516999828]],[[8721859e-11,1.07253635559,6283.0758499914]]],[[],[[.00227777722,3.4137662053,6283.0758499914],[3805678e-11,3.37063423795,12566.1516999828]]],[[[1.00013988784,0,0],[.01670699632,3.09846350258,6283.0758499914],[.00013956024,3.05524609456,12566.1516999828],[308372e-10,5.19846674381,77713.7714681205],[1628463e-11,1.17387558054,5753.3848848968],[1575572e-11,2.84685214877,7860.4193924392],[924799e-11,5.45292236722,11506.7697697936],[542439e-11,4.56409151453,3930.2096962196],[47211e-10,3.66100022149,5884.9268465832],[85831e-11,1.27079125277,161000.6857376741],[57056e-11,2.01374292245,83996.84731811189],[55736e-11,5.2415979917,71430.69561812909],[174844e-11,3.01193636733,18849.2275499742],[243181e-11,4.2734953079,11790.6290886588]],[[.00103018607,1.10748968172,6283.0758499914],[1721238e-11,1.06442300386,12566.1516999828]],[[4359385e-11,5.78455133808,6283.0758499914]]]],Mars:[[[[6.20347711581,0,0],[.18656368093,5.0503710027,3340.6124266998],[.01108216816,5.40099836344,6681.2248533996],[.00091798406,5.75478744667,10021.8372800994],[.00027744987,5.97049513147,3.523118349],[.00010610235,2.93958560338,2281.2304965106],[.00012315897,.84956094002,2810.9214616052],[8926784e-11,4.15697846427,.0172536522],[8715691e-11,6.11005153139,13362.4497067992],[6797556e-11,.36462229657,398.1490034082],[7774872e-11,3.33968761376,5621.8429232104],[3575078e-11,1.6618650571,2544.3144198834],[4161108e-11,.22814971327,2942.4634232916],[3075252e-11,.85696614132,191.4482661116],[2628117e-11,.64806124465,3337.0893083508],[2937546e-11,6.07893711402,.0673103028],[2389414e-11,5.03896442664,796.2980068164],[2579844e-11,.02996736156,3344.1355450488],[1528141e-11,1.14979301996,6151.533888305],[1798806e-11,.65634057445,529.6909650946],[1264357e-11,3.62275122593,5092.1519581158],[1286228e-11,3.06796065034,2146.1654164752],[1546404e-11,2.91579701718,1751.539531416],[1024902e-11,3.69334099279,8962.4553499102],[891566e-11,.18293837498,16703.062133499],[858759e-11,2.4009381194,2914.0142358238],[832715e-11,2.46418619474,3340.5951730476],[83272e-10,4.49495782139,3340.629680352],[712902e-11,3.66335473479,1059.3819301892],[748723e-11,3.82248614017,155.4203994342],[723861e-11,.67497311481,3738.761430108],[635548e-11,2.92182225127,8432.7643848156],[655162e-11,.48864064125,3127.3133312618],[550474e-11,3.81001042328,.9803210682],[55275e-10,4.47479317037,1748.016413067],[425966e-11,.55364317304,6283.0758499914],[415131e-11,.49662285038,213.299095438],[472167e-11,3.62547124025,1194.4470102246],[306551e-11,.38052848348,6684.7479717486],[312141e-11,.99853944405,6677.7017350506],[293198e-11,4.22131299634,20.7753954924],[302375e-11,4.48618007156,3532.0606928114],[274027e-11,.54222167059,3340.545116397],[281079e-11,5.88163521788,1349.8674096588],[231183e-11,1.28242156993,3870.3033917944],[283602e-11,5.7688543494,3149.1641605882],[236117e-11,5.75503217933,3333.498879699],[274033e-11,.13372524985,3340.6797370026],[299395e-11,2.78323740866,6254.6266625236]],[[3340.61242700512,0,0],[.01457554523,3.60433733236,3340.6124266998],[.00168414711,3.92318567804,6681.2248533996],[.00020622975,4.26108844583,10021.8372800994],[3452392e-11,4.7321039319,3.523118349],[2586332e-11,4.60670058555,13362.4497067992],[841535e-11,4.45864030426,2281.2304965106]],[[.00058152577,2.04961712429,3340.6124266998],[.00013459579,2.45738706163,6681.2248533996]]],[[[.03197134986,3.76832042431,3340.6124266998],[.00298033234,4.10616996305,6681.2248533996],[.00289104742,0,0],[.00031365539,4.4465105309,10021.8372800994],[34841e-9,4.7881254926,13362.4497067992]],[[.00217310991,6.04472194776,3340.6124266998],[.00020976948,3.14159265359,0],[.00012834709,1.60810667915,6681.2248533996]]],[[[1.53033488271,0,0],[.1418495316,3.47971283528,3340.6124266998],[.00660776362,3.81783443019,6681.2248533996],[.00046179117,4.15595316782,10021.8372800994],[8109733e-11,5.55958416318,2810.9214616052],[7485318e-11,1.77239078402,5621.8429232104],[5523191e-11,1.3643630377,2281.2304965106],[382516e-10,4.49407183687,13362.4497067992],[2306537e-11,.09081579001,2544.3144198834],[1999396e-11,5.36059617709,3337.0893083508],[2484394e-11,4.9254563992,2942.4634232916],[1960195e-11,4.74249437639,3344.1355450488],[1167119e-11,2.11260868341,5092.1519581158],[1102816e-11,5.00908403998,398.1490034082],[899066e-11,4.40791133207,529.6909650946],[992252e-11,5.83861961952,6151.533888305],[807354e-11,2.10217065501,1059.3819301892],[797915e-11,3.44839203899,796.2980068164],[740975e-11,1.49906336885,2146.1654164752]],[[.01107433345,2.03250524857,3340.6124266998],[.00103175887,2.37071847807,6681.2248533996],[128772e-9,0,0],[.0001081588,2.70888095665,10021.8372800994]],[[.00044242249,.47930604954,3340.6124266998],[8138042e-11,.86998389204,6681.2248533996]]]],Jupiter:[[[[.59954691494,0,0],[.09695898719,5.06191793158,529.6909650946],[.00573610142,1.44406205629,7.1135470008],[.00306389205,5.41734730184,1059.3819301892],[.00097178296,4.14264726552,632.7837393132],[.00072903078,3.64042916389,522.5774180938],[.00064263975,3.41145165351,103.0927742186],[.00039806064,2.29376740788,419.4846438752],[.00038857767,1.27231755835,316.3918696566],[.00027964629,1.7845459182,536.8045120954],[.0001358973,5.7748104079,1589.0728952838],[8246349e-11,3.5822792584,206.1855484372],[8768704e-11,3.63000308199,949.1756089698],[7368042e-11,5.0810119427,735.8765135318],[626315e-10,.02497628807,213.299095438],[6114062e-11,4.51319998626,1162.4747044078],[4905396e-11,1.32084470588,110.2063212194],[5305285e-11,1.30671216791,14.2270940016],[5305441e-11,4.18625634012,1052.2683831884],[4647248e-11,4.69958103684,3.9321532631],[3045023e-11,4.31676431084,426.598190876],[2609999e-11,1.56667394063,846.0828347512],[2028191e-11,1.06376530715,3.1813937377],[1764763e-11,2.14148655117,1066.49547719],[1722972e-11,3.88036268267,1265.5674786264],[1920945e-11,.97168196472,639.897286314],[1633223e-11,3.58201833555,515.463871093],[1431999e-11,4.29685556046,625.6701923124],[973272e-11,4.09764549134,95.9792272178]],[[529.69096508814,0,0],[.00489503243,4.2208293947,529.6909650946],[.00228917222,6.02646855621,7.1135470008],[.00030099479,4.54540782858,1059.3819301892],[.0002072092,5.45943156902,522.5774180938],[.00012103653,.16994816098,536.8045120954],[6067987e-11,4.42422292017,103.0927742186],[5433968e-11,3.98480737746,419.4846438752],[4237744e-11,5.89008707199,14.2270940016]],[[.00047233601,4.32148536482,7.1135470008],[.00030649436,2.929777887,529.6909650946],[.00014837605,3.14159265359,0]]],[[[.02268615702,3.55852606721,529.6909650946],[.00109971634,3.90809347197,1059.3819301892],[.00110090358,0,0],[8101428e-11,3.60509572885,522.5774180938],[6043996e-11,4.25883108339,1589.0728952838],[6437782e-11,.30627119215,536.8045120954]],[[.00078203446,1.52377859742,529.6909650946]]],[[[5.20887429326,0,0],[.25209327119,3.49108639871,529.6909650946],[.00610599976,3.84115365948,1059.3819301892],[.00282029458,2.57419881293,632.7837393132],[.00187647346,2.07590383214,522.5774180938],[.00086792905,.71001145545,419.4846438752],[.00072062974,.21465724607,536.8045120954],[.00065517248,5.9799588479,316.3918696566],[.00029134542,1.67759379655,103.0927742186],[.00030135335,2.16132003734,949.1756089698],[.00023453271,3.54023522184,735.8765135318],[.00022283743,4.19362594399,1589.0728952838],[.00023947298,.2745803748,7.1135470008],[.00013032614,2.96042965363,1162.4747044078],[970336e-10,1.90669633585,206.1855484372],[.00012749023,2.71550286592,1052.2683831884],[7057931e-11,2.18184839926,1265.5674786264],[6137703e-11,6.26418240033,846.0828347512],[2616976e-11,2.00994012876,1581.959348283]],[[.0127180152,2.64937512894,529.6909650946],[.00061661816,3.00076460387,1059.3819301892],[.00053443713,3.89717383175,522.5774180938],[.00031185171,4.88276958012,536.8045120954],[.00041390269,0,0]]]],Saturn:[[[[.87401354025,0,0],[.11107659762,3.96205090159,213.299095438],[.01414150957,4.58581516874,7.1135470008],[.00398379389,.52112032699,206.1855484372],[.00350769243,3.30329907896,426.598190876],[.00206816305,.24658372002,103.0927742186],[792713e-9,3.84007056878,220.4126424388],[.00023990355,4.66976924553,110.2063212194],[.00016573588,.43719228296,419.4846438752],[.00014906995,5.76903183869,316.3918696566],[.0001582029,.93809155235,632.7837393132],[.00014609559,1.56518472,3.9321532631],[.00013160301,4.44891291899,14.2270940016],[.00015053543,2.71669915667,639.897286314],[.00013005299,5.98119023644,11.0457002639],[.00010725067,3.12939523827,202.2533951741],[5863206e-11,.23656938524,529.6909650946],[5227757e-11,4.20783365759,3.1813937377],[6126317e-11,1.76328667907,277.0349937414],[5019687e-11,3.17787728405,433.7117378768],[459255e-10,.61977744975,199.0720014364],[4005867e-11,2.24479718502,63.7358983034],[2953796e-11,.98280366998,95.9792272178],[387367e-10,3.22283226966,138.5174968707],[2461186e-11,2.03163875071,735.8765135318],[3269484e-11,.77492638211,949.1756089698],[1758145e-11,3.2658010994,522.5774180938],[1640172e-11,5.5050445305,846.0828347512],[1391327e-11,4.02333150505,323.5054166574],[1580648e-11,4.37265307169,309.2783226558],[1123498e-11,2.83726798446,415.5524906121],[1017275e-11,3.71700135395,227.5261894396],[848642e-11,3.1915017083,209.3669421749]],[[213.2990952169,0,0],[.01297370862,1.82834923978,213.299095438],[.00564345393,2.88499717272,7.1135470008],[.00093734369,1.06311793502,426.598190876],[.00107674962,2.27769131009,206.1855484372],[.00040244455,2.04108104671,220.4126424388],[.00019941774,1.2795439047,103.0927742186],[.00010511678,2.7488034213,14.2270940016],[6416106e-11,.38238295041,639.897286314],[4848994e-11,2.43037610229,419.4846438752],[4056892e-11,2.92133209468,110.2063212194],[3768635e-11,3.6496533078,3.9321532631]],[[.0011644133,1.17988132879,7.1135470008],[.00091841837,.0732519584,213.299095438],[.00036661728,0,0],[.00015274496,4.06493179167,206.1855484372]]],[[[.04330678039,3.60284428399,213.299095438],[.00240348302,2.85238489373,426.598190876],[.00084745939,0,0],[.00030863357,3.48441504555,220.4126424388],[.00034116062,.57297307557,206.1855484372],[.0001473407,2.11846596715,639.897286314],[9916667e-11,5.79003188904,419.4846438752],[6993564e-11,4.7360468972,7.1135470008],[4807588e-11,5.43305312061,316.3918696566]],[[.00198927992,4.93901017903,213.299095438],[.00036947916,3.14159265359,0],[.00017966989,.5197943111,426.598190876]]],[[[9.55758135486,0,0],[.52921382865,2.39226219573,213.299095438],[.01873679867,5.2354960466,206.1855484372],[.01464663929,1.64763042902,426.598190876],[.00821891141,5.93520042303,316.3918696566],[.00547506923,5.0153261898,103.0927742186],[.0037168465,2.27114821115,220.4126424388],[.00361778765,3.13904301847,7.1135470008],[.00140617506,5.70406606781,632.7837393132],[.00108974848,3.29313390175,110.2063212194],[.00069006962,5.94099540992,419.4846438752],[.00061053367,.94037691801,639.897286314],[.00048913294,1.55733638681,202.2533951741],[.00034143772,.19519102597,277.0349937414],[.00032401773,5.47084567016,949.1756089698],[.00020936596,.46349251129,735.8765135318],[9796004e-11,5.20477537945,1265.5674786264],[.00011993338,5.98050967385,846.0828347512],[208393e-9,1.52102476129,433.7117378768],[.00015298404,3.0594381494,529.6909650946],[6465823e-11,.17732249942,1052.2683831884],[.00011380257,1.7310542704,522.5774180938],[3419618e-11,4.94550542171,1581.959348283]],[[.0618298134,.2584351148,213.299095438],[.00506577242,.71114625261,206.1855484372],[.00341394029,5.79635741658,426.598190876],[.00188491195,.47215589652,220.4126424388],[.00186261486,3.14159265359,0],[.00143891146,1.40744822888,7.1135470008]],[[.00436902572,4.78671677509,213.299095438]]]],Uranus:[[[[5.48129294297,0,0],[.09260408234,.89106421507,74.7815985673],[.01504247898,3.6271926092,1.4844727083],[.00365981674,1.89962179044,73.297125859],[.00272328168,3.35823706307,149.5631971346],[.00070328461,5.39254450063,63.7358983034],[.00068892678,6.09292483287,76.2660712756],[.00061998615,2.26952066061,2.9689454166],[.00061950719,2.85098872691,11.0457002639],[.0002646877,3.14152083966,71.8126531507],[.00025710476,6.11379840493,454.9093665273],[.0002107885,4.36059339067,148.0787244263],[.00017818647,1.74436930289,36.6485629295],[.00014613507,4.73732166022,3.9321532631],[.00011162509,5.8268179635,224.3447957019],[.0001099791,.48865004018,138.5174968707],[9527478e-11,2.95516862826,35.1640902212],[7545601e-11,5.236265824,109.9456887885],[4220241e-11,3.23328220918,70.8494453042],[40519e-9,2.277550173,151.0476698429],[3354596e-11,1.0654900738,4.4534181249],[2926718e-11,4.62903718891,9.5612275556],[349034e-10,5.48306144511,146.594251718],[3144069e-11,4.75199570434,77.7505439839],[2922333e-11,5.35235361027,85.8272988312],[2272788e-11,4.36600400036,70.3281804424],[2051219e-11,1.51773566586,.1118745846],[2148602e-11,.60745949945,38.1330356378],[1991643e-11,4.92437588682,277.0349937414],[1376226e-11,2.04283539351,65.2203710117],[1666902e-11,3.62744066769,380.12776796],[1284107e-11,3.11347961505,202.2533951741],[1150429e-11,.93343589092,3.1813937377],[1533221e-11,2.58594681212,52.6901980395],[1281604e-11,.54271272721,222.8603229936],[1372139e-11,4.19641530878,111.4301614968],[1221029e-11,.1990065003,108.4612160802],[946181e-11,1.19253165736,127.4717966068],[1150989e-11,4.17898916639,33.6796175129]],[[74.7815986091,0,0],[.00154332863,5.24158770553,74.7815985673],[.00024456474,1.71260334156,1.4844727083],[9258442e-11,.4282973235,11.0457002639],[8265977e-11,1.50218091379,63.7358983034],[915016e-10,1.41213765216,149.5631971346]]],[[[.01346277648,2.61877810547,74.7815985673],[623414e-9,5.08111189648,149.5631971346],[.00061601196,3.14159265359,0],[9963722e-11,1.61603805646,76.2660712756],[992616e-10,.57630380333,73.297125859]],[[.00034101978,.01321929936,74.7815985673]]],[[[19.21264847206,0,0],[.88784984413,5.60377527014,74.7815985673],[.03440836062,.32836099706,73.297125859],[.0205565386,1.7829515933,149.5631971346],[.0064932241,4.52247285911,76.2660712756],[.00602247865,3.86003823674,63.7358983034],[.00496404167,1.40139935333,454.9093665273],[.00338525369,1.58002770318,138.5174968707],[.00243509114,1.57086606044,71.8126531507],[.00190522303,1.99809394714,1.4844727083],[.00161858838,2.79137786799,148.0787244263],[.00143706183,1.38368544947,11.0457002639],[.00093192405,.17437220467,36.6485629295],[.00071424548,4.24509236074,224.3447957019],[.00089806014,3.66105364565,109.9456887885],[.00039009723,1.66971401684,70.8494453042],[.00046677296,1.39976401694,35.1640902212],[.00039025624,3.36234773834,277.0349937414],[.00036755274,3.88649278513,146.594251718],[.00030348723,.70100838798,151.0476698429],[.00029156413,3.180563367,77.7505439839],[.00022637073,.72518687029,529.6909650946],[.00011959076,1.7504339214,984.6003316219],[.00025620756,5.25656086672,380.12776796]],[[.01479896629,3.67205697578,74.7815985673]]]],Neptune:[[[[5.31188633046,0,0],[.0179847553,2.9010127389,38.1330356378],[.01019727652,.48580922867,1.4844727083],[.00124531845,4.83008090676,36.6485629295],[.00042064466,5.41054993053,2.9689454166],[.00037714584,6.09221808686,35.1640902212],[.00033784738,1.24488874087,76.2660712756],[.00016482741,7727998e-11,491.5579294568],[9198584e-11,4.93747051954,39.6175083461],[899425e-10,.27462171806,175.1660598002]],[[38.13303563957,0,0],[.00016604172,4.86323329249,1.4844727083],[.00015744045,2.27887427527,38.1330356378]]],[[[.03088622933,1.44104372644,38.1330356378],[.00027780087,5.91271884599,76.2660712756],[.00027623609,0,0],[.00015355489,2.52123799551,36.6485629295],[.00015448133,3.50877079215,39.6175083461]]],[[[30.07013205828,0,0],[.27062259632,1.32999459377,38.1330356378],[.01691764014,3.25186135653,36.6485629295],[.00807830553,5.18592878704,1.4844727083],[.0053776051,4.52113935896,35.1640902212],[.00495725141,1.5710564165,491.5579294568],[.00274571975,1.84552258866,175.1660598002],[.0001201232,1.92059384991,1021.2488945514],[.00121801746,5.79754470298,76.2660712756],[.00100896068,.3770272493,73.297125859],[.00135134092,3.37220609835,39.6175083461],[7571796e-11,1.07149207335,388.4651552382]]]]};function Yb(r){var t,e,i,n,s,a,o;const c=2e3+(r-14)/Fb;return c<-500?(t=(c-1820)/100,-20+32*t*t):c<500?(t=c/100,e=t*t,i=t*e,n=e*e,s=e*i,a=i*i,10583.6-1014.41*t+33.78311*e-5.952053*i-.1798452*n+.022174192*s+.0090316521*a):c<1600?(t=(c-1e3)/100,e=t*t,i=t*e,n=e*e,s=e*i,a=i*i,1574.2-556.01*t+71.23472*e+.319781*i-.8503463*n-.005050998*s+.0083572073*a):c<1700?(t=c-1600,e=t*t,i=t*e,120-.9808*t-.01532*e+i/7129):c<1800?(t=c-1700,e=t*t,i=t*e,n=e*e,8.83+.1603*t-.0059285*e+13336e-8*i-n/1174e3):c<1860?(t=c-1800,e=t*t,i=t*e,n=e*e,s=e*i,a=i*i,o=i*n,13.72-.332447*t+.0068612*e+.0041116*i-37436e-8*n+121272e-10*s-1699e-10*a+875e-12*o):c<1900?(t=c-1860,e=t*t,i=t*e,n=e*e,s=e*i,7.62+.5737*t-.251754*e+.01680668*i-.0004473624*n+s/233174):c<1920?(t=c-1900,e=t*t,i=t*e,n=e*e,-2.79+1.494119*t-.0598939*e+.0061966*i-197e-6*n):c<1941?(t=c-1920,e=t*t,i=t*e,21.2+.84493*t-.0761*e+.0020936*i):c<1961?(t=c-1950,e=t*t,i=t*e,29.07+.407*t-e/233+i/2547):c<1986?(t=c-1975,e=t*t,i=t*e,45.45+1.067*t-e/260-i/718):c<2005?(t=c-2e3,e=t*t,i=t*e,n=e*e,s=e*i,63.86+.3345*t-.060374*e+.0017275*i+651814e-9*n+2373599e-11*s):c<2050?(t=c-2e3,62.92+.32217*t+.005589*t*t):c<2150?(t=(c-1820)/100,-20+32*t*t-.5628*(2150-c)):(t=(c-1820)/100,-20+32*t*t)}let qb=Yb;function Yp(r){return r+qb(r)/86400}class Tr{constructor(t){if(t instanceof Tr){this.date=t.date,this.ut=t.ut,this.tt=t.tt;return}const e=1e3*3600*24;if(t instanceof Date&&Number.isFinite(t.getTime())){this.date=t,this.ut=(t.getTime()-Wp.getTime())/e,this.tt=Yp(this.ut);return}if(Number.isFinite(t)){this.date=new Date(Wp.getTime()+t*e),this.ut=t,this.tt=Yp(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(t){let e=new Tr(t);for(;;){const i=t-e.tt;if(Math.abs(i)<1e-12)return e;e=e.AddDays(i)}}toString(){return this.date.toISOString()}AddDays(t){return new Tr(this.ut+t)}}function $e(r){return r instanceof Tr?r:new Tr(r)}function $b(r){function t(d){return d%Ub*mr}const e=r.tt/36525,i=t(128710479305e-5+e*1295965810481e-4),n=t(335779.526232+e*17395272628478e-4),s=t(107226070369e-5+e*1602961601209e-3),a=t(450160.398036-e*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*e)*o+33386*c,h=(92052331+9086*e)*c+15377*o,u=2*(n-s+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*e)*o-13696*c,h+=(5730336-3015*e)*c-4587*o,u=2*(n+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*e)*o+2796*c,h+=(978459-485*e)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*e)*o-698*c,h+=(-897492+470*e)*c-291*o,o=Math.sin(i),c=Math.cos(i),l+=(1475877-3633*e)*o+11817*c,h+=(73871-184*e)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function p1(r){var t=r.tt/36525,e=((((-434e-10*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406;return e/3600}var Fc;function Ko(r){if(!Fc||Math.abs(Fc.tt-r.tt)>1e-6){const t=$b(r),e=p1(r),i=e+t.deps/3600;Fc={tt:r.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*Ee)/15,mobl:e,tobl:i}}return Fc}function Kb(r,t){const e=r*Ee,i=Math.cos(e),n=Math.sin(e);return[t[0],t[1]*i-t[2]*n,t[1]*n+t[2]*i]}function Zb(r,t){return Kb(p1(r),t)}function Jb(r){const t=r.tt/36525;function e(Ct,_t){const kt=[];let zt;for(zt=0;zt<=_t-Ct;++zt)kt.push(0);return{min:Ct,array:kt}}function i(Ct,_t,kt,zt){const Bt=[];for(let Me=0;Me<=_t-Ct;++Me)Bt.push(e(kt,zt));return{min:Ct,array:Bt}}function n(Ct,_t,kt){const zt=Ct.array[_t-Ct.min];return zt.array[kt-zt.min]}function s(Ct,_t,kt,zt){const Bt=Ct.array[_t-Ct.min];Bt.array[kt-Bt.min]=zt}let a,o,c,l,h,u,d,f,p,v,m,g,S,y,M,b,w,T,x,A,C,I,P,V=i(-6,6,1,4),X=i(-6,6,1,4);function L(Ct,_t){return n(V,Ct,_t)}function B(Ct,_t){return n(X,Ct,_t)}function k(Ct,_t,kt){return s(V,Ct,_t,kt)}function $(Ct,_t,kt){return s(X,Ct,_t,kt)}function tt(Ct,_t,kt,zt,Bt){Bt(Ct*kt-_t*zt,_t*kt+Ct*zt)}function J(Ct){return Math.sin(ms*Ct)}d=t*t,p=0,P=0,m=0,g=3422.7;var it=J(.19833+.05611*t),rt=J(.27869+.04508*t),Vt=J(.16827-.36903*t),Jt=J(.34734-5.37261*t),qt=J(.10498-5.37899*t),q=J(.42681-.41855*t),at=J(.14943-5.37511*t);for(T=.84*it+.31*rt+14.27*Vt+7.26*Jt+.28*qt+.24*q,x=2.94*it+.31*rt+14.27*Vt+9.34*Jt+1.12*qt+.83*q,A=-6.4*it-1.89*q,C=.21*it+.31*rt+14.27*Vt-88.7*Jt-15.3*qt+.24*q-1.86*at,I=T-A,f=-3332e-9*J(.59734-5.37261*t)-539e-9*J(.35498-5.37899*t)-64e-9*J(.39943-5.37511*t),S=ms*cr(.60643382+1336.85522467*t-313e-8*d)+T/Hs,y=ms*cr(.37489701+1325.55240982*t+2565e-8*d)+x/Hs,M=ms*cr(.99312619+99.99735956*t-44e-8*d)+A/Hs,b=ms*cr(.25909118+1342.2278298*t-892e-8*d)+C/Hs,w=ms*cr(.82736186+1236.85308708*t-397e-8*d)+I/Hs,h=1;h<=4;++h){switch(h){case 1:c=y,o=4,l=1.000002208;break;case 2:c=M,o=3,l=.997504612-.002495388*t;break;case 3:c=b,o=4,l=1.000002708+139.978*f;break;case 4:c=w,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(k(0,h,1),k(1,h,Math.cos(c)*l),$(0,h,0),$(1,h,Math.sin(c)*l),u=2;u<=o;++u)tt(L(u-1,h),B(u-1,h),L(1,h),B(1,h),(Ct,_t)=>(k(u,h,Ct),$(u,h,_t)));for(u=1;u<=o;++u)k(-u,h,L(u,h)),$(-u,h,-B(u,h))}function nt(Ct,_t,kt,zt){for(var Bt={x:1,y:0},Me=[0,Ct,_t,kt,zt],xe=1;xe<=4;++xe)Me[xe]!==0&&tt(Bt.x,Bt.y,L(Me[xe],xe),B(Me[xe],xe),(Ke,He)=>(Bt.x=Ke,Bt.y=He));return Bt}function z(Ct,_t,kt,zt,Bt,Me,xe,Ke){var He=nt(Bt,Me,xe,Ke);p+=Ct*He.y,P+=_t*He.y,m+=kt*He.x,g+=zt*He.x}z(13.902,14.06,-.001,.2607,0,0,0,4),z(.403,-4.01,.394,.0023,0,0,0,3),z(2369.912,2373.36,.601,28.2333,0,0,0,2),z(-125.154,-112.79,-.725,-.9781,0,0,0,1),z(1.979,6.98,-.445,.0433,1,0,0,4),z(191.953,192.72,.029,3.0861,1,0,0,2),z(-8.466,-13.51,.455,-.1093,1,0,0,1),z(22639.5,22609.07,.079,186.5398,1,0,0,0),z(18.609,3.59,-.094,.0118,1,0,0,-1),z(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),z(3.215,5.44,.192,-.0386,1,0,0,-3),z(-38.428,-38.64,.001,.6008,1,0,0,-4),z(-.393,-1.43,-.092,.0086,1,0,0,-6),z(-.289,-1.59,.123,-.0053,0,1,0,4),z(-24.42,-25.1,.04,-.3,0,1,0,2),z(18.023,17.93,.007,.1494,0,1,0,1),z(-668.146,-126.98,-1.302,-.3997,0,1,0,0),z(.56,.32,-.001,-.0037,0,1,0,-1),z(-165.145,-165.06,.054,1.9178,0,1,0,-2),z(-1.877,-6.46,-.416,.0339,0,1,0,-4),z(.213,1.02,-.074,.0054,2,0,0,4),z(14.387,14.78,-.017,.2833,2,0,0,2),z(-.586,-1.2,.054,-.01,2,0,0,1),z(769.016,767.96,.107,10.1657,2,0,0,0),z(1.75,2.01,-.018,.0155,2,0,0,-1),z(-211.656,-152.53,5.679,-.3039,2,0,0,-2),z(1.225,.91,-.03,-.0088,2,0,0,-3),z(-30.773,-34.07,-.308,.3722,2,0,0,-4),z(-.57,-1.4,-.074,.0109,2,0,0,-6),z(-2.921,-11.75,.787,-.0484,1,1,0,2),z(1.267,1.52,-.022,.0164,1,1,0,1),z(-109.673,-115.18,.461,-.949,1,1,0,0),z(-205.962,-182.36,2.056,1.4437,1,1,0,-2),z(.233,.36,.012,-.0025,1,1,0,-3),z(-4.391,-9.66,-.471,.0673,1,1,0,-4),z(.283,1.53,-.111,.006,1,-1,0,4),z(14.577,31.7,-1.54,.2302,1,-1,0,2),z(147.687,138.76,.679,1.1528,1,-1,0,0),z(-1.089,.55,.021,0,1,-1,0,-1),z(28.475,23.59,-.443,-.2257,1,-1,0,-2),z(-.276,-.38,-.006,-.0036,1,-1,0,-3),z(.636,2.27,.146,-.0102,1,-1,0,-4),z(-.189,-1.68,.131,-.0028,0,2,0,2),z(-7.486,-.66,-.037,-.0086,0,2,0,0),z(-8.096,-16.35,-.74,.0918,0,2,0,-2),z(-5.741,-.04,0,-9e-4,0,0,2,2),z(.255,0,0,0,0,0,2,1),z(-411.608,-.2,0,-.0124,0,0,2,0),z(.584,.84,0,.0071,0,0,2,-1),z(-55.173,-52.14,0,-.1052,0,0,2,-2),z(.254,.25,0,-.0017,0,0,2,-3),z(.025,-1.67,0,.0031,0,0,2,-4),z(1.06,2.96,-.166,.0243,3,0,0,2),z(36.124,50.64,-1.3,.6215,3,0,0,0),z(-13.193,-16.4,.258,-.1187,3,0,0,-2),z(-1.187,-.74,.042,.0074,3,0,0,-4),z(-.293,-.31,-.002,.0046,3,0,0,-6),z(-.29,-1.45,.116,-.0051,2,1,0,2),z(-7.649,-10.56,.259,-.1038,2,1,0,0),z(-8.627,-7.59,.078,-.0192,2,1,0,-2),z(-2.74,-2.54,.022,.0324,2,1,0,-4),z(1.181,3.32,-.212,.0213,2,-1,0,2),z(9.703,11.67,-.151,.1268,2,-1,0,0),z(-.352,-.37,.001,-.0028,2,-1,0,-1),z(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),z(.36,.2,-.012,-.0043,2,-1,0,-4),z(-1.167,-1.25,.008,-.0106,1,2,0,0),z(-7.412,-6.12,.117,.0484,1,2,0,-2),z(-.311,-.65,-.032,.0044,1,2,0,-4),z(.757,1.82,-.105,.0112,1,-2,0,2),z(2.58,2.32,.027,.0196,1,-2,0,0),z(2.533,2.4,-.014,-.0212,1,-2,0,-2),z(-.344,-.57,-.025,.0036,0,3,0,-2),z(-.992,-.02,0,0,1,0,2,2),z(-45.099,-.02,0,-.001,1,0,2,0),z(-.179,-9.52,0,-.0833,1,0,2,-2),z(-.301,-.33,0,.0014,1,0,2,-4),z(-6.382,-3.37,0,-.0481,1,0,-2,2),z(39.528,85.13,0,-.7136,1,0,-2,0),z(9.366,.71,0,-.0112,1,0,-2,-2),z(.202,.02,0,0,1,0,-2,-4),z(.415,.1,0,.0013,0,1,2,0),z(-2.152,-2.26,0,-.0066,0,1,2,-2),z(-1.44,-1.3,0,.0014,0,1,-2,2),z(.384,-.04,0,0,0,1,-2,-2),z(1.938,3.6,-.145,.0401,4,0,0,0),z(-.952,-1.58,.052,-.013,4,0,0,-2),z(-.551,-.94,.032,-.0097,3,1,0,0),z(-.482,-.57,.005,-.0045,3,1,0,-2),z(.681,.96,-.026,.0115,3,-1,0,0),z(-.297,-.27,.002,-9e-4,2,2,0,-2),z(.254,.21,-.003,0,2,-2,0,-2),z(-.25,-.22,.004,.0014,1,3,0,-2),z(-3.996,0,0,4e-4,2,0,2,0),z(.557,-.75,0,-.009,2,0,2,-2),z(-.459,-.38,0,-.0053,2,0,-2,2),z(-1.298,.74,0,4e-4,2,0,-2,0),z(.538,1.14,0,-.0141,2,0,-2,-2),z(.263,.02,0,0,1,1,2,0),z(.426,.07,0,-6e-4,1,1,-2,-2),z(-.304,.03,0,3e-4,1,-1,2,0),z(-.372,-.19,0,-.0027,1,-1,-2,2),z(.418,0,0,0,0,0,4,0),z(-.33,-.04,0,0,3,0,2,0);function Tt(Ct,_t,kt,zt,Bt){return Ct*nt(_t,kt,zt,Bt).y}v=0,v+=Tt(-526.069,0,0,1,-2),v+=Tt(-3.352,0,0,1,-4),v+=Tt(44.297,1,0,1,-2),v+=Tt(-6,1,0,1,-4),v+=Tt(20.599,-1,0,1,0),v+=Tt(-30.598,-1,0,1,-2),v+=Tt(-24.649,-2,0,1,0),v+=Tt(-2,-2,0,1,-2),v+=Tt(-22.571,0,1,1,-2),v+=Tt(10.985,0,-1,1,-2),p+=.82*J(.7736-62.5512*t)+.31*J(.0466-125.1025*t)+.35*J(.5785-25.1042*t)+.66*J(.4591+1335.8075*t)+.64*J(.313-91.568*t)+1.14*J(.148+1331.2898*t)+.21*J(.5918+1056.5859*t)+.44*J(.5784+1322.8595*t)+.24*J(.2275-5.7374*t)+.28*J(.2965+2.6929*t)+.33*J(.3132+6.3368*t),a=b+P/Hs;let Nt=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+v;return{geo_eclip_lon:ms*cr((S+p/Hs)/ms),geo_eclip_lat:Math.PI/(180*3600)*Nt,distance_au:Hs*Hb/(.999953253*g)}}function m1(r,t){return[r.rot[0][0]*t[0]+r.rot[1][0]*t[1]+r.rot[2][0]*t[2],r.rot[0][1]*t[0]+r.rot[1][1]*t[1]+r.rot[2][1]*t[2],r.rot[0][2]*t[0]+r.rot[1][2]*t[1]+r.rot[2][2]*t[2]]}function Cl(r,t,e){const i=I0(t,e);return m1(i,r)}function I0(r,t){const e=r.tt/36525;let i=84381.406,n=((((-951e-10*e+132851e-9)*e-.00114045)*e-1.0790069)*e+5038.481507)*e,s=((((3337e-10*e-467e-9)*e-.00772503)*e+.0512623)*e-.025754)*e+i,a=((((-56e-9*e+170663e-9)*e-.00121197)*e-2.3814292)*e+10.556403)*e;i*=mr,n*=mr,s*=mr,a*=mr;const o=Math.sin(i),c=Math.cos(i),l=Math.sin(-n),h=Math.cos(-n),u=Math.sin(-s),d=Math.cos(-s),f=Math.sin(a),p=Math.cos(a),v=p*h-l*f*d,m=p*l*c+f*d*h*c-o*f*u,g=p*l*o+f*d*h*o+c*f*u,S=-f*h-l*p*d,y=-f*l*c+p*d*h*c-o*p*u,M=-f*l*o+p*d*h*o+c*p*u,b=l*u,w=-u*h*c-o*d,T=-u*h*o+d*c;if(t===Ai.Into2000)return new sa([[v,m,g],[S,y,M],[b,w,T]]);if(t===Ai.From2000)return new sa([[v,S,b],[m,y,w],[g,M,T]]);throw"Invalid precess direction"}function jb(r){const t=.779057273264+.00273781191135448*r.ut,e=r.ut%1;let i=360*((t+e)%1);return i<0&&(i+=360),i}let Uc;function $l(r){if(!Uc||Uc.tt!==r.tt){const t=r.tt/36525;let e=15*Ko(r).ee;const i=jb(r);let s=((e+.014506+((((-368e-10*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+i)%360/15;s<0&&(s+=24),Uc={tt:r.tt,st:s}}return Uc.st}function Qb(r){const t=$e(r);return $l(t)}function g1(r,t){const e=r.latitude*Ee,i=Math.sin(e),n=Math.cos(e),s=1/Math.hypot(n,Ad*i),a=Bb*s,o=r.height/1e3,c=Td*s+o,l=Td*a+o,h=(15*t+r.longitude)*Ee,u=Math.sin(h),d=Math.cos(h);return{pos:[c*n*d/_a,c*n*u/_a,l*i/_a],vel:[-Xp*c*n*u*86400/_a,Xp*c*n*d*86400/_a,0]}}function Pd(r,t,e){const i=C0(t,e);return m1(i,r)}function C0(r,t){const e=Ko(r),i=e.mobl*Ee,n=e.tobl*Ee,s=e.dpsi*mr,a=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(s),u=Math.sin(s),d=h,f=-u*a,p=-u*o,v=u*c,m=h*a*c+o*l,g=h*o*c-a*l,S=u*l,y=h*a*l-o*c,M=h*o*l+a*c;if(t===Ai.From2000)return new sa([[d,v,S],[f,m,y],[p,g,M]]);if(t===Ai.Into2000)return new sa([[d,f,p],[v,m,g],[S,y,M]]);throw"Invalid precess direction"}function P0(r,t,e){return e===Ai.Into2000?Cl(Pd(r,t,e),t,e):Pd(Cl(r,t,e),t,e)}function t5(r,t){const e=$l(r),i=g1(t,e).pos;return P0(i,r,Ai.Into2000)}class Fe{constructor(t,e,i,n){this.x=t,this.y=e,this.z=i,this.t=n}Length(){return Math.hypot(this.x,this.y,this.z)}}class js{constructor(t,e,i,n,s,a,o){this.x=t,this.y=e,this.z=i,this.vx=n,this.vy=s,this.vz=a,this.t=o}}class Kl{constructor(t,e,i){this.lat=Si(t),this.lon=Si(e),this.dist=Si(i)}}class Ld{constructor(t,e,i,n){this.ra=Si(t),this.dec=Si(e),this.dist=Si(i),this.vec=n}}class sa{constructor(t){this.rot=t}}class e5{constructor(t,e,i,n){this.azimuth=Si(t),this.altitude=Si(e),this.ra=Si(i),this.dec=Si(n)}}class i5{constructor(t,e,i){this.vec=t,this.elat=Si(e),this.elon=Si(i)}}function v1(r,t){return new Fe(r[0],r[1],r[2],t)}function n5(r,t){const e=v1(r,t),i=e.x*e.x+e.y*e.y,n=Math.sqrt(i+e.z*e.z);if(i===0){if(e.z===0)throw"Indeterminate sky coordinates";return new Ld(0,e.z<0?-90:90,n,e)}let s=u1*Math.atan2(e.y,e.x);s<0&&(s+=24);const a=os*Math.atan2(r[2],Math.sqrt(i));return new Ld(s,a,n,e)}function Xh(r,t){const e=r*Ee,i=Math.cos(e),n=Math.sin(e);return[i*t[0]+n*t[1],i*t[1]-n*t[0],t[2]]}function M1(r,t,e,i,n){let s=$e(r);L0(t),Si(e),Si(i);const a=Math.sin(t.latitude*Ee),o=Math.cos(t.latitude*Ee),c=Math.sin(t.longitude*Ee),l=Math.cos(t.longitude*Ee),h=Math.sin(i*Ee),u=Math.cos(i*Ee),d=Math.sin(e*Vp),f=Math.cos(e*Vp);let p=[o*l,o*c,a],v=[-a*l,-a*c,o],m=[c,-l,0];const g=-15*$l(s);let S=Xh(g,p),y=Xh(g,v),M=Xh(g,m),b=[u*f,u*d,h];const w=b[0]*S[0]+b[1]*S[1]+b[2]*S[2],T=b[0]*y[0]+b[1]*y[1]+b[2]*y[2],x=b[0]*M[0]+b[1]*M[1]+b[2]*M[2];let A=Math.hypot(T,x),C;A>0?(C=-os*Math.atan2(x,T),C<0&&(C+=360)):C=0;let I=os*Math.atan2(A,w),P=e,V=i;if(n){let X=I,L=T1(n,90-I);if(I-=L,L>0&&I>3e-4){const B=Math.sin(I*Ee),k=Math.cos(I*Ee),$=Math.sin(X*Ee),tt=Math.cos(X*Ee),J=[];for(let it=0;it<3;++it)J.push((b[it]-tt*S[it])/$*B+S[it]*k);A=Math.hypot(J[0],J[1]),A>0?(P=u1*Math.atan2(J[1],J[0]),P<0&&(P+=24)):P=0,V=os*Math.atan2(J[2],A)}}return new e5(C,90-I,P,V)}function L0(r){if(!(r instanceof O0))throw`Not an instance of the Observer class: ${r}`;if(Si(r.latitude),Si(r.longitude),Si(r.height),r.latitude<-90||r.latitude>90)throw`Latitude ${r.latitude} is out of range. Must be -90..+90.`;return r}class O0{constructor(t,e,i){this.latitude=t,this.longitude=e,this.height=i,L0(this)}}function s5(r){const t=$e(r).AddDays(-1/T0),e=Dr(ss.Earth,t),i=[-e.x,-e.y,-e.z],[n,s,a]=P0(i,t,Ai.From2000),o=Ee*Ko(t).tobl,c=Math.cos(o),l=Math.sin(o),h=new Fe(n,s,a,t);return x1(h,c,l)}function a5(r,t,e,i,n){L0(e),Il(i),Il(n);const s=$e(t),a=t5(s,e),o=Vd(r,s,n),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=P0(c,s,Ai.From2000);return n5(l,s)}function r5(r,t,e){const i=$e(r),n=$l(i);let s=g1(t,n).pos;return v1(s,i)}function x1(r,t,e){const i=r.x,n=r.y*t+r.z*e,s=-r.y*e+r.z*t,a=Math.hypot(i,n);let o=0;a>0&&(o=os*Math.atan2(n,i),o<0&&(o+=360));let c=os*Math.atan2(s,a),l=new Fe(i,n,s,r.t);return new i5(l,c,o)}function Od(r){const t=Ko(r.t),e=[r.x,r.y,r.z],i=Cl(e,r.t,Ai.From2000),[n,s,a]=Pd(i,r.t,Ai.From2000),o=new Fe(n,s,a,r.t),c=t.tobl*Ee;return x1(o,Math.cos(c),Math.sin(c))}function Fr(r){const t=$e(r),e=Jb(t),i=e.distance_au*Math.cos(e.geo_eclip_lat),n=[i*Math.cos(e.geo_eclip_lon),i*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],s=Zb(t,n),a=Cl(s,t,Ai.Into2000);return new Fe(a[0],a[1],a[2],t)}function y1(r){const t=$e(r),e=1e-5,i=t.AddDays(-e),n=t.AddDays(+e),s=Fr(i),a=Fr(n);return new js((s.x+a.x)/2,(s.y+a.y)/2,(s.z+a.z)/2,(a.x-s.x)/(2*e),(a.y-s.y)/(2*e),(a.z-s.z)/(2*e),t)}function o5(r){const t=$e(r),e=y1(t),i=1+f1;return new js(e.x/i,e.y/i,e.z/i,e.vx/i,e.vy/i,e.vz/i,t)}function Rr(r,t,e){let i=1,n=0;for(let s of r){let a=0;for(let[c,l,h]of s)a+=c*Math.cos(l+t*h);let o=i*a;e&&(o%=ms),n+=o,i*=t}return n}function Yh(r,t){let e=1,i=0,n=0,s=0;for(let a of r){let o=0,c=0;for(let[l,h,u]of a){let d=h+t*u;o+=l*u*Math.sin(d),s>0&&(c+=l*Math.cos(d))}n+=s*i*c-e*o,i=e,e*=t,++s}return n}const Mo=365250,Nd=0,Fd=1,Ud=2;function kd(r){return new Li(r[0]+44036e-11*r[1]-190919e-12*r[2],-479966e-12*r[0]+.917482137087*r[1]-.397776982902*r[2],.397776982902*r[1]+.917482137087*r[2])}function _1(r,t,e){const i=e*Math.cos(t),n=Math.cos(r),s=Math.sin(r);return[i*n,i*s,e*Math.sin(t)]}function Dr(r,t){const e=t.tt/Mo,i=Rr(r[Nd],e,!0),n=Rr(r[Fd],e,!1),s=Rr(r[Ud],e,!1),a=_1(i,n,s);return kd(a).ToAstroVector(t)}function zd(r,t){const e=t/Mo,i=Rr(r[Nd],e,!0),n=Rr(r[Fd],e,!1),s=Rr(r[Ud],e,!1),a=Yh(r[Nd],e),o=Yh(r[Fd],e),c=Yh(r[Ud],e),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),d=Math.sin(n),f=+(c*u*l)-s*d*l*o-s*u*h*a,p=+(c*u*h)-s*d*h*o+s*u*l*a,v=+(c*d)+s*u*o,m=_1(i,n,s),g=[f/Mo,p/Mo,v/Mo],S=kd(m),y=kd(g);return new Fa(t,S,y)}function kc(r,t,e,i){const n=i/(i+R0),s=Dr(ss[e],t);r.x+=n*s.x,r.y+=n*s.y,r.z+=n*s.z}function c5(r){const t=new Fe(0,0,0,r);return kc(t,r,wt.Jupiter,Rd),kc(t,r,wt.Saturn,Dd),kc(t,r,wt.Uranus,Id),kc(t,r,wt.Neptune,Cd),t}const Bd=51,l5=29200,gr=146,gs=201,Ta=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class Li{constructor(t,e,i){this.x=t,this.y=e,this.z=i}clone(){return new Li(this.x,this.y,this.z)}ToAstroVector(t){return new Fe(this.x,this.y,this.z,t)}static zero(){return new Li(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(t){return new Li(this.x+t.x,this.y+t.y,this.z+t.z)}sub(t){return new Li(this.x-t.x,this.y-t.y,this.z-t.z)}incr(t){this.x+=t.x,this.y+=t.y,this.z+=t.z}decr(t){this.x-=t.x,this.y-=t.y,this.z-=t.z}mul(t){return new Li(t*this.x,t*this.y,t*this.z)}div(t){return new Li(this.x/t,this.y/t,this.z/t)}mean(t){return new Li((this.x+t.x)/2,(this.y+t.y)/2,(this.z+t.z)/2)}neg(){return new Li(-this.x,-this.y,-this.z)}}class Fa{constructor(t,e,i){this.tt=t,this.r=e,this.v=i}clone(){return new Fa(this.tt,this.r,this.v)}sub(t){return new Fa(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function h5(r){let[t,[e,i,n],[s,a,o]]=r;return new Fa(t,new Li(e,i,n),new Li(s,a,o))}function zc(r,t,e,i){const n=i/(i+R0),s=zd(ss[e],t);return r.r.incr(s.r.mul(n)),r.v.incr(s.v.mul(n)),s}function ao(r,t,e){const i=e.sub(r),n=i.quadrature();return i.mul(t/(n*Math.sqrt(n)))}class Zl{constructor(t){let e=new Fa(t,new Li(0,0,0),new Li(0,0,0));this.Jupiter=zc(e,t,wt.Jupiter,Rd),this.Saturn=zc(e,t,wt.Saturn,Dd),this.Uranus=zc(e,t,wt.Uranus,Id),this.Neptune=zc(e,t,wt.Neptune,Cd),this.Jupiter.r.decr(e.r),this.Jupiter.v.decr(e.v),this.Saturn.r.decr(e.r),this.Saturn.v.decr(e.v),this.Uranus.r.decr(e.r),this.Uranus.v.decr(e.v),this.Neptune.r.decr(e.r),this.Neptune.v.decr(e.v),this.Sun=new Fa(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=ao(t,R0,this.Sun.r);return e.incr(ao(t,Rd,this.Jupiter.r)),e.incr(ao(t,Dd,this.Saturn.r)),e.incr(ao(t,Id,this.Uranus.r)),e.incr(ao(t,Cd,this.Neptune.r)),e}}class Jl{constructor(t,e,i,n){this.tt=t,this.r=e,this.v=i,this.a=n}clone(){return new Jl(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class S1{constructor(t,e){this.bary=t,this.grav=e}}function Pl(r,t,e,i){return new Li(t.x+r*(e.x+r*i.x/2),t.y+r*(e.y+r*i.y/2),t.z+r*(e.z+r*i.z/2))}function qp(r,t,e){return new Li(t.x+r*e.x,t.y+r*e.y,t.z+r*e.z)}function Hd(r,t){const e=r-t.tt,i=new Zl(r),n=Pl(e,t.r,t.v,t.a),s=i.Acceleration(n).mean(t.a),a=Pl(e,t.r,t.v,s),o=t.v.add(s.mul(e)),c=i.Acceleration(a),l=new Jl(r,a,o,c);return new S1(i,l)}const u5=[];function b1(r,t){const e=Math.floor(r);return e<0?0:e>=t?t-1:e}function Gd(r){const t=h5(r),e=new Zl(t.tt),i=t.r.add(e.Sun.r),n=t.v.add(e.Sun.v),s=e.Acceleration(i),a=new Jl(t.tt,i,n,s);return new S1(e,a)}function d5(r,t){const e=Ta[0][0];if(t<e||t>Ta[Bd-1][0])return null;const i=b1((t-e)/l5,Bd-1);if(!r[i]){const s=r[i]=[];s[0]=Gd(Ta[i]).grav,s[gs-1]=Gd(Ta[i+1]).grav;let a,o=s[0].tt;for(a=1;a<gs-1;++a)s[a]=Hd(o+=gr,s[a-1]).grav;o=s[gs-1].tt;var n=[];for(n[gs-1]=s[gs-1],a=gs-2;a>0;--a)n[a]=Hd(o-=gr,n[a+1]).grav;for(a=gs-2;a>0;--a){const c=a/(gs-1);s[a].r=s[a].r.mul(1-c).add(n[a].r.mul(c)),s[a].v=s[a].v.mul(1-c).add(n[a].v.mul(c)),s[a].a=s[a].a.mul(1-c).add(n[a].a.mul(c))}}return r[i]}function $p(r,t,e){let i=Gd(r);const n=Math.ceil((t-i.grav.tt)/e);for(let s=0;s<n;++s)i=Hd(s+1===n?t:i.grav.tt+e,i.grav);return i}function w1(r,t){let e,i,n;const s=d5(u5,r.tt);if(s){const a=b1((r.tt-s[0].tt)/gr,gs-1),o=s[a],c=s[a+1],l=o.a.mean(c.a),h=Pl(r.tt-o.tt,o.r,o.v,l),u=qp(r.tt-o.tt,o.v,l),d=Pl(r.tt-c.tt,c.r,c.v,l),f=qp(r.tt-c.tt,c.v,l),p=(r.tt-o.tt)/gr;e=h.mul(1-p).add(d.mul(p)),i=u.mul(1-p).add(f.mul(p))}else{let a;r.tt<Ta[0][0]?a=$p(Ta[0],r.tt,-gr):a=$p(Ta[Bd-1],r.tt,+gr),e=a.grav.r,i=a.grav.v,n=a.bary}return n||(n=new Zl(r.tt)),e=e.sub(n.Sun.r),i=i.sub(n.Sun.v),new js(e.x,e.y,e.z,i.x,i.y,i.z,r)}function ea(r,t){var e=$e(t);if(r in ss)return Dr(ss[r],e);if(r===wt.Pluto){const a=w1(e);return new Fe(a.x,a.y,a.z,e)}if(r===wt.Sun)return new Fe(0,0,0,e);if(r===wt.Moon){var i=Dr(ss.Earth,e),n=Fr(e);return new Fe(i.x+n.x,i.y+n.y,i.z+n.z,e)}if(r===wt.EMB){const a=Dr(ss.Earth,e),o=Fr(e),c=1+f1;return new Fe(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,e)}if(r===wt.SSB)return c5(e);const s=D0(r);if(s){const a=new Kl(s.dec,15*s.ra,s.dist);return N0(a,e)}throw`HelioVector: Unknown body "${r}"`}function f5(r,t){let e=t,i=0;for(let n=0;n<10;++n){const s=r(e),a=s.Length()/T0;if(a>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-a);if(i=Math.abs(o.tt-e.tt),i<1e-9)return s;e=o}throw`Light-travel time solver did not converge: dt = ${i}`}class p5{constructor(t,e,i,n){this.observerBody=t,this.targetBody=e,this.aberration=i,this.observerPos=n}Position(t){this.aberration&&(this.observerPos=ea(this.observerBody,t));const e=ea(this.targetBody,t);return new Fe(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function m5(r,t,e,i){Il(i);const n=$e(r);if(D0(e)){const o=ea(e,n);if(i){const l=v5(t,n),h=new Fe(o.x-l.x,o.y-l.y,o.z-l.z,n),u=T0/h.Length();return new Fe(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,n)}const c=ea(t,n);return new Fe(o.x-c.x,o.y-c.y,o.z-c.z,n)}let s;i?s=new Fe(0,0,0,n):s=ea(t,n);const a=new p5(t,e,i,s);return f5(o=>a.Position(o),n)}function Vd(r,t,e){Il(e);const i=$e(t);switch(r){case wt.Earth:return new Fe(0,0,0,i);case wt.Moon:return Fr(i);default:const n=m5(i,wt.Earth,r,e);return n.t=i,n}}function g5(r,t){return new js(r.r.x,r.r.y,r.r.z,r.v.x,r.v.y,r.v.z,t)}function v5(r,t){const e=$e(t);switch(r){case wt.Sun:return new js(0,0,0,0,0,0,e);case wt.SSB:const i=new Zl(e.tt);return new js(-i.Sun.r.x,-i.Sun.r.y,-i.Sun.r.z,-i.Sun.v.x,-i.Sun.v.y,-i.Sun.v.z,e);case wt.Mercury:case wt.Venus:case wt.Earth:case wt.Mars:case wt.Jupiter:case wt.Saturn:case wt.Uranus:case wt.Neptune:const n=zd(ss[r],e.tt);return g5(n,e);case wt.Pluto:return w1(e);case wt.Moon:case wt.EMB:const s=zd(ss.Earth,e.tt),a=r==wt.Moon?y1(e):o5(e);return new js(a.x+s.r.x,a.y+s.r.y,a.z+s.r.z,a.vx+s.v.x,a.vy+s.v.y,a.vz+s.v.z,e);default:if(D0(r)){const o=ea(r,e);return new js(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${r}"`}}function M5(r){for(;r<0;)r+=360;for(;r>=360;)r-=360;return r}function x5(r,t,e){if(r===wt.Earth||t===wt.Earth)throw"The Earth does not have a longitude as seen from itself.";const i=$e(e),n=Vd(r,i,!1),s=Od(n),a=Vd(t,i,!1),o=Od(a);return M5(s.elon-o.elon)}function y5(r,t,e,i){let n,s=0,a=0,o=0;switch(r){case wt.Mercury:n=-.6,s=4.98,a=-4.88,o=3.02;break;case wt.Venus:t<163.6?(n=-4.47,s=1.03,a=.57,o=.13):(n=.98,s=-1.02);break;case wt.Mars:n=-1.52,s=1.6;break;case wt.Jupiter:n=-9.4,s=.5;break;case wt.Uranus:n=-7.19,s=.25;break;case wt.Neptune:n=-6.87;break;case wt.Pluto:n=-1,s=4;break;default:throw`VisualMagnitude: unsupported body ${r}`}const c=t/100;let l=n+c*(s+c*(a+c*o));return l+=5*Math.log10(e*i),l}function _5(r,t,e,i,n){const s=Od(i),a=Ee*28.06,o=Ee*(169.51+382e-7*n.tt),c=Ee*s.elat,l=Ee*s.elon,h=Math.asin(Math.sin(c)*Math.cos(a)-Math.cos(c)*Math.sin(a)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*r;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(t*e),{mag:d,ring_tilt:os*h}}function S5(r,t,e){let i=r*Ee,n=i*i,s=n*n,a=-12.717+1.49*Math.abs(i)+.0431*s;const o=385000.6/_a;let c=e/o;return a+=5*Math.log10(t*c),a}class b5{constructor(t,e,i,n,s,a,o,c){this.time=t,this.mag=e,this.phase_angle=i,this.helio_dist=n,this.geo_dist=s,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(Ee*i))/2}}function E1(r,t){if(r===wt.Earth)throw"The illumination of the Earth is not defined.";const e=$e(t),i=Dr(ss.Earth,e);let n,s,a,o;r===wt.Sun?(a=new Fe(-i.x,-i.y,-i.z,e),s=new Fe(0,0,0,e),n=0):(r===wt.Moon?(a=Fr(e),s=new Fe(i.x+a.x,i.y+a.y,i.z+a.z,e)):(s=ea(r,t),a=new Fe(s.x-i.x,s.y-i.y,s.z-i.z,e)),n=Gb(a,s));let c=a.Length(),l=s.Length(),h;if(r===wt.Sun)o=zb+5*Math.log10(c);else if(r===wt.Moon)o=S5(n,l,c);else if(r===wt.Saturn){const u=_5(n,l,c,a,e);o=u.mag,h=u.ring_tilt}else o=y5(r,n,l,c);return new b5(e,o,n,l,c,a,s,h)}function w5(r){return x5(wt.Moon,wt.Sun,r)}var Kp;(function(r){r[r.Pericenter=0]="Pericenter",r[r.Apocenter=1]="Apocenter"})(Kp||(Kp={}));function A1(r,t){return new sa([[t.rot[0][0]*r.rot[0][0]+t.rot[1][0]*r.rot[0][1]+t.rot[2][0]*r.rot[0][2],t.rot[0][1]*r.rot[0][0]+t.rot[1][1]*r.rot[0][1]+t.rot[2][1]*r.rot[0][2],t.rot[0][2]*r.rot[0][0]+t.rot[1][2]*r.rot[0][1]+t.rot[2][2]*r.rot[0][2]],[t.rot[0][0]*r.rot[1][0]+t.rot[1][0]*r.rot[1][1]+t.rot[2][0]*r.rot[1][2],t.rot[0][1]*r.rot[1][0]+t.rot[1][1]*r.rot[1][1]+t.rot[2][1]*r.rot[1][2],t.rot[0][2]*r.rot[1][0]+t.rot[1][2]*r.rot[1][1]+t.rot[2][2]*r.rot[1][2]],[t.rot[0][0]*r.rot[2][0]+t.rot[1][0]*r.rot[2][1]+t.rot[2][0]*r.rot[2][2],t.rot[0][1]*r.rot[2][0]+t.rot[1][1]*r.rot[2][1]+t.rot[2][1]*r.rot[2][2],t.rot[0][2]*r.rot[2][0]+t.rot[1][2]*r.rot[2][1]+t.rot[2][2]*r.rot[2][2]]])}function N0(r,t){t=$e(t);const e=r.lat*Ee,i=r.lon*Ee,n=r.dist*Math.cos(e);return new Fe(n*Math.cos(i),n*Math.sin(i),r.dist*Math.sin(e),t)}function F0(r){const t=E5(r);return new Ld(t.lon/15,t.lat,t.dist,r)}function E5(r){const t=r.x*r.x+r.y*r.y,e=Math.sqrt(t+r.z*r.z);let i,n;if(t===0){if(r.z===0)throw"Zero-length vector not allowed.";n=0,i=r.z<0?-90:90}else n=os*Math.atan2(r.y,r.x),n<0&&(n+=360),i=os*Math.atan2(r.z,Math.sqrt(t));return new Kl(i,n,e)}function T1(r,t){let e;if(Si(t),t<-90||t>90)return 0;if(r==="normal"||r==="jplhor"){let i=t;i<-1&&(i=-1),e=1.02/Math.tan((i+10.3/(i+5.11))*Ee)/60,r==="normal"&&t<-1&&(e*=(t+90)/89)}else if(!r)e=0;else throw`Invalid refraction option: ${r}`;return e}function Ir(r,t){return new Fe(r.rot[0][0]*t.x+r.rot[1][0]*t.y+r.rot[2][0]*t.z,r.rot[0][1]*t.x+r.rot[1][1]*t.y+r.rot[2][1]*t.z,r.rot[0][2]*t.x+r.rot[1][2]*t.y+r.rot[2][2]*t.z,t.t)}function A5(){return new sa([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function T5(){return new sa([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function R1(r){r=$e(r);const t=I0(r,Ai.From2000),e=C0(r,Ai.From2000);return A1(t,e)}function R5(r){r=$e(r);const t=C0(r,Ai.Into2000),e=I0(r,Ai.Into2000);return A1(t,e)}function D5(r){const e=Ko($e(r)).tobl*Ee,i=Math.cos(e),n=Math.sin(e);return new sa([[1,0,0],[0,+i,+n],[0,-n,+i]])}var Zp;(function(r){r.Penumbral="penumbral",r.Partial="partial",r.Annular="annular",r.Total="total"})(Zp||(Zp={}));var Jp;(function(r){r[r.Invalid=0]="Invalid",r[r.Ascending=1]="Ascending",r[r.Descending=-1]="Descending"})(Jp||(Jp={}));const I5=["Venus","Mars","Jupiter","Saturn"];function D1(r){return new O0(r.lat,r.lng,r.elevationM)}function U0(r,t,e,i,n=!0){const s=M1(e,D1(i),r,t,n?"normal":void 0);return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}class Pn{up;north;west;constructor(t,e){const i=$e(t),n=Math.sin(e.lat*vs),s=Math.cos(e.lat*vs),a=Math.sin(e.lng*vs),o=Math.cos(e.lng*vs),c=-15*Qb(i),l=R5(i);this.up=Pn.rotate(l,Pn.spin(c,[s*o,s*a,n]),i),this.north=Pn.rotate(l,Pn.spin(c,[-n*o,-n*a,s]),i),this.west=Pn.rotate(l,Pn.spin(c,[a,-o,0]),i)}static ofJ2000(t,e,i,n,s=!0){const a=$e(i),o=N0(new Kl(e,t*15,1),a),c=F0(Ir(R1(a),o));return U0(c.ra,c.dec,i,n,s)}position(t,e){const i=Math.sin(e*vs),n=Math.cos(e*vs),s=Math.sin(t*Qp),a=Math.cos(t*Qp),o=n*a,c=n*s,l=i,h=o*this.up[0]+c*this.up[1]+l*this.up[2],u=o*this.north[0]+c*this.north[1]+l*this.north[2],d=o*this.west[0]+c*this.west[1]+l*this.west[2],f=Math.hypot(u,d);let p=0;f>0&&(p=-jp*Math.atan2(d,u),p<0&&(p+=360));let v=jp*Math.atan2(f,h);return v-=T1("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(t,[e,i,n]){const s=Math.cos(t*vs),a=Math.sin(t*vs);return[s*e+a*i,s*i-a*e,n]}static rotate(t,[e,i,n],s){const a=Ir(t,new Fe(e,i,n,s));return[a.x,a.y,a.z]}}const vs=Math.PI/180,jp=180/Math.PI,Qp=15*vs;function qh(r,t,e){const i=D1(e),n=a5(wt[r],t,i,!0,!0),s=M1(t,i,n.ra,n.dec,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function $h(r,t){return E1(wt[r],t).mag}function C5(r){const t=w5(r),e=E1(wt.Moon,r);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const P5=2e3,L5=3,O5=20;function Bc(r,t,e){if(r.year===void 0&&r.month===void 0&&r.day===void 0&&r.hour===void 0)return;const i=r.year!==void 0,n=r.year??P5,s=r.month??(i?1:L5),a=r.day??(i?1:O5),o=e??Math.round(t/15);return new Date(Date.UTC(n,s-1,a,(r.hour??12)-o,r.minute??0,r.second??0))}const tm=["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"];class Ia{static POINT_DEG=360/16;static point(t,e=tm){const i=(t%360+360)%360,n=Math.round(i/Ia.POINT_DEG)%16;return e[n]}static POINTS=tm;static towards(t,e){return e?e.towards(Ia.point(t,e.compassPoints)):`to the ${Ia.point(t)}`}}class Kn{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static FALLOFF={core:Kn.CORE,rim:Kn.RIM};static apply(t){t.transparent=!0,t.depthWrite=!1,t.onBeforeCompile=e=>{e.fragmentShader=Kn.patch(e.fragmentShader)}}static patch(t){return t.replace(Kn.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
5987
+ */const T0=173.1446326846693,_a=14959787069098932e-8,Ee=.017453292519943295,Vp=.26179938779914946,os=57.29577951308232,u1=3.819718634205488,Fb=365.24217,Wp=new Date("2000-01-01T12:00:00Z"),ms=2*Math.PI,Hs=3600*(180/Math.PI),mr=484813681109536e-20,d1=10800*60,Ub=2*d1,Xp=7292115e-11,kb=d1/Math.PI,zb=-.17-5*Math.log10(kb),Ad=.996647180302104,Bb=Ad*Ad,Td=6378.1366,Hb=Td/_a,f1=81.30056,R0=.0002959122082855911,Rd=2825345909524226e-22,Dd=8459715185680659e-23,Id=1292024916781969e-23,Cd=1524358900784276e-23;function Il(r){if(r!==!0&&r!==!1)throw console.trace(),`Value is not boolean: ${r}`;return r}function Si(r){if(!Number.isFinite(r))throw console.trace(),`Value is not a finite number: ${r}`;return r}function cr(r){return r-Math.floor(r)}function Gb(r,t){const e=r.x*r.x+r.y*r.y+r.z*r.z;if(Math.abs(e)<1e-8)throw"AngleBetween: first vector is too short.";const i=t.x*t.x+t.y*t.y+t.z*t.z;if(Math.abs(i)<1e-8)throw"AngleBetween: second vector is too short.";const n=(r.x*t.x+r.y*t.y+r.z*t.z)/Math.sqrt(e*i);return n<=-1?180:n>=1?0:os*Math.acos(n)}var wt;(function(r){r.Sun="Sun",r.Moon="Moon",r.Mercury="Mercury",r.Venus="Venus",r.Earth="Earth",r.Mars="Mars",r.Jupiter="Jupiter",r.Saturn="Saturn",r.Uranus="Uranus",r.Neptune="Neptune",r.Pluto="Pluto",r.SSB="SSB",r.EMB="EMB",r.Star1="Star1",r.Star2="Star2",r.Star3="Star3",r.Star4="Star4",r.Star5="Star5",r.Star6="Star6",r.Star7="Star7",r.Star8="Star8"})(wt||(wt={}));const Vb=[wt.Star1,wt.Star2,wt.Star3,wt.Star4,wt.Star5,wt.Star6,wt.Star7,wt.Star8],Wb=[{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0}];function Xb(r){const t=Vb.indexOf(r);return t>=0?Wb[t]:null}function D0(r){const t=Xb(r);return t&&t.dist>0?t:null}var Ai;(function(r){r[r.From2000=0]="From2000",r[r.Into2000=1]="Into2000"})(Ai||(Ai={}));const ss={Mercury:[[[[4.40250710144,0,0],[.40989414977,1.48302034195,26087.9031415742],[.050462942,4.47785489551,52175.8062831484],[.00855346844,1.16520322459,78263.70942472259],[.00165590362,4.11969163423,104351.61256629678],[.00034561897,.77930768443,130439.51570787099],[7583476e-11,3.71348404924,156527.41884944518]],[[26087.90313685529,0,0],[.01131199811,6.21874197797,26087.9031415742],[.00292242298,3.04449355541,52175.8062831484],[.00075775081,6.08568821653,78263.70942472259],[.00019676525,2.80965111777,104351.61256629678]]],[[[.11737528961,1.98357498767,26087.9031415742],[.02388076996,5.03738959686,52175.8062831484],[.01222839532,3.14159265359,0],[.0054325181,1.79644363964,78263.70942472259],[.0012977877,4.83232503958,104351.61256629678],[.00031866927,1.58088495658,130439.51570787099],[7963301e-11,4.60972126127,156527.41884944518]],[[.00274646065,3.95008450011,26087.9031415742],[.00099737713,3.14159265359,0]]],[[[.39528271651,0,0],[.07834131818,6.19233722598,26087.9031415742],[.00795525558,2.95989690104,52175.8062831484],[.00121281764,6.01064153797,78263.70942472259],[.00021921969,2.77820093972,104351.61256629678],[4354065e-11,5.82894543774,130439.51570787099]],[[.0021734774,4.65617158665,26087.9031415742],[.00044141826,1.42385544001,52175.8062831484]]]],Venus:[[[[3.17614666774,0,0],[.01353968419,5.59313319619,10213.285546211],[.00089891645,5.30650047764,20426.571092422],[5477194e-11,4.41630661466,7860.4193924392],[3455741e-11,2.6996444782,11790.6290886588],[2372061e-11,2.99377542079,3930.2096962196],[1317168e-11,5.18668228402,26.2983197998],[1664146e-11,4.25018630147,1577.3435424478],[1438387e-11,4.15745084182,9683.5945811164],[1200521e-11,6.15357116043,30639.856638633]],[[10213.28554621638,0,0],[.00095617813,2.4640651111,10213.285546211],[7787201e-11,.6247848222,20426.571092422]]],[[[.05923638472,.26702775812,10213.285546211],[.00040107978,1.14737178112,20426.571092422],[.00032814918,3.14159265359,0]],[[.00287821243,1.88964962838,10213.285546211]]],[[[.72334820891,0,0],[.00489824182,4.02151831717,10213.285546211],[1658058e-11,4.90206728031,20426.571092422],[1378043e-11,1.12846591367,11790.6290886588],[1632096e-11,2.84548795207,7860.4193924392],[498395e-11,2.58682193892,9683.5945811164],[221985e-11,2.01346696541,19367.1891622328],[237454e-11,2.55136053886,15720.8387848784]],[[.00034551041,.89198706276,10213.285546211]]]],Earth:[[[[1.75347045673,0,0],[.03341656453,4.66925680415,6283.0758499914],[.00034894275,4.62610242189,12566.1516999828],[3417572e-11,2.82886579754,3.523118349],[3497056e-11,2.74411783405,5753.3848848968],[3135899e-11,3.62767041756,77713.7714681205],[2676218e-11,4.41808345438,7860.4193924392],[2342691e-11,6.13516214446,3930.2096962196],[1273165e-11,2.03709657878,529.6909650946],[1324294e-11,.74246341673,11506.7697697936],[901854e-11,2.04505446477,26.2983197998],[1199167e-11,1.10962946234,1577.3435424478],[857223e-11,3.50849152283,398.1490034082],[779786e-11,1.17882681962,5223.6939198022],[99025e-10,5.23268072088,5884.9268465832],[753141e-11,2.53339052847,5507.5532386674],[505267e-11,4.58292599973,18849.2275499742],[492392e-11,4.20505711826,775.522611324],[356672e-11,2.91954114478,.0673103028],[284125e-11,1.89869240932,796.2980068164],[242879e-11,.34481445893,5486.777843175],[317087e-11,5.84901948512,11790.6290886588],[271112e-11,.31486255375,10977.078804699],[206217e-11,4.80646631478,2544.3144198834],[205478e-11,1.86953770281,5573.1428014331],[202318e-11,2.45767790232,6069.7767545534],[126225e-11,1.08295459501,20.7753954924],[155516e-11,.83306084617,213.299095438]],[[6283.0758499914,0,0],[.00206058863,2.67823455808,6283.0758499914],[4303419e-11,2.63512233481,12566.1516999828]],[[8721859e-11,1.07253635559,6283.0758499914]]],[[],[[.00227777722,3.4137662053,6283.0758499914],[3805678e-11,3.37063423795,12566.1516999828]]],[[[1.00013988784,0,0],[.01670699632,3.09846350258,6283.0758499914],[.00013956024,3.05524609456,12566.1516999828],[308372e-10,5.19846674381,77713.7714681205],[1628463e-11,1.17387558054,5753.3848848968],[1575572e-11,2.84685214877,7860.4193924392],[924799e-11,5.45292236722,11506.7697697936],[542439e-11,4.56409151453,3930.2096962196],[47211e-10,3.66100022149,5884.9268465832],[85831e-11,1.27079125277,161000.6857376741],[57056e-11,2.01374292245,83996.84731811189],[55736e-11,5.2415979917,71430.69561812909],[174844e-11,3.01193636733,18849.2275499742],[243181e-11,4.2734953079,11790.6290886588]],[[.00103018607,1.10748968172,6283.0758499914],[1721238e-11,1.06442300386,12566.1516999828]],[[4359385e-11,5.78455133808,6283.0758499914]]]],Mars:[[[[6.20347711581,0,0],[.18656368093,5.0503710027,3340.6124266998],[.01108216816,5.40099836344,6681.2248533996],[.00091798406,5.75478744667,10021.8372800994],[.00027744987,5.97049513147,3.523118349],[.00010610235,2.93958560338,2281.2304965106],[.00012315897,.84956094002,2810.9214616052],[8926784e-11,4.15697846427,.0172536522],[8715691e-11,6.11005153139,13362.4497067992],[6797556e-11,.36462229657,398.1490034082],[7774872e-11,3.33968761376,5621.8429232104],[3575078e-11,1.6618650571,2544.3144198834],[4161108e-11,.22814971327,2942.4634232916],[3075252e-11,.85696614132,191.4482661116],[2628117e-11,.64806124465,3337.0893083508],[2937546e-11,6.07893711402,.0673103028],[2389414e-11,5.03896442664,796.2980068164],[2579844e-11,.02996736156,3344.1355450488],[1528141e-11,1.14979301996,6151.533888305],[1798806e-11,.65634057445,529.6909650946],[1264357e-11,3.62275122593,5092.1519581158],[1286228e-11,3.06796065034,2146.1654164752],[1546404e-11,2.91579701718,1751.539531416],[1024902e-11,3.69334099279,8962.4553499102],[891566e-11,.18293837498,16703.062133499],[858759e-11,2.4009381194,2914.0142358238],[832715e-11,2.46418619474,3340.5951730476],[83272e-10,4.49495782139,3340.629680352],[712902e-11,3.66335473479,1059.3819301892],[748723e-11,3.82248614017,155.4203994342],[723861e-11,.67497311481,3738.761430108],[635548e-11,2.92182225127,8432.7643848156],[655162e-11,.48864064125,3127.3133312618],[550474e-11,3.81001042328,.9803210682],[55275e-10,4.47479317037,1748.016413067],[425966e-11,.55364317304,6283.0758499914],[415131e-11,.49662285038,213.299095438],[472167e-11,3.62547124025,1194.4470102246],[306551e-11,.38052848348,6684.7479717486],[312141e-11,.99853944405,6677.7017350506],[293198e-11,4.22131299634,20.7753954924],[302375e-11,4.48618007156,3532.0606928114],[274027e-11,.54222167059,3340.545116397],[281079e-11,5.88163521788,1349.8674096588],[231183e-11,1.28242156993,3870.3033917944],[283602e-11,5.7688543494,3149.1641605882],[236117e-11,5.75503217933,3333.498879699],[274033e-11,.13372524985,3340.6797370026],[299395e-11,2.78323740866,6254.6266625236]],[[3340.61242700512,0,0],[.01457554523,3.60433733236,3340.6124266998],[.00168414711,3.92318567804,6681.2248533996],[.00020622975,4.26108844583,10021.8372800994],[3452392e-11,4.7321039319,3.523118349],[2586332e-11,4.60670058555,13362.4497067992],[841535e-11,4.45864030426,2281.2304965106]],[[.00058152577,2.04961712429,3340.6124266998],[.00013459579,2.45738706163,6681.2248533996]]],[[[.03197134986,3.76832042431,3340.6124266998],[.00298033234,4.10616996305,6681.2248533996],[.00289104742,0,0],[.00031365539,4.4465105309,10021.8372800994],[34841e-9,4.7881254926,13362.4497067992]],[[.00217310991,6.04472194776,3340.6124266998],[.00020976948,3.14159265359,0],[.00012834709,1.60810667915,6681.2248533996]]],[[[1.53033488271,0,0],[.1418495316,3.47971283528,3340.6124266998],[.00660776362,3.81783443019,6681.2248533996],[.00046179117,4.15595316782,10021.8372800994],[8109733e-11,5.55958416318,2810.9214616052],[7485318e-11,1.77239078402,5621.8429232104],[5523191e-11,1.3643630377,2281.2304965106],[382516e-10,4.49407183687,13362.4497067992],[2306537e-11,.09081579001,2544.3144198834],[1999396e-11,5.36059617709,3337.0893083508],[2484394e-11,4.9254563992,2942.4634232916],[1960195e-11,4.74249437639,3344.1355450488],[1167119e-11,2.11260868341,5092.1519581158],[1102816e-11,5.00908403998,398.1490034082],[899066e-11,4.40791133207,529.6909650946],[992252e-11,5.83861961952,6151.533888305],[807354e-11,2.10217065501,1059.3819301892],[797915e-11,3.44839203899,796.2980068164],[740975e-11,1.49906336885,2146.1654164752]],[[.01107433345,2.03250524857,3340.6124266998],[.00103175887,2.37071847807,6681.2248533996],[128772e-9,0,0],[.0001081588,2.70888095665,10021.8372800994]],[[.00044242249,.47930604954,3340.6124266998],[8138042e-11,.86998389204,6681.2248533996]]]],Jupiter:[[[[.59954691494,0,0],[.09695898719,5.06191793158,529.6909650946],[.00573610142,1.44406205629,7.1135470008],[.00306389205,5.41734730184,1059.3819301892],[.00097178296,4.14264726552,632.7837393132],[.00072903078,3.64042916389,522.5774180938],[.00064263975,3.41145165351,103.0927742186],[.00039806064,2.29376740788,419.4846438752],[.00038857767,1.27231755835,316.3918696566],[.00027964629,1.7845459182,536.8045120954],[.0001358973,5.7748104079,1589.0728952838],[8246349e-11,3.5822792584,206.1855484372],[8768704e-11,3.63000308199,949.1756089698],[7368042e-11,5.0810119427,735.8765135318],[626315e-10,.02497628807,213.299095438],[6114062e-11,4.51319998626,1162.4747044078],[4905396e-11,1.32084470588,110.2063212194],[5305285e-11,1.30671216791,14.2270940016],[5305441e-11,4.18625634012,1052.2683831884],[4647248e-11,4.69958103684,3.9321532631],[3045023e-11,4.31676431084,426.598190876],[2609999e-11,1.56667394063,846.0828347512],[2028191e-11,1.06376530715,3.1813937377],[1764763e-11,2.14148655117,1066.49547719],[1722972e-11,3.88036268267,1265.5674786264],[1920945e-11,.97168196472,639.897286314],[1633223e-11,3.58201833555,515.463871093],[1431999e-11,4.29685556046,625.6701923124],[973272e-11,4.09764549134,95.9792272178]],[[529.69096508814,0,0],[.00489503243,4.2208293947,529.6909650946],[.00228917222,6.02646855621,7.1135470008],[.00030099479,4.54540782858,1059.3819301892],[.0002072092,5.45943156902,522.5774180938],[.00012103653,.16994816098,536.8045120954],[6067987e-11,4.42422292017,103.0927742186],[5433968e-11,3.98480737746,419.4846438752],[4237744e-11,5.89008707199,14.2270940016]],[[.00047233601,4.32148536482,7.1135470008],[.00030649436,2.929777887,529.6909650946],[.00014837605,3.14159265359,0]]],[[[.02268615702,3.55852606721,529.6909650946],[.00109971634,3.90809347197,1059.3819301892],[.00110090358,0,0],[8101428e-11,3.60509572885,522.5774180938],[6043996e-11,4.25883108339,1589.0728952838],[6437782e-11,.30627119215,536.8045120954]],[[.00078203446,1.52377859742,529.6909650946]]],[[[5.20887429326,0,0],[.25209327119,3.49108639871,529.6909650946],[.00610599976,3.84115365948,1059.3819301892],[.00282029458,2.57419881293,632.7837393132],[.00187647346,2.07590383214,522.5774180938],[.00086792905,.71001145545,419.4846438752],[.00072062974,.21465724607,536.8045120954],[.00065517248,5.9799588479,316.3918696566],[.00029134542,1.67759379655,103.0927742186],[.00030135335,2.16132003734,949.1756089698],[.00023453271,3.54023522184,735.8765135318],[.00022283743,4.19362594399,1589.0728952838],[.00023947298,.2745803748,7.1135470008],[.00013032614,2.96042965363,1162.4747044078],[970336e-10,1.90669633585,206.1855484372],[.00012749023,2.71550286592,1052.2683831884],[7057931e-11,2.18184839926,1265.5674786264],[6137703e-11,6.26418240033,846.0828347512],[2616976e-11,2.00994012876,1581.959348283]],[[.0127180152,2.64937512894,529.6909650946],[.00061661816,3.00076460387,1059.3819301892],[.00053443713,3.89717383175,522.5774180938],[.00031185171,4.88276958012,536.8045120954],[.00041390269,0,0]]]],Saturn:[[[[.87401354025,0,0],[.11107659762,3.96205090159,213.299095438],[.01414150957,4.58581516874,7.1135470008],[.00398379389,.52112032699,206.1855484372],[.00350769243,3.30329907896,426.598190876],[.00206816305,.24658372002,103.0927742186],[792713e-9,3.84007056878,220.4126424388],[.00023990355,4.66976924553,110.2063212194],[.00016573588,.43719228296,419.4846438752],[.00014906995,5.76903183869,316.3918696566],[.0001582029,.93809155235,632.7837393132],[.00014609559,1.56518472,3.9321532631],[.00013160301,4.44891291899,14.2270940016],[.00015053543,2.71669915667,639.897286314],[.00013005299,5.98119023644,11.0457002639],[.00010725067,3.12939523827,202.2533951741],[5863206e-11,.23656938524,529.6909650946],[5227757e-11,4.20783365759,3.1813937377],[6126317e-11,1.76328667907,277.0349937414],[5019687e-11,3.17787728405,433.7117378768],[459255e-10,.61977744975,199.0720014364],[4005867e-11,2.24479718502,63.7358983034],[2953796e-11,.98280366998,95.9792272178],[387367e-10,3.22283226966,138.5174968707],[2461186e-11,2.03163875071,735.8765135318],[3269484e-11,.77492638211,949.1756089698],[1758145e-11,3.2658010994,522.5774180938],[1640172e-11,5.5050445305,846.0828347512],[1391327e-11,4.02333150505,323.5054166574],[1580648e-11,4.37265307169,309.2783226558],[1123498e-11,2.83726798446,415.5524906121],[1017275e-11,3.71700135395,227.5261894396],[848642e-11,3.1915017083,209.3669421749]],[[213.2990952169,0,0],[.01297370862,1.82834923978,213.299095438],[.00564345393,2.88499717272,7.1135470008],[.00093734369,1.06311793502,426.598190876],[.00107674962,2.27769131009,206.1855484372],[.00040244455,2.04108104671,220.4126424388],[.00019941774,1.2795439047,103.0927742186],[.00010511678,2.7488034213,14.2270940016],[6416106e-11,.38238295041,639.897286314],[4848994e-11,2.43037610229,419.4846438752],[4056892e-11,2.92133209468,110.2063212194],[3768635e-11,3.6496533078,3.9321532631]],[[.0011644133,1.17988132879,7.1135470008],[.00091841837,.0732519584,213.299095438],[.00036661728,0,0],[.00015274496,4.06493179167,206.1855484372]]],[[[.04330678039,3.60284428399,213.299095438],[.00240348302,2.85238489373,426.598190876],[.00084745939,0,0],[.00030863357,3.48441504555,220.4126424388],[.00034116062,.57297307557,206.1855484372],[.0001473407,2.11846596715,639.897286314],[9916667e-11,5.79003188904,419.4846438752],[6993564e-11,4.7360468972,7.1135470008],[4807588e-11,5.43305312061,316.3918696566]],[[.00198927992,4.93901017903,213.299095438],[.00036947916,3.14159265359,0],[.00017966989,.5197943111,426.598190876]]],[[[9.55758135486,0,0],[.52921382865,2.39226219573,213.299095438],[.01873679867,5.2354960466,206.1855484372],[.01464663929,1.64763042902,426.598190876],[.00821891141,5.93520042303,316.3918696566],[.00547506923,5.0153261898,103.0927742186],[.0037168465,2.27114821115,220.4126424388],[.00361778765,3.13904301847,7.1135470008],[.00140617506,5.70406606781,632.7837393132],[.00108974848,3.29313390175,110.2063212194],[.00069006962,5.94099540992,419.4846438752],[.00061053367,.94037691801,639.897286314],[.00048913294,1.55733638681,202.2533951741],[.00034143772,.19519102597,277.0349937414],[.00032401773,5.47084567016,949.1756089698],[.00020936596,.46349251129,735.8765135318],[9796004e-11,5.20477537945,1265.5674786264],[.00011993338,5.98050967385,846.0828347512],[208393e-9,1.52102476129,433.7117378768],[.00015298404,3.0594381494,529.6909650946],[6465823e-11,.17732249942,1052.2683831884],[.00011380257,1.7310542704,522.5774180938],[3419618e-11,4.94550542171,1581.959348283]],[[.0618298134,.2584351148,213.299095438],[.00506577242,.71114625261,206.1855484372],[.00341394029,5.79635741658,426.598190876],[.00188491195,.47215589652,220.4126424388],[.00186261486,3.14159265359,0],[.00143891146,1.40744822888,7.1135470008]],[[.00436902572,4.78671677509,213.299095438]]]],Uranus:[[[[5.48129294297,0,0],[.09260408234,.89106421507,74.7815985673],[.01504247898,3.6271926092,1.4844727083],[.00365981674,1.89962179044,73.297125859],[.00272328168,3.35823706307,149.5631971346],[.00070328461,5.39254450063,63.7358983034],[.00068892678,6.09292483287,76.2660712756],[.00061998615,2.26952066061,2.9689454166],[.00061950719,2.85098872691,11.0457002639],[.0002646877,3.14152083966,71.8126531507],[.00025710476,6.11379840493,454.9093665273],[.0002107885,4.36059339067,148.0787244263],[.00017818647,1.74436930289,36.6485629295],[.00014613507,4.73732166022,3.9321532631],[.00011162509,5.8268179635,224.3447957019],[.0001099791,.48865004018,138.5174968707],[9527478e-11,2.95516862826,35.1640902212],[7545601e-11,5.236265824,109.9456887885],[4220241e-11,3.23328220918,70.8494453042],[40519e-9,2.277550173,151.0476698429],[3354596e-11,1.0654900738,4.4534181249],[2926718e-11,4.62903718891,9.5612275556],[349034e-10,5.48306144511,146.594251718],[3144069e-11,4.75199570434,77.7505439839],[2922333e-11,5.35235361027,85.8272988312],[2272788e-11,4.36600400036,70.3281804424],[2051219e-11,1.51773566586,.1118745846],[2148602e-11,.60745949945,38.1330356378],[1991643e-11,4.92437588682,277.0349937414],[1376226e-11,2.04283539351,65.2203710117],[1666902e-11,3.62744066769,380.12776796],[1284107e-11,3.11347961505,202.2533951741],[1150429e-11,.93343589092,3.1813937377],[1533221e-11,2.58594681212,52.6901980395],[1281604e-11,.54271272721,222.8603229936],[1372139e-11,4.19641530878,111.4301614968],[1221029e-11,.1990065003,108.4612160802],[946181e-11,1.19253165736,127.4717966068],[1150989e-11,4.17898916639,33.6796175129]],[[74.7815986091,0,0],[.00154332863,5.24158770553,74.7815985673],[.00024456474,1.71260334156,1.4844727083],[9258442e-11,.4282973235,11.0457002639],[8265977e-11,1.50218091379,63.7358983034],[915016e-10,1.41213765216,149.5631971346]]],[[[.01346277648,2.61877810547,74.7815985673],[623414e-9,5.08111189648,149.5631971346],[.00061601196,3.14159265359,0],[9963722e-11,1.61603805646,76.2660712756],[992616e-10,.57630380333,73.297125859]],[[.00034101978,.01321929936,74.7815985673]]],[[[19.21264847206,0,0],[.88784984413,5.60377527014,74.7815985673],[.03440836062,.32836099706,73.297125859],[.0205565386,1.7829515933,149.5631971346],[.0064932241,4.52247285911,76.2660712756],[.00602247865,3.86003823674,63.7358983034],[.00496404167,1.40139935333,454.9093665273],[.00338525369,1.58002770318,138.5174968707],[.00243509114,1.57086606044,71.8126531507],[.00190522303,1.99809394714,1.4844727083],[.00161858838,2.79137786799,148.0787244263],[.00143706183,1.38368544947,11.0457002639],[.00093192405,.17437220467,36.6485629295],[.00071424548,4.24509236074,224.3447957019],[.00089806014,3.66105364565,109.9456887885],[.00039009723,1.66971401684,70.8494453042],[.00046677296,1.39976401694,35.1640902212],[.00039025624,3.36234773834,277.0349937414],[.00036755274,3.88649278513,146.594251718],[.00030348723,.70100838798,151.0476698429],[.00029156413,3.180563367,77.7505439839],[.00022637073,.72518687029,529.6909650946],[.00011959076,1.7504339214,984.6003316219],[.00025620756,5.25656086672,380.12776796]],[[.01479896629,3.67205697578,74.7815985673]]]],Neptune:[[[[5.31188633046,0,0],[.0179847553,2.9010127389,38.1330356378],[.01019727652,.48580922867,1.4844727083],[.00124531845,4.83008090676,36.6485629295],[.00042064466,5.41054993053,2.9689454166],[.00037714584,6.09221808686,35.1640902212],[.00033784738,1.24488874087,76.2660712756],[.00016482741,7727998e-11,491.5579294568],[9198584e-11,4.93747051954,39.6175083461],[899425e-10,.27462171806,175.1660598002]],[[38.13303563957,0,0],[.00016604172,4.86323329249,1.4844727083],[.00015744045,2.27887427527,38.1330356378]]],[[[.03088622933,1.44104372644,38.1330356378],[.00027780087,5.91271884599,76.2660712756],[.00027623609,0,0],[.00015355489,2.52123799551,36.6485629295],[.00015448133,3.50877079215,39.6175083461]]],[[[30.07013205828,0,0],[.27062259632,1.32999459377,38.1330356378],[.01691764014,3.25186135653,36.6485629295],[.00807830553,5.18592878704,1.4844727083],[.0053776051,4.52113935896,35.1640902212],[.00495725141,1.5710564165,491.5579294568],[.00274571975,1.84552258866,175.1660598002],[.0001201232,1.92059384991,1021.2488945514],[.00121801746,5.79754470298,76.2660712756],[.00100896068,.3770272493,73.297125859],[.00135134092,3.37220609835,39.6175083461],[7571796e-11,1.07149207335,388.4651552382]]]]};function Yb(r){var t,e,i,n,s,a,o;const c=2e3+(r-14)/Fb;return c<-500?(t=(c-1820)/100,-20+32*t*t):c<500?(t=c/100,e=t*t,i=t*e,n=e*e,s=e*i,a=i*i,10583.6-1014.41*t+33.78311*e-5.952053*i-.1798452*n+.022174192*s+.0090316521*a):c<1600?(t=(c-1e3)/100,e=t*t,i=t*e,n=e*e,s=e*i,a=i*i,1574.2-556.01*t+71.23472*e+.319781*i-.8503463*n-.005050998*s+.0083572073*a):c<1700?(t=c-1600,e=t*t,i=t*e,120-.9808*t-.01532*e+i/7129):c<1800?(t=c-1700,e=t*t,i=t*e,n=e*e,8.83+.1603*t-.0059285*e+13336e-8*i-n/1174e3):c<1860?(t=c-1800,e=t*t,i=t*e,n=e*e,s=e*i,a=i*i,o=i*n,13.72-.332447*t+.0068612*e+.0041116*i-37436e-8*n+121272e-10*s-1699e-10*a+875e-12*o):c<1900?(t=c-1860,e=t*t,i=t*e,n=e*e,s=e*i,7.62+.5737*t-.251754*e+.01680668*i-.0004473624*n+s/233174):c<1920?(t=c-1900,e=t*t,i=t*e,n=e*e,-2.79+1.494119*t-.0598939*e+.0061966*i-197e-6*n):c<1941?(t=c-1920,e=t*t,i=t*e,21.2+.84493*t-.0761*e+.0020936*i):c<1961?(t=c-1950,e=t*t,i=t*e,29.07+.407*t-e/233+i/2547):c<1986?(t=c-1975,e=t*t,i=t*e,45.45+1.067*t-e/260-i/718):c<2005?(t=c-2e3,e=t*t,i=t*e,n=e*e,s=e*i,63.86+.3345*t-.060374*e+.0017275*i+651814e-9*n+2373599e-11*s):c<2050?(t=c-2e3,62.92+.32217*t+.005589*t*t):c<2150?(t=(c-1820)/100,-20+32*t*t-.5628*(2150-c)):(t=(c-1820)/100,-20+32*t*t)}let qb=Yb;function Yp(r){return r+qb(r)/86400}class Tr{constructor(t){if(t instanceof Tr){this.date=t.date,this.ut=t.ut,this.tt=t.tt;return}const e=1e3*3600*24;if(t instanceof Date&&Number.isFinite(t.getTime())){this.date=t,this.ut=(t.getTime()-Wp.getTime())/e,this.tt=Yp(this.ut);return}if(Number.isFinite(t)){this.date=new Date(Wp.getTime()+t*e),this.ut=t,this.tt=Yp(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(t){let e=new Tr(t);for(;;){const i=t-e.tt;if(Math.abs(i)<1e-12)return e;e=e.AddDays(i)}}toString(){return this.date.toISOString()}AddDays(t){return new Tr(this.ut+t)}}function $e(r){return r instanceof Tr?r:new Tr(r)}function $b(r){function t(d){return d%Ub*mr}const e=r.tt/36525,i=t(128710479305e-5+e*1295965810481e-4),n=t(335779.526232+e*17395272628478e-4),s=t(107226070369e-5+e*1602961601209e-3),a=t(450160.398036-e*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*e)*o+33386*c,h=(92052331+9086*e)*c+15377*o,u=2*(n-s+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*e)*o-13696*c,h+=(5730336-3015*e)*c-4587*o,u=2*(n+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*e)*o+2796*c,h+=(978459-485*e)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*e)*o-698*c,h+=(-897492+470*e)*c-291*o,o=Math.sin(i),c=Math.cos(i),l+=(1475877-3633*e)*o+11817*c,h+=(73871-184*e)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function p1(r){var t=r.tt/36525,e=((((-434e-10*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406;return e/3600}var Fc;function Ko(r){if(!Fc||Math.abs(Fc.tt-r.tt)>1e-6){const t=$b(r),e=p1(r),i=e+t.deps/3600;Fc={tt:r.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*Ee)/15,mobl:e,tobl:i}}return Fc}function Kb(r,t){const e=r*Ee,i=Math.cos(e),n=Math.sin(e);return[t[0],t[1]*i-t[2]*n,t[1]*n+t[2]*i]}function Zb(r,t){return Kb(p1(r),t)}function Jb(r){const t=r.tt/36525;function e(Ct,_t){const kt=[];let zt;for(zt=0;zt<=_t-Ct;++zt)kt.push(0);return{min:Ct,array:kt}}function i(Ct,_t,kt,zt){const Bt=[];for(let Me=0;Me<=_t-Ct;++Me)Bt.push(e(kt,zt));return{min:Ct,array:Bt}}function n(Ct,_t,kt){const zt=Ct.array[_t-Ct.min];return zt.array[kt-zt.min]}function s(Ct,_t,kt,zt){const Bt=Ct.array[_t-Ct.min];Bt.array[kt-Bt.min]=zt}let a,o,c,l,h,u,d,f,p,v,m,g,S,y,M,b,w,T,x,A,C,I,P,V=i(-6,6,1,4),X=i(-6,6,1,4);function L(Ct,_t){return n(V,Ct,_t)}function B(Ct,_t){return n(X,Ct,_t)}function k(Ct,_t,kt){return s(V,Ct,_t,kt)}function $(Ct,_t,kt){return s(X,Ct,_t,kt)}function tt(Ct,_t,kt,zt,Bt){Bt(Ct*kt-_t*zt,_t*kt+Ct*zt)}function J(Ct){return Math.sin(ms*Ct)}d=t*t,p=0,P=0,m=0,g=3422.7;var it=J(.19833+.05611*t),rt=J(.27869+.04508*t),Vt=J(.16827-.36903*t),jt=J(.34734-5.37261*t),qt=J(.10498-5.37899*t),q=J(.42681-.41855*t),at=J(.14943-5.37511*t);for(T=.84*it+.31*rt+14.27*Vt+7.26*jt+.28*qt+.24*q,x=2.94*it+.31*rt+14.27*Vt+9.34*jt+1.12*qt+.83*q,A=-6.4*it-1.89*q,C=.21*it+.31*rt+14.27*Vt-88.7*jt-15.3*qt+.24*q-1.86*at,I=T-A,f=-3332e-9*J(.59734-5.37261*t)-539e-9*J(.35498-5.37899*t)-64e-9*J(.39943-5.37511*t),S=ms*cr(.60643382+1336.85522467*t-313e-8*d)+T/Hs,y=ms*cr(.37489701+1325.55240982*t+2565e-8*d)+x/Hs,M=ms*cr(.99312619+99.99735956*t-44e-8*d)+A/Hs,b=ms*cr(.25909118+1342.2278298*t-892e-8*d)+C/Hs,w=ms*cr(.82736186+1236.85308708*t-397e-8*d)+I/Hs,h=1;h<=4;++h){switch(h){case 1:c=y,o=4,l=1.000002208;break;case 2:c=M,o=3,l=.997504612-.002495388*t;break;case 3:c=b,o=4,l=1.000002708+139.978*f;break;case 4:c=w,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(k(0,h,1),k(1,h,Math.cos(c)*l),$(0,h,0),$(1,h,Math.sin(c)*l),u=2;u<=o;++u)tt(L(u-1,h),B(u-1,h),L(1,h),B(1,h),(Ct,_t)=>(k(u,h,Ct),$(u,h,_t)));for(u=1;u<=o;++u)k(-u,h,L(u,h)),$(-u,h,-B(u,h))}function nt(Ct,_t,kt,zt){for(var Bt={x:1,y:0},Me=[0,Ct,_t,kt,zt],xe=1;xe<=4;++xe)Me[xe]!==0&&tt(Bt.x,Bt.y,L(Me[xe],xe),B(Me[xe],xe),(Ke,He)=>(Bt.x=Ke,Bt.y=He));return Bt}function z(Ct,_t,kt,zt,Bt,Me,xe,Ke){var He=nt(Bt,Me,xe,Ke);p+=Ct*He.y,P+=_t*He.y,m+=kt*He.x,g+=zt*He.x}z(13.902,14.06,-.001,.2607,0,0,0,4),z(.403,-4.01,.394,.0023,0,0,0,3),z(2369.912,2373.36,.601,28.2333,0,0,0,2),z(-125.154,-112.79,-.725,-.9781,0,0,0,1),z(1.979,6.98,-.445,.0433,1,0,0,4),z(191.953,192.72,.029,3.0861,1,0,0,2),z(-8.466,-13.51,.455,-.1093,1,0,0,1),z(22639.5,22609.07,.079,186.5398,1,0,0,0),z(18.609,3.59,-.094,.0118,1,0,0,-1),z(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),z(3.215,5.44,.192,-.0386,1,0,0,-3),z(-38.428,-38.64,.001,.6008,1,0,0,-4),z(-.393,-1.43,-.092,.0086,1,0,0,-6),z(-.289,-1.59,.123,-.0053,0,1,0,4),z(-24.42,-25.1,.04,-.3,0,1,0,2),z(18.023,17.93,.007,.1494,0,1,0,1),z(-668.146,-126.98,-1.302,-.3997,0,1,0,0),z(.56,.32,-.001,-.0037,0,1,0,-1),z(-165.145,-165.06,.054,1.9178,0,1,0,-2),z(-1.877,-6.46,-.416,.0339,0,1,0,-4),z(.213,1.02,-.074,.0054,2,0,0,4),z(14.387,14.78,-.017,.2833,2,0,0,2),z(-.586,-1.2,.054,-.01,2,0,0,1),z(769.016,767.96,.107,10.1657,2,0,0,0),z(1.75,2.01,-.018,.0155,2,0,0,-1),z(-211.656,-152.53,5.679,-.3039,2,0,0,-2),z(1.225,.91,-.03,-.0088,2,0,0,-3),z(-30.773,-34.07,-.308,.3722,2,0,0,-4),z(-.57,-1.4,-.074,.0109,2,0,0,-6),z(-2.921,-11.75,.787,-.0484,1,1,0,2),z(1.267,1.52,-.022,.0164,1,1,0,1),z(-109.673,-115.18,.461,-.949,1,1,0,0),z(-205.962,-182.36,2.056,1.4437,1,1,0,-2),z(.233,.36,.012,-.0025,1,1,0,-3),z(-4.391,-9.66,-.471,.0673,1,1,0,-4),z(.283,1.53,-.111,.006,1,-1,0,4),z(14.577,31.7,-1.54,.2302,1,-1,0,2),z(147.687,138.76,.679,1.1528,1,-1,0,0),z(-1.089,.55,.021,0,1,-1,0,-1),z(28.475,23.59,-.443,-.2257,1,-1,0,-2),z(-.276,-.38,-.006,-.0036,1,-1,0,-3),z(.636,2.27,.146,-.0102,1,-1,0,-4),z(-.189,-1.68,.131,-.0028,0,2,0,2),z(-7.486,-.66,-.037,-.0086,0,2,0,0),z(-8.096,-16.35,-.74,.0918,0,2,0,-2),z(-5.741,-.04,0,-9e-4,0,0,2,2),z(.255,0,0,0,0,0,2,1),z(-411.608,-.2,0,-.0124,0,0,2,0),z(.584,.84,0,.0071,0,0,2,-1),z(-55.173,-52.14,0,-.1052,0,0,2,-2),z(.254,.25,0,-.0017,0,0,2,-3),z(.025,-1.67,0,.0031,0,0,2,-4),z(1.06,2.96,-.166,.0243,3,0,0,2),z(36.124,50.64,-1.3,.6215,3,0,0,0),z(-13.193,-16.4,.258,-.1187,3,0,0,-2),z(-1.187,-.74,.042,.0074,3,0,0,-4),z(-.293,-.31,-.002,.0046,3,0,0,-6),z(-.29,-1.45,.116,-.0051,2,1,0,2),z(-7.649,-10.56,.259,-.1038,2,1,0,0),z(-8.627,-7.59,.078,-.0192,2,1,0,-2),z(-2.74,-2.54,.022,.0324,2,1,0,-4),z(1.181,3.32,-.212,.0213,2,-1,0,2),z(9.703,11.67,-.151,.1268,2,-1,0,0),z(-.352,-.37,.001,-.0028,2,-1,0,-1),z(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),z(.36,.2,-.012,-.0043,2,-1,0,-4),z(-1.167,-1.25,.008,-.0106,1,2,0,0),z(-7.412,-6.12,.117,.0484,1,2,0,-2),z(-.311,-.65,-.032,.0044,1,2,0,-4),z(.757,1.82,-.105,.0112,1,-2,0,2),z(2.58,2.32,.027,.0196,1,-2,0,0),z(2.533,2.4,-.014,-.0212,1,-2,0,-2),z(-.344,-.57,-.025,.0036,0,3,0,-2),z(-.992,-.02,0,0,1,0,2,2),z(-45.099,-.02,0,-.001,1,0,2,0),z(-.179,-9.52,0,-.0833,1,0,2,-2),z(-.301,-.33,0,.0014,1,0,2,-4),z(-6.382,-3.37,0,-.0481,1,0,-2,2),z(39.528,85.13,0,-.7136,1,0,-2,0),z(9.366,.71,0,-.0112,1,0,-2,-2),z(.202,.02,0,0,1,0,-2,-4),z(.415,.1,0,.0013,0,1,2,0),z(-2.152,-2.26,0,-.0066,0,1,2,-2),z(-1.44,-1.3,0,.0014,0,1,-2,2),z(.384,-.04,0,0,0,1,-2,-2),z(1.938,3.6,-.145,.0401,4,0,0,0),z(-.952,-1.58,.052,-.013,4,0,0,-2),z(-.551,-.94,.032,-.0097,3,1,0,0),z(-.482,-.57,.005,-.0045,3,1,0,-2),z(.681,.96,-.026,.0115,3,-1,0,0),z(-.297,-.27,.002,-9e-4,2,2,0,-2),z(.254,.21,-.003,0,2,-2,0,-2),z(-.25,-.22,.004,.0014,1,3,0,-2),z(-3.996,0,0,4e-4,2,0,2,0),z(.557,-.75,0,-.009,2,0,2,-2),z(-.459,-.38,0,-.0053,2,0,-2,2),z(-1.298,.74,0,4e-4,2,0,-2,0),z(.538,1.14,0,-.0141,2,0,-2,-2),z(.263,.02,0,0,1,1,2,0),z(.426,.07,0,-6e-4,1,1,-2,-2),z(-.304,.03,0,3e-4,1,-1,2,0),z(-.372,-.19,0,-.0027,1,-1,-2,2),z(.418,0,0,0,0,0,4,0),z(-.33,-.04,0,0,3,0,2,0);function Tt(Ct,_t,kt,zt,Bt){return Ct*nt(_t,kt,zt,Bt).y}v=0,v+=Tt(-526.069,0,0,1,-2),v+=Tt(-3.352,0,0,1,-4),v+=Tt(44.297,1,0,1,-2),v+=Tt(-6,1,0,1,-4),v+=Tt(20.599,-1,0,1,0),v+=Tt(-30.598,-1,0,1,-2),v+=Tt(-24.649,-2,0,1,0),v+=Tt(-2,-2,0,1,-2),v+=Tt(-22.571,0,1,1,-2),v+=Tt(10.985,0,-1,1,-2),p+=.82*J(.7736-62.5512*t)+.31*J(.0466-125.1025*t)+.35*J(.5785-25.1042*t)+.66*J(.4591+1335.8075*t)+.64*J(.313-91.568*t)+1.14*J(.148+1331.2898*t)+.21*J(.5918+1056.5859*t)+.44*J(.5784+1322.8595*t)+.24*J(.2275-5.7374*t)+.28*J(.2965+2.6929*t)+.33*J(.3132+6.3368*t),a=b+P/Hs;let Nt=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+v;return{geo_eclip_lon:ms*cr((S+p/Hs)/ms),geo_eclip_lat:Math.PI/(180*3600)*Nt,distance_au:Hs*Hb/(.999953253*g)}}function m1(r,t){return[r.rot[0][0]*t[0]+r.rot[1][0]*t[1]+r.rot[2][0]*t[2],r.rot[0][1]*t[0]+r.rot[1][1]*t[1]+r.rot[2][1]*t[2],r.rot[0][2]*t[0]+r.rot[1][2]*t[1]+r.rot[2][2]*t[2]]}function Cl(r,t,e){const i=I0(t,e);return m1(i,r)}function I0(r,t){const e=r.tt/36525;let i=84381.406,n=((((-951e-10*e+132851e-9)*e-.00114045)*e-1.0790069)*e+5038.481507)*e,s=((((3337e-10*e-467e-9)*e-.00772503)*e+.0512623)*e-.025754)*e+i,a=((((-56e-9*e+170663e-9)*e-.00121197)*e-2.3814292)*e+10.556403)*e;i*=mr,n*=mr,s*=mr,a*=mr;const o=Math.sin(i),c=Math.cos(i),l=Math.sin(-n),h=Math.cos(-n),u=Math.sin(-s),d=Math.cos(-s),f=Math.sin(a),p=Math.cos(a),v=p*h-l*f*d,m=p*l*c+f*d*h*c-o*f*u,g=p*l*o+f*d*h*o+c*f*u,S=-f*h-l*p*d,y=-f*l*c+p*d*h*c-o*p*u,M=-f*l*o+p*d*h*o+c*p*u,b=l*u,w=-u*h*c-o*d,T=-u*h*o+d*c;if(t===Ai.Into2000)return new sa([[v,m,g],[S,y,M],[b,w,T]]);if(t===Ai.From2000)return new sa([[v,S,b],[m,y,w],[g,M,T]]);throw"Invalid precess direction"}function jb(r){const t=.779057273264+.00273781191135448*r.ut,e=r.ut%1;let i=360*((t+e)%1);return i<0&&(i+=360),i}let Uc;function $l(r){if(!Uc||Uc.tt!==r.tt){const t=r.tt/36525;let e=15*Ko(r).ee;const i=jb(r);let s=((e+.014506+((((-368e-10*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+i)%360/15;s<0&&(s+=24),Uc={tt:r.tt,st:s}}return Uc.st}function Qb(r){const t=$e(r);return $l(t)}function g1(r,t){const e=r.latitude*Ee,i=Math.sin(e),n=Math.cos(e),s=1/Math.hypot(n,Ad*i),a=Bb*s,o=r.height/1e3,c=Td*s+o,l=Td*a+o,h=(15*t+r.longitude)*Ee,u=Math.sin(h),d=Math.cos(h);return{pos:[c*n*d/_a,c*n*u/_a,l*i/_a],vel:[-Xp*c*n*u*86400/_a,Xp*c*n*d*86400/_a,0]}}function Pd(r,t,e){const i=C0(t,e);return m1(i,r)}function C0(r,t){const e=Ko(r),i=e.mobl*Ee,n=e.tobl*Ee,s=e.dpsi*mr,a=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(s),u=Math.sin(s),d=h,f=-u*a,p=-u*o,v=u*c,m=h*a*c+o*l,g=h*o*c-a*l,S=u*l,y=h*a*l-o*c,M=h*o*l+a*c;if(t===Ai.From2000)return new sa([[d,v,S],[f,m,y],[p,g,M]]);if(t===Ai.Into2000)return new sa([[d,f,p],[v,m,g],[S,y,M]]);throw"Invalid precess direction"}function P0(r,t,e){return e===Ai.Into2000?Cl(Pd(r,t,e),t,e):Pd(Cl(r,t,e),t,e)}function tw(r,t){const e=$l(r),i=g1(t,e).pos;return P0(i,r,Ai.Into2000)}class Fe{constructor(t,e,i,n){this.x=t,this.y=e,this.z=i,this.t=n}Length(){return Math.hypot(this.x,this.y,this.z)}}class js{constructor(t,e,i,n,s,a,o){this.x=t,this.y=e,this.z=i,this.vx=n,this.vy=s,this.vz=a,this.t=o}}class Kl{constructor(t,e,i){this.lat=Si(t),this.lon=Si(e),this.dist=Si(i)}}class Ld{constructor(t,e,i,n){this.ra=Si(t),this.dec=Si(e),this.dist=Si(i),this.vec=n}}class sa{constructor(t){this.rot=t}}class ew{constructor(t,e,i,n){this.azimuth=Si(t),this.altitude=Si(e),this.ra=Si(i),this.dec=Si(n)}}class iw{constructor(t,e,i){this.vec=t,this.elat=Si(e),this.elon=Si(i)}}function v1(r,t){return new Fe(r[0],r[1],r[2],t)}function nw(r,t){const e=v1(r,t),i=e.x*e.x+e.y*e.y,n=Math.sqrt(i+e.z*e.z);if(i===0){if(e.z===0)throw"Indeterminate sky coordinates";return new Ld(0,e.z<0?-90:90,n,e)}let s=u1*Math.atan2(e.y,e.x);s<0&&(s+=24);const a=os*Math.atan2(r[2],Math.sqrt(i));return new Ld(s,a,n,e)}function Xh(r,t){const e=r*Ee,i=Math.cos(e),n=Math.sin(e);return[i*t[0]+n*t[1],i*t[1]-n*t[0],t[2]]}function M1(r,t,e,i,n){let s=$e(r);L0(t),Si(e),Si(i);const a=Math.sin(t.latitude*Ee),o=Math.cos(t.latitude*Ee),c=Math.sin(t.longitude*Ee),l=Math.cos(t.longitude*Ee),h=Math.sin(i*Ee),u=Math.cos(i*Ee),d=Math.sin(e*Vp),f=Math.cos(e*Vp);let p=[o*l,o*c,a],v=[-a*l,-a*c,o],m=[c,-l,0];const g=-15*$l(s);let S=Xh(g,p),y=Xh(g,v),M=Xh(g,m),b=[u*f,u*d,h];const w=b[0]*S[0]+b[1]*S[1]+b[2]*S[2],T=b[0]*y[0]+b[1]*y[1]+b[2]*y[2],x=b[0]*M[0]+b[1]*M[1]+b[2]*M[2];let A=Math.hypot(T,x),C;A>0?(C=-os*Math.atan2(x,T),C<0&&(C+=360)):C=0;let I=os*Math.atan2(A,w),P=e,V=i;if(n){let X=I,L=T1(n,90-I);if(I-=L,L>0&&I>3e-4){const B=Math.sin(I*Ee),k=Math.cos(I*Ee),$=Math.sin(X*Ee),tt=Math.cos(X*Ee),J=[];for(let it=0;it<3;++it)J.push((b[it]-tt*S[it])/$*B+S[it]*k);A=Math.hypot(J[0],J[1]),A>0?(P=u1*Math.atan2(J[1],J[0]),P<0&&(P+=24)):P=0,V=os*Math.atan2(J[2],A)}}return new ew(C,90-I,P,V)}function L0(r){if(!(r instanceof O0))throw`Not an instance of the Observer class: ${r}`;if(Si(r.latitude),Si(r.longitude),Si(r.height),r.latitude<-90||r.latitude>90)throw`Latitude ${r.latitude} is out of range. Must be -90..+90.`;return r}class O0{constructor(t,e,i){this.latitude=t,this.longitude=e,this.height=i,L0(this)}}function sw(r){const t=$e(r).AddDays(-1/T0),e=Dr(ss.Earth,t),i=[-e.x,-e.y,-e.z],[n,s,a]=P0(i,t,Ai.From2000),o=Ee*Ko(t).tobl,c=Math.cos(o),l=Math.sin(o),h=new Fe(n,s,a,t);return x1(h,c,l)}function aw(r,t,e,i,n){L0(e),Il(i),Il(n);const s=$e(t),a=tw(s,e),o=Vd(r,s,n),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=P0(c,s,Ai.From2000);return nw(l,s)}function rw(r,t,e){const i=$e(r),n=$l(i);let s=g1(t,n).pos;return v1(s,i)}function x1(r,t,e){const i=r.x,n=r.y*t+r.z*e,s=-r.y*e+r.z*t,a=Math.hypot(i,n);let o=0;a>0&&(o=os*Math.atan2(n,i),o<0&&(o+=360));let c=os*Math.atan2(s,a),l=new Fe(i,n,s,r.t);return new iw(l,c,o)}function Od(r){const t=Ko(r.t),e=[r.x,r.y,r.z],i=Cl(e,r.t,Ai.From2000),[n,s,a]=Pd(i,r.t,Ai.From2000),o=new Fe(n,s,a,r.t),c=t.tobl*Ee;return x1(o,Math.cos(c),Math.sin(c))}function Fr(r){const t=$e(r),e=Jb(t),i=e.distance_au*Math.cos(e.geo_eclip_lat),n=[i*Math.cos(e.geo_eclip_lon),i*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],s=Zb(t,n),a=Cl(s,t,Ai.Into2000);return new Fe(a[0],a[1],a[2],t)}function y1(r){const t=$e(r),e=1e-5,i=t.AddDays(-e),n=t.AddDays(+e),s=Fr(i),a=Fr(n);return new js((s.x+a.x)/2,(s.y+a.y)/2,(s.z+a.z)/2,(a.x-s.x)/(2*e),(a.y-s.y)/(2*e),(a.z-s.z)/(2*e),t)}function ow(r){const t=$e(r),e=y1(t),i=1+f1;return new js(e.x/i,e.y/i,e.z/i,e.vx/i,e.vy/i,e.vz/i,t)}function Rr(r,t,e){let i=1,n=0;for(let s of r){let a=0;for(let[c,l,h]of s)a+=c*Math.cos(l+t*h);let o=i*a;e&&(o%=ms),n+=o,i*=t}return n}function Yh(r,t){let e=1,i=0,n=0,s=0;for(let a of r){let o=0,c=0;for(let[l,h,u]of a){let d=h+t*u;o+=l*u*Math.sin(d),s>0&&(c+=l*Math.cos(d))}n+=s*i*c-e*o,i=e,e*=t,++s}return n}const Mo=365250,Nd=0,Fd=1,Ud=2;function kd(r){return new Li(r[0]+44036e-11*r[1]-190919e-12*r[2],-479966e-12*r[0]+.917482137087*r[1]-.397776982902*r[2],.397776982902*r[1]+.917482137087*r[2])}function _1(r,t,e){const i=e*Math.cos(t),n=Math.cos(r),s=Math.sin(r);return[i*n,i*s,e*Math.sin(t)]}function Dr(r,t){const e=t.tt/Mo,i=Rr(r[Nd],e,!0),n=Rr(r[Fd],e,!1),s=Rr(r[Ud],e,!1),a=_1(i,n,s);return kd(a).ToAstroVector(t)}function zd(r,t){const e=t/Mo,i=Rr(r[Nd],e,!0),n=Rr(r[Fd],e,!1),s=Rr(r[Ud],e,!1),a=Yh(r[Nd],e),o=Yh(r[Fd],e),c=Yh(r[Ud],e),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),d=Math.sin(n),f=+(c*u*l)-s*d*l*o-s*u*h*a,p=+(c*u*h)-s*d*h*o+s*u*l*a,v=+(c*d)+s*u*o,m=_1(i,n,s),g=[f/Mo,p/Mo,v/Mo],S=kd(m),y=kd(g);return new Fa(t,S,y)}function kc(r,t,e,i){const n=i/(i+R0),s=Dr(ss[e],t);r.x+=n*s.x,r.y+=n*s.y,r.z+=n*s.z}function cw(r){const t=new Fe(0,0,0,r);return kc(t,r,wt.Jupiter,Rd),kc(t,r,wt.Saturn,Dd),kc(t,r,wt.Uranus,Id),kc(t,r,wt.Neptune,Cd),t}const Bd=51,lw=29200,gr=146,gs=201,Ta=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class Li{constructor(t,e,i){this.x=t,this.y=e,this.z=i}clone(){return new Li(this.x,this.y,this.z)}ToAstroVector(t){return new Fe(this.x,this.y,this.z,t)}static zero(){return new Li(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(t){return new Li(this.x+t.x,this.y+t.y,this.z+t.z)}sub(t){return new Li(this.x-t.x,this.y-t.y,this.z-t.z)}incr(t){this.x+=t.x,this.y+=t.y,this.z+=t.z}decr(t){this.x-=t.x,this.y-=t.y,this.z-=t.z}mul(t){return new Li(t*this.x,t*this.y,t*this.z)}div(t){return new Li(this.x/t,this.y/t,this.z/t)}mean(t){return new Li((this.x+t.x)/2,(this.y+t.y)/2,(this.z+t.z)/2)}neg(){return new Li(-this.x,-this.y,-this.z)}}class Fa{constructor(t,e,i){this.tt=t,this.r=e,this.v=i}clone(){return new Fa(this.tt,this.r,this.v)}sub(t){return new Fa(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function hw(r){let[t,[e,i,n],[s,a,o]]=r;return new Fa(t,new Li(e,i,n),new Li(s,a,o))}function zc(r,t,e,i){const n=i/(i+R0),s=zd(ss[e],t);return r.r.incr(s.r.mul(n)),r.v.incr(s.v.mul(n)),s}function ao(r,t,e){const i=e.sub(r),n=i.quadrature();return i.mul(t/(n*Math.sqrt(n)))}class Zl{constructor(t){let e=new Fa(t,new Li(0,0,0),new Li(0,0,0));this.Jupiter=zc(e,t,wt.Jupiter,Rd),this.Saturn=zc(e,t,wt.Saturn,Dd),this.Uranus=zc(e,t,wt.Uranus,Id),this.Neptune=zc(e,t,wt.Neptune,Cd),this.Jupiter.r.decr(e.r),this.Jupiter.v.decr(e.v),this.Saturn.r.decr(e.r),this.Saturn.v.decr(e.v),this.Uranus.r.decr(e.r),this.Uranus.v.decr(e.v),this.Neptune.r.decr(e.r),this.Neptune.v.decr(e.v),this.Sun=new Fa(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=ao(t,R0,this.Sun.r);return e.incr(ao(t,Rd,this.Jupiter.r)),e.incr(ao(t,Dd,this.Saturn.r)),e.incr(ao(t,Id,this.Uranus.r)),e.incr(ao(t,Cd,this.Neptune.r)),e}}class Jl{constructor(t,e,i,n){this.tt=t,this.r=e,this.v=i,this.a=n}clone(){return new Jl(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class S1{constructor(t,e){this.bary=t,this.grav=e}}function Pl(r,t,e,i){return new Li(t.x+r*(e.x+r*i.x/2),t.y+r*(e.y+r*i.y/2),t.z+r*(e.z+r*i.z/2))}function qp(r,t,e){return new Li(t.x+r*e.x,t.y+r*e.y,t.z+r*e.z)}function Hd(r,t){const e=r-t.tt,i=new Zl(r),n=Pl(e,t.r,t.v,t.a),s=i.Acceleration(n).mean(t.a),a=Pl(e,t.r,t.v,s),o=t.v.add(s.mul(e)),c=i.Acceleration(a),l=new Jl(r,a,o,c);return new S1(i,l)}const uw=[];function b1(r,t){const e=Math.floor(r);return e<0?0:e>=t?t-1:e}function Gd(r){const t=hw(r),e=new Zl(t.tt),i=t.r.add(e.Sun.r),n=t.v.add(e.Sun.v),s=e.Acceleration(i),a=new Jl(t.tt,i,n,s);return new S1(e,a)}function dw(r,t){const e=Ta[0][0];if(t<e||t>Ta[Bd-1][0])return null;const i=b1((t-e)/lw,Bd-1);if(!r[i]){const s=r[i]=[];s[0]=Gd(Ta[i]).grav,s[gs-1]=Gd(Ta[i+1]).grav;let a,o=s[0].tt;for(a=1;a<gs-1;++a)s[a]=Hd(o+=gr,s[a-1]).grav;o=s[gs-1].tt;var n=[];for(n[gs-1]=s[gs-1],a=gs-2;a>0;--a)n[a]=Hd(o-=gr,n[a+1]).grav;for(a=gs-2;a>0;--a){const c=a/(gs-1);s[a].r=s[a].r.mul(1-c).add(n[a].r.mul(c)),s[a].v=s[a].v.mul(1-c).add(n[a].v.mul(c)),s[a].a=s[a].a.mul(1-c).add(n[a].a.mul(c))}}return r[i]}function $p(r,t,e){let i=Gd(r);const n=Math.ceil((t-i.grav.tt)/e);for(let s=0;s<n;++s)i=Hd(s+1===n?t:i.grav.tt+e,i.grav);return i}function w1(r,t){let e,i,n;const s=dw(uw,r.tt);if(s){const a=b1((r.tt-s[0].tt)/gr,gs-1),o=s[a],c=s[a+1],l=o.a.mean(c.a),h=Pl(r.tt-o.tt,o.r,o.v,l),u=qp(r.tt-o.tt,o.v,l),d=Pl(r.tt-c.tt,c.r,c.v,l),f=qp(r.tt-c.tt,c.v,l),p=(r.tt-o.tt)/gr;e=h.mul(1-p).add(d.mul(p)),i=u.mul(1-p).add(f.mul(p))}else{let a;r.tt<Ta[0][0]?a=$p(Ta[0],r.tt,-gr):a=$p(Ta[Bd-1],r.tt,+gr),e=a.grav.r,i=a.grav.v,n=a.bary}return n||(n=new Zl(r.tt)),e=e.sub(n.Sun.r),i=i.sub(n.Sun.v),new js(e.x,e.y,e.z,i.x,i.y,i.z,r)}function ea(r,t){var e=$e(t);if(r in ss)return Dr(ss[r],e);if(r===wt.Pluto){const a=w1(e);return new Fe(a.x,a.y,a.z,e)}if(r===wt.Sun)return new Fe(0,0,0,e);if(r===wt.Moon){var i=Dr(ss.Earth,e),n=Fr(e);return new Fe(i.x+n.x,i.y+n.y,i.z+n.z,e)}if(r===wt.EMB){const a=Dr(ss.Earth,e),o=Fr(e),c=1+f1;return new Fe(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,e)}if(r===wt.SSB)return cw(e);const s=D0(r);if(s){const a=new Kl(s.dec,15*s.ra,s.dist);return N0(a,e)}throw`HelioVector: Unknown body "${r}"`}function fw(r,t){let e=t,i=0;for(let n=0;n<10;++n){const s=r(e),a=s.Length()/T0;if(a>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-a);if(i=Math.abs(o.tt-e.tt),i<1e-9)return s;e=o}throw`Light-travel time solver did not converge: dt = ${i}`}class pw{constructor(t,e,i,n){this.observerBody=t,this.targetBody=e,this.aberration=i,this.observerPos=n}Position(t){this.aberration&&(this.observerPos=ea(this.observerBody,t));const e=ea(this.targetBody,t);return new Fe(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function mw(r,t,e,i){Il(i);const n=$e(r);if(D0(e)){const o=ea(e,n);if(i){const l=vw(t,n),h=new Fe(o.x-l.x,o.y-l.y,o.z-l.z,n),u=T0/h.Length();return new Fe(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,n)}const c=ea(t,n);return new Fe(o.x-c.x,o.y-c.y,o.z-c.z,n)}let s;i?s=new Fe(0,0,0,n):s=ea(t,n);const a=new pw(t,e,i,s);return fw(o=>a.Position(o),n)}function Vd(r,t,e){Il(e);const i=$e(t);switch(r){case wt.Earth:return new Fe(0,0,0,i);case wt.Moon:return Fr(i);default:const n=mw(i,wt.Earth,r,e);return n.t=i,n}}function gw(r,t){return new js(r.r.x,r.r.y,r.r.z,r.v.x,r.v.y,r.v.z,t)}function vw(r,t){const e=$e(t);switch(r){case wt.Sun:return new js(0,0,0,0,0,0,e);case wt.SSB:const i=new Zl(e.tt);return new js(-i.Sun.r.x,-i.Sun.r.y,-i.Sun.r.z,-i.Sun.v.x,-i.Sun.v.y,-i.Sun.v.z,e);case wt.Mercury:case wt.Venus:case wt.Earth:case wt.Mars:case wt.Jupiter:case wt.Saturn:case wt.Uranus:case wt.Neptune:const n=zd(ss[r],e.tt);return gw(n,e);case wt.Pluto:return w1(e);case wt.Moon:case wt.EMB:const s=zd(ss.Earth,e.tt),a=r==wt.Moon?y1(e):ow(e);return new js(a.x+s.r.x,a.y+s.r.y,a.z+s.r.z,a.vx+s.v.x,a.vy+s.v.y,a.vz+s.v.z,e);default:if(D0(r)){const o=ea(r,e);return new js(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${r}"`}}function Mw(r){for(;r<0;)r+=360;for(;r>=360;)r-=360;return r}function xw(r,t,e){if(r===wt.Earth||t===wt.Earth)throw"The Earth does not have a longitude as seen from itself.";const i=$e(e),n=Vd(r,i,!1),s=Od(n),a=Vd(t,i,!1),o=Od(a);return Mw(s.elon-o.elon)}function yw(r,t,e,i){let n,s=0,a=0,o=0;switch(r){case wt.Mercury:n=-.6,s=4.98,a=-4.88,o=3.02;break;case wt.Venus:t<163.6?(n=-4.47,s=1.03,a=.57,o=.13):(n=.98,s=-1.02);break;case wt.Mars:n=-1.52,s=1.6;break;case wt.Jupiter:n=-9.4,s=.5;break;case wt.Uranus:n=-7.19,s=.25;break;case wt.Neptune:n=-6.87;break;case wt.Pluto:n=-1,s=4;break;default:throw`VisualMagnitude: unsupported body ${r}`}const c=t/100;let l=n+c*(s+c*(a+c*o));return l+=5*Math.log10(e*i),l}function _w(r,t,e,i,n){const s=Od(i),a=Ee*28.06,o=Ee*(169.51+382e-7*n.tt),c=Ee*s.elat,l=Ee*s.elon,h=Math.asin(Math.sin(c)*Math.cos(a)-Math.cos(c)*Math.sin(a)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*r;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(t*e),{mag:d,ring_tilt:os*h}}function Sw(r,t,e){let i=r*Ee,n=i*i,s=n*n,a=-12.717+1.49*Math.abs(i)+.0431*s;const o=385000.6/_a;let c=e/o;return a+=5*Math.log10(t*c),a}class bw{constructor(t,e,i,n,s,a,o,c){this.time=t,this.mag=e,this.phase_angle=i,this.helio_dist=n,this.geo_dist=s,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(Ee*i))/2}}function E1(r,t){if(r===wt.Earth)throw"The illumination of the Earth is not defined.";const e=$e(t),i=Dr(ss.Earth,e);let n,s,a,o;r===wt.Sun?(a=new Fe(-i.x,-i.y,-i.z,e),s=new Fe(0,0,0,e),n=0):(r===wt.Moon?(a=Fr(e),s=new Fe(i.x+a.x,i.y+a.y,i.z+a.z,e)):(s=ea(r,t),a=new Fe(s.x-i.x,s.y-i.y,s.z-i.z,e)),n=Gb(a,s));let c=a.Length(),l=s.Length(),h;if(r===wt.Sun)o=zb+5*Math.log10(c);else if(r===wt.Moon)o=Sw(n,l,c);else if(r===wt.Saturn){const u=_w(n,l,c,a,e);o=u.mag,h=u.ring_tilt}else o=yw(r,n,l,c);return new bw(e,o,n,l,c,a,s,h)}function ww(r){return xw(wt.Moon,wt.Sun,r)}var Kp;(function(r){r[r.Pericenter=0]="Pericenter",r[r.Apocenter=1]="Apocenter"})(Kp||(Kp={}));function A1(r,t){return new sa([[t.rot[0][0]*r.rot[0][0]+t.rot[1][0]*r.rot[0][1]+t.rot[2][0]*r.rot[0][2],t.rot[0][1]*r.rot[0][0]+t.rot[1][1]*r.rot[0][1]+t.rot[2][1]*r.rot[0][2],t.rot[0][2]*r.rot[0][0]+t.rot[1][2]*r.rot[0][1]+t.rot[2][2]*r.rot[0][2]],[t.rot[0][0]*r.rot[1][0]+t.rot[1][0]*r.rot[1][1]+t.rot[2][0]*r.rot[1][2],t.rot[0][1]*r.rot[1][0]+t.rot[1][1]*r.rot[1][1]+t.rot[2][1]*r.rot[1][2],t.rot[0][2]*r.rot[1][0]+t.rot[1][2]*r.rot[1][1]+t.rot[2][2]*r.rot[1][2]],[t.rot[0][0]*r.rot[2][0]+t.rot[1][0]*r.rot[2][1]+t.rot[2][0]*r.rot[2][2],t.rot[0][1]*r.rot[2][0]+t.rot[1][1]*r.rot[2][1]+t.rot[2][1]*r.rot[2][2],t.rot[0][2]*r.rot[2][0]+t.rot[1][2]*r.rot[2][1]+t.rot[2][2]*r.rot[2][2]]])}function N0(r,t){t=$e(t);const e=r.lat*Ee,i=r.lon*Ee,n=r.dist*Math.cos(e);return new Fe(n*Math.cos(i),n*Math.sin(i),r.dist*Math.sin(e),t)}function F0(r){const t=Ew(r);return new Ld(t.lon/15,t.lat,t.dist,r)}function Ew(r){const t=r.x*r.x+r.y*r.y,e=Math.sqrt(t+r.z*r.z);let i,n;if(t===0){if(r.z===0)throw"Zero-length vector not allowed.";n=0,i=r.z<0?-90:90}else n=os*Math.atan2(r.y,r.x),n<0&&(n+=360),i=os*Math.atan2(r.z,Math.sqrt(t));return new Kl(i,n,e)}function T1(r,t){let e;if(Si(t),t<-90||t>90)return 0;if(r==="normal"||r==="jplhor"){let i=t;i<-1&&(i=-1),e=1.02/Math.tan((i+10.3/(i+5.11))*Ee)/60,r==="normal"&&t<-1&&(e*=(t+90)/89)}else if(!r)e=0;else throw`Invalid refraction option: ${r}`;return e}function Ir(r,t){return new Fe(r.rot[0][0]*t.x+r.rot[1][0]*t.y+r.rot[2][0]*t.z,r.rot[0][1]*t.x+r.rot[1][1]*t.y+r.rot[2][1]*t.z,r.rot[0][2]*t.x+r.rot[1][2]*t.y+r.rot[2][2]*t.z,t.t)}function Aw(){return new sa([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function Tw(){return new sa([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function R1(r){r=$e(r);const t=I0(r,Ai.From2000),e=C0(r,Ai.From2000);return A1(t,e)}function Rw(r){r=$e(r);const t=C0(r,Ai.Into2000),e=I0(r,Ai.Into2000);return A1(t,e)}function Dw(r){const e=Ko($e(r)).tobl*Ee,i=Math.cos(e),n=Math.sin(e);return new sa([[1,0,0],[0,+i,+n],[0,-n,+i]])}var Zp;(function(r){r.Penumbral="penumbral",r.Partial="partial",r.Annular="annular",r.Total="total"})(Zp||(Zp={}));var Jp;(function(r){r[r.Invalid=0]="Invalid",r[r.Ascending=1]="Ascending",r[r.Descending=-1]="Descending"})(Jp||(Jp={}));const Iw=["Venus","Mars","Jupiter","Saturn"];function D1(r){return new O0(r.lat,r.lng,r.elevationM)}function U0(r,t,e,i,n=!0){const s=M1(e,D1(i),r,t,n?"normal":void 0);return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}class Pn{up;north;west;constructor(t,e){const i=$e(t),n=Math.sin(e.lat*vs),s=Math.cos(e.lat*vs),a=Math.sin(e.lng*vs),o=Math.cos(e.lng*vs),c=-15*Qb(i),l=Rw(i);this.up=Pn.rotate(l,Pn.spin(c,[s*o,s*a,n]),i),this.north=Pn.rotate(l,Pn.spin(c,[-n*o,-n*a,s]),i),this.west=Pn.rotate(l,Pn.spin(c,[a,-o,0]),i)}static ofJ2000(t,e,i,n,s=!0){const a=$e(i),o=N0(new Kl(e,t*15,1),a),c=F0(Ir(R1(a),o));return U0(c.ra,c.dec,i,n,s)}position(t,e){const i=Math.sin(e*vs),n=Math.cos(e*vs),s=Math.sin(t*Qp),a=Math.cos(t*Qp),o=n*a,c=n*s,l=i,h=o*this.up[0]+c*this.up[1]+l*this.up[2],u=o*this.north[0]+c*this.north[1]+l*this.north[2],d=o*this.west[0]+c*this.west[1]+l*this.west[2],f=Math.hypot(u,d);let p=0;f>0&&(p=-jp*Math.atan2(d,u),p<0&&(p+=360));let v=jp*Math.atan2(f,h);return v-=T1("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(t,[e,i,n]){const s=Math.cos(t*vs),a=Math.sin(t*vs);return[s*e+a*i,s*i-a*e,n]}static rotate(t,[e,i,n],s){const a=Ir(t,new Fe(e,i,n,s));return[a.x,a.y,a.z]}}const vs=Math.PI/180,jp=180/Math.PI,Qp=15*vs;function qh(r,t,e){const i=D1(e),n=aw(wt[r],t,i,!0,!0),s=M1(t,i,n.ra,n.dec,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function $h(r,t){return E1(wt[r],t).mag}function Cw(r){const t=ww(r),e=E1(wt.Moon,r);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const Pw=2e3,Lw=3,Ow=20;function Bc(r,t,e){if(r.year===void 0&&r.month===void 0&&r.day===void 0&&r.hour===void 0)return;const i=r.year!==void 0,n=r.year??Pw,s=r.month??(i?1:Lw),a=r.day??(i?1:Ow),o=e??Math.round(t/15);return new Date(Date.UTC(n,s-1,a,(r.hour??12)-o,r.minute??0,r.second??0))}const tm=["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"];class Ia{static POINT_DEG=360/16;static point(t,e=tm){const i=(t%360+360)%360,n=Math.round(i/Ia.POINT_DEG)%16;return e[n]}static POINTS=tm;static towards(t,e){return e?e.towards(Ia.point(t,e.compassPoints)):`to the ${Ia.point(t)}`}}class Kn{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static FALLOFF={core:Kn.CORE,rim:Kn.RIM};static apply(t){t.transparent=!0,t.depthWrite=!1,t.onBeforeCompile=e=>{e.fragmentShader=Kn.patch(e.fragmentShader)}}static patch(t){return t.replace(Kn.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
5931
5988
  // Outside the inscribed circle there is no star at all — this is what kills the corners.
5932
5989
  if ( distanceFromCentre > ${Kn.RIM.toFixed(2)} ) discard;
5933
5990
  float glare = 1.0 - smoothstep( ${Kn.CORE.toFixed(2)}, ${Kn.RIM.toFixed(2)}, distanceFromCentre );
@@ -6037,7 +6094,7 @@ void main() {`).replace(Kn.ANCHOR,`float sigma = max(${ae.MIN_SIGMA_PX.toFixed(2
6037
6094
  if (which < 2) gl_FragColor = vec4(sum * 4.0 * PI / SAMPLES, 1.0);
6038
6095
  else gl_FragColor = vec4(count > 0.0 ? logSum / count : -27.6, count, 0.0, 1.0);
6039
6096
  }
6040
- `,depthTest:!1,depthWrite:!1}),this.scene.add(new Dt(new Xi(2,2),this.material))}measure(t,e,i,n){if(this.reading)return;const s=this.material.uniforms;s.uProbe.value=e;const a=Math.cos(To.SOURCE_CONE_DEG*Math.PI/180);[s.uExcludeA.value,s.uExcludeB.value].forEach((h,u)=>{const d=i[u];d?h.set(d.x,d.y,d.z,a):h.set(0,-1,0,2)});const c=t.getRenderTarget();t.setRenderTarget(this.target),t.render(this.scene,this.camera),t.setRenderTarget(c),this.reading=!0;const l=new Float32Array(12);t.readRenderTargetPixelsAsync(this.target,0,0,3,1,l).then(()=>n({up:[l[0],l[1],l[2]],down:[l[4],l[5],l[6]],logAverage:l[8]})).catch(()=>{}).finally(()=>{this.reading=!1})}dispose(){this.target.dispose(),this.material.dispose(),this.scene.children[0].geometry.dispose()}}const N5=[{name:"Sirius",raHours:6.7525,decDeg:-16.7161,mag:-1.44},{name:"Canopus",raHours:6.3992,decDeg:-52.6957,mag:-.62},{name:"Arcturus",raHours:14.261,decDeg:19.1824,mag:-.05},{name:"Rigil Kentaurus",raHours:14.6608,decDeg:-60.834,mag:-.01},{name:"Vega",raHours:18.6156,decDeg:38.7837,mag:.03},{name:"Capella",raHours:5.2782,decDeg:45.998,mag:.08},{name:"Rigel",raHours:5.2423,decDeg:-8.2016,mag:.18},{name:"Procyon",raHours:7.655,decDeg:5.225,mag:.4},{name:"Achernar",raHours:1.6286,decDeg:-57.2368,mag:.45},{name:"Betelgeuse",raHours:5.9195,decDeg:7.4071,mag:.45},{name:"Hadar",raHours:14.0637,decDeg:-60.373,mag:.61},{name:"Altair",raHours:19.8464,decDeg:8.8683,mag:.76},{name:"Acrux",raHours:12.4433,decDeg:-63.0991,mag:.77},{name:"Aldebaran",raHours:4.5987,decDeg:16.5093,mag:.87},{name:"Spica",raHours:13.4199,decDeg:-11.1613,mag:.98},{name:"Antares",raHours:16.4901,decDeg:-26.432,mag:1.06},{name:"Pollux",raHours:7.7553,decDeg:28.0262,mag:1.16},{name:"Fomalhaut",raHours:22.9608,decDeg:-29.6222,mag:1.17},{name:"Mimosa",raHours:12.7954,decDeg:-59.6888,mag:1.25},{name:"Deneb",raHours:20.6905,decDeg:45.2803,mag:1.25},{name:"Toliman",raHours:14.6603,decDeg:-60.8383,mag:1.35},{name:"Regulus",raHours:10.1395,decDeg:11.9672,mag:1.36},{name:"Adhara",raHours:6.9771,decDeg:-28.9721,mag:1.5},{name:"Castor",raHours:7.5766,decDeg:31.8883,mag:1.58},{name:"Gacrux",raHours:12.5194,decDeg:-57.1132,mag:1.59},{name:"Shaula",raHours:17.5601,decDeg:-37.1038,mag:1.62},{name:"Bellatrix",raHours:5.4189,decDeg:6.3497,mag:1.64},{name:"Elnath",raHours:5.4382,decDeg:28.6075,mag:1.65},{name:"Miaplacidus",raHours:9.22,decDeg:-69.7172,mag:1.67},{name:"Alnilam",raHours:5.6036,decDeg:-1.2019,mag:1.69},{name:"Alnair",raHours:22.1372,decDeg:-46.961,mag:1.73},{name:"Alnitak",raHours:5.6793,decDeg:-1.9426,mag:1.74},{name:"γ² Velorum",raHours:8.1589,decDeg:-47.3366,mag:1.75},{name:"Alioth",raHours:12.9005,decDeg:55.9598,mag:1.76},{name:"Mirfak",raHours:3.4054,decDeg:49.8612,mag:1.79},{name:"Kaus Australis",raHours:18.4029,decDeg:-34.3846,mag:1.79},{name:"Dubhe",raHours:11.0622,decDeg:61.751,mag:1.81},{name:"Wezen",raHours:7.1399,decDeg:-26.3932,mag:1.83},{name:"Alkaid",raHours:13.7924,decDeg:49.3133,mag:1.85},{name:"Avior",raHours:8.3752,decDeg:-59.5095,mag:1.86},{name:"Sargas",raHours:17.622,decDeg:-42.9978,mag:1.86},{name:"Menkalinan",raHours:5.9921,decDeg:44.9474,mag:1.9},{name:"Atria",raHours:16.8111,decDeg:-69.0277,mag:1.91},{name:"Alhena",raHours:6.6285,decDeg:16.3993,mag:1.93},{name:"Alsephina",raHours:8.7451,decDeg:-54.7088,mag:1.93},{name:"Peacock",raHours:20.4275,decDeg:-56.7351,mag:1.94},{name:"Polaris",raHours:2.5297,decDeg:89.2641,mag:1.97},{name:"Mirzam",raHours:6.3783,decDeg:-17.9559,mag:1.98},{name:"Alphard",raHours:9.4598,decDeg:-8.6586,mag:1.99},{name:"Hamal",raHours:2.1196,decDeg:23.4624,mag:2.01},{name:"Algieba",raHours:10.3329,decDeg:19.8415,mag:2.01},{name:"Diphda",raHours:.7265,decDeg:-17.9866,mag:2.04},{name:"Nunki",raHours:18.9211,decDeg:-26.2967,mag:2.05},{name:"Menkent",raHours:14.1114,decDeg:-36.37,mag:2.06},{name:"Alpheratz",raHours:.1398,decDeg:29.0904,mag:2.07},{name:"Mirach",raHours:1.1622,decDeg:35.6206,mag:2.07},{name:"Saiph",raHours:5.7959,decDeg:-9.6696,mag:2.07},{name:"Kochab",raHours:14.8451,decDeg:74.1555,mag:2.07},{name:"Tiaki",raHours:22.7111,decDeg:-46.8846,mag:2.07},{name:"Rasalhague",raHours:17.5822,decDeg:12.56,mag:2.08},{name:"Algol",raHours:3.1361,decDeg:40.9556,mag:2.09},{name:"Almach",raHours:2.065,decDeg:42.3297,mag:2.1},{name:"Denebola",raHours:11.8177,decDeg:14.5721,mag:2.14},{name:"Cih",raHours:.9451,decDeg:60.7167,mag:2.15},{name:"γ Centauri",raHours:12.692,decDeg:-48.9599,mag:2.2},{name:"Naos",raHours:8.0597,decDeg:-40.0031,mag:2.21},{name:"Aspidiske",raHours:9.2848,decDeg:-59.2752,mag:2.21},{name:"Alphecca",raHours:15.5781,decDeg:26.7147,mag:2.22},{name:"Suhail",raHours:9.1333,decDeg:-43.4326,mag:2.23},{name:"Mizar",raHours:13.3987,decDeg:54.9254,mag:2.23},{name:"Sadr",raHours:20.3705,decDeg:40.2567,mag:2.23},{name:"Schedar",raHours:.6751,decDeg:56.5373,mag:2.24},{name:"Eltanin",raHours:17.9434,decDeg:51.4889,mag:2.24},{name:"Mintaka",raHours:5.5334,decDeg:-.2991,mag:2.25},{name:"Caph",raHours:.1529,decDeg:59.1498,mag:2.28},{name:"ε Centauri",raHours:13.6648,decDeg:-53.4664,mag:2.29},{name:"Dschubba",raHours:16.0056,decDeg:-22.6217,mag:2.29},{name:"Larawag",raHours:16.8361,decDeg:-34.2932,mag:2.29},{name:"α Lupi",raHours:14.6988,decDeg:-47.3882,mag:2.3},{name:"η Centauri",raHours:14.5918,decDeg:-42.1578,mag:2.33},{name:"Merak",raHours:11.0307,decDeg:56.3824,mag:2.34},{name:"Izar",raHours:14.7498,decDeg:27.0742,mag:2.35},{name:"Enif",raHours:21.7364,decDeg:9.875,mag:2.38},{name:"κ Scorpii",raHours:17.7081,decDeg:-39.03,mag:2.39},{name:"Ankaa",raHours:.4381,decDeg:-42.306,mag:2.4},{name:"Phecda",raHours:11.8972,decDeg:53.6948,mag:2.41},{name:"Sabik",raHours:17.173,decDeg:-15.7249,mag:2.43},{name:"Scheat",raHours:23.0629,decDeg:28.0828,mag:2.44},{name:"Aludra",raHours:7.4016,decDeg:-29.3031,mag:2.45},{name:"Alderamin",raHours:21.3096,decDeg:62.5856,mag:2.45},{name:"Markeb",raHours:9.3686,decDeg:-55.0107,mag:2.47},{name:"Aljanah",raHours:20.7702,decDeg:33.9703,mag:2.48},{name:"Markab",raHours:23.0793,decDeg:15.2053,mag:2.49},{name:"Menkar",raHours:3.038,decDeg:4.0897,mag:2.54},{name:"ζ Ophiuchi",raHours:16.6193,decDeg:-10.5671,mag:2.54},{name:"ζ Centauri",raHours:13.9257,decDeg:-47.2884,mag:2.55},{name:"Zosma",raHours:11.2351,decDeg:20.5237,mag:2.56},{name:"Acrab",raHours:16.0906,decDeg:-19.8055,mag:2.56},{name:"Arneb",raHours:5.5455,decDeg:-17.8223,mag:2.58},{name:"δ Centauri",raHours:12.1393,decDeg:-50.7224,mag:2.58},{name:"Gienah",raHours:12.2634,decDeg:-17.5419,mag:2.58},{name:"Ascella",raHours:19.0435,decDeg:-29.8801,mag:2.6},{name:"Zubeneschamali",raHours:15.2834,decDeg:-9.3829,mag:2.61},{name:"Unukalhai",raHours:15.7378,decDeg:6.4256,mag:2.63},{name:"Sheratan",raHours:1.9107,decDeg:20.808,mag:2.64},{name:"Phact",raHours:5.6608,decDeg:-34.0741,mag:2.65},{name:"Mahasim",raHours:5.9954,decDeg:37.2126,mag:2.65},{name:"Kraz",raHours:12.5731,decDeg:-23.3968,mag:2.65},{name:"Ruchbah",raHours:1.4302,decDeg:60.2353,mag:2.66},{name:"Muphrid",raHours:13.9114,decDeg:18.3977,mag:2.68},{name:"β Lupi",raHours:14.9755,decDeg:-43.134,mag:2.68},{name:"Hassaleh",raHours:4.9499,decDeg:33.1661,mag:2.69},{name:"μ Velorum",raHours:10.7795,decDeg:-49.4203,mag:2.69},{name:"α Muscae",raHours:12.6197,decDeg:-69.1356,mag:2.69},{name:"Lesath",raHours:17.5127,decDeg:-37.2958,mag:2.7},{name:"π Puppis",raHours:7.2857,decDeg:-37.0975,mag:2.71},{name:"Kaus Media",raHours:18.3499,decDeg:-29.8281,mag:2.72},{name:"Tarazed",raHours:19.771,decDeg:10.6133,mag:2.72},{name:"Yed Prior",raHours:16.2391,decDeg:-3.6943,mag:2.73},{name:"Athebyne",raHours:16.3999,decDeg:61.5142,mag:2.73},{name:"θ Carinae",raHours:10.7159,decDeg:-64.3945,mag:2.74},{name:"Porrima",raHours:12.6943,decDeg:-1.4494,mag:2.74},{name:"Hatysa",raHours:5.5906,decDeg:-5.9099,mag:2.75},{name:"ι Centauri",raHours:13.3433,decDeg:-36.7123,mag:2.75},{name:"Zubenelgenubi",raHours:14.848,decDeg:-16.0418,mag:2.75},{name:"Cebalrai",raHours:17.7245,decDeg:4.5673,mag:2.76},{name:"Cursa",raHours:5.1308,decDeg:-5.0864,mag:2.78},{name:"Kornephoros",raHours:16.5037,decDeg:21.4896,mag:2.78},{name:"Rasalgethi",raHours:17.2441,decDeg:14.3903,mag:2.78},{name:"Imai",raHours:12.2524,decDeg:-58.7489,mag:2.79},{name:"Rastaban",raHours:17.5072,decDeg:52.3014,mag:2.79},{name:"γ Lupi",raHours:15.5857,decDeg:-41.1668,mag:2.8},{name:"Nihal",raHours:5.4708,decDeg:-20.7594,mag:2.81},{name:"ζ Herculis",raHours:16.6881,decDeg:31.6027,mag:2.81},{name:"β Hydri",raHours:.4279,decDeg:-77.2542,mag:2.82},{name:"Paikauhale",raHours:16.598,decDeg:-28.216,mag:2.82},{name:"Kaus Borealis",raHours:18.4662,decDeg:-25.4217,mag:2.82},{name:"Algenib",raHours:.2206,decDeg:15.1836,mag:2.83},{name:"Tureis",raHours:8.1257,decDeg:-24.3043,mag:2.83},{name:"β Trianguli Australis",raHours:15.9191,decDeg:-63.4307,mag:2.83},{name:"ζ Persei",raHours:3.9022,decDeg:31.8836,mag:2.84},{name:"β Arae",raHours:17.4217,decDeg:-55.5299,mag:2.84},{name:"α Arae",raHours:17.5307,decDeg:-49.8761,mag:2.84},{name:"Alcyone",raHours:3.7914,decDeg:24.1051,mag:2.85},{name:"Vindemiatrix",raHours:13.0363,decDeg:10.9591,mag:2.85},{name:"Deneb Algedi",raHours:21.784,decDeg:-16.1273,mag:2.85},{name:"Castor B",raHours:7.5768,decDeg:31.8905,mag:2.85},{name:"α Hydri",raHours:1.9795,decDeg:-61.5699,mag:2.86},{name:"Fawaris",raHours:19.7496,decDeg:45.1308,mag:2.86},{name:"Tejat",raHours:6.3827,decDeg:22.5136,mag:2.87},{name:"γ Trianguli Australis",raHours:15.3152,decDeg:-68.6795,mag:2.87},{name:"α Tucanae",raHours:22.3084,decDeg:-60.2596,mag:2.87},{name:"Acamar",raHours:2.971,decDeg:-40.3047,mag:2.88},{name:"Albaldah",raHours:19.1627,decDeg:-21.0236,mag:2.88},{name:"Gomeisa",raHours:7.4525,decDeg:8.2893,mag:2.89},{name:"Cor Caroli",raHours:12.9338,decDeg:38.3184,mag:2.89},{name:"Fang",raHours:15.9809,decDeg:-26.1141,mag:2.89},{name:"ε Persei",raHours:3.9642,decDeg:40.0102,mag:2.9},{name:"Alniyat",raHours:16.3531,decDeg:-25.5928,mag:2.9},{name:"Sadalsuud",raHours:21.526,decDeg:-5.5712,mag:2.9},{name:"γ Persei",raHours:3.0799,decDeg:53.5064,mag:2.91},{name:"υ Carinae",raHours:9.785,decDeg:-65.072,mag:2.92},{name:"Matar",raHours:22.7167,decDeg:30.2212,mag:2.93},{name:"τ Puppis",raHours:6.8323,decDeg:-50.6146,mag:2.94},{name:"Algorab",raHours:12.4977,decDeg:-16.5154,mag:2.94},{name:"Sadalmelik",raHours:22.0964,decDeg:-.3199,mag:2.95},{name:"Zaurak",raHours:3.9672,decDeg:-13.5085,mag:2.97},{name:"Tianguan",raHours:5.6274,decDeg:21.1425,mag:2.97},{name:"Ras Elased Australis",raHours:9.7642,decDeg:23.7743,mag:2.97},{name:"Alnasl",raHours:18.0968,decDeg:-30.4241,mag:2.98},{name:"γ Hydrae",raHours:13.3154,decDeg:-23.1715,mag:2.99},{name:"ι¹ Scorpii",raHours:17.7931,decDeg:-40.127,mag:2.99},{name:"Okab",raHours:19.0902,decDeg:13.8635,mag:2.99},{name:"β Trianguli",raHours:2.1591,decDeg:34.9873,mag:3},{name:"ψ Ursae Majoris",raHours:11.1611,decDeg:44.4985,mag:3},{name:"Pherkad",raHours:15.3455,decDeg:71.834,mag:3},{name:"Xamidimura",raHours:16.8645,decDeg:-38.0474,mag:3},{name:"Aldhanab",raHours:21.8988,decDeg:-37.3649,mag:3}],xo=64,xi=xo+1,em=2048,F5=900,U5=700/900,k5=0,z5=.01;function I1(r,t,e){return{north:_s(0,-e,r,t).lat,south:_s(0,e,r,t).lat,east:_s(e,0,r,t).lng,west:_s(-e,0,r,t).lng}}async function B5(r,t,e,i=F5){const n=i,s=i*U5,a=I1(r,t,n),o={width:xi,height:xi},[c,l]=await Promise.all([e.elevation.getElevationGrid(a,o),e.imagery.getImageryTexture(a,{width:em,height:em})]),h=Math.floor(xi/2),u=c.heights[h*xi+h],d=new Float32Array(xi*xi*3),f=new Float32Array(xi*xi*2),p=new Float32Array(xi*xi*4);for(let b=0;b<xi;b++){const w=b/(xi-1),T=a.north+(a.south-a.north)*w;for(let x=0;x<xi;x++){const A=x/(xi-1),C=a.west+(a.east-a.west)*A,{x:I,z:P}=ai(T,C,r,t),V=c.heights[b*xi+x],X=Math.max(Math.abs(I),Math.abs(P)),L=1-H5((X-s)/(n-s),0,1),B=k5+z5+(V-u),k=b*xi+x;d[k*3]=I,d[k*3+1]=B,d[k*3+2]=P;const $=pg(l.bounds,C,T);f[k*2]=$.x,f[k*2+1]=$.y,p[k*4]=1,p[k*4+1]=1,p[k*4+2]=1,p[k*4+3]=L}}const v=new Uint16Array(xo*xo*6);let m=0;for(let b=0;b<xo;b++)for(let w=0;w<xo;w++){const T=b*xi+w,x=T+1,A=T+xi,C=A+1;v[m++]=T,v[m++]=A,v[m++]=x,v[m++]=x,v[m++]=A,v[m++]=C}const g=new ce;g.setAttribute("position",new ee(d,3)),g.setAttribute("uv",new ee(f,2)),g.setAttribute("color",new ee(p,4)),g.setIndex(new ee(v,1)),g.computeVertexNormals();const S=new Is(l.source);S.flipY=!1,S.colorSpace=Gi,S.anisotropy=8;const y=new kr({map:S,color:new st(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),M=new Dt(g,y);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:e.imagery.attribution,originElevationM:Number.isFinite(u)?u:void 0}}function H5(r,t,e){return Math.max(t,Math.min(e,r))}class gn{static STEP_M=8;static LIFT_M=.06;static CONTEMPORARY_OPACITY=.45;static ALBEDO={paved:[.16,.16,.17],gravel:[.42,.38,.31],dirt:[.34,.28,.21]};group=new Ce;surveyed=new Ce;stated=new Ce;constructor(){this.group.name="roads",this.surveyed.name="roads surveyed",this.stated.name="roads stated",this.group.add(this.surveyed,this.stated)}set(t,e,i,n,s){gn.empty(this.surveyed);const a=new Map;for(const o of t){const c=a.get(o.surface)??{positions:[],indices:[]};a.set(o.surface,c),this.appendRibbon(o,e,i,n,c)}for(const[o,c]of a){const l=this.meshOf(o,c,s);l&&this.surveyed.add(l)}}setStated(t,e){gn.empty(this.stated);const i=new Map;for(const n of t){const s=i.get(n.surface)??{positions:[],indices:[]};i.set(n.surface,s),this.appendPath(n.path.map(a=>({x:a.eastM,z:-a.northM})),n.widthM,e,s)}for(const[n,s]of i){const a=this.meshOf(n,s,!1);a&&this.stated.add(a)}}clear(){gn.empty(this.surveyed)}static empty(t){for(const e of[...t.children]){t.remove(e);const i=e;i.geometry?.dispose(),i.material?.dispose()}}dispose(){gn.empty(this.surveyed),gn.empty(this.stated)}appendRibbon(t,e,i,n,s){this.appendPath(t.points.map(a=>ai(a.lat,a.lng,e,i)),t.widthM,n,s)}appendPath(t,e,i,n){const s=this.resample(t);if(s.length<2)return;const a=Math.max(.5,e/2),o=n.positions.length/3;for(let c=0;c<s.length;c++){const l=s[Math.max(0,c-1)],h=s[Math.min(s.length-1,c+1)];let u=h.x-l.x,d=h.z-l.z;const f=Math.hypot(u,d);f<1e-6?(u=1,d=0):(u/=f,d/=f);const p=-d*a,v=u*a,m={x:s[c].x+p,z:s[c].z+v},g={x:s[c].x-p,z:s[c].z-v};n.positions.push(m.x,i(m.x,m.z)+gn.LIFT_M,m.z,g.x,i(g.x,g.z)+gn.LIFT_M,g.z)}for(let c=0;c<s.length-1;c++){const l=o+c*2;n.indices.push(l,l+2,l+1,l+1,l+2,l+3)}}meshOf(t,e,i){if(e.indices.length===0)return;const n=new ce;n.setAttribute("position",new ee(new Float32Array(e.positions),3)),n.setIndex(new ee(new Uint32Array(e.indices),1)),n.computeVertexNormals();const s=gn.ALBEDO[t],a=new kr({color:new st(s[0],s[1],s[2]),transparent:i,opacity:i?gn.CONTEMPORARY_OPACITY:1,fog:!0,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),o=new Dt(n,a);return o.name=`roads ${t}`,o.receiveShadow=!0,o.castShadow=!1,o}resample(t){const e=[];for(let n=0;n<t.length-1;n++){const s=t[n],a=t[n+1],o=Math.hypot(a.x-s.x,a.z-s.z),c=Math.max(1,Math.ceil(o/gn.STEP_M));for(let l=0;l<c;l++){const h=l/c;e.push({x:s.x+(a.x-s.x)*h,z:s.z+(a.z-s.z)*h})}}const i=t[t.length-1];return i&&e.push({x:i.x,z:i.z}),e}}const G5=18,V5=.55,W5=.5,X5=.4,Y5=2,q5=`
6097
+ `,depthTest:!1,depthWrite:!1}),this.scene.add(new Dt(new Xi(2,2),this.material))}measure(t,e,i,n){if(this.reading)return;const s=this.material.uniforms;s.uProbe.value=e;const a=Math.cos(To.SOURCE_CONE_DEG*Math.PI/180);[s.uExcludeA.value,s.uExcludeB.value].forEach((h,u)=>{const d=i[u];d?h.set(d.x,d.y,d.z,a):h.set(0,-1,0,2)});const c=t.getRenderTarget();t.setRenderTarget(this.target),t.render(this.scene,this.camera),t.setRenderTarget(c),this.reading=!0;const l=new Float32Array(12);t.readRenderTargetPixelsAsync(this.target,0,0,3,1,l).then(()=>n({up:[l[0],l[1],l[2]],down:[l[4],l[5],l[6]],logAverage:l[8]})).catch(()=>{}).finally(()=>{this.reading=!1})}dispose(){this.target.dispose(),this.material.dispose(),this.scene.children[0].geometry.dispose()}}const Nw=[{name:"Sirius",raHours:6.7525,decDeg:-16.7161,mag:-1.44},{name:"Canopus",raHours:6.3992,decDeg:-52.6957,mag:-.62},{name:"Arcturus",raHours:14.261,decDeg:19.1824,mag:-.05},{name:"Rigil Kentaurus",raHours:14.6608,decDeg:-60.834,mag:-.01},{name:"Vega",raHours:18.6156,decDeg:38.7837,mag:.03},{name:"Capella",raHours:5.2782,decDeg:45.998,mag:.08},{name:"Rigel",raHours:5.2423,decDeg:-8.2016,mag:.18},{name:"Procyon",raHours:7.655,decDeg:5.225,mag:.4},{name:"Achernar",raHours:1.6286,decDeg:-57.2368,mag:.45},{name:"Betelgeuse",raHours:5.9195,decDeg:7.4071,mag:.45},{name:"Hadar",raHours:14.0637,decDeg:-60.373,mag:.61},{name:"Altair",raHours:19.8464,decDeg:8.8683,mag:.76},{name:"Acrux",raHours:12.4433,decDeg:-63.0991,mag:.77},{name:"Aldebaran",raHours:4.5987,decDeg:16.5093,mag:.87},{name:"Spica",raHours:13.4199,decDeg:-11.1613,mag:.98},{name:"Antares",raHours:16.4901,decDeg:-26.432,mag:1.06},{name:"Pollux",raHours:7.7553,decDeg:28.0262,mag:1.16},{name:"Fomalhaut",raHours:22.9608,decDeg:-29.6222,mag:1.17},{name:"Mimosa",raHours:12.7954,decDeg:-59.6888,mag:1.25},{name:"Deneb",raHours:20.6905,decDeg:45.2803,mag:1.25},{name:"Toliman",raHours:14.6603,decDeg:-60.8383,mag:1.35},{name:"Regulus",raHours:10.1395,decDeg:11.9672,mag:1.36},{name:"Adhara",raHours:6.9771,decDeg:-28.9721,mag:1.5},{name:"Castor",raHours:7.5766,decDeg:31.8883,mag:1.58},{name:"Gacrux",raHours:12.5194,decDeg:-57.1132,mag:1.59},{name:"Shaula",raHours:17.5601,decDeg:-37.1038,mag:1.62},{name:"Bellatrix",raHours:5.4189,decDeg:6.3497,mag:1.64},{name:"Elnath",raHours:5.4382,decDeg:28.6075,mag:1.65},{name:"Miaplacidus",raHours:9.22,decDeg:-69.7172,mag:1.67},{name:"Alnilam",raHours:5.6036,decDeg:-1.2019,mag:1.69},{name:"Alnair",raHours:22.1372,decDeg:-46.961,mag:1.73},{name:"Alnitak",raHours:5.6793,decDeg:-1.9426,mag:1.74},{name:"γ² Velorum",raHours:8.1589,decDeg:-47.3366,mag:1.75},{name:"Alioth",raHours:12.9005,decDeg:55.9598,mag:1.76},{name:"Mirfak",raHours:3.4054,decDeg:49.8612,mag:1.79},{name:"Kaus Australis",raHours:18.4029,decDeg:-34.3846,mag:1.79},{name:"Dubhe",raHours:11.0622,decDeg:61.751,mag:1.81},{name:"Wezen",raHours:7.1399,decDeg:-26.3932,mag:1.83},{name:"Alkaid",raHours:13.7924,decDeg:49.3133,mag:1.85},{name:"Avior",raHours:8.3752,decDeg:-59.5095,mag:1.86},{name:"Sargas",raHours:17.622,decDeg:-42.9978,mag:1.86},{name:"Menkalinan",raHours:5.9921,decDeg:44.9474,mag:1.9},{name:"Atria",raHours:16.8111,decDeg:-69.0277,mag:1.91},{name:"Alhena",raHours:6.6285,decDeg:16.3993,mag:1.93},{name:"Alsephina",raHours:8.7451,decDeg:-54.7088,mag:1.93},{name:"Peacock",raHours:20.4275,decDeg:-56.7351,mag:1.94},{name:"Polaris",raHours:2.5297,decDeg:89.2641,mag:1.97},{name:"Mirzam",raHours:6.3783,decDeg:-17.9559,mag:1.98},{name:"Alphard",raHours:9.4598,decDeg:-8.6586,mag:1.99},{name:"Hamal",raHours:2.1196,decDeg:23.4624,mag:2.01},{name:"Algieba",raHours:10.3329,decDeg:19.8415,mag:2.01},{name:"Diphda",raHours:.7265,decDeg:-17.9866,mag:2.04},{name:"Nunki",raHours:18.9211,decDeg:-26.2967,mag:2.05},{name:"Menkent",raHours:14.1114,decDeg:-36.37,mag:2.06},{name:"Alpheratz",raHours:.1398,decDeg:29.0904,mag:2.07},{name:"Mirach",raHours:1.1622,decDeg:35.6206,mag:2.07},{name:"Saiph",raHours:5.7959,decDeg:-9.6696,mag:2.07},{name:"Kochab",raHours:14.8451,decDeg:74.1555,mag:2.07},{name:"Tiaki",raHours:22.7111,decDeg:-46.8846,mag:2.07},{name:"Rasalhague",raHours:17.5822,decDeg:12.56,mag:2.08},{name:"Algol",raHours:3.1361,decDeg:40.9556,mag:2.09},{name:"Almach",raHours:2.065,decDeg:42.3297,mag:2.1},{name:"Denebola",raHours:11.8177,decDeg:14.5721,mag:2.14},{name:"Cih",raHours:.9451,decDeg:60.7167,mag:2.15},{name:"γ Centauri",raHours:12.692,decDeg:-48.9599,mag:2.2},{name:"Naos",raHours:8.0597,decDeg:-40.0031,mag:2.21},{name:"Aspidiske",raHours:9.2848,decDeg:-59.2752,mag:2.21},{name:"Alphecca",raHours:15.5781,decDeg:26.7147,mag:2.22},{name:"Suhail",raHours:9.1333,decDeg:-43.4326,mag:2.23},{name:"Mizar",raHours:13.3987,decDeg:54.9254,mag:2.23},{name:"Sadr",raHours:20.3705,decDeg:40.2567,mag:2.23},{name:"Schedar",raHours:.6751,decDeg:56.5373,mag:2.24},{name:"Eltanin",raHours:17.9434,decDeg:51.4889,mag:2.24},{name:"Mintaka",raHours:5.5334,decDeg:-.2991,mag:2.25},{name:"Caph",raHours:.1529,decDeg:59.1498,mag:2.28},{name:"ε Centauri",raHours:13.6648,decDeg:-53.4664,mag:2.29},{name:"Dschubba",raHours:16.0056,decDeg:-22.6217,mag:2.29},{name:"Larawag",raHours:16.8361,decDeg:-34.2932,mag:2.29},{name:"α Lupi",raHours:14.6988,decDeg:-47.3882,mag:2.3},{name:"η Centauri",raHours:14.5918,decDeg:-42.1578,mag:2.33},{name:"Merak",raHours:11.0307,decDeg:56.3824,mag:2.34},{name:"Izar",raHours:14.7498,decDeg:27.0742,mag:2.35},{name:"Enif",raHours:21.7364,decDeg:9.875,mag:2.38},{name:"κ Scorpii",raHours:17.7081,decDeg:-39.03,mag:2.39},{name:"Ankaa",raHours:.4381,decDeg:-42.306,mag:2.4},{name:"Phecda",raHours:11.8972,decDeg:53.6948,mag:2.41},{name:"Sabik",raHours:17.173,decDeg:-15.7249,mag:2.43},{name:"Scheat",raHours:23.0629,decDeg:28.0828,mag:2.44},{name:"Aludra",raHours:7.4016,decDeg:-29.3031,mag:2.45},{name:"Alderamin",raHours:21.3096,decDeg:62.5856,mag:2.45},{name:"Markeb",raHours:9.3686,decDeg:-55.0107,mag:2.47},{name:"Aljanah",raHours:20.7702,decDeg:33.9703,mag:2.48},{name:"Markab",raHours:23.0793,decDeg:15.2053,mag:2.49},{name:"Menkar",raHours:3.038,decDeg:4.0897,mag:2.54},{name:"ζ Ophiuchi",raHours:16.6193,decDeg:-10.5671,mag:2.54},{name:"ζ Centauri",raHours:13.9257,decDeg:-47.2884,mag:2.55},{name:"Zosma",raHours:11.2351,decDeg:20.5237,mag:2.56},{name:"Acrab",raHours:16.0906,decDeg:-19.8055,mag:2.56},{name:"Arneb",raHours:5.5455,decDeg:-17.8223,mag:2.58},{name:"δ Centauri",raHours:12.1393,decDeg:-50.7224,mag:2.58},{name:"Gienah",raHours:12.2634,decDeg:-17.5419,mag:2.58},{name:"Ascella",raHours:19.0435,decDeg:-29.8801,mag:2.6},{name:"Zubeneschamali",raHours:15.2834,decDeg:-9.3829,mag:2.61},{name:"Unukalhai",raHours:15.7378,decDeg:6.4256,mag:2.63},{name:"Sheratan",raHours:1.9107,decDeg:20.808,mag:2.64},{name:"Phact",raHours:5.6608,decDeg:-34.0741,mag:2.65},{name:"Mahasim",raHours:5.9954,decDeg:37.2126,mag:2.65},{name:"Kraz",raHours:12.5731,decDeg:-23.3968,mag:2.65},{name:"Ruchbah",raHours:1.4302,decDeg:60.2353,mag:2.66},{name:"Muphrid",raHours:13.9114,decDeg:18.3977,mag:2.68},{name:"β Lupi",raHours:14.9755,decDeg:-43.134,mag:2.68},{name:"Hassaleh",raHours:4.9499,decDeg:33.1661,mag:2.69},{name:"μ Velorum",raHours:10.7795,decDeg:-49.4203,mag:2.69},{name:"α Muscae",raHours:12.6197,decDeg:-69.1356,mag:2.69},{name:"Lesath",raHours:17.5127,decDeg:-37.2958,mag:2.7},{name:"π Puppis",raHours:7.2857,decDeg:-37.0975,mag:2.71},{name:"Kaus Media",raHours:18.3499,decDeg:-29.8281,mag:2.72},{name:"Tarazed",raHours:19.771,decDeg:10.6133,mag:2.72},{name:"Yed Prior",raHours:16.2391,decDeg:-3.6943,mag:2.73},{name:"Athebyne",raHours:16.3999,decDeg:61.5142,mag:2.73},{name:"θ Carinae",raHours:10.7159,decDeg:-64.3945,mag:2.74},{name:"Porrima",raHours:12.6943,decDeg:-1.4494,mag:2.74},{name:"Hatysa",raHours:5.5906,decDeg:-5.9099,mag:2.75},{name:"ι Centauri",raHours:13.3433,decDeg:-36.7123,mag:2.75},{name:"Zubenelgenubi",raHours:14.848,decDeg:-16.0418,mag:2.75},{name:"Cebalrai",raHours:17.7245,decDeg:4.5673,mag:2.76},{name:"Cursa",raHours:5.1308,decDeg:-5.0864,mag:2.78},{name:"Kornephoros",raHours:16.5037,decDeg:21.4896,mag:2.78},{name:"Rasalgethi",raHours:17.2441,decDeg:14.3903,mag:2.78},{name:"Imai",raHours:12.2524,decDeg:-58.7489,mag:2.79},{name:"Rastaban",raHours:17.5072,decDeg:52.3014,mag:2.79},{name:"γ Lupi",raHours:15.5857,decDeg:-41.1668,mag:2.8},{name:"Nihal",raHours:5.4708,decDeg:-20.7594,mag:2.81},{name:"ζ Herculis",raHours:16.6881,decDeg:31.6027,mag:2.81},{name:"β Hydri",raHours:.4279,decDeg:-77.2542,mag:2.82},{name:"Paikauhale",raHours:16.598,decDeg:-28.216,mag:2.82},{name:"Kaus Borealis",raHours:18.4662,decDeg:-25.4217,mag:2.82},{name:"Algenib",raHours:.2206,decDeg:15.1836,mag:2.83},{name:"Tureis",raHours:8.1257,decDeg:-24.3043,mag:2.83},{name:"β Trianguli Australis",raHours:15.9191,decDeg:-63.4307,mag:2.83},{name:"ζ Persei",raHours:3.9022,decDeg:31.8836,mag:2.84},{name:"β Arae",raHours:17.4217,decDeg:-55.5299,mag:2.84},{name:"α Arae",raHours:17.5307,decDeg:-49.8761,mag:2.84},{name:"Alcyone",raHours:3.7914,decDeg:24.1051,mag:2.85},{name:"Vindemiatrix",raHours:13.0363,decDeg:10.9591,mag:2.85},{name:"Deneb Algedi",raHours:21.784,decDeg:-16.1273,mag:2.85},{name:"Castor B",raHours:7.5768,decDeg:31.8905,mag:2.85},{name:"α Hydri",raHours:1.9795,decDeg:-61.5699,mag:2.86},{name:"Fawaris",raHours:19.7496,decDeg:45.1308,mag:2.86},{name:"Tejat",raHours:6.3827,decDeg:22.5136,mag:2.87},{name:"γ Trianguli Australis",raHours:15.3152,decDeg:-68.6795,mag:2.87},{name:"α Tucanae",raHours:22.3084,decDeg:-60.2596,mag:2.87},{name:"Acamar",raHours:2.971,decDeg:-40.3047,mag:2.88},{name:"Albaldah",raHours:19.1627,decDeg:-21.0236,mag:2.88},{name:"Gomeisa",raHours:7.4525,decDeg:8.2893,mag:2.89},{name:"Cor Caroli",raHours:12.9338,decDeg:38.3184,mag:2.89},{name:"Fang",raHours:15.9809,decDeg:-26.1141,mag:2.89},{name:"ε Persei",raHours:3.9642,decDeg:40.0102,mag:2.9},{name:"Alniyat",raHours:16.3531,decDeg:-25.5928,mag:2.9},{name:"Sadalsuud",raHours:21.526,decDeg:-5.5712,mag:2.9},{name:"γ Persei",raHours:3.0799,decDeg:53.5064,mag:2.91},{name:"υ Carinae",raHours:9.785,decDeg:-65.072,mag:2.92},{name:"Matar",raHours:22.7167,decDeg:30.2212,mag:2.93},{name:"τ Puppis",raHours:6.8323,decDeg:-50.6146,mag:2.94},{name:"Algorab",raHours:12.4977,decDeg:-16.5154,mag:2.94},{name:"Sadalmelik",raHours:22.0964,decDeg:-.3199,mag:2.95},{name:"Zaurak",raHours:3.9672,decDeg:-13.5085,mag:2.97},{name:"Tianguan",raHours:5.6274,decDeg:21.1425,mag:2.97},{name:"Ras Elased Australis",raHours:9.7642,decDeg:23.7743,mag:2.97},{name:"Alnasl",raHours:18.0968,decDeg:-30.4241,mag:2.98},{name:"γ Hydrae",raHours:13.3154,decDeg:-23.1715,mag:2.99},{name:"ι¹ Scorpii",raHours:17.7931,decDeg:-40.127,mag:2.99},{name:"Okab",raHours:19.0902,decDeg:13.8635,mag:2.99},{name:"β Trianguli",raHours:2.1591,decDeg:34.9873,mag:3},{name:"ψ Ursae Majoris",raHours:11.1611,decDeg:44.4985,mag:3},{name:"Pherkad",raHours:15.3455,decDeg:71.834,mag:3},{name:"Xamidimura",raHours:16.8645,decDeg:-38.0474,mag:3},{name:"Aldhanab",raHours:21.8988,decDeg:-37.3649,mag:3}],xo=64,xi=xo+1,em=2048,Fw=900,Uw=700/900,kw=0,zw=.01;function I1(r,t,e){return{north:_s(0,-e,r,t).lat,south:_s(0,e,r,t).lat,east:_s(e,0,r,t).lng,west:_s(-e,0,r,t).lng}}async function Bw(r,t,e,i=Fw){const n=i,s=i*Uw,a=I1(r,t,n),o={width:xi,height:xi},[c,l]=await Promise.all([e.elevation.getElevationGrid(a,o),e.imagery.getImageryTexture(a,{width:em,height:em})]),h=Math.floor(xi/2),u=c.heights[h*xi+h],d=new Float32Array(xi*xi*3),f=new Float32Array(xi*xi*2),p=new Float32Array(xi*xi*4);for(let b=0;b<xi;b++){const w=b/(xi-1),T=a.north+(a.south-a.north)*w;for(let x=0;x<xi;x++){const A=x/(xi-1),C=a.west+(a.east-a.west)*A,{x:I,z:P}=ai(T,C,r,t),V=c.heights[b*xi+x],X=Math.max(Math.abs(I),Math.abs(P)),L=1-Hw((X-s)/(n-s),0,1),B=kw+zw+(V-u),k=b*xi+x;d[k*3]=I,d[k*3+1]=B,d[k*3+2]=P;const $=pg(l.bounds,C,T);f[k*2]=$.x,f[k*2+1]=$.y,p[k*4]=1,p[k*4+1]=1,p[k*4+2]=1,p[k*4+3]=L}}const v=new Uint16Array(xo*xo*6);let m=0;for(let b=0;b<xo;b++)for(let w=0;w<xo;w++){const T=b*xi+w,x=T+1,A=T+xi,C=A+1;v[m++]=T,v[m++]=A,v[m++]=x,v[m++]=x,v[m++]=A,v[m++]=C}const g=new ce;g.setAttribute("position",new ie(d,3)),g.setAttribute("uv",new ie(f,2)),g.setAttribute("color",new ie(p,4)),g.setIndex(new ie(v,1)),g.computeVertexNormals();const S=new Is(l.source);S.flipY=!1,S.colorSpace=Gi,S.anisotropy=8;const y=new kr({map:S,color:new st(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),M=new Dt(g,y);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:e.imagery.attribution,originElevationM:Number.isFinite(u)?u:void 0}}function Hw(r,t,e){return Math.max(t,Math.min(e,r))}class gn{static STEP_M=8;static LIFT_M=.06;static CONTEMPORARY_OPACITY=.45;static ALBEDO={paved:[.16,.16,.17],gravel:[.42,.38,.31],dirt:[.34,.28,.21]};group=new Ce;surveyed=new Ce;stated=new Ce;constructor(){this.group.name="roads",this.surveyed.name="roads surveyed",this.stated.name="roads stated",this.group.add(this.surveyed,this.stated)}set(t,e,i,n,s){gn.empty(this.surveyed);const a=new Map;for(const o of t){const c=a.get(o.surface)??{positions:[],indices:[]};a.set(o.surface,c),this.appendRibbon(o,e,i,n,c)}for(const[o,c]of a){const l=this.meshOf(o,c,s);l&&this.surveyed.add(l)}}setStated(t,e){gn.empty(this.stated);const i=new Map;for(const n of t){const s=i.get(n.surface)??{positions:[],indices:[]};i.set(n.surface,s),this.appendPath(n.path.map(a=>({x:a.eastM,z:-a.northM})),n.widthM,e,s)}for(const[n,s]of i){const a=this.meshOf(n,s,!1);a&&this.stated.add(a)}}clear(){gn.empty(this.surveyed)}static empty(t){for(const e of[...t.children]){t.remove(e);const i=e;i.geometry?.dispose(),i.material?.dispose()}}dispose(){gn.empty(this.surveyed),gn.empty(this.stated)}appendRibbon(t,e,i,n,s){this.appendPath(t.points.map(a=>ai(a.lat,a.lng,e,i)),t.widthM,n,s)}appendPath(t,e,i,n){const s=this.resample(t);if(s.length<2)return;const a=Math.max(.5,e/2),o=n.positions.length/3;for(let c=0;c<s.length;c++){const l=s[Math.max(0,c-1)],h=s[Math.min(s.length-1,c+1)];let u=h.x-l.x,d=h.z-l.z;const f=Math.hypot(u,d);f<1e-6?(u=1,d=0):(u/=f,d/=f);const p=-d*a,v=u*a,m={x:s[c].x+p,z:s[c].z+v},g={x:s[c].x-p,z:s[c].z-v};n.positions.push(m.x,i(m.x,m.z)+gn.LIFT_M,m.z,g.x,i(g.x,g.z)+gn.LIFT_M,g.z)}for(let c=0;c<s.length-1;c++){const l=o+c*2;n.indices.push(l,l+2,l+1,l+1,l+2,l+3)}}meshOf(t,e,i){if(e.indices.length===0)return;const n=new ce;n.setAttribute("position",new ie(new Float32Array(e.positions),3)),n.setIndex(new ie(new Uint32Array(e.indices),1)),n.computeVertexNormals();const s=gn.ALBEDO[t],a=new kr({color:new st(s[0],s[1],s[2]),transparent:i,opacity:i?gn.CONTEMPORARY_OPACITY:1,fog:!0,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),o=new Dt(n,a);return o.name=`roads ${t}`,o.receiveShadow=!0,o.castShadow=!1,o}resample(t){const e=[];for(let n=0;n<t.length-1;n++){const s=t[n],a=t[n+1],o=Math.hypot(a.x-s.x,a.z-s.z),c=Math.max(1,Math.ceil(o/gn.STEP_M));for(let l=0;l<c;l++){const h=l/c;e.push({x:s.x+(a.x-s.x)*h,z:s.z+(a.z-s.z)*h})}}const i=t[t.length-1];return i&&e.push({x:i.x,z:i.z}),e}}const Gw=18,Vw=.55,Ww=.5,Xw=.4,Yw=2,qw=`
6041
6098
  attribute float aSpeed;
6042
6099
  uniform float uTime;
6043
6100
  uniform float uOverallSpeed;
@@ -6082,7 +6139,7 @@ void main() {
6082
6139
  // And a drop a hand's breadth from the eye is not seen at all: out of focus by metres, its light
6083
6140
  // is spread over a disc so wide that nothing of it stands out. Drawn big and soft instead, it
6084
6141
  // reads as a drop sitting on a lens, which is a camera's sight and not an eye's.
6085
- vNearFade = smoothstep(${X5.toFixed(2)}, ${Y5.toFixed(2)}, -mvPosition.z);
6142
+ vNearFade = smoothstep(${Xw.toFixed(2)}, ${Yw.toFixed(2)}, -mvPosition.z);
6086
6143
  // Distance haze: 0 close in, ramping to 1 by uHazeDistance — real atmospheric haze, monotonic
6087
6144
  // (unlike defocus, there's no "in-focus band", it just keeps increasing with distance). Does NOT
6088
6145
  // add to gl_PointSize below — real haze dims/desaturates a distant object, it doesn't enlarge it;
@@ -6110,9 +6167,9 @@ void main() {
6110
6167
  vec2 travel = vec2((ahead.x - here.x) * uAspect, ahead.y - here.y);
6111
6168
  // Straight down is the texture's own orientation, so that is the zero.
6112
6169
  vSlant = length(travel) < 1e-6 ? 0.0 : atan(travel.x, -travel.y);
6113
- gl_PointSize = uPixelSize / dist + vNearBlur * ${G5.toFixed(1)};
6170
+ gl_PointSize = uPixelSize / dist + vNearBlur * ${Gw.toFixed(1)};
6114
6171
  }
6115
- `,$5=`
6172
+ `,$w=`
6116
6173
  precision mediump float;
6117
6174
  uniform sampler2D uTexture;
6118
6175
  uniform vec3 uColor;
@@ -6149,11 +6206,11 @@ void main() {
6149
6206
  // defocus doesn't change color, only spreads+dims (see vertex shader's own gl_PointSize term) —
6150
6207
  // both dim the alpha so a maximally blurred/hazy drop doesn't stay as visually "solid" as a sharp
6151
6208
  // one right in the middle distance.
6152
- vec3 color = mix(uColor, uHazeColor, vHaze * ${V5.toFixed(2)});
6209
+ vec3 color = mix(uColor, uHazeColor, vHaze * ${Vw.toFixed(2)});
6153
6210
  float blur = max(vNearBlur, vHaze);
6154
- gl_FragColor = vec4(color, tex.a * uOpacity * vNearFade * (1.0 - blur * ${W5.toFixed(2)}));
6211
+ gl_FragColor = vec4(color, tex.a * uOpacity * vNearFade * (1.0 - blur * ${Ww.toFixed(2)}));
6155
6212
  }
6156
- `;function K5(r){let t=r;return function(){t|=0,t=t+1831565813|0;let i=Math.imul(t^t>>>15,1|t);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}const Z5=.14,im=2.25;let Hc;function J5(){if(Hc)return Hc;const r=128,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d"),i=e.createImageData(r,r),n=r/2,s=r*Z5,a=r-s;for(let o=0;o<r;o++)for(let c=0;c<r;c++){const l=c+.5-n,h=o+.5<s?o+.5-s:o+.5>a?o+.5-a:0,u=Math.hypot(l,h),d=Math.exp(-(u*u)/(2*im*im)),f=(o*r+c)*4;i.data[f]=255,i.data[f+1]=255,i.data[f+2]=255,i.data[f+3]=Math.round(255*Math.min(1,d))}return e.putImageData(i,0,0),Hc=new Is(t),Hc}function j5(r){const t=K5(r.seed),e=new Float32Array(r.count*3),i=new Float32Array(r.count),n=r.radiusM;for(let l=0;l<r.count;l++){const h=t()*Math.PI*2,u=Math.sqrt(t())*r.radiusM;e[l*3]=Math.cos(h)*u,e[l*3+1]=t()*r.heightM,e[l*3+2]=Math.sin(h)*u,i[l]=.85+t()*.3}const s=new ce;s.setAttribute("position",new ee(e,3)),s.setAttribute("aSpeed",new ee(i,1)),s.setDrawRange(0,r.visibleCount);const a={uTime:{value:0},uOverallSpeed:{value:r.overallSpeed},uPixelSize:{value:r.pixelSize},uOpacity:{value:r.opacity},uColor:{value:r.color},uUvSquash:{value:1},uSpeedStreak:{value:r.speedStreak},uWindOffset:{value:new xt(0,0)},uDropVelocity:{value:new R(0,-1,0)},uAspect:{value:1},uHeight:{value:r.heightM},uBottomY:{value:r.bottomYM},uHalfWidth:{value:n},uTexture:{value:J5()},uNearFocusDistance:{value:r.nearFocusDistanceM},uHazeDistance:{value:r.hazeDistanceM},uHazeColor:{value:r.hazeColor}},o=new le({uniforms:a,vertexShader:q5,fragmentShader:$5,transparent:!0,depthWrite:!1,depthTest:!0}),c=new xs(s,o);return c.frustumCulled=!1,{points:c,uniforms:a}}class Ua{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(t){return Ua.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(t,1e-12))}static fromMagPerArcsec2(t){return 10**(.4*(Ua.S10_MAG_PER_ARCSEC2-t))}static latitudeOfRowCoord(t){const e=2*t-1;return 90*Math.sign(e)*e*e}static rowCoordOfLatitude(t){return(Math.sign(t)*Math.sqrt(Math.min(Math.abs(t),90)/90)+1)/2}static angleOfColumnCoord(t){return 180*t*t}static columnCoordOfAngle(t){return Math.sqrt(Math.min(Math.max(t,0),180)/180)}}class se{static LONGITUDE_STEPS=256;static LATITUDE_STEPS=128;static SUN_RADIUS_KPC=8.2;static SUN_HEIGHT_KPC=.02;static DISK_SCALE_LENGTH_KPC=2.6;static DISK_SCALE_HEIGHT_KPC=.3;static BULGE_SCALE_KPC=.5;static BULGE_FLATTENING=.6;static BULGE_TO_LOCAL_DISK=20;static DUST_SCALE_LENGTH_KPC=3.5;static DUST_SCALE_HEIGHT_KPC=.1;static EXTINCTION_MAG_PER_KPC=.8;static NEAR_LIMIT_KPC=.01;static FAR_LIMIT_KPC=40;static STEPS=192;static OPAQUE_MAG=15;static PEAK_MAG_PER_ARCSEC2=21;static PEAK_RADIANCE=6.278;static PEAK_LONGITUDE_DEG=0;static PEAK_LATITUDE_DEG=4.5;surfaceBrightnessS10(t,e){return this.radianceTowards(t,e)*se.anchor()}static anchor(){return Ua.fromMagPerArcsec2(se.PEAK_MAG_PER_ARCSEC2)/se.PEAK_RADIANCE}radianceTowards(t,e){return this.trace(t,e).light}extinctionTowards(t,e){return this.trace(t,e).extinctionMag}trace(t,e){const i=t*Math.PI/180,n=e*Math.PI/180,s=-Math.cos(n)*Math.cos(i),a=Math.cos(n)*Math.sin(i),o=Math.sin(n);let c=0,l=0,h=0;const u=Math.log(se.NEAR_LIMIT_KPC),d=Math.log(se.FAR_LIMIT_KPC)-u;for(let f=0;f<se.STEPS;f++){const p=Math.exp(u+d*f/(se.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=se.SUN_RADIUS_KPC+m*s,S=m*a,y=se.SUN_HEIGHT_KPC+m*o,M=Math.hypot(g,S),b=Math.exp(-(M-se.SUN_RADIUS_KPC)/se.DISK_SCALE_LENGTH_KPC-Math.abs(y)/se.DISK_SCALE_HEIGHT_KPC),w=Math.hypot(M,y/se.BULGE_FLATTENING),T=se.BULGE_TO_LOCAL_DISK*Math.exp(-w/se.BULGE_SCALE_KPC);if(c+=(b+T)*v*10**(-.4*l),l+=se.EXTINCTION_MAG_PER_KPC*Math.exp(-(M-se.SUN_RADIUS_KPC)/se.DUST_SCALE_LENGTH_KPC-(Math.abs(y)-se.SUN_HEIGHT_KPC)/se.DUST_SCALE_HEIGHT_KPC)*v,l>se.OPAQUE_MAG)break}return{light:c,extinctionMag:l}}values=new Float32Array(se.LONGITUDE_STEPS*se.LATITUDE_STEPS);walked=0;get done(){return this.walked>=se.LATITUDE_STEPS}walk(t){const e=se.LONGITUDE_STEPS,i=Math.min(se.LATITUDE_STEPS,this.walked+t);for(;this.walked<i;this.walked++){const n=Ua.latitudeOfRowCoord((this.walked+.5)/se.LATITUDE_STEPS);for(let s=0;s<e;s++)this.values[this.walked*e+s]=this.radianceTowards(360*(s+.5)/e,n)}}harvest(){let t=Number.POSITIVE_INFINITY;for(const n of this.values)n<t&&(t=n);const e=se.anchor(),i=new Float32Array(this.values.length);for(let n=0;n<i.length;n++)i[n]=(this.values[n]-t)*e;return{width:se.LONGITUDE_STEPS,height:se.LATITUDE_STEPS,data:i}}}class Xe{static LONGITUDE_STEPS=128;static LATITUDE_STEPS=96;static RADIAL_FALLOFF=1.3;static FAN_EXPONENT=2.6;static SUBLIMATION_AU=.1;static NEAR_LIMIT_AU=.004;static FAR_LIMIT_AU=8;static STEPS=224;static LOBE_ASYMMETRY=[.7,-.2,-.81];static LOBE_WEIGHT=[.665,.33,.00541];static RIGHT_ANGLE_S10=200;static POLE_S10=77;surfaceBrightnessS10(t,e){return this.radianceTowards(t,e)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=Xe.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(t,e){const i=t*Math.PI/180,n=e*Math.PI/180,s=-Math.cos(n)*Math.cos(i),a=-Math.cos(n)*Math.sin(i),o=Math.sin(n),c=-s;let l=0,h=0;const u=Math.log(Xe.NEAR_LIMIT_AU),d=Math.log(Xe.FAR_LIMIT_AU)-u;for(let f=0;f<Xe.STEPS;f++){const p=Math.exp(u+d*f/(Xe.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=1+m*s,S=m*a,y=m*o,M=Math.hypot(g,S,y);if(M<Xe.SUBLIMATION_AU)continue;const b=y/M,w=M**-1.3*Math.exp(-2.6*Math.abs(b)),T=(c-m)/M;l+=w*this.scattering(T)*v/(M*M)}return l}scattering(t){let e=0;for(let i=0;i<Xe.LOBE_ASYMMETRY.length;i++){const n=Xe.LOBE_ASYMMETRY[i],s=1+n*n-2*n*t;e+=Xe.LOBE_WEIGHT[i]*(1-n*n)/(4*Math.PI*s**1.5)}return e}values=new Float32Array(Xe.LONGITUDE_STEPS*Xe.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Xe.LATITUDE_STEPS}walk(t){const e=Xe.LONGITUDE_STEPS,i=Math.min(Xe.LATITUDE_STEPS,this.walked+t);for(;this.walked<i;this.walked++){const n=Ua.latitudeOfRowCoord((this.walked+.5)/Xe.LATITUDE_STEPS);for(let s=0;s<e;s++){const a=Ua.angleOfColumnCoord((s+.5)/e);this.values[this.walked*e+s]=this.radianceTowards(a,n)}}}harvest(){const t=this.anchor();let e=Number.POSITIVE_INFINITY;for(const n of this.values)n<e&&(e=n);const i=new Float32Array(this.values.length);for(let n=0;n<i.length;n++)i[n]=(this.values[n]-e)*t;return{width:Xe.LONGITUDE_STEPS,height:Xe.LATITUDE_STEPS,data:i}}}class Mt{static get NANOLAMBERTS_PER_S10(){return Mt.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(t){return t*Mt.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},...Array.from({length:15},(t,e)=>{const i=-4-e;return{sunAltitudeDeg:i,magPerArcsec2:Mt.patatV(i)}}),{sunAltitudeDeg:-24,magPerArcsec2:22}];static patatV(t){const e=90-t-95;return 11.84+1.518*e-.057*e*e}static moonlessMagPerArcsec2(t){const e=Mt.TWILIGHT;for(let i=0;i<e.length-1;i++){const n=e[i],s=e[i+1];if(t<=n.sunAltitudeDeg&&t>=s.sunAltitudeDeg){const a=(n.sunAltitudeDeg-t)/(n.sunAltitudeDeg-s.sunAltitudeDeg);return n.magPerArcsec2+(s.magPerArcsec2-n.magPerArcsec2)*a}}return t>0?e[0].magPerArcsec2:e[e.length-1].magPerArcsec2}static toNanolamberts(t){return 34.08*Math.exp(Mt.NANOLAMBERT_OFFSET-Mt.PER_MAGNITUDE*t)}static fromNanolamberts(t){return(Mt.NANOLAMBERT_OFFSET-Math.log(Math.max(t,1e-6)/34.08))/Mt.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(t){const e=Math.cos(Math.max(t,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*e*e,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(t){const e=Math.min(Math.max(t,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(e)**2)+10**(6.15-Math.min(t,180)/40)}static scatteredFraction(t){return 1-10**(-.4*Mt.EXTINCTION_PER_AIR_MASS*Mt.airMass(t))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(t){return Math.max(0,Mt.toNanolamberts(Mt.moonlessMagPerArcsec2(t))-Mt.toNanolamberts(Mt.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(t){const e=Mt.scatteringAt(90-t)*Mt.scatteredFraction(90);return Mt.twilightExcessNanolamberts(t)/e}static moonNanolamberts(t,e,i,n){return Mt.scatteringAt(i)*Mt.moonOutput(t,e)*Mt.scatteredFraction(n)}static moonOutput(t,e){if(e<=0)return 0;const i=Math.min(Math.abs(t),180);return 10**(-.4*(3.84+.026*i+4e-9*i**4))*10**(-.4*Mt.EXTINCTION_PER_AIR_MASS*Mt.airMass(e))}static phaseAngleOf(t){return Math.acos(Math.min(Math.max(2*t-1,-1),1))*180/Math.PI}static magPerArcsec2(t,e,i,n){const s=Mt.scatteredFraction(i),a=Mt.scatteringAt(t.separationDeg)*Mt.twilightOutput(t.altitudeDeg)*s,o=Mt.scatteringAt(e.separationDeg)*Mt.moonOutput(e.phaseAngleDeg,e.altitudeDeg)*s;return Mt.fromNanolamberts(Mt.toNanolamberts(Mt.AIRGLOW_MAG_PER_ARCSEC2)+a+o+Mt.artificialNanolamberts(n,i))}static artificialZenithNanolamberts(t){return t===void 0||!Number.isFinite(t)?0:Math.max(0,Mt.toNanolamberts(t)-Mt.toNanolamberts(Mt.AIRGLOW_MAG_PER_ARCSEC2))}static artificialNanolamberts(t,e){const i=Mt.artificialZenithNanolamberts(t);return i>0?i*Mt.artificialShape(e):0}static artificialShape(t){return Mt.scatteredFraction(t)/Mt.scatteredFraction(90)}static nakedEyeLimit(t){return 7.93-5*Math.log10(10**(4.316-t/5)+1)}static starLossMagnitudes(t,e,i){const n=Mt.moonlessMagPerArcsec2(t),s=Mt.fromNanolamberts(Mt.toNanolamberts(n)+Mt.scatteringAt(90-e.altitudeDeg)*Mt.moonOutput(e.phaseAngleDeg,e.altitudeDeg)*Mt.scatteredFraction(90)+Mt.artificialZenithNanolamberts(i));return Math.max(0,Mt.nakedEyeLimit(n)-Mt.nakedEyeLimit(s))}}class Xs{static RADIUS=890;static TOO_BRIGHT_MAG_PER_ARCSEC2=16;static MILKY_WAY_TINT=[.9,.94,1];static ZODIACAL_TINT=[1,.97,.9];object;material;maps=Sa.shared;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;repaint;constructor(){this.milkyWayTexels=this.maps.milkyWayTexels,this.milkyWayTexture=Xs.buildTexture(this.milkyWayTexels,se.LONGITUDE_STEPS,se.LATITUDE_STEPS,ko),this.zodiacalTexels=this.maps.zodiacalTexels,this.zodiacalTexture=Xs.buildTexture(this.zodiacalTexels,Xe.LONGITUDE_STEPS,Xe.LATITUDE_STEPS,wi),this.material=new le({uniforms:{uMilkyWay:{value:this.milkyWayTexture},uZodiacal:{value:this.zodiacalTexture},uGalactic:{value:new Yt},uEclipticPole:{value:new R(0,1,0)},uSunLongitude:{value:new R(1,0,0)},uMoonDirection:{value:new R(0,-1,0)},uMoonOutput:{value:0},uSunDirection:{value:new R(0,-1,0)},uTwilightOutput:{value:0},uAirglowNanolamberts:{value:Mt.toNanolamberts(Mt.AIRGLOW_MAG_PER_ARCSEC2)},uArtificialNanolamberts:{value:0},uSkyColor:{value:new R(0,0,0)},uMilkyWayTint:{value:new R(...Xs.MILKY_WAY_TINT)},uZodiacalTint:{value:new R(...Xs.ZODIACAL_TINT)},uReady:{value:this.maps.done?1:0},uEncodeDestination:{value:1}},vertexShader:`
6213
+ `;function Kw(r){let t=r;return function(){t|=0,t=t+1831565813|0;let i=Math.imul(t^t>>>15,1|t);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}const Zw=.14,im=2.25;let Hc;function Jw(){if(Hc)return Hc;const r=128,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d"),i=e.createImageData(r,r),n=r/2,s=r*Zw,a=r-s;for(let o=0;o<r;o++)for(let c=0;c<r;c++){const l=c+.5-n,h=o+.5<s?o+.5-s:o+.5>a?o+.5-a:0,u=Math.hypot(l,h),d=Math.exp(-(u*u)/(2*im*im)),f=(o*r+c)*4;i.data[f]=255,i.data[f+1]=255,i.data[f+2]=255,i.data[f+3]=Math.round(255*Math.min(1,d))}return e.putImageData(i,0,0),Hc=new Is(t),Hc}function jw(r){const t=Kw(r.seed),e=new Float32Array(r.count*3),i=new Float32Array(r.count),n=r.radiusM;for(let l=0;l<r.count;l++){const h=t()*Math.PI*2,u=Math.sqrt(t())*r.radiusM;e[l*3]=Math.cos(h)*u,e[l*3+1]=t()*r.heightM,e[l*3+2]=Math.sin(h)*u,i[l]=.85+t()*.3}const s=new ce;s.setAttribute("position",new ie(e,3)),s.setAttribute("aSpeed",new ie(i,1)),s.setDrawRange(0,r.visibleCount);const a={uTime:{value:0},uOverallSpeed:{value:r.overallSpeed},uPixelSize:{value:r.pixelSize},uOpacity:{value:r.opacity},uColor:{value:r.color},uUvSquash:{value:1},uSpeedStreak:{value:r.speedStreak},uWindOffset:{value:new xt(0,0)},uDropVelocity:{value:new R(0,-1,0)},uAspect:{value:1},uHeight:{value:r.heightM},uBottomY:{value:r.bottomYM},uHalfWidth:{value:n},uTexture:{value:Jw()},uNearFocusDistance:{value:r.nearFocusDistanceM},uHazeDistance:{value:r.hazeDistanceM},uHazeColor:{value:r.hazeColor}},o=new le({uniforms:a,vertexShader:qw,fragmentShader:$w,transparent:!0,depthWrite:!1,depthTest:!0}),c=new xs(s,o);return c.frustumCulled=!1,{points:c,uniforms:a}}class Ua{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(t){return Ua.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(t,1e-12))}static fromMagPerArcsec2(t){return 10**(.4*(Ua.S10_MAG_PER_ARCSEC2-t))}static latitudeOfRowCoord(t){const e=2*t-1;return 90*Math.sign(e)*e*e}static rowCoordOfLatitude(t){return(Math.sign(t)*Math.sqrt(Math.min(Math.abs(t),90)/90)+1)/2}static angleOfColumnCoord(t){return 180*t*t}static columnCoordOfAngle(t){return Math.sqrt(Math.min(Math.max(t,0),180)/180)}}class se{static LONGITUDE_STEPS=256;static LATITUDE_STEPS=128;static SUN_RADIUS_KPC=8.2;static SUN_HEIGHT_KPC=.02;static DISK_SCALE_LENGTH_KPC=2.6;static DISK_SCALE_HEIGHT_KPC=.3;static BULGE_SCALE_KPC=.5;static BULGE_FLATTENING=.6;static BULGE_TO_LOCAL_DISK=20;static DUST_SCALE_LENGTH_KPC=3.5;static DUST_SCALE_HEIGHT_KPC=.1;static EXTINCTION_MAG_PER_KPC=.8;static NEAR_LIMIT_KPC=.01;static FAR_LIMIT_KPC=40;static STEPS=192;static OPAQUE_MAG=15;static PEAK_MAG_PER_ARCSEC2=21;static PEAK_RADIANCE=6.278;static PEAK_LONGITUDE_DEG=0;static PEAK_LATITUDE_DEG=4.5;surfaceBrightnessS10(t,e){return this.radianceTowards(t,e)*se.anchor()}static anchor(){return Ua.fromMagPerArcsec2(se.PEAK_MAG_PER_ARCSEC2)/se.PEAK_RADIANCE}radianceTowards(t,e){return this.trace(t,e).light}extinctionTowards(t,e){return this.trace(t,e).extinctionMag}trace(t,e){const i=t*Math.PI/180,n=e*Math.PI/180,s=-Math.cos(n)*Math.cos(i),a=Math.cos(n)*Math.sin(i),o=Math.sin(n);let c=0,l=0,h=0;const u=Math.log(se.NEAR_LIMIT_KPC),d=Math.log(se.FAR_LIMIT_KPC)-u;for(let f=0;f<se.STEPS;f++){const p=Math.exp(u+d*f/(se.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=se.SUN_RADIUS_KPC+m*s,S=m*a,y=se.SUN_HEIGHT_KPC+m*o,M=Math.hypot(g,S),b=Math.exp(-(M-se.SUN_RADIUS_KPC)/se.DISK_SCALE_LENGTH_KPC-Math.abs(y)/se.DISK_SCALE_HEIGHT_KPC),w=Math.hypot(M,y/se.BULGE_FLATTENING),T=se.BULGE_TO_LOCAL_DISK*Math.exp(-w/se.BULGE_SCALE_KPC);if(c+=(b+T)*v*10**(-.4*l),l+=se.EXTINCTION_MAG_PER_KPC*Math.exp(-(M-se.SUN_RADIUS_KPC)/se.DUST_SCALE_LENGTH_KPC-(Math.abs(y)-se.SUN_HEIGHT_KPC)/se.DUST_SCALE_HEIGHT_KPC)*v,l>se.OPAQUE_MAG)break}return{light:c,extinctionMag:l}}values=new Float32Array(se.LONGITUDE_STEPS*se.LATITUDE_STEPS);walked=0;get done(){return this.walked>=se.LATITUDE_STEPS}walk(t){const e=se.LONGITUDE_STEPS,i=Math.min(se.LATITUDE_STEPS,this.walked+t);for(;this.walked<i;this.walked++){const n=Ua.latitudeOfRowCoord((this.walked+.5)/se.LATITUDE_STEPS);for(let s=0;s<e;s++)this.values[this.walked*e+s]=this.radianceTowards(360*(s+.5)/e,n)}}harvest(){let t=Number.POSITIVE_INFINITY;for(const n of this.values)n<t&&(t=n);const e=se.anchor(),i=new Float32Array(this.values.length);for(let n=0;n<i.length;n++)i[n]=(this.values[n]-t)*e;return{width:se.LONGITUDE_STEPS,height:se.LATITUDE_STEPS,data:i}}}class Xe{static LONGITUDE_STEPS=128;static LATITUDE_STEPS=96;static RADIAL_FALLOFF=1.3;static FAN_EXPONENT=2.6;static SUBLIMATION_AU=.1;static NEAR_LIMIT_AU=.004;static FAR_LIMIT_AU=8;static STEPS=224;static LOBE_ASYMMETRY=[.7,-.2,-.81];static LOBE_WEIGHT=[.665,.33,.00541];static RIGHT_ANGLE_S10=200;static POLE_S10=77;surfaceBrightnessS10(t,e){return this.radianceTowards(t,e)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=Xe.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(t,e){const i=t*Math.PI/180,n=e*Math.PI/180,s=-Math.cos(n)*Math.cos(i),a=-Math.cos(n)*Math.sin(i),o=Math.sin(n),c=-s;let l=0,h=0;const u=Math.log(Xe.NEAR_LIMIT_AU),d=Math.log(Xe.FAR_LIMIT_AU)-u;for(let f=0;f<Xe.STEPS;f++){const p=Math.exp(u+d*f/(Xe.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=1+m*s,S=m*a,y=m*o,M=Math.hypot(g,S,y);if(M<Xe.SUBLIMATION_AU)continue;const b=y/M,w=M**-1.3*Math.exp(-2.6*Math.abs(b)),T=(c-m)/M;l+=w*this.scattering(T)*v/(M*M)}return l}scattering(t){let e=0;for(let i=0;i<Xe.LOBE_ASYMMETRY.length;i++){const n=Xe.LOBE_ASYMMETRY[i],s=1+n*n-2*n*t;e+=Xe.LOBE_WEIGHT[i]*(1-n*n)/(4*Math.PI*s**1.5)}return e}values=new Float32Array(Xe.LONGITUDE_STEPS*Xe.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Xe.LATITUDE_STEPS}walk(t){const e=Xe.LONGITUDE_STEPS,i=Math.min(Xe.LATITUDE_STEPS,this.walked+t);for(;this.walked<i;this.walked++){const n=Ua.latitudeOfRowCoord((this.walked+.5)/Xe.LATITUDE_STEPS);for(let s=0;s<e;s++){const a=Ua.angleOfColumnCoord((s+.5)/e);this.values[this.walked*e+s]=this.radianceTowards(a,n)}}}harvest(){const t=this.anchor();let e=Number.POSITIVE_INFINITY;for(const n of this.values)n<e&&(e=n);const i=new Float32Array(this.values.length);for(let n=0;n<i.length;n++)i[n]=(this.values[n]-e)*t;return{width:Xe.LONGITUDE_STEPS,height:Xe.LATITUDE_STEPS,data:i}}}class Mt{static get NANOLAMBERTS_PER_S10(){return Mt.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(t){return t*Mt.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},...Array.from({length:15},(t,e)=>{const i=-4-e;return{sunAltitudeDeg:i,magPerArcsec2:Mt.patatV(i)}}),{sunAltitudeDeg:-24,magPerArcsec2:22}];static patatV(t){const e=90-t-95;return 11.84+1.518*e-.057*e*e}static moonlessMagPerArcsec2(t){const e=Mt.TWILIGHT;for(let i=0;i<e.length-1;i++){const n=e[i],s=e[i+1];if(t<=n.sunAltitudeDeg&&t>=s.sunAltitudeDeg){const a=(n.sunAltitudeDeg-t)/(n.sunAltitudeDeg-s.sunAltitudeDeg);return n.magPerArcsec2+(s.magPerArcsec2-n.magPerArcsec2)*a}}return t>0?e[0].magPerArcsec2:e[e.length-1].magPerArcsec2}static toNanolamberts(t){return 34.08*Math.exp(Mt.NANOLAMBERT_OFFSET-Mt.PER_MAGNITUDE*t)}static fromNanolamberts(t){return(Mt.NANOLAMBERT_OFFSET-Math.log(Math.max(t,1e-6)/34.08))/Mt.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(t){const e=Math.cos(Math.max(t,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*e*e,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(t){const e=Math.min(Math.max(t,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(e)**2)+10**(6.15-Math.min(t,180)/40)}static scatteredFraction(t){return 1-10**(-.4*Mt.EXTINCTION_PER_AIR_MASS*Mt.airMass(t))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(t){return Math.max(0,Mt.toNanolamberts(Mt.moonlessMagPerArcsec2(t))-Mt.toNanolamberts(Mt.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(t){const e=Mt.scatteringAt(90-t)*Mt.scatteredFraction(90);return Mt.twilightExcessNanolamberts(t)/e}static moonNanolamberts(t,e,i,n){return Mt.scatteringAt(i)*Mt.moonOutput(t,e)*Mt.scatteredFraction(n)}static moonOutput(t,e){if(e<=0)return 0;const i=Math.min(Math.abs(t),180);return 10**(-.4*(3.84+.026*i+4e-9*i**4))*10**(-.4*Mt.EXTINCTION_PER_AIR_MASS*Mt.airMass(e))}static phaseAngleOf(t){return Math.acos(Math.min(Math.max(2*t-1,-1),1))*180/Math.PI}static magPerArcsec2(t,e,i,n){const s=Mt.scatteredFraction(i),a=Mt.scatteringAt(t.separationDeg)*Mt.twilightOutput(t.altitudeDeg)*s,o=Mt.scatteringAt(e.separationDeg)*Mt.moonOutput(e.phaseAngleDeg,e.altitudeDeg)*s;return Mt.fromNanolamberts(Mt.toNanolamberts(Mt.AIRGLOW_MAG_PER_ARCSEC2)+a+o+Mt.artificialNanolamberts(n,i))}static artificialZenithNanolamberts(t){return t===void 0||!Number.isFinite(t)?0:Math.max(0,Mt.toNanolamberts(t)-Mt.toNanolamberts(Mt.AIRGLOW_MAG_PER_ARCSEC2))}static artificialNanolamberts(t,e){const i=Mt.artificialZenithNanolamberts(t);return i>0?i*Mt.artificialShape(e):0}static artificialShape(t){return Mt.scatteredFraction(t)/Mt.scatteredFraction(90)}static nakedEyeLimit(t){return 7.93-5*Math.log10(10**(4.316-t/5)+1)}static starLossMagnitudes(t,e,i){const n=Mt.moonlessMagPerArcsec2(t),s=Mt.fromNanolamberts(Mt.toNanolamberts(n)+Mt.scatteringAt(90-e.altitudeDeg)*Mt.moonOutput(e.phaseAngleDeg,e.altitudeDeg)*Mt.scatteredFraction(90)+Mt.artificialZenithNanolamberts(i));return Math.max(0,Mt.nakedEyeLimit(n)-Mt.nakedEyeLimit(s))}}class Xs{static RADIUS=890;static TOO_BRIGHT_MAG_PER_ARCSEC2=16;static MILKY_WAY_TINT=[.9,.94,1];static ZODIACAL_TINT=[1,.97,.9];object;material;maps=Sa.shared;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;repaint;constructor(){this.milkyWayTexels=this.maps.milkyWayTexels,this.milkyWayTexture=Xs.buildTexture(this.milkyWayTexels,se.LONGITUDE_STEPS,se.LATITUDE_STEPS,ko),this.zodiacalTexels=this.maps.zodiacalTexels,this.zodiacalTexture=Xs.buildTexture(this.zodiacalTexels,Xe.LONGITUDE_STEPS,Xe.LATITUDE_STEPS,wi),this.material=new le({uniforms:{uMilkyWay:{value:this.milkyWayTexture},uZodiacal:{value:this.zodiacalTexture},uGalactic:{value:new Yt},uEclipticPole:{value:new R(0,1,0)},uSunLongitude:{value:new R(1,0,0)},uMoonDirection:{value:new R(0,-1,0)},uMoonOutput:{value:0},uSunDirection:{value:new R(0,-1,0)},uTwilightOutput:{value:0},uAirglowNanolamberts:{value:Mt.toNanolamberts(Mt.AIRGLOW_MAG_PER_ARCSEC2)},uArtificialNanolamberts:{value:0},uSkyColor:{value:new R(0,0,0)},uMilkyWayTint:{value:new R(...Xs.MILKY_WAY_TINT)},uZodiacalTint:{value:new R(...Xs.ZODIACAL_TINT)},uReady:{value:this.maps.done?1:0},uEncodeDestination:{value:1}},vertexShader:`
6157
6214
  varying vec3 vDirection;
6158
6215
  void main() {
6159
6216
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -6273,13 +6330,13 @@ void main() {
6273
6330
  vec3 onEncoded = encodeSrgb(uSkyColor + light) - encodeSrgb(uSkyColor);
6274
6331
  gl_FragColor = vec4(mix(light, onEncoded, uEncodeDestination), 1.0);
6275
6332
  }
6276
- `,transparent:!0,blending:Ni,depthWrite:!1,side:Ve,fog:!1}),this.object=new Dt(new oi(Xs.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}static buildTexture(t,e,i,n){const s=new ra(t,e,i,Ei,qe);return s.minFilter=oe,s.magFilter=oe,s.wrapS=n,s.wrapT=wi,s.needsUpdate=!0,s}set onReady(t){this.repaint=t}update(t){if(Mt.moonlessMagPerArcsec2(t.sunAltitudeDeg)<Xs.TOO_BRIGHT_MAG_PER_ARCSEC2){this.object.visible=!1,this.stopWork();return}const i=this.material.uniforms;i.uGalactic.value.copy(t.galactic),i.uEclipticPole.value.copy(t.eclipticPole).normalize(),i.uSunLongitude.value.copy(t.sunLongitude).normalize(),i.uMoonDirection.value.copy(t.moon.direction).normalize(),i.uSunDirection.value.copy(t.sunDirection).normalize(),i.uMoonOutput.value=Mt.moonOutput(t.moon.phaseAngleDeg,t.moon.altitudeDeg),i.uTwilightOutput.value=Mt.twilightOutput(t.sunAltitudeDeg),i.uArtificialNanolamberts.value=Mt.artificialZenithNanolamberts(t.lightPollution),i.uSkyColor.value.copy(t.skyColor),this.object.visible=!0,i.uReady.value<.5&&this.scheduleWork()}setDestinationEncoded(t){this.material.uniforms.uEncodeDestination.value=t?1:0}hide(){this.object.visible=!1,this.stopWork()}scheduleWork(){this.maps.request(this.publish)}stopWork(){this.maps.cancel(this.publish)}publish=()=>{this.milkyWayTexture.needsUpdate=!0,this.zodiacalTexture.needsUpdate=!0,this.material.uniforms.uReady.value=1,this.repaint?.()};dispose(){this.stopWork(),this.milkyWayTexture.dispose(),this.zodiacalTexture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Sa{static instance;static get shared(){return Sa.instance??=new Sa}static WORK_BUDGET_MS=6;milkyWayTexels=new Uint16Array(se.LONGITUDE_STEPS*se.LATITUDE_STEPS*4);zodiacalTexels=new Uint16Array(Xe.LONGITUDE_STEPS*Xe.LATITUDE_STEPS*4);galaxy=new se;dust=new Xe;waiting=new Set;workHandle;published=!1;get done(){return this.published}request(t){if(this.published){t();return}if(this.waiting.add(t),this.workHandle!==void 0)return;const e=()=>{this.workHandle=void 0;const i=performance.now()+Sa.WORK_BUDGET_MS;for(;performance.now()<i&&!(this.galaxy.done&&this.dust.done);)this.galaxy.walk(1),this.dust.walk(1);if(this.galaxy.done&&this.dust.done){this.publish();return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}cancel(t){this.waiting.delete(t),!(this.waiting.size>0||this.workHandle===void 0)&&(cancelAnimationFrame(this.workHandle),this.workHandle=void 0)}publish(){Sa.fill(this.milkyWayTexels,this.galaxy.harvest()),Sa.fill(this.zodiacalTexels,this.dust.harvest()),this.published=!0;const t=[...this.waiting];this.waiting.clear();for(const e of t)e()}static fill(t,e){for(let i=0;i<e.data.length;i++)t[i*4]=Fn.toHalfFloat(Mt.nanolambertsOfS10(e.data[i])),t[i*4+3]=Fn.toHalfFloat(1)}}class Dn{static GALACTIC_CENTRE={raHours:266.4051/15,decDeg:-28.936175};static GALACTIC_ROTATION={raHours:318.00448/15,decDeg:48.32964};static GALACTIC_POLE={raHours:192.85948/15,decDeg:27.12825};static ECLIPTIC_POLE={raHours:18,decDeg:90-23.439291};static galactic(t,e){return{centre:Dn.at(Dn.GALACTIC_CENTRE,t,e),rotation:Dn.at(Dn.GALACTIC_ROTATION,t,e),pole:Dn.at(Dn.GALACTIC_POLE,t,e)}}static eclipticPole(t,e){return Dn.at(Dn.ECLIPTIC_POLE,t,e)}static at(t,e,i){return Pn.ofJ2000(t.raHours,t.decDeg,e,i,!1)}}const Q5=`
6333
+ `,transparent:!0,blending:Ni,depthWrite:!1,side:Ve,fog:!1}),this.object=new Dt(new oi(Xs.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}static buildTexture(t,e,i,n){const s=new ra(t,e,i,Ei,qe);return s.minFilter=oe,s.magFilter=oe,s.wrapS=n,s.wrapT=wi,s.needsUpdate=!0,s}set onReady(t){this.repaint=t}update(t){if(Mt.moonlessMagPerArcsec2(t.sunAltitudeDeg)<Xs.TOO_BRIGHT_MAG_PER_ARCSEC2){this.object.visible=!1,this.stopWork();return}const i=this.material.uniforms;i.uGalactic.value.copy(t.galactic),i.uEclipticPole.value.copy(t.eclipticPole).normalize(),i.uSunLongitude.value.copy(t.sunLongitude).normalize(),i.uMoonDirection.value.copy(t.moon.direction).normalize(),i.uSunDirection.value.copy(t.sunDirection).normalize(),i.uMoonOutput.value=Mt.moonOutput(t.moon.phaseAngleDeg,t.moon.altitudeDeg),i.uTwilightOutput.value=Mt.twilightOutput(t.sunAltitudeDeg),i.uArtificialNanolamberts.value=Mt.artificialZenithNanolamberts(t.lightPollution),i.uSkyColor.value.copy(t.skyColor),this.object.visible=!0,i.uReady.value<.5&&this.scheduleWork()}setDestinationEncoded(t){this.material.uniforms.uEncodeDestination.value=t?1:0}hide(){this.object.visible=!1,this.stopWork()}scheduleWork(){this.maps.request(this.publish)}stopWork(){this.maps.cancel(this.publish)}publish=()=>{this.milkyWayTexture.needsUpdate=!0,this.zodiacalTexture.needsUpdate=!0,this.material.uniforms.uReady.value=1,this.repaint?.()};dispose(){this.stopWork(),this.milkyWayTexture.dispose(),this.zodiacalTexture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Sa{static instance;static get shared(){return Sa.instance??=new Sa}static WORK_BUDGET_MS=6;milkyWayTexels=new Uint16Array(se.LONGITUDE_STEPS*se.LATITUDE_STEPS*4);zodiacalTexels=new Uint16Array(Xe.LONGITUDE_STEPS*Xe.LATITUDE_STEPS*4);galaxy=new se;dust=new Xe;waiting=new Set;workHandle;published=!1;get done(){return this.published}request(t){if(this.published){t();return}if(this.waiting.add(t),this.workHandle!==void 0)return;const e=()=>{this.workHandle=void 0;const i=performance.now()+Sa.WORK_BUDGET_MS;for(;performance.now()<i&&!(this.galaxy.done&&this.dust.done);)this.galaxy.walk(1),this.dust.walk(1);if(this.galaxy.done&&this.dust.done){this.publish();return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}cancel(t){this.waiting.delete(t),!(this.waiting.size>0||this.workHandle===void 0)&&(cancelAnimationFrame(this.workHandle),this.workHandle=void 0)}publish(){Sa.fill(this.milkyWayTexels,this.galaxy.harvest()),Sa.fill(this.zodiacalTexels,this.dust.harvest()),this.published=!0;const t=[...this.waiting];this.waiting.clear();for(const e of t)e()}static fill(t,e){for(let i=0;i<e.data.length;i++)t[i*4]=Fn.toHalfFloat(Mt.nanolambertsOfS10(e.data[i])),t[i*4+3]=Fn.toHalfFloat(1)}}class Dn{static GALACTIC_CENTRE={raHours:266.4051/15,decDeg:-28.936175};static GALACTIC_ROTATION={raHours:318.00448/15,decDeg:48.32964};static GALACTIC_POLE={raHours:192.85948/15,decDeg:27.12825};static ECLIPTIC_POLE={raHours:18,decDeg:90-23.439291};static galactic(t,e){return{centre:Dn.at(Dn.GALACTIC_CENTRE,t,e),rotation:Dn.at(Dn.GALACTIC_ROTATION,t,e),pole:Dn.at(Dn.GALACTIC_POLE,t,e)}}static eclipticPole(t,e){return Dn.at(Dn.ECLIPTIC_POLE,t,e)}static at(t,e,i){return Pn.ofJ2000(t.raHours,t.decDeg,e,i,!1)}}const Qw=`
6277
6334
  varying vec2 vUv;
6278
6335
  void main() {
6279
6336
  vUv = uv;
6280
6337
  gl_Position = vec4(position, 1.0);
6281
6338
  }
6282
- `,tw=`
6339
+ `,t5=`
6283
6340
  // Based on https://www.shadertoy.com/view/4sX3Rs
6284
6341
  uniform float uTime;
6285
6342
  uniform vec2 uLensPosition;
@@ -6717,7 +6774,7 @@ void main()
6717
6774
  // stays what it always was for the optional artifacts.
6718
6775
  gl_FragColor = vec4(dazzle + artifactsContribution * uOpacity, 1.0);
6719
6776
  }
6720
- `;let Gc;function ew(){if(Gc)return Gc;const r=256,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d");e.fillStyle="rgba(60,60,60,1)",e.fillRect(0,0,r,r);const i=[[.3,.35,.22,.5],[.7,.6,.16,.35],[.55,.8,.3,.4],[.15,.7,.12,.3],[.85,.2,.18,.3]];for(const[n,s,a,o]of i){const c=e.createRadialGradient(n*r,s*r,0,n*r,s*r,a*r);c.addColorStop(0,`rgba(200,200,200,${o})`),c.addColorStop(1,"rgba(200,200,200,0)"),e.fillStyle=c,e.fillRect(0,0,r,r)}return Gc=new Is(t),Gc}function iw(){const r={uTime:{value:0},uResolution:{value:new xt(1,1)},uLensPosition:{value:new xt(0,0)},uColorGain:{value:new st(55,55,51)},uOpacity:{value:.5},uFlareIntensity:{value:0},uStarPoints:{value:0},uTanHalfFov:{value:Math.tan(Math.PI/6)},uEquidistant:{value:0},uHalfFovRad:{value:Math.PI/6},uSourceRadiusDeg:{value:.265},uVeilStrength:{value:0},uDazzleColour:{value:new st(1,1,1)},uFlareSize:{value:.0025},uFlareSpeed:{value:.4},uFlareShape:{value:1.2},uHaloScale:{value:.5},uGhostScale:{value:.3},uAnimated:{value:!1},uAnamorphic:{value:!1},uSecondaryGhosts:{value:!0},uStarBurst:{value:!0},uAdditionalStreaks:{value:!0},uLensDirtTexture:{value:ew()}},t=new le({uniforms:r,vertexShader:Q5,fragmentShader:tw,transparent:!0,depthWrite:!1,depthTest:!1,blending:Ni,fog:!1,name:"LensFlareShader"}),e=new Dt(new Xi(2,2),t);return e.frustumCulled=!1,e.renderOrder=20,{mesh:e,uniforms:r}}class We{static MAX_HALF_ANGLE_DEG=80;static MAX_CUBE_FACE=2048;static SAMPLES=4;cubeTarget;cubeCamera;cubeMaterial;cubeRotation=new Yt;target;overlayTarget;overlayCubeTarget;quadScene=new Ts;quadCamera=new Un(-1,1,1,-1,0,1);material;width;height;constructor(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.target=new ri(this.width,this.height,{type:qe,samples:We.SAMPLES}),this.overlayTarget=new ri(this.width,this.height,{type:qe,samples:We.SAMPLES}),this.material=new le({uniforms:{...Hi,uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new xt(this.width,this.height)},uOverlay:{value:this.overlayTarget.texture},uMode:{value:hn.Finished}},vertexShader:`
6777
+ `;let Gc;function e5(){if(Gc)return Gc;const r=256,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d");e.fillStyle="rgba(60,60,60,1)",e.fillRect(0,0,r,r);const i=[[.3,.35,.22,.5],[.7,.6,.16,.35],[.55,.8,.3,.4],[.15,.7,.12,.3],[.85,.2,.18,.3]];for(const[n,s,a,o]of i){const c=e.createRadialGradient(n*r,s*r,0,n*r,s*r,a*r);c.addColorStop(0,`rgba(200,200,200,${o})`),c.addColorStop(1,"rgba(200,200,200,0)"),e.fillStyle=c,e.fillRect(0,0,r,r)}return Gc=new Is(t),Gc}function i5(){const r={uTime:{value:0},uResolution:{value:new xt(1,1)},uLensPosition:{value:new xt(0,0)},uColorGain:{value:new st(55,55,51)},uOpacity:{value:.5},uFlareIntensity:{value:0},uStarPoints:{value:0},uTanHalfFov:{value:Math.tan(Math.PI/6)},uEquidistant:{value:0},uHalfFovRad:{value:Math.PI/6},uSourceRadiusDeg:{value:.265},uVeilStrength:{value:0},uDazzleColour:{value:new st(1,1,1)},uFlareSize:{value:.0025},uFlareSpeed:{value:.4},uFlareShape:{value:1.2},uHaloScale:{value:.5},uGhostScale:{value:.3},uAnimated:{value:!1},uAnamorphic:{value:!1},uSecondaryGhosts:{value:!0},uStarBurst:{value:!0},uAdditionalStreaks:{value:!0},uLensDirtTexture:{value:e5()}},t=new le({uniforms:r,vertexShader:Qw,fragmentShader:t5,transparent:!0,depthWrite:!1,depthTest:!1,blending:Ni,fog:!1,name:"LensFlareShader"}),e=new Dt(new Xi(2,2),t);return e.frustumCulled=!1,e.renderOrder=20,{mesh:e,uniforms:r}}class We{static MAX_HALF_ANGLE_DEG=80;static MAX_CUBE_FACE=2048;static SAMPLES=4;cubeTarget;cubeCamera;cubeMaterial;cubeRotation=new Yt;target;overlayTarget;overlayCubeTarget;quadScene=new Ts;quadCamera=new Un(-1,1,1,-1,0,1);material;width;height;constructor(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.target=new ri(this.width,this.height,{type:qe,samples:We.SAMPLES}),this.overlayTarget=new ri(this.width,this.height,{type:qe,samples:We.SAMPLES}),this.material=new le({uniforms:{...Hi,uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new xt(this.width,this.height)},uOverlay:{value:this.overlayTarget.texture},uMode:{value:hn.Finished}},vertexShader:`
6721
6778
  varying vec2 vNdc;
6722
6779
  void main() {
6723
6780
  vNdc = position.xy;
@@ -6914,7 +6971,7 @@ void main()
6914
6971
  vec4 overlay = texture2D(uOverlay, vUv);
6915
6972
  ${Eo}
6916
6973
  }
6917
- `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new Dt(new Xi(2,2),this.material))}render(t,e,i,n,s,a){const o=t.getRenderTarget(),c=a??{scene:this.scene,overlay:this.overlay};t.setRenderTarget(c.scene),t.render(e,i),s?.(),(n||a)&&(We.clearTransparent(t,c.overlay),n?.()),t.setRenderTarget(o),!a&&(this.material.uniforms.uMode.value=hn.Finished,t.render(this.quadScene,this.quadCamera))}resize(t,e){this.scene.setSize(Math.max(1,t),Math.max(1,e)),this.overlay.setSize(Math.max(1,t),Math.max(1,e))}dispose(){this.scene.dispose(),this.overlay.dispose(),this.material.dispose(),this.quadScene.children[0].geometry.dispose()}}class ve{static MIN_RATIO=1;static STEP=.25;static MIN_SHARE_OF_DISPLAY=.75;static GPU_LATE_MS=12;static GPU_ROOM_MS=6;static INTERVAL_LATE_MS=21;static LOWER_COOLDOWN_MS=750;static RAISE_COOLDOWN_MS=2e3;static PROBE_WATCH_MS=2e3;static PROBE_EVERY_MS=6e3;static PROBE_BACKOFF_MS=3e4;ratio;maxRatio;timer;intervalMs;lastChangeMs=-1/0;nextProbeMs=0;probe;constructor(t,e){this.maxRatio=ve.clamp(t),this.ratio=this.maxRatio,this.timer=e?Ll.create(e):void 0}get pixelRatio(){return this.ratio}static SETTLE_MS=400;static SUSTAINED_MS=100;lastEditMs=-1/0;editStreakStartMs=-1/0;wasChanging=!1;noteChange(t){t-this.lastEditMs>ve.SETTLE_MS&&(this.editStreakStartMs=t),this.lastEditMs=t}changing(t){return t-this.lastEditMs<=ve.SETTLE_MS&&this.lastEditMs-this.editStreakStartMs>=ve.SUSTAINED_MS}ratioFor(t,e){return this.changing(t)?this.wasChanging?(this.update(t,e),this.ratio):(this.wasChanging=!0,this.reset(),this.ratio):(this.wasChanging=!1,this.maxRatio)}get timesGpu(){return this.timer!==void 0}set maximum(t){this.maxRatio=ve.clamp(t),this.ratio>this.maxRatio&&(this.ratio=this.maxRatio),this.ratio<this.minimum&&(this.ratio=Math.min(this.maxRatio,this.minimum))}get minimum(){const t=Math.floor(this.maxRatio*ve.MIN_SHARE_OF_DISPLAY/ve.STEP)*ve.STEP;return Math.max(ve.MIN_RATIO,t)}get maximum(){return this.maxRatio}beginDrawing(){this.timer?.begin()}endDrawing(){this.timer?.end()}reset(){this.intervalMs=void 0,this.probe=void 0,this.timer?.reset()}update(t,e){const i=this.timer?.poll();if(!(this.timer&&i===void 0))return i!==void 0?this.followGpu(t,i):this.followIntervals(t,e)}followGpu(t,e){if(e>ve.GPU_LATE_MS)return this.lower(t,ve.LOWER_COOLDOWN_MS);if(e<ve.GPU_ROOM_MS)return this.raise(t,ve.RAISE_COOLDOWN_MS)}followIntervals(t,e){if(!(e>0)||e>1e3)return;this.intervalMs=this.intervalMs===void 0?e:this.intervalMs*.9+e*.1;const i=this.intervalMs>ve.INTERVAL_LATE_MS;if(this.probe){if(i)return this.ratio=this.probe.ratioBefore,this.probe=void 0,this.lastChangeMs=t,this.nextProbeMs=t+ve.PROBE_BACKOFF_MS,this.ratio;t-this.probe.sinceMs>=ve.PROBE_WATCH_MS&&(this.probe=void 0,this.nextProbeMs=t+ve.PROBE_EVERY_MS);return}if(i){const n=this.lower(t,ve.LOWER_COOLDOWN_MS);return n!==void 0&&(this.nextProbeMs=t+ve.PROBE_EVERY_MS),n}if(this.ratio<this.maxRatio&&t>=this.nextProbeMs&&t-this.lastChangeMs>=ve.RAISE_COOLDOWN_MS){const n=this.ratio,s=this.raise(t,0);return s!==void 0&&(this.probe={sinceMs:t,ratioBefore:n}),s}}lower(t,e){if(!(this.ratio<=this.minimum||t-this.lastChangeMs<e))return this.ratio=Math.max(this.minimum,ve.clamp(this.ratio-ve.STEP)),this.lastChangeMs=t,this.ratio}raise(t,e){if(!(this.ratio>=this.maxRatio||t-this.lastChangeMs<e))return this.ratio=Math.min(this.maxRatio,ve.clamp(this.ratio+ve.STEP)),this.lastChangeMs=t,this.ratio}static clamp(t){return Number.isFinite(t)?Math.max(ve.MIN_RATIO,Math.round(t/ve.STEP)*ve.STEP):ve.MIN_RATIO}}class Ll{constructor(t,e){this.gl=t,this.extension=e}static IN_FLIGHT_MAX=8;static create(t){if(!(t instanceof WebGL2RenderingContext))return;const e=t.getExtension("EXT_disjoint_timer_query_webgl2");return e?new Ll(t,e):void 0}pending=[];active;smoothedMs;begin(){if(!(this.active||this.pending.length>=Ll.IN_FLIGHT_MAX))try{const t=this.gl.createQuery();if(!t)return;this.gl.beginQuery(this.extension.TIME_ELAPSED_EXT,t),this.active=t}catch{this.active=void 0}}end(){if(this.active){try{this.gl.endQuery(this.extension.TIME_ELAPSED_EXT),this.pending.push(this.active)}catch{}this.active=void 0}}poll(){const t=this.gl;try{for(let e=0;e<this.pending.length;e++){const i=this.pending[e];if(!t.getQueryParameter(i,t.QUERY_RESULT_AVAILABLE))continue;if(!t.getParameter(this.extension.GPU_DISJOINT_EXT)){const s=t.getQueryParameter(i,t.QUERY_RESULT)/1e6;this.smoothedMs=this.smoothedMs===void 0?s:this.smoothedMs*.8+s*.2}t.deleteQuery(i),this.pending.splice(e,1),e--}}catch{this.pending.length=0}return this.smoothedMs}reset(){this.smoothedMs=void 0}}class pe{static ICE_INDEX_RED=1.3067;static ICE_INDEX_BLUE=1.317;static SIDE_PRISM_ANGLE_DEG=60;static END_PRISM_ANGLE_DEG=90;static get PARHELIA_MAX_SUN_ALTITUDE_DEG(){const t=pe.ICE_INDEX_RED,e=Math.sqrt((4-t*t)/3);return Math.asin(Math.min(1,e))*180/Math.PI}static minimumDeviationDeg(t,e){const i=t*Math.PI/180,n=e*Math.sin(i/2);return n>1?Number.NaN:(2*Math.asin(n)-i)*180/Math.PI}static effectiveIndex(t,e){const i=e*Math.PI/180,n=Math.cos(i);return n<=0?Number.POSITIVE_INFINITY:Math.sqrt(t*t-Math.sin(i)**2)/n}static parheliaAzimuthDeg(t,e=pe.ICE_INDEX_RED){const i=pe.minimumDeviationDeg(pe.SIDE_PRISM_ANGLE_DEG,pe.effectiveIndex(e,t));return Number.isFinite(i)?i:void 0}static parheliaDistanceDeg(t,e=pe.ICE_INDEX_RED){const i=pe.parheliaAzimuthDeg(t,e);if(i===void 0)return;const n=t*Math.PI/180,s=Math.sin(n)**2,a=Math.cos(n)**2*Math.cos(i*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,s+a)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const t=pe.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(t*t-1)))*180/Math.PI}static circumzenithalAltitudeDeg(t,e=pe.ICE_INDEX_RED){if(t<0||t>90-pe.PLATE_END_FACE_LIMIT_DEG)return;const i=Math.cos(t*Math.PI/180),n=Math.sqrt(e*e-i*i);if(!(n>=1))return Math.asin(n)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(t){return Math.acos(6371e3/(6371e3+Math.max(0,t)))*180/Math.PI}static halo22(){return pe.ringOf("halo22",pe.SIDE_PRISM_ANGLE_DEG)}static halo46(){return pe.ringOf("halo46",pe.END_PRISM_ANGLE_DEG)}static ringOf(t,e){const i=pe.minimumDeviationDeg(e,pe.ICE_INDEX_RED),n=pe.minimumDeviationDeg(e,pe.ICE_INDEX_BLUE);return{id:t,angleDeg:(i+n)/2,redAngleDeg:i,blueAngleDeg:n}}static strength(t,e,i=90,n=0){const s=Math.max(0,Math.min(1,t)),a=Math.max(0,1-Math.max(0,Math.min(1,e))),o=i>=0?1:n<=0?0:Math.max(0,1+i/n);return s*a*o}static formsAt(t,e=0){if(t<=-e)return[];const i=[pe.halo22(),pe.halo46()],n=t>0?pe.parheliaDistanceDeg(t):void 0;n!==void 0&&i.push({id:"parhelia",angleDeg:n,redAngleDeg:n,blueAngleDeg:pe.parheliaDistanceDeg(t,pe.ICE_INDEX_BLUE)}),i.push({id:"tangentArc",angleDeg:pe.halo22().angleDeg}),t>0&&i.push({id:"parhelicCircle",angleDeg:t});const s=pe.circumzenithalAltitudeDeg(t);return s!==void 0&&i.push({id:"circumzenithal",angleDeg:s}),t>pe.PLATE_END_FACE_LIMIT_DEG&&i.push({id:"circumhorizontal"}),t<pe.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&i.push({id:"pillar"}),i}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class an{static get WATER_INDEX_RED(){return _i.indexAt(_i.RED_NM)}static get WATER_INDEX_BLUE(){return _i.indexAt(_i.BLUE_NM)}static radiusDeg(t,e){const i=(e*e-1)/(t*t-1);if(i<0||i>1)return Number.NaN;const n=Math.acos(Math.sqrt(i)),s=Math.asin(Math.sin(n)/e),a=2*(n-s)+(t-1)*(Math.PI-2*s),o=2*Math.PI;let c=a%o;return c<0&&(c+=o),c>Math.PI&&(c=o-c),180-c*180/Math.PI}static primary(){return an.bowOf("primary",2,0)}static secondary(){return an.bowOf("secondary",3,0)}static bowOf(t,e,i){const n=an.radiusDeg(e,an.WATER_INDEX_RED),s=an.radiusDeg(e,an.WATER_INDEX_BLUE),a=(n+s)/2;return{id:t,radiusDeg:a,redRadiusDeg:n,violetRadiusDeg:s,topAltitudeDeg:a-i}}static alexandersBandDeg(){return{fromDeg:an.primary().redRadiusDeg,toDeg:an.secondary().redRadiusDeg}}static formsAt(t){return t<0?[]:[an.bowOf("primary",2,t),an.bowOf("secondary",3,t)].filter(e=>e.topAltitudeDeg>0)}static FULL_MOON_MAGNITUDE=-12.7;static moonlightShare(t){return Math.min(1,10**(-.4*(t-an.FULL_MOON_MAGNITUDE)))}static strength(t,e,i){if(i<=0)return 0;const n=Math.max(0,Math.min(1,t)),s=Math.max(0,1-Math.max(0,Math.min(1,e)));return n*s}}class rn{constructor(t){this.radius=t;const e=rn.SEGMENTS*rn.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const i=new ce;i.setAttribute("position",new ee(this.positions,3)),i.setAttribute("color",new ee(this.colors,3)),i.setDrawRange(0,0),this.object=new Dt(i,new _n({vertexColors:!0,transparent:!0,blending:Ni,depthWrite:!1,fog:!1,side:ji})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=rn.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(rn.ACROSS-1)*6;static HEAD_HALF_WIDTH_DEG=.15;static SPREAD_FRACTION=.05;static FADE_POWER=1.8;object;positions;colors;head;tip;brightness=0;set(t,e,i){this.head=t&&hi(t.altitudeDeg,t.azimuthDeg,1),this.tip=e&&hi(e.altitudeDeg,e.azimuthDeg,1),this.brightness=i,this.rebuild()}rebuild(){const t=this.object.geometry,e=this.head,i=this.tip;if(!e||!i||this.brightness<=0){t.setDrawRange(0,0);return}const n=this.angleBetween(e,i);if(n<=0){t.setDrawRange(0,0);return}const s=n*rn.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(e,i,h),this.radius),o=h=>this.radius*(rn.HEAD_HALF_WIDTH_DEG*Math.PI/180+s*h),c=h=>this.brightness*(1-h)**rn.FADE_POWER;let l=0;for(let h=1;h<rn.POINTS;h++){const u=(h-1)/rn.SEGMENTS,d=h/rn.SEGMENTS;l=this.pushBand(l,a(u),a(d),o(u),o(d),c(u),c(d))}t.setDrawRange(0,l),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}pushBand(t,e,i,n,s,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(i,e))));for(let l=0;l<rn.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,n,h),f=this.across(i,c,s,h),p=this.across(e,c,n,u),v=this.across(i,c,s,u),m=(g,S)=>g===0?S:0;t=this.push(t,d,m(h,a)),t=this.push(t,f,m(h,o)),t=this.push(t,p,m(u,a)),t=this.push(t,f,m(h,o)),t=this.push(t,v,m(u,o)),t=this.push(t,p,m(u,a))}return t}across(t,e,i,n){return{x:t.x+e.x*i*n,y:t.y+e.y*i*n,z:t.z+e.z*i*n}}push(t,e,i){const n=t*3;this.positions[n]=e.x,this.positions[n+1]=e.y,this.positions[n+2]=e.z;const s=At.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[n]=s*.55,this.colors[n+1]=s*.75,this.colors[n+2]=s,t+1}slerp(t,e,i){const n=this.angleBetweenRadians(t,e);if(n<1e-9)return t;const s=Math.sin(n),a=Math.sin((1-i)*n)/s,o=Math.sin(i*n)/s;return{x:t.x*a+e.x*o,y:t.y*a+e.y*o,z:t.z*a+e.z*o}}angleBetween(t,e){return this.angleBetweenRadians(t,e)*180/Math.PI}angleBetweenRadians(t,e){const i=t.x*e.x+t.y*e.y+t.z*e.z;return Math.acos(Math.min(1,Math.max(-1,i)))}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class nw{object=new Ce;radius;tiers;drawn=[];constructor(t){this.radius=t,this.object.name="satellites",this.tiers=Ao.map(e=>{const i=new xs(new ce,ae.material(e.size));return ae.track(i),i.frustumCulled=!1,this.object.add(i),i})}set(t,e,i,n){const s=this.tiers.map(()=>[]);this.drawn=[];for(const a of t){if(a.magnitude>e)continue;const o=i(a.position);if(o<=0)continue;const c=a.magnitude-2.5*Math.log10(o);if(c>e)continue;const l=vo(c,e),h=h1(l),{x:u,y:d,z:f}=hi(a.position.altitudeDeg,a.position.azimuthDeg,this.radius),[p,v,m]=n(a.position,c);s[h].push({x:u,y:d,z:f,r:p,g:v,b:m,seed:a.norad*.6180339887%1}),this.drawn.push({satellite:a,direction:new R(u,d,f).normalize()})}this.tiers.forEach((a,o)=>{const c=s[o],l=new Float32Array(c.length*3),h=new Float32Array(c.length*3),u=new Float32Array(c.length);c.forEach((f,p)=>{l.set([f.x,f.y,f.z],p*3),h.set([f.r,f.g,f.b],p*3),u[p]=f.seed}),a.geometry.dispose();const d=new ce;d.setAttribute("position",new ee(l,3)),d.setAttribute("color",new ee(h,3)),d.setAttribute("seed",new ee(u,1)),a.geometry=d})}get count(){return this.drawn.length}nearest(t,e){let i,n=e;for(const s of this.drawn){const a=s.direction.dot(t);a>n&&(n=a,i=s.satellite)}return i}dispose(){for(const t of this.tiers)t.geometry.dispose(),t.material.dispose();this.object.removeFromParent(),this.drawn=[]}}class jl{constructor(t){this.state=t}next(){this.state=this.state+1831565813|0;let t=this.state;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}between(t,e){return t+this.next()*(e-t)}}class Ca{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(t){const{ratePerHour:e,durationMs:i,velocityKmS:n,seed:s}=t;if(e<=0||i<=0)return[];const a=e*i/36e5,o=new jl(s),c=Math.floor(a),l=c+(o.next()<a-c?1:0),h=[];for(let u=0;u<l;u++){const d=Math.min(1,Math.max(0,(n-20)/52)),f=Ca.MAX_DURATION_MS-d*(Ca.MAX_DURATION_MS-Ca.MIN_DURATION_MS),p=o.between(5,70);h.push({t:o.between(0,i),durationMs:f*o.between(.7,1.3),fromRadiantDeg:p,bearingDeg:o.between(0,360),lengthDeg:Math.sin(p*Math.PI/180)*o.between(8,40)*(.6+d),brightness:o.next()**3}),h.sort((v,m)=>v.t-m.t)}return h}static aliveAt(t,e){return t.filter(i=>e>=i.t&&e<=i.t+i.durationMs).map(i=>({meteor:i,progress:(e-i.t)/i.durationMs}))}}class Ys{object=new Ce;radius;core;glow;flashKey;static CORE_WIDTH_DEG=.06;static GLOW_WIDTH_DEG=.5;static SEGMENTS=28;static CORE_RELATIVE=1e3;constructor(t){this.radius=t,this.object.name="lightning-bolt",this.core=new _n({color:15659775,transparent:!0,opacity:0,blending:Ni,depthWrite:!1,fog:!1}),this.glow=new _n({color:10466559,transparent:!0,opacity:0,blending:Ni,depthWrite:!1,fog:!1}),this.object.visible=!1,this.object.renderOrder=5.95}set(t,e,i){if(!t||!t.cloudToGround||e<=.01){this.object.visible=!1;return}const n=`${t.channelSeed}:${Math.round(i)}`;n!==this.flashKey&&this.build(t,i,n),this.core.color.setHex(15659775).multiplyScalar(Ys.CORE_RELATIVE*Math.min(1,e*1.4)),this.glow.color.setHex(10466559).multiplyScalar(.1*Ys.CORE_RELATIVE*e*.35),this.core.opacity=1,this.glow.opacity=1,this.object.visible=!0}build(t,e,i){this.flashKey=i;for(const l of[...this.object.children])l.geometry.dispose(),this.object.remove(l);const n=new jl(t.channelSeed),s=Math.atan2(e,t.distanceM)*180/Math.PI,a=this.channel(n,t.azimuthDeg,s,0,1),o=[a],c=1+Math.floor(n.next()*2);for(let l=0;l<c;l++){const h=a[Math.floor(n.between(.15,.5)*a.length)];o.push(this.channel(n,h.azimuthDeg,h.altitudeDeg,h.altitudeDeg*n.between(.3,.7),.5))}for(const l of o)this.object.add(new Dt(this.ribbon(l,Ys.GLOW_WIDTH_DEG),this.glow)),this.object.add(new Dt(this.ribbon(l,Ys.CORE_WIDTH_DEG),this.core))}channel(t,e,i,n,s){const a=[],o=i-n;let c=e;for(let l=0;l<=Ys.SEGMENTS;l++){const h=i-o*l/Ys.SEGMENTS;a.push({azimuthDeg:c,altitudeDeg:h}),c+=t.between(-1,1)*o*.06*s}return a}ribbon(t,e){const i=new Float32Array(t.length*2*3),n=[],s=this.radius*Math.tan(e*Math.PI/180)/2,a=t.map(c=>{const{x:l,y:h,z:u}=hi(c.altitudeDeg,c.azimuthDeg,this.radius);return new R(l,h,u)});a.forEach((c,l)=>{const h=a[Math.min(l+1,a.length-1)],u=a[Math.max(l-1,0)],f=h.clone().sub(u).normalize().cross(c.clone().normalize()).normalize().multiplyScalar(s);if(i.set([c.x+f.x,c.y+f.y,c.z+f.z],l*6),i.set([c.x-f.x,c.y-f.y,c.z-f.z],l*6+3),l<a.length-1){const p=l*2;n.push(p,p+1,p+2,p+1,p+3,p+2)}});const o=new ce;return o.setAttribute("position",new ee(i,3)),o.setIndex(n),o}dispose(){for(const t of this.object.children)t.geometry.dispose();this.core.dispose(),this.glow.dispose(),this.object.removeFromParent()}}class pi{static MIN_INTERVAL_S=8;static MAX_INTERVAL_S=25;static SEVERE_MIN_INTERVAL_S=2;static SEVERE_MAX_INTERVAL_S=8;static CLOUD_TO_GROUND_FRACTION=.25;static MIN_DISTANCE_M=1e3;static MAX_DISTANCE_M=15e3;static INTERSTROKE_MS=60;static STROKE_DECAY_MS=40;static SOUND_SPEED_M_S=343;static schedule(t){const e=new jl(t.seed),i=[],{minS:n,maxS:s}=pi.intervalFor(t.intensity??.5);let a=e.between(0,s)*1e3;for(;a<t.durationMs;){const o=e.next()<pi.CLOUD_TO_GROUND_FRACTION,c=pi.MIN_DISTANCE_M,l=pi.MAX_DISTANCE_M,h=Math.sqrt(e.between(c*c,l*l)),u=o?1+Math.floor(e.next()*4):1,d=[];let f=0;for(let p=0;p<u;p++)d.push({offsetMs:f,intensity:p===0?1:e.between(.4,.9)}),f+=pi.INTERSTROKE_MS*e.between(.5,1.6);i.push({t:a,azimuthDeg:e.between(0,360),distanceM:h,cloudToGround:o,strokes:d,channelSeed:Math.floor(e.next()*2**31)}),a+=e.between(n,s)*1e3}return i}static intervalFor(t){const e=Math.min(1,Math.max(0,(t-.5)/.5));return{minS:pi.MIN_INTERVAL_S-e*(pi.MIN_INTERVAL_S-pi.SEVERE_MIN_INTERVAL_S),maxS:pi.MAX_INTERVAL_S-e*(pi.MAX_INTERVAL_S-pi.SEVERE_MAX_INTERVAL_S)}}static brightnessAt(t,e){let i=0;for(const n of t.strokes){const s=e-t.t-n.offsetMs;s<0||s>pi.STROKE_DECAY_MS*6||(i+=n.intensity*Math.exp(-s/pi.STROKE_DECAY_MS))}return Math.min(1,i)}static endOf(t){const e=t.strokes[t.strokes.length-1];return t.t+e.offsetMs+pi.STROKE_DECAY_MS*6}static thunderDelayMs(t){return t.distanceM/pi.SOUND_SPEED_M_S*1e3}}class $i{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=($i.ANCHOR_BLUE-$i.ANCHOR_RED)/(1/($i.BLUE_NM*$i.BLUE_NM)-1/($i.RED_NM*$i.RED_NM));static A=$i.ANCHOR_RED-$i.B/($i.RED_NM*$i.RED_NM);static indexAt(t){return $i.A+$i.B/(t*t)}}class Wo{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(t,e,i,n,s,a){let o=0,c=0,l=0;Math.abs(i)<.9?(o=-e,c=t,l=0):(o=0,c=-i,l=e);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=e*l-i*c,d=i*o-t*l,f=t*c-e*o,p=s/2,v=a/2;for(let m=0;m<6;m++){const g=n+m*Math.PI/3,S=Math.cos(g),y=Math.sin(g);this.normals[m*3]=o*S+u*y,this.normals[m*3+1]=c*S+d*y,this.normals[m*3+2]=l*S+f*y,this.offsets[m]=p}this.normals[18]=t,this.normals[19]=e,this.normals[20]=i,this.offsets[6]=v,this.normals[21]=-t,this.normals[22]=-e,this.normals[23]=-i,this.offsets[7]=v,this.radius=Math.hypot(p,v)}get aimRadius(){return this.radius}trace(t,e,i,n,s,a,o){let c=-e,l=t,h=0,u=Math.hypot(c,l,h);u<1e-6&&(c=1,l=0,h=0,u=1),c/=u,l/=u,h/=u;const d=e*h-i*l,f=i*c-t*h,p=t*l-e*c,v=c*n+d*s-t*this.radius*2,m=l*n+f*s-e*this.radius*2,g=h*n+p*s-i*this.radius*2;let S=-1,y=-1/0,M=1/0;for(let J=0;J<8;J++){const it=this.normals[J*3],rt=this.normals[J*3+1],Vt=this.normals[J*3+2],Jt=it*t+rt*e+Vt*i,qt=this.offsets[J]-(it*v+rt*m+Vt*g);if(Jt>1e-9){const q=qt/Jt;q<M&&(M=q)}else if(Jt<-1e-9){const q=qt/Jt;q>y&&(y=q,S=J)}else if(qt<0)return 0}if(S<0||y>=M)return 0;let b=0;const w=this.normals[S*3],T=this.normals[S*3+1],x=this.normals[S*3+2],A=-(w*t+T*e+x*i),C=Rl.reflectance(A,1,a);o[b].x=t+2*A*w,o[b].y=e+2*A*T,o[b].z=i+2*A*x,o[b].weight=C,b++;const I=1/a,P=Math.sqrt(Math.max(0,1-I*I*(1-A*A)));let V=I*t+(I*A-P)*w,X=I*e+(I*A-P)*T,L=I*i+(I*A-P)*x,B=v+t*y,k=m+e*y,$=g+i*y,tt=1-C;for(let J=0;J<Wo.MAX_BOUNCES&&tt>Wo.MIN_WEIGHT;J++){let it=-1,rt=1/0;for(let z=0;z<8;z++){const Tt=this.normals[z*3],Nt=this.normals[z*3+1],Ct=this.normals[z*3+2],_t=Tt*V+Nt*X+Ct*L;if(_t<=1e-9)continue;const kt=(this.offsets[z]-(Tt*B+Nt*k+Ct*$))/_t;kt>1e-9&&kt<rt&&(rt=kt,it=z)}if(it<0)break;const Vt=this.normals[it*3],Jt=this.normals[it*3+1],qt=this.normals[it*3+2],q=Vt*V+Jt*X+qt*L,at=a*Math.sqrt(Math.max(0,1-q*q));if(B+=V*rt,k+=X*rt,$+=L*rt,at<1){const z=Math.sqrt(Math.max(0,1-at*at)),Tt=Rl.reflectance(q,a,1);if(o[b].x=a*V-(a*q-z)*Vt,o[b].y=a*X-(a*q-z)*Jt,o[b].z=a*L-(a*q-z)*qt,o[b].weight=tt*(1-Tt),b++,b>=o.length)return b;tt*=Tt}const nt=2*q;V-=nt*Vt,X-=nt*Jt,L-=nt*qt}return b}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Ge{static AZIMUTH_BINS=512;static ALTITUDE_BINS=512;static POPULATIONS=[{orientation:"tumbling",widthMicrons:50,lengthMicrons:50,share:.52},{orientation:"plate",widthMicrons:100,lengthMicrons:15,share:.27},{orientation:"column",widthMicrons:40,lengthMicrons:120,share:.19},{orientation:"parry",widthMicrons:40,lengthMicrons:120,share:.02}];static WORST_TILT_DEG=180;static BEST_TILT_DEG=.5;static SOURCE_RADIUS_DEG=.265;static UNDEVIATED_DEG=.6;crystal=new Wo;emergent=Array.from({length:Wo.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(Ge.AZIMUTH_BINS*Ge.ALTITUDE_BINS*3);radiance=new Float32Array(Ge.AZIMUTH_BINS*Ge.ALTITUDE_BINS*3);scratch=new Float32Array(Ge.AZIMUTH_BINS*Ge.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(t,e,i=2654435769){this.seed=i>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=t*Math.PI/180,this.alignment=Math.min(1,Math.max(0,e));const n=Ge.WORST_TILT_DEG*(Ge.BEST_TILT_DEG/Ge.WORST_TILT_DEG)**this.alignment;this.tilt=n*Math.PI/180}trace(t){const e=Ge.AZIMUTH_BINS,i=Ge.ALTITUDE_BINS,n=this.tally,s=Ge.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(Ge.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<t;c++){const l=this.pickPopulation();this.orient(l,this.tilt);const h=this.random()*2*Math.PI,u=s*Math.sqrt(this.random()),d=o+u*Math.sin(h),f=u*Math.cos(h)/Math.max(.05,Math.cos(o)),p=-Math.cos(d)*Math.cos(f),v=-Math.cos(d)*Math.sin(f),m=-Math.sin(d),g=this.crystal.aimRadius,S=(this.random()*2-1)*g,y=(this.random()*2-1)*g,M=4*g*g,b=mi.SAMPLES[this.random()*mi.SAMPLES.length|0],w=this.crystal.trace(p,v,m,S,y,$i.indexAt(b.wavelengthNm),this.emergent);for(let T=0;T<w;T++){const x=this.emergent[T],A=Math.hypot(x.x,x.y,x.z);if(A<1e-9||x.weight<=0)continue;const C=x.x/A,I=x.y/A,P=x.z/A;if(C*p+I*v+P*m>a)continue;const V=Math.asin(Math.max(-1,Math.min(1,-P))),X=Math.abs(Math.atan2(-I,-C)),L=Math.min(e-1,X/Math.PI*e|0),k=(Math.min(i-1,(V+Math.PI/2)/Math.PI*i|0)*e+L)*3,$=x.weight*M*mi.SAMPLES.length;n[k]+=$*b.r,n[k+1]+=$*b.g,n[k+2]+=$*b.b}}this.traced+=t}get tracedRays(){return this.traced}harvest(){const t=Ge.AZIMUTH_BINS,e=Ge.ALTITUDE_BINS;return this.toRadiance(t,e),this.smooth(t,e),{width:t,height:e,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(t,e,i,n){return this.begin(t,e,n),this.trace(i),this.harvest()}toRadiance(t,e){const i=2*Math.PI/t,n=Math.max(1,this.traced),s=4*Ge.REFERENCE_MICRONS*Ge.REFERENCE_MICRONS;for(let a=0;a<e;a++){const o=Math.sin(a/e*Math.PI-Math.PI/2),c=Math.sin((a+1)/e*Math.PI-Math.PI/2),l=1/(i*(c-o)*n*s);for(let h=0;h<t;h++){const u=(a*t+h)*3;this.radiance[u]=this.tally[u]*l,this.radiance[u+1]=this.tally[u+1]*l,this.radiance[u+2]=this.tally[u+2]*l}}}static REFERENCE_MICRONS=50;smooth(t,e){const i=this.scratch,n=this.radiance;i.set(n);for(let a=0;a<e;a++){const o=a*t*3;for(let c=0;c<3;c++){let l=i[o+c];for(let h=0;h<t;h++){const u=o+h*3+c,d=h+1<t?i[u+3]:i[u];n[u]=(l+2*i[u]+d)/4,l=i[u]}}}i.set(n);const s=t*3;for(let a=0;a<e;a++){const o=a>0?-s:0,c=a+1<e?s:0,l=a*s;for(let h=l;h<l+s;h++)n[h]=(i[h+o]+2*i[h]+i[h+c])/4}}pickPopulation(){const t=this.random();let e=0;for(const i of Ge.POPULATIONS)if(e+=i.share,t<=e)return i;return Ge.POPULATIONS[Ge.POPULATIONS.length-1]}orient(t,e){const i=this.random()*2*Math.PI;let n=this.random()*2*Math.PI,s=0,a=0,o=1;switch(t.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),a=c*Math.sin(i);break}case"plate":{o=this.spreadAboutAnAxis(e);const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),a=c*Math.sin(i);break}case"column":case"parry":{o=this.spreadAboutAPlane(e);const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),a=c*Math.sin(i),t.orientation==="parry"&&(n=Math.PI/2+this.gaussian()*e);break}}this.crystal.set(s,a,o,n,t.widthMicrons,t.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let t=this.seed;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}spreadAboutAnAxis(t){const e=1/Math.max(1e-6,t*t),i=Math.max(1e-12,this.random()),n=1+Math.log(i+(1-i)*Math.exp(-2*e))/e;return Math.max(-1,Math.min(1,n))}spreadAboutAPlane(t){for(let e=0;e<8;e++){const i=this.gaussian()*t;if(i>=-1&&i<=1)return i}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const t=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),e=2*Math.PI*this.random();return this.spare=t*Math.sin(e),this.hasSpare=!0,t*Math.cos(e)}}class Ci{static RADIUS=880;static RAYS=9e5;static RAYS_PER_BATCH=2e3;static BUDGET_MS=6;static URGENT_BUDGET_MS=40;static ALTITUDE_STEP_DEG=1;static ALIGNMENT_STEP=.05;static LEAP_ALTITUDE_DEG=5;static LEAP_ALIGNMENT=.25;static GAIN=.55;setCloudOffset(t){this.material.uniforms.uFieldOffset.value.copy(t)}object;material;sky=new Ge;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;urgent=!1;workHandle;onRepaint;constructor(){const t=Ge.AZIMUTH_BINS,e=Ge.ALTITUDE_BINS;this.texels=new Uint16Array(t*e*4),this.texture=new ra(this.texels,t,e,Ei,qe),this.texture.minFilter=oe,this.texture.magFilter=oe,this.texture.wrapS=wi,this.texture.wrapT=wi,this.texture.needsUpdate=!0,this.material=new le({uniforms:{uSource:{value:new R(0,1,0)},uUp:{value:new R(0,1,0)},uStrength:{value:0},uTint:{value:new R(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uFieldOffset:{value:new R},uMap:{value:this.texture},uGain:{value:Ci.GAIN}},vertexShader:`
6974
+ `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new Dt(new Xi(2,2),this.material))}render(t,e,i,n,s,a){const o=t.getRenderTarget(),c=a??{scene:this.scene,overlay:this.overlay};t.setRenderTarget(c.scene),t.render(e,i),s?.(),(n||a)&&(We.clearTransparent(t,c.overlay),n?.()),t.setRenderTarget(o),!a&&(this.material.uniforms.uMode.value=hn.Finished,t.render(this.quadScene,this.quadCamera))}resize(t,e){this.scene.setSize(Math.max(1,t),Math.max(1,e)),this.overlay.setSize(Math.max(1,t),Math.max(1,e))}dispose(){this.scene.dispose(),this.overlay.dispose(),this.material.dispose(),this.quadScene.children[0].geometry.dispose()}}class ve{static MIN_RATIO=1;static STEP=.25;static MIN_SHARE_OF_DISPLAY=.75;static GPU_LATE_MS=12;static GPU_ROOM_MS=6;static INTERVAL_LATE_MS=21;static LOWER_COOLDOWN_MS=750;static RAISE_COOLDOWN_MS=2e3;static PROBE_WATCH_MS=2e3;static PROBE_EVERY_MS=6e3;static PROBE_BACKOFF_MS=3e4;ratio;maxRatio;timer;intervalMs;lastChangeMs=-1/0;nextProbeMs=0;probe;constructor(t,e){this.maxRatio=ve.clamp(t),this.ratio=this.maxRatio,this.timer=e?Ll.create(e):void 0}get pixelRatio(){return this.ratio}static SETTLE_MS=400;static SUSTAINED_MS=100;lastEditMs=-1/0;editStreakStartMs=-1/0;wasChanging=!1;noteChange(t){t-this.lastEditMs>ve.SETTLE_MS&&(this.editStreakStartMs=t),this.lastEditMs=t}changing(t){return t-this.lastEditMs<=ve.SETTLE_MS&&this.lastEditMs-this.editStreakStartMs>=ve.SUSTAINED_MS}ratioFor(t,e){return this.changing(t)?this.wasChanging?(this.update(t,e),this.ratio):(this.wasChanging=!0,this.reset(),this.ratio):(this.wasChanging=!1,this.maxRatio)}get timesGpu(){return this.timer!==void 0}set maximum(t){this.maxRatio=ve.clamp(t),this.ratio>this.maxRatio&&(this.ratio=this.maxRatio),this.ratio<this.minimum&&(this.ratio=Math.min(this.maxRatio,this.minimum))}get minimum(){const t=Math.floor(this.maxRatio*ve.MIN_SHARE_OF_DISPLAY/ve.STEP)*ve.STEP;return Math.max(ve.MIN_RATIO,t)}get maximum(){return this.maxRatio}beginDrawing(){this.timer?.begin()}endDrawing(){this.timer?.end()}reset(){this.intervalMs=void 0,this.probe=void 0,this.timer?.reset()}update(t,e){const i=this.timer?.poll();if(!(this.timer&&i===void 0))return i!==void 0?this.followGpu(t,i):this.followIntervals(t,e)}followGpu(t,e){if(e>ve.GPU_LATE_MS)return this.lower(t,ve.LOWER_COOLDOWN_MS);if(e<ve.GPU_ROOM_MS)return this.raise(t,ve.RAISE_COOLDOWN_MS)}followIntervals(t,e){if(!(e>0)||e>1e3)return;this.intervalMs=this.intervalMs===void 0?e:this.intervalMs*.9+e*.1;const i=this.intervalMs>ve.INTERVAL_LATE_MS;if(this.probe){if(i)return this.ratio=this.probe.ratioBefore,this.probe=void 0,this.lastChangeMs=t,this.nextProbeMs=t+ve.PROBE_BACKOFF_MS,this.ratio;t-this.probe.sinceMs>=ve.PROBE_WATCH_MS&&(this.probe=void 0,this.nextProbeMs=t+ve.PROBE_EVERY_MS);return}if(i){const n=this.lower(t,ve.LOWER_COOLDOWN_MS);return n!==void 0&&(this.nextProbeMs=t+ve.PROBE_EVERY_MS),n}if(this.ratio<this.maxRatio&&t>=this.nextProbeMs&&t-this.lastChangeMs>=ve.RAISE_COOLDOWN_MS){const n=this.ratio,s=this.raise(t,0);return s!==void 0&&(this.probe={sinceMs:t,ratioBefore:n}),s}}lower(t,e){if(!(this.ratio<=this.minimum||t-this.lastChangeMs<e))return this.ratio=Math.max(this.minimum,ve.clamp(this.ratio-ve.STEP)),this.lastChangeMs=t,this.ratio}raise(t,e){if(!(this.ratio>=this.maxRatio||t-this.lastChangeMs<e))return this.ratio=Math.min(this.maxRatio,ve.clamp(this.ratio+ve.STEP)),this.lastChangeMs=t,this.ratio}static clamp(t){return Number.isFinite(t)?Math.max(ve.MIN_RATIO,Math.round(t/ve.STEP)*ve.STEP):ve.MIN_RATIO}}class Ll{constructor(t,e){this.gl=t,this.extension=e}static IN_FLIGHT_MAX=8;static create(t){if(!(t instanceof WebGL2RenderingContext))return;const e=t.getExtension("EXT_disjoint_timer_query_webgl2");return e?new Ll(t,e):void 0}pending=[];active;smoothedMs;begin(){if(!(this.active||this.pending.length>=Ll.IN_FLIGHT_MAX))try{const t=this.gl.createQuery();if(!t)return;this.gl.beginQuery(this.extension.TIME_ELAPSED_EXT,t),this.active=t}catch{this.active=void 0}}end(){if(this.active){try{this.gl.endQuery(this.extension.TIME_ELAPSED_EXT),this.pending.push(this.active)}catch{}this.active=void 0}}poll(){const t=this.gl;try{for(let e=0;e<this.pending.length;e++){const i=this.pending[e];if(!t.getQueryParameter(i,t.QUERY_RESULT_AVAILABLE))continue;if(!t.getParameter(this.extension.GPU_DISJOINT_EXT)){const s=t.getQueryParameter(i,t.QUERY_RESULT)/1e6;this.smoothedMs=this.smoothedMs===void 0?s:this.smoothedMs*.8+s*.2}t.deleteQuery(i),this.pending.splice(e,1),e--}}catch{this.pending.length=0}return this.smoothedMs}reset(){this.smoothedMs=void 0}}class me{static ICE_INDEX_RED=1.3067;static ICE_INDEX_BLUE=1.317;static SIDE_PRISM_ANGLE_DEG=60;static END_PRISM_ANGLE_DEG=90;static get PARHELIA_MAX_SUN_ALTITUDE_DEG(){const t=me.ICE_INDEX_RED,e=Math.sqrt((4-t*t)/3);return Math.asin(Math.min(1,e))*180/Math.PI}static minimumDeviationDeg(t,e){const i=t*Math.PI/180,n=e*Math.sin(i/2);return n>1?Number.NaN:(2*Math.asin(n)-i)*180/Math.PI}static effectiveIndex(t,e){const i=e*Math.PI/180,n=Math.cos(i);return n<=0?Number.POSITIVE_INFINITY:Math.sqrt(t*t-Math.sin(i)**2)/n}static parheliaAzimuthDeg(t,e=me.ICE_INDEX_RED){const i=me.minimumDeviationDeg(me.SIDE_PRISM_ANGLE_DEG,me.effectiveIndex(e,t));return Number.isFinite(i)?i:void 0}static parheliaDistanceDeg(t,e=me.ICE_INDEX_RED){const i=me.parheliaAzimuthDeg(t,e);if(i===void 0)return;const n=t*Math.PI/180,s=Math.sin(n)**2,a=Math.cos(n)**2*Math.cos(i*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,s+a)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const t=me.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(t*t-1)))*180/Math.PI}static circumzenithalAltitudeDeg(t,e=me.ICE_INDEX_RED){if(t<0||t>90-me.PLATE_END_FACE_LIMIT_DEG)return;const i=Math.cos(t*Math.PI/180),n=Math.sqrt(e*e-i*i);if(!(n>=1))return Math.asin(n)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(t){return Math.acos(6371e3/(6371e3+Math.max(0,t)))*180/Math.PI}static halo22(){return me.ringOf("halo22",me.SIDE_PRISM_ANGLE_DEG)}static halo46(){return me.ringOf("halo46",me.END_PRISM_ANGLE_DEG)}static ringOf(t,e){const i=me.minimumDeviationDeg(e,me.ICE_INDEX_RED),n=me.minimumDeviationDeg(e,me.ICE_INDEX_BLUE);return{id:t,angleDeg:(i+n)/2,redAngleDeg:i,blueAngleDeg:n}}static strength(t,e,i=90,n=0){const s=Math.max(0,Math.min(1,t)),a=Math.max(0,1-Math.max(0,Math.min(1,e))),o=i>=0?1:n<=0?0:Math.max(0,1+i/n);return s*a*o}static formsAt(t,e=0){if(t<=-e)return[];const i=[me.halo22(),me.halo46()],n=t>0?me.parheliaDistanceDeg(t):void 0;n!==void 0&&i.push({id:"parhelia",angleDeg:n,redAngleDeg:n,blueAngleDeg:me.parheliaDistanceDeg(t,me.ICE_INDEX_BLUE)}),i.push({id:"tangentArc",angleDeg:me.halo22().angleDeg}),t>0&&i.push({id:"parhelicCircle",angleDeg:t});const s=me.circumzenithalAltitudeDeg(t);return s!==void 0&&i.push({id:"circumzenithal",angleDeg:s}),t>me.PLATE_END_FACE_LIMIT_DEG&&i.push({id:"circumhorizontal"}),t<me.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&i.push({id:"pillar"}),i}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class an{static get WATER_INDEX_RED(){return _i.indexAt(_i.RED_NM)}static get WATER_INDEX_BLUE(){return _i.indexAt(_i.BLUE_NM)}static radiusDeg(t,e){const i=(e*e-1)/(t*t-1);if(i<0||i>1)return Number.NaN;const n=Math.acos(Math.sqrt(i)),s=Math.asin(Math.sin(n)/e),a=2*(n-s)+(t-1)*(Math.PI-2*s),o=2*Math.PI;let c=a%o;return c<0&&(c+=o),c>Math.PI&&(c=o-c),180-c*180/Math.PI}static primary(){return an.bowOf("primary",2,0)}static secondary(){return an.bowOf("secondary",3,0)}static bowOf(t,e,i){const n=an.radiusDeg(e,an.WATER_INDEX_RED),s=an.radiusDeg(e,an.WATER_INDEX_BLUE),a=(n+s)/2;return{id:t,radiusDeg:a,redRadiusDeg:n,violetRadiusDeg:s,topAltitudeDeg:a-i}}static alexandersBandDeg(){return{fromDeg:an.primary().redRadiusDeg,toDeg:an.secondary().redRadiusDeg}}static formsAt(t){return t<0?[]:[an.bowOf("primary",2,t),an.bowOf("secondary",3,t)].filter(e=>e.topAltitudeDeg>0)}static FULL_MOON_MAGNITUDE=-12.7;static moonlightShare(t){return Math.min(1,10**(-.4*(t-an.FULL_MOON_MAGNITUDE)))}static strength(t,e,i){if(i<=0)return 0;const n=Math.max(0,Math.min(1,t)),s=Math.max(0,1-Math.max(0,Math.min(1,e)));return n*s}}class rn{constructor(t){this.radius=t;const e=rn.SEGMENTS*rn.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const i=new ce;i.setAttribute("position",new ie(this.positions,3)),i.setAttribute("color",new ie(this.colors,3)),i.setDrawRange(0,0),this.object=new Dt(i,new _n({vertexColors:!0,transparent:!0,blending:Ni,depthWrite:!1,fog:!1,side:ji})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=rn.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(rn.ACROSS-1)*6;static HEAD_HALF_WIDTH_DEG=.15;static SPREAD_FRACTION=.05;static FADE_POWER=1.8;object;positions;colors;head;tip;brightness=0;set(t,e,i){this.head=t&&hi(t.altitudeDeg,t.azimuthDeg,1),this.tip=e&&hi(e.altitudeDeg,e.azimuthDeg,1),this.brightness=i,this.rebuild()}rebuild(){const t=this.object.geometry,e=this.head,i=this.tip;if(!e||!i||this.brightness<=0){t.setDrawRange(0,0);return}const n=this.angleBetween(e,i);if(n<=0){t.setDrawRange(0,0);return}const s=n*rn.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(e,i,h),this.radius),o=h=>this.radius*(rn.HEAD_HALF_WIDTH_DEG*Math.PI/180+s*h),c=h=>this.brightness*(1-h)**rn.FADE_POWER;let l=0;for(let h=1;h<rn.POINTS;h++){const u=(h-1)/rn.SEGMENTS,d=h/rn.SEGMENTS;l=this.pushBand(l,a(u),a(d),o(u),o(d),c(u),c(d))}t.setDrawRange(0,l),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}pushBand(t,e,i,n,s,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(i,e))));for(let l=0;l<rn.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,n,h),f=this.across(i,c,s,h),p=this.across(e,c,n,u),v=this.across(i,c,s,u),m=(g,S)=>g===0?S:0;t=this.push(t,d,m(h,a)),t=this.push(t,f,m(h,o)),t=this.push(t,p,m(u,a)),t=this.push(t,f,m(h,o)),t=this.push(t,v,m(u,o)),t=this.push(t,p,m(u,a))}return t}across(t,e,i,n){return{x:t.x+e.x*i*n,y:t.y+e.y*i*n,z:t.z+e.z*i*n}}push(t,e,i){const n=t*3;this.positions[n]=e.x,this.positions[n+1]=e.y,this.positions[n+2]=e.z;const s=At.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[n]=s*.55,this.colors[n+1]=s*.75,this.colors[n+2]=s,t+1}slerp(t,e,i){const n=this.angleBetweenRadians(t,e);if(n<1e-9)return t;const s=Math.sin(n),a=Math.sin((1-i)*n)/s,o=Math.sin(i*n)/s;return{x:t.x*a+e.x*o,y:t.y*a+e.y*o,z:t.z*a+e.z*o}}angleBetween(t,e){return this.angleBetweenRadians(t,e)*180/Math.PI}angleBetweenRadians(t,e){const i=t.x*e.x+t.y*e.y+t.z*e.z;return Math.acos(Math.min(1,Math.max(-1,i)))}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class n5{object=new Ce;radius;tiers;drawn=[];constructor(t){this.radius=t,this.object.name="satellites",this.tiers=Ao.map(e=>{const i=new xs(new ce,ae.material(e.size));return ae.track(i),i.frustumCulled=!1,this.object.add(i),i})}set(t,e,i,n){const s=this.tiers.map(()=>[]);this.drawn=[];for(const a of t){if(a.magnitude>e)continue;const o=i(a.position);if(o<=0)continue;const c=a.magnitude-2.5*Math.log10(o);if(c>e)continue;const l=vo(c,e),h=h1(l),{x:u,y:d,z:f}=hi(a.position.altitudeDeg,a.position.azimuthDeg,this.radius),[p,v,m]=n(a.position,c);s[h].push({x:u,y:d,z:f,r:p,g:v,b:m,seed:a.norad*.6180339887%1}),this.drawn.push({satellite:a,direction:new R(u,d,f).normalize()})}this.tiers.forEach((a,o)=>{const c=s[o],l=new Float32Array(c.length*3),h=new Float32Array(c.length*3),u=new Float32Array(c.length);c.forEach((f,p)=>{l.set([f.x,f.y,f.z],p*3),h.set([f.r,f.g,f.b],p*3),u[p]=f.seed}),a.geometry.dispose();const d=new ce;d.setAttribute("position",new ie(l,3)),d.setAttribute("color",new ie(h,3)),d.setAttribute("seed",new ie(u,1)),a.geometry=d})}get count(){return this.drawn.length}nearest(t,e){let i,n=e;for(const s of this.drawn){const a=s.direction.dot(t);a>n&&(n=a,i=s.satellite)}return i}dispose(){for(const t of this.tiers)t.geometry.dispose(),t.material.dispose();this.object.removeFromParent(),this.drawn=[]}}class jl{constructor(t){this.state=t}next(){this.state=this.state+1831565813|0;let t=this.state;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}between(t,e){return t+this.next()*(e-t)}}class Ca{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(t){const{ratePerHour:e,durationMs:i,velocityKmS:n,seed:s}=t;if(e<=0||i<=0)return[];const a=e*i/36e5,o=new jl(s),c=Math.floor(a),l=c+(o.next()<a-c?1:0),h=[];for(let u=0;u<l;u++){const d=Math.min(1,Math.max(0,(n-20)/52)),f=Ca.MAX_DURATION_MS-d*(Ca.MAX_DURATION_MS-Ca.MIN_DURATION_MS),p=o.between(5,70);h.push({t:o.between(0,i),durationMs:f*o.between(.7,1.3),fromRadiantDeg:p,bearingDeg:o.between(0,360),lengthDeg:Math.sin(p*Math.PI/180)*o.between(8,40)*(.6+d),brightness:o.next()**3}),h.sort((v,m)=>v.t-m.t)}return h}static aliveAt(t,e){return t.filter(i=>e>=i.t&&e<=i.t+i.durationMs).map(i=>({meteor:i,progress:(e-i.t)/i.durationMs}))}}class Ys{object=new Ce;radius;core;glow;flashKey;static CORE_WIDTH_DEG=.06;static GLOW_WIDTH_DEG=.5;static SEGMENTS=28;static CORE_RELATIVE=1e3;constructor(t){this.radius=t,this.object.name="lightning-bolt",this.core=new _n({color:15659775,transparent:!0,opacity:0,blending:Ni,depthWrite:!1,fog:!1}),this.glow=new _n({color:10466559,transparent:!0,opacity:0,blending:Ni,depthWrite:!1,fog:!1}),this.object.visible=!1,this.object.renderOrder=5.95}set(t,e,i){if(!t||!t.cloudToGround||e<=.01){this.object.visible=!1;return}const n=`${t.channelSeed}:${Math.round(i)}`;n!==this.flashKey&&this.build(t,i,n),this.core.color.setHex(15659775).multiplyScalar(Ys.CORE_RELATIVE*Math.min(1,e*1.4)),this.glow.color.setHex(10466559).multiplyScalar(.1*Ys.CORE_RELATIVE*e*.35),this.core.opacity=1,this.glow.opacity=1,this.object.visible=!0}build(t,e,i){this.flashKey=i;for(const l of[...this.object.children])l.geometry.dispose(),this.object.remove(l);const n=new jl(t.channelSeed),s=Math.atan2(e,t.distanceM)*180/Math.PI,a=this.channel(n,t.azimuthDeg,s,0,1),o=[a],c=1+Math.floor(n.next()*2);for(let l=0;l<c;l++){const h=a[Math.floor(n.between(.15,.5)*a.length)];o.push(this.channel(n,h.azimuthDeg,h.altitudeDeg,h.altitudeDeg*n.between(.3,.7),.5))}for(const l of o)this.object.add(new Dt(this.ribbon(l,Ys.GLOW_WIDTH_DEG),this.glow)),this.object.add(new Dt(this.ribbon(l,Ys.CORE_WIDTH_DEG),this.core))}channel(t,e,i,n,s){const a=[],o=i-n;let c=e;for(let l=0;l<=Ys.SEGMENTS;l++){const h=i-o*l/Ys.SEGMENTS;a.push({azimuthDeg:c,altitudeDeg:h}),c+=t.between(-1,1)*o*.06*s}return a}ribbon(t,e){const i=new Float32Array(t.length*2*3),n=[],s=this.radius*Math.tan(e*Math.PI/180)/2,a=t.map(c=>{const{x:l,y:h,z:u}=hi(c.altitudeDeg,c.azimuthDeg,this.radius);return new R(l,h,u)});a.forEach((c,l)=>{const h=a[Math.min(l+1,a.length-1)],u=a[Math.max(l-1,0)],f=h.clone().sub(u).normalize().cross(c.clone().normalize()).normalize().multiplyScalar(s);if(i.set([c.x+f.x,c.y+f.y,c.z+f.z],l*6),i.set([c.x-f.x,c.y-f.y,c.z-f.z],l*6+3),l<a.length-1){const p=l*2;n.push(p,p+1,p+2,p+1,p+3,p+2)}});const o=new ce;return o.setAttribute("position",new ie(i,3)),o.setIndex(n),o}dispose(){for(const t of this.object.children)t.geometry.dispose();this.core.dispose(),this.glow.dispose(),this.object.removeFromParent()}}class pi{static MIN_INTERVAL_S=8;static MAX_INTERVAL_S=25;static SEVERE_MIN_INTERVAL_S=2;static SEVERE_MAX_INTERVAL_S=8;static CLOUD_TO_GROUND_FRACTION=.25;static MIN_DISTANCE_M=1e3;static MAX_DISTANCE_M=15e3;static INTERSTROKE_MS=60;static STROKE_DECAY_MS=40;static SOUND_SPEED_M_S=343;static schedule(t){const e=new jl(t.seed),i=[],{minS:n,maxS:s}=pi.intervalFor(t.intensity??.5);let a=e.between(0,s)*1e3;for(;a<t.durationMs;){const o=e.next()<pi.CLOUD_TO_GROUND_FRACTION,c=pi.MIN_DISTANCE_M,l=pi.MAX_DISTANCE_M,h=Math.sqrt(e.between(c*c,l*l)),u=o?1+Math.floor(e.next()*4):1,d=[];let f=0;for(let p=0;p<u;p++)d.push({offsetMs:f,intensity:p===0?1:e.between(.4,.9)}),f+=pi.INTERSTROKE_MS*e.between(.5,1.6);i.push({t:a,azimuthDeg:e.between(0,360),distanceM:h,cloudToGround:o,strokes:d,channelSeed:Math.floor(e.next()*2**31)}),a+=e.between(n,s)*1e3}return i}static intervalFor(t){const e=Math.min(1,Math.max(0,(t-.5)/.5));return{minS:pi.MIN_INTERVAL_S-e*(pi.MIN_INTERVAL_S-pi.SEVERE_MIN_INTERVAL_S),maxS:pi.MAX_INTERVAL_S-e*(pi.MAX_INTERVAL_S-pi.SEVERE_MAX_INTERVAL_S)}}static brightnessAt(t,e){let i=0;for(const n of t.strokes){const s=e-t.t-n.offsetMs;s<0||s>pi.STROKE_DECAY_MS*6||(i+=n.intensity*Math.exp(-s/pi.STROKE_DECAY_MS))}return Math.min(1,i)}static endOf(t){const e=t.strokes[t.strokes.length-1];return t.t+e.offsetMs+pi.STROKE_DECAY_MS*6}static thunderDelayMs(t){return t.distanceM/pi.SOUND_SPEED_M_S*1e3}}class $i{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=($i.ANCHOR_BLUE-$i.ANCHOR_RED)/(1/($i.BLUE_NM*$i.BLUE_NM)-1/($i.RED_NM*$i.RED_NM));static A=$i.ANCHOR_RED-$i.B/($i.RED_NM*$i.RED_NM);static indexAt(t){return $i.A+$i.B/(t*t)}}class Wo{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(t,e,i,n,s,a){let o=0,c=0,l=0;Math.abs(i)<.9?(o=-e,c=t,l=0):(o=0,c=-i,l=e);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=e*l-i*c,d=i*o-t*l,f=t*c-e*o,p=s/2,v=a/2;for(let m=0;m<6;m++){const g=n+m*Math.PI/3,S=Math.cos(g),y=Math.sin(g);this.normals[m*3]=o*S+u*y,this.normals[m*3+1]=c*S+d*y,this.normals[m*3+2]=l*S+f*y,this.offsets[m]=p}this.normals[18]=t,this.normals[19]=e,this.normals[20]=i,this.offsets[6]=v,this.normals[21]=-t,this.normals[22]=-e,this.normals[23]=-i,this.offsets[7]=v,this.radius=Math.hypot(p,v)}get aimRadius(){return this.radius}trace(t,e,i,n,s,a,o){let c=-e,l=t,h=0,u=Math.hypot(c,l,h);u<1e-6&&(c=1,l=0,h=0,u=1),c/=u,l/=u,h/=u;const d=e*h-i*l,f=i*c-t*h,p=t*l-e*c,v=c*n+d*s-t*this.radius*2,m=l*n+f*s-e*this.radius*2,g=h*n+p*s-i*this.radius*2;let S=-1,y=-1/0,M=1/0;for(let J=0;J<8;J++){const it=this.normals[J*3],rt=this.normals[J*3+1],Vt=this.normals[J*3+2],jt=it*t+rt*e+Vt*i,qt=this.offsets[J]-(it*v+rt*m+Vt*g);if(jt>1e-9){const q=qt/jt;q<M&&(M=q)}else if(jt<-1e-9){const q=qt/jt;q>y&&(y=q,S=J)}else if(qt<0)return 0}if(S<0||y>=M)return 0;let b=0;const w=this.normals[S*3],T=this.normals[S*3+1],x=this.normals[S*3+2],A=-(w*t+T*e+x*i),C=Rl.reflectance(A,1,a);o[b].x=t+2*A*w,o[b].y=e+2*A*T,o[b].z=i+2*A*x,o[b].weight=C,b++;const I=1/a,P=Math.sqrt(Math.max(0,1-I*I*(1-A*A)));let V=I*t+(I*A-P)*w,X=I*e+(I*A-P)*T,L=I*i+(I*A-P)*x,B=v+t*y,k=m+e*y,$=g+i*y,tt=1-C;for(let J=0;J<Wo.MAX_BOUNCES&&tt>Wo.MIN_WEIGHT;J++){let it=-1,rt=1/0;for(let z=0;z<8;z++){const Tt=this.normals[z*3],Nt=this.normals[z*3+1],Ct=this.normals[z*3+2],_t=Tt*V+Nt*X+Ct*L;if(_t<=1e-9)continue;const kt=(this.offsets[z]-(Tt*B+Nt*k+Ct*$))/_t;kt>1e-9&&kt<rt&&(rt=kt,it=z)}if(it<0)break;const Vt=this.normals[it*3],jt=this.normals[it*3+1],qt=this.normals[it*3+2],q=Vt*V+jt*X+qt*L,at=a*Math.sqrt(Math.max(0,1-q*q));if(B+=V*rt,k+=X*rt,$+=L*rt,at<1){const z=Math.sqrt(Math.max(0,1-at*at)),Tt=Rl.reflectance(q,a,1);if(o[b].x=a*V-(a*q-z)*Vt,o[b].y=a*X-(a*q-z)*jt,o[b].z=a*L-(a*q-z)*qt,o[b].weight=tt*(1-Tt),b++,b>=o.length)return b;tt*=Tt}const nt=2*q;V-=nt*Vt,X-=nt*jt,L-=nt*qt}return b}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Ge{static AZIMUTH_BINS=512;static ALTITUDE_BINS=512;static POPULATIONS=[{orientation:"tumbling",widthMicrons:50,lengthMicrons:50,share:.52},{orientation:"plate",widthMicrons:100,lengthMicrons:15,share:.27},{orientation:"column",widthMicrons:40,lengthMicrons:120,share:.19},{orientation:"parry",widthMicrons:40,lengthMicrons:120,share:.02}];static WORST_TILT_DEG=180;static BEST_TILT_DEG=.5;static SOURCE_RADIUS_DEG=.265;static UNDEVIATED_DEG=.6;crystal=new Wo;emergent=Array.from({length:Wo.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(Ge.AZIMUTH_BINS*Ge.ALTITUDE_BINS*3);radiance=new Float32Array(Ge.AZIMUTH_BINS*Ge.ALTITUDE_BINS*3);scratch=new Float32Array(Ge.AZIMUTH_BINS*Ge.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(t,e,i=2654435769){this.seed=i>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=t*Math.PI/180,this.alignment=Math.min(1,Math.max(0,e));const n=Ge.WORST_TILT_DEG*(Ge.BEST_TILT_DEG/Ge.WORST_TILT_DEG)**this.alignment;this.tilt=n*Math.PI/180}trace(t){const e=Ge.AZIMUTH_BINS,i=Ge.ALTITUDE_BINS,n=this.tally,s=Ge.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(Ge.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<t;c++){const l=this.pickPopulation();this.orient(l,this.tilt);const h=this.random()*2*Math.PI,u=s*Math.sqrt(this.random()),d=o+u*Math.sin(h),f=u*Math.cos(h)/Math.max(.05,Math.cos(o)),p=-Math.cos(d)*Math.cos(f),v=-Math.cos(d)*Math.sin(f),m=-Math.sin(d),g=this.crystal.aimRadius,S=(this.random()*2-1)*g,y=(this.random()*2-1)*g,M=4*g*g,b=mi.SAMPLES[this.random()*mi.SAMPLES.length|0],w=this.crystal.trace(p,v,m,S,y,$i.indexAt(b.wavelengthNm),this.emergent);for(let T=0;T<w;T++){const x=this.emergent[T],A=Math.hypot(x.x,x.y,x.z);if(A<1e-9||x.weight<=0)continue;const C=x.x/A,I=x.y/A,P=x.z/A;if(C*p+I*v+P*m>a)continue;const V=Math.asin(Math.max(-1,Math.min(1,-P))),X=Math.abs(Math.atan2(-I,-C)),L=Math.min(e-1,X/Math.PI*e|0),k=(Math.min(i-1,(V+Math.PI/2)/Math.PI*i|0)*e+L)*3,$=x.weight*M*mi.SAMPLES.length;n[k]+=$*b.r,n[k+1]+=$*b.g,n[k+2]+=$*b.b}}this.traced+=t}get tracedRays(){return this.traced}harvest(){const t=Ge.AZIMUTH_BINS,e=Ge.ALTITUDE_BINS;return this.toRadiance(t,e),this.smooth(t,e),{width:t,height:e,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(t,e,i,n){return this.begin(t,e,n),this.trace(i),this.harvest()}toRadiance(t,e){const i=2*Math.PI/t,n=Math.max(1,this.traced),s=4*Ge.REFERENCE_MICRONS*Ge.REFERENCE_MICRONS;for(let a=0;a<e;a++){const o=Math.sin(a/e*Math.PI-Math.PI/2),c=Math.sin((a+1)/e*Math.PI-Math.PI/2),l=1/(i*(c-o)*n*s);for(let h=0;h<t;h++){const u=(a*t+h)*3;this.radiance[u]=this.tally[u]*l,this.radiance[u+1]=this.tally[u+1]*l,this.radiance[u+2]=this.tally[u+2]*l}}}static REFERENCE_MICRONS=50;smooth(t,e){const i=this.scratch,n=this.radiance;i.set(n);for(let a=0;a<e;a++){const o=a*t*3;for(let c=0;c<3;c++){let l=i[o+c];for(let h=0;h<t;h++){const u=o+h*3+c,d=h+1<t?i[u+3]:i[u];n[u]=(l+2*i[u]+d)/4,l=i[u]}}}i.set(n);const s=t*3;for(let a=0;a<e;a++){const o=a>0?-s:0,c=a+1<e?s:0,l=a*s;for(let h=l;h<l+s;h++)n[h]=(i[h+o]+2*i[h]+i[h+c])/4}}pickPopulation(){const t=this.random();let e=0;for(const i of Ge.POPULATIONS)if(e+=i.share,t<=e)return i;return Ge.POPULATIONS[Ge.POPULATIONS.length-1]}orient(t,e){const i=this.random()*2*Math.PI;let n=this.random()*2*Math.PI,s=0,a=0,o=1;switch(t.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),a=c*Math.sin(i);break}case"plate":{o=this.spreadAboutAnAxis(e);const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),a=c*Math.sin(i);break}case"column":case"parry":{o=this.spreadAboutAPlane(e);const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),a=c*Math.sin(i),t.orientation==="parry"&&(n=Math.PI/2+this.gaussian()*e);break}}this.crystal.set(s,a,o,n,t.widthMicrons,t.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let t=this.seed;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}spreadAboutAnAxis(t){const e=1/Math.max(1e-6,t*t),i=Math.max(1e-12,this.random()),n=1+Math.log(i+(1-i)*Math.exp(-2*e))/e;return Math.max(-1,Math.min(1,n))}spreadAboutAPlane(t){for(let e=0;e<8;e++){const i=this.gaussian()*t;if(i>=-1&&i<=1)return i}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const t=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),e=2*Math.PI*this.random();return this.spare=t*Math.sin(e),this.hasSpare=!0,t*Math.cos(e)}}class Ci{static RADIUS=880;static RAYS=9e5;static RAYS_PER_BATCH=2e3;static BUDGET_MS=6;static URGENT_BUDGET_MS=40;static ALTITUDE_STEP_DEG=1;static ALIGNMENT_STEP=.05;static LEAP_ALTITUDE_DEG=5;static LEAP_ALIGNMENT=.25;static GAIN=.55;setCloudOffset(t){this.material.uniforms.uFieldOffset.value.copy(t)}object;material;sky=new Ge;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;urgent=!1;workHandle;onRepaint;constructor(){const t=Ge.AZIMUTH_BINS,e=Ge.ALTITUDE_BINS;this.texels=new Uint16Array(t*e*4),this.texture=new ra(this.texels,t,e,Ei,qe),this.texture.minFilter=oe,this.texture.magFilter=oe,this.texture.wrapS=wi,this.texture.wrapT=wi,this.texture.needsUpdate=!0,this.material=new le({uniforms:{uSource:{value:new R(0,1,0)},uUp:{value:new R(0,1,0)},uStrength:{value:0},uTint:{value:new R(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uFieldOffset:{value:new R},uMap:{value:this.texture},uGain:{value:Ci.GAIN}},vertexShader:`
6918
6975
  varying vec3 vDirection;
6919
6976
  void main() {
6920
6977
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -6943,7 +7000,7 @@ void main()
6943
7000
  if (ice <= 0.0) discard;
6944
7001
  gl_FragColor = vec4(iceHaloLight(dir, ice), 1.0);
6945
7002
  }
6946
- `,transparent:!0,blending:Ni,depthWrite:!1,side:Ve,fog:!1}),this.object=new Dt(new oi(Ci.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1;const i=this.material.uniforms;this.deckUniforms={uSource:i.uSource,uUp:i.uUp,uStrength:i.uStrength,uTint:i.uTint,uMap:i.uMap,uGain:i.uGain,uHaloShown:{value:0}}}deckUniforms;shown=!1;hostedByDeck=!1;set hosted(t){this.hostedByDeck=t,this.show(this.shown)}show(t){this.shown=t,this.object.visible=t&&!this.hostedByDeck,this.deckUniforms.uHaloShown.value=t?1:0}get awaitingFirstDisplay(){return this.tracing&&!this.everDisplayed}setUrgent(t){this.urgent=t}set onReady(t){this.onRepaint=t}update(t,e,i,n,s,a){const o=this.material.uniforms;if(i<=0){o.uStrength.value=0,this.show(!1),this.stopWork();return}o.uSource.value.set(t.x,t.y,t.z).normalize(),o.uStrength.value=i,o.uTint.value.set(n[0],n[1],n[2]),o.uIceCover.value=s.cover,o.uIceHeight.value=s.layerHeight,this.show(this.everDisplayed),this.requestMap(e,a)}requestMap(t,e){if(!(!(Math.abs(t-this.mappedAltitudeDeg)<Ci.ALTITUDE_STEP_DEG)||!(Math.abs(e-this.mappedAlignment)<Ci.ALIGNMENT_STEP))){this.next=void 0;return}if(this.tracing){if(this.tracingFor(t,e)){this.next=void 0;return}if(!(!(Math.abs(t-this.pendingAltitudeDeg)<Ci.LEAP_ALTITUDE_DEG)||!(Math.abs(e-this.pendingAlignment)<Ci.LEAP_ALIGNMENT))){this.next={sourceAltitudeDeg:t,alignment:e};return}}this.next=void 0,this.pendingAltitudeDeg=t,this.pendingAlignment=e,this.sky.begin(t,e),this.tracing=!0,this.scheduleWork()}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;next;tracingFor(t,e){return this.tracing&&Math.abs(t-this.pendingAltitudeDeg)<Ci.ALTITUDE_STEP_DEG&&Math.abs(e-this.pendingAlignment)<Ci.ALIGNMENT_STEP}scheduleWork(){if(this.workHandle!==void 0)return;const t=()=>{if(this.workHandle=void 0,!this.tracing)return;const e=performance.now(),i=this.urgent?Ci.URGENT_BUDGET_MS:Ci.BUDGET_MS;do this.sky.trace(Ci.RAYS_PER_BATCH);while(this.sky.tracedRays<Ci.RAYS&&performance.now()-e<i);if(this.sky.tracedRays>=Ci.RAYS){this.publish(),this.tracing=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;const s=this.next;s&&this.requestMap(s.sourceAltitudeDeg,s.alignment);return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1,this.next=void 0}publish(){const e=this.sky.harvest().data;for(let i=0,n=0;n<e.length;i+=4,n+=3)this.texels[i]=Fn.toHalfFloat(e[n]),this.texels[i+1]=Fn.toHalfFloat(e[n+1]),this.texels[i+2]=Fn.toHalfFloat(e[n+2]),this.texels[i+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.show(this.material.uniforms.uStrength.value>0),this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class yi{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=yi.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(yi.ACROSS-1)*6;static RADIUS=840;static MIN_HALF_WIDTH_DEG=.05;static BRIGHT_HALF_WIDTH_DEG=.22;object;positions;colors;meteors=[];radiantAltitudeDeg=0;radiantAzimuthDeg=0;constructor(){const t=yi.MAX_CONCURRENT*yi.SEGMENTS*yi.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const e=new ce;e.setAttribute("position",new ee(this.positions,3)),e.setAttribute("color",new ee(this.colors,3)),e.setDrawRange(0,0),this.object=new Dt(e,new _n({vertexColors:!0,transparent:!0,blending:Ni,depthWrite:!1,fog:!1,side:ji})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(t,e,i){this.meteors=t,this.radiantAltitudeDeg=e,this.radiantAzimuthDeg=i}update(t){const e=this.object.geometry;if(this.meteors.length===0){e.setDrawRange(0,0);return}const i=Ca.aliveAt(this.meteors,t).slice(0,yi.MAX_CONCURRENT);let n=0;for(const{meteor:s,progress:a}of i){const o=this.radiantOf(s);if(!o)continue;const c=hi(o.altitudeDeg,o.azimuthDeg,1),[l,h]=this.basisAround(c),u=s.fromRadiantDeg+a*s.lengthDeg,d=Math.max(s.fromRadiantDeg,u-s.lengthDeg*.6),f=Math.min(1,(1-a)*2.5),p=this.turn(l,h,s.bearingDeg),v=(.15+.85*s.brightness)*f,m=y=>v*y**1.6,g=y=>this.onSphere(c,p,d+(u-d)*y),S=y=>yi.RADIUS*((yi.MIN_HALF_WIDTH_DEG+yi.BRIGHT_HALF_WIDTH_DEG*s.brightness*y)*Math.PI/180);for(let y=1;y<yi.POINTS;y++){const M=(y-1)/yi.SEGMENTS,b=y/yi.SEGMENTS;n=this.pushRibbon(n,g(M),g(b),S(M),S(b),m(M),m(b))}}e.setDrawRange(0,n),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}midpointOf(t){const e=this.radiantOf(t);if(!e)return;const i=hi(e.altitudeDeg,e.azimuthDeg,1),[n,s]=this.basisAround(i),a=this.turn(n,s,t.bearingDeg),o=this.onSphere(i,a,t.fromRadiantDeg+t.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(t){return t.radiant?t.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(t,e,i,n,s,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(i,e))));for(let l=0;l<yi.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,n,h),f=this.across(i,c,s,h),p=this.across(e,c,n,u),v=this.across(i,c,s,u),m=(g,S)=>g===0?S:0;t=this.push(t,d,m(h,a)),t=this.push(t,f,m(h,o)),t=this.push(t,p,m(u,a)),t=this.push(t,f,m(h,o)),t=this.push(t,v,m(u,o)),t=this.push(t,p,m(u,a))}return t}across(t,e,i,n){return{x:t.x+e.x*i*n,y:t.y+e.y*i*n,z:t.z+e.z*i*n}}push(t,e,i){const n=t*3;this.positions[n]=e.x,this.positions[n+1]=e.y,this.positions[n+2]=e.z;const s=At.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[n]=s*.9,this.colors[n+1]=s*.95,this.colors[n+2]=s,t+1}turn(t,e,i){const n=i*Math.PI/180,s=Math.cos(n),a=Math.sin(n);return{x:t.x*s+e.x*a,y:t.y*s+e.y*a,z:t.z*s+e.z*a}}onSphere(t,e,i){const n=i*Math.PI/180,s=Math.cos(n),a=Math.sin(n);return{x:(t.x*s+e.x*a)*yi.RADIUS,y:(t.y*s+e.y*a)*yi.RADIUS,z:(t.z*s+e.z*a)*yi.RADIUS}}basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=this.normalise(this.cross(t,e));return[i,this.normalise(this.cross(t,i))]}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class Oe{constructor(t,e={}){this.size=t,this.span=Math.min(t.lengthM,Math.max(0,e.spanM??t.lengthM)),this.bank=(t.lengthM-this.span)/2,this.deck=Math.min(t.heightM,e.deckThicknessM??Oe.DEFAULT_DECK_THICKNESS_M),this.railHeight=e.railing?.heightM??Oe.DEFAULT_RAILING_HEIGHT_M,this.postSpacing=Math.max(.3,e.railing?.postSpacingM??Oe.DEFAULT_POST_SPACING_M),this.rails=Math.max(0,Math.round(e.railing?.rails??Oe.DEFAULT_RAILS))}static DEFAULT_DECK_THICKNESS_M=1.2;static DEFAULT_RAILING_HEIGHT_M=1.05;static DEFAULT_POST_SPACING_M=1.5;static DEFAULT_RAILS=2;static BANK_SLOPE=1.5;static ABUTMENT_THICKNESS_M=1;static POST_SIDE_M=.08;static RAIL_HEIGHT_M=.08;static RAIL_DEPTH_M=.06;static BANK_STATIONS=12;static NATURAL_SIZE=Object.freeze({widthM:9,lengthM:40,heightM:6.5});span;bank;deck;railHeight;postSpacing;rails;roadAt(t){const e=Math.abs(t)-this.span/2;return e<=0?this.size.heightM:this.bank<=0?0:Math.max(0,this.size.heightM*(1-e/this.bank))}build(){const{widthM:t,heightM:e}=this.size,i=this.span/2,n=[];if(this.span>0){n.push(Oe.box(t,this.deck,this.span,0,e-this.deck/2,0));for(const c of[-1,1]){const l=e-this.deck;l>0&&this.bank>0&&n.push(Oe.box(t+1,l,Oe.ABUTMENT_THICKNESS_M,0,l/2,c*(i-Oe.ABUTMENT_THICKNESS_M/2)))}}const s=[];this.span>0&&s.push(Oe.box(t,.04,this.span,0,e+.02,0));const a=[];for(const c of[-1,1])this.bank<=0||(a.push(this.embankment(c)),s.push(this.bankRoad(c)));const o=[];for(const c of[-1,1])o.push(...this.railing(c*(t/2-Oe.POST_SIDE_M)));return{concrete:Oe.merge(n),road:Oe.merge(s),earth:Oe.merge(a),railing:Oe.merge(o)}}embankment(t){const e=this.size.widthM/2,i=this.stations(t),n=[],s=(l,h,u,d)=>{n.push(l.x,l.y,l.z,h.x,h.y,h.z,u.x,u.y,u.z,l.x,l.y,l.z,u.x,u.y,u.z,d.x,d.y,d.z)},a=l=>{const h=this.roadAt(l),u=e+Oe.BANK_SLOPE*h;return{leftFoot:new R(-u,0,l),leftTop:new R(-e,h,l),rightTop:new R(e,h,l),rightFoot:new R(u,0,l)}};for(let l=1;l<i.length;l++){const h=a(i[l-1]),u=a(i[l]),d=t>0,f=(p,v,m,g)=>d?s(p,v,m,g):s(g,m,v,p);f(h.leftFoot,h.leftTop,u.leftTop,u.leftFoot),f(h.leftTop,h.rightTop,u.rightTop,u.leftTop),f(h.rightTop,h.rightFoot,u.rightFoot,u.rightTop)}const o=a(i[0]);t>0?s(o.leftFoot,o.rightFoot,o.rightTop,o.leftTop):s(o.leftTop,o.rightTop,o.rightFoot,o.leftFoot);const c=new ce;return c.setAttribute("position",new de(n,3)),c.computeVertexNormals(),c}bankRoad(t){const e=this.size.widthM/2,i=this.stations(t),n=[];for(let a=1;a<i.length;a++){const o=i[a-1],c=i[a],l=this.roadAt(o)+.02,h=this.roadAt(c)+.02,u=t>0?[[-e,l,o],[e,l,o],[e,h,c],[-e,h,c]]:[[-e,h,c],[e,h,c],[e,l,o],[-e,l,o]];for(const d of[0,2,1,0,3,2])n.push(...u[d])}const s=new ce;return s.setAttribute("position",new de(n,3)),s.computeVertexNormals(),s}stations(t){const e=[];for(let i=0;i<=Oe.BANK_STATIONS;i++)e.push(t*(this.span/2+this.bank*i/Oe.BANK_STATIONS));return e}railing(t){const e=this.size.lengthM/2,i=Math.max(1,Math.round(this.size.lengthM/this.postSpacing)),n=[];for(let o=0;o<=i;o++)n.push(-e+this.size.lengthM*o/i);const s=[],a=Oe.POST_SIDE_M;for(const o of n)s.push(Oe.box(a,this.railHeight,a,t,this.roadAt(o)+this.railHeight/2,o));for(let o=1;o<=this.rails;o++){const c=this.railHeight*o/this.rails-Oe.RAIL_HEIGHT_M/2;for(let l=1;l<n.length;l++){const h=new R(t,this.roadAt(n[l-1])+c,n[l-1]),u=new R(t,this.roadAt(n[l])+c,n[l]);s.push(Oe.beam(h,u))}}return s}static box(t,e,i,n,s,a){return new Wi(t,e,i).translate(n,s,a)}static beam(t,e){const i=new R().subVectors(e,t),n=new Wi(Oe.RAIL_DEPTH_M,Oe.RAIL_HEIGHT_M,i.length()),s=new Qi().setFromUnitVectors(new R(0,0,1),i.clone().normalize()),a=new R().addVectors(t,e).multiplyScalar(.5);return n.applyMatrix4(new Zt().compose(a,s,new R(1,1,1)))}static merge(t){const e=t.map(c=>c.getIndex()?c.toNonIndexed():c),i=e.reduce((c,l)=>c+l.getAttribute("position").count,0),n=new Float32Array(i*3),s=new Float32Array(i*3);let a=0;for(const c of e){const l=c.getAttribute("position"),h=c.getAttribute("normal");n.set(l.array,a*3),h&&s.set(h.array,a*3),a+=l.count}const o=new ce;o.setAttribute("position",new de(n,3)),o.setAttribute("normal",new de(s,3));for(const c of t)c.dispose();for(const c of e)c.dispose();return o}}const Kh=Math.PI/180;function Ue(r,t,e,i,n=!1){const s=n?new _n({color:new st(...e)}):new kr({color:new st(...e)}),a=new Dt(t,s);return a.position.y=i,a.userData={emissive:n},a.castShadow=!n,a.receiveShadow=!n,r.add(a),a}const Zh=.25,sw=.002,aw=100,rw=1500,ow=.25,cw=1e3,lw=.15;function hw(r){const t=/^#([0-9a-f]{6})$/i.exec(r);if(!t)return[1,1,1];const e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}const uw=[.32,.32,.3],C1=[1,.85,.5],dw=[.25,.25,.25],P1=[1,.97,.85],fw=[.55,.68,.72],Jn=.03,jn=.05,L1={front:0,behind:Math.PI,left:Math.PI/2,right:-Math.PI/2,"front-left":Math.PI/2,"behind-left":Math.PI/2,"front-right":-Math.PI/2,"behind-right":-Math.PI/2};function Bi(r,t){return r?.[t]}function Qn(r,t,e,i,n,s,a,o){if(o===void 0)return;const c=new kr({color:new st(...fw),transparent:!0,opacity:o/100}),l=new Dt(new Wi(t,e,i),c);l.position.set(n,s,a),r.add(l)}const vn=.05,Jh=[.6,.58,.53],nm=[.5,.5,.48];function vr(r,t,e,i,n,s,a,o){const c=new kr({color:new st(...o),side:Ve}),l=new Dt(new Wi(t,e,i),c);l.position.set(n,s,a),r.add(l)}function pw(r,t,e,i,n,s,a,o,c){const l=(i-s)/2,h=(p,v,m,g)=>{p<=0||(t?vr(r,p,v,vn,m,o+g,a,c):vr(r,vn,v,p,a,o+g,m,c))};h(e,l,0,i/2-l/2),h(e,l,0,-(i/2-l/2));const u=[...n].sort((p,v)=>p.center-v.center);let d=-e/2;for(const p of u){const m=p.center-p.main/2-d;h(m,s,d+m/2,0),d=p.center+p.main/2}const f=e/2-d;h(f,s,d+f/2,0)}function O1(r,t,e,i,n,s,a,o,c,l){const h=(i+n)/2,u=n-i,d=(f,p,v,m)=>{f.length===0?p?vr(r,v,u,vn,0,h,m,Jh):vr(r,vn,u,v,m,h,0,Jh):pw(r,p,v,u,f,s,m,h,Jh)};d(a,!0,t*2,-e+vn),d(o,!0,t*2,e-vn),d(c,!1,e*2,-t+vn),d(l,!1,e*2,t-vn),vr(r,t*2,vn,e*2,0,i+vn,0,nm),vr(r,t*2,vn,e*2,0,n-vn,0,nm)}function Wd(r,t,e,i){switch(r){case"front":return{x:0,z:-(e-i)};case"behind":return{x:0,z:e-i};case"left":return{x:-(t-i),z:0};case"right":return{x:t-i,z:0};case"front-left":return{x:-(t-i),z:-ts};case"front-right":return{x:t-i,z:-ts};case"behind-left":return{x:-(t-i),z:ts};case"behind-right":return{x:t-i,z:ts}}}function N1(r,t,e,i,n,s,a){const o=qd();o.scale.setScalar(i),o.rotation.y=L1[t];const{x:c,z:l}=Wd(t,n,s,a);o.position.set(c,e,l),r.add(o)}const Xd=6,Yd=6,qs=3,ro=1.4,oo=qs*.5,F1=1.2,U1=.35,mw=.75,gw=1.6;function sm(r,t,e,i){const n=new Ce,s=Math.max(1,r+1),a=s*qs;Ue(n,new Wi(Xd,a,Yd),[.55,.54,.5],a/2);const o=Xd/2,c=Yd/2;for(let l=0;l<s;l++){const h=l*qs+qs/2;Qn(n,ro,oo,jn,0,h,-c-Jn,Bi(t,"front")),Qn(n,ro,oo,jn,0,h,c+Jn,Bi(t,"behind")),Qn(n,jn,oo,ro,-o-Jn,h,0,Bi(t,"left")),Qn(n,jn,oo,ro,o+Jn,h,0,Bi(t,"right"))}if(e){const l=Math.min(Math.max(i??0,0),s-1);N1(n,e,l*qs,.72,o,c,F1);const h=u=>Bi(t,u)!==void 0?[{main:ro,center:0}]:[];O1(n,o,c,l*qs,(l+1)*qs,oo,h("front"),h("behind"),h("left"),h("right"))}return n}function am(){const r=new Ce,t=[[0,0,.55,.5],[.4,.1,.35,.4],[-.35,-.2,.4,.38],[.1,-.4,.35,.36],[-.15,.4,.3,.34]];for(const[e,i,n,s]of t){const a=new oi(n,10,7);a.scale(1,.85,1),a.translate(e,0,i),Ue(r,a,[.26,.28,.17],s)}return r}function vw(r){const t=new Ce,e=new Oe(ui.sizeOf(r),r.bridge).build();Ue(t,e.concrete,[.6,.6,.58],0);const i=Ue(t,e.road,[.2,.2,.21],0),n=Ue(t,e.earth,[.3,.36,.22],0);for(const s of[i,n])s.material.side=ji;return Ue(t,e.railing,[.5,.52,.55],0),t}function rm(){const r=new Ce;return Ue(r,new cs(.15,.22,2,8),[.32,.22,.14],1),Ue(r,new Ur(1.4,3,8),[.16,.32,.14],3.5),r}const om=.275,Mw=.35,xw=.9,yw=34,_w=8,Sw=1.4;function cm(){const r=new Ce,t=new oi(om,7,3,0,Math.PI*2,0,Math.PI/2);t.scale(1,Mw/om,1);const e=ui.repeatOnGrid(t,yw,xw,_w,Sw),i=Ue(r,e,[.26,.28,.22],0);return i.castShadow=!0,i.userData.cropBasePositions=e.getAttribute("position").array.slice(),i.userData.cropVerticesPerClump=t.getAttribute("position").count,t.dispose(),r}function lm(){const r=new Ce,t=new oi(1,7,3,0,Math.PI*2,0,Math.PI/2);return Ue(r,t,[.38,.36,.32],0),r}function hm(r){const t=new Ce;return Ue(t,new cs(.05,.08,5,8),[.28,.28,.3],2.5),Ue(t,new oi(.25,12,8),r?C1:uw,5.1,!0),t}const bw=[.08,.08,.08],Vs=.8,ur=1,Yn=1.7,jh=.6,da=.4,Vc=1.2,lr=.7,ts=.5,ww=Yn;function um(r,t,e){const i=new Ce;Ue(i,new Wi(1.8,1.4,4.2),[.45,.14,.14],.7),Ue(i,new Wi(Vs*2,jh,ur*2),[.4,.12,.12],Yn);for(const s of[-1.4,1.4])for(const a of[-.95,.95]){const o=Ue(i,new cs(.4,.4,.3,12),bw,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=s}const n=r?P1:dw;for(const s of[-.7,.7])Ue(i,new oi(.15,8,6),n,.7,!0).position.set(s,.7,-2.1);if(Qn(i,Vc,da,jn,0,Yn,-ur-Jn,Bi(t,"front")),Qn(i,Vc,da,jn,0,Yn,ur+Jn,Bi(t,"behind")),Qn(i,jn,da,lr,-Vs-Jn,Yn,-ts,Bi(t,"front-left")),Qn(i,jn,da,lr,-Vs-Jn,Yn,ts,Bi(t,"behind-left")),Qn(i,jn,da,lr,Vs+Jn,Yn,-ts,Bi(t,"front-right")),Qn(i,jn,da,lr,Vs+Jn,Yn,ts,Bi(t,"behind-right")),e){N1(i,e,mw,.5,Vs,ur,U1);const s=(c,l)=>{const h=[];return Bi(t,c)!==void 0&&h.push({main:lr,center:-ts}),Bi(t,l)!==void 0&&h.push({main:lr,center:ts}),h},a=Bi(t,"front")!==void 0?[{main:Vc,center:0}]:[],o=Bi(t,"behind")!==void 0?[{main:Vc,center:0}]:[];O1(i,Vs,ur,Yn-jh/2,Yn+jh/2,da,a,o,s("front-left","behind-left"),s("front-right","behind-right"))}return i}const dm=new Map;function fm(r,t){if(!r)return;const e=[[r.lengthM,t.lengthM],[r.heightM,t.heightM],[r.widthM,t.widthM]];for(const[i,n]of e)if(i!==void 0&&n>1e-6)return i/n}function Qh(r,t){return t>1e-6?r/t:1}const k1=[.95,.9,.82],pm=[.72,.74,.78];function mm(){const r=new Ce;Ue(r,new cs(.25,.3,1.5,10),pm,.75),Ue(r,new oi(.26,10,8),pm,1.74);const t=Ue(r,new Ur(.07,.16,8),k1,1.74);return t.rotation.x=-Math.PI/2,t.position.z=-.22,r}function qd(){const r=new Ce;Ue(r,new cs(.25,.3,1.5,10),[.3,.3,.35],.75),Ue(r,new oi(.22,10,8),[.62,.52,.46],1.72);const t=Ue(r,new Ur(.07,.16,8),k1,1.72);return t.rotation.x=-Math.PI/2,t.position.z=-.2,r}const Ew=17,gm=18.5,tu=[.16,.16,.18];function vm(){const r=new Ce,t=Ue(r,new cs(1.8,1.8,gm*2,10),tu,0);t.rotation.x=Math.PI/2,Ue(r,new Wi(Ew*2,.5,4.5),tu,0);const e=Ue(r,new Wi(.4,5.5,4),tu,3);return e.position.z=-gm+2,r}class ui{static GROWS_FROM_GROUND=new Set(["tree","shrub","crop","mound"]);static groundUnderFootprint(t,e,i,n,s,a=0){const o=ui.sizeOf(t);if(a>o.heightM)return s(e,i);const c=(n??0)*Math.PI/180,l=Math.min(21,Math.max(2,Math.ceil(o.lengthM/.75)+1)),h=Math.min(21,Math.max(2,Math.ceil(o.widthM/.75)+1)),u=ui.GROWS_FROM_GROUND.has(t.kind);let d=u?1/0:-1/0;for(let f=0;f<l;f++){const p=(f/(l-1)-.5)*o.lengthM;for(let v=0;v<h;v++){const m=(v/(h-1)-.5)*o.widthM,g=e+Math.sin(c)*p+Math.cos(c)*m,S=i-Math.cos(c)*p+Math.sin(c)*m;d=u?Math.min(d,s(g,S)):Math.max(d,s(g,S))}}return Number.isFinite(d)?d:s(e,i)}static occupantView(t){const e=t.observerSide;if(!e)throw new Error("occupantView requires object.observerSide to be set");const{x:i,z:n}=t.kind==="vehicle"?Wd(e,Vs,ur,U1):Wd(e,Xd/2,Yd/2,F1),s=t.kind==="vehicle"?ww:(t.occupiedFloor??0)*qs+gw,a=(t.headingDeg??0)-L1[e]/Kh,o=this.scaleFor(t);return{x:i*o.x,z:n*o.z,eyeY:s*o.y,headingDeg:a}}static BODY_NAME="decor-body";static bodyOf(t){return t.getObjectByName(ui.BODY_NAME)??t}static repeatOnGrid(t,e,i,n,s){const a=t.getAttribute("position"),o=t.getAttribute("normal"),c=t.getIndex();if(!c)throw new Error("repeatOnGrid needs an indexed geometry");const l=a.count,h=e*n,u=new Float32Array(l*h*3),d=new Float32Array(l*h*3),f=new Uint32Array(c.count*h),p=-((e-1)*i)/2,v=-((n-1)*s)/2;let m=0;for(let S=0;S<n;S++)for(let y=0;y<e;y++,m++){const M=v+S*s,b=p+y*i;for(let w=0;w<l;w++){const T=(m*l+w)*3;u[T]=a.getX(w)+M,u[T+1]=a.getY(w),u[T+2]=a.getZ(w)+b,d[T]=o.getX(w),d[T+1]=o.getY(w),d[T+2]=o.getZ(w)}for(let w=0;w<c.count;w++)f[m*c.count+w]=c.getX(w)+m*l}const g=new ce;return g.setAttribute("position",new de(u,3)),g.setAttribute("normal",new de(d,3)),g.setIndex(new m0(f,1)),g}static fitCropToGround(t,e){t.updateMatrixWorld(!0);const i=new R;t.traverse(n=>{const s=n,a=s.userData.cropBasePositions,o=s.userData.cropVerticesPerClump;if(!s.isMesh||!a||!o)return;const c=s.geometry.getAttribute("position"),l=new Zt().copy(s.matrixWorld).invert();for(let h=0;h<c.count;h+=o){i.set(a[h*3],0,a[h*3+2]).applyMatrix4(s.matrixWorld),i.y=e(i.x,i.z),i.applyMatrix4(l);for(let u=h;u<h+o;u++)c.setY(u,a[u*3+1]+i.y)}c.needsUpdate=!0,s.geometry.computeBoundingBox(),s.geometry.computeBoundingSphere()})}static paint(t,e){t.traverse(i=>{const n=i,s=n.userData;if(!n.isMesh||s?.emissive)return;const a=n.material;a?.color&&a.color.set(e)})}static build(t,e){const i=t.kind==="building"?sm(t.floors??J0,t.windows,t.observerSide,t.occupiedFloor):t.kind==="tree"?rm():t.kind==="shrub"?am():t.kind==="bridge"?vw(t):t.kind==="crop"?cm():t.kind==="mound"?lm():t.kind==="streetlight"?hm(e):t.kind==="vehicle"?um(e,t.windows,t.observerSide):t.kind==="aircraft"?vm():t.kind==="entity"?mm():qd();t.color&&this.paint(i,t.color);const n=this.scaleFor(t),s=new Ce;return i.name=ui.BODY_NAME,i.scale.copy(n),s.add(i),t.headingDeg!==void 0&&(s.rotation.y=-t.headingDeg*Kh),this.addLights(s,t.lights),s}static scaleFor(t){const e=t.sizeM;if(!e||t.kind==="bridge")return new R(1,1,1);const i=this.naturalSize(t.kind,t.floors);return new R(e.widthM===void 0?1:Qh(e.widthM,i.widthM),e.heightM===void 0?1:Qh(e.heightM,i.heightM),e.lengthM===void 0?1:Qh(e.lengthM,i.lengthM))}static naturalSize(t,e){const i=t==="building"?Math.max(1,(e??J0)+1):0;if(t==="bridge")return Oe.NATURAL_SIZE;const n=`${t}:${i}`,s=dm.get(n);if(s)return s;const a=t==="building"?sm(i-1,void 0,void 0,void 0):t==="tree"?rm():t==="shrub"?am():t==="crop"?cm():t==="mound"?lm():t==="streetlight"?hm(!1):t==="vehicle"?um(!1,void 0,void 0):t==="aircraft"?vm():t==="entity"?mm():qd(),o=new Vi().setFromObject(a),c={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(a),dm.set(n,c),c}static usesModel(t){return t.model!==void 0&&!(t.observerSide!==void 0&&tg(t.kind))}static applyModel(t,e,i,n={}){const s=this.bodyOf(t),a=new Ce;a.name=ui.BODY_NAME,i.rotation.y=-(n.headingOffsetDeg??0)*Kh,i.updateMatrixWorld(!0);const o=new Vi().setFromObject(i),c={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},l=fm(e.sizeM,c)??fm(n.depictedSizeM,c)??1;i.scale.multiplyScalar(l);const h=o.getCenter(new R).multiplyScalar(l);i.position.x-=h.x,i.position.z-=h.z,i.position.y-=e.kind==="aircraft"?h.y:o.min.y*l,i.traverse(u=>{u instanceof Dt&&(u.castShadow=!0,u.receiveShadow=!0)}),a.add(i),s.parent?(s.parent.add(a),s.removeFromParent()):t.add(a),this.dispose(s)}static sizeOf(t){const e=this.naturalSize(t.kind,t.floors);return{widthM:t.sizeM?.widthM??e.widthM,lengthM:t.sizeM?.lengthM??e.lengthM,heightM:t.sizeM?.heightM??e.heightM}}static addLights(t,e){for(const i of e??[]){const n=hw(i.color),s=Ue(t,new oi(Zh,8,6),n,i.offsetM.y,!0);s.position.set(i.offsetM.x,i.offsetM.y,i.offsetM.z),s.userData={emissive:!0,lightId:i.id,lightColor:n},s.visible=!1}}static setLights(t,e,i,n,s=0,a=1,o=sw){if(!e||e.length===0)return;const c=new Map(e.map(d=>[d.id,d])),l=Math.max(1,n*o/Zh),h=Zh*l,u=a/(Math.PI*h*h);for(const d of t.children){if(!(d instanceof Dt))continue;const f=d.userData.lightId;if(!f)continue;const p=c.get(f);if(!p)continue;const v=s>0?eg(p,i,i+s):tv(p,i)?1:0;d.visible=v>0;const m=d.material,g=d.userData.lightColor;if(g){const S=v*aw*(p.intensity??1)*u;m.color.setRGB(g[0]*S,g[1]*S,g[2]*S)}d.scale.setScalar(l)}}static setLit(t,e,i,n=1){const[s,a,o]=e==="streetlight"?[rw,ow,C1]:[cw,lw,P1],c=i?s*n/(Math.PI*a*a):0,l=[o[0]*c,o[1]*c,o[2]*c];t.traverse(h=>{const u=h.userData;!(h instanceof Dt)||!u.emissive||u.lightId||h.material.color.setRGB(...l)})}static dispose(t){t.traverse(e=>{if(!(e instanceof Dt))return;e.geometry.dispose();const i=e.material;for(const n of Array.isArray(i)?i:[i])n.dispose()})}}const eu="https://ufoathome.org/models/index.json";class Aw{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Tw()}async entries(t){const e=await this.load();return t?e.filter(i=>i.kind===t):e}async entry(t){return(await this.load()).find(e=>e.id===t)}load(){return this.loading??=this.fetchFirstAvailable(),this.loading}async fetchFirstAvailable(){for(const t of this.indexUrls){const e=await this.fetchIndex(t);if(e)return e}return[]}async fetchIndex(t){try{const e=await this.fetchImpl(t);if(!e.ok)return;const i=await e.json();return Array.isArray(i?.models)?i.models.map(({file:n,...s})=>({...s,url:new URL(n,t).href})):void 0}catch{return}}}function Tw(){const r=`?v=${encodeURIComponent("0.76.0")}`,t=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return(t&&t!==eu?[t,eu]:[eu]).map(e=>e+r)}const Rw=[{id:"ufoathome",name:"UFO@home",credit:"3D models re-hosted by UFO@home, each under its own author's licence",creditUrl:"https://ufoathome.org/models/",create:()=>new Aw}];async function Mm(r){const{GLTFLoader:t}=await is(async()=>{const{GLTFLoader:i}=await import("./GLTFLoader-BumifFuq.js");return{GLTFLoader:i}},[],import.meta.url),e=new t;return new Promise((i,n)=>{e.load(r,s=>i(Object.assign(s.scene,{animations:s.animations})),void 0,s=>n(new Error(`Could not load 3D model ${r}: ${s instanceof Error?s.message:String(s)}`)))})}const z1=["ellipsoid","sphere","disc","cylinder","cone","box","torus","figure"];class ln{static MIN_ANGLE_RAD=.002;static FILL=(1-Math.exp(-4))/4;static MAX_SHARE=.3;mesh;constructor(t,e){this.mesh=new Dt(new Xi(2,2),new le({uniforms:{uColor:{value:new st(0,0,0)},uRadius:{value:1}},vertexShader:ln.VERTEX,fragmentShader:ln.FRAGMENT,transparent:!0,depthWrite:!1,blending:Ni,toneMapped:!1})),this.mesh.name=t,this.mesh.frustumCulled=!1,this.mesh.renderOrder=e,this.mesh.visible=!1}shine(t,e,i){this.mesh.visible=!0,this.mesh.position.set(t.x,t.y,t.z),this.mesh.material.uniforms.uRadius.value=e,this.mesh.material.uniforms.uColor.value.setRGB(i[0],i[1],i[2])}hide(){this.mesh.visible=!1}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}static spread(t,e,i,n){const s=Math.max(t,n*ln.MIN_ANGLE_RAD),a=ln.FILL*Math.PI*s*s;return{radiusM:s,luminanceCdM2:i*Math.min(ln.MAX_SHARE,e/a)}}static conserving(t){return Math.sqrt(t/(ln.MAX_SHARE*ln.FILL*Math.PI))}static VERTEX=`
7003
+ `,transparent:!0,blending:Ni,depthWrite:!1,side:Ve,fog:!1}),this.object=new Dt(new oi(Ci.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1;const i=this.material.uniforms;this.deckUniforms={uSource:i.uSource,uUp:i.uUp,uStrength:i.uStrength,uTint:i.uTint,uMap:i.uMap,uGain:i.uGain,uHaloShown:{value:0}}}deckUniforms;shown=!1;hostedByDeck=!1;set hosted(t){this.hostedByDeck=t,this.show(this.shown)}show(t){this.shown=t,this.object.visible=t&&!this.hostedByDeck,this.deckUniforms.uHaloShown.value=t?1:0}get awaitingFirstDisplay(){return this.tracing&&!this.everDisplayed}setUrgent(t){this.urgent=t}set onReady(t){this.onRepaint=t}update(t,e,i,n,s,a){const o=this.material.uniforms;if(i<=0){o.uStrength.value=0,this.show(!1),this.stopWork();return}o.uSource.value.set(t.x,t.y,t.z).normalize(),o.uStrength.value=i,o.uTint.value.set(n[0],n[1],n[2]),o.uIceCover.value=s.cover,o.uIceHeight.value=s.layerHeight,this.show(this.everDisplayed),this.requestMap(e,a)}requestMap(t,e){if(!(!(Math.abs(t-this.mappedAltitudeDeg)<Ci.ALTITUDE_STEP_DEG)||!(Math.abs(e-this.mappedAlignment)<Ci.ALIGNMENT_STEP))){this.next=void 0;return}if(this.tracing){if(this.tracingFor(t,e)){this.next=void 0;return}if(!(!(Math.abs(t-this.pendingAltitudeDeg)<Ci.LEAP_ALTITUDE_DEG)||!(Math.abs(e-this.pendingAlignment)<Ci.LEAP_ALIGNMENT))){this.next={sourceAltitudeDeg:t,alignment:e};return}}this.next=void 0,this.pendingAltitudeDeg=t,this.pendingAlignment=e,this.sky.begin(t,e),this.tracing=!0,this.scheduleWork()}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;next;tracingFor(t,e){return this.tracing&&Math.abs(t-this.pendingAltitudeDeg)<Ci.ALTITUDE_STEP_DEG&&Math.abs(e-this.pendingAlignment)<Ci.ALIGNMENT_STEP}scheduleWork(){if(this.workHandle!==void 0)return;const t=()=>{if(this.workHandle=void 0,!this.tracing)return;const e=performance.now(),i=this.urgent?Ci.URGENT_BUDGET_MS:Ci.BUDGET_MS;do this.sky.trace(Ci.RAYS_PER_BATCH);while(this.sky.tracedRays<Ci.RAYS&&performance.now()-e<i);if(this.sky.tracedRays>=Ci.RAYS){this.publish(),this.tracing=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;const s=this.next;s&&this.requestMap(s.sourceAltitudeDeg,s.alignment);return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1,this.next=void 0}publish(){const e=this.sky.harvest().data;for(let i=0,n=0;n<e.length;i+=4,n+=3)this.texels[i]=Fn.toHalfFloat(e[n]),this.texels[i+1]=Fn.toHalfFloat(e[n+1]),this.texels[i+2]=Fn.toHalfFloat(e[n+2]),this.texels[i+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.show(this.material.uniforms.uStrength.value>0),this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class yi{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=yi.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(yi.ACROSS-1)*6;static RADIUS=840;static MIN_HALF_WIDTH_DEG=.05;static BRIGHT_HALF_WIDTH_DEG=.22;object;positions;colors;meteors=[];radiantAltitudeDeg=0;radiantAzimuthDeg=0;constructor(){const t=yi.MAX_CONCURRENT*yi.SEGMENTS*yi.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const e=new ce;e.setAttribute("position",new ie(this.positions,3)),e.setAttribute("color",new ie(this.colors,3)),e.setDrawRange(0,0),this.object=new Dt(e,new _n({vertexColors:!0,transparent:!0,blending:Ni,depthWrite:!1,fog:!1,side:ji})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(t,e,i){this.meteors=t,this.radiantAltitudeDeg=e,this.radiantAzimuthDeg=i}update(t){const e=this.object.geometry;if(this.meteors.length===0){e.setDrawRange(0,0);return}const i=Ca.aliveAt(this.meteors,t).slice(0,yi.MAX_CONCURRENT);let n=0;for(const{meteor:s,progress:a}of i){const o=this.radiantOf(s);if(!o)continue;const c=hi(o.altitudeDeg,o.azimuthDeg,1),[l,h]=this.basisAround(c),u=s.fromRadiantDeg+a*s.lengthDeg,d=Math.max(s.fromRadiantDeg,u-s.lengthDeg*.6),f=Math.min(1,(1-a)*2.5),p=this.turn(l,h,s.bearingDeg),v=(.15+.85*s.brightness)*f,m=y=>v*y**1.6,g=y=>this.onSphere(c,p,d+(u-d)*y),S=y=>yi.RADIUS*((yi.MIN_HALF_WIDTH_DEG+yi.BRIGHT_HALF_WIDTH_DEG*s.brightness*y)*Math.PI/180);for(let y=1;y<yi.POINTS;y++){const M=(y-1)/yi.SEGMENTS,b=y/yi.SEGMENTS;n=this.pushRibbon(n,g(M),g(b),S(M),S(b),m(M),m(b))}}e.setDrawRange(0,n),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}midpointOf(t){const e=this.radiantOf(t);if(!e)return;const i=hi(e.altitudeDeg,e.azimuthDeg,1),[n,s]=this.basisAround(i),a=this.turn(n,s,t.bearingDeg),o=this.onSphere(i,a,t.fromRadiantDeg+t.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(t){return t.radiant?t.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(t,e,i,n,s,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(i,e))));for(let l=0;l<yi.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,n,h),f=this.across(i,c,s,h),p=this.across(e,c,n,u),v=this.across(i,c,s,u),m=(g,S)=>g===0?S:0;t=this.push(t,d,m(h,a)),t=this.push(t,f,m(h,o)),t=this.push(t,p,m(u,a)),t=this.push(t,f,m(h,o)),t=this.push(t,v,m(u,o)),t=this.push(t,p,m(u,a))}return t}across(t,e,i,n){return{x:t.x+e.x*i*n,y:t.y+e.y*i*n,z:t.z+e.z*i*n}}push(t,e,i){const n=t*3;this.positions[n]=e.x,this.positions[n+1]=e.y,this.positions[n+2]=e.z;const s=At.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[n]=s*.9,this.colors[n+1]=s*.95,this.colors[n+2]=s,t+1}turn(t,e,i){const n=i*Math.PI/180,s=Math.cos(n),a=Math.sin(n);return{x:t.x*s+e.x*a,y:t.y*s+e.y*a,z:t.z*s+e.z*a}}onSphere(t,e,i){const n=i*Math.PI/180,s=Math.cos(n),a=Math.sin(n);return{x:(t.x*s+e.x*a)*yi.RADIUS,y:(t.y*s+e.y*a)*yi.RADIUS,z:(t.z*s+e.z*a)*yi.RADIUS}}basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=this.normalise(this.cross(t,e));return[i,this.normalise(this.cross(t,i))]}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class Oe{constructor(t,e={}){this.size=t,this.span=Math.min(t.lengthM,Math.max(0,e.spanM??t.lengthM)),this.bank=(t.lengthM-this.span)/2,this.deck=Math.min(t.heightM,e.deckThicknessM??Oe.DEFAULT_DECK_THICKNESS_M),this.railHeight=e.railing?.heightM??Oe.DEFAULT_RAILING_HEIGHT_M,this.postSpacing=Math.max(.3,e.railing?.postSpacingM??Oe.DEFAULT_POST_SPACING_M),this.rails=Math.max(0,Math.round(e.railing?.rails??Oe.DEFAULT_RAILS))}static DEFAULT_DECK_THICKNESS_M=1.2;static DEFAULT_RAILING_HEIGHT_M=1.05;static DEFAULT_POST_SPACING_M=1.5;static DEFAULT_RAILS=2;static BANK_SLOPE=1.5;static ABUTMENT_THICKNESS_M=1;static POST_SIDE_M=.08;static RAIL_HEIGHT_M=.08;static RAIL_DEPTH_M=.06;static BANK_STATIONS=12;static NATURAL_SIZE=Object.freeze({widthM:9,lengthM:40,heightM:6.5});span;bank;deck;railHeight;postSpacing;rails;roadAt(t){const e=Math.abs(t)-this.span/2;return e<=0?this.size.heightM:this.bank<=0?0:Math.max(0,this.size.heightM*(1-e/this.bank))}build(){const{widthM:t,heightM:e}=this.size,i=this.span/2,n=[];if(this.span>0){n.push(Oe.box(t,this.deck,this.span,0,e-this.deck/2,0));for(const c of[-1,1]){const l=e-this.deck;l>0&&this.bank>0&&n.push(Oe.box(t+1,l,Oe.ABUTMENT_THICKNESS_M,0,l/2,c*(i-Oe.ABUTMENT_THICKNESS_M/2)))}}const s=[];this.span>0&&s.push(Oe.box(t,.04,this.span,0,e+.02,0));const a=[];for(const c of[-1,1])this.bank<=0||(a.push(this.embankment(c)),s.push(this.bankRoad(c)));const o=[];for(const c of[-1,1])o.push(...this.railing(c*(t/2-Oe.POST_SIDE_M)));return{concrete:Oe.merge(n),road:Oe.merge(s),earth:Oe.merge(a),railing:Oe.merge(o)}}embankment(t){const e=this.size.widthM/2,i=this.stations(t),n=[],s=(l,h,u,d)=>{n.push(l.x,l.y,l.z,h.x,h.y,h.z,u.x,u.y,u.z,l.x,l.y,l.z,u.x,u.y,u.z,d.x,d.y,d.z)},a=l=>{const h=this.roadAt(l),u=e+Oe.BANK_SLOPE*h;return{leftFoot:new R(-u,0,l),leftTop:new R(-e,h,l),rightTop:new R(e,h,l),rightFoot:new R(u,0,l)}};for(let l=1;l<i.length;l++){const h=a(i[l-1]),u=a(i[l]),d=t>0,f=(p,v,m,g)=>d?s(p,v,m,g):s(g,m,v,p);f(h.leftFoot,h.leftTop,u.leftTop,u.leftFoot),f(h.leftTop,h.rightTop,u.rightTop,u.leftTop),f(h.rightTop,h.rightFoot,u.rightFoot,u.rightTop)}const o=a(i[0]);t>0?s(o.leftFoot,o.rightFoot,o.rightTop,o.leftTop):s(o.leftTop,o.rightTop,o.rightFoot,o.leftFoot);const c=new ce;return c.setAttribute("position",new de(n,3)),c.computeVertexNormals(),c}bankRoad(t){const e=this.size.widthM/2,i=this.stations(t),n=[];for(let a=1;a<i.length;a++){const o=i[a-1],c=i[a],l=this.roadAt(o)+.02,h=this.roadAt(c)+.02,u=t>0?[[-e,l,o],[e,l,o],[e,h,c],[-e,h,c]]:[[-e,h,c],[e,h,c],[e,l,o],[-e,l,o]];for(const d of[0,2,1,0,3,2])n.push(...u[d])}const s=new ce;return s.setAttribute("position",new de(n,3)),s.computeVertexNormals(),s}stations(t){const e=[];for(let i=0;i<=Oe.BANK_STATIONS;i++)e.push(t*(this.span/2+this.bank*i/Oe.BANK_STATIONS));return e}railing(t){const e=this.size.lengthM/2,i=Math.max(1,Math.round(this.size.lengthM/this.postSpacing)),n=[];for(let o=0;o<=i;o++)n.push(-e+this.size.lengthM*o/i);const s=[],a=Oe.POST_SIDE_M;for(const o of n)s.push(Oe.box(a,this.railHeight,a,t,this.roadAt(o)+this.railHeight/2,o));for(let o=1;o<=this.rails;o++){const c=this.railHeight*o/this.rails-Oe.RAIL_HEIGHT_M/2;for(let l=1;l<n.length;l++){const h=new R(t,this.roadAt(n[l-1])+c,n[l-1]),u=new R(t,this.roadAt(n[l])+c,n[l]);s.push(Oe.beam(h,u))}}return s}static box(t,e,i,n,s,a){return new Wi(t,e,i).translate(n,s,a)}static beam(t,e){const i=new R().subVectors(e,t),n=new Wi(Oe.RAIL_DEPTH_M,Oe.RAIL_HEIGHT_M,i.length()),s=new Qi().setFromUnitVectors(new R(0,0,1),i.clone().normalize()),a=new R().addVectors(t,e).multiplyScalar(.5);return n.applyMatrix4(new Jt().compose(a,s,new R(1,1,1)))}static merge(t){const e=t.map(c=>c.getIndex()?c.toNonIndexed():c),i=e.reduce((c,l)=>c+l.getAttribute("position").count,0),n=new Float32Array(i*3),s=new Float32Array(i*3);let a=0;for(const c of e){const l=c.getAttribute("position"),h=c.getAttribute("normal");n.set(l.array,a*3),h&&s.set(h.array,a*3),a+=l.count}const o=new ce;o.setAttribute("position",new de(n,3)),o.setAttribute("normal",new de(s,3));for(const c of t)c.dispose();for(const c of e)c.dispose();return o}}const Kh=Math.PI/180;function Ue(r,t,e,i,n=!1){const s=n?new _n({color:new st(...e)}):new kr({color:new st(...e)}),a=new Dt(t,s);return a.position.y=i,a.userData={emissive:n},a.castShadow=!n,a.receiveShadow=!n,r.add(a),a}const Zh=.25,s5=.002,a5=100,r5=1500,o5=.25,c5=1e3,l5=.15;function h5(r){const t=/^#([0-9a-f]{6})$/i.exec(r);if(!t)return[1,1,1];const e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}const u5=[.32,.32,.3],C1=[1,.85,.5],d5=[.25,.25,.25],P1=[1,.97,.85],f5=[.55,.68,.72],Jn=.03,jn=.05,L1={front:0,behind:Math.PI,left:Math.PI/2,right:-Math.PI/2,"front-left":Math.PI/2,"behind-left":Math.PI/2,"front-right":-Math.PI/2,"behind-right":-Math.PI/2};function Bi(r,t){return r?.[t]}function Qn(r,t,e,i,n,s,a,o){if(o===void 0)return;const c=new kr({color:new st(...f5),transparent:!0,opacity:o/100}),l=new Dt(new Wi(t,e,i),c);l.position.set(n,s,a),r.add(l)}const vn=.05,Jh=[.6,.58,.53],nm=[.5,.5,.48];function vr(r,t,e,i,n,s,a,o){const c=new kr({color:new st(...o),side:Ve}),l=new Dt(new Wi(t,e,i),c);l.position.set(n,s,a),r.add(l)}function p5(r,t,e,i,n,s,a,o,c){const l=(i-s)/2,h=(p,v,m,g)=>{p<=0||(t?vr(r,p,v,vn,m,o+g,a,c):vr(r,vn,v,p,a,o+g,m,c))};h(e,l,0,i/2-l/2),h(e,l,0,-(i/2-l/2));const u=[...n].sort((p,v)=>p.center-v.center);let d=-e/2;for(const p of u){const m=p.center-p.main/2-d;h(m,s,d+m/2,0),d=p.center+p.main/2}const f=e/2-d;h(f,s,d+f/2,0)}function O1(r,t,e,i,n,s,a,o,c,l){const h=(i+n)/2,u=n-i,d=(f,p,v,m)=>{f.length===0?p?vr(r,v,u,vn,0,h,m,Jh):vr(r,vn,u,v,m,h,0,Jh):p5(r,p,v,u,f,s,m,h,Jh)};d(a,!0,t*2,-e+vn),d(o,!0,t*2,e-vn),d(c,!1,e*2,-t+vn),d(l,!1,e*2,t-vn),vr(r,t*2,vn,e*2,0,i+vn,0,nm),vr(r,t*2,vn,e*2,0,n-vn,0,nm)}function Wd(r,t,e,i){switch(r){case"front":return{x:0,z:-(e-i)};case"behind":return{x:0,z:e-i};case"left":return{x:-(t-i),z:0};case"right":return{x:t-i,z:0};case"front-left":return{x:-(t-i),z:-ts};case"front-right":return{x:t-i,z:-ts};case"behind-left":return{x:-(t-i),z:ts};case"behind-right":return{x:t-i,z:ts}}}function N1(r,t,e,i,n,s,a){const o=qd();o.scale.setScalar(i),o.rotation.y=L1[t];const{x:c,z:l}=Wd(t,n,s,a);o.position.set(c,e,l),r.add(o)}const Xd=6,Yd=6,qs=3,ro=1.4,oo=qs*.5,F1=1.2,U1=.35,m5=.75,g5=1.6;function sm(r,t,e,i){const n=new Ce,s=Math.max(1,r+1),a=s*qs;Ue(n,new Wi(Xd,a,Yd),[.55,.54,.5],a/2);const o=Xd/2,c=Yd/2;for(let l=0;l<s;l++){const h=l*qs+qs/2;Qn(n,ro,oo,jn,0,h,-c-Jn,Bi(t,"front")),Qn(n,ro,oo,jn,0,h,c+Jn,Bi(t,"behind")),Qn(n,jn,oo,ro,-o-Jn,h,0,Bi(t,"left")),Qn(n,jn,oo,ro,o+Jn,h,0,Bi(t,"right"))}if(e){const l=Math.min(Math.max(i??0,0),s-1);N1(n,e,l*qs,.72,o,c,F1);const h=u=>Bi(t,u)!==void 0?[{main:ro,center:0}]:[];O1(n,o,c,l*qs,(l+1)*qs,oo,h("front"),h("behind"),h("left"),h("right"))}return n}function am(){const r=new Ce,t=[[0,0,.55,.5],[.4,.1,.35,.4],[-.35,-.2,.4,.38],[.1,-.4,.35,.36],[-.15,.4,.3,.34]];for(const[e,i,n,s]of t){const a=new oi(n,10,7);a.scale(1,.85,1),a.translate(e,0,i),Ue(r,a,[.26,.28,.17],s)}return r}function v5(r){const t=new Ce,e=new Oe(ui.sizeOf(r),r.bridge).build();Ue(t,e.concrete,[.6,.6,.58],0);const i=Ue(t,e.road,[.2,.2,.21],0),n=Ue(t,e.earth,[.3,.36,.22],0);for(const s of[i,n])s.material.side=ji;return Ue(t,e.railing,[.5,.52,.55],0),t}function rm(){const r=new Ce;return Ue(r,new cs(.15,.22,2,8),[.32,.22,.14],1),Ue(r,new Ur(1.4,3,8),[.16,.32,.14],3.5),r}const om=.275,M5=.35,x5=.9,y5=34,_5=8,S5=1.4;function cm(){const r=new Ce,t=new oi(om,7,3,0,Math.PI*2,0,Math.PI/2);t.scale(1,M5/om,1);const e=ui.repeatOnGrid(t,y5,x5,_5,S5),i=Ue(r,e,[.26,.28,.22],0);return i.castShadow=!0,i.userData.cropBasePositions=e.getAttribute("position").array.slice(),i.userData.cropVerticesPerClump=t.getAttribute("position").count,t.dispose(),r}function lm(){const r=new Ce,t=new oi(1,7,3,0,Math.PI*2,0,Math.PI/2);return Ue(r,t,[.38,.36,.32],0),r}function hm(r){const t=new Ce;return Ue(t,new cs(.05,.08,5,8),[.28,.28,.3],2.5),Ue(t,new oi(.25,12,8),r?C1:u5,5.1,!0),t}const b5=[.08,.08,.08],Vs=.8,ur=1,Yn=1.7,jh=.6,da=.4,Vc=1.2,lr=.7,ts=.5,w5=Yn;function um(r,t,e){const i=new Ce;Ue(i,new Wi(1.8,1.4,4.2),[.45,.14,.14],.7),Ue(i,new Wi(Vs*2,jh,ur*2),[.4,.12,.12],Yn);for(const s of[-1.4,1.4])for(const a of[-.95,.95]){const o=Ue(i,new cs(.4,.4,.3,12),b5,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=s}const n=r?P1:d5;for(const s of[-.7,.7])Ue(i,new oi(.15,8,6),n,.7,!0).position.set(s,.7,-2.1);if(Qn(i,Vc,da,jn,0,Yn,-ur-Jn,Bi(t,"front")),Qn(i,Vc,da,jn,0,Yn,ur+Jn,Bi(t,"behind")),Qn(i,jn,da,lr,-Vs-Jn,Yn,-ts,Bi(t,"front-left")),Qn(i,jn,da,lr,-Vs-Jn,Yn,ts,Bi(t,"behind-left")),Qn(i,jn,da,lr,Vs+Jn,Yn,-ts,Bi(t,"front-right")),Qn(i,jn,da,lr,Vs+Jn,Yn,ts,Bi(t,"behind-right")),e){N1(i,e,m5,.5,Vs,ur,U1);const s=(c,l)=>{const h=[];return Bi(t,c)!==void 0&&h.push({main:lr,center:-ts}),Bi(t,l)!==void 0&&h.push({main:lr,center:ts}),h},a=Bi(t,"front")!==void 0?[{main:Vc,center:0}]:[],o=Bi(t,"behind")!==void 0?[{main:Vc,center:0}]:[];O1(i,Vs,ur,Yn-jh/2,Yn+jh/2,da,a,o,s("front-left","behind-left"),s("front-right","behind-right"))}return i}const dm=new Map;function fm(r,t){if(!r)return;const e=[[r.lengthM,t.lengthM],[r.heightM,t.heightM],[r.widthM,t.widthM]];for(const[i,n]of e)if(i!==void 0&&n>1e-6)return i/n}function Qh(r,t){return t>1e-6?r/t:1}const k1=[.95,.9,.82],pm=[.72,.74,.78];function mm(){const r=new Ce;Ue(r,new cs(.25,.3,1.5,10),pm,.75),Ue(r,new oi(.26,10,8),pm,1.74);const t=Ue(r,new Ur(.07,.16,8),k1,1.74);return t.rotation.x=-Math.PI/2,t.position.z=-.22,r}function qd(){const r=new Ce;Ue(r,new cs(.25,.3,1.5,10),[.3,.3,.35],.75),Ue(r,new oi(.22,10,8),[.62,.52,.46],1.72);const t=Ue(r,new Ur(.07,.16,8),k1,1.72);return t.rotation.x=-Math.PI/2,t.position.z=-.2,r}const E5=17,gm=18.5,tu=[.16,.16,.18];function vm(){const r=new Ce,t=Ue(r,new cs(1.8,1.8,gm*2,10),tu,0);t.rotation.x=Math.PI/2,Ue(r,new Wi(E5*2,.5,4.5),tu,0);const e=Ue(r,new Wi(.4,5.5,4),tu,3);return e.position.z=-gm+2,r}class ui{static GROWS_FROM_GROUND=new Set(["tree","shrub","crop","mound"]);static groundUnderFootprint(t,e,i,n,s,a=0){const o=ui.sizeOf(t);if(a>o.heightM)return s(e,i);const c=(n??0)*Math.PI/180,l=Math.min(21,Math.max(2,Math.ceil(o.lengthM/.75)+1)),h=Math.min(21,Math.max(2,Math.ceil(o.widthM/.75)+1)),u=ui.GROWS_FROM_GROUND.has(t.kind);let d=u?1/0:-1/0;for(let f=0;f<l;f++){const p=(f/(l-1)-.5)*o.lengthM;for(let v=0;v<h;v++){const m=(v/(h-1)-.5)*o.widthM,g=e+Math.sin(c)*p+Math.cos(c)*m,S=i-Math.cos(c)*p+Math.sin(c)*m;d=u?Math.min(d,s(g,S)):Math.max(d,s(g,S))}}return Number.isFinite(d)?d:s(e,i)}static occupantView(t){const e=t.observerSide;if(!e)throw new Error("occupantView requires object.observerSide to be set");const{x:i,z:n}=t.kind==="vehicle"?Wd(e,Vs,ur,U1):Wd(e,Xd/2,Yd/2,F1),s=t.kind==="vehicle"?w5:(t.occupiedFloor??0)*qs+g5,a=(t.headingDeg??0)-L1[e]/Kh,o=this.scaleFor(t);return{x:i*o.x,z:n*o.z,eyeY:s*o.y,headingDeg:a}}static BODY_NAME="decor-body";static bodyOf(t){return t.getObjectByName(ui.BODY_NAME)??t}static repeatOnGrid(t,e,i,n,s){const a=t.getAttribute("position"),o=t.getAttribute("normal"),c=t.getIndex();if(!c)throw new Error("repeatOnGrid needs an indexed geometry");const l=a.count,h=e*n,u=new Float32Array(l*h*3),d=new Float32Array(l*h*3),f=new Uint32Array(c.count*h),p=-((e-1)*i)/2,v=-((n-1)*s)/2;let m=0;for(let S=0;S<n;S++)for(let y=0;y<e;y++,m++){const M=v+S*s,b=p+y*i;for(let w=0;w<l;w++){const T=(m*l+w)*3;u[T]=a.getX(w)+M,u[T+1]=a.getY(w),u[T+2]=a.getZ(w)+b,d[T]=o.getX(w),d[T+1]=o.getY(w),d[T+2]=o.getZ(w)}for(let w=0;w<c.count;w++)f[m*c.count+w]=c.getX(w)+m*l}const g=new ce;return g.setAttribute("position",new de(u,3)),g.setAttribute("normal",new de(d,3)),g.setIndex(new m0(f,1)),g}static fitCropToGround(t,e){t.updateMatrixWorld(!0);const i=new R;t.traverse(n=>{const s=n,a=s.userData.cropBasePositions,o=s.userData.cropVerticesPerClump;if(!s.isMesh||!a||!o)return;const c=s.geometry.getAttribute("position"),l=new Jt().copy(s.matrixWorld).invert();for(let h=0;h<c.count;h+=o){i.set(a[h*3],0,a[h*3+2]).applyMatrix4(s.matrixWorld),i.y=e(i.x,i.z),i.applyMatrix4(l);for(let u=h;u<h+o;u++)c.setY(u,a[u*3+1]+i.y)}c.needsUpdate=!0,s.geometry.computeBoundingBox(),s.geometry.computeBoundingSphere()})}static paint(t,e){t.traverse(i=>{const n=i,s=n.userData;if(!n.isMesh||s?.emissive)return;const a=n.material;a?.color&&a.color.set(e)})}static build(t,e){const i=t.kind==="building"?sm(t.floors??J0,t.windows,t.observerSide,t.occupiedFloor):t.kind==="tree"?rm():t.kind==="shrub"?am():t.kind==="bridge"?v5(t):t.kind==="crop"?cm():t.kind==="mound"?lm():t.kind==="streetlight"?hm(e):t.kind==="vehicle"?um(e,t.windows,t.observerSide):t.kind==="aircraft"?vm():t.kind==="entity"?mm():qd();t.color&&this.paint(i,t.color);const n=this.scaleFor(t),s=new Ce;return i.name=ui.BODY_NAME,i.scale.copy(n),s.add(i),t.headingDeg!==void 0&&(s.rotation.y=-t.headingDeg*Kh),this.addLights(s,t.lights),s}static scaleFor(t){const e=t.sizeM;if(!e||t.kind==="bridge")return new R(1,1,1);const i=this.naturalSize(t.kind,t.floors);return new R(e.widthM===void 0?1:Qh(e.widthM,i.widthM),e.heightM===void 0?1:Qh(e.heightM,i.heightM),e.lengthM===void 0?1:Qh(e.lengthM,i.lengthM))}static naturalSize(t,e){const i=t==="building"?Math.max(1,(e??J0)+1):0;if(t==="bridge")return Oe.NATURAL_SIZE;const n=`${t}:${i}`,s=dm.get(n);if(s)return s;const a=t==="building"?sm(i-1,void 0,void 0,void 0):t==="tree"?rm():t==="shrub"?am():t==="crop"?cm():t==="mound"?lm():t==="streetlight"?hm(!1):t==="vehicle"?um(!1,void 0,void 0):t==="aircraft"?vm():t==="entity"?mm():qd(),o=new Vi().setFromObject(a),c={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(a),dm.set(n,c),c}static usesModel(t){return t.model!==void 0&&!(t.observerSide!==void 0&&tg(t.kind))}static applyModel(t,e,i,n={}){const s=this.bodyOf(t),a=new Ce;a.name=ui.BODY_NAME,i.rotation.y=-(n.headingOffsetDeg??0)*Kh,i.updateMatrixWorld(!0);const o=new Vi().setFromObject(i),c={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},l=fm(e.sizeM,c)??fm(n.depictedSizeM,c)??1;i.scale.multiplyScalar(l);const h=o.getCenter(new R).multiplyScalar(l);i.position.x-=h.x,i.position.z-=h.z,i.position.y-=e.kind==="aircraft"?h.y:o.min.y*l,i.traverse(u=>{u instanceof Dt&&(u.castShadow=!0,u.receiveShadow=!0)}),a.add(i),s.parent?(s.parent.add(a),s.removeFromParent()):t.add(a),this.dispose(s)}static sizeOf(t){const e=this.naturalSize(t.kind,t.floors);return{widthM:t.sizeM?.widthM??e.widthM,lengthM:t.sizeM?.lengthM??e.lengthM,heightM:t.sizeM?.heightM??e.heightM}}static addLights(t,e){for(const i of e??[]){const n=h5(i.color),s=Ue(t,new oi(Zh,8,6),n,i.offsetM.y,!0);s.position.set(i.offsetM.x,i.offsetM.y,i.offsetM.z),s.userData={emissive:!0,lightId:i.id,lightColor:n},s.visible=!1}}static setLights(t,e,i,n,s=0,a=1,o=s5){if(!e||e.length===0)return;const c=new Map(e.map(d=>[d.id,d])),l=Math.max(1,n*o/Zh),h=Zh*l,u=a/(Math.PI*h*h);for(const d of t.children){if(!(d instanceof Dt))continue;const f=d.userData.lightId;if(!f)continue;const p=c.get(f);if(!p)continue;const v=s>0?eg(p,i,i+s):tv(p,i)?1:0;d.visible=v>0;const m=d.material,g=d.userData.lightColor;if(g){const S=v*a5*(p.intensity??1)*u;m.color.setRGB(g[0]*S,g[1]*S,g[2]*S)}d.scale.setScalar(l)}}static setLit(t,e,i,n=1){const[s,a,o]=e==="streetlight"?[r5,o5,C1]:[c5,l5,P1],c=i?s*n/(Math.PI*a*a):0,l=[o[0]*c,o[1]*c,o[2]*c];t.traverse(h=>{const u=h.userData;!(h instanceof Dt)||!u.emissive||u.lightId||h.material.color.setRGB(...l)})}static dispose(t){t.traverse(e=>{if(!(e instanceof Dt))return;e.geometry.dispose();const i=e.material;for(const n of Array.isArray(i)?i:[i])n.dispose()})}}const eu="https://ufoathome.org/models/index.json";class A5{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??T5()}async entries(t){const e=await this.load();return t?e.filter(i=>i.kind===t):e}async entry(t){return(await this.load()).find(e=>e.id===t)}load(){return this.loading??=this.fetchFirstAvailable(),this.loading}async fetchFirstAvailable(){for(const t of this.indexUrls){const e=await this.fetchIndex(t);if(e)return e}return[]}async fetchIndex(t){try{const e=await this.fetchImpl(t);if(!e.ok)return;const i=await e.json();return Array.isArray(i?.models)?i.models.map(({file:n,...s})=>({...s,url:new URL(n,t).href})):void 0}catch{return}}}function T5(){const r=`?v=${encodeURIComponent("0.78.0")}`,t=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return(t&&t!==eu?[t,eu]:[eu]).map(e=>e+r)}const R5=[{id:"ufoathome",name:"UFO@home",credit:"3D models re-hosted by UFO@home, each under its own author's licence",creditUrl:"https://ufoathome.org/models/",create:()=>new A5}];async function Mm(r){const{GLTFLoader:t}=await is(async()=>{const{GLTFLoader:i}=await import("./GLTFLoader-BumifFuq.js");return{GLTFLoader:i}},[],import.meta.url),e=new t;return new Promise((i,n)=>{e.load(r,s=>i(Object.assign(s.scene,{animations:s.animations})),void 0,s=>n(new Error(`Could not load 3D model ${r}: ${s instanceof Error?s.message:String(s)}`)))})}const z1=["ellipsoid","sphere","disc","cylinder","cone","box","torus","figure"];class ln{static MIN_ANGLE_RAD=.002;static FILL=(1-Math.exp(-4))/4;static MAX_SHARE=.3;mesh;constructor(t,e){this.mesh=new Dt(new Xi(2,2),new le({uniforms:{uColor:{value:new st(0,0,0)},uRadius:{value:1}},vertexShader:ln.VERTEX,fragmentShader:ln.FRAGMENT,transparent:!0,depthWrite:!1,blending:Ni,toneMapped:!1})),this.mesh.name=t,this.mesh.frustumCulled=!1,this.mesh.renderOrder=e,this.mesh.visible=!1}shine(t,e,i){this.mesh.visible=!0,this.mesh.position.set(t.x,t.y,t.z),this.mesh.material.uniforms.uRadius.value=e,this.mesh.material.uniforms.uColor.value.setRGB(i[0],i[1],i[2])}hide(){this.mesh.visible=!1}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}static spread(t,e,i,n){const s=Math.max(t,n*ln.MIN_ANGLE_RAD),a=ln.FILL*Math.PI*s*s;return{radiusM:s,luminanceCdM2:i*Math.min(ln.MAX_SHARE,e/a)}}static conserving(t){return Math.sqrt(t/(ln.MAX_SHARE*ln.FILL*Math.PI))}static VERTEX=`
6947
7004
  uniform float uRadius;
6948
7005
  varying vec2 vOffset;
6949
7006
  void main() {
@@ -7022,7 +7079,7 @@ void main()
7022
7079
  vec3 colour = mix(uColor, uTipColor, smoothstep(0.35, 0.95, s));
7023
7080
  gl_FragColor = vec4(colour * body, body);
7024
7081
  }
7025
- `}class es{constructor(t){this.kind=t;const e=new ce;this.positions=new Float32Array(t.count*3),this.sizes=new Float32Array(t.count),this.alphas=new Float32Array(t.count),e.setAttribute("position",new ee(this.positions,3)),e.setAttribute("size",new ee(this.sizes,1)),e.setAttribute("alpha",new ee(this.alphas,1)),this.seeds=Array.from({length:t.count},(s,a)=>[es.hash(a*3+1)*2*Math.PI,.5+es.hash(a*3+2),.6+.8*es.hash(a*3+3)]);const i=new le({uniforms:{uColour:{value:new st(t.colour[0],t.colour[1],t.colour[2])},uLight:{value:new st(1,1,1)},uHalfHeight:{value:500}},vertexShader:es.VERTEX,fragmentShader:es.FRAGMENT,transparent:!0,depthWrite:!1,blending:ta,toneMapped:!1});this.points=new xs(e,i),this.points.frustumCulled=!1,this.points.renderOrder=3,this.points.visible=!1;const n=new xt;this.points.onBeforeRender=s=>{const a=s.getRenderTarget();this.points.material.uniforms.uHalfHeight.value=(a?a.height:s.getDrawingBufferSize(n).y)/2}}static DUST={count:160,lifeS:2.2,startRadiusM:.4,spreadMS:2.5,riseMS:.8,birthSizeM:.5,deathSizeM:2.2,colour:[.52,.44,.33],opacity:.35};static SMOKE={count:60,lifeS:7,startRadiusM:.1,spreadMS:.15,riseMS:.7,birthSizeM:.6,deathSizeM:3.5,colour:[.42,.42,.42],opacity:.18};points;positions;sizes;alphas;seeds;set(t,e,i,n,s,a,o=[1,1,1]){const c=this.kind;if(this.points.visible=a>0,!this.points.visible)return;this.points.material.uniforms.uLight.value.setRGB(o[0],o[1],o[2]);for(let h=0;h<c.count;h++){const[u,d,f]=this.seeds[h],p=((n+h/c.count*c.lifeS)%c.lifeS+c.lifeS)%c.lifeS,v=p/c.lifeS,m=c.startRadiusM+c.spreadMS*d*Math.sqrt(p);this.positions[h*3]=t+Math.cos(u)*m+s.x*p,this.positions[h*3+1]=e+c.riseMS*f*p,this.positions[h*3+2]=i+Math.sin(u)*m+s.z*p,this.sizes[h]=c.birthSizeM+(c.deathSizeM-c.birthSizeM)*v,this.alphas[h]=c.opacity*a*Math.min(1,v*8)*(1-v)}const l=this.points.geometry;l.getAttribute("position").needsUpdate=!0,l.getAttribute("size").needsUpdate=!0,l.getAttribute("alpha").needsUpdate=!0}dispose(){this.points.geometry.dispose(),this.points.material.dispose()}static hash(t){const e=Math.sin(t*12.9898)*43758.5453;return e-Math.floor(e)}static VERTEX=`
7082
+ `}class es{constructor(t){this.kind=t;const e=new ce;this.positions=new Float32Array(t.count*3),this.sizes=new Float32Array(t.count),this.alphas=new Float32Array(t.count),e.setAttribute("position",new ie(this.positions,3)),e.setAttribute("size",new ie(this.sizes,1)),e.setAttribute("alpha",new ie(this.alphas,1)),this.seeds=Array.from({length:t.count},(s,a)=>[es.hash(a*3+1)*2*Math.PI,.5+es.hash(a*3+2),.6+.8*es.hash(a*3+3)]);const i=new le({uniforms:{uColour:{value:new st(t.colour[0],t.colour[1],t.colour[2])},uLight:{value:new st(1,1,1)},uHalfHeight:{value:500}},vertexShader:es.VERTEX,fragmentShader:es.FRAGMENT,transparent:!0,depthWrite:!1,blending:ta,toneMapped:!1});this.points=new xs(e,i),this.points.frustumCulled=!1,this.points.renderOrder=3,this.points.visible=!1;const n=new xt;this.points.onBeforeRender=s=>{const a=s.getRenderTarget();this.points.material.uniforms.uHalfHeight.value=(a?a.height:s.getDrawingBufferSize(n).y)/2}}static DUST={count:160,lifeS:2.2,startRadiusM:.4,spreadMS:2.5,riseMS:.8,birthSizeM:.5,deathSizeM:2.2,colour:[.52,.44,.33],opacity:.35};static SMOKE={count:60,lifeS:7,startRadiusM:.1,spreadMS:.15,riseMS:.7,birthSizeM:.6,deathSizeM:3.5,colour:[.42,.42,.42],opacity:.18};points;positions;sizes;alphas;seeds;set(t,e,i,n,s,a,o=[1,1,1]){const c=this.kind;if(this.points.visible=a>0,!this.points.visible)return;this.points.material.uniforms.uLight.value.setRGB(o[0],o[1],o[2]);for(let h=0;h<c.count;h++){const[u,d,f]=this.seeds[h],p=((n+h/c.count*c.lifeS)%c.lifeS+c.lifeS)%c.lifeS,v=p/c.lifeS,m=c.startRadiusM+c.spreadMS*d*Math.sqrt(p);this.positions[h*3]=t+Math.cos(u)*m+s.x*p,this.positions[h*3+1]=e+c.riseMS*f*p,this.positions[h*3+2]=i+Math.sin(u)*m+s.z*p,this.sizes[h]=c.birthSizeM+(c.deathSizeM-c.birthSizeM)*v,this.alphas[h]=c.opacity*a*Math.min(1,v*8)*(1-v)}const l=this.points.geometry;l.getAttribute("position").needsUpdate=!0,l.getAttribute("size").needsUpdate=!0,l.getAttribute("alpha").needsUpdate=!0}dispose(){this.points.geometry.dispose(),this.points.material.dispose()}static hash(t){const e=Math.sin(t*12.9898)*43758.5453;return e-Math.floor(e)}static VERTEX=`
7026
7083
  attribute float size;
7027
7084
  attribute float alpha;
7028
7085
  uniform float uHalfHeight;
@@ -7083,11 +7140,11 @@ void main()
7083
7140
  vec3 around = textureCube(uSurroundings, reflect(view, normal)).rgb;
7084
7141
  gl_FragColor = vec4(around * wall, wall + (1.0 - wall) * uAbsorption);
7085
7142
  }
7086
- `,transparent:!0,depthWrite:!1,side:ji,fog:!1,blending:zl,blendSrc:Fo,blendDst:Uo})}static wallReflectance(t,e,i){const n=i(t,1,e);return 2*n/(1+n)}setSurroundings(t){this.uniforms.uSurroundings.value=t}static reflectedResponse(t,e){return At.respond(e*At.relativeOfResponse(Math.max(t,1e-5)))}}const Wc=Math.PI/180;class ue{constructor(t,e,i=()=>0){this.loadModel=t,this.onModelArrived=e,this.sceneUnitsPerLux=i,this.group.name="bodies"}group=new Ce;built=new Map;token=0;credits=new Map;flames=new Map;glares=new Map;lightVeils=new Map;lightRay=new ol;boxHit=new R;dust=new Map;smoke=[];scratch=new R;aim=new Qi;down=new R;frame;lastSet;get modelCredits(){return[...this.credits.values()]}set(t,e,i=0,n,s=t.map(a=>a.id)){this.frame=e,this.lastSet=[t,e,i,n,s];const a=new Set;for(const c of t){a.add(c.id);const l=ue.signatureOf(c.model);let h=this.built.get(c.id);(!h||h.signature!==l)&&(h&&this.remove(c.id),h=this.build(c),this.built.set(c.id,h),this.group.add(h.holder));const{holder:u,material:d,glowing:f}=h;u.visible=!0,u.position.set(e.originX+c.eastM,e.originGroundY+c.upM,e.originZ-c.northM),u.rotation.set(c.attitude.pitchDeg*Wc,-c.attitude.headingDeg*Wc,-c.attitude.rollDeg*Wc,"YXZ"),u.scale.set(c.sizeM.widthM,c.sizeM.heightM,c.sizeM.lengthM),d&&ue.paint(d,c,n),f&&ue.light(f,c,n),h.motions&&ue.move(h.motions,c.motions??{}),this.shine(c,u,f,n,e.eye),this.shineLights(c,u,f,e),this.throwFlame(c,u,i,n,e.eye)}const o=new Set(s);for(const[c,{holder:l}]of[...this.built])a.has(c)||(o.has(c)?(l.visible=!1,this.flames.get(c)?.putOut(),this.glares.get(c)?.hide(),this.hideLights(c)):this.remove(c))}shine(t,e,i,n,s){const a=t.appearance.luminanceCdM2;let o=this.glares.get(t.id);if(!(a>0)||!s||i&&i.length>0){o?.hide();return}o||(o=new Pi(`body-veil:${t.id}`),this.glares.set(t.id,o),this.group.add(o.mesh));const c=Math.max(t.sizeM.widthM,t.sizeM.heightM)/2,l=Math.max(e.position.distanceTo(s),c*1.01),h=Math.asin(c/l),u=2*Math.PI*(1-Math.cos(h)),d=i?.find(p=>p.share>=1)?.hue??ue.rgbOf(t.appearance.color),f=this.throughAir(ue.shown(d,a,n),e.position);o.shine(e.position,[f[0]*u,f[1]*u,f[2]*u],h*180/Math.PI)}static glaze(t){t.traverse(e=>{if(!(e instanceof Dt))return;const i=e.material;!(i instanceof BM)||!(i.transmission>0)||(e.material=new Xo(i.ior),i.dispose(),e.castShadow=!1)})}throughAir(t,e){const i=this.frame?.transmittance?.(e.x,e.y,e.z)??[1,1,1];return[t[0]*i[0],t[1]*i[1],t[2]*i[2]]}static rgbOf(t){const e=new st(t);return[e.r,e.g,e.b]}throwFlame(t,e,i,n,s){let a=this.flames.get(t.id);if(!a&&t.throwsFlame&&(a=new Ra,this.flames.set(t.id,a),this.group.add(a.mesh,a.light,a.glow)),!a)return;const o=t.flame;if(!o){a.putOut(),this.dust.get(t.id)?.set(0,0,0,i,{x:0,z:0},0);return}e.updateMatrixWorld(!0);const c=e.getObjectByName(o.node??ue.EXHAUST_NODE);c?c.getWorldPosition(this.scratch):e.localToWorld(this.scratch.set(0,-.5,0)),a.place(this.scratch,c?ue.pointing(c,this.down,this.aim):e.quaternion,o.lengthM,o.widthM);const l=d=>{const f=new st(d);return this.throughAir(ue.shown([f.r,f.g,f.b],o.luminanceCdM2,n),this.scratch)};a.set(l(o.color),l(o.tipColor??o.color),i),a.illuminate(ue.luminousIntensityCd(o)*this.sceneUnitsPerLux(),ue.lightColourOf(o));const h=Ra.glowFor(o,s?a.mesh.position.distanceTo(s):0),u=new st(o.color).lerp(new st(o.tipColor??o.color),.5);a.shine(h.radiusM,this.throughAir(ue.shown([u.r,u.g,u.b],h.luminanceCdM2,n),this.scratch)),this.raiseDust(t.id,o,i)}raiseDust(t,e,i){const n=this.frame;if(!e.raisesDust||!n?.groundYAt){this.dust.get(t)?.set(0,0,0,i,{x:0,z:0},0);return}let s=this.dust.get(t);s||(s=new es(es.DUST),this.dust.set(t,s),this.group.add(s.points));const{x:a,y:o,z:c}=this.scratch,l=n.groundYAt(a,c),h=Math.max(0,Math.min(1,1-(o-l)/(e.lengthM+1)));s.set(a,l,c,i,n.wind??{x:0,z:0},h,n.light)}setSmoke(t,e){const i=this.frame;for(;this.smoke.length<t.length;){const n=new es(es.SMOKE);this.smoke.push(n),this.group.add(n.points)}this.smoke.forEach((n,s)=>{const a=t[s],o=e*1e3;if(!(a!==void 0&&i!==void 0&&o>=a.fromT&&(a.untilT===void 0||o<a.untilT))){n.set(0,0,0,e,{x:0,z:0},0);return}const l=i.originX+a.eastM,h=i.originZ-a.northM,u=(o-a.fromT)/1e3,d=Math.min(1,u/2)*(.1+.9*Math.pow(2,-u/(a.halfLifeS??20)));n.set(l,i.groundYAt?i.groundYAt(l,h):i.originGroundY,h,e,i.wind??{x:0,z:0},d,i.light)})}static luminousIntensityCd(t){return t.luminanceCdM2*.7*t.widthM*t.lengthM}static lightColourOf(t){const e=new st(t.color),i=new st(t.tipColor??t.color),n=[(e.r+i.r)/2,(e.g+i.g)/2,(e.b+i.b)/2],s=.2126*n[0]+.7152*n[1]+.0722*n[2];return s>0?[n[0]/s,n[1]/s,n[2]/s]:[1,1,1]}static pointing(t,e,i){return e.set(0,-1,0).transformDirection(t.matrixWorld).normalize(),i.setFromUnitVectors(ue.DOWN,e)}static DOWN=new R(0,-1,0);static EXHAUST_NODE="exhaust";shineLights(t,e,i,n){const s=n.eye,a=t.lights;if(!i||!a||!s){this.hideLights(t.id);return}e.updateMatrixWorld(!0);let o;for(const c of i){const l=`${t.id}\0${c.name}`,h=a[c.name];let u=this.lightVeils.get(l);if(!(h>0)||c.meshes.length===0){u?.hide();continue}const d=new Vi;for(const x of c.meshes)d.expandByObject(x);const f=d.getCenter(new R),p=d.getSize(new R),v=Math.max(p.x,p.y,p.z)/2,m=Math.max(f.distanceTo(s),v*1.01,.001);o??=[e,...n.occluders??[]].map(x=>({object:x,box:new Vi().setFromObject(x)}));const g=this.clearShare(s,d,f,c.meshes,o);if(g<=0){u?.hide();continue}u||(u=new Pi(`body-light:${t.id}:${c.name}`),this.lightVeils.set(l,u),this.group.add(u.mesh));const S=Math.asin(Math.min(1,v/m)),y=2*Math.PI*(1-Math.cos(S))*g,M=h*y*this.sceneUnitsPerLux(),b=Math.max(...c.hue)||1,w=[c.hue[0]/b,c.hue[1]/b,c.hue[2]/b],T=this.throughAir([w[0]*M,w[1]*M,w[2]*M],f);u.shine(f,T,S*180/Math.PI)}}clearShare(t,e,i,n,s){const a=[i];for(const[l,h]of[[.2,.2],[.8,.2],[.2,.8],[.8,.8]])a.push(new R(e.min.x+(e.max.x-e.min.x)*l,i.y+(l<.5?-1:1)*(e.max.y-e.min.y)*.3,e.min.z+(e.max.z-e.min.z)*h));const o=new R;let c=0;for(const l of a){o.subVectors(l,t);const h=o.length();this.lightRay.set(t,o.normalize()),this.lightRay.far=h;const u=s.filter(({box:f})=>{const p=this.lightRay.ray.intersectBox(f,this.boxHit);return p!==null&&p.distanceTo(t)<h}).map(({object:f})=>f);u.length>0&&this.lightRay.intersectObjects(u,!0).some(f=>f.object instanceof Dt&&!n.includes(f.object)&&f.distance<h-.05)||c++}return c/a.length}hideLights(t){const e=`${t}\0`;for(const[i,n]of this.lightVeils)i.startsWith(e)&&n.hide()}dropGlare(t){const e=this.glares.get(t);e&&(this.group.remove(e.mesh),e.dispose(),this.glares.delete(t))}dropFlame(t){const e=this.flames.get(t);if(!e)return;e.mesh.removeFromParent(),e.light.removeFromParent(),e.glow.removeFromParent(),e.dispose(),this.flames.delete(t);const i=this.dust.get(t);i&&(i.points.removeFromParent(),i.dispose(),this.dust.delete(t))}outlineOf(t,e){const i=this.built.get(t)?.holder,n=this.frame,s=i?.getObjectByName(e);if(!i||!n||!s)return;i.updateMatrixWorld(!0);const a=[];return s.traverse(o=>{if(!(o instanceof Dt))return;const c=o.geometry.getAttribute("position"),l=Math.max(1,Math.floor(c.count/400));for(let h=0;h<c.count;h+=l)this.scratch.fromBufferAttribute(c,h).applyMatrix4(o.matrixWorld),a.push({eastM:this.scratch.x-n.originX,northM:n.originZ-this.scratch.z,upM:this.scratch.y-n.originGroundY})}),a.length>0?a:void 0}boxOf(t,e){const i=this.built.get(t)?.holder;return i?.visible?e.setFromObject(i):void 0}pick(t){const e=[...this.built.entries()].filter(([,{holder:s}])=>s.visible),i=t.intersectObjects(e.map(([,{holder:s}])=>s),!0)[0];if(!i)return;let n=i.object;for(;n&&!e.some(([,{holder:s}])=>s===n);)n=n.parent;return e.find(([,{holder:s}])=>s===n)?.[0]}reachFrom(t){let e=0;for(const{holder:i}of this.built.values()){if(!i.visible)continue;const n=Math.hypot(i.position.x-t.x,i.position.z-t.z);e=Math.max(e,n+Math.max(i.scale.x,i.scale.y,i.scale.z)/2)}return e}furthestFrom(t){let e=0;for(const{holder:i}of this.built.values())i.visible&&(e=Math.max(e,i.position.distanceTo(t)));return e}get reflectors(){return[...this.built.entries()].filter(([,{holder:t}])=>t.visible).map(([t,{holder:e}])=>({id:t,holder:e,shiny:ue.isShiny(e)}))}static isShiny(t){let e=!1;return t.traverse(i=>{const n=i.material;for(const s of Array.isArray(n)?n:[n])(s instanceof Xo||s instanceof xa&&(s.roughness<ue.SHINY_ROUGHNESS||s.metalness>ue.SHINY_METALNESS))&&(e=!0)}),e}static SHINY_ROUGHNESS=.6;static SHINY_METALNESS=.3;get any(){return[...this.built.values()].some(({holder:t})=>t.visible)}clear(){this.token++;for(const t of[...this.built.keys()])this.remove(t)}build(t){const e=new Ce;e.name=`body:${t.id}`;const i=ue.signatureOf(t.model),n=ue.primitiveOf(t.model);if(n==="figure"){const c=new xa({roughness:.7,metalness:0});ue.paint(c,t);const l=ui.build({id:t.id,kind:"entity",eastM:0,northM:0},!1);return l.traverse(h=>{h instanceof Dt&&(h.material=c,h.castShadow=!0,h.receiveShadow=!0)}),e.add(ue.fit(l,0)),{holder:e,signature:i,material:c}}if(n){const c=new xa({roughness:.45,metalness:0});ue.paint(c,t);const l=new Dt(ue.unitGeometry(n),c);return l.castShadow=!0,l.receiveShadow=!0,e.add(l),{holder:e,signature:i,material:c}}const s=new xa({roughness:.45,metalness:0});ue.paint(s,t);const a=new Dt(ue.unitGeometry("ellipsoid"),s);a.castShadow=!0,a.receiveShadow=!0,e.add(a);const o=this.token;return this.loadModel(t.model).then(c=>{if(!c||o!==this.token||this.built.get(t.id)?.holder!==e)return;e.remove(a),a.geometry.dispose(),s.dispose(),ue.glaze(c.scene),e.add(ue.fit(c.scene,c.headingOffsetDeg??t.model.headingOffsetDeg??0)),this.credits.set(t.id,c.credit);const l=this.built.get(t.id);l&&(l.material=void 0,l.glowing=ue.glowingOf(c.scene),l.motions=ue.motionsOf(c.scene)),this.lastSet&&this.set(...this.lastSet),this.onModelArrived()}).catch(c=>console.warn(`Keeping the ellipsoid for body "${t.id}":`,c)),{holder:e,signature:i,material:s}}static fit(t,e){const i=new Ce;t.rotation.y=-e*Wc,i.add(t),i.updateMatrixWorld(!0);const n=new Vi().setFromObject(i),s=n.getSize(new R),a=n.getCenter(new R),o=new Ce;return i.position.sub(a),o.add(i),o.scale.set(1/Math.max(s.x,1e-6),1/Math.max(s.y,1e-6),1/Math.max(s.z,1e-6)),t.traverse(c=>{c instanceof Dt&&(c.castShadow=!0,c.receiveShadow=!0)}),o}static paint(t,e,i){const n=new st(e.appearance.color),s=.2126*n.r+.7152*n.g+.0722*n.b;s>0&&n.multiplyScalar(e.appearance.albedo/s),n.r=Math.min(1,n.r),n.g=Math.min(1,n.g),n.b=Math.min(1,n.b),t.color.equals(n)||t.color.copy(n);const a=new st(e.appearance.color),o=Math.max(a.r,a.g,a.b);ue.glow(t,o>0?[a.r/o,a.g/o,a.b/o]:[1,1,1],e.appearance.luminanceCdM2,i)}static light(t,e,i){for(const{material:n,hue:s,share:a,name:o}of t)ue.glow(n,s,e.lights?.[o]??e.appearance.luminanceCdM2*a,i)}static glow(t,e,i,n){if(!(i>0)){(t.emissive.r!==0||t.emissive.g!==0||t.emissive.b!==0)&&t.emissive.setRGB(0,0,0);return}const s=ue.shown(e,i,n);t.emissive.setRGB(s[0],s[1],s[2])}static motionsOf(t){if(t.animations.length===0)return;const e=new Mx(t),i=new Map;for(const n of t.animations){const s=e.clipAction(n);s.setLoop(Pg,1),s.clampWhenFinished=!0,s.play(),s.paused=!0,i.set(n.name,s)}return i}static move(t,e){let i;for(const[n,s]of t){const a=Math.max(0,e[n]??0),o=a-Math.floor(a),c=a>0&&o===0?1:o;s.time=c*s.getClip().duration,i=s.getMixer()}i?.update(0)}static shown(t,e,i){return On.shown(t,e,i)}static glowingOf(t){const e=[],i=new Map;t.traverse(a=>{if(a instanceof Dt)for(const o of Array.isArray(a.material)?a.material:[a.material]){if(!(o instanceof xa))continue;const c=i.get(o);if(c){c.push(a);continue}i.set(o,[a]),Math.max(o.emissive.r,o.emissive.g,o.emissive.b)>0&&e.push(o)}});const n=a=>Math.max(a.emissive.r,a.emissive.g,a.emissive.b),s=Math.max(...e.map(n),0);return s<=0?[]:e.map(a=>({material:a,hue:[a.emissive.r,a.emissive.g,a.emissive.b],share:n(a)/s,name:a.name,meshes:i.get(a)??[]}))}static primitiveOf(t){return t.url===void 0&&z1.includes(t.id??"")?t.id:void 0}static signatureOf(t){return`${t.id??""}|${t.url??""}`}static unitGeometry(t){let e;switch(t){case"ellipsoid":case"sphere":e=new oi(.5,48,24);break;case"disc":{const a=[];for(let c=0;c<=24;c++){const l=.5*Math.sin(c/24*Math.PI),h=.5*Math.cos(c/24*Math.PI);a.push(new xt(l,Math.sign(h)*h*h*2))}e=new Gl(a.reverse(),64);break}case"cylinder":e=new cs(.5,.5,1,48);break;case"cone":e=new Ur(.5,1,48);break;case"box":e=new Wi(1,1,1);break;case"torus":e=new M0(.35,.15,24,64),e.rotateX(Math.PI/2);break;case"figure":e=new oi(.5,24,12);break}e.computeBoundingBox();const i=e.boundingBox,n=i.getSize(new R),s=i.getCenter(new R);return e.translate(-s.x,-s.y,-s.z),e.scale(1/n.x,1/n.y,1/n.z),e.computeVertexNormals(),e}remove(t){const e=this.built.get(t);if(!e)return;e.holder.removeFromParent(),e.holder.traverse(n=>{if(!(n instanceof Dt))return;n.geometry.dispose();const s=Array.isArray(n.material)?n.material:[n.material];for(const a of s)a.dispose()}),this.built.delete(t),this.credits.delete(t),this.dropFlame(t),this.dropGlare(t);const i=`${t}\0`;for(const[n,s]of[...this.lightVeils])n.startsWith(i)&&(this.group.remove(s.mesh),s.dispose(),this.lightVeils.delete(n))}}const B1=2,Dw=5,Iw=2048;class In{constructor(t){this.scene=t}cloudLayers=[];cloudSignature="";setCloudLayers(t){const e=t.map(i=>i.mesh.uuid).join(",");if(e!==this.cloudSignature){this.cloudSignature=e,this.cloudLayers=t;for(const i of this.meshes.values())this.configureCloudMaterial(i.material)}}configureCloudMaterial(t){const e=this.cloudLayers,i=this.cloudSignature;t.customProgramCacheKey=()=>i,t.onBeforeCompile=n=>{if(!e.length)return;n.vertexShader=`varying vec3 cloudPoint;
7143
+ `,transparent:!0,depthWrite:!1,side:ji,fog:!1,blending:zl,blendSrc:Fo,blendDst:Uo})}static wallReflectance(t,e,i){const n=i(t,1,e);return 2*n/(1+n)}setSurroundings(t){this.uniforms.uSurroundings.value=t}static reflectedResponse(t,e){return At.respond(e*At.relativeOfResponse(Math.max(t,1e-5)))}}const Wc=Math.PI/180;class ue{constructor(t,e,i=()=>0){this.loadModel=t,this.onModelArrived=e,this.sceneUnitsPerLux=i,this.group.name="bodies"}group=new Ce;built=new Map;token=0;credits=new Map;flames=new Map;glares=new Map;lightVeils=new Map;lightRay=new ol;boxHit=new R;dust=new Map;smoke=[];scratch=new R;aim=new Qi;down=new R;frame;lastSet;get modelCredits(){return[...this.credits.values()]}set(t,e,i=0,n,s=t.map(a=>a.id)){this.frame=e,this.lastSet=[t,e,i,n,s];const a=new Set;for(const c of t){a.add(c.id);const l=ue.signatureOf(c.model);let h=this.built.get(c.id);(!h||h.signature!==l)&&(h&&this.remove(c.id),h=this.build(c),this.built.set(c.id,h),this.group.add(h.holder));const{holder:u,material:d,glowing:f}=h;u.visible=!0,u.position.set(e.originX+c.eastM,e.originGroundY+c.upM,e.originZ-c.northM),u.rotation.set(c.attitude.pitchDeg*Wc,-c.attitude.headingDeg*Wc,-c.attitude.rollDeg*Wc,"YXZ"),u.scale.set(c.sizeM.widthM,c.sizeM.heightM,c.sizeM.lengthM),d&&ue.paint(d,c,n),f&&ue.light(f,c,n),h.motions&&ue.move(h.motions,c.motions??{}),this.shine(c,u,f,n,e.eye),this.shineLights(c,u,f,e),this.throwFlame(c,u,i,n,e.eye)}const o=new Set(s);for(const[c,{holder:l}]of[...this.built])a.has(c)||(o.has(c)?(l.visible=!1,this.flames.get(c)?.putOut(),this.glares.get(c)?.hide(),this.hideLights(c)):this.remove(c))}shine(t,e,i,n,s){const a=t.appearance.luminanceCdM2;let o=this.glares.get(t.id);if(!(a>0)||!s||i&&i.length>0){o?.hide();return}o||(o=new Pi(`body-veil:${t.id}`),this.glares.set(t.id,o),this.group.add(o.mesh));const c=Math.max(t.sizeM.widthM,t.sizeM.heightM)/2,l=Math.max(e.position.distanceTo(s),c*1.01),h=Math.asin(c/l),u=2*Math.PI*(1-Math.cos(h)),d=i?.find(p=>p.share>=1)?.hue??ue.rgbOf(t.appearance.color),f=this.throughAir(ue.shown(d,a,n),e.position);o.shine(e.position,[f[0]*u,f[1]*u,f[2]*u],h*180/Math.PI)}static glaze(t){t.traverse(e=>{if(!(e instanceof Dt))return;const i=e.material;!(i instanceof BM)||!(i.transmission>0)||(e.material=new Xo(i.ior),i.dispose(),e.castShadow=!1)})}throughAir(t,e){const i=this.frame?.transmittance?.(e.x,e.y,e.z)??[1,1,1];return[t[0]*i[0],t[1]*i[1],t[2]*i[2]]}static rgbOf(t){const e=new st(t);return[e.r,e.g,e.b]}throwFlame(t,e,i,n,s){let a=this.flames.get(t.id);if(!a&&t.throwsFlame&&(a=new Ra,this.flames.set(t.id,a),this.group.add(a.mesh,a.light,a.glow)),!a)return;const o=t.flame;if(!o){a.putOut(),this.dust.get(t.id)?.set(0,0,0,i,{x:0,z:0},0);return}e.updateMatrixWorld(!0);const c=e.getObjectByName(o.node??ue.EXHAUST_NODE);c?c.getWorldPosition(this.scratch):e.localToWorld(this.scratch.set(0,-.5,0)),a.place(this.scratch,c?ue.pointing(c,this.down,this.aim):e.quaternion,o.lengthM,o.widthM);const l=d=>{const f=new st(d);return this.throughAir(ue.shown([f.r,f.g,f.b],o.luminanceCdM2,n),this.scratch)};a.set(l(o.color),l(o.tipColor??o.color),i),a.illuminate(ue.luminousIntensityCd(o)*this.sceneUnitsPerLux(),ue.lightColourOf(o));const h=Ra.glowFor(o,s?a.mesh.position.distanceTo(s):0),u=new st(o.color).lerp(new st(o.tipColor??o.color),.5);a.shine(h.radiusM,this.throughAir(ue.shown([u.r,u.g,u.b],h.luminanceCdM2,n),this.scratch)),this.raiseDust(t.id,o,i)}raiseDust(t,e,i){const n=this.frame;if(!e.raisesDust||!n?.groundYAt){this.dust.get(t)?.set(0,0,0,i,{x:0,z:0},0);return}let s=this.dust.get(t);s||(s=new es(es.DUST),this.dust.set(t,s),this.group.add(s.points));const{x:a,y:o,z:c}=this.scratch,l=n.groundYAt(a,c),h=Math.max(0,Math.min(1,1-(o-l)/(e.lengthM+1)));s.set(a,l,c,i,n.wind??{x:0,z:0},h,n.light)}setSmoke(t,e){const i=this.frame;for(;this.smoke.length<t.length;){const n=new es(es.SMOKE);this.smoke.push(n),this.group.add(n.points)}this.smoke.forEach((n,s)=>{const a=t[s],o=e*1e3;if(!(a!==void 0&&i!==void 0&&o>=a.fromT&&(a.untilT===void 0||o<a.untilT))){n.set(0,0,0,e,{x:0,z:0},0);return}const l=i.originX+a.eastM,h=i.originZ-a.northM,u=(o-a.fromT)/1e3,d=Math.min(1,u/2)*(.1+.9*Math.pow(2,-u/(a.halfLifeS??20)));n.set(l,i.groundYAt?i.groundYAt(l,h):i.originGroundY,h,e,i.wind??{x:0,z:0},d,i.light)})}static luminousIntensityCd(t){return t.luminanceCdM2*.7*t.widthM*t.lengthM}static lightColourOf(t){const e=new st(t.color),i=new st(t.tipColor??t.color),n=[(e.r+i.r)/2,(e.g+i.g)/2,(e.b+i.b)/2],s=.2126*n[0]+.7152*n[1]+.0722*n[2];return s>0?[n[0]/s,n[1]/s,n[2]/s]:[1,1,1]}static pointing(t,e,i){return e.set(0,-1,0).transformDirection(t.matrixWorld).normalize(),i.setFromUnitVectors(ue.DOWN,e)}static DOWN=new R(0,-1,0);static EXHAUST_NODE="exhaust";shineLights(t,e,i,n){const s=n.eye,a=t.lights;if(!i||!a||!s){this.hideLights(t.id);return}e.updateMatrixWorld(!0);let o;for(const c of i){const l=`${t.id}\0${c.name}`,h=a[c.name];let u=this.lightVeils.get(l);if(!(h>0)||c.meshes.length===0){u?.hide();continue}const d=new Vi;for(const x of c.meshes)d.expandByObject(x);const f=d.getCenter(new R),p=d.getSize(new R),v=Math.max(p.x,p.y,p.z)/2,m=Math.max(f.distanceTo(s),v*1.01,.001);o??=[e,...n.occluders??[]].map(x=>({object:x,box:new Vi().setFromObject(x)}));const g=this.clearShare(s,d,f,c.meshes,o);if(g<=0){u?.hide();continue}u||(u=new Pi(`body-light:${t.id}:${c.name}`),this.lightVeils.set(l,u),this.group.add(u.mesh));const S=Math.asin(Math.min(1,v/m)),y=2*Math.PI*(1-Math.cos(S))*g,M=h*y*this.sceneUnitsPerLux(),b=Math.max(...c.hue)||1,w=[c.hue[0]/b,c.hue[1]/b,c.hue[2]/b],T=this.throughAir([w[0]*M,w[1]*M,w[2]*M],f);u.shine(f,T,S*180/Math.PI)}}clearShare(t,e,i,n,s){const a=[i];for(const[l,h]of[[.2,.2],[.8,.2],[.2,.8],[.8,.8]])a.push(new R(e.min.x+(e.max.x-e.min.x)*l,i.y+(l<.5?-1:1)*(e.max.y-e.min.y)*.3,e.min.z+(e.max.z-e.min.z)*h));const o=new R;let c=0;for(const l of a){o.subVectors(l,t);const h=o.length();this.lightRay.set(t,o.normalize()),this.lightRay.far=h;const u=s.filter(({box:f})=>{const p=this.lightRay.ray.intersectBox(f,this.boxHit);return p!==null&&p.distanceTo(t)<h}).map(({object:f})=>f);u.length>0&&this.lightRay.intersectObjects(u,!0).some(f=>f.object instanceof Dt&&!n.includes(f.object)&&f.distance<h-.05)||c++}return c/a.length}hideLights(t){const e=`${t}\0`;for(const[i,n]of this.lightVeils)i.startsWith(e)&&n.hide()}dropGlare(t){const e=this.glares.get(t);e&&(this.group.remove(e.mesh),e.dispose(),this.glares.delete(t))}dropFlame(t){const e=this.flames.get(t);if(!e)return;e.mesh.removeFromParent(),e.light.removeFromParent(),e.glow.removeFromParent(),e.dispose(),this.flames.delete(t);const i=this.dust.get(t);i&&(i.points.removeFromParent(),i.dispose(),this.dust.delete(t))}outlineOf(t,e){const i=this.built.get(t)?.holder,n=this.frame,s=i?.getObjectByName(e);if(!i||!n||!s)return;i.updateMatrixWorld(!0);const a=[];return s.traverse(o=>{if(!(o instanceof Dt))return;const c=o.geometry.getAttribute("position"),l=Math.max(1,Math.floor(c.count/400));for(let h=0;h<c.count;h+=l)this.scratch.fromBufferAttribute(c,h).applyMatrix4(o.matrixWorld),a.push({eastM:this.scratch.x-n.originX,northM:n.originZ-this.scratch.z,upM:this.scratch.y-n.originGroundY})}),a.length>0?a:void 0}boxOf(t,e){const i=this.built.get(t)?.holder;return i?.visible?e.setFromObject(i):void 0}pick(t){const e=[...this.built.entries()].filter(([,{holder:s}])=>s.visible),i=t.intersectObjects(e.map(([,{holder:s}])=>s),!0)[0];if(!i)return;let n=i.object;for(;n&&!e.some(([,{holder:s}])=>s===n);)n=n.parent;return e.find(([,{holder:s}])=>s===n)?.[0]}reachFrom(t){let e=0;for(const{holder:i}of this.built.values()){if(!i.visible)continue;const n=Math.hypot(i.position.x-t.x,i.position.z-t.z);e=Math.max(e,n+Math.max(i.scale.x,i.scale.y,i.scale.z)/2)}return e}furthestFrom(t){let e=0;for(const{holder:i}of this.built.values())i.visible&&(e=Math.max(e,i.position.distanceTo(t)));return e}get reflectors(){return[...this.built.entries()].filter(([,{holder:t}])=>t.visible).map(([t,{holder:e}])=>({id:t,holder:e,shiny:ue.isShiny(e)}))}static isShiny(t){let e=!1;return t.traverse(i=>{const n=i.material;for(const s of Array.isArray(n)?n:[n])(s instanceof Xo||s instanceof xa&&(s.roughness<ue.SHINY_ROUGHNESS||s.metalness>ue.SHINY_METALNESS))&&(e=!0)}),e}static SHINY_ROUGHNESS=.6;static SHINY_METALNESS=.3;get any(){return[...this.built.values()].some(({holder:t})=>t.visible)}clear(){this.token++;for(const t of[...this.built.keys()])this.remove(t)}build(t){const e=new Ce;e.name=`body:${t.id}`;const i=ue.signatureOf(t.model),n=ue.primitiveOf(t.model);if(n==="figure"){const c=new xa({roughness:.7,metalness:0});ue.paint(c,t);const l=ui.build({id:t.id,kind:"entity",eastM:0,northM:0},!1);return l.traverse(h=>{h instanceof Dt&&(h.material=c,h.castShadow=!0,h.receiveShadow=!0)}),e.add(ue.fit(l,0)),{holder:e,signature:i,material:c}}if(n){const c=new xa({roughness:.45,metalness:0});ue.paint(c,t);const l=new Dt(ue.unitGeometry(n),c);return l.castShadow=!0,l.receiveShadow=!0,e.add(l),{holder:e,signature:i,material:c}}const s=new xa({roughness:.45,metalness:0});ue.paint(s,t);const a=new Dt(ue.unitGeometry("ellipsoid"),s);a.castShadow=!0,a.receiveShadow=!0,e.add(a);const o=this.token;return this.loadModel(t.model).then(c=>{if(!c||o!==this.token||this.built.get(t.id)?.holder!==e)return;e.remove(a),a.geometry.dispose(),s.dispose(),ue.glaze(c.scene),e.add(ue.fit(c.scene,c.headingOffsetDeg??t.model.headingOffsetDeg??0)),this.credits.set(t.id,c.credit);const l=this.built.get(t.id);l&&(l.material=void 0,l.glowing=ue.glowingOf(c.scene),l.motions=ue.motionsOf(c.scene)),this.lastSet&&this.set(...this.lastSet),this.onModelArrived()}).catch(c=>console.warn(`Keeping the ellipsoid for body "${t.id}":`,c)),{holder:e,signature:i,material:s}}static fit(t,e){const i=new Ce;t.rotation.y=-e*Wc,i.add(t),i.updateMatrixWorld(!0);const n=new Vi().setFromObject(i),s=n.getSize(new R),a=n.getCenter(new R),o=new Ce;return i.position.sub(a),o.add(i),o.scale.set(1/Math.max(s.x,1e-6),1/Math.max(s.y,1e-6),1/Math.max(s.z,1e-6)),t.traverse(c=>{c instanceof Dt&&(c.castShadow=!0,c.receiveShadow=!0)}),o}static paint(t,e,i){const n=new st(e.appearance.color),s=.2126*n.r+.7152*n.g+.0722*n.b;s>0&&n.multiplyScalar(e.appearance.albedo/s),n.r=Math.min(1,n.r),n.g=Math.min(1,n.g),n.b=Math.min(1,n.b),t.color.equals(n)||t.color.copy(n);const a=new st(e.appearance.color),o=Math.max(a.r,a.g,a.b);ue.glow(t,o>0?[a.r/o,a.g/o,a.b/o]:[1,1,1],e.appearance.luminanceCdM2,i)}static light(t,e,i){for(const{material:n,hue:s,share:a,name:o}of t)ue.glow(n,s,e.lights?.[o]??e.appearance.luminanceCdM2*a,i)}static glow(t,e,i,n){if(!(i>0)){(t.emissive.r!==0||t.emissive.g!==0||t.emissive.b!==0)&&t.emissive.setRGB(0,0,0);return}const s=ue.shown(e,i,n);t.emissive.setRGB(s[0],s[1],s[2])}static motionsOf(t){if(t.animations.length===0)return;const e=new Mx(t),i=new Map;for(const n of t.animations){const s=e.clipAction(n);s.setLoop(Pg,1),s.clampWhenFinished=!0,s.play(),s.paused=!0,i.set(n.name,s)}return i}static move(t,e){let i;for(const[n,s]of t){const a=Math.max(0,e[n]??0),o=a-Math.floor(a),c=a>0&&o===0?1:o;s.time=c*s.getClip().duration,i=s.getMixer()}i?.update(0)}static shown(t,e,i){return On.shown(t,e,i)}static glowingOf(t){const e=[],i=new Map;t.traverse(a=>{if(a instanceof Dt)for(const o of Array.isArray(a.material)?a.material:[a.material]){if(!(o instanceof xa))continue;const c=i.get(o);if(c){c.push(a);continue}i.set(o,[a]),Math.max(o.emissive.r,o.emissive.g,o.emissive.b)>0&&e.push(o)}});const n=a=>Math.max(a.emissive.r,a.emissive.g,a.emissive.b),s=Math.max(...e.map(n),0);return s<=0?[]:e.map(a=>({material:a,hue:[a.emissive.r,a.emissive.g,a.emissive.b],share:n(a)/s,name:a.name,meshes:i.get(a)??[]}))}static primitiveOf(t){return t.url===void 0&&z1.includes(t.id??"")?t.id:void 0}static signatureOf(t){return`${t.id??""}|${t.url??""}`}static unitGeometry(t){let e;switch(t){case"ellipsoid":case"sphere":e=new oi(.5,48,24);break;case"disc":{const a=[];for(let c=0;c<=24;c++){const l=.5*Math.sin(c/24*Math.PI),h=.5*Math.cos(c/24*Math.PI);a.push(new xt(l,Math.sign(h)*h*h*2))}e=new Gl(a.reverse(),64);break}case"cylinder":e=new cs(.5,.5,1,48);break;case"cone":e=new Ur(.5,1,48);break;case"box":e=new Wi(1,1,1);break;case"torus":e=new M0(.35,.15,24,64),e.rotateX(Math.PI/2);break;case"figure":e=new oi(.5,24,12);break}e.computeBoundingBox();const i=e.boundingBox,n=i.getSize(new R),s=i.getCenter(new R);return e.translate(-s.x,-s.y,-s.z),e.scale(1/n.x,1/n.y,1/n.z),e.computeVertexNormals(),e}remove(t){const e=this.built.get(t);if(!e)return;e.holder.removeFromParent(),e.holder.traverse(n=>{if(!(n instanceof Dt))return;n.geometry.dispose();const s=Array.isArray(n.material)?n.material:[n.material];for(const a of s)a.dispose()}),this.built.delete(t),this.credits.delete(t),this.dropFlame(t),this.dropGlare(t);const i=`${t}\0`;for(const[n,s]of[...this.lightVeils])n.startsWith(i)&&(this.group.remove(s.mesh),s.dispose(),this.lightVeils.delete(n))}}const B1=2,D5=5,I5=2048;class In{constructor(t){this.scene=t}cloudLayers=[];cloudSignature="";setCloudLayers(t){const e=t.map(i=>i.mesh.uuid).join(",");if(e!==this.cloudSignature){this.cloudSignature=e,this.cloudLayers=t;for(const i of this.meshes.values())this.configureCloudMaterial(i.material)}}configureCloudMaterial(t){const e=this.cloudLayers,i=this.cloudSignature;t.customProgramCacheKey=()=>i,t.onBeforeCompile=n=>{if(!e.length)return;n.vertexShader=`varying vec3 cloudPoint;
7087
7144
  `+n.vertexShader,n.vertexShader=n.vertexShader.replace("#include <project_vertex>",`#include <project_vertex>
7088
7145
  cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let s=`varying vec3 cloudPoint;
7089
7146
  `,a="";e.forEach((o,c)=>{const l=`cloud${c}_`;for(const[h,u]of Object.entries(o.uniforms))n.uniforms[l+h]=u;s+=yb(l),a+=`diffuseColor.a *= ${l}transmissionAt(normalize(cloudPoint), length(cloudPoint));
7090
- `}),n.fragmentShader=s+n.fragmentShader,n.fragmentShader=n.fragmentShader.replace("#include <opaque_fragment>",a+"#include <opaque_fragment>")},t.needsUpdate=!0}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new R;up=new R;lookAt=new Zt;vertex=new R;centre=new R;right=new R;above=new R;set(t,e){this.placed=t,this.frame=e;const i=new Set(t.map(n=>n.sourceId));for(const[n,s]of this.meshes)i.has(n)||(this.dispose(s),this.meshes.delete(n),this.signatures.delete(n),this.extents.delete(n));for(const n of t){let s=this.meshes.get(n.sourceId);s||(s=new Dt(new Xi(1,1,In.SEGMENTS,In.SEGMENTS),new _n({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),this.configureCloudMaterial(s.material),s.frustumCulled=!1,s.layers.set(B1),this.scene.add(s),this.meshes.set(n.sourceId,s)),s.renderOrder=Dw+n.renderOrder,s.visible=!n.hidden&&n.shape.transparency<1,s.visible&&this.paint(s,n,e)}}place(t,e,i){const n=this.frame;if(n)for(const s of this.placed){const a=this.meshes.get(s.sourceId);if(!a||!a.visible)continue;const o=this.extents.get(s.sourceId);if(!o)continue;const{bounds:c}=s.shape;let l=c.x+c.width/2,h=c.y+c.height/2,u=!0;if(s.aim){const d=i(In.directionOf(s.aim,this.direction));d&&Math.abs(d.ndcX)<In.FURTHEST_NDC&&Math.abs(d.ndcY)<In.FURTHEST_NDC?(l=(d.ndcX+1)/2*n.canvasWidthPx,h=(1-d.ndcY)/2*n.canvasHeightPx):u=!1}u?this.curve(a,t,e,n,o,l,h,s.distanceM):this.flat(a,t,n,o,s.distanceM)}}static FURTHEST_NDC=4;curve(t,e,i,n,s,a,o,c){const l=a-s.width/2,h=o-s.height/2,u=t.geometry.attributes.position,d=In.SEGMENTS;let f=0;for(let p=0;p<=d;p++){const v=h+p/d*s.height;for(let m=0;m<=d;m++){const g=l+m/d*s.width;i(g/n.canvasWidthPx*2-1,-(v/n.canvasHeightPx*2-1),this.direction),this.vertex.copy(e.position).addScaledVector(this.direction,c),u.setXYZ(f++,this.vertex.x,this.vertex.y,this.vertex.z)}}u.needsUpdate=!0,t.matrixAutoUpdate=!1,t.matrix.identity(),t.matrixWorldNeedsUpdate=!0,t.scale.set(Te.sizeMAt(c,n.projection.pxToDeg(s.width)),Te.sizeMAt(c,n.projection.pxToDeg(s.height)),1)}flat(t,e,i,n,s){const a=t.geometry.attributes.position,o=In.SEGMENTS,c=Te.sizeMAt(s,i.projection.pxToDeg(n.width)),l=Te.sizeMAt(s,i.projection.pxToDeg(n.height));this.up.set(0,1,0).applyQuaternion(e.quaternion),this.centre.copy(e.position).addScaledVector(this.direction,s),this.lookAt.lookAt(e.position,this.centre,this.up),this.right.setFromMatrixColumn(this.lookAt,0),this.above.setFromMatrixColumn(this.lookAt,1);let h=0;for(let u=0;u<=o;u++){const d=.5-u/o;for(let f=0;f<=o;f++){const p=f/o-.5;this.vertex.copy(this.centre).addScaledVector(this.right,p*c).addScaledVector(this.above,d*l),a.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}a.needsUpdate=!0,t.matrixAutoUpdate=!1,t.matrix.identity(),t.matrixWorldNeedsUpdate=!0,t.scale.set(c,l,1)}static SEGMENTS=16;static directionOf(t,e){const i=t.azimuthDeg*Math.PI/180,n=t.altitudeDeg*Math.PI/180;return e.set(Math.sin(i)*Math.cos(n),Math.sin(n),-Math.cos(i)*Math.cos(n))}get any(){for(const t of this.meshes.values())if(t.visible)return!0;return!1}get furthestM(){return this.placed.reduce((t,e)=>Math.max(t,e.distanceM),0)}paint(t,e,i){const{shape:n}=e,s=No.paintExtent(n),a=e.ghost?3:0,o={x:s.x-a,y:s.y-a,width:s.width+2*a,height:s.height+2*a};this.extents.set(e.sourceId,o);const c=`${In.signatureOf(n,i)}|${e.ghost?"ghost":""}`;if(this.signatures.get(e.sourceId)===c&&t.material.map)return;this.signatures.set(e.sourceId,c);const l=Math.min(i.scale,Iw/Math.max(o.width,o.height,1)),h=Math.max(1,Math.ceil(o.width*l)),u=Math.max(1,Math.ceil(o.height*l)),d=t.material.map,f=d?.image??document.createElement("canvas"),p=f.width!==h||f.height!==u;p&&(f.width=h,f.height=u);const v=f.getContext("2d");if(!v)return;v.clearRect(0,0,h,u);const m=new No(v);if(m.setStarPoints(i.starPoints),m.setRoll(i.rollRad),m.paintInto(n,o,l,e.ghost),d&&!p){d.needsUpdate=!0;return}d?.dispose();const g=new Is(f);g.colorSpace=Gi,g.minFilter=oe,g.generateMipmaps=!1,t.material.map=g,t.material.needsUpdate=!0}static signatureOf(t,e){const{bounds:i}=t;return JSON.stringify([t.kind,Math.round(i.width*10),Math.round(i.height*10),t.color,t.angle,t.transparency,t.haloScale,t.blur??0,t.brightness??0,t.kind==="polygon"?t.points:void 0,e.scale,e.starPoints,e.rollRad])}dispose(t){t.removeFromParent(),t.geometry.dispose(),t.material.map?.dispose(),t.material.dispose()}clear(){for(const t of this.meshes.values())this.dispose(t);this.meshes.clear(),this.signatures.clear(),this.extents.clear(),this.placed=[]}}const H1=3,Xc=800,co=Math.PI/180;class Rn{constructor(t,e,i=Rn.fetchImage){this.scene=t,this.onImageLoaded=e,this.loadImage=i}meshes=new Map;signatures=new Map;images=new Map;loading=new Map;failed=new Set;references=[];views=new Map;shown=!0;observerAt;static PRESENT_WITHIN_M=2;static GONE_BEYOND_M=20;static presenceAt(t,e){if(!t.from||!e)return 1;const i=ai(e.lat,e.lng,t.from.lat,t.from.lng),s=(Math.hypot(i.x,i.z)-Rn.PRESENT_WITHIN_M)/(Rn.GONE_BEYOND_M-Rn.PRESENT_WITHIN_M),a=Math.min(Math.max(s,0),1);return 1-a*a*(3-2*a)}set(t,e=this.views,i){this.references=t,this.observerAt=i,this.views=e;const n=new Set(t.map(s=>s.id));for(const[s,a]of this.meshes)n.has(s)||(this.dispose(a),this.meshes.delete(s),this.signatures.delete(s));for(const[s,a]of this.images){const o=t.find(c=>c.id===s);o&&o.src===a.texture.userData.src||(a.texture.dispose(),this.images.delete(s))}for(const s of t){const a=this.images.get(s.id);if(!a){this.load(s);continue}this.build(s,a)}}setShown(t){this.shown=t;for(const e of this.meshes.values())e.visible=t&&this.opacityOf(e.userData.id)>0}setView(t,e){this.views.set(t,e);const i=this.meshes.get(t);i&&this.applyOpacity(i,t)}get any(){for(const t of this.meshes.values())if(t.visible)return!0;return!1}place(t){for(const e of this.meshes.values())e.visible&&(e.position.copy(t.position),e.updateMatrixWorld())}get furthestM(){return this.meshes.size>0?Xc:0}directionOfPixel(t,e,i,n){const s=this.images.get(t.id),a=s?s.width/s.height:1,o=Math.tan(t.registration.fovDeg/2*co),c=o*a;return n.set((e*2-1)*c,(1-i*2)*o,-1).normalize(),n.applyQuaternion(Rn.orientation(t))}aspectOf(t){const e=this.images.get(t);return e?e.width/e.height:void 0}failedToLoad(t){return this.failed.has(t)}load(t){const e=t.src;if(this.loading.has(t.id)||this.failed.has(e))return;const i=this.loadImage(e).then(n=>{this.loading.delete(t.id);const s=this.references.find(a=>a.id===t.id);if(!s||s.src!==e){n.texture.dispose();return}n.texture.userData.src=e,this.images.set(t.id,n),this.build(s,n),this.onImageLoaded()},()=>{this.loading.delete(t.id),this.failed.add(e)});this.loading.set(t.id,i)}static async fetchImage(t){const e=await fetch(t);if(!e.ok)throw new Error(`${t}: ${e.status}`);const i=await createImageBitmap(await e.blob(),{imageOrientation:"flipY"}),n=new bi(i);return n.flipY=!1,n.colorSpace=Gi,n.minFilter=oe,n.magFilter=oe,n.generateMipmaps=!1,n.needsUpdate=!0,{texture:n,width:i.width,height:i.height}}build(t,e){const i=Rn.signatureOf(t,e);let n=this.meshes.get(t.id);if(n&&this.signatures.get(t.id)===i){this.applyOpacity(n,t.id);return}n&&(this.dispose(n),this.meshes.delete(t.id)),n=new Dt(Rn.geometryOf(t,e),new _n({map:e.texture,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),t.kind==="panorama"&&(n.material.side=Ve),n.frustumCulled=!1,n.layers.set(H1),n.userData.id=t.id,n.quaternion.copy(Rn.orientation(t)),this.scene.add(n),this.meshes.set(t.id,n),this.signatures.set(t.id,i),this.applyOpacity(n,t.id)}static geometryOf(t,e){if(t.kind==="panorama"){const a=new oi(Xc,64,32,Math.PI/2,Math.PI*2),o=a.attributes.uv;for(let c=0;c<o.count;c++)o.setX(c,1-o.getX(c));return o.needsUpdate=!0,a}const i=2*Xc*Math.tan(t.registration.fovDeg/2*co),n=i*(e.width/Math.max(e.height,1)),s=new Xi(n,i);return s.translate(0,0,-Xc),s}static orientation(t){const{headingDeg:e,pitchDeg:i,rollDeg:n}=t.registration,s=new Be;return s.rotation.set(i*co,-e*co,-(n??0)*co,"YXZ"),s.quaternion}opacityOf(t){const e=this.references.find(s=>s.id===t),i=this.views.get(t),n=e?Rn.presenceAt(e,this.observerAt):1;return(i?.opacity??e?.opacity??0)*n}applyOpacity(t,e){const i=this.opacityOf(e);t.material.opacity=i,t.visible=this.shown&&i>0}static signatureOf(t,e){const{headingDeg:i,pitchDeg:n,rollDeg:s,fovDeg:a}=t.registration;return[t.kind,t.src,e.width,e.height,i,n,s??0,a].join("|")}dispose(t){this.scene.remove(t),t.geometry.dispose(),t.material.dispose()}disposeAll(){for(const t of this.meshes.values())this.dispose(t);this.meshes.clear(),this.signatures.clear();for(const t of this.images.values())t.texture.dispose();this.images.clear()}}class Ft{static GROUND_RADIUS_M=636e4;static TOP_RADIUS_M=646e4;static WAVELENGTHS_NM=Array.from({length:15},(t,e)=>410+20*e);static WAVELENGTH_STEP_NM=20;static SOLAR_IRRADIANCE=[1.707,1.676,1.982,2.02,1.941,1.87,1.879,1.856,1.839,1.799,1.728,1.668,1.57,1.532,1.452];static OZONE_CROSS_SECTION=[.021,.069,.19,.418,.827,1.531,2.439,3.291,4.468,4.55,4.663,3.477,2.447,1.658,1.071];static RAYLEIGH_SCALE_HEIGHT_M=8e3;static AEROSOL_SCALE_HEIGHT_M=1200;static OZONE_PEAK_ALTITUDE_M=25e3;static OZONE_HALF_WIDTH_M=15e3;static DEFAULT_AEROSOL_OPTICAL_DEPTH=.1;static DEFAULT_OZONE_DOBSON=300;static AEROSOL_SINGLE_SCATTERING_ALBEDO=.9;static AEROSOL_ANGSTROM_EXPONENT=1.3;static AEROSOL_ASYMMETRY=.8;rayleighScattering;aerosolScattering;aerosolExtinction;ozoneAbsorption;constructor(t={}){const e=Ft.WAVELENGTHS_NM.length,i=t.aerosolOpticalDepth??Ft.DEFAULT_AEROSOL_OPTICAL_DEPTH,n=t.ozoneDobson??Ft.DEFAULT_OZONE_DOBSON;this.rayleighScattering=new Float64Array(e),this.aerosolScattering=new Float64Array(e),this.aerosolExtinction=new Float64Array(e),this.ozoneAbsorption=new Float64Array(e);const s=n*2687e17/Ft.OZONE_HALF_WIDTH_M;for(let a=0;a<e;a++){const o=Ft.WAVELENGTHS_NM[a];this.rayleighScattering[a]=Ft.rayleighAt(o);const c=i/Ft.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosolExtinction[a]=c,this.aerosolScattering[a]=c*Ft.AEROSOL_SINGLE_SCATTERING_ALBEDO,this.ozoneAbsorption[a]=Ft.OZONE_CROSS_SECTION[a]*1e-25*s}}static rayleighAt(t){const e=t/1e3,i=1/(e*e),n=e*e;return(1.0455996-341.29061*i-.9023085*n)/(1+.0027059889*i-85.968563*n)*1e-28*1e-4*2546899e19}static rayleighDensity(t){return Math.exp(-Math.max(t,0)/Ft.RAYLEIGH_SCALE_HEIGHT_M)}static aerosolDensity(t){return Math.exp(-Math.max(t,0)/Ft.AEROSOL_SCALE_HEIGHT_M)}static ozoneDensity(t){return Math.max(0,1-Math.abs(t-Ft.OZONE_PEAK_ALTITUDE_M)/Ft.OZONE_HALF_WIDTH_M)}static rayleighPhase(t){return 3/(16*Math.PI)*(1+t*t)}static aerosolPhase(t,e=Ft.AEROSOL_ASYMMETRY){const i=e*e;return 3/(8*Math.PI)*(1-i)*(1+t*t)/((2+i)*Math.pow(Math.max(1+i-2*e*t,1e-6),1.5))}}class Wt{static TRANSMITTANCE_WIDTH=256;static TRANSMITTANCE_HEIGHT=64;static MULTIPLE_SIZE=64;static MULTIPLE_ROWS=16;static MULTIPLE_HEIGHT_POWER=2;static MULTIPLE_DIRECTIONS=16;static SKY_VIEW_WIDTH=192;static SKY_VIEW_HEIGHT=108;static STEPS=40;static MULTIPLE_STEPS=12;static GROUND_ALBEDO=.3;supported;renderer;transmittance;multiple;sunView;moonView;scene=new Ts;camera=new Un(-1,1,1,-1,0,1);quad;transmittanceMaterial;multipleMaterial;skyViewMaterial;transmittanceReady=!1;multipleRows=0;multipleColumn=0;mediumKey="";static MULTIPLE_BLOCK=16;static shared=new Map;building=!1;adopted;tableUniforms;constructor(t){this.renderer=t,this.supported=t.capabilities.isWebGL2&&t.extensions.has("EXT_color_buffer_float"),this.transmittance=new ri(Wt.TRANSMITTANCE_WIDTH,Wt.TRANSMITTANCE_HEIGHT,{count:4,type:qe,minFilter:oe,magFilter:oe,depthBuffer:!1}),this.multiple=new ri(Wt.MULTIPLE_SIZE,Wt.MULTIPLE_ROWS,{count:4,type:Oi,minFilter:Re,magFilter:Re,depthBuffer:!1});const e=()=>new ri(Wt.SKY_VIEW_WIDTH,Wt.SKY_VIEW_HEIGHT,{type:Oi,minFilter:Re,magFilter:Re,depthBuffer:!1});this.sunView=e(),this.moonView=e();const i=Wt.mediumUniforms(),n=this.tableUniforms={uT0:{value:this.transmittance.textures[0]},uT1:{value:this.transmittance.textures[1]},uT2:{value:this.transmittance.textures[2]},uT3:{value:this.transmittance.textures[3]},uM0:{value:this.multiple.textures[0]},uM1:{value:this.multiple.textures[1]},uM2:{value:this.multiple.textures[2]},uM3:{value:this.multiple.textures[3]}},s=(a,o={})=>new Xg({glslVersion:_l,uniforms:{...i,...n,...o},vertexShader:Wt.VERTEX,fragmentShader:a,depthTest:!1,depthWrite:!1});this.transmittanceMaterial=s(Wt.TRANSMITTANCE_FRAGMENT),this.multipleMaterial=s(Wt.MULTIPLE_FRAGMENT),this.skyViewMaterial=s(Wt.SKY_VIEW_FRAGMENT,{uObserverRadius:{value:Ft.GROUND_RADIUS_M+2},uSourceMu:{value:1}}),this.quad=new Dt(new Xi(2,2),this.transmittanceMaterial),this.quad.frustumCulled=!1,this.scene.add(this.quad)}get transmittanceTextures(){return this.transmittance.textures}get sunViewTexture(){return this.sunView.texture}get moonViewTexture(){return this.moonView.texture}get ready(){return this.supported&&(this.adopted!==void 0||this.transmittanceReady&&this.multipleRows>=Wt.MULTIPLE_ROWS)}setMedium(t){const e=[t.rayleighScattering,t.aerosolScattering,t.aerosolExtinction,t.ozoneAbsorption].map(n=>Array.from(n,s=>s.toPrecision(6)).join(",")).join("|");if(e===this.mediumKey)return;this.abandonBuilding(),this.releaseAdopted(),this.mediumKey=e;const i=(n,s)=>{const a=this.transmittanceMaterial.uniforms[n].value;for(let o=0;o<4;o++)a[o].set(s[o*4]??0,s[o*4+1]??0,s[o*4+2]??0,s[o*4+3]??0)};i("uRayleigh",t.rayleighScattering),i("uAerosolScattering",t.aerosolScattering),i("uAerosolExtinction",t.aerosolExtinction),i("uOzone",t.ozoneAbsorption),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0}invalidate(){this.adopted||(this.abandonBuilding(),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0)}advance(t){if(!this.supported||!this.mediumKey)return!1;if(this.ready)return!0;const e=Wt.shared.get(this.mediumKey);if(e&&e!=="building")return this.adopt(e),!0;if(e==="building"&&!this.building)return!1;e||(Wt.shared.set(this.mediumKey,"building"),this.building=!0);const i=this.renderer.getRenderTarget();let n=Math.max(1,t);this.transmittanceReady||(this.draw(this.transmittanceMaterial,this.transmittance),this.transmittanceReady=!0,n--);const s=Wt.MULTIPLE_SIZE,a=Wt.MULTIPLE_BLOCK;for(;n>0&&this.multipleRows<Wt.MULTIPLE_ROWS;n--)this.multiple.scissor.set(this.multipleColumn,this.multipleRows,a,1),this.multiple.scissorTest=!0,this.draw(this.multipleMaterial,this.multiple),this.multipleColumn+=a,this.multipleColumn>=s&&(this.multipleColumn=0,this.multipleRows++);return this.multiple.scissorTest=!1,this.renderer.setRenderTarget(i),this.ready&&this.building&&this.share(this.mediumKey),this.ready}async share(t){this.building=!1;try{const e=await Promise.all([0,1,2,3].map(n=>this.readRaw(this.transmittance,n,Uint16Array))),i=await Promise.all([0,1,2,3].map(n=>this.readRaw(this.multiple,n,Float32Array)));this.mediumKey===t?Wt.shared.set(t,{transmittance:e,multiple:i}):Wt.shared.delete(t)}catch{Wt.shared.delete(t)}}async readRaw(t,e,i){const n=new i(t.width*t.height*4);return await this.renderer.readRenderTargetPixelsAsync(t,0,0,t.width,t.height,n,void 0,e),n}adopt(t){const e=(s,a,o,c)=>{const l=new ra(s,a,o,Ei,c?qe:Oi);return l.minFilter=l.magFilter=c?oe:Re,l.needsUpdate=!0,l},i=t.transmittance.map(s=>e(s,Wt.TRANSMITTANCE_WIDTH,Wt.TRANSMITTANCE_HEIGHT,!0)),n=t.multiple.map(s=>e(s,Wt.MULTIPLE_SIZE,Wt.MULTIPLE_ROWS,!1));i.forEach((s,a)=>this.tableUniforms[`uT${a}`].value=s),n.forEach((s,a)=>this.tableUniforms[`uM${a}`].value=s),this.adopted=[...i,...n]}releaseAdopted(){if(this.adopted){for(const t of this.adopted)t.dispose();this.adopted=void 0;for(let t=0;t<4;t++)this.tableUniforms[`uT${t}`].value=this.transmittance.textures[t],this.tableUniforms[`uM${t}`].value=this.multiple.textures[t]}}abandonBuilding(){this.building&&(this.building=!1,Wt.shared.get(this.mediumKey)==="building"&&Wt.shared.delete(this.mediumKey))}renderSkyViews(t,e,i){if(!this.ready)return;const n=this.renderer.getRenderTarget(),s=this.skyViewMaterial.uniforms;s.uObserverRadius.value=Ft.GROUND_RADIUS_M+Math.max(t,2),s.uSourceMu.value=Math.sin(e*Math.PI/180),this.draw(this.skyViewMaterial,this.sunView),s.uSourceMu.value=Math.sin(i*Math.PI/180),this.draw(this.skyViewMaterial,this.moonView),this.renderer.setRenderTarget(n)}static skyViewUv(t,e,i){const n=Ft.GROUND_RADIUS_M+Math.max(t,2),s=Ft.GROUND_RADIUS_M,a=Math.acos(Math.min(Math.sqrt(Math.max(n*n-s*s,0))/n,1)),o=Math.PI-a,c=e<o?.5*(1-Math.sqrt(Math.max(1-e/o,0))):.5+.5*Math.sqrt(Math.min((e-o)/a,1));return{u:Math.min(Math.max(Math.abs(i)/Math.PI,0),1),v:c}}async readTable(t,e){if(t==="multiple"){const s=new Float32Array(this.multiple.width*this.multiple.height*4);return await this.renderer.readRenderTargetPixelsAsync(this.multiple,0,0,this.multiple.width,this.multiple.height,s,void 0,e),s}const i=this.transmittance,n=new Uint16Array(i.width*i.height*4);return await this.renderer.readRenderTargetPixelsAsync(i,0,0,i.width,i.height,n,void 0,e),Float32Array.from(n,s=>Fn.fromHalfFloat(s))}readSkyViewNow(t){const e=t==="sun"?this.sunView:this.moonView,i=new Float32Array(e.width*e.height*4),n=this.renderer.getContext();return n.bindBuffer(n.PIXEL_PACK_BUFFER,null),this.renderer.readRenderTargetPixels(e,0,0,e.width,e.height,i),i}async readSkyView(t){const e=t==="sun"?this.sunView:this.moonView,i=new Float32Array(e.width*e.height*4);return await this.renderer.readRenderTargetPixelsAsync(e,0,0,e.width,e.height,i),i}dispose(){this.abandonBuilding(),this.releaseAdopted(),this.transmittance.dispose(),this.multiple.dispose(),this.sunView.dispose(),this.moonView.dispose(),this.transmittanceMaterial.dispose(),this.multipleMaterial.dispose(),this.skyViewMaterial.dispose(),this.quad.geometry.dispose()}draw(t,e){this.quad.material=t,this.renderer.setRenderTarget(e),this.renderer.render(this.scene,this.camera)}static mediumUniforms(){const t=()=>[new ne,new ne,new ne,new ne],e=(i,n)=>{const s=t();return Ft.WAVELENGTHS_NM.forEach((a,o)=>{s[Math.floor(o/4)].setComponent(o%4,i(a)*n*Ft.WAVELENGTH_STEP_NM*Ft.SOLAR_IRRADIANCE[o])}),s};return{uRayleigh:{value:t()},uAerosolScattering:{value:t()},uAerosolExtinction:{value:t()},uOzone:{value:t()},uCieX:{value:e(i=>mi.colourMatching(i)[0],683)},uCieY:{value:e(i=>mi.colourMatching(i)[1],683)},uCieZ:{value:e(i=>mi.colourMatching(i)[2],683)},uScotopic:{value:e(i=>mi.scotopic(i),1700)}}}static VERTEX=`
7147
+ `}),n.fragmentShader=s+n.fragmentShader,n.fragmentShader=n.fragmentShader.replace("#include <opaque_fragment>",a+"#include <opaque_fragment>")},t.needsUpdate=!0}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new R;up=new R;lookAt=new Jt;vertex=new R;centre=new R;right=new R;above=new R;set(t,e){this.placed=t,this.frame=e;const i=new Set(t.map(n=>n.sourceId));for(const[n,s]of this.meshes)i.has(n)||(this.dispose(s),this.meshes.delete(n),this.signatures.delete(n),this.extents.delete(n));for(const n of t){let s=this.meshes.get(n.sourceId);s||(s=new Dt(new Xi(1,1,In.SEGMENTS,In.SEGMENTS),new _n({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),this.configureCloudMaterial(s.material),s.frustumCulled=!1,s.layers.set(B1),this.scene.add(s),this.meshes.set(n.sourceId,s)),s.renderOrder=D5+n.renderOrder,s.visible=!n.hidden&&n.shape.transparency<1,s.visible&&this.paint(s,n,e)}}place(t,e,i){const n=this.frame;if(n)for(const s of this.placed){const a=this.meshes.get(s.sourceId);if(!a||!a.visible)continue;const o=this.extents.get(s.sourceId);if(!o)continue;const{bounds:c}=s.shape;let l=c.x+c.width/2,h=c.y+c.height/2,u=!0;if(s.aim){const d=i(In.directionOf(s.aim,this.direction));d&&Math.abs(d.ndcX)<In.FURTHEST_NDC&&Math.abs(d.ndcY)<In.FURTHEST_NDC?(l=(d.ndcX+1)/2*n.canvasWidthPx,h=(1-d.ndcY)/2*n.canvasHeightPx):u=!1}u?this.curve(a,t,e,n,o,l,h,s.distanceM):this.flat(a,t,n,o,s.distanceM)}}static FURTHEST_NDC=4;curve(t,e,i,n,s,a,o,c){const l=a-s.width/2,h=o-s.height/2,u=t.geometry.attributes.position,d=In.SEGMENTS;let f=0;for(let p=0;p<=d;p++){const v=h+p/d*s.height;for(let m=0;m<=d;m++){const g=l+m/d*s.width;i(g/n.canvasWidthPx*2-1,-(v/n.canvasHeightPx*2-1),this.direction),this.vertex.copy(e.position).addScaledVector(this.direction,c),u.setXYZ(f++,this.vertex.x,this.vertex.y,this.vertex.z)}}u.needsUpdate=!0,t.matrixAutoUpdate=!1,t.matrix.identity(),t.matrixWorldNeedsUpdate=!0,t.scale.set(Te.sizeMAt(c,n.projection.pxToDeg(s.width)),Te.sizeMAt(c,n.projection.pxToDeg(s.height)),1)}flat(t,e,i,n,s){const a=t.geometry.attributes.position,o=In.SEGMENTS,c=Te.sizeMAt(s,i.projection.pxToDeg(n.width)),l=Te.sizeMAt(s,i.projection.pxToDeg(n.height));this.up.set(0,1,0).applyQuaternion(e.quaternion),this.centre.copy(e.position).addScaledVector(this.direction,s),this.lookAt.lookAt(e.position,this.centre,this.up),this.right.setFromMatrixColumn(this.lookAt,0),this.above.setFromMatrixColumn(this.lookAt,1);let h=0;for(let u=0;u<=o;u++){const d=.5-u/o;for(let f=0;f<=o;f++){const p=f/o-.5;this.vertex.copy(this.centre).addScaledVector(this.right,p*c).addScaledVector(this.above,d*l),a.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}a.needsUpdate=!0,t.matrixAutoUpdate=!1,t.matrix.identity(),t.matrixWorldNeedsUpdate=!0,t.scale.set(c,l,1)}static SEGMENTS=16;static directionOf(t,e){const i=t.azimuthDeg*Math.PI/180,n=t.altitudeDeg*Math.PI/180;return e.set(Math.sin(i)*Math.cos(n),Math.sin(n),-Math.cos(i)*Math.cos(n))}get any(){for(const t of this.meshes.values())if(t.visible)return!0;return!1}get furthestM(){return this.placed.reduce((t,e)=>Math.max(t,e.distanceM),0)}paint(t,e,i){const{shape:n}=e,s=No.paintExtent(n),a=e.ghost?3:0,o={x:s.x-a,y:s.y-a,width:s.width+2*a,height:s.height+2*a};this.extents.set(e.sourceId,o);const c=`${In.signatureOf(n,i)}|${e.ghost?"ghost":""}`;if(this.signatures.get(e.sourceId)===c&&t.material.map)return;this.signatures.set(e.sourceId,c);const l=Math.min(i.scale,I5/Math.max(o.width,o.height,1)),h=Math.max(1,Math.ceil(o.width*l)),u=Math.max(1,Math.ceil(o.height*l)),d=t.material.map,f=d?.image??document.createElement("canvas"),p=f.width!==h||f.height!==u;p&&(f.width=h,f.height=u);const v=f.getContext("2d");if(!v)return;v.clearRect(0,0,h,u);const m=new No(v);if(m.setStarPoints(i.starPoints),m.setRoll(i.rollRad),m.paintInto(n,o,l,e.ghost),d&&!p){d.needsUpdate=!0;return}d?.dispose();const g=new Is(f);g.colorSpace=Gi,g.minFilter=oe,g.generateMipmaps=!1,t.material.map=g,t.material.needsUpdate=!0}static signatureOf(t,e){const{bounds:i}=t;return JSON.stringify([t.kind,Math.round(i.width*10),Math.round(i.height*10),t.color,t.angle,t.transparency,t.haloScale,t.blur??0,t.brightness??0,t.kind==="polygon"?t.points:void 0,e.scale,e.starPoints,e.rollRad])}dispose(t){t.removeFromParent(),t.geometry.dispose(),t.material.map?.dispose(),t.material.dispose()}clear(){for(const t of this.meshes.values())this.dispose(t);this.meshes.clear(),this.signatures.clear(),this.extents.clear(),this.placed=[]}}const H1=3,Xc=800,co=Math.PI/180;class Rn{constructor(t,e,i=Rn.fetchImage){this.scene=t,this.onImageLoaded=e,this.loadImage=i}meshes=new Map;signatures=new Map;images=new Map;loading=new Map;failed=new Set;references=[];views=new Map;shown=!0;observerAt;static PRESENT_WITHIN_M=2;static GONE_BEYOND_M=20;static presenceAt(t,e){if(!t.from||!e)return 1;const i=ai(e.lat,e.lng,t.from.lat,t.from.lng),s=(Math.hypot(i.x,i.z)-Rn.PRESENT_WITHIN_M)/(Rn.GONE_BEYOND_M-Rn.PRESENT_WITHIN_M),a=Math.min(Math.max(s,0),1);return 1-a*a*(3-2*a)}set(t,e=this.views,i){this.references=t,this.observerAt=i,this.views=e;const n=new Set(t.map(s=>s.id));for(const[s,a]of this.meshes)n.has(s)||(this.dispose(a),this.meshes.delete(s),this.signatures.delete(s));for(const[s,a]of this.images){const o=t.find(c=>c.id===s);o&&o.src===a.texture.userData.src||(a.texture.dispose(),this.images.delete(s))}for(const s of t){const a=this.images.get(s.id);if(!a){this.load(s);continue}this.build(s,a)}}setShown(t){this.shown=t;for(const e of this.meshes.values())e.visible=t&&this.opacityOf(e.userData.id)>0}setView(t,e){this.views.set(t,e);const i=this.meshes.get(t);i&&this.applyOpacity(i,t)}get any(){for(const t of this.meshes.values())if(t.visible)return!0;return!1}place(t){for(const e of this.meshes.values())e.visible&&(e.position.copy(t.position),e.updateMatrixWorld())}get furthestM(){return this.meshes.size>0?Xc:0}directionOfPixel(t,e,i,n){const s=this.images.get(t.id),a=s?s.width/s.height:1,o=Math.tan(t.registration.fovDeg/2*co),c=o*a;return n.set((e*2-1)*c,(1-i*2)*o,-1).normalize(),n.applyQuaternion(Rn.orientation(t))}aspectOf(t){const e=this.images.get(t);return e?e.width/e.height:void 0}failedToLoad(t){return this.failed.has(t)}load(t){const e=t.src;if(this.loading.has(t.id)||this.failed.has(e))return;const i=this.loadImage(e).then(n=>{this.loading.delete(t.id);const s=this.references.find(a=>a.id===t.id);if(!s||s.src!==e){n.texture.dispose();return}n.texture.userData.src=e,this.images.set(t.id,n),this.build(s,n),this.onImageLoaded()},()=>{this.loading.delete(t.id),this.failed.add(e)});this.loading.set(t.id,i)}static async fetchImage(t){const e=await fetch(t);if(!e.ok)throw new Error(`${t}: ${e.status}`);const i=await createImageBitmap(await e.blob(),{imageOrientation:"flipY"}),n=new bi(i);return n.flipY=!1,n.colorSpace=Gi,n.minFilter=oe,n.magFilter=oe,n.generateMipmaps=!1,n.needsUpdate=!0,{texture:n,width:i.width,height:i.height}}build(t,e){const i=Rn.signatureOf(t,e);let n=this.meshes.get(t.id);if(n&&this.signatures.get(t.id)===i){this.applyOpacity(n,t.id);return}n&&(this.dispose(n),this.meshes.delete(t.id)),n=new Dt(Rn.geometryOf(t,e),new _n({map:e.texture,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),t.kind==="panorama"&&(n.material.side=Ve),n.frustumCulled=!1,n.layers.set(H1),n.userData.id=t.id,n.quaternion.copy(Rn.orientation(t)),this.scene.add(n),this.meshes.set(t.id,n),this.signatures.set(t.id,i),this.applyOpacity(n,t.id)}static geometryOf(t,e){if(t.kind==="panorama"){const a=new oi(Xc,64,32,Math.PI/2,Math.PI*2),o=a.attributes.uv;for(let c=0;c<o.count;c++)o.setX(c,1-o.getX(c));return o.needsUpdate=!0,a}const i=2*Xc*Math.tan(t.registration.fovDeg/2*co),n=i*(e.width/Math.max(e.height,1)),s=new Xi(n,i);return s.translate(0,0,-Xc),s}static orientation(t){const{headingDeg:e,pitchDeg:i,rollDeg:n}=t.registration,s=new Be;return s.rotation.set(i*co,-e*co,-(n??0)*co,"YXZ"),s.quaternion}opacityOf(t){const e=this.references.find(s=>s.id===t),i=this.views.get(t),n=e?Rn.presenceAt(e,this.observerAt):1;return(i?.opacity??e?.opacity??0)*n}applyOpacity(t,e){const i=this.opacityOf(e);t.material.opacity=i,t.visible=this.shown&&i>0}static signatureOf(t,e){const{headingDeg:i,pitchDeg:n,rollDeg:s,fovDeg:a}=t.registration;return[t.kind,t.src,e.width,e.height,i,n,s??0,a].join("|")}dispose(t){this.scene.remove(t),t.geometry.dispose(),t.material.dispose()}disposeAll(){for(const t of this.meshes.values())this.dispose(t);this.meshes.clear(),this.signatures.clear();for(const t of this.images.values())t.texture.dispose();this.images.clear()}}class Ft{static GROUND_RADIUS_M=636e4;static TOP_RADIUS_M=646e4;static WAVELENGTHS_NM=Array.from({length:15},(t,e)=>410+20*e);static WAVELENGTH_STEP_NM=20;static SOLAR_IRRADIANCE=[1.707,1.676,1.982,2.02,1.941,1.87,1.879,1.856,1.839,1.799,1.728,1.668,1.57,1.532,1.452];static OZONE_CROSS_SECTION=[.021,.069,.19,.418,.827,1.531,2.439,3.291,4.468,4.55,4.663,3.477,2.447,1.658,1.071];static RAYLEIGH_SCALE_HEIGHT_M=8e3;static AEROSOL_SCALE_HEIGHT_M=1200;static OZONE_PEAK_ALTITUDE_M=25e3;static OZONE_HALF_WIDTH_M=15e3;static DEFAULT_AEROSOL_OPTICAL_DEPTH=.1;static DEFAULT_OZONE_DOBSON=300;static AEROSOL_SINGLE_SCATTERING_ALBEDO=.9;static AEROSOL_ANGSTROM_EXPONENT=1.3;static AEROSOL_ASYMMETRY=.8;rayleighScattering;aerosolScattering;aerosolExtinction;ozoneAbsorption;constructor(t={}){const e=Ft.WAVELENGTHS_NM.length,i=t.aerosolOpticalDepth??Ft.DEFAULT_AEROSOL_OPTICAL_DEPTH,n=t.ozoneDobson??Ft.DEFAULT_OZONE_DOBSON;this.rayleighScattering=new Float64Array(e),this.aerosolScattering=new Float64Array(e),this.aerosolExtinction=new Float64Array(e),this.ozoneAbsorption=new Float64Array(e);const s=n*2687e17/Ft.OZONE_HALF_WIDTH_M;for(let a=0;a<e;a++){const o=Ft.WAVELENGTHS_NM[a];this.rayleighScattering[a]=Ft.rayleighAt(o);const c=i/Ft.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosolExtinction[a]=c,this.aerosolScattering[a]=c*Ft.AEROSOL_SINGLE_SCATTERING_ALBEDO,this.ozoneAbsorption[a]=Ft.OZONE_CROSS_SECTION[a]*1e-25*s}}static rayleighAt(t){const e=t/1e3,i=1/(e*e),n=e*e;return(1.0455996-341.29061*i-.9023085*n)/(1+.0027059889*i-85.968563*n)*1e-28*1e-4*2546899e19}static rayleighDensity(t){return Math.exp(-Math.max(t,0)/Ft.RAYLEIGH_SCALE_HEIGHT_M)}static aerosolDensity(t){return Math.exp(-Math.max(t,0)/Ft.AEROSOL_SCALE_HEIGHT_M)}static ozoneDensity(t){return Math.max(0,1-Math.abs(t-Ft.OZONE_PEAK_ALTITUDE_M)/Ft.OZONE_HALF_WIDTH_M)}static rayleighPhase(t){return 3/(16*Math.PI)*(1+t*t)}static aerosolPhase(t,e=Ft.AEROSOL_ASYMMETRY){const i=e*e;return 3/(8*Math.PI)*(1-i)*(1+t*t)/((2+i)*Math.pow(Math.max(1+i-2*e*t,1e-6),1.5))}}class Wt{static TRANSMITTANCE_WIDTH=256;static TRANSMITTANCE_HEIGHT=64;static MULTIPLE_SIZE=64;static MULTIPLE_ROWS=16;static MULTIPLE_HEIGHT_POWER=2;static MULTIPLE_DIRECTIONS=16;static SKY_VIEW_WIDTH=192;static SKY_VIEW_HEIGHT=108;static STEPS=40;static MULTIPLE_STEPS=12;static GROUND_ALBEDO=.3;supported;renderer;transmittance;multiple;sunView;moonView;scene=new Ts;camera=new Un(-1,1,1,-1,0,1);quad;transmittanceMaterial;multipleMaterial;skyViewMaterial;transmittanceReady=!1;multipleRows=0;multipleColumn=0;mediumKey="";static MULTIPLE_BLOCK=16;static shared=new Map;building=!1;adopted;tableUniforms;constructor(t){this.renderer=t,this.supported=t.capabilities.isWebGL2&&t.extensions.has("EXT_color_buffer_float"),this.transmittance=new ri(Wt.TRANSMITTANCE_WIDTH,Wt.TRANSMITTANCE_HEIGHT,{count:4,type:qe,minFilter:oe,magFilter:oe,depthBuffer:!1}),this.multiple=new ri(Wt.MULTIPLE_SIZE,Wt.MULTIPLE_ROWS,{count:4,type:Oi,minFilter:Re,magFilter:Re,depthBuffer:!1});const e=()=>new ri(Wt.SKY_VIEW_WIDTH,Wt.SKY_VIEW_HEIGHT,{type:Oi,minFilter:Re,magFilter:Re,depthBuffer:!1});this.sunView=e(),this.moonView=e();const i=Wt.mediumUniforms(),n=this.tableUniforms={uT0:{value:this.transmittance.textures[0]},uT1:{value:this.transmittance.textures[1]},uT2:{value:this.transmittance.textures[2]},uT3:{value:this.transmittance.textures[3]},uM0:{value:this.multiple.textures[0]},uM1:{value:this.multiple.textures[1]},uM2:{value:this.multiple.textures[2]},uM3:{value:this.multiple.textures[3]}},s=(a,o={})=>new Xg({glslVersion:_l,uniforms:{...i,...n,...o},vertexShader:Wt.VERTEX,fragmentShader:a,depthTest:!1,depthWrite:!1});this.transmittanceMaterial=s(Wt.TRANSMITTANCE_FRAGMENT),this.multipleMaterial=s(Wt.MULTIPLE_FRAGMENT),this.skyViewMaterial=s(Wt.SKY_VIEW_FRAGMENT,{uObserverRadius:{value:Ft.GROUND_RADIUS_M+2},uSourceMu:{value:1}}),this.quad=new Dt(new Xi(2,2),this.transmittanceMaterial),this.quad.frustumCulled=!1,this.scene.add(this.quad)}get transmittanceTextures(){return this.transmittance.textures}get sunViewTexture(){return this.sunView.texture}get moonViewTexture(){return this.moonView.texture}get ready(){return this.supported&&(this.adopted!==void 0||this.transmittanceReady&&this.multipleRows>=Wt.MULTIPLE_ROWS)}setMedium(t){const e=[t.rayleighScattering,t.aerosolScattering,t.aerosolExtinction,t.ozoneAbsorption].map(n=>Array.from(n,s=>s.toPrecision(6)).join(",")).join("|");if(e===this.mediumKey)return;this.abandonBuilding(),this.releaseAdopted(),this.mediumKey=e;const i=(n,s)=>{const a=this.transmittanceMaterial.uniforms[n].value;for(let o=0;o<4;o++)a[o].set(s[o*4]??0,s[o*4+1]??0,s[o*4+2]??0,s[o*4+3]??0)};i("uRayleigh",t.rayleighScattering),i("uAerosolScattering",t.aerosolScattering),i("uAerosolExtinction",t.aerosolExtinction),i("uOzone",t.ozoneAbsorption),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0}invalidate(){this.adopted||(this.abandonBuilding(),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0)}advance(t){if(!this.supported||!this.mediumKey)return!1;if(this.ready)return!0;const e=Wt.shared.get(this.mediumKey);if(e&&e!=="building")return this.adopt(e),!0;if(e==="building"&&!this.building)return!1;e||(Wt.shared.set(this.mediumKey,"building"),this.building=!0);const i=this.renderer.getRenderTarget();let n=Math.max(1,t);this.transmittanceReady||(this.draw(this.transmittanceMaterial,this.transmittance),this.transmittanceReady=!0,n--);const s=Wt.MULTIPLE_SIZE,a=Wt.MULTIPLE_BLOCK;for(;n>0&&this.multipleRows<Wt.MULTIPLE_ROWS;n--)this.multiple.scissor.set(this.multipleColumn,this.multipleRows,a,1),this.multiple.scissorTest=!0,this.draw(this.multipleMaterial,this.multiple),this.multipleColumn+=a,this.multipleColumn>=s&&(this.multipleColumn=0,this.multipleRows++);return this.multiple.scissorTest=!1,this.renderer.setRenderTarget(i),this.ready&&this.building&&this.share(this.mediumKey),this.ready}async share(t){this.building=!1;try{const e=await Promise.all([0,1,2,3].map(n=>this.readRaw(this.transmittance,n,Uint16Array))),i=await Promise.all([0,1,2,3].map(n=>this.readRaw(this.multiple,n,Float32Array)));this.mediumKey===t?Wt.shared.set(t,{transmittance:e,multiple:i}):Wt.shared.delete(t)}catch{Wt.shared.delete(t)}}async readRaw(t,e,i){const n=new i(t.width*t.height*4);return await this.renderer.readRenderTargetPixelsAsync(t,0,0,t.width,t.height,n,void 0,e),n}adopt(t){const e=(s,a,o,c)=>{const l=new ra(s,a,o,Ei,c?qe:Oi);return l.minFilter=l.magFilter=c?oe:Re,l.needsUpdate=!0,l},i=t.transmittance.map(s=>e(s,Wt.TRANSMITTANCE_WIDTH,Wt.TRANSMITTANCE_HEIGHT,!0)),n=t.multiple.map(s=>e(s,Wt.MULTIPLE_SIZE,Wt.MULTIPLE_ROWS,!1));i.forEach((s,a)=>this.tableUniforms[`uT${a}`].value=s),n.forEach((s,a)=>this.tableUniforms[`uM${a}`].value=s),this.adopted=[...i,...n]}releaseAdopted(){if(this.adopted){for(const t of this.adopted)t.dispose();this.adopted=void 0;for(let t=0;t<4;t++)this.tableUniforms[`uT${t}`].value=this.transmittance.textures[t],this.tableUniforms[`uM${t}`].value=this.multiple.textures[t]}}abandonBuilding(){this.building&&(this.building=!1,Wt.shared.get(this.mediumKey)==="building"&&Wt.shared.delete(this.mediumKey))}renderSkyViews(t,e,i){if(!this.ready)return;const n=this.renderer.getRenderTarget(),s=this.skyViewMaterial.uniforms;s.uObserverRadius.value=Ft.GROUND_RADIUS_M+Math.max(t,2),s.uSourceMu.value=Math.sin(e*Math.PI/180),this.draw(this.skyViewMaterial,this.sunView),s.uSourceMu.value=Math.sin(i*Math.PI/180),this.draw(this.skyViewMaterial,this.moonView),this.renderer.setRenderTarget(n)}static skyViewUv(t,e,i){const n=Ft.GROUND_RADIUS_M+Math.max(t,2),s=Ft.GROUND_RADIUS_M,a=Math.acos(Math.min(Math.sqrt(Math.max(n*n-s*s,0))/n,1)),o=Math.PI-a,c=e<o?.5*(1-Math.sqrt(Math.max(1-e/o,0))):.5+.5*Math.sqrt(Math.min((e-o)/a,1));return{u:Math.min(Math.max(Math.abs(i)/Math.PI,0),1),v:c}}async readTable(t,e){if(t==="multiple"){const s=new Float32Array(this.multiple.width*this.multiple.height*4);return await this.renderer.readRenderTargetPixelsAsync(this.multiple,0,0,this.multiple.width,this.multiple.height,s,void 0,e),s}const i=this.transmittance,n=new Uint16Array(i.width*i.height*4);return await this.renderer.readRenderTargetPixelsAsync(i,0,0,i.width,i.height,n,void 0,e),Float32Array.from(n,s=>Fn.fromHalfFloat(s))}readSkyViewNow(t){const e=t==="sun"?this.sunView:this.moonView,i=new Float32Array(e.width*e.height*4),n=this.renderer.getContext();return n.bindBuffer(n.PIXEL_PACK_BUFFER,null),this.renderer.readRenderTargetPixels(e,0,0,e.width,e.height,i),i}async readSkyView(t){const e=t==="sun"?this.sunView:this.moonView,i=new Float32Array(e.width*e.height*4);return await this.renderer.readRenderTargetPixelsAsync(e,0,0,e.width,e.height,i),i}dispose(){this.abandonBuilding(),this.releaseAdopted(),this.transmittance.dispose(),this.multiple.dispose(),this.sunView.dispose(),this.moonView.dispose(),this.transmittanceMaterial.dispose(),this.multipleMaterial.dispose(),this.skyViewMaterial.dispose(),this.quad.geometry.dispose()}draw(t,e){this.quad.material=t,this.renderer.setRenderTarget(e),this.renderer.render(this.scene,this.camera)}static mediumUniforms(){const t=()=>[new ne,new ne,new ne,new ne],e=(i,n)=>{const s=t();return Ft.WAVELENGTHS_NM.forEach((a,o)=>{s[Math.floor(o/4)].setComponent(o%4,i(a)*n*Ft.WAVELENGTH_STEP_NM*Ft.SOLAR_IRRADIANCE[o])}),s};return{uRayleigh:{value:t()},uAerosolScattering:{value:t()},uAerosolExtinction:{value:t()},uOzone:{value:t()},uCieX:{value:e(i=>mi.colourMatching(i)[0],683)},uCieY:{value:e(i=>mi.colourMatching(i)[1],683)},uCieZ:{value:e(i=>mi.colourMatching(i)[2],683)},uScotopic:{value:e(i=>mi.scotopic(i),1700)}}}static VERTEX=`
7091
7148
  in vec3 position;
7092
7149
  void main() {
7093
7150
  gl_Position = vec4(position.xy, 0.0, 1.0);
@@ -7506,7 +7563,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
7506
7563
  vec3 light = texture2D(uMap, vec2((along * (uSteps - 1.0) + 0.5) / uSteps, 0.5)).rgb;
7507
7564
  gl_FragColor = vec4(light, 1.0);
7508
7565
  }
7509
- `,transparent:!0,blending:Ni,depthWrite:!1,side:Ve,fog:!1});this.object=new Dt(new oi(z0.RADIUS,128,32,0,Math.PI*2,0,fe.MAX_ANGLE_RAD),e),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}show(t,e){if(!t||!e){this.object.visible=!1;return}this.towards.set(t.x,t.y,t.z).normalize(),this.object.quaternion.setFromUnitVectors(this.up,this.towards),this.object.material.uniforms.uSource.value.copy(this.towards);for(let i=0;i<fe.STEPS;i++){for(let n=0;n<3;n++)this.texels[i*4+n]=Fn.toHalfFloat(Math.min(e[i*3+n],6e4));this.texels[i*4+3]=Fn.toHalfFloat(1)}this.texture.needsUpdate=!0,this.object.visible=!0}dispose(){this.object.geometry.dispose(),this.object.material.dispose(),this.texture.dispose()}}class Ol{constructor(t){this.generator=t}static SIZE=128;target=new Vo(Ol.SIZE,{type:qe,generateMipmaps:!1,minFilter:oe,magFilter:oe});camera=new S0(.1,2e5,this.target);filteredTarget;capturedAtMs=-1/0;capturedVersion;get sharp(){return this.target.texture}get filtered(){return this.filteredTarget?.texture}capture(t,e,i,n=[]){const s=t.shadowMap.autoUpdate;t.shadowMap.autoUpdate=!1;const a=n.map(o=>o.visible);for(const o of n)o.visible=!1;this.camera.position.copy(i),this.camera.update(t,e),n.forEach((o,c)=>{o.visible=a[c]}),t.shadowMap.autoUpdate=s,this.filteredTarget=this.generator.fromCubemap(this.target.texture,this.filteredTarget),this.capturedAtMs=performance.now()}dispose(){this.target.dispose(),this.filteredTarget?.dispose()}}class on{static REFRESH_MS=250;generator;eye;probes=new Map;constructor(t){on.install(),this.generator=new md(t),this.eye=new Ol(this.generator)}static decor;refresh(t,e,i,n,s,a,o,c=[],l,h=on.REFRESH_MS){for(const m of[...this.probes.keys()])n.some(g=>g.id===m&&g.shiny)||(this.probes.get(m).dispose(),this.probes.delete(m));const u=[{probe:this.eye}];for(const m of n){if(!m.shiny)continue;let g=this.probes.get(m.id);g||(g=new Ol(this.generator),this.probes.set(m.id,g)),u.push({probe:g,reflector:m})}const d=performance.now(),f=()=>u.filter(({probe:m})=>m.capturedVersion!==o),p=f().filter(({probe:m})=>d-m.capturedAtMs>=h);if(p.length>0){const m=p.reduce((g,S)=>S.probe.capturedAtMs<g.probe.capturedAtMs?S:g);if(m.reflector){const g=m.reflector.holder.getWorldPosition(this.scratch);m.probe.capture(t,e,g,[m.reflector.holder,...s]),on.reflectOn(m.reflector.holder,m.probe)}else{m.probe.capture(t,e,i,[...s,...c]),l?.(m.probe.sharp),on.decor=m.probe.filtered;for(const g of a)on.reflectOn(g,m.probe);for(const g of n)g.shiny||on.reflectOn(g.holder,m.probe)}m.probe.capturedVersion=o}const v=f();if(v.length!==0)return Math.max(16,Math.min(...v.map(({probe:m})=>h-(d-m.capturedAtMs))))}scratch=new R;static reflectOn(t,e={filtered:on.decor}){t.traverse(i=>{const n=i.material;for(const s of Array.isArray(n)?n:n?[n]:[])s instanceof Xo?e.sharp&&s.setSurroundings(e.sharp):s instanceof xa&&e.filtered&&s.envMap!==e.filtered&&(s.envMap=e.filtered,s.needsUpdate=!0)})}dispose(){this.eye.dispose();for(const t of this.probes.values())t.dispose();this.generator.dispose()}static installed=!1;static install(){if(on.installed)return;on.installed=!0;const t="iblIrradiance += getIBLIrradiance( geometryNormal );";if(!Xt.lights_fragment_maps.includes(t)){console.warn("Reflections: three's lights_fragment_maps changed; the environment will light diffusely too");return}Xt.lights_fragment_maps=Xt.lights_fragment_maps.replace(t,"// The sky's diffuse light is the hemisphere light's (see Reflections).")}}function Cw(r,t){return JSON.stringify(r.cloudLayers)===JSON.stringify(t.cloudLayers)&&r.cloudCover===t.cloudCover&&r.cloudDarkness===t.cloudDarkness&&r.cloudBaseM===t.cloudBaseM&&r.highCloudCover===t.highCloudCover&&r.iceCrystalAlignment===t.iceCrystalAlignment&&r.lowerCloudCover===t.lowerCloudCover&&r.relativeHumidity===t.relativeHumidity&&r.precipitationType===t.precipitationType&&r.precipitationIntensity===t.precipitationIntensity&&r.precipitationAmount===t.precipitationAmount&&r.windDirectionDeg===t.windDirectionDeg&&r.windSpeed===t.windSpeed&&r.storm===t.storm}const Yc=900,iu=1,xm=4,ym=5,_m=.5,yo=900,Pw=6371e3,Lw=3e4;function Sm(r){const t=Math.sqrt(2*Pw*Math.max(r,0));return Math.max(yo,Math.min(t,Lw))}const nu=.5,su=850,bm=.03,sn=850,lo=300,Gs=120,Ow=700,Nw=.04,ho=4,au=1.5,wm=-1,Fw=6,$d=-4,Uw=2,kw=20,qc=2600,zw=.97,Bw=.38,$c=$d,Em=1500,Hw=400,Gw=[0,45,90,135,180,225,270,315],Vw=2,Ww=16,Am=4e3,Tm=880,Kc=40,Rm=60,Xw=10,Yw=1,qw=150,$w=55,Kw=.5,Zw=17,Dm=.265,Im=[[0,0],...Array.from({length:8},(r,t)=>{const e=t*Math.PI/4;return[Math.cos(e)*Dm,Math.sin(e)*Dm]})],ru=700,ou=250/Zd,Jw=12,Cm=5,cu=6,fa=[.92,.92,.95],lu=[.15,.15,.19],hu={snow:{fallSpeedMPerS:2,size:.3,color:new st(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new st(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},dr=0,uu=0,jw=150,du=3e3,uo=20,Qw=15,Pm=dr,tE=40,Lm=1,eE=9;function fu(r){return Lm+(eE-Lm)*r}const Om=new st(.75,.82,.92),iE=10,nE=.5;function Nm(r){return Mr(r/iE,nE,1)}const pa=200,Fm=.18,Um=.32,sE=.35,km=new st(.85,.9,.98),zm=5,Bm=.85,Hm=.01;function aE(r,t,e=1){return Math.round(r*(Hm+(1-Hm)*t)*e)}function rE(r,t){return JSON.stringify(r.cloudLayers)===JSON.stringify(t.cloudLayers)&&r.cloudCover===t.cloudCover&&r.cloudDarkness===t.cloudDarkness&&r.cloudBaseM===t.cloudBaseM&&r.highCloudCover===t.highCloudCover&&r.iceCrystalAlignment===t.iceCrystalAlignment&&r.lowerCloudCover===t.lowerCloudCover}const Gm=230,Vm=.7,Wm=.05,oE=.6,cE=.7,lE=.15,Xm=.35,hE=3,uE=1/12,dE=.5,Xn=new st(.82,.86,1),fE=2500,pE=1.6,pu=15,mE={Venus:new st(1,.96,.85),Mars:new st(1,.55,.4),Jupiter:new st(.95,.87,.72),Saturn:new st(.92,.86,.68)};class ke{renderer;scene=new Ts;phenomena=new In(this.scene);references=new Rn(this.scene,()=>this.render());camera;celestialGroup=new Ce;skyMesh;skyGradientMaterial;scatteredSky;lastAstronomy;skyColoursStale=!1;scatteredSkyFrameId=null;skyHoldUntilMs=void 0;onFirstFrameHold;firstFrameReady(){return(!this.scatteredSky||this.scatteredSky.ambient!==void 0)&&!this.iceHalos?.awaitingFirstDisplay}sceneSettled(){return this.firstFrameReady()&&this.arrivalsPending===0&&this.eyeSettledVersion>=this.lastArrivalVersion}arrivalsPending=0;eyeSettledVersion=-1;lastArrivalVersion=0;awaitArrival(t,e){if(this.skyHoldUntilMs===null)return t;this.arrivalsPending++;let i=!0;const n=()=>{i&&(i=!1,this.arrivalsPending--,this.lastArrivalVersion=this.sceneVersion,this.skyHoldUntilMs&&this.redrawHeld())},s=e===void 0?void 0:setTimeout(n,e);return t.finally(()=>{clearTimeout(s),n()})}static ROADS_PATIENCE_MS=1500;redrawHeld(){this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()}))}holdForNewScene(t){this.surroundings=void 0,this.scatteredSky?.resetSurroundings(),this.startHold(),t&&this.awaitArrival(t).catch(()=>{})}startHold(){this.skyHoldUntilMs=performance.now()+Am,this.eyeSettledVersion=-1,this.lastArrivalVersion=this.sceneVersion+1,this.iceHalos?.setUrgent(!0),this.onFirstFrameHold?.(!0),setTimeout(()=>this.render(),Am+20)}groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;roadSystem=new gn;roadAttribution;roadWays;statedRoads=[];decorModelProvider=Rw[0].create();decorModelToken=0;decorModelCredits=new Map;bodySystem=new ue(t=>this.awaitArrival(this.loadBodyModel(t)),()=>this.render(),()=>this.relativeScale);bodyOrigin={x:0,z:0};starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;decorReferencePose;decorCurrentPose;decorTime=0;celestialLight=new dp(16777215,0);celestialLightTarget=new Be;skyLight=new ex(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;resolution;cssSize={width:1,height:1};frameDirty=!1;flushFrameId=null;framesDriven=!1;lastFrameTimeMs;raycaster=new ol;weather=Jd;observerElevationM=0;siteElevationM=0;air=new xn;groundRadius=yo;terrainRadius=yo;cloudRendering="volume";layeredClouds;cloudLayerOffsetsM={};cloudOffsetM=new R;cloudFieldOffset=new R;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new R;rainLastVerticalFacing=-1;rainViewportSize=new xt;lightningArmed=!1;lightningFlashes=[];lightningLevel=0;lightningBolt;lightningLight=new dp(16777215,0);baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new R;sunVisible=!1;lensFlareScratch=new R;sunOcclusionRaycaster=new ol;sunOcclusionDirectionScratch=new R;sunOcclusionRightScratch=new R;sunOcclusionUpScratch=new R;ufoOcclusionRaycaster=new ol;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;finishPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;static exposureInstantsPerFrame(t){return Math.max(3,Math.round(6e6/Math.max(1,t)))}exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;lightPollution;meteorSystem;cometTail;satelliteField;iceHalos;lunarDiffraction;lunarDiffractionKey="";rainbow;skyGlow;cometKey;novaKeys=new Set;constructor(t,e=e2()){this.renderer=new pb({canvas:t,antialias:!0}),this.resolution=new ve(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=So,this.camera=new Zi(60,t.width/Math.max(t.height,1),.1,Yc*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=e,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-Gs,this.celestialLight.shadow.camera.right=Gs,this.celestialLight.shadow.camera.top=Gs,this.celestialLight.shadow.camera.bottom=-Gs,this.celestialLight.shadow.camera.near=sn-lo,this.celestialLight.shadow.camera.far=sn+lo,this.celestialLight.shadow.bias=-.03/(2*lo),this.celestialLight.shadow.normalBias=Nw,this.celestialLight.target=this.celestialLightTarget,this.lightningLight.color.copy(Xn),this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight,this.lightningLight),this.scene.add(this.celestialGroup),this.scene.add(this.bodySystem.group),this.scene.add(this.roadSystem.group);const i=new Ne(this.renderer,()=>{this.skyColoursStale=!0,this.render()});i.supported?this.scatteredSky=i:i.dispose()}get currentTerrainAttribution(){return this.terrainAttribution}get currentRoadAttribution(){return this.roadAttribution}resize(t,e){this.cssSize.width=t,this.cssSize.height=e,this.renderer.setSize(t,e,!1),this.camera.aspect=t/Math.max(e,1),this.camera.updateProjectionMatrix(),this.render()}setCloudRendering(t){t!==this.cloudRendering&&(this.cloudTransmissionMemo.clear(),this.cloudRendering=t,this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.buildClouds(),this.buildCirrus(),this.render())}setCloudOffset(t,e={}){this.cloudOffsetM.set(t.x,0,t.z),this.cloudLayerOffsetsM=e,this.layeredClouds?.setOffsets(t,e),this.cloudFieldOffset.set(t.x*ou,0,t.z*ou);for(const i of[this.cloudUniforms,this.cirrusUniforms])i?.fieldOffset.value.copy(this.cloudFieldOffset);this.iceHalos?.setCloudOffset(this.layeredClouds?.cirrusMask?.offset??this.cloudFieldOffset)}setObserverPose(t){const e=((t.rollDeg??0)+this.gaitOffset.rollDeg)*qi,i=(t.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*qi;if(t.headingDeg!==void 0?this.camera.rotation.set(i,-(t.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*qi,e,"YXZ"):this.camera.rotation.set(i,this.camera.rotation.y,e,"YXZ"),t.elevationM!==this.observerElevationM&&(this.observerElevationM=t.elevationM,this.syncCloudLayer(),Math.abs(Sm(t.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/yo),this.camera.far=Math.max(Yc*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&t.lat!==void 0&&t.lng!==void 0){const n=ai(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=n.x,this.terrainMesh.position.z=n.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+t.elevationM,this.camera.position.y=this.poseCameraY,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==t.fovDeg&&(this.camera.fov=t.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(t){this.stopTerrainFade(),this.terrainProviders=t,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.roadSystem.clear(),this.roadAttribution=void 0,this.roadWays=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(t,e,i){if(t===void 0||e===void 0)return;const n=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-n)<n*.1){const{x:c,z:l}=ai(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<qw*(n/yo))return}const s=this.terrainOrigin,a=this.terrainRadius;(!s||s.lat!==t||s.lng!==e)&&(this.roadSystem.clear(),this.roadAttribution=void 0),this.terrainOrigin={lat:t,lng:e},this.terrainRadius=n;const o=++this.terrainBuildToken;this.awaitArrival(B5(t,e,this.terrainProviders,n)).then(({mesh:c,attribution:l,originElevationM:h})=>{if(o!==this.terrainBuildToken)return;this.setSiteElevation(h??0);const u=this.terrainMesh,d=s?ai(t,e,s.lat,s.lng):void 0;u&&d&&Math.hypot(d.x,d.z)<=a&&(c.position.y=u.position.y+this.groundYOfPatch(u,d.x,d.z)),u&&d&&Math.hypot(d.x,d.z)<=a?this.crossfadeTerrain(c,u):this.disposeMesh(this.terrainMesh),c.renderOrder=Yw,this.terrainMesh=c,this.compileNextFrameOffThread(),this.terrainAttribution=l,this.scene.add(c),this.applyGroundDepthWrite(),this.decorCurrentPose&&(this.setObserverPose(this.decorCurrentPose),this.updateDecorAnchoring(this.decorReferencePose,this.decorCurrentPose,this.decorTime)),this.buildRoads(t,e,n),this.drapeStatedRoads(),this.render(),i?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),i?.()})}static TERRAIN_CROSSFADE_MS=1200;fadingTerrain;crossfadeTerrain(t,e){this.stopTerrainFade();const i=t.material;i.opacity=0,i.polygonOffset=!0,i.polygonOffsetFactor=-1,i.polygonOffsetUnits=-4;const n=performance.now(),s=()=>{const a=Math.min(1,(performance.now()-n)/ke.TERRAIN_CROSSFADE_MS);if(i.opacity=a*a*(3-2*a),this.render(),a<1&&this.fadingTerrain){this.fadingTerrain.frameId=requestAnimationFrame(s);return}i.polygonOffset=!1,i.opacity=1,this.fadingTerrain&&this.disposeMesh(this.fadingTerrain.mesh),this.fadingTerrain=void 0,this.render()};this.fadingTerrain={mesh:e,frameId:requestAnimationFrame(s)}}stopTerrainFade(){if(!this.fadingTerrain)return;cancelAnimationFrame(this.fadingTerrain.frameId),this.disposeMesh(this.fadingTerrain.mesh),this.fadingTerrain=void 0;const t=this.terrainMesh?.material;t&&(t.opacity=1,t.polygonOffset=!1)}static ROADS_MAX_RADIUS_M=5e3;buildRoads(t,e,i){const n=this.terrainProviders.roads;if(!n||i>ke.ROADS_MAX_RADIUS_M){this.roadSystem.clear(),this.roadAttribution=void 0;return}const s=this.roadWays;if(s&&s.lat===t&&s.lng===e&&s.radiusM===i){this.drapeRoads(s.ways,t,e,n.contemporary);return}this.awaitArrival(n.getRoads(I1(t,e,i)),ke.ROADS_PATIENCE_MS).then(a=>{this.terrainOrigin?.lat!==t||this.terrainOrigin?.lng!==e||(this.roadWays={lat:t,lng:e,radiusM:i,ways:a},this.drapeRoads(a,t,e,n.contemporary))}).catch(a=>{console.warn("Roads unavailable, drawing none:",a)})}setStatedRoads(t){t!==this.statedRoads&&(this.statedRoads=t,this.drapeStatedRoads(),this.render())}drapeStatedRoads(){const t=this.terrainMesh;t&&(this.roadSystem.group.position.copy(t.position),this.roadSystem.setStated(this.statedRoads,(e,i)=>this.groundYOfPatch(t,e,i)))}drapeRoads(t,e,i,n){const s=this.terrainMesh;s&&(this.roadSystem.group.position.copy(s.position),this.roadSystem.set(t,e,i,(a,o)=>this.groundYOfPatch(s,a,o),n),this.roadAttribution=t.length>0?this.terrainProviders.roads?.attribution:void 0,this.compileNextFrameOffThread(),this.render())}setShowCompass(t){this.showCompass!==t&&(this.showCompass=t,this.disposeCompassLabels(),t&&this.buildCompassLabels(),this.render())}setCompassPoints(t){this.compassPoints!==t&&(this.compassPoints=t,this.showCompass&&(this.disposeCompassLabels(),this.buildCompassLabels(),this.render()))}compassPoints;applyLensFlareTint(t){if(!this.lensFlare)return;const e=$w*(this.sunArriving[1]/Zw);this.lensFlare.uniforms.uColorGain.value.setRGB(e*t[0],e*t[1],e*t[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const[t,e,i]=this.sunArriving,n=Math.max(e,1e-30);this.lensFlare.uniforms.uDazzleColour.value.setRGB(t/n,1,i/n),this.lensFlare.uniforms.uVeilStrength.value=Pi.K*e*this.sunUnhiddenFraction}sunArriving=[0,0,0];setCompassHovered(t){this.compassHovered!==t&&(this.compassHovered=t,this.updateCompassVisibility())}setCompassForced(t){this.compassForced!==t&&(this.compassForced=t,this.updateCompassVisibility())}updateCompassVisibility(){const t=this.compassHovered||this.compassForced;if(this.compassSprites.some(e=>e.visible!==t)){for(const e of this.compassSprites)e.visible=t;this.developingExposure?this.exposureInstantsDone>0&&this.presentExposure():this.render()}}setWeather(t){if(Cw(this.weather,t))return;this.cloudTransmissionMemo.clear();const e=this.weather;this.weather=t;const i=!rE(e,t),n=e.precipitationType!==t.precipitationType,s=e.precipitationIntensity!==t.precipitationIntensity||e.precipitationAmount!==t.precipitationAmount;(e.relativeHumidity!==t.relativeHumidity||n||s)&&(this.air=xn.of(t),this.applyAir(),this.scatteredSky?.setConditions({aerosolOpticalDepth:t.relativeHumidity===void 0?void 0:Qs.steppedOpticalDepth(t.relativeHumidity)}),this.pumpScatteredSky()),i&&(this.buildClouds(),this.buildCirrus()),n?this.buildPrecipitation():s&&this.updatePrecipitationDensity(),this.lastAstronomy&&(i&&(this.buildIceHalos(this.lastAstronomy.sun,this.lastAstronomy.moon),this.buildLunarDiffraction(this.lastAstronomy.moon)),(i||n||s)&&this.buildRainbow(this.lastAstronomy.sun,this.lastAstronomy.moon)),this.lightningArmed=t.storm&&t.cloudDarkness>=dE,this.syncAnimationLoop(),this.render()}setDecor(t){if(this.decorObjects!==t){this.decorObjects=t,this.decorModelToken++,this.decorModelCredits.clear();for(const e of this.decorGroups.values())e.removeFromParent(),ui.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear();for(const e of t){const i=ui.build(e,e.lit??!1);this.scene.add(i),this.decorGroups.set(e.id,i),e.kind==="streetlight"&&this.addStreetlightLight(e.id,i),this.awaitArrival(this.loadDecorModel(e,this.decorModelToken))}this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}}setDecorModelProvider(t){this.decorModelProvider=t;const e=this.decorObjects;this.decorObjects=[],this.setDecor(e)}get currentDecorModelCredits(){return[...this.decorModelCredits.values(),...this.bodySystem.modelCredits]}get bodyGround(){const{x:t,z:e}=this.bodyOrigin,i=this.groundYUnder(t,e);return{heightAt:(n,s)=>this.groundYUnder(t+n,e-s)-i}}setBodies(t,e=0,i=t.map(a=>a.id),n=[],s){const{x:a,z:o}=this.bodyOrigin,c=this.scatteredSky;this.bodySystem.set(t,{originX:a,originZ:o,originGroundY:this.groundYUnder(a,o),eye:this.camera.position,groundYAt:(h,u)=>this.groundYUnder(h,u),wind:s,light:this.plumeLight(),occluders:[...this.decorGroups.values()],transmittance:(h,u,d)=>this.transmittanceTo(h,u,d)},e,c?(h,u)=>c.relativeOfLuminance(h,u):void 0,i),this.bodySystem.setSmoke(n,e),this.bodySystem.any&&(this.celestialLight.castShadow=!0),this.fitShadowToBodies();const l=this.bodySystem.furthestFrom(this.camera.position)*1.2;l>this.camera.far&&(this.camera.far=l,this.camera.updateProjectionMatrix())}plumeLight(){const t=this.celestialLight.color,e=this.celestialLight.intensity*.5,i=this.skyLight.color,n=this.skyLight.groundColor,s=this.skyLight.intensity,a=(o,c,l)=>(o*e+(c+l)/2*s)/Math.PI;return[a(t.r,i.r,n.r),a(t.g,i.g,n.g),a(t.b,i.b,n.b)]}bodyOutline(t,e){return this.bodySystem.outlineOf(t,e)}documentUrl;modelUrl(t){return t.url?this.documentRelative(t.url):void 0}documentRelative(t){if(t.startsWith("data:"))return t;const e=this.documentUrl??(typeof location>"u"?void 0:location.href);return e?new URL(t,e).href:t}async loadBodyModel(t){const e=t.url?void 0:t.id?await this.decorModelProvider.entry(t.id):void 0,i=this.modelUrl(t)??e?.url,n=t.credit??e?.credit;if(!(!i||!n))return{scene:await Mm(i),credit:n,headingOffsetDeg:t.headingOffsetDeg??e?.headingOffsetDeg}}async loadDecorModel(t,e){const i=t.model;if(!(!i||!ui.usesModel(t)))try{const n=i.url?void 0:i.id?await this.decorModelProvider.entry(i.id):void 0,s=this.modelUrl(i)??n?.url,a=i.credit??n?.credit;if(!s||!a)return;const o=await Mm(s);if(e!==this.decorModelToken)return;const c=this.decorGroups.get(t.id);if(!c)return;on.reflectOn(o),ui.applyModel(c,t,o,{headingOffsetDeg:i.headingOffsetDeg??n?.headingOffsetDeg,depictedSizeM:n?.sizeM}),this.decorModelCredits.set(t.id,a),this.render()}catch(n){console.warn(`Keeping the built-in shape for decor "${t.id}":`,n)}}updateDecorAnchoring(t,e,i=0){this.decorReferencePose=t,this.decorCurrentPose=e,this.decorTime=i;const n=t?.lat!==void 0&&t.lng!==void 0&&e?.lat!==void 0&&e?.lng!==void 0?ai(t.lat,t.lng,e.lat,e.lng):{x:0,z:0},s=this.decorObjects.find(l=>l.observerSide!==void 0&&tg(l.kind));if(this.terrainMesh&&this.terrainOrigin&&e?.lat!==void 0&&e.lng!==void 0){const l=ai(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=l.x-(s?0:this.gaitOffset.eastM),this.terrainMesh.position.z=l.z+(s?0:this.gaitOffset.northM),this.roadSystem.group.position.copy(this.terrainMesh.position)}s||(n.x-=this.gaitOffset.eastM,n.z+=this.gaitOffset.northM,this.camera.position.y=this.poseCameraY+this.gaitOffset.upM,this.celestialGroup.position.y=this.camera.position.y);const a={x:0,z:0};let o=0;if(s){const l=ui.occupantView(s),h=-(s.headingDeg??0)*qi,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=s.eastM+n.x,p=-s.northM+n.z;a.x=-(f+u),a.z=-(p+d),this.camera.position.y=this.groundYUnder(f,p)+l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*qi,-(l.headingDeg+this.indoorLookYawDeg)*qi,0,"YXZ")}this.bodyOrigin={x:n.x+a.x,z:n.z+a.z},this.placeShadowFrustum();for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=Io(l,i),d=u.eastM+n.x+a.x,f=-u.northM+n.z+a.z,p=this.terrainMesh,v=`${p?.geometry.uuid}:${(d-(p?.position.x??0)).toFixed(3)}:${(f-(p?.position.z??0)).toFixed(3)}:${(p?.position.y??0).toFixed(3)}:${u.headingDeg}:${u.altitudeM}`;if(h.userData.footprintKey!==v&&(h.userData.footprintGroundY=this.groundUnderFootprint(l,d,f,u.headingDeg,u.altitudeM),h.userData.footprintKey=v),h.position.set(d,h.userData.footprintGroundY+u.altitudeM,f),l.kind==="crop"){const m=Math.hypot(d,f);h.visible=m<=jw}if(u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*qi),l.kind==="crop"&&h.visible){const m=this.terrainMesh,g=[m?.geometry.uuid,d-(m?.position.x??0),f-(m?.position.z??0),h.position.y-(m?.position.y??0),u.headingDeg,u.altitudeM].map(S=>typeof S=="number"?S.toFixed(4):S).join(":");h.userData.cropGroundKey!==g&&(ui.fitCropToGround(h,(S,y)=>this.groundYUnder(S,y)+u.altitudeM),h.userData.cropGroundKey=g)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(Yc*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}groundYUnder(t,e){const i=this.terrainMesh;return i?i.position.y+this.groundYOfPatch(i,t-i.position.x,e-i.position.z):uu}groundYOfPatch(t,e,i){const n=t.geometry.getAttribute("position"),s=Math.round(Math.sqrt(n.count));if(s<2||s*s!==n.count)return uu;const a=n.getX(0),o=n.getX(s-1),c=n.getZ(0),l=n.getZ((s-1)*s),h=Mr((e-a)/(o-a)*(s-1),0,s-1),u=Mr((i-c)/(l-c)*(s-1),0,s-1);if(!Number.isFinite(h)||!Number.isFinite(u))return uu;const d=Math.min(Math.floor(h),s-2),f=Math.min(Math.floor(u),s-2),p=h-d,v=u-f,m=(b,w)=>n.getY(b*s+w),g=m(f,d),S=m(f,d+1),y=m(f+1,d),M=m(f+1,d+1);return p+v<=1?g+(S-g)*p+(y-g)*v:M+(y-M)*(1-p)+(S-M)*(1-v)}groundUnderFootprint(t,e,i,n,s=0){return ui.groundUnderFootprint(t,e,i,n,(a,o)=>this.groundYUnder(a,o),s)}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(t){this.gaitOffset=t}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(t,e){this.lookYawDeg=t,this.lookPitchDeg=e}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(t,e){this.indoorLookYawDeg=t,this.indoorLookPitchDeg=e}medium;setMedium(t,e,i,n){const s=t&&e!==void 0&&e>0&&i!==void 0&&i>0?{kind:t.kind,iso:n??t.iso,autoExposure:t.autoExposure===!0,exposureSeconds:e,fNumber:i}:void 0;JSON.stringify(s)!==JSON.stringify(this.medium)&&(this.medium=s,this.render())}applyMedium(){const t=this.medium,e=Math.max(this.relativeScale,1e-30);if(!t){Hi.uMedium.value=0;return}Hi.uMedium.value=t.kind==="negative"?1:t.kind==="slide"?2:3;const i=t.autoExposure?this.scatteredSky?.sceneAdaptation:void 0;Hi.uMediumExposure.value=i!==void 0&&i>0?1/(e*i):.065*t.exposureSeconds*t.iso/(t.fNumber*t.fNumber*e)}grain;lampBloomRadiusRad(){if(!this.grain)return;const t=this.camera.fov*Math.PI/180,e=this.grain.frameHeightMm/(2*Math.tan(t/2)),i=Math.max(1,this.renderer.getDrawingBufferSize(this.bloomSize).y);return Math.max(this.grain.detailUm*.001/e,t/i)}bloomSize=new xt;updateDecorLitState(t,e=0){const i=this.lampBloomRadiusRad();for(const n of this.decorObjects){const s=this.decorGroups.get(n.id);if(s&&n.lights?.length&&ui.setLights(s,n.lights,t,s.position.distanceTo(this.camera.position),e,this.relativeScale,i),n.kind!=="streetlight"&&n.kind!=="vehicle")continue;const a=this.decorGroups.get(n.id);if(!a)continue;const o=Q1(n,t);ui.setLit(a,n.kind,o,this.relativeScale);const c=this.streetlightLights.get(n.id);c&&(c.visible=o)}}addStreetlightLight(t,e){const i=ui.bodyOf(e),n=i.children.find(a=>a.userData.emissive);if(!n)return;const s=new Zg(16764006,Em*this.relativeScale,Hw);s.position.copy(n.position).multiply(i.scale),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,e.add(s),this.streetlightLights.set(t,s)}setAstronomy(t){(!this.lastAstronomy||Math.abs(this.lastAstronomy.sun.altitudeDeg-t.sun.altitudeDeg)>2)&&(this.surroundings=void 0,this.scatteredSky?.resetSurroundings()),this.lastAstronomy=t,this.scatteredSky?.update(this.scatteredSkyState(t)),this.skyHoldUntilMs===void 0&&this.startHold(),this.pumpScatteredSky(),this.lastSunPosition=t.sun,this.buildSky(t.sun),this.buildGround();const e=this.magnitudeLimitOf(t);this.buildStars(t.stars,e),this.placeBodies(t,e),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon),this.applySkyColours(t),this.syncAnimationLoop(),this.render()}static relativeSkyOf(t,e){const i=a=>{const o=On.luminanceOf(a);if(!(o>0))return[0,0,0];const c=At.relativeOfResponse(o)/o;return[a[0]*c,a[1]*c,a[2]*c]},n=i(t.zenith),s=i(t.horizon);return{zenith:n,horizon:s,airlight:s,skyIrradiance:[n[0]*Math.PI,n[1]*Math.PI,n[2]*Math.PI],scale:e}}placeBodies(t,e){this.bodiesScale=this.relativeScale,this.setBodyMesh("sun",t.sun,ho,new st(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon,e),this.buildPlanets(t.planets,e),this.buildComet(t.comet,e),this.buildNovae(t.novae??[],e)}bodiesScale=0;applySkyColours(t){this.skyColoursStale=!1,this.bodiesScale!==this.relativeScale&&(this.placeBodies(t,this.magnitudeLimitOf(t)),this.applyDazzleStrength(),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon));const e=this.scatteredSky?.ambient??ke.relativeSkyOf(wd(t.sun.altitudeDeg),this.relativeScale),i=e,n=this.lightUnderClouds(t),s=a=>n?[0,1,2].map(o=>a[o]*n.through+n.radiance[o]*(1-n.through)):[a[0],a[1],a[2]];this.baseFogColor=[i.horizon[0],i.horizon[1],i.horizon[2]],this.airlight=s(i.airlight),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.scatteredSky?.ready?this.scatteredSky.material:this.skyGradientMaterial),this.updateCelestialLight(t,e),this.updateCloudLighting(t.sun,this.baseFogColor),ae.setEye(this.scatteredSky?.rodShare??0,this.relativeScale),this.updateTwinkle(this.twinkleSeconds);for(const a of this.streetlightLights.values())a.intensity=Em*this.relativeScale;this.buildSkyGlow(t,i.zenith),this.applyAir(),this.buildLunarDiffraction(t.moon)}reflections;sceneVersion=0;reflectionTimer;buildLunarDiffraction(t){const e=this.scatteredSky?.ready?this.scatteredSky:void 0;if(t.altitudeDeg<-.5||!e){this.lunarDiffraction?.show(void 0),this.lunarDiffractionKey="";return}const i=this.weather.relativeHumidity,n=(i===void 0?Ft.DEFAULT_AEROSOL_OPTICAL_DEPTH:Qs.opticalDepth(i))*Ft.aerosolDensity(this.siteElevationM+this.observerElevationM),s=this.cloudTransmission(t),a=-Math.log(Math.max(this.cloudTransmission(t,!0),1e-4)),o=fe.aureoleScale(n,fe.airMass(t.altitudeDeg))*s,c=fe.coronaScale(a),l=fe.illuminanceOf(t.magnitude),h=[t.altitudeDeg.toFixed(1),t.azimuthDeg.toFixed(1),t.magnitude.toFixed(2),o.toExponential(2),c.toExponential(2),Math.log10(Math.max(e.adaptation,1e-12)).toFixed(2)].join(":");if(h===this.lunarDiffractionKey)return;this.lunarDiffractionKey=h,this.lunarDiffraction||(this.lunarDiffraction=new z0,this.celestialGroup.add(this.lunarDiffraction.object));const u=fe.profile(fe.HAZE_COARSE_MODE),d=fe.profile(fe.CLOUD_DROPLETS),f=Gp(t.altitudeDeg),p=new Float32Array(fe.STEPS*3);let v=0;for(let y=0;y<fe.STEPS;y++){const M=y*3,b=[0,1,2].map(T=>l*f[T]*(o*u[M+T]+c*d[M+T])),w=On.shown(b,On.luminanceOf(b),(T,x)=>e.relativeOfLuminance(T,x));p.set(w,M),v=Math.max(v,On.response(w))}const{x:m,y:g,z:S}=hi(t.altitudeDeg,t.azimuthDeg,1);this.lunarDiffraction.show(v>1/200?{x:m,y:g,z:S}:void 0,p)}applyAir(){this.scene.fog instanceof Pa||(this.scene.fog=new Pa),this.scene.fog.setAir(this.air,this.siteElevationM,this.airlight)}airlight=[0,0,0];transmittanceTo(t,e,i){const n=this.camera.position;return this.air.transmittance(this.siteElevationM+n.y,this.siteElevationM+e,Math.hypot(t-n.x,e-n.y,i-n.z))}setSiteElevation(t){Math.abs(t-this.siteElevationM)<1||(this.siteElevationM=t,this.applyAir(),this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}scatteredSkyState(t){return{altitudeM:this.siteElevationM+this.observerElevationM+1.6,lightPollution:this.lightPollution,sun:{altitudeDeg:t.sun.altitudeDeg,azimuthDeg:t.sun.azimuthDeg,magnitude:t.sun.magnitude},moon:{altitudeDeg:t.moon.altitudeDeg,azimuthDeg:t.moon.azimuthDeg,magnitude:t.moon.magnitude,phaseAngleDeg:Mt.phaseAngleOf(t.moon.phase.illuminatedFraction)}}}pumpScatteredSky(){const t=this.scatteredSky;!t||t.tables.ready||this.scatteredSkyFrameId!==null||this.contextReleased||(this.scatteredSkyFrameId=requestAnimationFrame(()=>{this.scatteredSkyFrameId=null,!this.contextReleased&&(t.advance(this.skyHoldUntilMs?Ww:Vw),this.pumpScatteredSky())}))}cancelScatteredSkyPump(){this.scatteredSkyFrameId!==null&&(cancelAnimationFrame(this.scatteredSkyFrameId),this.scatteredSkyFrameId=null)}setSatellites(t){if(t.length===0&&!this.satelliteField?.count)return;this.satelliteField||(this.satelliteField=new nw(su),this.celestialGroup.add(this.satelliteField.object));const e=this.lastAstronomy?this.magnitudeLimitOf(this.lastAstronomy):Ed(-90,this.instrumentMagnitudeGain);this.satelliteField.set(t,e,i=>this.cloudTransmission(i),(i,n)=>this.arrivingIlluminance(i,n,1)),this.render()}pickSatelliteAt(t,e){if(!this.satelliteField?.count)return;this.aimAtScreenPoint(this.raycaster,t,e);const i=Math.cos(bm*this.camera.fov*Math.PI/180),n=this.satelliteField.nearest(this.raycaster.ray.direction,i);return n&&this.groundHides(t,e)?void 0:n}updateCelestialLight(t,e){const i=this.relativeScale,n=t.sun.altitudeDeg>=$c,s=!n&&t.moon.altitudeDeg>=$c,a=n?t.sun:t.moon,o=[0,0,0],c=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*qi)),l=n||s?this.cloudTransmission(a):1,h=-Math.log(Math.max(l,1e-6)),u=Math.max(0,1/(1+.1125*h)-l),d=[0,0,0];if(n||s){const S=fe.illuminanceOf(a.magnitude)*i,y=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,a.altitudeDeg);for(let T=0;T<3;T++)o[T]=S*y[T]*l,d[T]=S*y[T]*u*c,this.cloudBeam[T]=S*y[T];const{x:M,y:b,z:w}=hi(a.altitudeDeg,a.azimuthDeg,1);this.cloudBeamDirection.set(M,b,w)}else this.cloudBeam.fill(0);const f=this.surroundings;if(f)this.skyLight.color.setRGB(f.up[0]*i,f.up[1]*i,f.up[2]*i),this.skyLight.groundColor.setRGB(f.down[0]*i,f.down[1]*i,f.down[2]*i);else{const S=this.skyCloudTransmission(),y=e.skyIrradiance,M=[0,1,2].map(w=>y[w]*S+d[w]);this.skyLight.color.setRGB(M[0],M[1],M[2]);const b=Wt.GROUND_ALBEDO;this.skyLight.groundColor.setRGB(b*(M[0]+o[0]*c),b*(M[1]+o[1]*c),b*(M[2]+o[2]*c))}if(this.skyLight.intensity=1,!n&&!s){this.celestialLight.intensity=0;return}const{x:p,y:v,z:m}=hi(a.altitudeDeg,a.azimuthDeg,1);this.lightDirection.set(p,v,m),this.placeShadowFrustum();const g=Math.max(o[0],o[1],o[2],1e-30);this.celestialLight.color.setRGB(o[0]/g,o[1]/g,o[2]/g),this.celestialLight.intensity=g,this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}lightDirection=new R(0,1,0);placeShadowFrustum(){const t=this.lightDirection,e=this.celestialLight.shadow.camera,i=(e.right-e.left)/this.celestialLight.shadow.mapSize.x,n=this.shadowAxisX.crossVectors(this.shadowUp,t);n.lengthSq()<1e-8&&n.set(1,0,0),n.normalize();const s=this.shadowAxisY.crossVectors(t,n).normalize(),a=this.shadowWorld.set(this.bodyOrigin.x,0,this.bodyOrigin.z),o=l=>{const h=a.dot(l)/i;return(h-Math.round(h))*i},c=this.celestialLightTarget.position.set(0,0,0).addScaledVector(n,o(n)).addScaledVector(s,o(s));this.celestialLightTarget.updateMatrixWorld(),this.celestialLight.position.copy(c).addScaledVector(t,this.shadowLightDistanceM)}fitShadowToBodies(){const t=this.bodySystem.reachFrom(this.camera.position),e=Math.min(Ow,Math.max(Gs,Math.ceil(t*1.25/20)*20));if(e===this.shadowHalfExtentM)return;this.shadowHalfExtentM=e;const i=this.celestialLight.shadow,n=i.camera;n.left=-e,n.right=e,n.top=e,n.bottom=-e;const s=Math.max(lo,e*(lo/Gs));this.shadowLightDistanceM=Math.max(sn,s+10),n.near=this.shadowLightDistanceM-s,n.far=this.shadowLightDistanceM+s,n.updateProjectionMatrix(),i.bias=-.03/(2*s);const a=e>2*Gs?2048:1024;i.mapSize.x!==a&&(i.mapSize.set(a,a),i.map?.dispose(),i.map=null),this.placeShadowFrustum()}shadowHalfExtentM=Gs;shadowLightDistanceM=sn;shadowUp=new R(0,1,0);shadowAxisX=new R;shadowAxisY=new R;shadowWorld=new R;skyCloudTransmission(){let t=this.cloudTransmission({altitudeDeg:90,azimuthDeg:0}),e=1;for(const i of[20,45,70]){const n=i*qi,s=Math.sin(n)*Math.cos(n)*2;for(let a=0;a<360;a+=60)t+=s*this.cloudTransmission({altitudeDeg:i,azimuthDeg:a}),e+=s}return t/e}cloudBeam=[0,0,0];cloudBeamDirection=new R(0,1,0);get relativeScale(){return this.scatteredSky?.relativeScale??1/At.semiSaturation(At.DAYLIGHT_ANCHOR_CD_M2)}setMeteorShower(t,e,i){this.meteorSystem||(this.meteorSystem=new yi,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(t,e,i)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(t){return this.meteorSystem?.midpointOf(t)}updateMeteors(t){this.meteorSystem?.update(t)}setInstrument(t){this.projectionKind=t.projection,this.grain=t.detailUm!==void 0&&t.frame?{detailUm:t.detailUm,frameHeightMm:t.frame.heightMm}:void 0;const e=fi.starPointsOf(t),i=fi.flareArtifactsOf(t);e===this.starPoints&&i===this.lensFlareArtifactIntensity||(this.starPoints=e,this.lensFlareArtifactIntensity=i,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=e,this.lensFlare.uniforms.uFlareIntensity.value=i),this.render())}magnitudeLimitOf(t){const e=Mt.starLossMagnitudes(t.sun.altitudeDeg,{phaseAngleDeg:Mt.phaseAngleOf(t.moon.phase.illuminatedFraction),altitudeDeg:t.moon.altitudeDeg},this.lightPollution);return Ed(t.sun.altitudeDeg,this.instrumentMagnitudeGain,e)}setLightPollution(t){t!==this.lightPollution&&(this.lightPollution=t,this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}setInstrumentGain(t,e=!1){this.instrumentMagnitudeGain=Number.isFinite(t)?t:0,this.scatteredSky?.setInstrument(e,this.instrumentMagnitudeGain)}render(){this.restatingExposure||(this.sceneVersion++,this.frameDirty=!0,this.resolution.noteChange(performance.now()),!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()})))}drawIfDirty(){if(!(!this.frameDirty||this.contextReleased)){if(this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy),this.compileBeforeNextDraw){this.compileBeforeNextDraw=!1;const t=this.compileOffThread().then(()=>{this.compiling===t&&(this.compiling=void 0,this.render())});this.compiling=t;return}if(!this.compiling){if(this.skyHoldUntilMs){if(!this.sceneSettled()&&performance.now()<this.skyHoldUntilMs){this.firstFrameReady()&&this.refreshReflections(!0);return}this.skyHoldUntilMs=null,this.iceHalos?.setUrgent(!1),this.onFirstFrameHold?.(!1),this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy)}this.frameDirty=!1,this.refreshReflections(),this.resolution.beginDrawing();try{this.renderOnce(),this.drawn++}finally{this.resolution.endDrawing()}this.developingExposure&&this.startExposure()}}}drawn=0;get framesDrawn(){return this.drawn}compileBeforeNextDraw=!1;compiling;static COMPILE_WAIT_MS=1500;compileOffThread(){const t=this.renderer.compile(this.scene,this.camera);if(!this.renderer.extensions.get("KHR_parallel_shader_compile"))return Promise.resolve();const e=this.renderer.properties,i=performance.now()+ke.COMPILE_WAIT_MS;return new Promise(n=>{const s=()=>{if(this.contextReleased)return n();for(const a of t){const o=e.get(a)?.currentProgram;(!o||o.isReady())&&t.delete(a)}t.size===0||performance.now()>i?n():setTimeout(s,10)};s()})}compileNextFrameOffThread(){this.compileBeforeNextDraw=!0}contextReleased=!1;releaseContext(){this.contextReleased||(this.contextReleased=!0,this.stopTwinkle(),this.cancelFlush(),this.cancelExposure(),this.compiling=void 0,this.cancelScatteredSkyPump(),this.renderer.forceContextLoss())}restoreContext(){this.contextReleased&&(this.contextReleased=!1,this.renderer.forceContextRestore(),this.scatteredSky?.invalidate(),this.pumpScatteredSky(),this.compileNextFrameOffThread(),this.syncAnimationLoop(),this.render())}cancelFlush(){this.flushFrameId!==null&&(cancelAnimationFrame(this.flushFrameId),this.flushFrameId=null)}frame(t){if(this.animationsRunning){const e=this.lastFrameTimeMs===void 0?0:t-this.lastFrameTimeMs;this.lastFrameTimeMs=t,this.hasAnimations()&&this.animate(t,e);const i=this.resolution.ratioFor(t,e);i!==this.renderer.getPixelRatio()&&this.applyPixelRatio(i)}this.drawIfDirty()}refreshReflections(t=!1){this.reflections??=new on(this.renderer);const e=[...this.compassSprites,...this.lensFlare?[this.lensFlare.mesh]:[],...[...this.glareSprites.values()].map(o=>o.mesh)],i=[...this.starTiers.map(o=>o.points),...[...this.bodyMeshes.values()].filter(o=>o instanceof xs),...[this.rainSystem?.points,this.precipitationPoints,this.rainSplashSystem?.points].filter(o=>o!==void 0)],n=this.relativeScale,s=this.sceneVersion,a=this.reflections.refresh(this.renderer,this.scene,this.camera.position,this.bodySystem.reflectors,e,[...this.decorGroups.values()],s,i,o=>this.measureSurroundings(o,n,s),t?0:on.REFRESH_MS);a===void 0||this.reflectionTimer||(this.reflectionTimer=setTimeout(()=>{this.reflectionTimer=void 0,this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()}))},a))}measureSurroundings(t,e,i){const n=this.lastAstronomy;if(!n)return;this.probeIrradiance??=new To;const s=[n.sun,n.moon].filter(a=>a.altitudeDeg>-2).map(a=>hi(a.altitudeDeg,a.azimuthDeg,1));this.probeIrradiance.measure(this.renderer,t,s,a=>{const o=f=>f.map(p=>p/e),c=this.surroundings,l={up:o(a.up),down:o(a.down)},h=(f,p)=>f.some((v,m)=>Math.abs(v-p[m])>.03*Math.max(Math.abs(v),Math.abs(p[m]),1e-12)),u=!c||h(c.up,l.up)||h(c.down,l.down);u&&(this.surroundings=l),this.eyeSettledVersion=-1;const d=this.scatteredSky?.adaptToSurroundings(Math.exp(a.logAverage)/e)??!1;if(!u&&!d){this.eyeSettledVersion=i,this.skyHoldUntilMs&&this.redrawHeld();return}this.skyColoursStale=!0,this.render()})}lightUnderClouds(t){const e=this.surroundings;if(!e)return;const i=t.sun.altitudeDeg>=$c?t.sun:t.moon.altitudeDeg>=$c?t.moon:void 0;if(!i)return;const n=this.relativeScale/Math.PI;return{through:this.cloudTransmission(i),radiance:[e.up[0]*n,e.up[1]*n,e.up[2]*n]}}probeIrradiance;surroundings;animate(t,e){const i=Math.min(e/1e3,uE);this.twinkleSeconds=t/1e3,this.updateTwinkle(this.twinkleSeconds),this.updatePrecipitation(t/1e3,i),this.updateRain(i),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=t/1e3),this.developingExposure||(this.frameDirty=!0)}setMaxPixelRatio(t){this.resolution.maximum=t,this.renderer.getPixelRatio()>this.resolution.maximum&&this.applyPixelRatio(this.resolution.maximum)}applyPixelRatio(t){this.renderer.setPixelRatio(t),this.renderer.setSize(this.cssSize.width,this.cssSize.height,!1),this.frameDirty=!0}setExposure(t,e){const i=e?Math.max(1,Math.round(t)):1;if(i===this.exposureInstants&&(i===1||e===this.exposureInstantAt)){this.exposureInstantAt=e;return}this.exposureInstants=i,this.exposureInstantAt=e,i===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(t){if(this.onMapSubjectBounds){const a=this.mapSubjectBounds();t?this.exposureSubjectBounds.push(...a):this.onMapSubjectBounds(a)}const e=this.usableEquidistantPass();this.phenomena.setCloudLayers(this.layeredClouds?.volumes??[]),this.phenomena.place(this.camera,(a,o,c)=>this.directionAtScreenPoint(a,o,c),a=>this.screenPointOf(a)),this.references.place(this.camera);const i=Math.max(this.phenomena.furthestM,this.references.furthestM)*1.2;i>this.camera.far&&(this.camera.far=i,this.camera.updateProjectionMatrix()),Hi.uRodShare.value=this.scatteredSky?.rodShare??0,Hi.uRelativeScale.value=this.relativeScale,this.applyMedium();const n=this.references.any||this.phenomena.any||this.compassSprites.some(a=>a.visible);Hi.uHasOverlay.value=n?1:0;const s=n?a=>this.renderOverlayPasses(a):void 0;if(this.skyGlow?.setDestinationEncoded(!1),!e){this.updateLensFlarePosition();const a=this.usableDepthOfFieldPass();a?a.render(this.renderer,this.scene,this.camera,s,t):this.usableFinishPass().render(this.renderer,this.scene,this.camera,s,void 0,t);return}e.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),s,a=>{this.lensFlare&&(this.lensFlare.mesh.visible=a?!1:this.sunVisible)},()=>this.renderDazzleOnResample(),t)}renderOverlayPasses(t=this.camera){this.renderReferencesPass(t),this.renderPhenomenaPass(t),this.renderHudPass(t)}renderHudPass(t){if(!this.compassSprites.some(n=>n.visible))return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,t.layers.set(ym),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}renderReferencesPass(t){if(!this.references.any)return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,t.layers.set(H1),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}setReferences(t,e){this.references.set(t.map(i=>{const n=this.documentRelative(i.src);return n===i.src?i:{...i,src:n}}),void 0,e)}referenceAspect(t){return this.references.aspectOf(t)}directionAt(t,e){return this.directionAtScreenPoint(t,e,new R)}referenceFailedToLoad(t){return this.references.failedToLoad(this.documentRelative(t))}setReferencesShown(t){this.references.setShown(t),this.render()}setReferenceView(t,e){this.references.setView(t,e),this.render()}renderPhenomenaPass(t){if(!this.phenomena.any)return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const s=this.decorGroups.get(n.id);s&&ke.markDecorDepth(s,n.kind!=="crop")}t.layers.set(iu),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,t),this.scene.overrideMaterial=null,t.layers.set(B1),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}decorDepthMaterial=new _n({colorWrite:!1});static markDecorDepth(t,e){t.traverse(i=>{if(!(i instanceof Dt))return;const n=Array.isArray(i.material)?i.material[0]:i.material;e&&n.depthWrite!==!1&&n.blending!==Ni?i.layers.enable(iu):i.layers.disable(iu)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const t=this.renderer.getDrawingBufferSize(new xt),e=Math.max(1,Math.round(t.x)),i=Math.max(1,Math.round(t.y));this.exposureAccumulation||(this.exposureAccumulation=new Sb(e,i)),this.exposureAccumulation.resize(e,i),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const t=this.exposureInstantAt,e=this.exposureAccumulation;if(!t||!e)return;const i=1/this.exposureInstants;this.resolution.beginDrawing();const n=performance.now()+ke.EXPOSURE_BUDGET_MS,s=ke.exposureInstantsPerFrame(e.instantTarget.scene.width*e.instantTarget.scene.height);let a=0;do{this.restateAt(t,this.exposureInstantsDone);const o=this.compassSprites.map(c=>c.visible);for(const c of this.compassSprites)c.visible=!1;try{this.renderOnce(e.instantTarget)}finally{this.compassSprites.forEach((c,l)=>{c.visible=o[l]})}e.add(this.renderer,i),this.exposureInstantsDone++,a++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<n&&a<s);this.restateAt(t,0),this.presentExposure(),this.resolution.endDrawing(),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}presentExposure(){if(Hi.uRodShare.value=this.scatteredSky?.rodShare??0,Hi.uHasOverlay.value=1,Hi.uRelativeScale.value=this.relativeScale,this.applyMedium(),this.exposureAccumulation?.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.onMapSubjectBounds?.(this.exposureSubjectBounds),!this.compassSprites.some(s=>s.visible))return;const t=new Ts,e=new Un(-1,1,1,-1,0,2),i=Kc/(Tm*Math.tan(Rm*qi/2));for(const s of this.compassSprites){if(!s.visible)continue;const a=s.getWorldPosition(new R).sub(this.camera.position).normalize(),o=this.screenPointOf(a);if(!o)continue;const c=new Jr(s.material);c.position.set(o.ndcX,o.ndcY,-1),c.scale.set(i/this.camera.aspect,i,1),t.add(c)}const n=this.renderer.autoClear;this.renderer.autoClear=!1;try{this.renderer.render(t,e)}finally{this.renderer.autoClear=n}}onMapSubjectBounds;exposureSubjectBounds=[];static MAP_SUBJECT_NEAREST_M=8;mapSubjectBounds(){const t=[],e=new Vi,i=new R,n=this.camera.getWorldDirection(new R),s=this.decorObjects.filter(o=>o.track?.length||o.kind==="aircraft"||o.kind==="vehicle").map(o=>this.decorGroups.get(o.id)),a=this.bodySystem.reflectors.map(o=>o.holder);for(const o of[...s,...a]){if(!o?.visible||(e.setFromObject(o),e.isEmpty())||e.distanceToPoint(this.camera.position)<ke.MAP_SUBJECT_NEAREST_M)continue;let c=1/0,l=-1/0,h=1/0,u=-1/0;for(const d of[e.min.x,e.max.x])for(const f of[e.min.y,e.max.y])for(const p of[e.min.z,e.max.z]){if(i.set(d,f,p).sub(this.camera.position).normalize(),i.dot(n)<=0)continue;const v=this.screenPointOf(i);if(!v)continue;const m=(v.ndcX+1)/2,g=(1-v.ndcY)/2;c=Math.min(c,m),l=Math.max(l,m),h=Math.min(h,g),u=Math.max(u,g)}c=Math.max(c,0),l=Math.min(l,1),h=Math.max(h,0),u=Math.min(u,1),l>=c&&u>=h&&t.push({x:c,y:h,width:l-c,height:u-h})}return t}restateAt(t,e){this.restatingExposure=!0;try{t(e)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(t){const e=this.lensOptics;this.lensOptics=t,(e===void 0!=(t===void 0)||e&&t&&(e.focalLengthMm!==t.focalLengthMm||e.fNumber!==t.fNumber||e.focusDistance!==t.focusDistance||e.frameHeightMm!==t.frameHeightMm))&&(t&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.render())}usableDepthOfFieldPass(){const t=this.lensOptics;if(!t)return;const e=this.renderer.getDrawingBufferSize(new xt),i=Math.max(1,Math.round(e.x)),n=Math.max(1,Math.round(e.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new Ro(i,n)),this.depthOfFieldPass.resize(i,n),this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.depthOfFieldPass}usableFinishPass(){const t=this.renderer.getDrawingBufferSize(new xt);return this.finishPass?this.finishPass.resize(t.x,t.y):this.finishPass=new k0(t.x,t.y),this.finishPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const t=this.renderer.getDrawingBufferSize(new xt);return this.equidistantPass?this.equidistantPass.resize(t.x,t.y):this.equidistantPass=new We(t.x,t.y),this.equidistantPass}aimAtScreenPoint(t,e,i){const n=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!n){t.setFromCamera(new xt(e,i),this.camera);return}const s=n.directionFor(e,i,this.camera.fov);this.camera.updateMatrixWorld(),t.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),t.ray.direction.set(s.x,s.y,s.z).applyQuaternion(this.camera.quaternion).normalize(),t.camera=this.camera}pickCloudAt(t,e){return this.layeredClouds?.pickInstance(this.cloudDirectionAt(t,e))}cloudDirectionAt(t,e){return this.directionAtScreenPoint(t,e,new R)}directionAtScreenPoint(t,e,i){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),i.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(t){this.camera.updateMatrixWorld();const e=this.screenPointScratch.copy(t).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert()),i=this.renderer.getDrawingBufferSize(this.screenPointSize),n=i.x/Math.max(i.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return We.ndcFor(e,this.camera.fov,n);if(e.z>=0)return;const s=Math.tan(this.camera.fov/2*qi);return{ndcX:e.x/-e.z/(n*s),ndcY:e.y/-e.z/s}}screenPointScratch=new R;screenPointQuaternion=new Qi;screenPointSize=new xt;updateLensFlarePosition(){const t=this.lensFlare;if(!t)return;if(!this.sunVisible){t.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){t.mesh.visible=!1;return}const e=this.sunVisibleFraction();if(e<=0){t.mesh.visible=!1;return}t.mesh.visible=!0,this.sunUnhiddenFraction=e,this.applyDazzleStrength();const i=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);t.uniforms.uLensPosition.value.set(i.x,i.y);const n=this.renderer.domElement.width,s=this.renderer.domElement.height;t.uniforms.uResolution.value.set(n,s),t.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}renderDazzleOnResample(){const t=this.lensFlare;if(!t||!this.sunVisible)return;const e=this.sunVisibleFraction();if(e<=0)return;this.sunUnhiddenFraction=e,this.applyDazzleStrength();const i=this.screenPointOf(this.lensFlareScratch.copy(this.sunWorldPosition).sub(this.camera.position).normalize());if(!i)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize);t.uniforms.uLensPosition.value.set(i.ndcX,i.ndcY),t.uniforms.uResolution.value.set(n.x,n.y),t.uniforms.uEquidistant.value=1,t.uniforms.uHalfFovRad.value=this.camera.fov*Math.PI/360;const s=this.renderer.autoClear;this.renderer.autoClear=!1,t.mesh.visible=!0,t.mesh.layers.enable(xm),this.camera.layers.set(xm),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),t.mesh.visible=!1,t.uniforms.uEquidistant.value=0,this.renderer.autoClear=s}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let t=0;for(const e of Im)this.isSunOccluded(e[0],e[1])||t++;return t/Im.length}raycastableDecor(){const t=[];for(const e of this.decorObjects){if(e.kind==="crop")continue;const i=this.decorGroups.get(e.id);i&&t.push(i)}return t}isSunOccluded(t=0,e=0){const i=this.raycastableDecor();if(!this.groundMesh&&!this.terrainMesh&&i.length===0)return!1;const n=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),s=n.length();if(n.normalize(),t!==0||e!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(n.z,0,-n.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,n).normalize();n.addScaledVector(c,t*o).addScaledVector(l,e*o).normalize()}if(this.groundBlocks(this.camera.position,n,s))return!0;if(i.length===0)return!1;this.sunOcclusionRaycaster.set(this.camera.position,n);const a=this.sunOcclusionRaycaster.intersectObjects(i,!0)[0];return a!==void 0&&a.distance<s}groundBlocks(t,e,i,n=0){const s=this.groundMesh;if(s&&e.y<0){const m=(s.position.y-t.y)/e.y;if(m>n&&m<i){const g=t.x+e.x*m-s.position.x,S=t.z+e.z*m-s.position.z;if(Math.hypot(g,S)<=this.groundRadius)return!0}}const a=this.terrainMesh;if(!a)return!1;const o=a.geometry.getAttribute("position"),c=Math.round(Math.sqrt(o.count));if(c<2||c*c!==o.count)return!1;const l=[a.position.x+o.getX(0),a.position.x+o.getX(c-1)],h=[a.position.z+o.getZ(0),a.position.z+o.getZ((c-1)*c)],u=Math.min(Math.abs(l[1]-l[0]),Math.abs(h[1]-h[0]))/(c-1);if(!(u>0))return!1;let d=n,f=i;for(const[m,g,S]of[[t.x,e.x,l],[t.z,e.z,h]]){const y=Math.min(S[0],S[1]),M=Math.max(S[0],S[1]);if(Math.abs(g)<1e-12){if(m<y||m>M)return!1;continue}const b=(y-m)/g,w=(M-m)/g;d=Math.max(d,Math.min(b,w)),f=Math.min(f,Math.max(b,w))}if(!(f>d))return!1;const p=Math.hypot(e.x,e.z),v=Math.min(4096,Math.max(8,Math.ceil((f-d)*p/(u/2))));for(let m=0;m<=v;m++){const g=d+(f-d)*m/v,S=t.x+e.x*g,y=t.y+e.y*g,M=t.z+e.z*g;if(y<=this.groundYUnder(S,M))return!0}return!1}setPhenomena(t,e){this.phenomena.set(t,e)}decorDistancesAt(t,e,i){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=_m;let n,s;for(const a of this.decorObjects){if(a.kind==="crop")continue;const o=this.decorGroups.get(a.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(a.occludesSourceIds?.includes(i)?n=n===void 0?c.distance:Math.max(n,c.distance):s=s===void 0?c.distance:Math.min(s,c.distance))}return{behindM:n,inFrontM:s}}pickBodyAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const i=[...this.hitAreas.entries()],n=this.raycaster.intersectObjects(i.map(([,s])=>s))[0];if(n&&!this.groundHides(t,e))return i.find(([,s])=>s===n.object)?.[0]}pickStarAt(t,e){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,t,e);const i=this.raycaster.ray.direction,n=Math.cos(bm*this.camera.fov*Math.PI/180);let s,a=n;for(const o of this.namedStars){const c=o.direction.dot(i);c>a&&(a=c,s={star:o.star,altitudeDeg:o.altitudeDeg})}return s&&this.groundHides(t,e)?void 0:s}groundHides(t,e){if(!this.terrainMesh&&!this.groundMesh)return!1;this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e);const i=this.ufoOcclusionRaycaster.ray;return this.groundBlocks(i.origin,i.direction,1/0,_m)}bodyScreenBox(t){const e=this.bodySystem.boxOf(t,this.bodyBoxScratch);if(!e)return;let i=1/0,n=1/0,s=-1/0,a=-1/0;for(let o=0;o<8;o++){const c=this.bodyCornerScratch.set(o&1?e.max.x:e.min.x,o&2?e.max.y:e.min.y,o&4?e.max.z:e.min.z),l=this.screenPointOf(c.sub(this.camera.position).normalize());if(!l)return;i=Math.min(i,l.ndcX),s=Math.max(s,l.ndcX),n=Math.min(n,l.ndcY),a=Math.max(a,l.ndcY)}return{minX:i,minY:n,maxX:s,maxY:a}}bodyBoxScratch=new Vi;bodyCornerScratch=new R;pickPlacedBodyAt(t,e){return this.aimAtScreenPoint(this.raycaster,t,e),this.bodySystem.pick(this.raycaster)}pickDecorAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const i=[...this.decorGroups.entries()],n=this.raycaster.intersectObjects(i.map(([,a])=>a),!0)[0];if(!n)return;let s=n.object;for(;s&&!i.some(([,a])=>a===s);)s=s.parent;return i.find(([,a])=>a===s)?.[0]}dispose(){this.stopTerrainFade(),this.stopTwinkle(),this.cancelFlush(),this.phenomena.clear(),this.references.disposeAll(),this.terrainBuildToken++,this.cancelScatteredSkyPump(),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.skyGradientMaterial),this.scatteredSky?.dispose(),this.scatteredSky=void 0,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.roadSystem.dispose(),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.finishPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0,this.satelliteField?.dispose(),this.satelliteField=void 0,this.lightningBolt?.dispose(),this.lightningBolt=void 0;for(const t of this.bodyMeshes.values())this.disposeMesh(t);this.bodyMeshes.clear(),this.novaKeys.clear();for(const t of[...this.hitAreas.keys()])this.disposeHitArea(t);for(const t of[...this.glareSprites.keys()])this.disposeGlare(t);this.disposeCompassLabels();for(const t of this.decorGroups.values())ui.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear(),this.lensFlare&&(this.lensFlare.mesh.removeFromParent(),this.lensFlare.mesh.geometry.dispose(),this.lensFlare.mesh.material.dispose(),this.lensFlare=void 0),this.renderer.dispose()}animationsRunning=!1;startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;this.cancelFlush();const t=e=>{this.frame(e),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}setAnimationsRunning(t,e=!1){const i=t&&e;if(t===this.animationsRunning&&i===this.framesDriven)return;const n=this.animationsRunning;this.animationsRunning=t,this.framesDriven=i,t&&!n&&(this.lastFrameTimeMs=void 0,this.resolution.reset());const s=!t&&this.renderer.getPixelRatio()!==this.resolution.maximum;s&&this.applyPixelRatio(this.resolution.maximum),this.syncAnimationLoop(),(!t||this.frameDirty)&&this.render(),s&&this.drawIfDirty()}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}needsAnimationLoop(){return this.animationsRunning&&!this.framesDriven&&this.hasAnimations()}hasAnimations(){return this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lensFlare!==void 0&&this.sunVisible}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(t){const e=this.skyMesh?.geometry??new oi(Yc,32,16),i=e.attributes.position,n=e.getAttribute("color")??new de(new Float32Array(i.count*3),3);for(let a=0;a<i.count;a++){const{altitudeDeg:o,azimuthDeg:c}=Eb(i.getX(a),i.getY(a),i.getZ(a)),l=Lb(o,c,t.azimuthDeg,t.altitudeDeg);n.setXYZ(a,l[0],l[1],l[2])}if(n.needsUpdate=!0,this.skyMesh)return;e.setAttribute("color",n);const s=new _n({vertexColors:!0,side:Ve,fog:!1,depthWrite:!1});this.skyGradientMaterial=s,this.skyMesh=new Dt(e,s),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const t=Sm(this.observerElevationM);if(this.groundMesh&&t===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=t;const e=new v0(this.groundRadius,48),i=new kr({color:new st(nu,nu,nu),fog:!0});Pa.fadeRim(i,this.groundRadius*.75,this.groundRadius),this.groundMesh=new Dt(e,i),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const t=this.groundMesh?.material;if(!t)return;const e=this.terrainMesh===void 0;t.depthWrite!==e&&(t.depthWrite=e,t.needsUpdate=!0)}cloudTransmission(t,e=!1){const i=`${t.altitudeDeg.toFixed(1)}:${t.azimuthDeg.toFixed(1)}:${Math.round(this.cloudOffsetM.x/10)}:${Math.round(this.cloudOffsetM.z/10)}:${Math.round(this.observerElevationM)}:`+Object.entries(this.cloudLayerOffsetsM).map(([a,o])=>`${a}=${Math.round(o.x/10)},${Math.round(o.z/10)}`).join(";")+(e?":water":""),n=this.cloudTransmissionMemo.get(i);if(n!==void 0)return n;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const s=this.computeCloudTransmission(t,e);return this.cloudTransmissionMemo.set(i,s),s}cloudTransmissionMemo=new Map;computeCloudTransmission(t,e=!1){const i=hi(t.altitudeDeg,t.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(i,e);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-me.alphaAt(i,Math.abs(this.cloudLayerOffset()),s,this.cloudFieldOffset)*zw);const a=e?0:this.weather.highCloudCover??0;return a>0&&(n*=1-me.iceAlphaAt(i,qc,a,this.cloudFieldOffset)*Bw),Math.max(0,Math.min(1,n))}setBodyMesh(t,e,i,n,s){if(e.altitudeDeg<$d){this.disposeMesh(this.bodyMeshes.get(t)),this.bodyMeshes.delete(t),this.disposeHitArea(t),this.disposeGlare(t),t==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=hi(e.altitudeDeg,e.azimuthDeg,sn),l=Gp(e.altitudeDeg),h=this.cloudTransmission(e),u=this.arrivingIlluminance(e,s,h),d=ke.unitLuminance(n);let f=this.bodyMeshes.get(t);if(t==="sun"){const p=Math.PI*(i/sn)**2,v=[0,1,2].map(m=>Math.min(ke.BRIGHTEST_RELATIVE,d[m]*u[m]/p));f instanceof Dt||(this.disposeMesh(f),f=new Dt(new oi(1,16,16),new _n({fog:!1})),this.celestialGroup.add(f),this.bodyMeshes.set(t,f)),f.material.color.setRGB(v[0],v[1],v[2]),f.scale.setScalar(i)}else{if(!(f instanceof xs)){this.disposeMesh(f);const m=new ce;m.setAttribute("position",new ee(new Float32Array(3),3)),m.setAttribute("color",new ee(new Float32Array(3),3)),f=new xs(m,ae.material(Ao[Ao.length-1].size,!1)),ae.track(f),this.celestialGroup.add(f),this.bodyMeshes.set(t,f)}const p=f.geometry.getAttribute("color"),v=t.startsWith("comet:")?this.pointToPixel():1;p.setXYZ(0,d[0]*u[0]*v,d[1]*u[1]*v,d[2]*u[2]*v),p.needsUpdate=!0}if(f.position.set(a,o,c),this.setHitArea(t,a,o,c,i),t==="sun"&&(this.sunArriving=u),t.startsWith("comet:")?this.disposeGlare(t):t!=="sun"&&this.setGlare(t,a,o,c,u,i/sn*(180/Math.PI),ke.POINT_VEIL_HOLD_DEG),t==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*p,o*p+this.celestialGroup.position.y,c*p),this.lensFlare||(this.lensFlare=iw(),this.lensFlare.uniforms.uOpacity.value=Kw,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(t,e){const i="moon";if(t.magnitude>e||t.altitudeDeg<$d){this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i);return}const{x:n,y:s,z:a}=hi(t.altitudeDeg,t.azimuthDeg,sn),o=this.cloudTransmission(t),c=this.arrivingIlluminance(t,t.magnitude,o),l=Math.max(Mr(t.phase.illuminatedFraction,0,1),.01)*Math.PI*(ho/sn)**2,h=new st(...c.map(f=>Math.min(ke.BRIGHTEST_RELATIVE,f/l))),u=`${t.phase.phaseFraction<.5}:${Math.round(Mr(t.phase.illuminatedFraction,0,1)*500)}`;let d=this.bodyMeshes.get(i);if(d instanceof Jr)d.userData.phaseKey!==u&&(d.material.map?.dispose(),d.material.map=qm(t.phase),d.userData.phaseKey=u),d.material.color.copy(h);else{this.disposeMesh(d),d=new Jr(new rl({map:qm(t.phase),color:h,fog:!1})),d.userData.phaseKey=u;const f=ho*2;d.scale.set(f,f,1),this.celestialGroup.add(d),this.bodyMeshes.set(i,d)}d.position.set(n,s,a),this.setHitArea(i,n,s,a,ho),this.setGlare(i,n,s,a,c,ho/sn*(180/Math.PI))}bentLight(t,e,i=Uw){const[n,s,a]=this.arrivingIlluminance(t,e,1),o=Math.max(s,1e-30);return{scale:s/i,tint:[n/o,1,a/o]}}static litBySky(t,e){return ke.litScratch.setRGB(t.r*e[0],t.g*e[1],t.b*e[2])}static litScratch=new st;pointToPixel(){const t=Math.max(1,this.renderer.getDrawingBufferSize(this.pointScratch).y),e=(this.camera.fov*Math.PI/180/t)**2;return Math.min(1,ae.CONE_SOLID_ANGLE/e)}pointScratch=new xt;static POINT_VEIL_HOLD_DEG=.25;static BRIGHTEST_RELATIVE=6e4;arrivingIlluminance(t,e,i){const n=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,t.altitudeDeg),s=fe.illuminanceOf(e)*i*this.relativeScale;return[n[0]*s,n[1]*s,n[2]*s]}static unitLuminance(t){const e=On.luminanceOf([t.r,t.g,t.b]);return e>0?[t.r/e,t.g/e,t.b/e]:[1,1,1]}setHitArea(t,e,i,n,s){let a=this.hitAreas.get(t);if(!a){const c=new rl({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});a=new Jr(c),this.celestialGroup.add(a),this.hitAreas.set(t,a)}a.position.set(e,i,n);const o=s*Fw;a.scale.set(o,o,1)}disposeHitArea(t){const e=this.hitAreas.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.hitAreas.delete(t))}setGlare(t,e,i,n,s,a,o=0){if(Pi.radiusDeg(Pi.K*Math.max(...s))<=Math.max(a,o)){this.disposeGlare(t);return}let c=this.glareSprites.get(t);c||(c=new Pi(`veil:${t}`),this.celestialGroup.add(c.mesh),this.glareSprites.set(t,c)),c.shine({x:e,y:i,z:n},s,a,o)}disposeGlare(t){const e=this.glareSprites.get(t);e&&(e.mesh.removeFromParent(),e.dispose(),this.glareSprites.delete(t))}buildComet(t,e){const i=t&&`comet:${t.id}`;if(!t||!i||t.magnitude>e){this.disposeComet();return}this.cometKey&&this.cometKey!==i&&this.disposeComet();const n=vo(t.magnitude,e),s=Wh(n);this.cometKey=i,this.setBodyMesh(i,t.position,au*(.5+.5*n),new st(s,s,s),t.magnitude),this.cometTail||(this.cometTail=new rn(sn),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(t.position,t.tailEnd,n)}buildIceHalos(t,e){this.iceHalos||(this.iceHalos=new Ci,this.iceHalos.setCloudOffset(this.cloudFieldOffset),this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object)),this.iceHalos.setUrgent(!!this.skyHoldUntilMs);const i=this.highCloudCover(),n=this.layeredClouds?.cirrusMask;if(this.iceHalos.setCloudOffset(n?.offset??this.cloudFieldOffset),this.layeredClouds?.hostHalo(this.iceHalos),i===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:qc},0);return}const s=this.lowerCloudCover(),a=pe.deckLitUntilDeg(pe.DECK_HEIGHT_M),o=t.altitudeDeg>-a?t:e,c=this.bentLight(o,o===t?Ne.SUN_MAGNITUDE:e.magnitude),l=pe.strength(i,s,o.altitudeDeg,a)*c.scale,{x:h,y:u,z:d}=hi(o.altitudeDeg,o.azimuthDeg,1);this.iceHalos.update({x:h,y:u,z:d},o.altitudeDeg,l,c.tint,{cover:n?.cover??i,layerHeight:n?.layerHeight??qc},n?.iceCrystalAlignment??this.weather.iceCrystalAlignment??ev)}buildRainbow(t,e){this.rainbow||(this.rainbow=new Aa,this.celestialGroup.add(this.rainbow.object));const i=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity*(this.weather.precipitationAmount??1):0,n=t.altitudeDeg>0,s=n?t:e,a=this.lowerCloudCover(),o=this.bentLight(s,n?Ne.SUN_MAGNITUDE:e.magnitude,kw),c=an.strength(i,a,s.altitudeDeg)*o.scale;if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=hi(s.altitudeDeg,s.azimuthDeg,1);this.rainbow.update({x:l,y:h,z:u},c,o.tint,n)}buildSkyGlow(t,e){if(!t.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Xs,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:i,observer:n}=t.frame,s=Dn.galactic(i,n),a=ke.directionOf(s.centre),o=ke.directionOf(s.rotation),c=ke.directionOf(s.pole),l=new Yt().set(a.x,a.y,a.z,o.x,o.y,o.z,c.x,c.y,c.z),h=ke.directionOf(Dn.eclipticPole(i,n)),u=ke.directionOf(t.sun),d=u.clone().addScaledVector(h,-u.dot(h)).normalize();this.skyGlow.update({galactic:l,eclipticPole:h,sunLongitude:d,sunDirection:u,sunAltitudeDeg:t.sun.altitudeDeg,moon:{direction:ke.directionOf(t.moon),altitudeDeg:t.moon.altitudeDeg,phaseAngleDeg:Mt.phaseAngleOf(t.moon.phase.illuminatedFraction)},lightPollution:this.lightPollution,skyColor:new R(e[0],e[1],e[2])})}static directionOf(t){const{x:e,y:i,z:n}=hi(t.altitudeDeg,t.azimuthDeg,1);return new R(e,i,n).normalize()}buildNovae(t,e){const i=new Set;for(const n of t){if(n.magnitude>e)continue;const s=`nova:${n.id}`;i.add(s);const a=vo(n.magnitude,e),o=Wh(a);this.setBodyMesh(s,n.position,au*(.5+.5*a),new st(o,o,o),n.magnitude)}for(const n of this.novaKeys)i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n));this.novaKeys=i}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(t,e){const i=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[],...this.novaKeys]);for(const n of t){if(n.magnitude>e)continue;i.add(n.body);const s=vo(n.magnitude,e),a=Wh(s),o=mE[n.body]??new st(1,1,1),c=new st(o.r*a,o.g*a,o.b*a),l=au*(.5+.5*s);this.setBodyMesh(n.body,n.position,l,c,n.magnitude)}for(const n of[...this.bodyMeshes.keys()])i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n))}buildStars(t,e){if(this.namedStars=[],!t||t.catalog.count===0){this.disposeStarTiers(),this.syncAnimationLoop();return}const{catalog:i,date:n,observer:s}=t,a=new Pn(n,s),o=mu(1337),c=[],l=this.siteElevationM+this.observerElevationM;for(let h=0;h<i.count;h++){const u=i.mag[h];if(u>e)break;const{altitudeDeg:d,azimuthDeg:f}=a.position(i.ra[h],i.dec[h]);if(d<wm)continue;const{x:p,y:v,z:m}=hi(d,f,su);c.push({x:p,y:v,z:m,brightness:vo(u,e),illuminance:this.air.transmittanceFromSpace(l,d).map(g=>g*fe.illuminanceOf(u)),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const h of N5){if(h.mag>e)continue;const{altitudeDeg:u,azimuthDeg:d}=a.position(h.raHours,h.decDeg);if(u<wm)continue;const{x:f,y:p,z:v}=hi(u,d,su);this.namedStars.push({star:h,direction:new R(f,p,v).normalize(),altitudeDeg:u})}this.starTiers=Ao.map((h,u)=>{const d=c.filter(b=>h1(b.brightness)===u),f=new Float32Array(d.length*3),p=new Float32Array(d.length),v=new Float32Array(d.length*3),m=new Float32Array(d.length),g=new Float32Array(d.length);d.forEach((b,w)=>{f[w*3]=b.x,f[w*3+1]=b.y,f[w*3+2]=b.z,p[w]=b.brightness,v.set(b.illuminance,w*3),m[w]=b.phase,g[w]=b.speedFactor});const S=new ce;S.setAttribute("position",new ee(f,3)),S.setAttribute("seed",new ee(m.map(b=>b/(2*Math.PI)),1));const y=new ee(new Float32Array(d.length*3),3);S.setAttribute("color",y);let M=this.starTiers[u]?.points;return M?(M.geometry.dispose(),M.geometry=S):(M=new xs(S,ae.material(h.size)),ae.track(M),this.celestialGroup.add(M)),{points:M,colorAttribute:y,brightness:p,illuminance:v,phase:m,speedFactor:g}}),this.starColoursRelative=Number.NaN,this.updateTwinkle(this.twinkleSeconds),this.startTwinkle()}twinkleSeconds=0;starColoursRelative=Number.NaN;updateTwinkle(t){ae.setTime(t);const e=this.relativeScale;if(e!==this.starColoursRelative){this.starColoursRelative=e;for(const i of this.starTiers){const n=i.colorAttribute.array;for(let s=0;s<i.brightness.length;s++)n[s*3]=i.illuminance[s*3]*e,n[s*3+1]=i.illuminance[s*3+1]*e,n[s*3+2]=i.illuminance[s*3+2]*e;i.colorAttribute.needsUpdate=!0}}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new Er(this.celestialGroup,ru,this.cloudRendering)),this.disposeCirrus(),this.layeredClouds.hostHalo(this.iceHalos),this.layeredClouds.update(this.weather,this.observerElevationM+1.6),this.layeredClouds.setOffsets(this.cloudOffsetM,this.cloudLayerOffsetsM),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const t=this.lowerCloudCover();if(t<=0){this.disposeCloudSystem();return}const e=this.weather.cloudDarkness,i=new st(fa[0]+(lu[0]-fa[0])*e,fa[1]+(lu[1]-fa[1])*e,fa[2]+(lu[2]-fa[2])*e);if(this.cloudMesh&&this.cloudUniforms){this.cloudUniforms.coverage.value=t,this.cloudUniforms.baseColor.value.copy(i),this.syncCloudLayer(),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}this.disposeCloudSystem();const{material:n,uniforms:s}=xd(i,t,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=n,this.cloudUniforms=s,s.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=yd(ru);this.cloudMesh=new Dt(a,n),this.faceCloudDeck(this.cloudMesh,this.cloudLayerOffset()),this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(t=>t.type!=="cirrus").reduce((t,e)=>t*(1-e.coverage),1):this.weather.lowerCloudCover??this.weather.cloudCover}highCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(t=>t.type==="cirrus").reduce((t,e)=>t*(1-e.coverage),1):this.weather.highCloudCover}buildCirrus(){const t=this.weather.highCloudCover??0;if(this.layeredClouds||t<=0){this.disposeCirrus();return}if(this.cirrusMesh&&this.cirrusUniforms){this.cirrusUniforms.coverage.value=t,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const{material:e,uniforms:i}=xd(new st(...fa),t,qc,1);this.cirrusMaterial=e,this.cirrusUniforms=i,i.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new Dt(yd(ru*1.04),e),this.cirrusMesh.renderOrder=Cm-1,this.celestialGroup.add(this.cirrusMesh)}disposeCirrus(){this.cirrusMesh&&(this.cirrusMesh.removeFromParent(),this.cirrusMesh.geometry.dispose()),this.cirrusMaterial?.dispose(),this.cirrusMesh=void 0,this.cirrusMaterial=void 0,this.cirrusUniforms=void 0}syncCloudLayer(){this.layeredClouds?.update(this.weather,this.observerElevationM+1.6);const t=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(t)),this.cloudMesh&&this.faceCloudDeck(this.cloudMesh,t)}faceCloudDeck(t,e){const i=e<0;t.scale.y=i?-1:1,t.renderOrder=i?Er.deckOrder(!0,0,1):Cm}cloudLayerOffset(){const e=((this.weather.cloudBaseM??Zd)-this.observerElevationM)*ou;return Math.sign(e||1)*Math.max(Math.abs(e),Jw)}updateCloudLighting(t,e){const i=[this.cloudUniforms,this.cirrusUniforms].filter(u=>u!==void 0);if(i.length===0&&!this.layeredClouds)return;const n=this.cloudBeamDirection,[s,a,o]=this.cloudBeam.map(u=>u/Math.PI),c=this.lightningLevel*pu*this.relativeScale/Math.PI,l=new st(e[0]+Xn.r*c,e[1]+Xn.g*c,e[2]+Xn.b*c);this.layeredClouds?.setLighting(n.clone(),new st(s,a,o),l,l);const h=Math.max(0,n.y);for(const u of i)u.sunDir.value.copy(n),u.sunColor.value.setRGB(s*h,a*h,o*h),u.ambientColor.value.copy(l)}disposeCloudSystem(){this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.cloudMesh&&(this.cloudMesh.removeFromParent(),this.cloudMesh.geometry.dispose()),this.cloudMaterial?.dispose(),this.cloudMesh=void 0,this.cloudMaterial=void 0,this.cloudUniforms=void 0}disposePrecipitationPoints(){this.precipitationPoints&&(this.precipitationPoints.removeFromParent(),this.precipitationPoints.geometry.dispose(),this.precipitationPoints.material.dispose()),this.precipitationPoints=void 0,this.precipitationPositions=void 0,this.precipitationPhase=void 0,this.precipitationSpeedJitter=void 0,this.precipitationWobbleFreqJitter=void 0,this.precipitationWobbleAmpJitter=void 0,this.precipitationBounceRemaining=void 0,this.precipitationBounceHeight=void 0,this.precipitationBounceDuration=void 0,this.precipitationBounceVelX=void 0,this.precipitationBounceVelZ=void 0,this.precipitationUniforms=void 0}precipitationCount(t){return aE(t,this.weather.precipitationIntensity,this.weather.precipitationAmount??1)}updatePrecipitationDensity(){const t=[[this.rainSystem?.points,du],[this.rainSplashSystem?.points,pa],[this.precipitationPoints,this.weather.precipitationType==="none"||this.weather.precipitationType==="rain"?void 0:hu[this.weather.precipitationType].poolSize]];for(const[e,i]of t)e&&i!==void 0&&e.geometry.setDrawRange(0,this.precipitationCount(i));this.rainSystem&&(this.rainSystem.uniforms.uSpeedStreak.value=Nm(fu(this.weather.precipitationIntensity)))}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const t=this.weather.precipitationType;if(t==="none")return;if(t==="rain"){this.buildRain();return}const e=hu[t],i=e.poolSize,n=mu(9001),s=new Float32Array(i*3),a=new Float32Array(i),o=new Float32Array(i),c=new Float32Array(i),l=new Float32Array(i),h=new Float32Array(i),u=new Float32Array(i),d=new Float32Array(i),f=new Float32Array(i),p=new Float32Array(i);for(let y=0;y<i;y++){const M=n()*Math.PI*2,b=n()*e.radiusM;s[y*3]=Math.cos(M)*b,s[y*3+1]=dr+n()*(e.topYM-dr),s[y*3+2]=Math.sin(M)*b,a[y]=n()*Math.PI*2,o[y]=.7+n()*.6,c[y]=.6+n()*.8,l[y]=.4+n()*1.2}const v=new ce;v.setAttribute("position",new ee(s,3)),v.setDrawRange(0,this.precipitationCount(i));const m={uSize:{value:e.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:e.opacity},uColor:{value:e.color.clone()},uHazeColor:{value:new st(...this.baseFogColor)},uTexture:{value:gE(t)},uNearFocusDistance:{value:zm},uHazeDistance:{value:e.radiusM*Bm}},g=new le({uniforms:m,vertexShader:SE,fragmentShader:bE,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const S=new xs(v,g);S.renderOrder=cu,this.scene.add(S),this.precipitationPoints=S,this.precipitationPositions=s,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=p}updatePrecipitation(t,e){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter)return;this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor);const i=this.weather.precipitationType;if(i==="none"||i==="rain")return;const n=hu[i];if(this.precipitationUniforms?.uColor.value.copy(ke.litBySky(n.color,this.baseFogColor)),e<=0)return;const s=this.weather.windDirectionDeg*qi,a=Math.sin(s)*this.weather.windSpeed*n.driftSensitivity,o=-Math.cos(s)*this.weather.windSpeed*n.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,p=this.precipitationBounceHeight,v=this.precipitationBounceDuration,m=this.precipitationBounceVelX,g=this.precipitationBounceVelZ,S=i==="snow"&&u&&d,y=i==="hail"&&f&&p&&v&&m&&g;for(let M=0,b=0;M<c.length;M+=3,b++){if(y&&f[b]>0){if(f[b]-=e,f[b]<=0){const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A,f[b]=0}else{const x=1-f[b]/v[b];c[M+1]=dr+Math.sin(Math.PI*x)*p[b],c[M]=Zc(c[M]+(a+m[b])*e,n.radiusM),c[M+2]=Zc(c[M+2]+(o+g[b])*e,n.radiusM)}continue}let w=0,T=0;if(S){const x=oE*u[b],A=cE*d[b];w=Math.sin(t*x*Math.PI*2+l[b])*A,T=Math.sin(t*x*Math.PI*2+l[b]+Math.PI/2)*A}if(c[M]+=(a+w)*e,c[M+1]-=n.fallSpeedMPerS*h[b]*e,c[M+2]+=(o+T)*e,c[M]=Zc(c[M],n.radiusM),c[M+2]=Zc(c[M+2],n.radiusM),c[M+1]<dr){if(y){p[b]=Xm*(.2+Math.random()*1.6),v[b]=lE*(.5+Math.random()),f[b]=v[b];const C=Math.random()*Math.PI*2,I=hE*(p[b]/Xm);m[b]=Math.cos(C)*I,g[b]=Math.sin(C)*I,c[M+1]=dr;continue}const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=fu(this.weather.precipitationIntensity);this.rainSystem=j5({count:du,radiusM:uo,heightM:Qw,bottomYM:Pm,overallSpeed:tE,color:Om.clone(),opacity:.85,visibleCount:this.precipitationCount(du),speedStreak:Nm(t),pixelSize:Gm,seed:9001,nearFocusDistanceM:zm,hazeDistanceM:uo*Bm,hazeColor:new st(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=cu,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=mu(4242),e=new Float32Array(pa*3),i=new Float32Array(pa),n=new Float32Array(pa),s=new Float32Array(pa);for(let h=0;h<pa;h++){const u=t()*Math.PI*2,d=Math.sqrt(t())*uo;e[h*3]=Math.cos(u)*d,e[h*3+1]=Pm,e[h*3+2]=Math.sin(u)*d,n[h]=Ym(Fm,Um),i[h]=t()*n[h],s[h]=i[h]/n[h]}const a=new ce;a.setAttribute("position",new ee(e,3));const o=new ee(s,1);a.setAttribute("aLife",o),a.setDrawRange(0,this.precipitationCount(pa));const c=new le({uniforms:{uMaxSize:{value:sE},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:km.clone()},uTexture:{value:xE()}},vertexShader:yE,fragmentShader:_E,transparent:!0,depthWrite:!1}),l=new xs(a,c);l.renderOrder=cu,this.scene.add(l),this.rainSplashSystem={points:l,positions:e,life:i,duration:n,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.rainSystem.points.removeFromParent(),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.rainSplashSystem.points.removeFromParent(),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}syncRainSlant(){const t=this.rainSystem;if(!t)return;const e=this.weather.windDirectionDeg*qi;t.uniforms.uDropVelocity.value.set(Math.sin(e)*this.weather.windSpeed,-fu(this.weather.precipitationIntensity),-Math.cos(e)*this.weather.windSpeed);const i=this.renderer.getSize(this.rainViewportSize);t.uniforms.uAspect.value=i.x/Math.max(i.y,1)}updateRain(t){const e=this.rainSystem;if(!e)return;e.uniforms.uTime.value+=t,e.uniforms.uHazeColor.value.setRGB(...this.baseFogColor),e.uniforms.uColor.value.copy(ke.litBySky(Om,this.baseFogColor));const i=this.rainSplashSystem?.points.material?.uniforms?.uColor;i&&i.value.copy(ke.litBySky(km,this.baseFogColor));const n=this.weather.windDirectionDeg*qi,s=Math.sin(n)*this.weather.windSpeed,a=-Math.cos(n)*this.weather.windSpeed,o=uo,c=h=>(h%(o*2)+o*3)%(o*2)-o;e.uniforms.uWindOffset.value.set(c(e.uniforms.uWindOffset.value.x+s*t),c(e.uniforms.uWindOffset.value.y+a*t)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const l=Math.abs(this.rainCameraDirection.y);if(Math.abs(l-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=l;const h=Vm+(1-Vm)*(1-l),u=Wm+(1-Wm)*(1-l);e.uniforms.uUvSquash.value=u,e.uniforms.uPixelSize.value=Gm*h*(.5+.5*u)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:i,life:n,duration:s,lifeAttribute:a}=e,o=a.array;for(let c=0,l=0;c<i.length;c+=3,l++){if(n[l]+=t,n[l]>=s[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*uo;i[c]=Math.cos(h)*u,i[c+2]=Math.sin(h)*u,s[l]=Ym(Fm,Um),n[l]=0}o[l]=n[l]/s[l]}e.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}setLightning(t){this.lightningFlashes=t}updateLightning(t){let e,i=0;if(this.lightningArmed)for(const c of this.lightningFlashes){if(c.t>t)break;const l=pi.brightnessAt(c,t);l>i&&(e=c,i=l)}const n=e?Math.min(1,Math.max(.1,(fE/e.distanceM)**2)):0,s=i*n*(e?.cloudToGround?1:.6);if(s===this.lightningLevel&&!e?.cloudToGround)return;if(this.lightningLevel=s,this.scene.fog){const c=this.scene.fog,l=s*pu*this.relativeScale/Math.PI;c.color.setRGB(this.airlight[0]+Xn.r*l,this.airlight[1]+Xn.g*l,this.airlight[2]+Xn.b*l)}const a=this.skyMesh?.material?.color;if(a){const c=s*pE;a.setRGB(1+c*Xn.r,1+c*Xn.g,1+c*Xn.b)}if(this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.lightningLight.intensity=s*pu*this.relativeScale,e){const{x:c,y:l,z:h}=hi(25,e.azimuthDeg,sn);this.lightningLight.position.set(c,l,h)}this.lightningBolt||(this.lightningBolt=new Ys(sn*.95),this.celestialGroup.add(this.lightningBolt.object));const o=this.weather.cloudBaseM??1500;this.lightningBolt.set(e,i,o),this.render()}buildCompassLabels(){this.compassSprites=Gw.map(t=>{const e=Ia.point(t,this.compassPoints),i=new rl({map:wE(e),depthTest:!1,fog:!1}),n=new Jr(i),{x:s,y:a,z:o}=hi(0,t,Tm);return n.position.set(s,a,o),n.scale.set(Kc,Kc,1),n.renderOrder=Xw,n.layers.set(ym),n.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(n),n}),this.updateCompassScale()}updateCompassScale(){const t=this.camera.fov*Math.PI/360,e=Rm*Math.PI/360,i=Kc*Math.tan(t)/Math.tan(e);for(const n of this.compassSprites)n.scale.set(i,i,1)}disposeCompassLabels(){for(const t of this.compassSprites)t.removeFromParent(),t.material.map?.dispose(),t.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const t of this.starTiers)this.disposeMesh(t.points);this.starTiers=[]}disposeMesh(t){if(!t)return;t.removeFromParent(),"geometry"in t&&t.geometry.dispose();const e=t.material;for(const i of Array.isArray(e)?e:[e]){const n=i.map;n&&n.dispose(),i.dispose()}}}const qi=Math.PI/180;function Mr(r,t,e){return Math.max(t,Math.min(e,r))}function Ym(r,t){return r+Math.random()*(t-r)}function Zc(r,t){return(r%(t*2)+t*3)%(t*2)-t}let Jc,jc;function gE(r){switch(r){case"snow":return vE();case"hail":return ME()}}function vE(){if(Jc)return Jc;const r=64,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d"),i=e.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);return i.addColorStop(0,"rgba(255,255,255,0.95)"),i.addColorStop(.5,"rgba(255,255,255,0.55)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,r,r),Jc=new Is(t),Jc}function ME(){if(jc)return jc;const r=64,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d"),i=e.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(.55,"rgba(255,255,255,0.95)"),i.addColorStop(.8,"rgba(255,255,255,0.4)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,r,r),jc=new Is(t),jc}let Qc;function xE(){if(Qc)return Qc;const r=64,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d"),i=e.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);return i.addColorStop(0,"rgba(255,255,255,0)"),i.addColorStop(.4,"rgba(255,255,255,0)"),i.addColorStop(.6,"rgba(255,255,255,0.9)"),i.addColorStop(.8,"rgba(255,255,255,0.25)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,r,r),Qc=new Is(t),Qc}const yE=`
7566
+ `,transparent:!0,blending:Ni,depthWrite:!1,side:Ve,fog:!1});this.object=new Dt(new oi(z0.RADIUS,128,32,0,Math.PI*2,0,fe.MAX_ANGLE_RAD),e),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}show(t,e){if(!t||!e){this.object.visible=!1;return}this.towards.set(t.x,t.y,t.z).normalize(),this.object.quaternion.setFromUnitVectors(this.up,this.towards),this.object.material.uniforms.uSource.value.copy(this.towards);for(let i=0;i<fe.STEPS;i++){for(let n=0;n<3;n++)this.texels[i*4+n]=Fn.toHalfFloat(Math.min(e[i*3+n],6e4));this.texels[i*4+3]=Fn.toHalfFloat(1)}this.texture.needsUpdate=!0,this.object.visible=!0}dispose(){this.object.geometry.dispose(),this.object.material.dispose(),this.texture.dispose()}}class Ol{constructor(t){this.generator=t}static SIZE=128;target=new Vo(Ol.SIZE,{type:qe,generateMipmaps:!1,minFilter:oe,magFilter:oe});camera=new S0(.1,2e5,this.target);filteredTarget;capturedAtMs=-1/0;capturedVersion;get sharp(){return this.target.texture}get filtered(){return this.filteredTarget?.texture}capture(t,e,i,n=[]){const s=t.shadowMap.autoUpdate;t.shadowMap.autoUpdate=!1;const a=n.map(o=>o.visible);for(const o of n)o.visible=!1;this.camera.position.copy(i),this.camera.update(t,e),n.forEach((o,c)=>{o.visible=a[c]}),t.shadowMap.autoUpdate=s,this.filteredTarget=this.generator.fromCubemap(this.target.texture,this.filteredTarget),this.capturedAtMs=performance.now()}dispose(){this.target.dispose(),this.filteredTarget?.dispose()}}class on{static REFRESH_MS=250;generator;eye;probes=new Map;constructor(t){on.install(),this.generator=new md(t),this.eye=new Ol(this.generator)}static decor;refresh(t,e,i,n,s,a,o,c=[],l,h=on.REFRESH_MS){for(const m of[...this.probes.keys()])n.some(g=>g.id===m&&g.shiny)||(this.probes.get(m).dispose(),this.probes.delete(m));const u=[{probe:this.eye}];for(const m of n){if(!m.shiny)continue;let g=this.probes.get(m.id);g||(g=new Ol(this.generator),this.probes.set(m.id,g)),u.push({probe:g,reflector:m})}const d=performance.now(),f=()=>u.filter(({probe:m})=>m.capturedVersion!==o),p=f().filter(({probe:m})=>d-m.capturedAtMs>=h);if(p.length>0){const m=p.reduce((g,S)=>S.probe.capturedAtMs<g.probe.capturedAtMs?S:g);if(m.reflector){const g=m.reflector.holder.getWorldPosition(this.scratch);m.probe.capture(t,e,g,[m.reflector.holder,...s]),on.reflectOn(m.reflector.holder,m.probe)}else{m.probe.capture(t,e,i,[...s,...c]),l?.(m.probe.sharp),on.decor=m.probe.filtered;for(const g of a)on.reflectOn(g,m.probe);for(const g of n)g.shiny||on.reflectOn(g.holder,m.probe)}m.probe.capturedVersion=o}const v=f();if(v.length!==0)return Math.max(16,Math.min(...v.map(({probe:m})=>h-(d-m.capturedAtMs))))}scratch=new R;static reflectOn(t,e={filtered:on.decor}){t.traverse(i=>{const n=i.material;for(const s of Array.isArray(n)?n:n?[n]:[])s instanceof Xo?e.sharp&&s.setSurroundings(e.sharp):s instanceof xa&&e.filtered&&s.envMap!==e.filtered&&(s.envMap=e.filtered,s.needsUpdate=!0)})}dispose(){this.eye.dispose();for(const t of this.probes.values())t.dispose();this.generator.dispose()}static installed=!1;static install(){if(on.installed)return;on.installed=!0;const t="iblIrradiance += getIBLIrradiance( geometryNormal );";if(!Xt.lights_fragment_maps.includes(t)){console.warn("Reflections: three's lights_fragment_maps changed; the environment will light diffusely too");return}Xt.lights_fragment_maps=Xt.lights_fragment_maps.replace(t,"// The sky's diffuse light is the hemisphere light's (see Reflections).")}}function C5(r,t){return JSON.stringify(r.cloudLayers)===JSON.stringify(t.cloudLayers)&&r.cloudCover===t.cloudCover&&r.cloudDarkness===t.cloudDarkness&&r.cloudBaseM===t.cloudBaseM&&r.highCloudCover===t.highCloudCover&&r.iceCrystalAlignment===t.iceCrystalAlignment&&r.lowerCloudCover===t.lowerCloudCover&&r.relativeHumidity===t.relativeHumidity&&r.precipitationType===t.precipitationType&&r.precipitationIntensity===t.precipitationIntensity&&r.precipitationAmount===t.precipitationAmount&&r.windDirectionDeg===t.windDirectionDeg&&r.windSpeed===t.windSpeed&&r.storm===t.storm}const Yc=900,iu=1,xm=4,ym=5,_m=.5,yo=900,P5=6371e3,L5=3e4;function Sm(r){const t=Math.sqrt(2*P5*Math.max(r,0));return Math.max(yo,Math.min(t,L5))}const nu=.5,su=850,bm=.03,sn=850,lo=300,Gs=120,O5=700,N5=.04,ho=4,au=1.5,wm=-1,F5=6,$d=-4,U5=2,k5=20,qc=2600,z5=.97,B5=.38,$c=$d,Em=1500,H5=400,G5=[0,45,90,135,180,225,270,315],V5=2,W5=16,Am=4e3,Tm=880,Kc=40,Rm=60,X5=10,Y5=1,q5=150,$5=55,K5=.5,Z5=17,Dm=.265,Im=[[0,0],...Array.from({length:8},(r,t)=>{const e=t*Math.PI/4;return[Math.cos(e)*Dm,Math.sin(e)*Dm]})],ru=700,ou=250/Zd,J5=12,Cm=5,cu=6,fa=[.92,.92,.95],lu=[.15,.15,.19],hu={snow:{fallSpeedMPerS:2,size:.3,color:new st(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new st(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},dr=0,uu=0,j5=150,du=3e3,uo=20,Q5=15,Pm=dr,tE=40,Lm=1,eE=9;function fu(r){return Lm+(eE-Lm)*r}const Om=new st(.75,.82,.92),iE=10,nE=.5;function Nm(r){return Mr(r/iE,nE,1)}const pa=200,Fm=.18,Um=.32,sE=.35,km=new st(.85,.9,.98),zm=5,Bm=.85,Hm=.01;function aE(r,t,e=1){return Math.round(r*(Hm+(1-Hm)*t)*e)}function rE(r,t){return JSON.stringify(r.cloudLayers)===JSON.stringify(t.cloudLayers)&&r.cloudCover===t.cloudCover&&r.cloudDarkness===t.cloudDarkness&&r.cloudBaseM===t.cloudBaseM&&r.highCloudCover===t.highCloudCover&&r.iceCrystalAlignment===t.iceCrystalAlignment&&r.lowerCloudCover===t.lowerCloudCover}const Gm=230,Vm=.7,Wm=.05,oE=.6,cE=.7,lE=.15,Xm=.35,hE=3,uE=1/12,dE=.5,Xn=new st(.82,.86,1),fE=2500,pE=1.6,pu=15,mE={Venus:new st(1,.96,.85),Mars:new st(1,.55,.4),Jupiter:new st(.95,.87,.72),Saturn:new st(.92,.86,.68)};class ke{renderer;scene=new Ts;phenomena=new In(this.scene);references=new Rn(this.scene,()=>this.render());camera;celestialGroup=new Ce;skyMesh;skyGradientMaterial;scatteredSky;lastAstronomy;skyColoursStale=!1;scatteredSkyFrameId=null;skyHoldUntilMs=void 0;onFirstFrameHold;firstFrameReady(){return(!this.scatteredSky||this.scatteredSky.ambient!==void 0)&&!this.iceHalos?.awaitingFirstDisplay}sceneSettled(){return this.firstFrameReady()&&this.arrivalsPending===0&&this.eyeSettledVersion>=this.lastArrivalVersion}arrivalsPending=0;eyeSettledVersion=-1;lastArrivalVersion=0;awaitArrival(t,e){if(this.skyHoldUntilMs===null)return t;this.arrivalsPending++;let i=!0;const n=()=>{i&&(i=!1,this.arrivalsPending--,this.lastArrivalVersion=this.sceneVersion,this.skyHoldUntilMs&&this.redrawHeld())},s=e===void 0?void 0:setTimeout(n,e);return t.finally(()=>{clearTimeout(s),n()})}static ROADS_PATIENCE_MS=1500;redrawHeld(){this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()}))}holdForNewScene(t){this.surroundings=void 0,this.scatteredSky?.resetSurroundings(),this.startHold(),t&&this.awaitArrival(t).catch(()=>{})}startHold(){this.skyHoldUntilMs=performance.now()+Am,this.eyeSettledVersion=-1,this.lastArrivalVersion=this.sceneVersion+1,this.iceHalos?.setUrgent(!0),this.onFirstFrameHold?.(!0),setTimeout(()=>this.render(),Am+20)}groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;roadSystem=new gn;roadAttribution;roadWays;statedRoads=[];decorModelProvider=R5[0].create();decorModelToken=0;decorModelCredits=new Map;bodySystem=new ue(t=>this.awaitArrival(this.loadBodyModel(t)),()=>this.render(),()=>this.relativeScale);bodyOrigin={x:0,z:0};starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;decorReferencePose;decorCurrentPose;decorTime=0;celestialLight=new dp(16777215,0);celestialLightTarget=new Be;skyLight=new ex(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;resolution;cssSize={width:1,height:1};frameDirty=!1;flushFrameId=null;framesDriven=!1;lastFrameTimeMs;raycaster=new ol;weather=Jd;observerElevationM=0;siteElevationM=0;air=new xn;groundRadius=yo;terrainRadius=yo;cloudRendering="volume";layeredClouds;cloudLayerOffsetsM={};cloudOffsetM=new R;cloudFieldOffset=new R;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new R;rainLastVerticalFacing=-1;rainViewportSize=new xt;lightningArmed=!1;lightningFlashes=[];lightningLevel=0;lightningBolt;lightningLight=new dp(16777215,0);baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new R;sunVisible=!1;lensFlareScratch=new R;sunOcclusionRaycaster=new ol;sunOcclusionDirectionScratch=new R;sunOcclusionRightScratch=new R;sunOcclusionUpScratch=new R;ufoOcclusionRaycaster=new ol;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;finishPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;static exposureInstantsPerFrame(t){return Math.max(3,Math.round(6e6/Math.max(1,t)))}exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;lightPollution;meteorSystem;cometTail;satelliteField;iceHalos;lunarDiffraction;lunarDiffractionKey="";rainbow;skyGlow;cometKey;novaKeys=new Set;constructor(t,e=e2()){this.renderer=new pb({canvas:t,antialias:!0}),this.resolution=new ve(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=So,this.camera=new Zi(60,t.width/Math.max(t.height,1),.1,Yc*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=e,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-Gs,this.celestialLight.shadow.camera.right=Gs,this.celestialLight.shadow.camera.top=Gs,this.celestialLight.shadow.camera.bottom=-Gs,this.celestialLight.shadow.camera.near=sn-lo,this.celestialLight.shadow.camera.far=sn+lo,this.celestialLight.shadow.bias=-.03/(2*lo),this.celestialLight.shadow.normalBias=N5,this.celestialLight.target=this.celestialLightTarget,this.lightningLight.color.copy(Xn),this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight,this.lightningLight),this.scene.add(this.celestialGroup),this.scene.add(this.bodySystem.group),this.scene.add(this.roadSystem.group);const i=new Ne(this.renderer,()=>{this.skyColoursStale=!0,this.render()});i.supported?this.scatteredSky=i:i.dispose()}get currentTerrainAttribution(){return this.terrainAttribution}get currentRoadAttribution(){return this.roadAttribution}resize(t,e){this.cssSize.width=t,this.cssSize.height=e,this.renderer.setSize(t,e,!1),this.camera.aspect=t/Math.max(e,1),this.camera.updateProjectionMatrix(),this.render()}setCloudRendering(t){t!==this.cloudRendering&&(this.cloudTransmissionMemo.clear(),this.cloudRendering=t,this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.buildClouds(),this.buildCirrus(),this.render())}setCloudOffset(t,e={}){this.cloudOffsetM.set(t.x,0,t.z),this.cloudLayerOffsetsM=e,this.layeredClouds?.setOffsets(t,e),this.cloudFieldOffset.set(t.x*ou,0,t.z*ou);for(const i of[this.cloudUniforms,this.cirrusUniforms])i?.fieldOffset.value.copy(this.cloudFieldOffset);this.iceHalos?.setCloudOffset(this.layeredClouds?.cirrusMask?.offset??this.cloudFieldOffset)}setObserverPose(t){const e=((t.rollDeg??0)+this.gaitOffset.rollDeg)*qi,i=(t.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*qi;if(t.headingDeg!==void 0?this.camera.rotation.set(i,-(t.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*qi,e,"YXZ"):this.camera.rotation.set(i,this.camera.rotation.y,e,"YXZ"),t.elevationM!==this.observerElevationM&&(this.observerElevationM=t.elevationM,this.syncCloudLayer(),Math.abs(Sm(t.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/yo),this.camera.far=Math.max(Yc*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&t.lat!==void 0&&t.lng!==void 0){const n=ai(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=n.x,this.terrainMesh.position.z=n.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+t.elevationM,this.camera.position.y=this.poseCameraY,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==t.fovDeg&&(this.camera.fov=t.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(t){this.stopTerrainFade(),this.terrainProviders=t,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.roadSystem.clear(),this.roadAttribution=void 0,this.roadWays=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(t,e,i){if(t===void 0||e===void 0)return;const n=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-n)<n*.1){const{x:c,z:l}=ai(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<q5*(n/yo))return}const s=this.terrainOrigin,a=this.terrainRadius;(!s||s.lat!==t||s.lng!==e)&&(this.roadSystem.clear(),this.roadAttribution=void 0),this.terrainOrigin={lat:t,lng:e},this.terrainRadius=n;const o=++this.terrainBuildToken;this.awaitArrival(Bw(t,e,this.terrainProviders,n)).then(({mesh:c,attribution:l,originElevationM:h})=>{if(o!==this.terrainBuildToken)return;this.setSiteElevation(h??0);const u=this.terrainMesh,d=s?ai(t,e,s.lat,s.lng):void 0;u&&d&&Math.hypot(d.x,d.z)<=a&&(c.position.y=u.position.y+this.groundYOfPatch(u,d.x,d.z)),u&&d&&Math.hypot(d.x,d.z)<=a?this.crossfadeTerrain(c,u):this.disposeMesh(this.terrainMesh),c.renderOrder=Y5,this.terrainMesh=c,this.compileNextFrameOffThread(),this.terrainAttribution=l,this.scene.add(c),this.applyGroundDepthWrite(),this.decorCurrentPose&&(this.setObserverPose(this.decorCurrentPose),this.updateDecorAnchoring(this.decorReferencePose,this.decorCurrentPose,this.decorTime)),this.buildRoads(t,e,n),this.drapeStatedRoads(),this.render(),i?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),i?.()})}static TERRAIN_CROSSFADE_MS=1200;fadingTerrain;crossfadeTerrain(t,e){this.stopTerrainFade();const i=t.material;i.opacity=0,i.polygonOffset=!0,i.polygonOffsetFactor=-1,i.polygonOffsetUnits=-4;const n=performance.now(),s=()=>{const a=Math.min(1,(performance.now()-n)/ke.TERRAIN_CROSSFADE_MS);if(i.opacity=a*a*(3-2*a),this.render(),a<1&&this.fadingTerrain){this.fadingTerrain.frameId=requestAnimationFrame(s);return}i.polygonOffset=!1,i.opacity=1,this.fadingTerrain&&this.disposeMesh(this.fadingTerrain.mesh),this.fadingTerrain=void 0,this.render()};this.fadingTerrain={mesh:e,frameId:requestAnimationFrame(s)}}stopTerrainFade(){if(!this.fadingTerrain)return;cancelAnimationFrame(this.fadingTerrain.frameId),this.disposeMesh(this.fadingTerrain.mesh),this.fadingTerrain=void 0;const t=this.terrainMesh?.material;t&&(t.opacity=1,t.polygonOffset=!1)}static ROADS_MAX_RADIUS_M=5e3;buildRoads(t,e,i){const n=this.terrainProviders.roads;if(!n||i>ke.ROADS_MAX_RADIUS_M){this.roadSystem.clear(),this.roadAttribution=void 0;return}const s=this.roadWays;if(s&&s.lat===t&&s.lng===e&&s.radiusM===i){this.drapeRoads(s.ways,t,e,n.contemporary);return}this.awaitArrival(n.getRoads(I1(t,e,i)),ke.ROADS_PATIENCE_MS).then(a=>{this.terrainOrigin?.lat!==t||this.terrainOrigin?.lng!==e||(this.roadWays={lat:t,lng:e,radiusM:i,ways:a},this.drapeRoads(a,t,e,n.contemporary))}).catch(a=>{console.warn("Roads unavailable, drawing none:",a)})}setStatedRoads(t){t!==this.statedRoads&&(this.statedRoads=t,this.drapeStatedRoads(),this.render())}drapeStatedRoads(){const t=this.terrainMesh;t&&(this.roadSystem.group.position.copy(t.position),this.roadSystem.setStated(this.statedRoads,(e,i)=>this.groundYOfPatch(t,e,i)))}drapeRoads(t,e,i,n){const s=this.terrainMesh;s&&(this.roadSystem.group.position.copy(s.position),this.roadSystem.set(t,e,i,(a,o)=>this.groundYOfPatch(s,a,o),n),this.roadAttribution=t.length>0?this.terrainProviders.roads?.attribution:void 0,this.compileNextFrameOffThread(),this.render())}setShowCompass(t){this.showCompass!==t&&(this.showCompass=t,this.disposeCompassLabels(),t&&this.buildCompassLabels(),this.render())}setCompassPoints(t){this.compassPoints!==t&&(this.compassPoints=t,this.showCompass&&(this.disposeCompassLabels(),this.buildCompassLabels(),this.render()))}compassPoints;applyLensFlareTint(t){if(!this.lensFlare)return;const e=$5*(this.sunArriving[1]/Z5);this.lensFlare.uniforms.uColorGain.value.setRGB(e*t[0],e*t[1],e*t[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const[t,e,i]=this.sunArriving,n=Math.max(e,1e-30);this.lensFlare.uniforms.uDazzleColour.value.setRGB(t/n,1,i/n),this.lensFlare.uniforms.uVeilStrength.value=Pi.K*e*this.sunUnhiddenFraction}sunArriving=[0,0,0];setCompassHovered(t){this.compassHovered!==t&&(this.compassHovered=t,this.updateCompassVisibility())}setCompassForced(t){this.compassForced!==t&&(this.compassForced=t,this.updateCompassVisibility())}updateCompassVisibility(){const t=this.compassHovered||this.compassForced;if(this.compassSprites.some(e=>e.visible!==t)){for(const e of this.compassSprites)e.visible=t;this.developingExposure?this.exposureInstantsDone>0&&this.presentExposure():this.render()}}setWeather(t){if(C5(this.weather,t))return;this.cloudTransmissionMemo.clear();const e=this.weather;this.weather=t;const i=!rE(e,t),n=e.precipitationType!==t.precipitationType,s=e.precipitationIntensity!==t.precipitationIntensity||e.precipitationAmount!==t.precipitationAmount;(e.relativeHumidity!==t.relativeHumidity||n||s)&&(this.air=xn.of(t),this.applyAir(),this.scatteredSky?.setConditions({aerosolOpticalDepth:t.relativeHumidity===void 0?void 0:Qs.steppedOpticalDepth(t.relativeHumidity)}),this.pumpScatteredSky()),i&&(this.buildClouds(),this.buildCirrus()),n?this.buildPrecipitation():s&&this.updatePrecipitationDensity(),this.lastAstronomy&&(i&&(this.buildIceHalos(this.lastAstronomy.sun,this.lastAstronomy.moon),this.buildLunarDiffraction(this.lastAstronomy.moon)),(i||n||s)&&this.buildRainbow(this.lastAstronomy.sun,this.lastAstronomy.moon)),this.lightningArmed=t.storm&&t.cloudDarkness>=dE,this.syncAnimationLoop(),this.render()}setDecor(t){if(this.decorObjects!==t){this.decorObjects=t,this.decorModelToken++,this.decorModelCredits.clear();for(const e of this.decorGroups.values())e.removeFromParent(),ui.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear();for(const e of t){const i=ui.build(e,e.lit??!1);this.scene.add(i),this.decorGroups.set(e.id,i),e.kind==="streetlight"&&this.addStreetlightLight(e.id,i),this.awaitArrival(this.loadDecorModel(e,this.decorModelToken))}this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}}setDecorModelProvider(t){this.decorModelProvider=t;const e=this.decorObjects;this.decorObjects=[],this.setDecor(e)}get currentDecorModelCredits(){return[...this.decorModelCredits.values(),...this.bodySystem.modelCredits]}get bodyGround(){const{x:t,z:e}=this.bodyOrigin,i=this.groundYUnder(t,e);return{heightAt:(n,s)=>this.groundYUnder(t+n,e-s)-i}}setBodies(t,e=0,i=t.map(a=>a.id),n=[],s){const{x:a,z:o}=this.bodyOrigin,c=this.scatteredSky;this.bodySystem.set(t,{originX:a,originZ:o,originGroundY:this.groundYUnder(a,o),eye:this.camera.position,groundYAt:(h,u)=>this.groundYUnder(h,u),wind:s,light:this.plumeLight(),occluders:[...this.decorGroups.values()],transmittance:(h,u,d)=>this.transmittanceTo(h,u,d)},e,c?(h,u)=>c.relativeOfLuminance(h,u):void 0,i),this.bodySystem.setSmoke(n,e),this.bodySystem.any&&(this.celestialLight.castShadow=!0),this.fitShadowToBodies();const l=this.bodySystem.furthestFrom(this.camera.position)*1.2;l>this.camera.far&&(this.camera.far=l,this.camera.updateProjectionMatrix())}plumeLight(){const t=this.celestialLight.color,e=this.celestialLight.intensity*.5,i=this.skyLight.color,n=this.skyLight.groundColor,s=this.skyLight.intensity,a=(o,c,l)=>(o*e+(c+l)/2*s)/Math.PI;return[a(t.r,i.r,n.r),a(t.g,i.g,n.g),a(t.b,i.b,n.b)]}bodyOutline(t,e){return this.bodySystem.outlineOf(t,e)}documentUrl;modelUrl(t){return t.url?this.documentRelative(t.url):void 0}documentRelative(t){if(t.startsWith("data:"))return t;const e=this.documentUrl??(typeof location>"u"?void 0:location.href);return e?new URL(t,e).href:t}async loadBodyModel(t){const e=t.url?void 0:t.id?await this.decorModelProvider.entry(t.id):void 0,i=this.modelUrl(t)??e?.url,n=t.credit??e?.credit;if(!(!i||!n))return{scene:await Mm(i),credit:n,headingOffsetDeg:t.headingOffsetDeg??e?.headingOffsetDeg}}async loadDecorModel(t,e){const i=t.model;if(!(!i||!ui.usesModel(t)))try{const n=i.url?void 0:i.id?await this.decorModelProvider.entry(i.id):void 0,s=this.modelUrl(i)??n?.url,a=i.credit??n?.credit;if(!s||!a)return;const o=await Mm(s);if(e!==this.decorModelToken)return;const c=this.decorGroups.get(t.id);if(!c)return;on.reflectOn(o),ui.applyModel(c,t,o,{headingOffsetDeg:i.headingOffsetDeg??n?.headingOffsetDeg,depictedSizeM:n?.sizeM}),this.decorModelCredits.set(t.id,a),this.render()}catch(n){console.warn(`Keeping the built-in shape for decor "${t.id}":`,n)}}updateDecorAnchoring(t,e,i=0){this.decorReferencePose=t,this.decorCurrentPose=e,this.decorTime=i;const n=t?.lat!==void 0&&t.lng!==void 0&&e?.lat!==void 0&&e?.lng!==void 0?ai(t.lat,t.lng,e.lat,e.lng):{x:0,z:0},s=this.decorObjects.find(l=>l.observerSide!==void 0&&tg(l.kind));if(this.terrainMesh&&this.terrainOrigin&&e?.lat!==void 0&&e.lng!==void 0){const l=ai(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=l.x-(s?0:this.gaitOffset.eastM),this.terrainMesh.position.z=l.z+(s?0:this.gaitOffset.northM),this.roadSystem.group.position.copy(this.terrainMesh.position)}s||(n.x-=this.gaitOffset.eastM,n.z+=this.gaitOffset.northM,this.camera.position.y=this.poseCameraY+this.gaitOffset.upM,this.celestialGroup.position.y=this.camera.position.y);const a={x:0,z:0};let o=0;if(s){const l=ui.occupantView(s),h=-(s.headingDeg??0)*qi,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=s.eastM+n.x,p=-s.northM+n.z;a.x=-(f+u),a.z=-(p+d),this.camera.position.y=this.groundYUnder(f,p)+l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*qi,-(l.headingDeg+this.indoorLookYawDeg)*qi,0,"YXZ")}this.bodyOrigin={x:n.x+a.x,z:n.z+a.z},this.placeShadowFrustum();for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=Io(l,i),d=u.eastM+n.x+a.x,f=-u.northM+n.z+a.z,p=this.terrainMesh,v=`${p?.geometry.uuid}:${(d-(p?.position.x??0)).toFixed(3)}:${(f-(p?.position.z??0)).toFixed(3)}:${(p?.position.y??0).toFixed(3)}:${u.headingDeg}:${u.altitudeM}`;if(h.userData.footprintKey!==v&&(h.userData.footprintGroundY=this.groundUnderFootprint(l,d,f,u.headingDeg,u.altitudeM),h.userData.footprintKey=v),h.position.set(d,h.userData.footprintGroundY+u.altitudeM,f),l.kind==="crop"){const m=Math.hypot(d,f);h.visible=m<=j5}if(u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*qi),l.kind==="crop"&&h.visible){const m=this.terrainMesh,g=[m?.geometry.uuid,d-(m?.position.x??0),f-(m?.position.z??0),h.position.y-(m?.position.y??0),u.headingDeg,u.altitudeM].map(S=>typeof S=="number"?S.toFixed(4):S).join(":");h.userData.cropGroundKey!==g&&(ui.fitCropToGround(h,(S,y)=>this.groundYUnder(S,y)+u.altitudeM),h.userData.cropGroundKey=g)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(Yc*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}groundYUnder(t,e){const i=this.terrainMesh;return i?i.position.y+this.groundYOfPatch(i,t-i.position.x,e-i.position.z):uu}groundYOfPatch(t,e,i){const n=t.geometry.getAttribute("position"),s=Math.round(Math.sqrt(n.count));if(s<2||s*s!==n.count)return uu;const a=n.getX(0),o=n.getX(s-1),c=n.getZ(0),l=n.getZ((s-1)*s),h=Mr((e-a)/(o-a)*(s-1),0,s-1),u=Mr((i-c)/(l-c)*(s-1),0,s-1);if(!Number.isFinite(h)||!Number.isFinite(u))return uu;const d=Math.min(Math.floor(h),s-2),f=Math.min(Math.floor(u),s-2),p=h-d,v=u-f,m=(b,w)=>n.getY(b*s+w),g=m(f,d),S=m(f,d+1),y=m(f+1,d),M=m(f+1,d+1);return p+v<=1?g+(S-g)*p+(y-g)*v:M+(y-M)*(1-p)+(S-M)*(1-v)}groundUnderFootprint(t,e,i,n,s=0){return ui.groundUnderFootprint(t,e,i,n,(a,o)=>this.groundYUnder(a,o),s)}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(t){this.gaitOffset=t}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(t,e){this.lookYawDeg=t,this.lookPitchDeg=e}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(t,e){this.indoorLookYawDeg=t,this.indoorLookPitchDeg=e}medium;setMedium(t,e,i,n){const s=t&&e!==void 0&&e>0&&i!==void 0&&i>0?{kind:t.kind,iso:n??t.iso,autoExposure:t.autoExposure===!0,exposureSeconds:e,fNumber:i}:void 0;JSON.stringify(s)!==JSON.stringify(this.medium)&&(this.medium=s,this.render())}applyMedium(){const t=this.medium,e=Math.max(this.relativeScale,1e-30);if(!t){Hi.uMedium.value=0;return}Hi.uMedium.value=t.kind==="negative"?1:t.kind==="slide"?2:3;const i=t.autoExposure?this.scatteredSky?.sceneAdaptation:void 0;Hi.uMediumExposure.value=i!==void 0&&i>0?1/(e*i):.065*t.exposureSeconds*t.iso/(t.fNumber*t.fNumber*e)}grain;lampBloomRadiusRad(){if(!this.grain)return;const t=this.camera.fov*Math.PI/180,e=this.grain.frameHeightMm/(2*Math.tan(t/2)),i=Math.max(1,this.renderer.getDrawingBufferSize(this.bloomSize).y);return Math.max(this.grain.detailUm*.001/e,t/i)}bloomSize=new xt;updateDecorLitState(t,e=0){const i=this.lampBloomRadiusRad();for(const n of this.decorObjects){const s=this.decorGroups.get(n.id);if(s&&n.lights?.length&&ui.setLights(s,n.lights,t,s.position.distanceTo(this.camera.position),e,this.relativeScale,i),n.kind!=="streetlight"&&n.kind!=="vehicle")continue;const a=this.decorGroups.get(n.id);if(!a)continue;const o=Q1(n,t);ui.setLit(a,n.kind,o,this.relativeScale);const c=this.streetlightLights.get(n.id);c&&(c.visible=o)}}addStreetlightLight(t,e){const i=ui.bodyOf(e),n=i.children.find(a=>a.userData.emissive);if(!n)return;const s=new Zg(16764006,Em*this.relativeScale,H5);s.position.copy(n.position).multiply(i.scale),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,e.add(s),this.streetlightLights.set(t,s)}setAstronomy(t){(!this.lastAstronomy||Math.abs(this.lastAstronomy.sun.altitudeDeg-t.sun.altitudeDeg)>2)&&(this.surroundings=void 0,this.scatteredSky?.resetSurroundings()),this.lastAstronomy=t,this.scatteredSky?.update(this.scatteredSkyState(t)),this.skyHoldUntilMs===void 0&&this.startHold(),this.pumpScatteredSky(),this.lastSunPosition=t.sun,this.buildSky(t.sun),this.buildGround();const e=this.magnitudeLimitOf(t);this.buildStars(t.stars,e),this.placeBodies(t,e),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon),this.applySkyColours(t),this.syncAnimationLoop(),this.render()}static relativeSkyOf(t,e){const i=a=>{const o=On.luminanceOf(a);if(!(o>0))return[0,0,0];const c=At.relativeOfResponse(o)/o;return[a[0]*c,a[1]*c,a[2]*c]},n=i(t.zenith),s=i(t.horizon);return{zenith:n,horizon:s,airlight:s,skyIrradiance:[n[0]*Math.PI,n[1]*Math.PI,n[2]*Math.PI],scale:e}}placeBodies(t,e){this.bodiesScale=this.relativeScale,this.setBodyMesh("sun",t.sun,ho,new st(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon,e),this.buildPlanets(t.planets,e),this.buildComet(t.comet,e),this.buildNovae(t.novae??[],e)}bodiesScale=0;applySkyColours(t){this.skyColoursStale=!1,this.bodiesScale!==this.relativeScale&&(this.placeBodies(t,this.magnitudeLimitOf(t)),this.applyDazzleStrength(),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon));const e=this.scatteredSky?.ambient??ke.relativeSkyOf(wd(t.sun.altitudeDeg),this.relativeScale),i=e,n=this.lightUnderClouds(t),s=a=>n?[0,1,2].map(o=>a[o]*n.through+n.radiance[o]*(1-n.through)):[a[0],a[1],a[2]];this.baseFogColor=[i.horizon[0],i.horizon[1],i.horizon[2]],this.airlight=s(i.airlight),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.scatteredSky?.ready?this.scatteredSky.material:this.skyGradientMaterial),this.updateCelestialLight(t,e),this.updateCloudLighting(t.sun,this.baseFogColor),ae.setEye(this.scatteredSky?.rodShare??0,this.relativeScale),this.updateTwinkle(this.twinkleSeconds);for(const a of this.streetlightLights.values())a.intensity=Em*this.relativeScale;this.buildSkyGlow(t,i.zenith),this.applyAir(),this.buildLunarDiffraction(t.moon)}reflections;sceneVersion=0;reflectionTimer;buildLunarDiffraction(t){const e=this.scatteredSky?.ready?this.scatteredSky:void 0;if(t.altitudeDeg<-.5||!e){this.lunarDiffraction?.show(void 0),this.lunarDiffractionKey="";return}const i=this.weather.relativeHumidity,n=(i===void 0?Ft.DEFAULT_AEROSOL_OPTICAL_DEPTH:Qs.opticalDepth(i))*Ft.aerosolDensity(this.siteElevationM+this.observerElevationM),s=this.cloudTransmission(t),a=-Math.log(Math.max(this.cloudTransmission(t,!0),1e-4)),o=fe.aureoleScale(n,fe.airMass(t.altitudeDeg))*s,c=fe.coronaScale(a),l=fe.illuminanceOf(t.magnitude),h=[t.altitudeDeg.toFixed(1),t.azimuthDeg.toFixed(1),t.magnitude.toFixed(2),o.toExponential(2),c.toExponential(2),Math.log10(Math.max(e.adaptation,1e-12)).toFixed(2)].join(":");if(h===this.lunarDiffractionKey)return;this.lunarDiffractionKey=h,this.lunarDiffraction||(this.lunarDiffraction=new z0,this.celestialGroup.add(this.lunarDiffraction.object));const u=fe.profile(fe.HAZE_COARSE_MODE),d=fe.profile(fe.CLOUD_DROPLETS),f=Gp(t.altitudeDeg),p=new Float32Array(fe.STEPS*3);let v=0;for(let y=0;y<fe.STEPS;y++){const M=y*3,b=[0,1,2].map(T=>l*f[T]*(o*u[M+T]+c*d[M+T])),w=On.shown(b,On.luminanceOf(b),(T,x)=>e.relativeOfLuminance(T,x));p.set(w,M),v=Math.max(v,On.response(w))}const{x:m,y:g,z:S}=hi(t.altitudeDeg,t.azimuthDeg,1);this.lunarDiffraction.show(v>1/200?{x:m,y:g,z:S}:void 0,p)}applyAir(){this.scene.fog instanceof Pa||(this.scene.fog=new Pa),this.scene.fog.setAir(this.air,this.siteElevationM,this.airlight)}airlight=[0,0,0];transmittanceTo(t,e,i){const n=this.camera.position;return this.air.transmittance(this.siteElevationM+n.y,this.siteElevationM+e,Math.hypot(t-n.x,e-n.y,i-n.z))}setSiteElevation(t){Math.abs(t-this.siteElevationM)<1||(this.siteElevationM=t,this.applyAir(),this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}scatteredSkyState(t){return{altitudeM:this.siteElevationM+this.observerElevationM+1.6,lightPollution:this.lightPollution,sun:{altitudeDeg:t.sun.altitudeDeg,azimuthDeg:t.sun.azimuthDeg,magnitude:t.sun.magnitude},moon:{altitudeDeg:t.moon.altitudeDeg,azimuthDeg:t.moon.azimuthDeg,magnitude:t.moon.magnitude,phaseAngleDeg:Mt.phaseAngleOf(t.moon.phase.illuminatedFraction)}}}pumpScatteredSky(){const t=this.scatteredSky;!t||t.tables.ready||this.scatteredSkyFrameId!==null||this.contextReleased||(this.scatteredSkyFrameId=requestAnimationFrame(()=>{this.scatteredSkyFrameId=null,!this.contextReleased&&(t.advance(this.skyHoldUntilMs?W5:V5),this.pumpScatteredSky())}))}cancelScatteredSkyPump(){this.scatteredSkyFrameId!==null&&(cancelAnimationFrame(this.scatteredSkyFrameId),this.scatteredSkyFrameId=null)}setSatellites(t){if(t.length===0&&!this.satelliteField?.count)return;this.satelliteField||(this.satelliteField=new n5(su),this.celestialGroup.add(this.satelliteField.object));const e=this.lastAstronomy?this.magnitudeLimitOf(this.lastAstronomy):Ed(-90,this.instrumentMagnitudeGain);this.satelliteField.set(t,e,i=>this.cloudTransmission(i),(i,n)=>this.arrivingIlluminance(i,n,1)),this.render()}pickSatelliteAt(t,e){if(!this.satelliteField?.count)return;this.aimAtScreenPoint(this.raycaster,t,e);const i=Math.cos(bm*this.camera.fov*Math.PI/180),n=this.satelliteField.nearest(this.raycaster.ray.direction,i);return n&&this.groundHides(t,e)?void 0:n}updateCelestialLight(t,e){const i=this.relativeScale,n=t.sun.altitudeDeg>=$c,s=!n&&t.moon.altitudeDeg>=$c,a=n?t.sun:t.moon,o=[0,0,0],c=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*qi)),l=n||s?this.cloudTransmission(a):1,h=-Math.log(Math.max(l,1e-6)),u=Math.max(0,1/(1+.1125*h)-l),d=[0,0,0];if(n||s){const S=fe.illuminanceOf(a.magnitude)*i,y=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,a.altitudeDeg);for(let T=0;T<3;T++)o[T]=S*y[T]*l,d[T]=S*y[T]*u*c,this.cloudBeam[T]=S*y[T];const{x:M,y:b,z:w}=hi(a.altitudeDeg,a.azimuthDeg,1);this.cloudBeamDirection.set(M,b,w)}else this.cloudBeam.fill(0);const f=this.surroundings;if(f)this.skyLight.color.setRGB(f.up[0]*i,f.up[1]*i,f.up[2]*i),this.skyLight.groundColor.setRGB(f.down[0]*i,f.down[1]*i,f.down[2]*i);else{const S=this.skyCloudTransmission(),y=e.skyIrradiance,M=[0,1,2].map(w=>y[w]*S+d[w]);this.skyLight.color.setRGB(M[0],M[1],M[2]);const b=Wt.GROUND_ALBEDO;this.skyLight.groundColor.setRGB(b*(M[0]+o[0]*c),b*(M[1]+o[1]*c),b*(M[2]+o[2]*c))}if(this.skyLight.intensity=1,!n&&!s){this.celestialLight.intensity=0;return}const{x:p,y:v,z:m}=hi(a.altitudeDeg,a.azimuthDeg,1);this.lightDirection.set(p,v,m),this.placeShadowFrustum();const g=Math.max(o[0],o[1],o[2],1e-30);this.celestialLight.color.setRGB(o[0]/g,o[1]/g,o[2]/g),this.celestialLight.intensity=g,this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}lightDirection=new R(0,1,0);placeShadowFrustum(){const t=this.lightDirection,e=this.celestialLight.shadow.camera,i=(e.right-e.left)/this.celestialLight.shadow.mapSize.x,n=this.shadowAxisX.crossVectors(this.shadowUp,t);n.lengthSq()<1e-8&&n.set(1,0,0),n.normalize();const s=this.shadowAxisY.crossVectors(t,n).normalize(),a=this.shadowWorld.set(this.bodyOrigin.x,0,this.bodyOrigin.z),o=l=>{const h=a.dot(l)/i;return(h-Math.round(h))*i},c=this.celestialLightTarget.position.set(0,0,0).addScaledVector(n,o(n)).addScaledVector(s,o(s));this.celestialLightTarget.updateMatrixWorld(),this.celestialLight.position.copy(c).addScaledVector(t,this.shadowLightDistanceM)}fitShadowToBodies(){const t=this.bodySystem.reachFrom(this.camera.position),e=Math.min(O5,Math.max(Gs,Math.ceil(t*1.25/20)*20));if(e===this.shadowHalfExtentM)return;this.shadowHalfExtentM=e;const i=this.celestialLight.shadow,n=i.camera;n.left=-e,n.right=e,n.top=e,n.bottom=-e;const s=Math.max(lo,e*(lo/Gs));this.shadowLightDistanceM=Math.max(sn,s+10),n.near=this.shadowLightDistanceM-s,n.far=this.shadowLightDistanceM+s,n.updateProjectionMatrix(),i.bias=-.03/(2*s);const a=e>2*Gs?2048:1024;i.mapSize.x!==a&&(i.mapSize.set(a,a),i.map?.dispose(),i.map=null),this.placeShadowFrustum()}shadowHalfExtentM=Gs;shadowLightDistanceM=sn;shadowUp=new R(0,1,0);shadowAxisX=new R;shadowAxisY=new R;shadowWorld=new R;skyCloudTransmission(){let t=this.cloudTransmission({altitudeDeg:90,azimuthDeg:0}),e=1;for(const i of[20,45,70]){const n=i*qi,s=Math.sin(n)*Math.cos(n)*2;for(let a=0;a<360;a+=60)t+=s*this.cloudTransmission({altitudeDeg:i,azimuthDeg:a}),e+=s}return t/e}cloudBeam=[0,0,0];cloudBeamDirection=new R(0,1,0);get relativeScale(){return this.scatteredSky?.relativeScale??1/At.semiSaturation(At.DAYLIGHT_ANCHOR_CD_M2)}setMeteorShower(t,e,i){this.meteorSystem||(this.meteorSystem=new yi,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(t,e,i)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(t){return this.meteorSystem?.midpointOf(t)}updateMeteors(t){this.meteorSystem?.update(t)}setInstrument(t){this.projectionKind=t.projection,this.grain=t.detailUm!==void 0&&t.frame?{detailUm:t.detailUm,frameHeightMm:t.frame.heightMm}:void 0;const e=fi.starPointsOf(t),i=fi.flareArtifactsOf(t);e===this.starPoints&&i===this.lensFlareArtifactIntensity||(this.starPoints=e,this.lensFlareArtifactIntensity=i,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=e,this.lensFlare.uniforms.uFlareIntensity.value=i),this.render())}magnitudeLimitOf(t){const e=Mt.starLossMagnitudes(t.sun.altitudeDeg,{phaseAngleDeg:Mt.phaseAngleOf(t.moon.phase.illuminatedFraction),altitudeDeg:t.moon.altitudeDeg},this.lightPollution);return Ed(t.sun.altitudeDeg,this.instrumentMagnitudeGain,e)}setLightPollution(t){t!==this.lightPollution&&(this.lightPollution=t,this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}setInstrumentGain(t,e=!1){this.instrumentMagnitudeGain=Number.isFinite(t)?t:0,this.scatteredSky?.setInstrument(e,this.instrumentMagnitudeGain)}render(){this.restatingExposure||(this.sceneVersion++,this.frameDirty=!0,this.resolution.noteChange(performance.now()),!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()})))}drawIfDirty(){if(!(!this.frameDirty||this.contextReleased)){if(this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy),this.compileBeforeNextDraw){this.compileBeforeNextDraw=!1;const t=this.compileOffThread().then(()=>{this.compiling===t&&(this.compiling=void 0,this.render())});this.compiling=t;return}if(!this.compiling){if(this.skyHoldUntilMs){if(!this.sceneSettled()&&performance.now()<this.skyHoldUntilMs){this.firstFrameReady()&&this.refreshReflections(!0);return}this.skyHoldUntilMs=null,this.iceHalos?.setUrgent(!1),this.onFirstFrameHold?.(!1),this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy)}this.frameDirty=!1,this.refreshReflections(),this.resolution.beginDrawing();try{this.renderOnce(),this.drawn++}finally{this.resolution.endDrawing()}this.developingExposure&&this.startExposure()}}}drawn=0;get framesDrawn(){return this.drawn}compileBeforeNextDraw=!1;compiling;static COMPILE_WAIT_MS=1500;compileOffThread(){const t=this.renderer.compile(this.scene,this.camera);if(!this.renderer.extensions.get("KHR_parallel_shader_compile"))return Promise.resolve();const e=this.renderer.properties,i=performance.now()+ke.COMPILE_WAIT_MS;return new Promise(n=>{const s=()=>{if(this.contextReleased)return n();for(const a of t){const o=e.get(a)?.currentProgram;(!o||o.isReady())&&t.delete(a)}t.size===0||performance.now()>i?n():setTimeout(s,10)};s()})}compileNextFrameOffThread(){this.compileBeforeNextDraw=!0}contextReleased=!1;releaseContext(){this.contextReleased||(this.contextReleased=!0,this.stopTwinkle(),this.cancelFlush(),this.cancelExposure(),this.compiling=void 0,this.cancelScatteredSkyPump(),this.renderer.forceContextLoss())}restoreContext(){this.contextReleased&&(this.contextReleased=!1,this.renderer.forceContextRestore(),this.scatteredSky?.invalidate(),this.pumpScatteredSky(),this.compileNextFrameOffThread(),this.syncAnimationLoop(),this.render())}cancelFlush(){this.flushFrameId!==null&&(cancelAnimationFrame(this.flushFrameId),this.flushFrameId=null)}frame(t){if(this.animationsRunning){const e=this.lastFrameTimeMs===void 0?0:t-this.lastFrameTimeMs;this.lastFrameTimeMs=t,this.hasAnimations()&&this.animate(t,e);const i=this.resolution.ratioFor(t,e);i!==this.renderer.getPixelRatio()&&this.applyPixelRatio(i)}this.drawIfDirty()}refreshReflections(t=!1){this.reflections??=new on(this.renderer);const e=[...this.compassSprites,...this.lensFlare?[this.lensFlare.mesh]:[],...[...this.glareSprites.values()].map(o=>o.mesh)],i=[...this.starTiers.map(o=>o.points),...[...this.bodyMeshes.values()].filter(o=>o instanceof xs),...[this.rainSystem?.points,this.precipitationPoints,this.rainSplashSystem?.points].filter(o=>o!==void 0)],n=this.relativeScale,s=this.sceneVersion,a=this.reflections.refresh(this.renderer,this.scene,this.camera.position,this.bodySystem.reflectors,e,[...this.decorGroups.values()],s,i,o=>this.measureSurroundings(o,n,s),t?0:on.REFRESH_MS);a===void 0||this.reflectionTimer||(this.reflectionTimer=setTimeout(()=>{this.reflectionTimer=void 0,this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()}))},a))}measureSurroundings(t,e,i){const n=this.lastAstronomy;if(!n)return;this.probeIrradiance??=new To;const s=[n.sun,n.moon].filter(a=>a.altitudeDeg>-2).map(a=>hi(a.altitudeDeg,a.azimuthDeg,1));this.probeIrradiance.measure(this.renderer,t,s,a=>{const o=f=>f.map(p=>p/e),c=this.surroundings,l={up:o(a.up),down:o(a.down)},h=(f,p)=>f.some((v,m)=>Math.abs(v-p[m])>.03*Math.max(Math.abs(v),Math.abs(p[m]),1e-12)),u=!c||h(c.up,l.up)||h(c.down,l.down);u&&(this.surroundings=l),this.eyeSettledVersion=-1;const d=this.scatteredSky?.adaptToSurroundings(Math.exp(a.logAverage)/e)??!1;if(!u&&!d){this.eyeSettledVersion=i,this.skyHoldUntilMs&&this.redrawHeld();return}this.skyColoursStale=!0,this.render()})}lightUnderClouds(t){const e=this.surroundings;if(!e)return;const i=t.sun.altitudeDeg>=$c?t.sun:t.moon.altitudeDeg>=$c?t.moon:void 0;if(!i)return;const n=this.relativeScale/Math.PI;return{through:this.cloudTransmission(i),radiance:[e.up[0]*n,e.up[1]*n,e.up[2]*n]}}probeIrradiance;surroundings;animate(t,e){const i=Math.min(e/1e3,uE);this.twinkleSeconds=t/1e3,this.updateTwinkle(this.twinkleSeconds),this.updatePrecipitation(t/1e3,i),this.updateRain(i),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=t/1e3),this.developingExposure||(this.frameDirty=!0)}setMaxPixelRatio(t){this.resolution.maximum=t,this.renderer.getPixelRatio()>this.resolution.maximum&&this.applyPixelRatio(this.resolution.maximum)}applyPixelRatio(t){this.renderer.setPixelRatio(t),this.renderer.setSize(this.cssSize.width,this.cssSize.height,!1),this.frameDirty=!0}setExposure(t,e){const i=e?Math.max(1,Math.round(t)):1;if(i===this.exposureInstants&&(i===1||e===this.exposureInstantAt)){this.exposureInstantAt=e;return}this.exposureInstants=i,this.exposureInstantAt=e,i===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(t){if(this.onMapSubjectBounds){const a=this.mapSubjectBounds();t?this.exposureSubjectBounds.push(...a):this.onMapSubjectBounds(a)}const e=this.usableEquidistantPass();this.phenomena.setCloudLayers(this.layeredClouds?.volumes??[]),this.phenomena.place(this.camera,(a,o,c)=>this.directionAtScreenPoint(a,o,c),a=>this.screenPointOf(a)),this.references.place(this.camera);const i=Math.max(this.phenomena.furthestM,this.references.furthestM)*1.2;i>this.camera.far&&(this.camera.far=i,this.camera.updateProjectionMatrix()),Hi.uRodShare.value=this.scatteredSky?.rodShare??0,Hi.uRelativeScale.value=this.relativeScale,this.applyMedium();const n=this.references.any||this.phenomena.any||this.compassSprites.some(a=>a.visible);Hi.uHasOverlay.value=n?1:0;const s=n?a=>this.renderOverlayPasses(a):void 0;if(this.skyGlow?.setDestinationEncoded(!1),!e){this.updateLensFlarePosition();const a=this.usableDepthOfFieldPass();a?a.render(this.renderer,this.scene,this.camera,s,t):this.usableFinishPass().render(this.renderer,this.scene,this.camera,s,void 0,t);return}e.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),s,a=>{this.lensFlare&&(this.lensFlare.mesh.visible=a?!1:this.sunVisible)},()=>this.renderDazzleOnResample(),t)}renderOverlayPasses(t=this.camera){this.renderReferencesPass(t),this.renderPhenomenaPass(t),this.renderHudPass(t)}renderHudPass(t){if(!this.compassSprites.some(n=>n.visible))return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,t.layers.set(ym),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}renderReferencesPass(t){if(!this.references.any)return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,t.layers.set(H1),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}setReferences(t,e){this.references.set(t.map(i=>{const n=this.documentRelative(i.src);return n===i.src?i:{...i,src:n}}),void 0,e)}referenceAspect(t){return this.references.aspectOf(t)}directionAt(t,e){return this.directionAtScreenPoint(t,e,new R)}referenceFailedToLoad(t){return this.references.failedToLoad(this.documentRelative(t))}setReferencesShown(t){this.references.setShown(t),this.render()}setReferenceView(t,e){this.references.setView(t,e),this.render()}renderPhenomenaPass(t){if(!this.phenomena.any)return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const s=this.decorGroups.get(n.id);s&&ke.markDecorDepth(s,n.kind!=="crop")}t.layers.set(iu),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,t),this.scene.overrideMaterial=null,t.layers.set(B1),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}decorDepthMaterial=new _n({colorWrite:!1});static markDecorDepth(t,e){t.traverse(i=>{if(!(i instanceof Dt))return;const n=Array.isArray(i.material)?i.material[0]:i.material;e&&n.depthWrite!==!1&&n.blending!==Ni?i.layers.enable(iu):i.layers.disable(iu)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const t=this.renderer.getDrawingBufferSize(new xt),e=Math.max(1,Math.round(t.x)),i=Math.max(1,Math.round(t.y));this.exposureAccumulation||(this.exposureAccumulation=new Sb(e,i)),this.exposureAccumulation.resize(e,i),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const t=this.exposureInstantAt,e=this.exposureAccumulation;if(!t||!e)return;const i=1/this.exposureInstants;this.resolution.beginDrawing();const n=performance.now()+ke.EXPOSURE_BUDGET_MS,s=ke.exposureInstantsPerFrame(e.instantTarget.scene.width*e.instantTarget.scene.height);let a=0;do{this.restateAt(t,this.exposureInstantsDone);const o=this.compassSprites.map(c=>c.visible);for(const c of this.compassSprites)c.visible=!1;try{this.renderOnce(e.instantTarget)}finally{this.compassSprites.forEach((c,l)=>{c.visible=o[l]})}e.add(this.renderer,i),this.exposureInstantsDone++,a++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<n&&a<s);this.restateAt(t,0),this.presentExposure(),this.resolution.endDrawing(),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}presentExposure(){if(Hi.uRodShare.value=this.scatteredSky?.rodShare??0,Hi.uHasOverlay.value=1,Hi.uRelativeScale.value=this.relativeScale,this.applyMedium(),this.exposureAccumulation?.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.onMapSubjectBounds?.(this.exposureSubjectBounds),!this.compassSprites.some(s=>s.visible))return;const t=new Ts,e=new Un(-1,1,1,-1,0,2),i=Kc/(Tm*Math.tan(Rm*qi/2));for(const s of this.compassSprites){if(!s.visible)continue;const a=s.getWorldPosition(new R).sub(this.camera.position).normalize(),o=this.screenPointOf(a);if(!o)continue;const c=new Jr(s.material);c.position.set(o.ndcX,o.ndcY,-1),c.scale.set(i/this.camera.aspect,i,1),t.add(c)}const n=this.renderer.autoClear;this.renderer.autoClear=!1;try{this.renderer.render(t,e)}finally{this.renderer.autoClear=n}}onMapSubjectBounds;exposureSubjectBounds=[];static MAP_SUBJECT_NEAREST_M=8;mapSubjectBounds(){const t=[],e=new Vi,i=new R,n=this.camera.getWorldDirection(new R),s=this.decorObjects.filter(o=>o.track?.length||o.kind==="aircraft"||o.kind==="vehicle").map(o=>this.decorGroups.get(o.id)),a=this.bodySystem.reflectors.map(o=>o.holder);for(const o of[...s,...a]){if(!o?.visible||(e.setFromObject(o),e.isEmpty())||e.distanceToPoint(this.camera.position)<ke.MAP_SUBJECT_NEAREST_M)continue;let c=1/0,l=-1/0,h=1/0,u=-1/0;for(const d of[e.min.x,e.max.x])for(const f of[e.min.y,e.max.y])for(const p of[e.min.z,e.max.z]){if(i.set(d,f,p).sub(this.camera.position).normalize(),i.dot(n)<=0)continue;const v=this.screenPointOf(i);if(!v)continue;const m=(v.ndcX+1)/2,g=(1-v.ndcY)/2;c=Math.min(c,m),l=Math.max(l,m),h=Math.min(h,g),u=Math.max(u,g)}c=Math.max(c,0),l=Math.min(l,1),h=Math.max(h,0),u=Math.min(u,1),l>=c&&u>=h&&t.push({x:c,y:h,width:l-c,height:u-h})}return t}restateAt(t,e){this.restatingExposure=!0;try{t(e)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(t){const e=this.lensOptics;this.lensOptics=t,(e===void 0!=(t===void 0)||e&&t&&(e.focalLengthMm!==t.focalLengthMm||e.fNumber!==t.fNumber||e.focusDistance!==t.focusDistance||e.frameHeightMm!==t.frameHeightMm))&&(t&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.render())}usableDepthOfFieldPass(){const t=this.lensOptics;if(!t)return;const e=this.renderer.getDrawingBufferSize(new xt),i=Math.max(1,Math.round(e.x)),n=Math.max(1,Math.round(e.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new Ro(i,n)),this.depthOfFieldPass.resize(i,n),this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.depthOfFieldPass}usableFinishPass(){const t=this.renderer.getDrawingBufferSize(new xt);return this.finishPass?this.finishPass.resize(t.x,t.y):this.finishPass=new k0(t.x,t.y),this.finishPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const t=this.renderer.getDrawingBufferSize(new xt);return this.equidistantPass?this.equidistantPass.resize(t.x,t.y):this.equidistantPass=new We(t.x,t.y),this.equidistantPass}aimAtScreenPoint(t,e,i){const n=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!n){t.setFromCamera(new xt(e,i),this.camera);return}const s=n.directionFor(e,i,this.camera.fov);this.camera.updateMatrixWorld(),t.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),t.ray.direction.set(s.x,s.y,s.z).applyQuaternion(this.camera.quaternion).normalize(),t.camera=this.camera}pickCloudAt(t,e){return this.layeredClouds?.pickInstance(this.cloudDirectionAt(t,e))}cloudDirectionAt(t,e){return this.directionAtScreenPoint(t,e,new R)}directionAtScreenPoint(t,e,i){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),i.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(t){this.camera.updateMatrixWorld();const e=this.screenPointScratch.copy(t).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert()),i=this.renderer.getDrawingBufferSize(this.screenPointSize),n=i.x/Math.max(i.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return We.ndcFor(e,this.camera.fov,n);if(e.z>=0)return;const s=Math.tan(this.camera.fov/2*qi);return{ndcX:e.x/-e.z/(n*s),ndcY:e.y/-e.z/s}}screenPointScratch=new R;screenPointQuaternion=new Qi;screenPointSize=new xt;updateLensFlarePosition(){const t=this.lensFlare;if(!t)return;if(!this.sunVisible){t.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){t.mesh.visible=!1;return}const e=this.sunVisibleFraction();if(e<=0){t.mesh.visible=!1;return}t.mesh.visible=!0,this.sunUnhiddenFraction=e,this.applyDazzleStrength();const i=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);t.uniforms.uLensPosition.value.set(i.x,i.y);const n=this.renderer.domElement.width,s=this.renderer.domElement.height;t.uniforms.uResolution.value.set(n,s),t.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}renderDazzleOnResample(){const t=this.lensFlare;if(!t||!this.sunVisible)return;const e=this.sunVisibleFraction();if(e<=0)return;this.sunUnhiddenFraction=e,this.applyDazzleStrength();const i=this.screenPointOf(this.lensFlareScratch.copy(this.sunWorldPosition).sub(this.camera.position).normalize());if(!i)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize);t.uniforms.uLensPosition.value.set(i.ndcX,i.ndcY),t.uniforms.uResolution.value.set(n.x,n.y),t.uniforms.uEquidistant.value=1,t.uniforms.uHalfFovRad.value=this.camera.fov*Math.PI/360;const s=this.renderer.autoClear;this.renderer.autoClear=!1,t.mesh.visible=!0,t.mesh.layers.enable(xm),this.camera.layers.set(xm),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),t.mesh.visible=!1,t.uniforms.uEquidistant.value=0,this.renderer.autoClear=s}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let t=0;for(const e of Im)this.isSunOccluded(e[0],e[1])||t++;return t/Im.length}raycastableDecor(){const t=[];for(const e of this.decorObjects){if(e.kind==="crop")continue;const i=this.decorGroups.get(e.id);i&&t.push(i)}return t}isSunOccluded(t=0,e=0){const i=this.raycastableDecor();if(!this.groundMesh&&!this.terrainMesh&&i.length===0)return!1;const n=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),s=n.length();if(n.normalize(),t!==0||e!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(n.z,0,-n.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,n).normalize();n.addScaledVector(c,t*o).addScaledVector(l,e*o).normalize()}if(this.groundBlocks(this.camera.position,n,s))return!0;if(i.length===0)return!1;this.sunOcclusionRaycaster.set(this.camera.position,n);const a=this.sunOcclusionRaycaster.intersectObjects(i,!0)[0];return a!==void 0&&a.distance<s}groundBlocks(t,e,i,n=0){const s=this.groundMesh;if(s&&e.y<0){const m=(s.position.y-t.y)/e.y;if(m>n&&m<i){const g=t.x+e.x*m-s.position.x,S=t.z+e.z*m-s.position.z;if(Math.hypot(g,S)<=this.groundRadius)return!0}}const a=this.terrainMesh;if(!a)return!1;const o=a.geometry.getAttribute("position"),c=Math.round(Math.sqrt(o.count));if(c<2||c*c!==o.count)return!1;const l=[a.position.x+o.getX(0),a.position.x+o.getX(c-1)],h=[a.position.z+o.getZ(0),a.position.z+o.getZ((c-1)*c)],u=Math.min(Math.abs(l[1]-l[0]),Math.abs(h[1]-h[0]))/(c-1);if(!(u>0))return!1;let d=n,f=i;for(const[m,g,S]of[[t.x,e.x,l],[t.z,e.z,h]]){const y=Math.min(S[0],S[1]),M=Math.max(S[0],S[1]);if(Math.abs(g)<1e-12){if(m<y||m>M)return!1;continue}const b=(y-m)/g,w=(M-m)/g;d=Math.max(d,Math.min(b,w)),f=Math.min(f,Math.max(b,w))}if(!(f>d))return!1;const p=Math.hypot(e.x,e.z),v=Math.min(4096,Math.max(8,Math.ceil((f-d)*p/(u/2))));for(let m=0;m<=v;m++){const g=d+(f-d)*m/v,S=t.x+e.x*g,y=t.y+e.y*g,M=t.z+e.z*g;if(y<=this.groundYUnder(S,M))return!0}return!1}setPhenomena(t,e){this.phenomena.set(t,e)}decorDistancesAt(t,e,i){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=_m;let n,s;for(const a of this.decorObjects){if(a.kind==="crop")continue;const o=this.decorGroups.get(a.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(a.occludesSourceIds?.includes(i)?n=n===void 0?c.distance:Math.max(n,c.distance):s=s===void 0?c.distance:Math.min(s,c.distance))}return{behindM:n,inFrontM:s}}pickBodyAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const i=[...this.hitAreas.entries()],n=this.raycaster.intersectObjects(i.map(([,s])=>s))[0];if(n&&!this.groundHides(t,e))return i.find(([,s])=>s===n.object)?.[0]}pickStarAt(t,e){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,t,e);const i=this.raycaster.ray.direction,n=Math.cos(bm*this.camera.fov*Math.PI/180);let s,a=n;for(const o of this.namedStars){const c=o.direction.dot(i);c>a&&(a=c,s={star:o.star,altitudeDeg:o.altitudeDeg})}return s&&this.groundHides(t,e)?void 0:s}groundHides(t,e){if(!this.terrainMesh&&!this.groundMesh)return!1;this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e);const i=this.ufoOcclusionRaycaster.ray;return this.groundBlocks(i.origin,i.direction,1/0,_m)}bodyScreenBox(t){const e=this.bodySystem.boxOf(t,this.bodyBoxScratch);if(!e)return;let i=1/0,n=1/0,s=-1/0,a=-1/0;for(let o=0;o<8;o++){const c=this.bodyCornerScratch.set(o&1?e.max.x:e.min.x,o&2?e.max.y:e.min.y,o&4?e.max.z:e.min.z),l=this.screenPointOf(c.sub(this.camera.position).normalize());if(!l)return;i=Math.min(i,l.ndcX),s=Math.max(s,l.ndcX),n=Math.min(n,l.ndcY),a=Math.max(a,l.ndcY)}return{minX:i,minY:n,maxX:s,maxY:a}}bodyBoxScratch=new Vi;bodyCornerScratch=new R;pickPlacedBodyAt(t,e){return this.aimAtScreenPoint(this.raycaster,t,e),this.bodySystem.pick(this.raycaster)}pickDecorAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const i=[...this.decorGroups.entries()],n=this.raycaster.intersectObjects(i.map(([,a])=>a),!0)[0];if(!n)return;let s=n.object;for(;s&&!i.some(([,a])=>a===s);)s=s.parent;return i.find(([,a])=>a===s)?.[0]}dispose(){this.stopTerrainFade(),this.stopTwinkle(),this.cancelFlush(),this.phenomena.clear(),this.references.disposeAll(),this.terrainBuildToken++,this.cancelScatteredSkyPump(),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.skyGradientMaterial),this.scatteredSky?.dispose(),this.scatteredSky=void 0,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.roadSystem.dispose(),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.finishPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0,this.satelliteField?.dispose(),this.satelliteField=void 0,this.lightningBolt?.dispose(),this.lightningBolt=void 0;for(const t of this.bodyMeshes.values())this.disposeMesh(t);this.bodyMeshes.clear(),this.novaKeys.clear();for(const t of[...this.hitAreas.keys()])this.disposeHitArea(t);for(const t of[...this.glareSprites.keys()])this.disposeGlare(t);this.disposeCompassLabels();for(const t of this.decorGroups.values())ui.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear(),this.lensFlare&&(this.lensFlare.mesh.removeFromParent(),this.lensFlare.mesh.geometry.dispose(),this.lensFlare.mesh.material.dispose(),this.lensFlare=void 0),this.renderer.dispose()}animationsRunning=!1;startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;this.cancelFlush();const t=e=>{this.frame(e),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}setAnimationsRunning(t,e=!1){const i=t&&e;if(t===this.animationsRunning&&i===this.framesDriven)return;const n=this.animationsRunning;this.animationsRunning=t,this.framesDriven=i,t&&!n&&(this.lastFrameTimeMs=void 0,this.resolution.reset());const s=!t&&this.renderer.getPixelRatio()!==this.resolution.maximum;s&&this.applyPixelRatio(this.resolution.maximum),this.syncAnimationLoop(),(!t||this.frameDirty)&&this.render(),s&&this.drawIfDirty()}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}needsAnimationLoop(){return this.animationsRunning&&!this.framesDriven&&this.hasAnimations()}hasAnimations(){return this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lensFlare!==void 0&&this.sunVisible}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(t){const e=this.skyMesh?.geometry??new oi(Yc,32,16),i=e.attributes.position,n=e.getAttribute("color")??new de(new Float32Array(i.count*3),3);for(let a=0;a<i.count;a++){const{altitudeDeg:o,azimuthDeg:c}=Eb(i.getX(a),i.getY(a),i.getZ(a)),l=Lb(o,c,t.azimuthDeg,t.altitudeDeg);n.setXYZ(a,l[0],l[1],l[2])}if(n.needsUpdate=!0,this.skyMesh)return;e.setAttribute("color",n);const s=new _n({vertexColors:!0,side:Ve,fog:!1,depthWrite:!1});this.skyGradientMaterial=s,this.skyMesh=new Dt(e,s),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const t=Sm(this.observerElevationM);if(this.groundMesh&&t===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=t;const e=new v0(this.groundRadius,48),i=new kr({color:new st(nu,nu,nu),fog:!0});Pa.fadeRim(i,this.groundRadius*.75,this.groundRadius),this.groundMesh=new Dt(e,i),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const t=this.groundMesh?.material;if(!t)return;const e=this.terrainMesh===void 0;t.depthWrite!==e&&(t.depthWrite=e,t.needsUpdate=!0)}cloudTransmission(t,e=!1){const i=`${t.altitudeDeg.toFixed(1)}:${t.azimuthDeg.toFixed(1)}:${Math.round(this.cloudOffsetM.x/10)}:${Math.round(this.cloudOffsetM.z/10)}:${Math.round(this.observerElevationM)}:`+Object.entries(this.cloudLayerOffsetsM).map(([a,o])=>`${a}=${Math.round(o.x/10)},${Math.round(o.z/10)}`).join(";")+(e?":water":""),n=this.cloudTransmissionMemo.get(i);if(n!==void 0)return n;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const s=this.computeCloudTransmission(t,e);return this.cloudTransmissionMemo.set(i,s),s}cloudTransmissionMemo=new Map;computeCloudTransmission(t,e=!1){const i=hi(t.altitudeDeg,t.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(i,e);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-ge.alphaAt(i,Math.abs(this.cloudLayerOffset()),s,this.cloudFieldOffset)*z5);const a=e?0:this.weather.highCloudCover??0;return a>0&&(n*=1-ge.iceAlphaAt(i,qc,a,this.cloudFieldOffset)*B5),Math.max(0,Math.min(1,n))}setBodyMesh(t,e,i,n,s){if(e.altitudeDeg<$d){this.disposeMesh(this.bodyMeshes.get(t)),this.bodyMeshes.delete(t),this.disposeHitArea(t),this.disposeGlare(t),t==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=hi(e.altitudeDeg,e.azimuthDeg,sn),l=Gp(e.altitudeDeg),h=this.cloudTransmission(e),u=this.arrivingIlluminance(e,s,h),d=ke.unitLuminance(n);let f=this.bodyMeshes.get(t);if(t==="sun"){const p=Math.PI*(i/sn)**2,v=[0,1,2].map(m=>Math.min(ke.BRIGHTEST_RELATIVE,d[m]*u[m]/p));f instanceof Dt||(this.disposeMesh(f),f=new Dt(new oi(1,16,16),new _n({fog:!1})),this.celestialGroup.add(f),this.bodyMeshes.set(t,f)),f.material.color.setRGB(v[0],v[1],v[2]),f.scale.setScalar(i)}else{if(!(f instanceof xs)){this.disposeMesh(f);const m=new ce;m.setAttribute("position",new ie(new Float32Array(3),3)),m.setAttribute("color",new ie(new Float32Array(3),3)),f=new xs(m,ae.material(Ao[Ao.length-1].size,!1)),ae.track(f),this.celestialGroup.add(f),this.bodyMeshes.set(t,f)}const p=f.geometry.getAttribute("color"),v=t.startsWith("comet:")?this.pointToPixel():1;p.setXYZ(0,d[0]*u[0]*v,d[1]*u[1]*v,d[2]*u[2]*v),p.needsUpdate=!0}if(f.position.set(a,o,c),this.setHitArea(t,a,o,c,i),t==="sun"&&(this.sunArriving=u),t.startsWith("comet:")?this.disposeGlare(t):t!=="sun"&&this.setGlare(t,a,o,c,u,i/sn*(180/Math.PI),ke.POINT_VEIL_HOLD_DEG),t==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*p,o*p+this.celestialGroup.position.y,c*p),this.lensFlare||(this.lensFlare=i5(),this.lensFlare.uniforms.uOpacity.value=K5,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(t,e){const i="moon";if(t.magnitude>e||t.altitudeDeg<$d){this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i);return}const{x:n,y:s,z:a}=hi(t.altitudeDeg,t.azimuthDeg,sn),o=this.cloudTransmission(t),c=this.arrivingIlluminance(t,t.magnitude,o),l=Math.max(Mr(t.phase.illuminatedFraction,0,1),.01)*Math.PI*(ho/sn)**2,h=new st(...c.map(f=>Math.min(ke.BRIGHTEST_RELATIVE,f/l))),u=`${t.phase.phaseFraction<.5}:${Math.round(Mr(t.phase.illuminatedFraction,0,1)*500)}`;let d=this.bodyMeshes.get(i);if(d instanceof Jr)d.userData.phaseKey!==u&&(d.material.map?.dispose(),d.material.map=qm(t.phase),d.userData.phaseKey=u),d.material.color.copy(h);else{this.disposeMesh(d),d=new Jr(new rl({map:qm(t.phase),color:h,fog:!1})),d.userData.phaseKey=u;const f=ho*2;d.scale.set(f,f,1),this.celestialGroup.add(d),this.bodyMeshes.set(i,d)}d.position.set(n,s,a),this.setHitArea(i,n,s,a,ho),this.setGlare(i,n,s,a,c,ho/sn*(180/Math.PI))}bentLight(t,e,i=U5){const[n,s,a]=this.arrivingIlluminance(t,e,1),o=Math.max(s,1e-30);return{scale:s/i,tint:[n/o,1,a/o]}}static litBySky(t,e){return ke.litScratch.setRGB(t.r*e[0],t.g*e[1],t.b*e[2])}static litScratch=new st;pointToPixel(){const t=Math.max(1,this.renderer.getDrawingBufferSize(this.pointScratch).y),e=(this.camera.fov*Math.PI/180/t)**2;return Math.min(1,ae.CONE_SOLID_ANGLE/e)}pointScratch=new xt;static POINT_VEIL_HOLD_DEG=.25;static BRIGHTEST_RELATIVE=6e4;arrivingIlluminance(t,e,i){const n=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,t.altitudeDeg),s=fe.illuminanceOf(e)*i*this.relativeScale;return[n[0]*s,n[1]*s,n[2]*s]}static unitLuminance(t){const e=On.luminanceOf([t.r,t.g,t.b]);return e>0?[t.r/e,t.g/e,t.b/e]:[1,1,1]}setHitArea(t,e,i,n,s){let a=this.hitAreas.get(t);if(!a){const c=new rl({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});a=new Jr(c),this.celestialGroup.add(a),this.hitAreas.set(t,a)}a.position.set(e,i,n);const o=s*F5;a.scale.set(o,o,1)}disposeHitArea(t){const e=this.hitAreas.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.hitAreas.delete(t))}setGlare(t,e,i,n,s,a,o=0){if(Pi.radiusDeg(Pi.K*Math.max(...s))<=Math.max(a,o)){this.disposeGlare(t);return}let c=this.glareSprites.get(t);c||(c=new Pi(`veil:${t}`),this.celestialGroup.add(c.mesh),this.glareSprites.set(t,c)),c.shine({x:e,y:i,z:n},s,a,o)}disposeGlare(t){const e=this.glareSprites.get(t);e&&(e.mesh.removeFromParent(),e.dispose(),this.glareSprites.delete(t))}buildComet(t,e){const i=t&&`comet:${t.id}`;if(!t||!i||t.magnitude>e){this.disposeComet();return}this.cometKey&&this.cometKey!==i&&this.disposeComet();const n=vo(t.magnitude,e),s=Wh(n);this.cometKey=i,this.setBodyMesh(i,t.position,au*(.5+.5*n),new st(s,s,s),t.magnitude),this.cometTail||(this.cometTail=new rn(sn),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(t.position,t.tailEnd,n)}buildIceHalos(t,e){this.iceHalos||(this.iceHalos=new Ci,this.iceHalos.setCloudOffset(this.cloudFieldOffset),this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object)),this.iceHalos.setUrgent(!!this.skyHoldUntilMs);const i=this.highCloudCover(),n=this.layeredClouds?.cirrusMask;if(this.iceHalos.setCloudOffset(n?.offset??this.cloudFieldOffset),this.layeredClouds?.hostHalo(this.iceHalos),i===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:qc},0);return}const s=this.lowerCloudCover(),a=me.deckLitUntilDeg(me.DECK_HEIGHT_M),o=t.altitudeDeg>-a?t:e,c=this.bentLight(o,o===t?Ne.SUN_MAGNITUDE:e.magnitude),l=me.strength(i,s,o.altitudeDeg,a)*c.scale,{x:h,y:u,z:d}=hi(o.altitudeDeg,o.azimuthDeg,1);this.iceHalos.update({x:h,y:u,z:d},o.altitudeDeg,l,c.tint,{cover:n?.cover??i,layerHeight:n?.layerHeight??qc},n?.iceCrystalAlignment??this.weather.iceCrystalAlignment??ev)}buildRainbow(t,e){this.rainbow||(this.rainbow=new Aa,this.celestialGroup.add(this.rainbow.object));const i=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity*(this.weather.precipitationAmount??1):0,n=t.altitudeDeg>0,s=n?t:e,a=this.lowerCloudCover(),o=this.bentLight(s,n?Ne.SUN_MAGNITUDE:e.magnitude,k5),c=an.strength(i,a,s.altitudeDeg)*o.scale;if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=hi(s.altitudeDeg,s.azimuthDeg,1);this.rainbow.update({x:l,y:h,z:u},c,o.tint,n)}buildSkyGlow(t,e){if(!t.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Xs,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:i,observer:n}=t.frame,s=Dn.galactic(i,n),a=ke.directionOf(s.centre),o=ke.directionOf(s.rotation),c=ke.directionOf(s.pole),l=new Yt().set(a.x,a.y,a.z,o.x,o.y,o.z,c.x,c.y,c.z),h=ke.directionOf(Dn.eclipticPole(i,n)),u=ke.directionOf(t.sun),d=u.clone().addScaledVector(h,-u.dot(h)).normalize();this.skyGlow.update({galactic:l,eclipticPole:h,sunLongitude:d,sunDirection:u,sunAltitudeDeg:t.sun.altitudeDeg,moon:{direction:ke.directionOf(t.moon),altitudeDeg:t.moon.altitudeDeg,phaseAngleDeg:Mt.phaseAngleOf(t.moon.phase.illuminatedFraction)},lightPollution:this.lightPollution,skyColor:new R(e[0],e[1],e[2])})}static directionOf(t){const{x:e,y:i,z:n}=hi(t.altitudeDeg,t.azimuthDeg,1);return new R(e,i,n).normalize()}buildNovae(t,e){const i=new Set;for(const n of t){if(n.magnitude>e)continue;const s=`nova:${n.id}`;i.add(s);const a=vo(n.magnitude,e),o=Wh(a);this.setBodyMesh(s,n.position,au*(.5+.5*a),new st(o,o,o),n.magnitude)}for(const n of this.novaKeys)i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n));this.novaKeys=i}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(t,e){const i=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[],...this.novaKeys]);for(const n of t){if(n.magnitude>e)continue;i.add(n.body);const s=vo(n.magnitude,e),a=Wh(s),o=mE[n.body]??new st(1,1,1),c=new st(o.r*a,o.g*a,o.b*a),l=au*(.5+.5*s);this.setBodyMesh(n.body,n.position,l,c,n.magnitude)}for(const n of[...this.bodyMeshes.keys()])i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n))}buildStars(t,e){if(this.namedStars=[],!t||t.catalog.count===0){this.disposeStarTiers(),this.syncAnimationLoop();return}const{catalog:i,date:n,observer:s}=t,a=new Pn(n,s),o=mu(1337),c=[],l=this.siteElevationM+this.observerElevationM;for(let h=0;h<i.count;h++){const u=i.mag[h];if(u>e)break;const{altitudeDeg:d,azimuthDeg:f}=a.position(i.ra[h],i.dec[h]);if(d<wm)continue;const{x:p,y:v,z:m}=hi(d,f,su);c.push({x:p,y:v,z:m,brightness:vo(u,e),illuminance:this.air.transmittanceFromSpace(l,d).map(g=>g*fe.illuminanceOf(u)),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const h of Nw){if(h.mag>e)continue;const{altitudeDeg:u,azimuthDeg:d}=a.position(h.raHours,h.decDeg);if(u<wm)continue;const{x:f,y:p,z:v}=hi(u,d,su);this.namedStars.push({star:h,direction:new R(f,p,v).normalize(),altitudeDeg:u})}this.starTiers=Ao.map((h,u)=>{const d=c.filter(b=>h1(b.brightness)===u),f=new Float32Array(d.length*3),p=new Float32Array(d.length),v=new Float32Array(d.length*3),m=new Float32Array(d.length),g=new Float32Array(d.length);d.forEach((b,w)=>{f[w*3]=b.x,f[w*3+1]=b.y,f[w*3+2]=b.z,p[w]=b.brightness,v.set(b.illuminance,w*3),m[w]=b.phase,g[w]=b.speedFactor});const S=new ce;S.setAttribute("position",new ie(f,3)),S.setAttribute("seed",new ie(m.map(b=>b/(2*Math.PI)),1));const y=new ie(new Float32Array(d.length*3),3);S.setAttribute("color",y);let M=this.starTiers[u]?.points;return M?(M.geometry.dispose(),M.geometry=S):(M=new xs(S,ae.material(h.size)),ae.track(M),this.celestialGroup.add(M)),{points:M,colorAttribute:y,brightness:p,illuminance:v,phase:m,speedFactor:g}}),this.starColoursRelative=Number.NaN,this.updateTwinkle(this.twinkleSeconds),this.startTwinkle()}twinkleSeconds=0;starColoursRelative=Number.NaN;updateTwinkle(t){ae.setTime(t);const e=this.relativeScale;if(e!==this.starColoursRelative){this.starColoursRelative=e;for(const i of this.starTiers){const n=i.colorAttribute.array;for(let s=0;s<i.brightness.length;s++)n[s*3]=i.illuminance[s*3]*e,n[s*3+1]=i.illuminance[s*3+1]*e,n[s*3+2]=i.illuminance[s*3+2]*e;i.colorAttribute.needsUpdate=!0}}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new Er(this.celestialGroup,ru,this.cloudRendering)),this.disposeCirrus(),this.layeredClouds.hostHalo(this.iceHalos),this.layeredClouds.update(this.weather,this.observerElevationM+1.6),this.layeredClouds.setOffsets(this.cloudOffsetM,this.cloudLayerOffsetsM),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const t=this.lowerCloudCover();if(t<=0){this.disposeCloudSystem();return}const e=this.weather.cloudDarkness,i=new st(fa[0]+(lu[0]-fa[0])*e,fa[1]+(lu[1]-fa[1])*e,fa[2]+(lu[2]-fa[2])*e);if(this.cloudMesh&&this.cloudUniforms){this.cloudUniforms.coverage.value=t,this.cloudUniforms.baseColor.value.copy(i),this.syncCloudLayer(),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}this.disposeCloudSystem();const{material:n,uniforms:s}=xd(i,t,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=n,this.cloudUniforms=s,s.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=yd(ru);this.cloudMesh=new Dt(a,n),this.faceCloudDeck(this.cloudMesh,this.cloudLayerOffset()),this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(t=>t.type!=="cirrus").reduce((t,e)=>t*(1-e.coverage),1):this.weather.lowerCloudCover??this.weather.cloudCover}highCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(t=>t.type==="cirrus").reduce((t,e)=>t*(1-e.coverage),1):this.weather.highCloudCover}buildCirrus(){const t=this.weather.highCloudCover??0;if(this.layeredClouds||t<=0){this.disposeCirrus();return}if(this.cirrusMesh&&this.cirrusUniforms){this.cirrusUniforms.coverage.value=t,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const{material:e,uniforms:i}=xd(new st(...fa),t,qc,1);this.cirrusMaterial=e,this.cirrusUniforms=i,i.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new Dt(yd(ru*1.04),e),this.cirrusMesh.renderOrder=Cm-1,this.celestialGroup.add(this.cirrusMesh)}disposeCirrus(){this.cirrusMesh&&(this.cirrusMesh.removeFromParent(),this.cirrusMesh.geometry.dispose()),this.cirrusMaterial?.dispose(),this.cirrusMesh=void 0,this.cirrusMaterial=void 0,this.cirrusUniforms=void 0}syncCloudLayer(){this.layeredClouds?.update(this.weather,this.observerElevationM+1.6);const t=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(t)),this.cloudMesh&&this.faceCloudDeck(this.cloudMesh,t)}faceCloudDeck(t,e){const i=e<0;t.scale.y=i?-1:1,t.renderOrder=i?Er.deckOrder(!0,0,1):Cm}cloudLayerOffset(){const e=((this.weather.cloudBaseM??Zd)-this.observerElevationM)*ou;return Math.sign(e||1)*Math.max(Math.abs(e),J5)}updateCloudLighting(t,e){const i=[this.cloudUniforms,this.cirrusUniforms].filter(u=>u!==void 0);if(i.length===0&&!this.layeredClouds)return;const n=this.cloudBeamDirection,[s,a,o]=this.cloudBeam.map(u=>u/Math.PI),c=this.lightningLevel*pu*this.relativeScale/Math.PI,l=new st(e[0]+Xn.r*c,e[1]+Xn.g*c,e[2]+Xn.b*c);this.layeredClouds?.setLighting(n.clone(),new st(s,a,o),l,l);const h=Math.max(0,n.y);for(const u of i)u.sunDir.value.copy(n),u.sunColor.value.setRGB(s*h,a*h,o*h),u.ambientColor.value.copy(l)}disposeCloudSystem(){this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.cloudMesh&&(this.cloudMesh.removeFromParent(),this.cloudMesh.geometry.dispose()),this.cloudMaterial?.dispose(),this.cloudMesh=void 0,this.cloudMaterial=void 0,this.cloudUniforms=void 0}disposePrecipitationPoints(){this.precipitationPoints&&(this.precipitationPoints.removeFromParent(),this.precipitationPoints.geometry.dispose(),this.precipitationPoints.material.dispose()),this.precipitationPoints=void 0,this.precipitationPositions=void 0,this.precipitationPhase=void 0,this.precipitationSpeedJitter=void 0,this.precipitationWobbleFreqJitter=void 0,this.precipitationWobbleAmpJitter=void 0,this.precipitationBounceRemaining=void 0,this.precipitationBounceHeight=void 0,this.precipitationBounceDuration=void 0,this.precipitationBounceVelX=void 0,this.precipitationBounceVelZ=void 0,this.precipitationUniforms=void 0}precipitationCount(t){return aE(t,this.weather.precipitationIntensity,this.weather.precipitationAmount??1)}updatePrecipitationDensity(){const t=[[this.rainSystem?.points,du],[this.rainSplashSystem?.points,pa],[this.precipitationPoints,this.weather.precipitationType==="none"||this.weather.precipitationType==="rain"?void 0:hu[this.weather.precipitationType].poolSize]];for(const[e,i]of t)e&&i!==void 0&&e.geometry.setDrawRange(0,this.precipitationCount(i));this.rainSystem&&(this.rainSystem.uniforms.uSpeedStreak.value=Nm(fu(this.weather.precipitationIntensity)))}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const t=this.weather.precipitationType;if(t==="none")return;if(t==="rain"){this.buildRain();return}const e=hu[t],i=e.poolSize,n=mu(9001),s=new Float32Array(i*3),a=new Float32Array(i),o=new Float32Array(i),c=new Float32Array(i),l=new Float32Array(i),h=new Float32Array(i),u=new Float32Array(i),d=new Float32Array(i),f=new Float32Array(i),p=new Float32Array(i);for(let y=0;y<i;y++){const M=n()*Math.PI*2,b=n()*e.radiusM;s[y*3]=Math.cos(M)*b,s[y*3+1]=dr+n()*(e.topYM-dr),s[y*3+2]=Math.sin(M)*b,a[y]=n()*Math.PI*2,o[y]=.7+n()*.6,c[y]=.6+n()*.8,l[y]=.4+n()*1.2}const v=new ce;v.setAttribute("position",new ie(s,3)),v.setDrawRange(0,this.precipitationCount(i));const m={uSize:{value:e.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:e.opacity},uColor:{value:e.color.clone()},uHazeColor:{value:new st(...this.baseFogColor)},uTexture:{value:gE(t)},uNearFocusDistance:{value:zm},uHazeDistance:{value:e.radiusM*Bm}},g=new le({uniforms:m,vertexShader:SE,fragmentShader:bE,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const S=new xs(v,g);S.renderOrder=cu,this.scene.add(S),this.precipitationPoints=S,this.precipitationPositions=s,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=p}updatePrecipitation(t,e){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter)return;this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor);const i=this.weather.precipitationType;if(i==="none"||i==="rain")return;const n=hu[i];if(this.precipitationUniforms?.uColor.value.copy(ke.litBySky(n.color,this.baseFogColor)),e<=0)return;const s=this.weather.windDirectionDeg*qi,a=Math.sin(s)*this.weather.windSpeed*n.driftSensitivity,o=-Math.cos(s)*this.weather.windSpeed*n.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,p=this.precipitationBounceHeight,v=this.precipitationBounceDuration,m=this.precipitationBounceVelX,g=this.precipitationBounceVelZ,S=i==="snow"&&u&&d,y=i==="hail"&&f&&p&&v&&m&&g;for(let M=0,b=0;M<c.length;M+=3,b++){if(y&&f[b]>0){if(f[b]-=e,f[b]<=0){const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A,f[b]=0}else{const x=1-f[b]/v[b];c[M+1]=dr+Math.sin(Math.PI*x)*p[b],c[M]=Zc(c[M]+(a+m[b])*e,n.radiusM),c[M+2]=Zc(c[M+2]+(o+g[b])*e,n.radiusM)}continue}let w=0,T=0;if(S){const x=oE*u[b],A=cE*d[b];w=Math.sin(t*x*Math.PI*2+l[b])*A,T=Math.sin(t*x*Math.PI*2+l[b]+Math.PI/2)*A}if(c[M]+=(a+w)*e,c[M+1]-=n.fallSpeedMPerS*h[b]*e,c[M+2]+=(o+T)*e,c[M]=Zc(c[M],n.radiusM),c[M+2]=Zc(c[M+2],n.radiusM),c[M+1]<dr){if(y){p[b]=Xm*(.2+Math.random()*1.6),v[b]=lE*(.5+Math.random()),f[b]=v[b];const C=Math.random()*Math.PI*2,I=hE*(p[b]/Xm);m[b]=Math.cos(C)*I,g[b]=Math.sin(C)*I,c[M+1]=dr;continue}const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=fu(this.weather.precipitationIntensity);this.rainSystem=jw({count:du,radiusM:uo,heightM:Q5,bottomYM:Pm,overallSpeed:tE,color:Om.clone(),opacity:.85,visibleCount:this.precipitationCount(du),speedStreak:Nm(t),pixelSize:Gm,seed:9001,nearFocusDistanceM:zm,hazeDistanceM:uo*Bm,hazeColor:new st(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=cu,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=mu(4242),e=new Float32Array(pa*3),i=new Float32Array(pa),n=new Float32Array(pa),s=new Float32Array(pa);for(let h=0;h<pa;h++){const u=t()*Math.PI*2,d=Math.sqrt(t())*uo;e[h*3]=Math.cos(u)*d,e[h*3+1]=Pm,e[h*3+2]=Math.sin(u)*d,n[h]=Ym(Fm,Um),i[h]=t()*n[h],s[h]=i[h]/n[h]}const a=new ce;a.setAttribute("position",new ie(e,3));const o=new ie(s,1);a.setAttribute("aLife",o),a.setDrawRange(0,this.precipitationCount(pa));const c=new le({uniforms:{uMaxSize:{value:sE},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:km.clone()},uTexture:{value:xE()}},vertexShader:yE,fragmentShader:_E,transparent:!0,depthWrite:!1}),l=new xs(a,c);l.renderOrder=cu,this.scene.add(l),this.rainSplashSystem={points:l,positions:e,life:i,duration:n,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.rainSystem.points.removeFromParent(),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.rainSplashSystem.points.removeFromParent(),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}syncRainSlant(){const t=this.rainSystem;if(!t)return;const e=this.weather.windDirectionDeg*qi;t.uniforms.uDropVelocity.value.set(Math.sin(e)*this.weather.windSpeed,-fu(this.weather.precipitationIntensity),-Math.cos(e)*this.weather.windSpeed);const i=this.renderer.getSize(this.rainViewportSize);t.uniforms.uAspect.value=i.x/Math.max(i.y,1)}updateRain(t){const e=this.rainSystem;if(!e)return;e.uniforms.uTime.value+=t,e.uniforms.uHazeColor.value.setRGB(...this.baseFogColor),e.uniforms.uColor.value.copy(ke.litBySky(Om,this.baseFogColor));const i=this.rainSplashSystem?.points.material?.uniforms?.uColor;i&&i.value.copy(ke.litBySky(km,this.baseFogColor));const n=this.weather.windDirectionDeg*qi,s=Math.sin(n)*this.weather.windSpeed,a=-Math.cos(n)*this.weather.windSpeed,o=uo,c=h=>(h%(o*2)+o*3)%(o*2)-o;e.uniforms.uWindOffset.value.set(c(e.uniforms.uWindOffset.value.x+s*t),c(e.uniforms.uWindOffset.value.y+a*t)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const l=Math.abs(this.rainCameraDirection.y);if(Math.abs(l-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=l;const h=Vm+(1-Vm)*(1-l),u=Wm+(1-Wm)*(1-l);e.uniforms.uUvSquash.value=u,e.uniforms.uPixelSize.value=Gm*h*(.5+.5*u)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:i,life:n,duration:s,lifeAttribute:a}=e,o=a.array;for(let c=0,l=0;c<i.length;c+=3,l++){if(n[l]+=t,n[l]>=s[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*uo;i[c]=Math.cos(h)*u,i[c+2]=Math.sin(h)*u,s[l]=Ym(Fm,Um),n[l]=0}o[l]=n[l]/s[l]}e.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}setLightning(t){this.lightningFlashes=t}updateLightning(t){let e,i=0;if(this.lightningArmed)for(const c of this.lightningFlashes){if(c.t>t)break;const l=pi.brightnessAt(c,t);l>i&&(e=c,i=l)}const n=e?Math.min(1,Math.max(.1,(fE/e.distanceM)**2)):0,s=i*n*(e?.cloudToGround?1:.6);if(s===this.lightningLevel&&!e?.cloudToGround)return;if(this.lightningLevel=s,this.scene.fog){const c=this.scene.fog,l=s*pu*this.relativeScale/Math.PI;c.color.setRGB(this.airlight[0]+Xn.r*l,this.airlight[1]+Xn.g*l,this.airlight[2]+Xn.b*l)}const a=this.skyMesh?.material?.color;if(a){const c=s*pE;a.setRGB(1+c*Xn.r,1+c*Xn.g,1+c*Xn.b)}if(this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.lightningLight.intensity=s*pu*this.relativeScale,e){const{x:c,y:l,z:h}=hi(25,e.azimuthDeg,sn);this.lightningLight.position.set(c,l,h)}this.lightningBolt||(this.lightningBolt=new Ys(sn*.95),this.celestialGroup.add(this.lightningBolt.object));const o=this.weather.cloudBaseM??1500;this.lightningBolt.set(e,i,o),this.render()}buildCompassLabels(){this.compassSprites=G5.map(t=>{const e=Ia.point(t,this.compassPoints),i=new rl({map:wE(e),depthTest:!1,fog:!1}),n=new Jr(i),{x:s,y:a,z:o}=hi(0,t,Tm);return n.position.set(s,a,o),n.scale.set(Kc,Kc,1),n.renderOrder=X5,n.layers.set(ym),n.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(n),n}),this.updateCompassScale()}updateCompassScale(){const t=this.camera.fov*Math.PI/360,e=Rm*Math.PI/360,i=Kc*Math.tan(t)/Math.tan(e);for(const n of this.compassSprites)n.scale.set(i,i,1)}disposeCompassLabels(){for(const t of this.compassSprites)t.removeFromParent(),t.material.map?.dispose(),t.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const t of this.starTiers)this.disposeMesh(t.points);this.starTiers=[]}disposeMesh(t){if(!t)return;t.removeFromParent(),"geometry"in t&&t.geometry.dispose();const e=t.material;for(const i of Array.isArray(e)?e:[e]){const n=i.map;n&&n.dispose(),i.dispose()}}}const qi=Math.PI/180;function Mr(r,t,e){return Math.max(t,Math.min(e,r))}function Ym(r,t){return r+Math.random()*(t-r)}function Zc(r,t){return(r%(t*2)+t*3)%(t*2)-t}let Jc,jc;function gE(r){switch(r){case"snow":return vE();case"hail":return ME()}}function vE(){if(Jc)return Jc;const r=64,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d"),i=e.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);return i.addColorStop(0,"rgba(255,255,255,0.95)"),i.addColorStop(.5,"rgba(255,255,255,0.55)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,r,r),Jc=new Is(t),Jc}function ME(){if(jc)return jc;const r=64,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d"),i=e.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(.55,"rgba(255,255,255,0.95)"),i.addColorStop(.8,"rgba(255,255,255,0.4)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,r,r),jc=new Is(t),jc}let Qc;function xE(){if(Qc)return Qc;const r=64,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d"),i=e.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);return i.addColorStop(0,"rgba(255,255,255,0)"),i.addColorStop(.4,"rgba(255,255,255,0)"),i.addColorStop(.6,"rgba(255,255,255,0.9)"),i.addColorStop(.8,"rgba(255,255,255,0.25)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,r,r),Qc=new Is(t),Qc}const yE=`
7510
7567
  uniform float uMaxSize;
7511
7568
  uniform float uScale;
7512
7569
  attribute float aLife;
@@ -7572,4 +7629,4 @@ void main() {
7572
7629
  gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
7573
7630
  }
7574
7631
  `;function qm(r){const e=document.createElement("canvas");e.width=128,e.height=128;const i=e.getContext("2d"),n=128/2-2,s=128/2,a=128/2,o="#010101",c="#f4f1e2";i.fillStyle=o,i.beginPath(),i.arc(s,a,n,0,Math.PI*2),i.fill();const l=Mr(r.illuminatedFraction,0,1),h=r.phaseFraction<.5,u=n*Math.abs(1-2*l),d=l<.5;return i.save(),i.beginPath(),i.arc(s,a,n,0,Math.PI*2),i.clip(),i.fillStyle=c,i.beginPath(),h?(i.arc(s,a,n,-Math.PI/2,Math.PI/2,!1),i.ellipse(s,a,u,n,0,Math.PI/2,-Math.PI/2,d)):(i.arc(s,a,n,Math.PI/2,-Math.PI/2,!1),i.ellipse(s,a,u,n,0,-Math.PI/2,Math.PI/2,d)),i.fill(),i.restore(),new Is(e)}function wE(r){const t=document.createElement("canvas");t.width=128,t.height=128;const e=t.getContext("2d");return e.fillStyle="rgba(0, 0, 0, 0.55)",e.beginPath(),e.arc(64,64,60,0,Math.PI*2),e.fill(),e.fillStyle="#ffffff",e.font="bold 52px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(r,64,68),new Is(t)}function mu(r){let t=r;return function(){t|=0,t=t+1831565813|0;let i=Math.imul(t^t>>>15,1|t);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}class Nl{constructor(t,e){this.source=t,this.create=e}scene;wanted;pumping=!1;disposed=!1;static PATIENCE_FRAMES=600;static SCENE_WIDTH_PX=320;paint(t,e){this.disposed||(this.wanted={t,canvas:e},this.pumping||this.pump())}recordingChanged(t){this.scene&&(this.scene.sightingData=t)}dispose(){this.disposed=!0,this.scene?.remove(),this.scene=void 0}ensureScene(){if(this.scene)return this.scene;const t=this.create();return t.setAttribute("max-pixel-ratio","1"),Object.assign(t.style,{position:"fixed",left:"-10000px",top:"0",width:`${Nl.SCENE_WIDTH_PX}px`,visibility:"hidden",pointerEvents:"none"}),document.body.appendChild(t),t.documentUrl=this.source.documentUrl,t.accountInTheRound=this.source.accountInTheRound,t.sightingData=this.source.sightingData,this.scene=t,t}async pump(){this.pumping=!0;try{for(;this.wanted&&!this.disposed;){const{t,canvas:e}=this.wanted;this.wanted=void 0;const i=this.ensureScene();i.interpretation!==this.source.interpretation&&(i.interpretation=this.source.interpretation),i.compareAccount!==this.source.compareAccount&&(i.compareAccount=this.source.compareAccount),i.showAt(t);for(let n=0;n<Nl.PATIENCE_FRAMES&&!this.wanted&&!this.disposed&&(await new Promise(s=>requestAnimationFrame(()=>s())),!this.wanted);n++)if(i.snapshotTo(e)){e.dataset.ready="true";break}}}finally{this.pumping=!1}}}const gu=7.5,vu=9;class qn{static cache=new Map;static load(t){let e=qn.cache.get(t);return e||(e=fetch(t).then(i=>i.arrayBuffer()).then(i=>qn.parse(i)),qn.cache.set(t,e)),e}static upTo(t,e){const i=t.filter((a,o)=>o===0||t[o-1].magnitudeLimit<e);if(i.length<=1)return qn.load(t[0].url);const n=i.map(a=>a.url).join(`
7575
- `);let s=qn.cache.get(n);return s||(s=Promise.all(i.map(a=>qn.load(a.url))).then(a=>a.reduce((o,c)=>qn.concat(o,c))),qn.cache.set(n,s)),s}static parse(t){const e=t.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),i=e*Float32Array.BYTES_PER_ELEMENT;return{count:e,ra:new Float32Array(t,0*i,e),dec:new Float32Array(t,1*i,e),mag:new Float32Array(t,2*i,e),ci:new Float32Array(t,3*i,e)}}static concat(t,e){const i=(n,s)=>{const a=new Float32Array(n.length+s.length);return a.set(n,0),a.set(s,n.length),a};return{count:t.count+e.count,ra:i(t.ra,e.ra),dec:i(t.dec,e.dec),mag:i(t.mag,e.mag),ci:i(t.ci,e.ci)}}}class $m{constructor(t){this.names=t}body(t,e){return this.names?.bodies[t]??e}star(t){return this.names?.stars[t.name]??t.name}comet(t){return this.names?.comets[t.id]??t.name}nova(t){return this.names?.novae[t.id]??t.name}satelliteClass(t){return this.names?.satelliteClasses[t.id]??t.name}shower(t){return this.names?.showers[t.id]??t.name}lightRig(t){return this.names?.lightRigs[t.id]??t.name}instrument(t){return this.names?.instruments[t.id]??t.name}decorKind(t,e){return this.names?.decorKinds[t]??e}point(t){return Ia.point(t,this.names?.compassPoints)}towards(t){return Ia.towards(t,this.names)}}const EE="“Thunder” by Jerimee",AE="https://creativecommons.org/licenses/by/3.0/",TE="CC BY 3.0";class $n{static fill(t,e){t.innerHTML="";const i=l=>t.appendChild(l),n=e.currentTerrainAttribution;n&&i($n.text(n));const s=e.currentRoadAttribution;s&&i($n.text(s));const a=e.ufoElement.observerMapCredit;a&&!n?.includes(a)&&i($n.text(a));for(const l of e.decorModelCredits){const h=l.author?` — ${l.author}`:"",u=document.createElement("li");l.sourceUrl?u.append($n.link(l.sourceUrl,l.title),document.createTextNode(`${h} (${l.license})`)):u.textContent=`${l.title}${h} (${l.license})`,i(u)}for(const l of e.ufoElement.sighting.references){if(!l.credit)continue;const h=document.createElement("li");l.creditUrl?h.appendChild($n.link(l.creditUrl,l.credit)):h.textContent=l.credit,i(h)}const o=e.satelliteState;if(o.status==="ready"&&o.credit){const l=document.createElement("li");l.appendChild($n.link(o.creditUrl??"",o.credit)),i(l)}const c=$n.text(`${EE} (`);c.append($n.link(AE,TE),document.createTextNode(")")),i(c)}static text(t){const e=document.createElement("li");return e.textContent=t,e}static link(t,e){const i=document.createElement("a");return i.href=t,i.target="_blank",i.rel="noopener",i.textContent=e,i}}const RE=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,DE=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,IE=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,CE=20,PE=1;class LE{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=0;paused=!0;requested={type:"none",intensity:0,windSpeed:0};level=1;master;output(t){return this.master||(this.master=t.createGain(),this.master.gain.value=this.level,this.master.connect(t.destination)),this.master}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",t);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(t,e,i){if(this.requested={type:t,intensity:e,windSpeed:i},!this.context)return;this.paused&&(t="none",e=0,i=0);const n=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=n==="hail"?Math.min(1,e*1.3+.2):n==="rain"?e:0,n!==this.ambientKey){this.ambientKey=n;const a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,n!=="none"&&this.startLoop(RE,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(i/CE,1);const s=i>PE;if(s!==this.windActive){this.windActive=s;const a=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,s&&this.startLoop(DE,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(t){if(t===this.paused)return;this.paused=t;const{type:e,intensity:i,windSpeed:n}=this.requested;this.setAmbient(e,i,n)}playThunder(){!this.context||this.paused||this.playOneShot(IE,.9)}dispose(){this.ambientToken++,this.windToken++,this.stopSource(this.ambientSource,this.ambientGain),this.stopSource(this.windSource,this.windGain),this.ambientSource=void 0,this.ambientGain=void 0,this.windSource=void 0,this.windGain=void 0,this.context?.close(),this.context=void 0,this.master=void 0,this.buffers.clear()}applyIfCurrent(t,e,i,n){if(e!==i()){t?.source.stop();return}n(t)}async startLoop(t,e){const i=this.context;if(i)try{const n=await this.getBuffer(t),s=i.createBufferSource();s.buffer=n,s.loop=!0;const a=i.createGain();return a.gain.value=e,s.connect(a).connect(this.output(i)),s.start(),{source:s,gain:a}}catch(n){console.warn("Weather ambient sound failed to load, staying silent:",n);return}}async playOneShot(t,e){const i=this.context;if(i)try{const n=await this.getBuffer(t),s=i.createBufferSource();s.buffer=n;const a=i.createGain();a.gain.value=e,s.connect(a).connect(this.output(i)),s.start()}catch(n){console.warn("Thunder sound failed to load:",n)}}async getBuffer(t){const e=this.context;if(!e)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(t);return i||(i=fetch(t).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${t}`);return n.arrayBuffer()}).then(n=>e.decodeAudioData(n)),this.buffers.set(t,i)),i}stopSource(t,e){try{t?.stop()}catch{}t?.disconnect(),e?.disconnect()}}class Ms{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:i}=t,[n,s]=this.perifocalAxes(),a=Math.sqrt(Ms.SUN_GM_AU3_PER_DAY2*(1+e)/i);this.perihelionPosition=this.scale(n,i),this.perihelionVelocity=this.scale(s,a),this.inverseSemiMajorAxis=(1-e)/i}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(t){const e=t-this.elements.perihelionJd,i=this.universalAnomaly(e),n=this.inverseSemiMajorAxis*i*i,s=this.elements.perihelionAu,a=1-i*i/s*Ms.stumpffC(n),o=e-i*i*i/Math.sqrt(Ms.SUN_GM_AU3_PER_DAY2)*Ms.stumpffS(n);return{x:a*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:a*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:a*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(t){const e=this.positionAt(t);return Math.hypot(e.x,e.y,e.z)}universalAnomaly(t){if(t===0)return 0;const e=Math.sign(t),i=Math.sqrt(Ms.SUN_GM_AU3_PER_DAY2)*Math.abs(t),n=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*Ms.stumpffS(c)+l*o};let s=Math.max(1,i/this.elements.perihelionAu);for(;n(s)<i;)s*=2;let a=0;for(let o=0;o<Ms.MAX_ITERATIONS&&s-a>1e-13*Math.max(1,s);o++){const c=(a+s)/2;n(c)<i?a=c:s=c}return e*(a+s)/2}perifocalAxes(){const t=this.elements.ascendingNodeDeg*Math.PI/180,e=this.elements.argumentOfPerihelionDeg*Math.PI/180,i=this.elements.inclinationDeg*Math.PI/180,n=Math.cos(t),s=Math.sin(t),a=Math.cos(e),o=Math.sin(e),c=Math.cos(i),l=Math.sin(i);return[{x:n*a-s*o*c,y:s*a+n*o*c,z:o*l},{x:-n*o-s*a*c,y:-s*o+n*a*c,z:a*l}]}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}static stumpffC(t){if(Math.abs(t)<1e-6)return 1/2-t/24+t*t/720;if(t>0)return(1-Math.cos(Math.sqrt(t)))/t;const e=Math.sqrt(-t);return(Math.cosh(e)-1)/-t}static stumpffS(t){if(Math.abs(t)<1e-6)return 1/6-t/120+t*t/5040;if(t>0){const i=Math.sqrt(t);return(i-Math.sin(i))/(i*i*i)}const e=Math.sqrt(-t);return(Math.sinh(e)-e)/(e*e*e)}}const G1=[{id:"halley-1910",designation:"1P/Halley",name:"Halley's Comet",orbit:{eccentricity:.9672960498922706,perihelionAu:.5872100477652511,inclinationDeg:162.218798367122,ascendingNodeDeg:58.56208298700436,argumentOfPerihelionDeg:111.7366940639061,perihelionJd:2.4187816784171113e6},peakMagnitude:0,peakOn:"1910-05-20",absoluteMagnitude:4.72,activityExponent:4,tailLengthDeg:100,tailLengthAu:.1638,note:"Passed 0.15 au from Earth on 20 May 1910, and the Earth crossed the outer tail the day before — the apparition that produced a genuine public panic."},{id:"brooks-1911",designation:"C/1911 O1",name:"Comet Brooks",orbit:{eccentricity:.9876404970138669,perihelionAu:.4898172916113738,inclinationDeg:33.34043866978714,ascendingNodeDeg:293.7022074981857,argumentOfPerihelionDeg:153.5578007321686,perihelionJd:2.4193378856140426e6},peakMagnitude:2,peakOn:"1911-10-25",absoluteMagnitude:5.59,activityExponent:4},{id:"skjellerup-maristany-1927",designation:"C/1927 X1",name:"Comet Skjellerup-Maristany",orbit:{eccentricity:.999839726885059,perihelionAu:.1761569619628186,inclinationDeg:85.1125991950808,ascendingNodeDeg:78.24360172472711,argumentOfPerihelionDeg:47.15877857390136,perihelionJd:2.4252326808989984e6},peakMagnitude:-6,peakOn:"1927-12-15",absoluteMagnitude:1.19,activityExponent:4,note:"One of the few comets of the century seen in full daylight."},{id:"de-kock-paraskevopoulos-1941",designation:"C/1941 B2",name:"Comet de Kock-Paraskevopoulos",orbit:{eccentricity:.9991026715181549,perihelionAu:.7900329662827822,inclinationDeg:168.2039226531089,ascendingNodeDeg:43.10609347214336,argumentOfPerihelionDeg:268.6990344196369,perihelionJd:2430022157765061e-9},peakMagnitude:2,peakOn:"1941-02-05",absoluteMagnitude:5.01,activityExponent:4},{id:"southern-1947",designation:"C/1947 X1",name:"the Southern Comet",orbit:{eccentricity:.9998424430916737,perihelionAu:.1100045955093761,inclinationDeg:138.5113919632757,ascendingNodeDeg:337.3114969669252,argumentOfPerihelionDeg:196.1820121395961,perihelionJd:2.4325220864727003e6},peakMagnitude:-3,peakOn:"1947-12-08",absoluteMagnitude:3.01,activityExponent:4,note:"A bright southern-hemisphere comet of December 1947, the month the American sighting wave of that year was still being argued over."},{id:"eclipse-1948",designation:"C/1948 V1",name:"the Eclipse Comet",orbit:{eccentricity:.9999130678247334,perihelionAu:.1354437057263306,inclinationDeg:23.11668597152911,ascendingNodeDeg:211.0454985994762,argumentOfPerihelionDeg:107.2474157073104,perihelionJd:2.4328519265329437e6},peakMagnitude:-2,peakOn:"1948-11-01",absoluteMagnitude:4.79,activityExponent:4,note:"Found during the total solar eclipse of 1 November 1948, which is how a comet that bright had gone unnoticed: it had been hidden in the Sun's glare."},{id:"arend-roland-1957",designation:"C/1956 R1",name:"Comet Arend-Roland",orbit:{eccentricity:1.0002570255357,perihelionAu:.3160532361485914,inclinationDeg:119.9440863251822,ascendingNodeDeg:215.8548157717755,argumentOfPerihelionDeg:308.775920364167,perihelionJd:2.4359365327396123e6},peakMagnitude:.5,peakOn:"1957-04-25",absoluteMagnitude:3.96,activityExponent:4,note:"Showed a spike pointing back TOWARD the Sun in late April 1957 — a real anti-tail, and much reported at the time."},{id:"mrkos-1957",designation:"C/1957 P1",name:"Comet Mrkos",orbit:{eccentricity:.9993521583504134,perihelionAu:.3549238508212375,inclinationDeg:93.9433042053929,ascendingNodeDeg:68.32441518619923,argumentOfPerihelionDeg:40.31823675802871,perihelionJd:243605193752228e-8},peakMagnitude:1,peakOn:"1957-08-05",absoluteMagnitude:5.07,activityExponent:4,note:"The second bright naked-eye comet of 1957, four months after Arend-Roland."},{id:"seki-lines-1962",designation:"C/1962 C1",name:"Comet Seki-Lines",orbit:{eccentricity:1.000003791331562,perihelionAu:.03139689112215131,inclinationDeg:65.01487186102287,ascendingNodeDeg:304.6776602796538,argumentOfPerihelionDeg:11.47295326312573,perihelionJd:2437756163010178e-9},peakMagnitude:-2.5,peakOn:"1962-04-01",absoluteMagnitude:9.3,activityExponent:4},{id:"ikeya-seki-1965",designation:"C/1965 S1",name:"Comet Ikeya-Seki",orbit:{eccentricity:.9999141178248997,perihelionAu:.007785966366889336,inclinationDeg:141.8642315267051,ascendingNodeDeg:346.9951764632611,argumentOfPerihelionDeg:69.04909813996062,perihelionJd:2.4390546837018197e6},peakMagnitude:-10,peakOn:"1965-10-21",alsoRecordedMagnitude:2,alsoRecordedOn:"1965-10-30",absoluteMagnitude:5.26,activityExponent:4.002,tailLengthDeg:25,tailLengthAu:.5048,note:"A sungrazer that passed 450 000 km above the Sun's surface and was seen beside it in broad daylight — the brightest comet of the twentieth century. It then stood in the dawn sky for a fortnight with a tail some 25 degrees long, which is the second magnitude recorded here."},{id:"bennett-1970",designation:"C/1969 Y1",name:"Comet Bennett",orbit:{eccentricity:.9962979048768408,perihelionAu:.5376209981502136,inclinationDeg:90.03975717147327,ascendingNodeDeg:224.6576652531314,argumentOfPerihelionDeg:354.1494209173161,perihelionJd:2.4406655455270996e6},peakMagnitude:0,peakOn:"1970-03-26",absoluteMagnitude:3.36,activityExponent:4},{id:"white-ortiz-bolelli-1970",designation:"C/1970 K1",name:"Comet White-Ortiz-Bolelli",orbit:{eccentricity:.9999488875801225,perihelionAu:.00884411465256722,inclinationDeg:138.9520738221631,ascendingNodeDeg:336.8194095816687,argumentOfPerihelionDeg:61.10224765396615,perihelionJd:2.4407209807728203e6},peakMagnitude:1,peakOn:"1970-05-22",absoluteMagnitude:4.35,activityExponent:4},{id:"kohoutek-1973",designation:"C/1973 E1",name:"Comet Kohoutek",orbit:{eccentricity:1.000007152175185,perihelionAu:.1424250377812859,inclinationDeg:14.30414984159355,ascendingNodeDeg:258.4893339663974,argumentOfPerihelionDeg:37.79772760699667,perihelionJd:2442044930687027e-9},peakMagnitude:0,peakOn:"1974-01-05",absoluteMagnitude:4.89,activityExponent:4,note:"Announced in advance as the comet of the century and remembered for disappointing: it was an ordinary naked-eye object, not the spectacle the press had promised."},{id:"west-1976",designation:"C/1975 V1",name:"Comet West",orbit:{eccentricity:1.000017859625611,perihelionAu:.1966006188461085,inclinationDeg:43.07319920579427,ascendingNodeDeg:118.9189245655447,argumentOfPerihelionDeg:358.4315101259072,perihelionJd:2442833721841768e-9},peakMagnitude:-3,peakOn:"1976-02-25",absoluteMagnitude:4.41,activityExponent:4,tailLengthDeg:30,tailLengthAu:.4325,note:"Broke into four pieces at perihelion. Barely reported at the time — the press had been burned by Kohoutek two years earlier."},{id:"iras-araki-alcock-1983",designation:"C/1983 H1",name:"Comet IRAS-Araki-Alcock",orbit:{eccentricity:.9898409731606003,perihelionAu:.9913412593828502,inclinationDeg:73.25000846947029,ascendingNodeDeg:49.10235754476374,argumentOfPerihelionDeg:192.8506176754439,perihelionJd:2.4454757545235856e6},peakMagnitude:1.7,peakOn:"1983-05-11",absoluteMagnitude:9.04,activityExponent:4,note:"Passed 0.031 au from Earth on 11 May 1983, one of the closest cometary approaches on record: it crossed a quarter of the sky in a night, which no other comet in this list did."},{id:"halley-1986",designation:"1P/Halley",name:"Halley's Comet",orbit:{eccentricity:.9672792271749998,perihelionAu:.5871034488173393,inclinationDeg:162.2422242700916,ascendingNodeDeg:58.85993640671803,argumentOfPerihelionDeg:111.8655480539208,perihelionJd:2.4464709589610207e6},peakMagnitude:2.1,peakOn:"1986-03-10",absoluteMagnitude:2.71,activityExponent:4,note:"The worst-placed return in two thousand years — famous, expected, and for most observers a faint smudge."},{id:"hyakutake-1996",designation:"C/1996 B2",name:"Comet Hyakutake",orbit:{eccentricity:.9997295133739305,perihelionAu:.2302272039470452,inclinationDeg:124.923592343765,ascendingNodeDeg:188.0454295899424,argumentOfPerihelionDeg:130.1724036582639,perihelionJd:2.4502048946148166e6},peakMagnitude:0,peakOn:"1996-03-25",absoluteMagnitude:4.75,activityExponent:4,tailLengthDeg:80,tailLengthAu:1,note:"Passed 0.10 au from Earth in March 1996, five weeks BEFORE perihelion, with a tail measured at some 80 degrees — the longest of the modern era."},{id:"hale-bopp-1997",designation:"C/1995 O1",name:"Comet Hale-Bopp",orbit:{eccentricity:.9951314746156615,perihelionAu:.9141695067003724,inclinationDeg:89.43017155012492,ascendingNodeDeg:282.470602866853,argumentOfPerihelionDeg:130.5872524854533,perihelionJd:2450539633099368e-9},peakMagnitude:-.8,peakOn:"1997-04-01",absoluteMagnitude:-1.06,activityExponent:4,tailLengthDeg:20,tailLengthAu:.9938,note:"Visible to the naked eye for about eighteen months, longer than any comet on record."},{id:"mcnaught-2007",designation:"C/2006 P1",name:"Comet McNaught",orbit:{eccentricity:1.00001811603225,perihelionAu:.1707325614080681,inclinationDeg:77.83726446452654,ascendingNodeDeg:267.4149080498975,argumentOfPerihelionDeg:155.9756130642756,perihelionJd:2454113298753579e-9},peakMagnitude:-5.5,peakOn:"2007-01-13",absoluteMagnitude:2.53,activityExponent:4,tailLengthDeg:35,tailLengthAu:.5009,note:"The brightest comet since Ikeya-Seki, seen in daylight beside the Sun in January 2007."},{id:"lovejoy-2011",designation:"C/2011 W3",name:"Comet Lovejoy",orbit:{eccentricity:.999915056276912,perihelionAu:.005553783989325053,inclinationDeg:134.3558712062691,ascendingNodeDeg:326.3693517957772,argumentOfPerihelionDeg:53.50991655176601,perihelionJd:2455911511809431e-9},peakMagnitude:-3,peakOn:"2011-12-16",alsoRecordedMagnitude:1.5,alsoRecordedOn:"2011-12-22",absoluteMagnitude:3.51,activityExponent:1.194,note:"A sungrazer that was expected to be destroyed at perihelion and came out the other side, to stand in the southern dawn sky for the rest of December — which is the second magnitude recorded here."},{id:"panstarrs-2013",designation:"C/2011 L4",name:"Comet PANSTARRS",orbit:{eccentricity:1.000032542889696,perihelionAu:.301544229714915,inclinationDeg:84.2081978367921,ascendingNodeDeg:65.66588626213694,argumentOfPerihelionDeg:333.6516444379993,perihelionJd:2456361669960698e-9},peakMagnitude:1,peakOn:"2013-03-10",absoluteMagnitude:5.98,activityExponent:4},{id:"neowise-2020",designation:"C/2020 F3",name:"Comet NEOWISE",orbit:{eccentricity:.9991782081129224,perihelionAu:.2946512466331692,inclinationDeg:128.9375043020912,ascendingNodeDeg:61.01042991771634,argumentOfPerihelionDeg:37.2786526292898,perihelionJd:2.4590341788972816e6},peakMagnitude:.9,peakOn:"2020-07-08",absoluteMagnitude:5.79,activityExponent:4,tailLengthDeg:10,tailLengthAu:.1808,note:"The first comet since Hale-Bopp that ordinary observers in the northern hemisphere saw without being told where to look."},{id:"tsuchinshan-atlas-2024",designation:"C/2023 A3",name:"Comet Tsuchinshan-ATLAS",orbit:{eccentricity:1.000020192843226,perihelionAu:.3914228969475176,inclinationDeg:139.1105462619479,ascendingNodeDeg:21.55945689078845,argumentOfPerihelionDeg:308.4913086299446,perihelionJd:2460581242087108e-9},peakMagnitude:0,peakOn:"2024-10-14",absoluteMagnitude:3.97,activityExponent:4,tailLengthDeg:20,tailLengthAu:.1902,note:"Briefly reported far brighter around 9 October 2024, when it stood almost between the observer and the Sun and forward-scattered the light through its own dust — a geometry this catalog's brightness model does not attempt, so what is stored is the ordinary evening-sky peak a few days later."}];class OE{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(t){const e=this.julianDayOf(t);return G1.filter(i=>Math.abs(e-i.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(t,e){return this.aroundDate(t).map(i=>this.appearanceOf(i,t,e)).sort((i,n)=>i.magnitude-n.magnitude)[0]}static appearanceOf(t,e,i){const n=$e(e),s=this.earthPositionAt(n),a=this.apparentPositionOf(t,2451545+n.tt,s),o=this.subtract(a,s),c=this.length(a),l=this.length(o),h=this.tailEndAt(t,a,s,c,n,e,i),u=this.horizontalOf(o,n,e,i);return{apparition:t,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},s)),magnitude:this.magnitudeAt(t,c,l)}}static magnitudeAt(t,e,i){const n=t.absoluteMagnitude+5*Math.log10(i)+2.5*t.activityExponent*Math.log10(e);return Math.max(n,t.peakMagnitude)}static tailEndAt(t,e,i,n,s,a,o){if(t.tailLengthAu===void 0)return{};const c=1+t.tailLengthAu/n,l=this.subtract({x:e.x*c,y:e.y*c,z:e.z*c},i),h=this.subtract(e,i);return{tailEnd:this.horizontalOf(l,s,a,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(t,e,i){const n=this.orbitOf(t);let s=n.positionAt(e);for(let a=0;a<2;a++){const o=this.length(this.subtract(s,i))/this.LIGHT_SPEED_AU_PER_DAY;s=n.positionAt(e-o)}return s}static horizontalOf(t,e,i,n){const s=Ir(T5(),new Fe(t.x,t.y,t.z,e)),a=Ir(R1(e),s),o=r5(e,new O0(n.lat,n.lng,n.elevationM)),c=new Fe(a.x-o.x,a.y-o.y,a.z-o.z,e),l=F0(c);return U0(l.ra,l.dec,i,n)}static earthPositionAt(t){return Ir(A5(),ea(wt.Earth,t))}static julianDayOf(t){return 2451545+$e(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const i=new Ms(t.orbit);return this.orbits.set(t.id,i),i}static subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}static length(t){return Math.hypot(t.x,t.y,t.z)}static angleBetween(t,e){const i=(t.x*e.x+t.y*e.y+t.z*e.z)/(this.length(t)*this.length(e)||1);return Math.acos(Math.min(1,Math.max(-1,i)))*180/Math.PI}}const Mu=[{id:"sn-1006",kind:"supernova",designation:"SN 1006",name:"Supernova of 1006",raHours:15.03947,decDeg:-42.09694,peakMagnitude:-7.5,peakJd:2088620,startJd:2088620,lightCurve:[[0,-7.5],[29,-5.9],[60,-4.9],[106,-3.2],[166,-1.9],[258,-1],[350,.5],[364,.7],[411,1.2],[456,1.8],[484,2.5],[785.5,7]],source:"Winkler, Gupta & Long 2003 (peak); decline borrowed from SN 1572",note:"The brightest stellar event in recorded history, seen in daylight, low in the southern sky from Europe and the Near East. The decline is modelled, not recorded, and falls below the naked eye after about two years where the chronicles speak of three."},{id:"sn-1054",kind:"supernova",designation:"SN 1054",name:"Supernova of 1054",raHours:5.5755,decDeg:22.0175,peakMagnitude:-6,peakJd:2106216,startJd:2106216,lightCurve:[[0,-6],[23,-4],[642,6]],source:"Chinese chronicles (Song huiyao), via Stephenson & Green 2002",note:"The explosion that left the Crab Nebula. Its magnitude is an estimate; the two durations are recorded."},{id:"sn-1181",kind:"supernova",designation:"SN 1181",name:"Supernova of 1181",raHours:.88645,decDeg:67.50067,peakMagnitude:0,peakJd:2152636,startJd:2152636,lightCurve:[[0,0],[185,6]],source:"Chinese and Japanese chronicles, via Stephenson & Green 2002",note:"Circumpolar from Europe and China, so never set. Its peak magnitude is uncertain by at least a magnitude."},{id:"sn-1572",kind:"supernova",designation:"SN 1572",name:"Tycho's Supernova",raHours:.42264,decDeg:64.14083,peakMagnitude:-4,peakJd:2295551,startJd:2295546,lightCurve:[[0,-3],[5,-4],[34,-2.4],[65,-1.4],[111,.3],[171,1.6],[263,2.5],[355,4],[369,4.2],[416,4.7],[461,5.3],[489,6]],source:"Tycho Brahe and contemporaries, reduced by Ruiz-Lapuente 2004",note:"Circumpolar from northern Europe. Tycho showed it had no parallax, so it was not in the air: a new star, beyond the Moon."},{id:"sn-1604",kind:"supernova",designation:"SN 1604",name:"Kepler's Supernova",raHours:17.51125,decDeg:-21.48733,peakMagnitude:-2.95,peakJd:2307210,startJd:2307191,lightCurve:[[0,.23],[3,-1.3],[6,-2.08],[9,-2.17],[19,-2.95],[27,-2.95],[32,-1.95],[36,-1.52],[86,.9],[96,.45],[103,1],[114,1.2],[118,1.55],[133,1.95],[137,2.3],[170,2.25],[185,2.25],[194,2.4],[197,2.9],[308,4.45],[324,4.45],[339,4.95],[364,4.7]],source:"Kepler, Fabricius, Maestlin and the Korean court astronomers, reduced by Ruiz-Lapuente 2017",note:"The last supernova in our Galaxy seen with the naked eye. It went behind the Sun from mid-November 1604 to January 1605, which is the gap in its record."},{id:"t-crb-1866",kind:"nova",designation:"T CrB",name:"Nova Coronae Borealis 1866",raHours:15.99171,decDeg:25.92017,peakMagnitude:2,peakJd:2402734,startJd:2402734,lightCurve:[[0,2],[1.5,3],[2.5,3.11],[6.5,5.18],[8.5,5.75],[10.5,6.85],[11.5,6.8],[12.5,7.5],[16,8.18],[32,9.27],[38,9.2],[40,8.95],[44,9.4],[48,9.07],[54,9.4],[58,9.21],[79,9.44],[107,9.26],[111,9.01],[115,8.21],[119,7.96],[159,7.51],[179,7.57],[183,7.97],[191,7.66],[199,8.2],[207,8.31],[211,8.83],[215,8.65],[223,8.97],[297,8.9],[345,9.25],[377,9.07],[425,9.3],[537,9.3]],source:"Recorded peak (Birmingham); curve borrowed from its 1946 eruption",note:"The first eruption of the recurrent nova T CrB to be seen. The decline is its 1946 one."},{id:"t-aur-1891",kind:"nova",designation:"T Aur",name:"Nova Aurigae 1891",raHours:5.53309,decDeg:30.44583,peakMagnitude:4.49,peakJd:2412083,startJd:2412079,lightCurve:[[0,5.28],[4,4.49],[24,4.58],[40,4.97],[52,4.95],[56,4.5],[60,4.9],[68,4.88],[72,5.25],[76,4.93],[84,5.44],[88,7.23],[96,8.85],[100,10.44]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"gk-per-1901",kind:"nova",designation:"GK Per",name:"Nova Persei 1901",raHours:3.52,decDeg:43.90431,peakMagnitude:.19,peakJd:24154395e-1,startJd:24154377e-1,lightCurve:[[0,2.7],[.8,.86],[1.8,.19],[2.3,.2],[5.8,1.78],[11.8,2.54],[12.8,2.98],[17.8,3.62],[18.8,3.35],[19.8,3.77],[20.8,3.59],[22.8,3.95],[24.8,3.82],[25.6,4.99],[25.9,4.89],[26.6,3.69],[27.6,3.94],[27.9,4.61],[28.6,5.28],[28.9,4.46],[29.9,3.8],[30.9,4.27],[31.6,5.21],[31.9,5.22],[32.9,3.88],[33.9,4.19],[34.6,4.85],[35.6,4.8],[36.6,4.23],[37.6,4.44],[38.9,4.15],[39.7,5.19],[40.6,5.39],[40.9,5.35],[41.9,4.01],[42.6,4.5],[42.9,4.49],[43.6,5.53],[44,5.23],[44.6,5.61],[44.9,5.5],[45.9,4.17],[46.9,4.69],[47.6,5.5],[48.6,5.59],[49.6,5.14],[49.9,4.48],[50.6,4.45],[50.9,4.55],[51.6,5.47],[52.6,5.74],[53.7,5.66],[55.7,4.41],[56.7,5.43],[58.7,5.81],[58.9,5.58],[59.7,5.64],[59.9,4.76],[60.9,4.26],[61.9,5.62],[62.7,5.85],[62.9,5.53],[63.7,5.8],[64.9,4.28],[65.6,5.33],[66.7,5.87],[66.9,5.56],[68.7,5.7],[68.9,5.3],[69.7,4.47],[70.7,5.65],[72.9,5.98],[73.9,5.71],[74.7,4.98],[74.9,4.46],[75.7,4.87],[76.9,6.05],[77.6,5.76],[78,6],[78.7,5.95],[80.7,4.98],[81.9,5.85],[82.7,6.02],[84.7,5.41],[84.9,5.08],[85.7,5.17],[85.9,5.6],[87,6.1],[88.8,6.2],[89.7,4.96],[89.9,4.93],[90.7,5.9],[91.9,6.32],[92.7,5.86],[93.1,6.24],[93.7,5.38],[93.9,6.2],[96.1,6.12],[97.1,6.37],[97.6,5.12],[98,5.85],[99.3,6.35],[101.3,6.12],[101.7,5.25],[102.3,4.95],[102.7,6.12],[103.2,5.83],[104.7,6.37],[105,6.13],[106,6.22],[106.7,4.88],[107.7,6.3],[108.1,6.4],[109,6],[109.7,5.16],[110,5.82],[112.1,5.89],[113.1,5.5],[115.7,5.8],[116,6.11],[118.7,5.68],[119,6.23],[119.7,5.85],[120,6.12],[121,4.62],[121.8,5.9],[123,5.48],[125,6.05],[126,5.89],[130.9,6.11],[146.1,6.02],[155.6,6.26],[180.4,6.09],[190.4,6.39],[245.5,6.87],[266.2,6.77],[301.1,7.16],[321.5,7.07],[346.5,7.87],[375.7,7.86],[385.8,8.09],[389.8,8.55],[406.1,8.33],[416.5,8.59],[445.9,8.62],[472.1,9.24],[565.9,9.74],[571,9.4],[589.8,9.76]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"Discovered on 21 February 1901 by Thomas Anderson in Edinburgh, and the brightest nova of the century until V603 Aql."},{id:"dn-gem-1912",kind:"nova",designation:"DN Gem",name:"Nova Geminorum 1912",raHours:6.9151,decDeg:32.14108,peakMagnitude:3.58,peakJd:241947675e-2,startJd:241947275e-2,lightCurve:[[0,11.7],[1,4.5],[4,3.58],[5,4.45],[5.5,5.32],[6,5.53],[6.5,5.11],[8,5.43],[8.5,5.16],[11,5.53],[11.5,5.13],[12,5.18],[13.75,4.5],[15.75,5.3],[18.75,6],[19.75,5.55],[26.75,6],[28.75,5.9],[31.75,6.6],[32.75,6.2],[33.75,6.5],[36.75,6.55],[39.75,6.2],[40.75,6.75],[41.75,7],[44.75,6.75],[52.75,6.75],[54.75,7.23],[58.25,7.5],[62.25,7.3],[64.25,7.47],[66.25,8.1],[70.25,7.5],[72.25,8.1],[78.25,7.55],[80.25,8.2],[86.25,7.2],[90.25,7.3],[92.25,7.8],[152.25,7.2],[160.25,7.4],[166.25,8.2],[168.25,8.2],[170.25,7.3],[180.25,7.4],[182.25,8],[186.25,7.5],[190.25,7.6],[192.25,8],[211.25,7.75],[227.25,8],[275.25,7.78],[315.25,8.6],[331.25,7.79],[339.25,8.27],[363.25,8.61],[443.25,8.93],[451.25,9.2],[535.25,10.3],[567.25,9.9],[615.25,10.8],[631.25,10.63],[647.25,10.88],[679.25,10.8],[695.25,11.07],[727.25,11]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v603-aql-1918",kind:"nova",designation:"V603 Aql",name:"Nova Aquilae 1918",raHours:18.81518,decDeg:.58414,peakMagnitude:-.5,peakJd:242175475e-2,startJd:242174875e-2,lightCurve:[[0,11.3],[2,10.5],[4,6.6],[4.5,1.04],[6,-.5],[6.5,.18],[10,1.1],[10.5,.95],[12.75,1.89],[21.75,3.07],[23.75,3.76],[29.75,3.16],[34.75,3.5],[36.75,3.86],[44.75,3.79],[48.75,4.43],[52.75,3.84],[56.75,3.95],[57.75,4.04],[58.75,4.49],[59.75,4.42],[60.75,4.69],[62.75,4.6],[63.75,4.11],[64.75,3.97],[68.75,4.18],[70.75,4.65],[71.75,4.51],[73.75,4.73],[75.75,4.44],[79.75,4.85],[83.75,4.43],[89.75,4.88],[92.75,4.86],[94.75,4.58],[96.75,4.92],[99.75,5.05],[163.25,5.45],[167.25,5.7],[179.25,5.48],[191.25,5.8],[203.25,5.5],[247.25,5.9],[251.25,6.25],[257.25,5.5],[265.25,6.13],[281.25,6.33],[345.25,6.3],[385.25,6.73],[393.25,6.43],[425.25,6.71],[433.25,6.56],[461.25,7.27],[525.25,7.6],[541.25,7.47],[637.25,8.3],[669.25,8.17],[717.25,8.55],[749.25,8.4],[765.25,8.68],[885.25,8.75],[949.25,9.4],[1013.25,9.19],[1141.25,9.57],[1269.25,9.48],[1333.25,9.95],[1653.25,9.94],[1781.25,10.28],[1909.25,10.34],[2037.25,10.1],[2101.25,10.46],[2165.25,10.51],[2357.25,10.3],[2549.25,10.77],[2741.25,10.46],[2869.25,10.83],[3125.25,10.71],[3317.25,11.22],[3381.25,10.91],[3637.25,11.42],[3829.25,10.96],[3893.25,11.65],[3957.25,11.63],[4085.25,11.14],[4213.25,11.48],[4277.25,10.7],[4341.25,11.42],[4405.25,11.47],[4469.25,11.06],[4533.25,11.08],[4597.25,11.7],[4725.25,11.45],[4789.25,10.94]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"The brightest nova of the modern era, at magnitude -0.5 on 9-10 June 1918: as bright as Vega, in a summer evening sky, in wartime."},{id:"v476-cyg-1920",kind:"nova",designation:"V476 Cyg",name:"Nova Cygni 1920",raHours:19.97347,decDeg:53.61858,peakMagnitude:1.94,peakJd:242256025e-2,startJd:242255925e-2,lightCurve:[[0,2.7],[1,1.94],[3,2.07],[4.5,2.95],[8.25,4],[31.75,6.41],[35.75,7.23],[37.75,7.08],[41.75,7.33],[43.75,7.92],[45.75,8.2],[51.75,8.59],[63.75,8.82],[65.75,9.25],[71.75,8.93],[85.75,9.43],[87.75,9.05],[95.75,9.2],[97.75,8.67],[99.75,9.07],[112.75,8.78],[120.75,9.03],[128.75,8.67],[144.75,8.94],[152.75,8.73],[168.75,8.79],[176.75,9.28],[192.75,9],[216.75,9.6],[232.75,9.27],[240.75,9.5],[288.75,9.4],[296.75,9.6],[304.75,9.3],[320.75,9.73],[328.75,9.5],[336.75,9.8],[428.75,9.61],[476.75,10.01],[492.75,9.76],[508.75,9.87],[524.75,9.65],[556.75,9.87],[572.75,9.65],[620.75,10.22],[668.75,10.44],[684.75,10.23],[716.75,10.33],[756.75,10.66],[884.75,10.59],[948.75,10.96],[1108.75,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"rr-pic-1925",kind:"nova",designation:"RR Pic",name:"Nova Pictoris 1925",raHours:6.59335,decDeg:-62.64008,peakMagnitude:.95,peakJd:24243085e-1,startJd:24242995e-1,lightCurve:[[0,2.43],[5,2.35],[6,2.1],[7,2.4],[9,.95],[13,1.8],[14,1.7],[16,2.15],[18,2.2],[19,1.9],[23,3.1],[27,3.05],[31.5,3.58],[43.5,3.08],[47.5,3.15],[57.5,2.3],[59.5,1.65],[63.5,3.03],[65.5,2.84],[67.5,3.16],[69.5,2.4],[71.5,2.04],[73.5,2.05],[75.5,2.55],[79.5,3],[83.5,3.15],[116.5,3.54],[120.5,3.78],[124.5,3.67],[136.5,4.18],[148.5,4.34],[154.5,4.17],[194.5,4.43],[226.5,4.93],[234.5,4.8],[242.5,5.4],[250.5,5.5],[266.5,5.15],[298.5,5.6],[362.5,5.4],[414.5,5.7],[430.5,5.5],[494.5,6.2],[718.5,6.52],[830.5,6.3],[862.5,6.6],[878.5,6.4],[910.5,6.77],[958.5,6.67],[1062.5,7.07],[1318.5,7.35],[1590.5,8.12],[1718.5,8.25],[2486.5,8.59],[2614.5,8.47],[2742.5,8.7],[3382.5,8.6],[3766.5,8.97],[4022.5,8.79],[4150.5,9.22],[6710.5,10.29],[7414.5,11.03],[8438.5,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A slow nova, and a southern one: more than two months within two magnitudes of its peak."},{id:"dq-her-1934",kind:"nova",designation:"DQ Her",name:"Nova Herculis 1934",raHours:18.12507,decDeg:45.85906,peakMagnitude:1.56,peakJd:24277935e-1,startJd:242778675e-2,lightCurve:[[0,3.4],[1.5,2.4],[3,2.67],[5.75,2.01],[6.75,1.56],[7.75,1.59],[11.75,2.97],[12.75,2.31],[14.75,3.07],[15.75,2.56],[16.75,2.51],[19.75,2.68],[23.75,2.53],[24.75,2.27],[26.75,2.58],[30.75,2.24],[31.75,2.63],[32.75,2.66],[34.75,2.11],[39.75,2.71],[41.75,2.31],[43.75,2.37],[46.75,3.64],[47.75,3.21],[50.75,3.23],[52.75,2.66],[55.75,2.56],[58.75,2.97],[60.75,2.77],[61.75,3.36],[63.75,3.43],[64.75,2.89],[65.75,3.22],[68.75,3.52],[69.75,2.95],[70.75,3.06],[71.75,2.7],[76.75,3.65],[79.75,3.74],[81.75,3.21],[83.75,3.75],[87.75,3.69],[92.75,4.04],[94.75,4.8],[97.75,4.24],[98.75,4.52],[100.75,4.08],[101.75,4.43],[105.75,4.58],[106.75,4.33],[107.75,4.73],[108.75,6.57],[109.75,8.08],[110.75,8.15],[111.75,8.56],[113.75,8.45],[114.75,9.15],[115.75,9.15],[116.75,9.59],[117.75,9.43],[118.75,9.8],[122.75,10.5],[123.75,10.28],[124.75,10.93],[127.75,10.83],[129.75,11.87],[131.75,12.42],[135.75,12.5],[137.75,12.9],[138.75,12.77],[139.75,13],[143.75,12],[144.75,12.33],[146.75,12.35],[147.75,11.64],[148.75,11.83],[150.75,10.9],[151.75,10.78],[152.75,11.17],[154.75,10.32],[155.75,10.4],[165.25,9.24],[185.25,7.74],[225.25,6.8],[273.25,6.72],[321.25,6.97],[333.25,6.79],[353.25,7],[357.25,6.82],[377.25,6.88],[401.25,7.29],[409.25,6.8],[413.25,6.8],[419.25,7.1],[435.25,7.09],[451.25,7.4],[475.25,7],[555.25,7.48],[823.25,7.83],[855.25,8.18],[1135.25,8.43],[1823.25,9.98],[1887.25,9.71],[2015.25,10.55],[2335.25,10.95]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"Lost about ten magnitudes in a few weeks from April 1935, when dust condensed around it, then came back to naked-eye brightness."},{id:"cp-lac-1936",kind:"nova",designation:"CP Lac",name:"Nova Lacertae 1936",raHours:22.26142,decDeg:55.61703,peakMagnitude:2.02,peakJd:242834025e-2,startJd:242833825e-2,lightCurve:[[0,4.03],[.5,2.9],[1,2.45],[2,2.02],[2.5,2.61],[4,3],[4.5,3.35],[5,3.3],[9.25,4.59],[14.25,5.45],[22.25,6.03],[23.25,6.3],[26.25,6.23],[38.25,6.74],[41.25,6.61],[50.25,7.35],[53.25,7.27],[57.25,7.7],[58.25,7.54],[60.25,7.55],[61.25,7.79],[71.25,7.6],[74.25,7.81],[76.25,8.3],[77.25,7.79],[86.25,8.21],[87.25,8],[88.25,8.25],[92.25,8.17],[94.25,8.47],[102.25,8.27],[103.25,8.7],[104.25,8.4],[110.25,8.66],[116.75,8.55],[122.75,8.83],[126.75,8.7],[140.75,9.06],[154.75,9.01],[164.75,9.36],[170.75,9.18],[174.75,9.48],[186.75,9.42],[188.75,9.73],[192.75,9.53],[200.75,9.74],[202.75,9.5],[204.75,9.77],[208.75,9.6],[214.75,9.75],[216.75,10.05],[222.75,9.7],[232.75,10.03],[236.75,9.82],[250.75,10.1],[254.75,9.9],[260.75,10.1],[264.75,9.8],[266.75,10.15],[268.75,10],[274.75,10.2],[276.75,9.9],[292.75,10.6],[294.75,10.6],[298.75,10.1],[318.75,10.35],[320.75,10.6],[322.75,10.3],[328.75,10.65],[332.75,10.3],[338.75,10.7],[348.75,10.53],[350.75,10.7],[354.75,10.37],[358.75,10.58],[365.75,10.43],[373.75,10.85],[421.75,10.94]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"cp-pup-1942",kind:"nova",designation:"CP Pup",name:"Nova Puppis 1942",raHours:8.19613,decDeg:-35.35139,peakMagnitude:.73,peakJd:243067675e-2,startJd:243067275e-2,lightCurve:[[0,.95],[4,.73],[4.5,1.3],[5.5,1.47],[6,2.01],[7.75,2.88],[8.75,2.97],[10.75,3.5],[11.75,4.02],[13.75,4.4],[14.75,3.8],[17.75,5],[18.75,4.93],[19.75,5.48],[23.75,5.5],[25.75,5.65],[26.75,5.99],[33.25,6.28],[45.25,6.6],[57.25,6.41],[81.25,6.85],[89.25,6.5],[97.25,6.67],[101.25,7],[113.25,6.66],[125.25,7.1],[135.25,6.96],[231.25,7.86],[279.25,7.8],[327.25,8.33],[407.25,8.18],[423.25,8.59],[471.25,8.53],[503.25,8.99],[551.25,8.97],[567.25,8.7],[583.25,9.47],[615.25,8.95],[655.25,9.5],[751.25,9.55],[815.25,10.09],[847.25,10.02],[879.25,10.48],[911.25,10.34],[1023.25,10.79],[1279.25,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"One of the fastest bright novae: two magnitudes gone in four days."},{id:"t-crb-1946",kind:"nova",designation:"T CrB",name:"Nova Coronae Borealis 1946",raHours:15.99171,decDeg:25.92017,peakMagnitude:2.5,peakJd:2431860,startJd:2431860,lightCurve:[[0,2.5],[1.5,3.5],[2.5,3.61],[6.5,5.68],[8.5,6.25],[10.5,7.35],[11.5,7.3],[12.5,8],[16,8.68],[32,9.77],[38,9.7],[40,9.45],[44,9.9],[48,9.57],[54,9.9],[58,9.71],[79,9.94],[107,9.76],[111,9.51],[115,8.71],[119,8.46],[159,8.01],[179,8.07],[183,8.47],[191,8.16],[199,8.7],[207,8.81],[211,9.33],[215,9.15],[223,9.47],[297,9.4],[345,9.75],[377,9.57],[425,9.8],[537,9.8]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A recurrent nova. It erupted in 1866 and in 1946, and a third eruption was expected from 2024 on."},{id:"v446-her-1960",kind:"nova",designation:"V446 Her",name:"Nova Herculis 1960",raHours:18.956,decDeg:13.24147,peakMagnitude:4.83,peakJd:24370038e-1,startJd:24370033e-1,lightCurve:[[0,5.2],[.5,4.83],[2,4.9],[2.5,5.4],[3,5.05],[3.5,5.57],[4,5.25],[5,5.5],[6.5,5.4],[7.2,5.78],[8.2,5.6],[9.2,5.98],[10.2,5.92],[11.2,6.21],[16.2,6.1],[17.2,6.23],[18.2,7.2],[19.2,6.51],[20.2,6.78],[26.2,6.97],[27.2,7.24],[28.2,7.13],[29.2,7.45],[31.2,7.2],[40.7,7.57],[44.7,8.25],[46.7,7.84],[56.7,8.15],[60.7,8.9],[70.7,8.7],[72.7,8.14],[76.7,8.71],[80.7,8.47],[82.7,8.87],[86.7,8.57],[90.7,8.93],[107.7,9.11],[111.7,8.94],[115.7,9.27],[139.7,9.38],[151.7,9.91],[155.7,9.72],[173.7,10.51],[221.7,10.95]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v533-her-1963",kind:"nova",designation:"V533 Her",name:"Nova Herculis 1963",raHours:18.23902,decDeg:41.85614,peakMagnitude:3,peakJd:24380605e-1,startJd:24380565e-1,lightCurve:[[0,8],[4,3],[4.5,3],[8,4],[13,3.95],[15,4.6],[21,4.53],[24,5.05],[27,5.15],[32,4.76],[34,4.98],[35,5.39],[37,5.43],[41,6.04],[49,6.02],[56.5,6.34],[60.5,6.11],[74.5,6.72],[102.5,6.99],[137.5,7.81],[197.5,8.31],[217.5,8.8],[225.5,8.57],[233.5,9.03],[237.5,8.78],[277.5,9.44],[301.5,9.46],[315.5,9.86],[323.5,9.73],[339.5,10.05],[355.5,10.74],[363.5,10.32],[371.5,10.6],[387.5,10.69],[427.5,10.38],[435.5,10.84],[443.5,10.74],[451.5,11.33],[459.5,10.98],[467.5,11.17],[507.5,11.16],[539.5,11.66],[603.5,11.7],[619.5,12.05],[651.5,12.03],[659.5,11.74],[667.5,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"hr-del-1967",kind:"nova",designation:"HR Del",name:"Nova Delphini 1967",raHours:20.70565,decDeg:19.16092,peakMagnitude:3.58,peakJd:2439838,startJd:2439646,lightCurve:[[0,11.9],[6,11.8],[12,8.8],[16,8.3],[20,6.7],[30,5.8],[36,5.51],[66,5.55],[78,5.35],[86,4.89],[96,5],[108,4.75],[136,5.13],[152,4.83],[182,4.93],[186,4.59],[192,3.58],[202,5],[220,5.46],[226,5.14],[230,5.45],[232,5.14],[236,5],[242,5.08],[244,4.59],[246,4.45],[254,5.3],[256,4.75],[260,5.69],[268,4.8],[274,4.94],[276,5.45],[280,5.2],[282,5.51],[286,5.58],[292,4.95],[294,5.16],[298,4.94],[311,5.09],[335,4.4],[367,5.76],[407,6.16],[423,6.55],[603,7.43],[907,8.32],[1451,9.41],[2347,10.75]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"An exceptionally slow nova: rose over months and stayed near magnitude 4 to 5 for most of 1967 and 1968."},{id:"lv-vul-1968",kind:"nova",designation:"LV Vul",name:"Nova Vulpeculae 1968",raHours:19.80012,decDeg:27.1715,peakMagnitude:4.5,peakJd:243996425e-2,startJd:243996325e-2,lightCurve:[[0,5],[1,4.5],[2,5],[2.5,4.86],[3,5.1],[3.5,4.88],[4,5.1],[5,4.9],[7,5.4],[8,5.23],[10.5,5.42],[12,5.82],[13,5.4],[13.5,5.74],[14,5.7],[14.5,6.08],[15,5.75],[15.5,5.86],[16,5.6],[17,5.8],[18,5.6],[20.5,6.34],[21,6.2],[22.5,6.84],[23,6.57],[24,6.98],[24.5,6.3],[25,7.1],[26,6.65],[34.25,7.48],[35.25,7.23],[39.25,7.32],[44.25,7.76],[45.25,7.49],[46.25,7.78],[50.25,7.84],[51.25,8.1],[53.25,7.9],[54.25,8.13],[56.25,8],[57.75,8.24],[67.75,8.52],[75.75,8.38],[83.75,8.69],[89.75,8.59],[125.75,9.32],[127.75,9.33],[129.75,8.98],[131.75,9.29],[135.75,9.43],[212.75,9.9],[220.75,10.16],[228.75,10.03],[236.75,10.3],[244.75,10.16],[264.75,10.54],[280.75,10.45],[296.75,10.79],[328.75,10.78]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"fh-ser-1970",kind:"nova",designation:"FH Ser",name:"Nova Serpentis 1970",raHours:18.51307,decDeg:2.61444,peakMagnitude:4.5,peakJd:244063425e-2,startJd:244063125e-2,lightCurve:[[0,7],[2,5],[3,4.5],[3.5,5],[4.5,4.6],[5.5,5],[6.5,4.68],[12.25,4.66],[16.25,5.3],[17.25,5.72],[18.25,5.3],[19.25,5.2],[23.25,5.84],[24.25,5.68],[27.25,5.9],[30.25,5.47],[32.25,5.9],[34.25,5.7],[43.25,6.28],[45.25,6.1],[50.25,6.62],[52.25,6.47],[57.25,6.63],[60.25,7.08],[61.25,6.87],[62.25,7.2],[63.25,6.85],[64.25,7.68],[65.25,7.3],[66.25,8.3],[67.25,7.93],[69.25,9.15],[71.25,9.2],[72.25,9.63],[74.25,9.9],[76.25,9.7],[77.25,10.25],[78.25,10.1],[79.25,10.4],[80.25,10.23],[81.25,10.57],[83.25,10.64],[85.25,10.35],[86.25,11.2],[87.25,10.1],[89.25,11.2],[96.25,11.35],[100.25,11.95],[102.25,11.1],[104.25,11.65],[106.25,11.5],[108.25,12.07],[114.75,11.32],[118.75,11.28],[122.75,10.93],[130.75,10.85],[134.75,10.52],[154.75,10.65],[162.75,10.12],[174.75,9.98],[178.75,10.34],[186.75,9.98],[214.75,10.25],[224.75,10.02],[240.75,10.2],[264.75,10],[272.75,10.2],[280.75,10.05],[288.75,10.4],[296.75,10],[348.75,10.7],[396.75,10.3],[444.75,10.73],[460.75,10.59],[540.75,10.94],[556.75,10.82]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v1500-cyg-1975",kind:"nova",designation:"V1500 Cyg",name:"Nova Cygni 1975",raHours:21.19349,decDeg:48.15056,peakMagnitude:1.88,peakJd:244265525e-2,startJd:244265425e-2,lightCurve:[[0,2.44],[1,1.88],[1.5,1.88],[2.5,2.41],[3,3.38],[4,4.28],[8.25,5.81],[11.25,6.46],[22.25,7.35],[33.25,7.73],[34.25,7.97],[37.25,7.86],[40.25,8.3],[43.25,8.19],[48.25,8.6],[49.25,8.46],[66.25,9.04],[70.25,8.93],[75.25,9.23],[76.25,9.03],[80.25,9.39],[81.25,9.19],[83.25,9.35],[84.25,9.13],[86.25,9.39],[89.25,9.32],[90.25,9.54],[93.25,9.37],[105.75,9.86],[193.75,10.43],[201.75,10.7],[209.75,10.47],[257.75,10.94],[265.75,10.81]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"One of the fastest novae on record: discovered on 29 August 1975, at its peak of magnitude 1.9 within two days, and two magnitudes down again two days later."},{id:"v842-cen-1986",kind:"nova",designation:"V842 Cen",name:"Nova Centauri 1986",raHours:14.59794,decDeg:-57.6265,peakMagnitude:4.9,peakJd:244675975e-2,startJd:244675725e-2,lightCurve:[[0,5.6],[2.5,4.9],[3.5,5.1],[15.5,5.1],[17.5,5.75],[18.5,5.4],[20.5,5.5],[22.5,5.95],[30.5,6.15],[31.5,6.3],[32,7.5],[34.5,7.2],[38.5,7.5],[39,7],[41.5,7.15],[42.5,6.7],[44.5,7.23],[45.5,6.6],[53,9.3]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"sn-1987a",kind:"supernova",designation:"SN 1987A",name:"Supernova 1987A",raHours:5.59111,decDeg:-69.26975,peakMagnitude:2.98,peakJd:24469425e-1,startJd:24468495e-1,lightCurve:[[0,6.36],[1,6.11],[2,4.63],[4,4.45],[32,3.97],[56,3.15],[93,2.98],[105,3.35],[118,4.11],[134,4.43],[504,8.15],[617,10.27]],source:"V photometry compiled by the Open Supernova Catalog (Sternberg catalogue, IAU circulars, CTIO)",note:"In the Large Magellanic Cloud, 160 000 light years away: the nearest supernova since Kepler's, and invisible north of about 20° N."},{id:"v1974-cyg-1992",kind:"nova",designation:"V1974 Cyg",name:"Nova Cygni 1992",raHours:20.50879,decDeg:52.63078,peakMagnitude:4.27,peakJd:24486753e-1,startJd:24486718e-1,lightCurve:[[0,7.2],[1,5.23],[2,4.62],[3.5,4.27],[4.5,4.59],[6,4.5],[7,4.78],[7.5,4.52],[8,4.82],[10.7,5.25],[11.7,5.66],[16.7,5.85],[21.7,6.47],[22.7,6.3],[27.7,6.46],[29.7,6.83],[34.7,6.9],[35.7,7.25],[36.7,7],[37.7,7.16],[39.7,7.03],[43.7,7.41],[45.7,7.26],[50.7,7.45],[57.7,7.78],[58.7,8.13],[61.7,7.92],[64.7,8.19],[65.7,7.99],[71.7,8.22],[76.7,8.01],[128.2,8.72],[176.2,8.89],[192.2,9.15],[216.2,9.28],[232.2,9.07],[236.2,9.3],[390.2,10.99]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v382-vel-1999",kind:"nova",designation:"V382 Vel",name:"Nova Velorum 1999",raHours:10.74678,decDeg:-52.42533,peakMagnitude:2.88,peakJd:245132225e-2,startJd:245132075e-2,lightCurve:[[0,2.99],[1.5,2.88],[2.5,3.46],[4.5,3.98],[5,4.32],[5.5,4.23],[7.5,4.85],[21.75,6.67],[30.25,7.2],[40.25,7.41],[93.25,7.95],[97.25,8.25],[101.25,8],[113.25,7.96],[129.25,8.5],[155.25,8.47],[163.25,9.1],[179.25,9],[187.25,8.7],[195.25,9.15],[211.25,9.23],[235.25,9.8],[243.25,9.71],[299.25,10.42],[383.25,10.52],[415.25,10.81]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v1494-aql-1999",kind:"nova",designation:"V1494 Aql",name:"Nova Aquilae 1999",raHours:19.38482,decDeg:4.9555,peakMagnitude:4.11,peakJd:245151575e-2,startJd:245151425e-2,lightCurve:[[0,5.15],[.5,4.86],[1,4.27],[1.5,4.11],[2.5,4.35],[5,5.48],[10.5,6.26],[14.25,6.28],[20.25,7.43],[24.25,7.25],[25.25,7.63],[27.25,7.7],[29.25,7.42],[33.25,8.08],[35.25,8.03],[36.25,7.6],[37.25,7.6],[46.25,8.5],[54.25,8.28],[56.25,8.63],[58.25,8.4],[61.25,9.53],[62.25,9],[64.25,9.13],[69.25,8.58],[70.25,8.9],[72.25,8.88],[75.25,8.57],[77.25,9],[79.25,8.8],[81.25,9.7],[83.25,9.6],[85.25,9.8],[86.75,9.5],[88.75,9.54],[90.75,8.9],[92.75,8.85],[96.75,9.63],[102.75,9.7],[104.75,8.98],[106.75,8.73],[116.75,9.63],[118.75,9.6],[120.75,9.07],[122.75,9.26],[124.75,9.8],[128.75,9.36],[134.75,9.75],[147.75,9.92],[155.75,9.81],[259.75,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v4743-sgr-2002",kind:"nova",designation:"V4743 Sgr",name:"Nova Sagittarii 2002",raHours:19.01926,decDeg:-22.00167,peakMagnitude:5,peakJd:245253775e-2,startJd:245253675e-2,lightCurve:[[0,5.2],[1,5],[2,5.89],[2.5,5.91],[3.5,6.43],[5,6.45],[5.5,6.86],[6,6.59],[7,6.77],[7.5,7.31],[8.5,6.99],[9,7.09],[10.5,7.86],[11,7.58],[11.5,7.89],[15.75,8.33],[17.75,8.18],[18.75,8.58],[19.75,8.44],[22.75,8.83],[23.75,8.6],[24.75,8.85],[27.75,8.83],[30.75,9.4],[31.75,9.09],[36.25,9.08],[38.25,9.34],[62.25,9.75],[66.25,10.1],[70.25,9.7],[74.25,10],[171.25,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"rs-oph-2006",kind:"nova",designation:"RS Oph",name:"Nova Ophiuchi 2006",raHours:17.83699,decDeg:-6.70792,peakMagnitude:4.8,peakJd:2453779,startJd:2453779,lightCurve:[[0,4.8],[1.25,4.97],[2.75,5.78],[3.25,5.7],[3.75,6.24],[4.25,6.05],[4.75,6.38],[5.25,6.3],[8.5,7.25],[14.5,7.95],[24.5,8.55],[29.5,9.08],[48,9.87],[80,10.28],[107,11.54],[119,11.54],[139,11.98],[147,11.83],[163,12.03],[171,11.97],[175,11.65],[183,11.84],[195,11.64],[203,11.8],[207,12.13],[219,11.45],[277,11.68],[325,11],[341,11.53],[357,11.62],[373,11.3],[405,11.5],[421,11.17],[469,10.96],[501,11.22],[549,10.75],[581,11.08],[597,10.98]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A recurrent nova, erupting every twenty years or so (1898, 1907, 1933, 1945, 1958, 1967, 1985, 2006, 2021)."},{id:"v1280-sco-2007",kind:"nova",designation:"V1280 Sco",name:"Nova Scorpii 2007",raHours:16.96145,decDeg:-32.34325,peakMagnitude:3.8,peakJd:2454149,startJd:2454136,lightCurve:[[0,9.7],[13,3.8],[34,5.8],[103,15]],source:"AAVSO (discovery, peak, dust minimum); t2 from Das et al. 2008",note:"Faded from sight quickly when dust formed around it, three weeks after its peak."},{id:"v339-del-2013",kind:"nova",designation:"V339 Del",name:"Nova Delphini 2013",raHours:20.39186,decDeg:20.76772,peakMagnitude:4.4,peakJd:24565214e-1,startJd:24565214e-1,lightCurve:[[0,4.4],[11,6.4],[20,7.4]],source:"Gehrz et al. 2015 (peak, t2, t3)",note:"High in the summer evening sky of the northern hemisphere, and widely photographed."},{id:"v1369-cen-2013",kind:"nova",designation:"V1369 Cen",name:"Nova Centauri 2013",raHours:13.9126,decDeg:-59.15114,peakMagnitude:3.48,peakJd:245663965e-2,startJd:24566285e-1,lightCurve:[[0,5.33],[1.57,4.08],[2.75,3.73],[4.57,4.16],[5.96,4.15],[10.26,3.77],[11.15,3.48],[12.14,3.74],[14.17,4.78],[15.46,4.97],[23.16,4.22],[26.25,4.32],[27.31,4.82],[29.56,5.11],[32.66,4.71],[33.84,4.86],[36.05,4.46],[37.15,4.99],[41.42,4.59],[42.37,4.93],[43.37,4.82],[44.54,5.09],[49.95,5.38],[51.99,5.82],[54.21,5.77]],source:"AAVSO, binned by day, as plotted by Izzo 2017 (arXiv:1704.07214, figure 1)",note:"Discovered on 2 December 2013 by John Seach at magnitude 5.5, it flared several times, reaching about 3.3 around 14 December: the brightest nova of the century so far, and a southern one."},{id:"rs-oph-2021",kind:"nova",designation:"RS Oph",name:"Nova Ophiuchi 2021",raHours:17.83699,decDeg:-6.70792,peakMagnitude:4.6,peakJd:2459436,startJd:2459435,lightCurve:[[0,5],[1,4.6],[2.25,4.77],[3.75,5.58],[4.25,5.5],[4.75,6.04],[5.25,5.85],[5.75,6.18],[6.25,6.1],[9.5,7.05],[15.5,7.75],[25.5,8.35],[30.5,8.88],[49,9.67],[81,10.08],[108,11.34],[120,11.34],[140,11.78],[148,11.63],[164,11.83],[172,11.77],[176,11.45],[184,11.64],[196,11.44],[204,11.6],[208,11.93],[220,11.25],[278,11.48],[326,10.8],[342,11.33],[358,11.42],[374,11.1],[406,11.3],[422,10.97],[470,10.76],[502,11.02],[550,10.55],[582,10.88],[598,10.78]],source:"Recorded discovery and peak (8 and 9 August 2021); curve borrowed from its 2006 eruption",note:"RS Oph's latest eruption, discovered on 8 August 2021. The decline is its 2006 one."}];class Km{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(t){const e=this.julianDayOf(t);return Mu.filter(i=>this.magnitudeAt(i,e)!==void 0)}static appearancesAt(t,e){const i=this.julianDayOf(t),n=[];for(const s of Mu){const a=this.magnitudeAt(s,i);a!==void 0&&n.push({outburst:s,position:Pn.ofJ2000(s.raHours,s.decDeg,t,e),magnitude:a})}return n.sort((s,a)=>s.magnitude-a.magnitude)}static brightestAt(t,e){return this.appearancesAt(t,e)[0]}static byId(t){return Mu.find(e=>e.id===t)}static magnitudeAt(t,e){const i=t.lightCurve,n=e-t.startJd;if(i.length===0||n<i[0][0]||n>i[i.length-1][0])return;let s=1;for(;s<i.length-1&&i[s][0]<n;)s++;const[a,o]=i[s-1]??i[0],[c,l]=i[s]??i[0];if(c===a)return o;const h=Math.min(1,Math.max(0,(n-a)/(c-a)));return o+h*(l-o)}static julianDayOf(t){return t.getTime()/864e5+this.UNIX_EPOCH_JD}}const NE=[{id:"quadrantids",code:"QUA",name:"Quadrantids",radiantRaHours:15.33,radiantDecDeg:49.7,start:{month:12,day:28},peak:{month:1,day:3},end:{month:1,day:12},peakZhr:110,velocityKmS:41,populationIndex:2.1},{id:"lyrids",code:"LYR",name:"April Lyrids",radiantRaHours:18.13,radiantDecDeg:33.3,start:{month:4,day:16},peak:{month:4,day:22},end:{month:4,day:25},peakZhr:18,velocityKmS:49,populationIndex:2.1},{id:"eta-aquariids",code:"ETA",name:"eta Aquariids",radiantRaHours:22.53,radiantDecDeg:-1,start:{month:4,day:19},peak:{month:5,day:6},end:{month:5,day:28},peakZhr:50,velocityKmS:66,populationIndex:2.4},{id:"alpha-capricornids",code:"CAP",name:"alpha Capricornids",radiantRaHours:20.47,radiantDecDeg:-9.2,start:{month:7,day:3},peak:{month:7,day:30},end:{month:8,day:15},peakZhr:5,velocityKmS:23,populationIndex:2.5},{id:"southern-delta-aquariids",code:"SDA",name:"Southern delta Aquariids",radiantRaHours:22.67,radiantDecDeg:-16.4,start:{month:7,day:12},peak:{month:7,day:30},end:{month:8,day:23},peakZhr:25,velocityKmS:41,populationIndex:3.2},{id:"perseids",code:"PER",name:"Perseids",radiantRaHours:3.22,radiantDecDeg:58,start:{month:7,day:17},peak:{month:8,day:12},end:{month:8,day:24},peakZhr:100,velocityKmS:59,populationIndex:2.2},{id:"southern-taurids",code:"STA",name:"Southern Taurids",radiantRaHours:3.47,radiantDecDeg:13,start:{month:9,day:10},peak:{month:10,day:10},end:{month:11,day:20},peakZhr:5,velocityKmS:27,populationIndex:2.3},{id:"draconids",code:"DRA",name:"October Draconids",radiantRaHours:17.47,radiantDecDeg:54,start:{month:10,day:6},peak:{month:10,day:8},end:{month:10,day:10},peakZhr:10,velocityKmS:20,populationIndex:2.6},{id:"orionids",code:"ORI",name:"Orionids",radiantRaHours:6.35,radiantDecDeg:15.6,start:{month:10,day:2},peak:{month:10,day:21},end:{month:11,day:7},peakZhr:20,velocityKmS:66,populationIndex:2.5},{id:"northern-taurids",code:"NTA",name:"Northern Taurids",radiantRaHours:3.87,radiantDecDeg:22,start:{month:10,day:20},peak:{month:11,day:12},end:{month:12,day:10},peakZhr:5,velocityKmS:29,populationIndex:2.3},{id:"leonids",code:"LEO",name:"Leonids",radiantRaHours:10.13,radiantDecDeg:21.6,start:{month:11,day:6},peak:{month:11,day:17},end:{month:11,day:30},peakZhr:15,velocityKmS:71,populationIndex:2.5},{id:"geminids",code:"GEM",name:"Geminids",radiantRaHours:7.47,radiantDecDeg:32.3,start:{month:12,day:4},peak:{month:12,day:14},end:{month:12,day:17},peakZhr:150,velocityKmS:35,populationIndex:2.6},{id:"ursids",code:"URS",name:"Ursids",radiantRaHours:14.47,radiantDecDeg:75.3,start:{month:12,day:17},peak:{month:12,day:22},end:{month:12,day:26},peakZhr:10,velocityKmS:33,populationIndex:3}],Fl=6.5;class xu{static activeAt(t){return NE.flatMap(e=>{const i=this.nearness(e,t);return i<=0?[]:[{shower:e,zhr:e.peakZhr*i,nearness:i}]})}static nearness(t,e){const i=this.dayOfYear(e),n=this.dayOfYear(this.asDate(t.start)),s=this.dayOfYear(this.asDate(t.peak)),a=this.dayOfYear(this.asDate(t.end)),o=this.wrappedDelta(i,s),c=this.wrappedDelta(s,n),l=this.wrappedDelta(a,s);return o<0?o<-c?0:1+o/c:o>0?o>l?0:1-o/l:1}static observedRatePerHour(t,e,i,n=Fl){if(e<=0)return 0;const s=Fl-n;return t*Math.sin(e*Math.PI/180)/Math.pow(i,s)}static radiantPosition(t,e,i){return Pn.ofJ2000(t.radiantRaHours,t.radiantDecDeg,e,i)}static dayOfYear(t){const e=Date.UTC(t.getUTCFullYear(),0,1);return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-e)/864e5)+1}static asDate(t){return new Date(Date.UTC(2001,t.month-1,t.day))}static wrappedDelta(t,e){const i=t-e;return i>182?i-365:i<-182?i+365:i}}class ti{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const i=$e(t),n=new Kl(0,s5(t).elon-90,1),s=Ir(D5(i),N0(n,i)),a=F0(s);return U0(a.ra,a.dec,t,e)}static observedRatePerHour(t,e=Fl){const i=ti.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),n=Fl-e;return(ti.QUIET_RATE_PER_HOUR+i)/Math.pow(ti.POPULATION_INDEX,n)}static schedule(t){const e=new jl(t.seed^1542469173);return Ca.schedule(t).map(i=>{const n=ti.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),s=i.fromRadiantDeg*Math.PI/180,a=ti.turnAround(n,e.between(0,360)),o={x:n.x*Math.cos(s)+a.x*Math.sin(s),y:n.y*Math.cos(s)+a.y*Math.sin(s),z:n.z*Math.cos(s)+a.z*Math.sin(s)};return{...i,radiant:ti.toHorizontal(o),bearingDeg:ti.bearingFrom(o,n)}})}static turnAround(t,e){const[i,n]=ti.basisAround(t),s=e*Math.PI/180;return{x:i.x*Math.cos(s)+n.x*Math.sin(s),y:i.y*Math.cos(s)+n.y*Math.sin(s),z:i.z*Math.cos(s)+n.z*Math.sin(s)}}static bearingFrom(t,e){const[i,n]=ti.basisAround(t),s=t.x*e.x+t.y*e.y+t.z*e.z,a=ti.normalise({x:e.x-t.x*s,y:e.y-t.y*s,z:e.z-t.z*s});return(Math.atan2(a.x*n.x+a.y*n.y+a.z*n.z,a.x*i.x+a.y*i.y+a.z*i.z)*180/Math.PI%360+360)%360}static basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=ti.normalise(ti.cross(t,e));return[i,ti.normalise(ti.cross(t,i))]}static toHorizontal(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,t.y/e)))*180/Math.PI,azimuthDeg:(Math.atan2(t.x,-t.z)*180/Math.PI%360+360)%360}}static appearanceOf(t){const e=ti.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),i=ti.turnAround(e,t.bearingDeg),n=t.fromRadiantDeg*Math.PI/180;return ti.toHorizontal({x:e.x*Math.cos(n)+i.x*Math.sin(n),y:e.y*Math.cos(n)+i.y*Math.sin(n),z:e.z*Math.cos(n)+i.z*Math.sin(n)})}static toCartesian(t){const e=t.altitudeDeg*Math.PI/180,i=t.azimuthDeg*Math.PI/180,n=Math.cos(e);return{x:n*Math.sin(i),y:Math.sin(e),z:-n*Math.cos(i)}}static cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}static normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}static TYPICAL_VELOCITY_KM_S=40}const Zm="https://ufoathome.org/tle/index.json";class Ii{static MAX_ELEMENT_AGE_DAYS=7;static DAY_MS=864e5;fetchImpl;indexUrls;index;files=new Map;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Ii.defaultIndexUrls()}static defaultIndexUrls(){const t=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&t.push(new URL("/tle/index.json",location.href).href),t.includes(Zm)||t.push(Zm),t}static FIRST_SNAPSHOT="2021-02-22";async covers(t){const e=Date.parse(`${Ii.FIRST_SNAPSHOT}T00:00:00Z`)-Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS;if(t.getTime()<e)return!1;const i=await this.loadIndex();return i?Object.values(i.index.kinds).some(n=>t.getTime()>=Date.parse(n.from)-Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS&&t.getTime()<=Date.parse(n.to)+Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS):!1}async at(t){const e=await this.loadIndex();if(!e)return;const{index:i,base:n}=e,s=[],a=[];for(const o of Object.keys(i.kinds)){const c=await this.kindAt(o,t,i,n);s.push(...c),a.push(this.coverageOf(o,t,i,c.length>0))}return{objects:s,coverage:a,credit:i.credit,creditUrl:i.source}}async kindAt(t,e,i,n){const s=e.getTime(),a=i.binDays*Ii.DAY_MS,o=Math.floor(s/a),c=s-o*a<a/2?o-1:o+1,l=new Set(i.kinds[t].bins),h=[o,c].map(v=>new Date(v*a).toISOString().slice(0,10)).filter(v=>l.has(v));if(h.length===0)return[];const[u,...d]=await Promise.all([this.json(new URL(`objects-${t}.json`,n).href),...h.map(v=>this.binary(new URL(`${t}/${v}.bin`,n).href))]),f=new Map;for(const v of d)for(const m of Ii.decode(v,i.recordBytes)){const g=f.get(m.norad);(!g||Math.abs(m.epochMs-s)<Math.abs(g.epochMs-s))&&f.set(m.norad,m)}const p=[];for(const v of f.values()){const m=Math.abs(v.epochMs-s)/Ii.DAY_MS;if(m>Ii.MAX_ELEMENT_AGE_DAYS)continue;const g=u[v.norad]??{name:String(v.norad)};g.launch&&Date.parse(`${g.launch}T00:00:00Z`)>s||p.push({norad:v.norad,name:g.name,kind:t,launch:g.launch,stdMag:g.stdMag,elements:v,ageDays:m})}return p}coverageOf(t,e,i,n){const{from:s,to:a}=i.kinds[t],o=e.getTime(),c=Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS,l=n?"covered":o<Date.parse(s)-c?"before":o>Date.parse(a)+c?"after":"gap";return{kind:t,status:l,from:s,to:a}}static decode(t,e){const i=new DataView(t),n=[];for(let s=0;s+e<=t.byteLength;s+=e)n.push({norad:i.getUint32(s,!0),epochMs:i.getFloat64(s+4,!0),bstar:i.getFloat32(s+12,!0),inclinationDeg:i.getFloat32(s+16,!0),raanDeg:i.getFloat32(s+20,!0),eccentricity:i.getFloat32(s+24,!0),argOfPerigeeDeg:i.getFloat32(s+28,!0),meanAnomalyDeg:i.getFloat32(s+32,!0),meanMotion:i.getFloat64(s+36,!0)});return n}loadIndex(){return this.index??=(async()=>{for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;return{index:await e.json(),base:t}}catch{}})(),this.index}json(t){return this.cached(t,async e=>e.json())}binary(t){return this.cached(t,async e=>e.arrayBuffer())}cached(t,e){let i=this.files.get(t);return i||(i=this.fetchImpl(t).then(n=>{if(!n.ok)throw new Error(`${t}: ${n.status}`);return e(n)}),i.catch(()=>this.files.delete(t)),this.files.set(t,i)),i}}class FE{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const i=Te.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(e.inFrontM!==void 0){const i=Te.sizeMAt(e.inFrontM,t);this.upperM=this.upperM===void 0?i:Math.min(this.upperM,i)}}}get sizeRange(){return{minM:this.lowerM,maxM:this.upperM}}get empty(){return this.lowerM===void 0&&this.upperM===void 0}get contradictory(){return this.lowerM!==void 0&&this.upperM!==void 0&&this.lowerM>this.upperM}distanceRangeAt(t){return t<=0?{}:{minM:this.lowerM===void 0?void 0:Te.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:Te.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class La{static DEG_PER_SECOND=360/86164.0905;static degOver(t){return Math.max(0,t)*La.DEG_PER_SECOND}static instants(t,e){if(!(e>0))return 1;const i=La.degOver(t)/e;return i<1?1:Math.min(La.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class zi{static EYE={apertureMm:7,exposureSeconds:.1,resolutionArcsec:60};static WAVELENGTH_M=55e-8;static ARCSEC_PER_RADIAN=180*3600/Math.PI;static UNKNOWN_CAMERA_FOCAL_MM=50;static UNKNOWN_CAMERA_DETAIL_UM=20;static get skyDriftArcsecPerSecond(){return La.DEG_PER_SECOND*3600}static graspOf(t,e={}){const i=e.exposureSeconds??t.exposureSeconds,n=e.fNumber??t.fNumber;if(i===void 0||n===void 0||!(i>0)||!(n>0))return zi.EYE;const s=e.focalLengthMm??t.frame?.focalLengthMm??zi.UNKNOWN_CAMERA_FOCAL_MM,a=s/n,o=zi.resolutionArcsec(t,s,a);return{apertureMm:a,exposureSeconds:Math.min(i,zi.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(t,e,i){const s=(t.detailUm??zi.UNKNOWN_CAMERA_DETAIL_UM)/1e3/e*zi.ARCSEC_PER_RADIAN,a=1.22*zi.WAVELENGTH_M/(i/1e3)*zi.ARCSEC_PER_RADIAN;return Math.max(s,a)}static trailLimitedSeconds(t){return t/zi.skyDriftArcsecPerSecond}static gainOverEye(t,e={}){const i=zi.graspOf(t,e),n=zi.EYE,s=(i.apertureMm/n.apertureMm)**2,a=i.exposureSeconds/n.exposureSeconds,o=(n.resolutionArcsec/i.resolutionArcsec)**2;return 1.25*Math.log10(s*a*o)}static gainFor(t,e){const i=e.fieldOfViewDeg===void 0?void 0:fi.focalLengthMmFor(t,e.fieldOfViewDeg);return zi.gainOverEye(t,{fNumber:e.fNumber,focalLengthMm:i,exposureSeconds:e.exposureSeconds})}}const Jm=111320,fo=Math.PI/180,UE=1.02,kE=1;class Do{static of(t,e){const i=Do.sightings(t,e);if(i.length<2)return;const n=Do.baseline(i);if(!n)return;const{near:s,far:a,closedM:o}=n,c=Math.tan(a.widthDeg/2*fo)===0?0:Math.tan(s.widthDeg/2*fo)/Math.tan(a.widthDeg/2*fo);if(c<UE)return;const l=o/(c-1),h=Te.sizeMAt(l,s.widthDeg),u=i.map(d=>({t:d.t,m:Te.distanceMAt(h,d.widthDeg)}));return{widthM:h,distanceM:u,nearestM:Math.min(...u.map(d=>d.m)),fromT:a.t,toT:s.t,closedM:o}}static sightings(t,e){return t.timeline.allKeyframes.flatMap(i=>{const n=i.shapes.find(o=>o.sourceId===e)?.shape,s=n?.angular?.widthDeg,a=di(t,i.t);return s===void 0||s<=0||a?.lat===void 0||a.lng===void 0?[]:[{t:i.t,widthDeg:s,lat:a.lat,lng:a.lng,sightAzimuthDeg:n?.aim?.azimuthDeg??a.headingDeg}]}).sort((i,n)=>i.t-n.t)}static baseline(t){let e;for(const i of t)for(const n of t){if(i.t>=n.t)continue;const s=Do.closedAlongSight(i,n),[a,o,c]=s>=0?[n,i,s]:[i,n,-s];c<kE||a.widthDeg<=o.widthDeg||(!e||c>e.closedM)&&(e={near:a,far:o,closedM:c})}return e}static closedAlongSight(t,e){const i=(e.lat-t.lat)*Jm,n=(e.lng-t.lng)*Jm*Math.cos(t.lat*fo),s=(t.sightAzimuthDeg??0)*fo;return i*Math.cos(s)+n*Math.sin(s)}}class ki{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(t){if(t.statedM!==void 0&&t.statedM>0)return{distanceM:ki.atLeastNearest(t.statedM),basis:"stated"};if(t.hypothesisM!==void 0&&t.hypothesisM>0)return{distanceM:ki.atLeastNearest(t.hypothesisM),basis:"hypothesis"};if(t.derivedM!==void 0&&t.derivedM>0)return{distanceM:ki.atLeastNearest(t.derivedM),basis:"derived"};const e=ki.largest(t.range?.minM,t.crossing?.behindM),i=ki.smallest(t.range?.maxM,t.crossing?.inFrontM),n=e===void 0?void 0:e*ki.MARGIN,s=i===void 0?void 0:i/ki.MARGIN;return n!==void 0&&s!==void 0?{distanceM:ki.atLeastNearest(n<=s?Math.sqrt(n*s):n),basis:"bounded"}:n!==void 0?{distanceM:ki.atLeastNearest(n),basis:"bounded"}:s!==void 0&&s<ki.CONVENTIONAL_M?{distanceM:ki.atLeastNearest(s),basis:"bounded"}:{distanceM:ki.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(t){return Math.max(ki.NEAREST_M,t)}static largest(...t){const e=t.filter(i=>i!==void 0&&i>0);return e.length===0?void 0:Math.max(...e)}static smallest(...t){const e=t.filter(i=>i!==void 0&&i>0);return e.length===0?void 0:Math.min(...e)}}const yu=Math.PI/180;class Qt{constructor(t,e,i){this.body=t,this.ground=e;const n=[...t.track].sort((s,a)=>s.t-a.t);this.keys=this.place(n,i);for(const s of n)Qt.collect(this.motionKeys,s.t,s.motions),Qt.collect(this.lightKeys,s.t,s.lights)}static EYE_HEIGHT_M=1.6;static MAX_RANGE_M=3e4;static DEFAULT_SIZE={widthM:1,lengthM:1,heightM:1};static DEFAULT_APPEARANCE={color:"#c8c8c8",albedo:.5,luminanceCdM2:0};keys;motionKeys=new Map;lightKeys=new Map;static collect(t,e,i){for(const[n,s]of Object.entries(i??{})){const a=t.get(n)??[];a.push({t:e,value:s}),t.set(n,a)}}motionsAt(t){return Qt.channelsAt(this.motionKeys,t,0)}lightsAt(t){return this.lightKeys.size>0?Qt.channelsAt(this.lightKeys,t,void 0):void 0}static channelsAt(t,e,i){const n={};for(const[s,a]of t){let o=a.length-1;for(;o>=0&&a[o].t>e;)o--;if(o<0){i!==void 0&&(n[s]=i);continue}const c=a[o],l=a[Math.min(o+1,a.length-1)],h=l===c||l.t===c.t?0:Math.min(1,(e-c.t)/(l.t-c.t));n[s]=Qt.lerp(c.value,l.value,h)}return n}static eyeOf(t,e,i){const n=di(t,0),s=di(t,e),o=n?.lat!==void 0&&n.lng!==void 0&&s?.lat!==void 0&&s.lng!==void 0?ai(s.lat,s.lng,n.lat,n.lng):void 0,c=o?o.x:0,l=o?-o.z:0;return{eastM:c,northM:l,upM:i.heightAt(c,l)+Qt.EYE_HEIGHT_M+(s?.elevationM??0),headingDeg:s?.headingDeg}}static lineOfSightMeetsGround(t,e,i,n){const s=Qt.directionOf(e,i),a=l=>t.upM+s.upM*l-n.heightAt(t.eastM+s.eastM*l,t.northM+s.northM*l);let o=0,c=0;for(;c<Qt.MAX_RANGE_M;){if(c=o+Math.max(.5,o*.01),a(c)<=0){for(let l=0;l<30;l++){const h=(o+c)/2;a(h)<=0?c=h:o=h}return c}o=c}}static directionOf(t,e){const i=t*yu,n=e*yu;return{eastM:Math.sin(i)*Math.cos(n),northM:Math.cos(i)*Math.cos(n),upM:Math.sin(n)}}at(t){const e=this.keys;if(e.length===0||t<e[0].t)return;let i=e.length-1;for(;i>0&&e[i].t>t;)i--;const n=e[i];if(!n.present)return;const s=e[Math.min(i+1,e.length-1)],a=s===n||s.t===n.t?0:Math.min(1,(t-n.t)/(s.t-n.t)),o=Qt.lerp(n.eastM,s.eastM,a),c=Qt.lerp(n.northM,s.northM,a),l={widthM:Qt.lerp(n.sizeM.widthM,s.sizeM.widthM,a),lengthM:Qt.lerp(n.sizeM.lengthM,s.sizeM.lengthM,a),heightM:Qt.lerp(n.sizeM.heightM,s.sizeM.heightM,a)},h={headingDeg:Qt.lerpAngle(n.attitude.headingDeg,s.attitude.headingDeg,a),pitchDeg:Qt.lerp(n.attitude.pitchDeg,s.attitude.pitchDeg,a),rollDeg:Qt.lerp(n.attitude.rollDeg,s.attitude.rollDeg,a)};let u;if("aboveGroundM"in n.vertical&&"aboveGroundM"in s.vertical){const d=Qt.lerp(n.vertical.aboveGroundM,s.vertical.aboveGroundM,a);u=this.groundUnderFootprint(o,c,l,h.headingDeg)+d+l.heightM/2}else u=Qt.lerp(this.centreUpOf(n),this.centreUpOf(s),a);return{id:this.body.id,model:this.body.model,explains:this.body.explains??[],outlineNode:this.body.outlineNode,eastM:o,northM:c,upM:u,sizeM:l,attitude:h,appearance:{color:(a<1?n:s).appearance.color,albedo:Qt.lerp(n.appearance.albedo,s.appearance.albedo,a),luminanceCdM2:Qt.lerp(n.appearance.luminanceCdM2,s.appearance.luminanceCdM2,a)},flame:Qt.flameBetween(n.flame,s.flame,a),motions:this.motionsAt(t),lights:this.lightsAt(t),throwsFlame:this.body.track.some(d=>d.flame!==void 0&&d.flame.luminanceCdM2>0)}}static flameBetween(t,e,i){if(!t||t.luminanceCdM2<=0)return i>=1&&e&&e.luminanceCdM2>0?e:void 0;const n=t,s=e??t,a={...i<1?n:s,lengthM:Qt.lerp(n.lengthM,s.lengthM,i),widthM:Qt.lerp(n.widthM,s.widthM,i),luminanceCdM2:Qt.lerp(n.luminanceCdM2,s.luminanceCdM2,i)};return a.luminanceCdM2>0?a:void 0}centreUpOf(t){return"upM"in t.vertical?t.vertical.upM:this.groundUnderFootprint(t.eastM,t.northM,t.sizeM,t.attitude.headingDeg)+t.vertical.aboveGroundM+t.sizeM.heightM/2}groundUnderFootprint(t,e,i,n){const s=n*yu,a={eastM:Math.cos(s),northM:-Math.sin(s)},o={eastM:Math.sin(s),northM:Math.cos(s)};let c=this.ground.heightAt(t,e);for(const[l,h]of[[-1,-1],[1,-1],[-1,1],[1,1]]){const u=l*i.widthM/2,d=h*i.lengthM/2;c=Math.max(c,this.ground.heightAt(t+a.eastM*u+o.eastM*d,e+a.northM*u+o.northM*d))}return c}place(t,e){const i=[];let n;for(const s of t){const a=s.sizeM??n?.sizeM??Qt.DEFAULT_SIZE,o={headingDeg:s.attitude?.headingDeg??n?.attitude.headingDeg??0,pitchDeg:s.attitude?.pitchDeg??n?.attitude.pitchDeg??0,rollDeg:s.attitude?.rollDeg??n?.attitude.rollDeg??0},c={color:s.appearance?.color??n?.appearance.color??Qt.DEFAULT_APPEARANCE.color,albedo:s.appearance?.albedo??n?.appearance.albedo??Qt.DEFAULT_APPEARANCE.albedo,luminanceCdM2:s.appearance?.luminanceCdM2??n?.appearance.luminanceCdM2??Qt.DEFAULT_APPEARANCE.luminanceCdM2},l=this.positionOf(s,e)??(n&&{eastM:n.eastM,northM:n.northM,vertical:this.verticalOf(s)??n.vertical});if(!l)continue;const h=s.flame??n?.flame,u=s.present??n?.present??!0;n={t:s.t,...l,sizeM:a,attitude:o,appearance:c,flame:h,present:u},i.push(n)}return i}verticalOf(t){if(t.onGround)return{aboveGroundM:0};if(t.altitudeAboveGroundM!==void 0)return{aboveGroundM:t.altitudeAboveGroundM}}positionOf(t,e){if(t.eastM!==void 0&&t.northM!==void 0)return{eastM:t.eastM,northM:t.northM,vertical:this.verticalOf(t)??{aboveGroundM:0}};if(t.azimuthDeg===void 0||t.altitudeDeg===void 0)return;const i=e(t.t);if(!i)return;const n=t.distanceM??(t.onGround?Qt.lineOfSightMeetsGround(i,t.azimuthDeg,t.altitudeDeg,this.ground):void 0);if(n===void 0)return;const s=Qt.directionOf(t.azimuthDeg,t.altitudeDeg),a=i.eastM+s.eastM*n,o=i.northM+s.northM*n;return{eastM:a,northM:o,vertical:this.verticalOf(t)??{upM:i.upM+s.upM*n}}}static lerp(t,e,i){return t+(e-t)*i}static lerpAngle(t,e,i){const n=((e-t)%360+540)%360-180;return((t+n*i)%360+360)%360}}const hr=Math.PI/180,po=180/Math.PI;class Qe{constructor(t){this.timeline=t}static DIRECTION_TOLERANCE_DEG=1;static SIZE_TOLERANCE=1.5;static RINGS=12;static SEGMENTS=24;at(t,e,i,n){const s=[];for(const a of e){const o=Qe.projectionOf(a,i,n?.(a));if(o)for(const c of a.explains){const l=this.timeline.getInterpolatedShapeAt(t,c);!l||l.transparency>=1||s.push({...Qe.compare(c,a.id,{aim:l.aim,angular:l.angular},o),title:l.title})}}return s}static compare(t,e,i,n){const s=[],a=i.aim?Qe.separationDeg(i.aim,n.aim):void 0;if(a!==void 0){const l=Math.max(i.angular?.widthDeg??0,n.angular.widthDeg)/2;a>Math.max(Qe.DIRECTION_TOLERANCE_DEG,l)&&s.push("direction")}const o=i.angular&&i.angular.widthDeg>0?n.angular.widthDeg/i.angular.widthDeg:void 0,c=i.angular&&i.angular.heightDeg>0?n.angular.heightDeg/i.angular.heightDeg:void 0;return o!==void 0&&!Qe.withinSize(o)&&s.push("width"),c!==void 0&&!Qe.withinSize(c)&&s.push("height"),{sourceId:t,bodyId:e,stated:i,predicted:n,separationDeg:a,widthRatio:o,heightRatio:c,disagreements:s}}static projectionOf(t,e,i){const n=i&&i.length>0?i:Qe.outlineOf(t),s=i&&i.length>0?Qe.centreOf(i):t,a=Qe.normalized({eastM:s.eastM-e.eastM,northM:s.northM-e.northM,upM:s.upM-e.upM});if(!a)return;const o=Qe.normalized({eastM:a.northM,northM:-a.eastM,upM:0})??{eastM:1,northM:0,upM:0},c=Qe.cross(o,a);let l=1/0,h=-1/0,u=1/0,d=-1/0;for(const f of n){const p={eastM:f.eastM-e.eastM,northM:f.northM-e.northM,upM:f.upM-e.upM},v=Qe.dot(p,a);if(v<=0)return;const m=Math.atan2(Qe.dot(p,o),v),g=Math.atan2(Qe.dot(p,c),v);l=Math.min(l,m),h=Math.max(h,m),u=Math.min(u,g),d=Math.max(d,g)}return{aim:{azimuthDeg:(Math.atan2(a.eastM,a.northM)*po+360)%360,altitudeDeg:Math.asin(Math.max(-1,Math.min(1,a.upM)))*po},angular:{widthDeg:(h-l)*po,heightDeg:(d-u)*po}}}static centreOf(t){const e=i=>(Math.min(...t.map(n=>n[i]))+Math.max(...t.map(n=>n[i])))/2;return{eastM:e("eastM"),northM:e("northM"),upM:e("upM")}}static separationDeg(t,e){const i=t.altitudeDeg*hr,n=e.altitudeDeg*hr,s=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((t.azimuthDeg-e.azimuthDeg)*hr);return Math.acos(Math.max(-1,Math.min(1,s)))*po}static withinSize(t){return t<=Qe.SIZE_TOLERANCE&&t>=1/Qe.SIZE_TOLERANCE}static outlineOf(t){const e=t.sizeM.widthM/2,i=t.sizeM.lengthM/2,n=t.sizeM.heightM/2,s=[],a=t.model.url===void 0?t.model.id:void 0;if(a!==void 0&&a!=="box"&&z1.includes(a))for(let u=0;u<=Qe.RINGS;u++){const d=u/Qe.RINGS*Math.PI;for(let f=0;f<Qe.SEGMENTS;f++){const p=f/Qe.SEGMENTS*2*Math.PI;s.push([e*Math.sin(d)*Math.cos(p),i*Math.sin(d)*Math.sin(p),n*Math.cos(d)])}}else for(const u of[-e,e])for(const d of[-i,i])for(const f of[-n,n])s.push([u,d,f]);const c=t.attitude.headingDeg*hr,l=t.attitude.pitchDeg*hr,h=t.attitude.rollDeg*hr;return s.map(([u,d,f])=>{const p=u*Math.cos(h)+f*Math.sin(h),v=-u*Math.sin(h)+f*Math.cos(h),m=d*Math.cos(l)-v*Math.sin(l),g=d*Math.sin(l)+v*Math.cos(l);return{eastM:t.eastM+p*Math.cos(c)+m*Math.sin(c),northM:t.northM-p*Math.sin(c)+m*Math.cos(c),upM:t.upM+g}})}static dot(t,e){return t.eastM*e.eastM+t.northM*e.northM+t.upM*e.upM}static cross(t,e){return{eastM:t.northM*e.upM-t.upM*e.northM,northM:t.upM*e.eastM-t.eastM*e.upM,upM:t.eastM*e.northM-t.northM*e.eastM}}static normalized(t){const e=Math.hypot(t.eastM,t.northM,t.upM);return e>1e-9?{eastM:t.eastM/e,northM:t.northM/e,upM:t.upM/e}:void 0}}vg();const zE={sun:"Sun",moon:"Moon",Venus:"Venus",Mars:"Mars",Jupiter:"Jupiter",Saturn:"Saturn"},BE="{name} — mag {mag}, {alt}° above the horizon",HE="{name} — satellite, mag {mag}, {height} km up",GE="satellites-change",VE="rr0-confrontation",WE="{name} — mag {mag}, {alt}° below the horizontal",_u="Credits",jm="comet:",Qm="nova:",XE={building:"Building",tree:"Tree",shrub:"Shrub",bridge:"Bridge",crop:"Crop row",mound:"Stone heap",streetlight:"Streetlight",vehicle:"Vehicle",observer:"Observer",aircraft:"Aircraft",entity:"Being"},YE=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,qE=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,$E=-18,KE={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},Su={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class B0 extends HTMLElement{creditsButton;set ownCredits(t){this.creditsButton.hidden=!t}static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",yr,_r]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;distanceHypotheses=new Map;depths=new Map;directionScratch=new R;meteorScheduleFor;lightningScheduleFor;lightningFlashes=[];lastLightningT;lastTimeMs=0;interpretationShown;confrontationReadings=[];confrontationSignature="";comparing=!1;inTheRound=!0;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new Ii;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;starCatalogDepth=0;weatherAudio=new LE;vehicleAudio=new j1;vehicleHearing=new ul;animateWhilePausedValue=!1;set animateWhilePaused(t){t!==this.animateWhilePausedValue&&(this.animateWhilePausedValue=t,this.syncAnimationsToPlayback())}get animateWhilePaused(){return this.animateWhilePausedValue}thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=t=>{this.sceneRenderer.setCompassHovered(!0);const e=this.ufoElement.canvasElement,i=e.getBoundingClientRect();if(i.width===0||i.height===0)return;const n=(t.clientX-i.left)/i.width*e.width,s=(t.clientY-i.top)/i.height*e.height;if(this.ufoElement.hasVisibleShapeAt(n,s)){this.hoverTooltip.hidden=!0;return}const a=(t.clientX-i.left)/i.width*2-1,o=-((t.clientY-i.top)/i.height*2-1),c=this.naming,l=c.names,h=this.sceneRenderer.pickBodyAt(a,o);if(h){this.showHoverTooltip(t,this.bodyName(h));return}const u=this.sceneRenderer.pickDecorAt(a,o),d=u?this.ufoElement.sighting.decor.find(v=>v.id===u):void 0;if(d){this.showHoverTooltip(t,this.said.read(d.title)||c.decorKind(d.kind,XE[d.kind]));return}const f=this.sceneRenderer.pickSatelliteAt(a,o);if(f){this.showHoverTooltip(t,(l?.satelliteTooltip??HE).replace("{name}",f.name).replace("{mag}",f.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(f.heightKm).toLocaleString()));return}const p=this.sceneRenderer.pickStarAt(a,o);if(p){const v=p.star.mag,m=p.altitudeDeg,g=m<0?l?.starTooltipBelow??WE:l?.starTooltip??BE;this.showHoverTooltip(t,g.replace("{name}",c.star(p.star)).replace("{mag}",v.toLocaleString(void 0,{maximumFractionDigits:Math.abs(v)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(m)))));return}this.hoverTooltip.hidden=!0};bodyName(t){const e=t.startsWith(jm)?t.slice(jm.length):void 0,i=e?G1.find(a=>a.id===e):void 0;if(i)return this.naming.comet(i);const n=t.startsWith(Qm)?Km.byId(t.slice(Qm.length)):void 0;if(n)return this.naming.nova(n);const s=zE[t];return s===void 0?t:this.naming.body(t,s)}get naming(){return this.sceneNaming}sceneNaming=new $m;namesLanguage="en";async loadSceneNames(){const t=ag(fl.preferencesFor(this),rg);if(t===this.namesLanguage)return;this.namesLanguage=t;const e=await Bv(t);t===this.namesLanguage&&this.applySceneNaming(new $m(e))}applySceneNaming(t){this.sceneNaming=t;const e=t.names?.credits??_u;this.creditsButton.title=e,this.creditsButton.setAttribute("aria-label",e),this.sceneRenderer.setCompassPoints(t.names?.compassPoints)}showHoverTooltip(t,e){this.hoverTooltip.textContent=e,this.hoverTooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${t.clientX-i.left+12}px`,this.hoverTooltip.style.top=`${t.clientY-i.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash(t){clearTimeout(this.thunderTimeoutId),this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),pi.thunderDelayMs(t))}handleFirstInteraction=()=>{this.removeEventListener("pointerdown",this.handleFirstInteraction,!0),this.removeEventListener("keydown",this.handleFirstInteraction,!0),this.weatherAudio.resume(),this.vehicleAudio.resume(),this.setWeather(sf(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=t=>{this.lastTimeMs=t.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"&&this.sceneRenderer.frame(performance.now())};syncAnimationsToPlayback(){const t=this.ufoElement.playbackState==="playing",e=t||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(e,t),this.weatherAudio.setPaused(!e),this.vehicleAudio.setPaused(!e),e||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${nv}</style>${iv}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new ke(this.sceneCanvas);const e=this.shadow.getElementById("scene-loader");this.sceneRenderer.onFirstFrameHold=s=>{e.hidden=!s},this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(Eu),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",s=>this.lookToward(s.detail)),this.ufoElement.style.setProperty("--ufo-canvas-background","transparent"),this.ufoElement.style.setProperty("--ufo-canvas-border","none"),this.ufoElement.fullscreenTarget=this.stageElement,this.shadow.getElementById("ufo-slot").replaceWith(this.ufoElement),this.ufoElement.creditShownExternally=!0,this.creditsButton=this.shadow.getElementById("credits-button");const i=this.shadow.getElementById("credits-panel"),n=this.shadow.getElementById("credits-list");i.addEventListener("beforetoggle",s=>{s.newState==="open"&&$n.fill(n,this)}),this.creditsButton.title=_u,this.creditsButton.setAttribute("aria-label",_u),this.sceneRenderer.onMapSubjectBounds=s=>this.ufoElement.setMapSubjectBounds(s),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.seekPreviewPainter=(s,a)=>this.seekPreviewOf(a).paint(s,a),this.ufoElement.addEventListener("mutedchange",()=>this.weatherAudio.setLevel(this.ufoElement.level)),this.ufoElement.addEventListener("referenceview",s=>this.applyReferenceView(s.detail)),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave),this.addEventListener("pointerdown",this.handleFirstInteraction,!0),this.addEventListener("keydown",this.handleFirstInteraction,!0)}get said(){return this.saidTexts??=new $s(fl.preferencesFor(this))}saidTexts;connectedCallback(){this.saidTexts=void 0,this.loadSceneNames(),this.sceneRenderer.restoreContext(),this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),document.addEventListener("fullscreenchange",this.handleFullscreenChange);const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose(),this.vehicleAudio.dispose(),this.seekPreview?.dispose(),this.seekPreview=void 0,queueMicrotask(()=>{this.isConnected||this.sceneRenderer.releaseContext()})}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),(t==="star-catalog-src"||t==="deep-star-catalog-src")&&i!==e&&this.isConnected&&this.loadStars(),t==="show-compass"&&i!==e&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),t==="max-pixel-ratio"&&i!==e){const n=Number(i);this.sceneRenderer.setMaxPixelRatio(Number.isFinite(n)&&n>0?n:Math.min(window.devicePixelRatio||1,2))}(t===yr||t===_r)&&i!==e&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const t of[yr,_r]){const e=this.getAttribute(t);e===null?this.ufoElement.removeAttribute(t):this.ufoElement.setAttribute(t,e)}}setCompassForced(t){this.sceneRenderer.setCompassForced(t)}lookToward(t){const e=di(this.ufoElement.sighting,this.lastTimeMs);if(t.kind==="observer"||e?.lat===void 0||e.lng===void 0||e.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:i,z:n}=ai(t.lat,t.lng,e.lat,e.lng);if(Math.hypot(i,n)<1)return this.setLookOffset(0,0);const s=(Math.atan2(i,-n)*180/Math.PI+360)%360;this.setLookOffset(((s-e.headingDeg)%360+540)%360-180,-e.pitchDeg)}setLookOffset(t,e){this.sceneRenderer.setLookOffset(t,e),this.ufoElement.setLookOffset(t,e),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(t,e){this.sceneRenderer.setIndoorLook(t,e)}setCloudRendering(t){this.sceneRenderer.setCloudRendering(t)}setWeather(t){this.sceneRenderer.setWeather(t),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity*(t.precipitationAmount??1),t.windSpeed)}pickCloudAt(t,e){return this.sceneRenderer.pickCloudAt(t,e)}cloudDirectionAt(t,e){return this.sceneRenderer.cloudDirectionAt(t,e)}pickDecorAt(t,e){return this.sceneRenderer.pickDecorAt(t,e)}bodyScreenBox(t){return this.sceneRenderer.bodyScreenBox(t)}pickPlacedBodyAt(t,e){return this.sceneRenderer.pickPlacedBodyAt(t,e)}resumeWeatherAudio(){this.weatherAudio.resume(),this.vehicleAudio.resume()}async loadFromSrc(t){const e=ng.json(t);this.holdForNewScene(e);const i=await e;this.documentUrl=new URL(t,location.href).href,this.sightingData=i}holdForNewScene(t){this.sceneRenderer.holdForNewScene(t)}get documentUrl(){return this.sceneRenderer.documentUrl}set documentUrl(t){this.sceneRenderer.documentUrl=t}get sightingData(){return this.ufoElement.sightingData}set sightingData(t){this.ufoElement.sightingData=t,this.seekPreview?.recordingChanged(t),this.interpretationShown=this.inTheRound?this.ufoElement.sighting.interpretation:void 0,this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}seekPreview;seekPreviewOf(t){const e=this.sceneCanvas.width>0&&this.sceneCanvas.height>0?this.sceneCanvas.width/this.sceneCanvas.height:1.7777777777777777,i=Math.round(t.width/e);return t.height!==i&&(t.height=i),this.seekPreview??=new Nl(this,()=>document.createElement(Kd))}showAt(t){this.ufoElement.currentTime=t,this.framesAtAsk=this.sceneRenderer.framesDrawn}framesAtAsk=0;snapshotTo(t){if(this.sceneRenderer.frame(performance.now()),this.sceneRenderer.framesDrawn===this.framesAtAsk)return!1;const e=t.getContext("2d");return e?(e.drawImage(this.sceneCanvas,0,0,t.width,t.height),!0):!1}referenceAspect(t){return this.sceneRenderer.referenceAspect(t)}screenPointOf(t){return this.sceneRenderer.screenPointOf(t)}directionAt(t,e){return this.sceneRenderer.directionAt(t,e)}referenceFailedToLoad(t){return this.sceneRenderer.referenceFailedToLoad(t)}applyReferenceView(t){this.sceneRenderer.setReferencesShown(t.shown);for(const e of this.ufoElement.sighting.references)this.sceneRenderer.setReferenceView(e.id,{opacity:t.opacity})}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}get currentRoadAttribution(){return this.sceneRenderer.currentRoadAttribution}setTerrainProviders(t){this.sceneRenderer.setTerrainProviders(t)}setDecorModelProvider(t){this.sceneRenderer.setDecorModelProvider(t)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const t=this.ufoElement.sighting.instrument,e=Te.CANVAS_HEIGHT_PX,i=fi.frameWidthPx(t,e);this.frameElement.style.setProperty("--frame-aspect",`${i} / ${e}`)}resizeToStage(){const t=this.frameElement.getBoundingClientRect(),e=Math.max(1,Math.round(t.width)),i=Math.max(1,Math.round(t.height));this.sceneCanvas.width=e,this.sceneCanvas.height=i,this.sceneRenderer.resize(e,i)}async loadStars(){const t=[{magnitudeLimit:gu,url:this.getAttribute("star-catalog-src")??YE},{magnitudeLimit:vu,url:this.getAttribute("deep-star-catalog-src")??qE}],e=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=e>gu?vu:gu;const n=await qn.upTo(t,e);i===this.starCatalogRequest&&(this.starCatalog=n,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=vu||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const t=this.ufoElement.sighting,e=zi.gainFor(t.instrument,{fNumber:di(t,0)?.fNumber,fieldOfViewDeg:Ji.fovOf(t,0),exposureSeconds:t.exposure});return Ed($E,e)}updateAstronomy(t){this.ensureStarsDeepEnough(),this.applySceneAt(t);const e=Cn.windowEndingAt(t,this.exposureSeconds()),i=e.seconds,n=this.degreesPerPixelAt(t),s=La.instants(i,n),a=Math.max(s,this.ufoElement.exposureTimes(t).length,Cn.instants(this.ufoElement.sighting.decor,di(this.ufoElement.sighting,t)?.elevationM??0,e.fromMs,i,n));if(a<=1){this.sceneRenderer.setExposure(1);return}this.sceneRenderer.setExposure(a,o=>this.applySceneAt(e.fromMs+e.ms*o/(a-1),{sky:Math.floor(o*s/a)!==Math.floor((o-1)*s/a),stepMs:e.ms/a}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(t){const e=this.sceneCanvas.height;return e<=0?0:Ji.fovOf(this.ufoElement.sighting,t)/e}applySceneAt(t,e){const i=this.ufoElement.sighting;this.setWeather(sf(i,t)),this.sceneRenderer.setInstrument(i.instrument),this.sceneRenderer.setLightPollution(i.lightPollution),e||this.vehicleAudio.setVoices(this.vehicleHearing.at(i,t)),this.updateMeteorShower(i,t),this.updateLightning(i,t,e!==void 0),this.sceneRenderer.setDecor(i.decor);const n=di(i,t);this.sceneRenderer.setReferences(i.references,n?.lat!==void 0&&n.lng!==void 0?{lat:n.lat,lng:n.lng}:void 0);const s=di(i,0),a=Gr(i,0),o=Object.fromEntries(dl(Gr(i,t)).map(y=>[y.id,Q0(t,i.weatherTrack,a,s,n,y.id)]));this.sceneRenderer.setCloudOffset(Q0(t,i.weatherTrack,a,s,n),o),this.sceneRenderer.setObserverPose(n??Su),this.sceneRenderer.setLensOptics(this.lensOpticsAt(t)),this.sceneRenderer.setInstrumentGain(zi.gainFor(i.instrument,{fNumber:n?.fNumber,fieldOfViewDeg:Ji.fovOf(i,t),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0),this.sceneRenderer.setMedium(i.instrument.medium,i.exposure,n?.fNumber??i.instrument.fNumber,i.iso),this.sceneRenderer.setGait(_e.bodyAt(i,t,this.ufoElement.steadyObserver)),this.sceneRenderer.updateDecorAnchoring(di(i,0),n,t),this.placeBodiesAt(t,e===void 0),this.sceneRenderer.updateDecorLitState(t,e?.stepMs??0),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng,()=>{this.placeBodiesAt(this.lastTimeMs,!0),this.sceneRenderer.render()}),this.sceneRenderer.setStatedRoads(i.roads),this.pushPhenomenaAt(t);const c=n?.lat??Su.lat,l=n?.lng??Su.lng,h=Bc(i.event.time??{},l,i.event.utcOffsetHours),u={lat:c,lng:l,elevationM:n?.elevationM??0};if(this.pushSatellitesAt(h,t,u),e&&!e.sky)return;if(!h){this.sceneRenderer.setAstronomy(KE);return}const d=new Date(h.getTime()+t),f=Math.max(1,Math.round(.25*this.degreesPerPixelAt(t)/La.DEG_PER_SECOND*1e3)),p=Math.max(1e-8,this.degreesPerPixelAt(t)*.1),v=`${Math.floor(d.getTime()/f)}|${Math.round(c/p)}|${Math.round(l/p)}|${Math.round(u.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(v===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=v;const m={...qh("Sun",d,u),magnitude:$h("Sun",d)},g={...qh("Moon",d,u),phase:C5(d),magnitude:$h("Moon",d)},S=I5.map(y=>({body:y,position:qh(y,d,u),magnitude:$h(y,d)}));this.sceneRenderer.setAstronomy({sun:m,moon:g,planets:S,comet:this.cometAt(d,u),novae:Km.appearancesAt(d,u).map(({outburst:y,position:M,magnitude:b})=>({id:y.id,position:M,magnitude:b})),stars:this.starCatalog?{catalog:this.starCatalog,date:d,observer:u}:void 0,frame:{date:d,observer:u}}),this.ufoElement.setSunAltitude(m.altitudeDeg)}pushSatellitesAt(t,e,i){if(this.ensureSatellites(t),!t||!this.satellites){this.sceneRenderer.setSatellites([]);return}const n=new Date(t.getTime()+e),s=[];for(const a of this.satellites.passes.positionsAt(n,i,-1))a.magnitude!==void 0&&s.push({norad:a.object.norad,name:a.object.name,position:{altitudeDeg:a.altitudeDeg,azimuthDeg:a.azimuthDeg},magnitude:a.magnitude,heightKm:a.heightKm});this.sceneRenderer.setSatellites(s)}ensureSatellites(t){const e=t?String(t.getTime()):"";if(e===this.satellitesFor)return;this.satellitesFor=e,this.satellites=void 0,this.satellitePassesMemo=void 0;const i=++this.satelliteRequest;if(!t){this.satelliteStatus="none";return}this.satelliteStatus="loading";const n=a=>{i===this.satelliteRequest&&(this.satelliteStatus=a,this.isConnected&&this.dispatchEvent(new CustomEvent(GE)))},s=B0.tleArchive;(async()=>{if(!await s.covers(t))return n("outside");const[a,o]=await Promise.all([s.at(t),is(()=>import("./SatellitePasses-Pfro2-0Z.js"),[],import.meta.url)]);if(i===this.satelliteRequest){if(!a)return n("unavailable");this.satellites={snapshot:a,passes:new o.SatellitePasses(a.objects)},n("ready"),this.isConnected&&this.updateAstronomy(this.lastTimeMs)}})().catch(()=>n("unavailable"))}get satelliteState(){const t=this.satellites?.snapshot;return{status:this.satelliteStatus,coverage:t?.coverage,credit:t?.credit,creditUrl:t?.creditUrl}}satellitePassesDuring(t){const e=this.satellites,i=this.ufoElement.sighting,n=di(i,0),s=i.event.place?.[0],a=n?.lat??s?.lat,o=n?.lng??s?.lng;if(!e||a===void 0||o===void 0)return[];const c=Bc(i.event.time??{},o,i.event.utcOffsetHours);if(!c)return[];const l=Math.min(Math.max(t,0),4*36e5),h={lat:a,lng:o,elevationM:n?.elevationM??0},u=JSON.stringify([this.satellitesFor,c.getTime(),a,o,h.elevationM,l]);if(this.satellitePassesMemo?.key===u)return this.satellitePassesMemo.passes;const d=Math.max(10,Math.ceil(l/1e3/600)),f=e.passes.passesDuring(c,new Date(c.getTime()+l),h,d);return this.satellitePassesMemo={key:u,passes:f},f}cometAt(t,e){const i=OE.brightestAt(t,e);if(i)return{id:i.apparition.id,position:i.position,tailEnd:i.tailEnd,magnitude:i.magnitude}}pushPhenomenaAt(t){const e=this.ufoElement.sighting;e!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=e);const i=e.timeline,n=this.ufoElement.canvasElement,s=this.ufoElement.frameShiftPx,a=this.projectionAt(t),o=new Map,c=new Map,l=new Set;for(const p of i.sourceIds){const v=i.getInterpolatedShapeAt(t,p);if(!v)continue;const m={...v,bounds:{...v.bounds,x:v.bounds.x+s.x,y:v.bounds.y+s.y}};o.set(p,m);const g=v.aim?this.sceneRenderer.screenPointOf(In.directionOf(v.aim,this.directionScratch)):{ndcX:(m.bounds.x+m.bounds.width/2)/n.width*2-1,ndcY:-((m.bounds.y+m.bounds.height/2)/n.height*2-1)},S=g!==void 0&&Math.abs(g.ndcX)<=1&&Math.abs(g.ndcY)<=1,y=S?this.sceneRenderer.decorDistancesAt(g.ndcX,g.ndcY,p):{};l.add(p),(S||v.aim)&&l.delete(p);const M=v.angular?.widthDeg??a.pxToDeg(v.bounds.width),b=this.sizeEstimateOf(p);b.add(M,y);const w=Do.of(e,p);c.set(p,ki.resolve({hypothesisM:this.distanceHypotheses.get(p),derivedM:w&&M>0?Te.distanceMAt(w.widthM,M):void 0,range:b.distanceRangeAt(M),crossing:y}))}for(const[p,v]of o)for(const[m,g]of o){if(m===p||g.transparency>=1||g.bounds.width*g.bounds.height<=v.bounds.width*v.bounds.height||!(v.bounds.x>=g.bounds.x&&v.bounds.y>=g.bounds.y&&v.bounds.x+v.bounds.width<=g.bounds.x+g.bounds.width&&v.bounds.y+v.bounds.height<=g.bounds.y+g.bounds.height))continue;const y=c.get(m);y&&c.set(p,{distanceM:y.distanceM*.999,basis:y.basis});break}this.depths=c;const h=i.sourceIds,u=[];for(const[p,v]of o)u.push({sourceId:p,shape:v,distanceM:c.get(p).distanceM,renderOrder:h.indexOf(p),aim:v.aim,hidden:l.has(p)||this.interpretationShown!==void 0&&(!this.comparing||v.transparency>=1),ghost:this.interpretationShown!==void 0&&this.comparing});const f=(di(e,t)?.rollDeg??0)+_e.bodyAt(e,t,this.ufoElement.steadyObserver).rollDeg;this.sceneRenderer.setPhenomena(u,{projection:a,canvasWidthPx:n.width,canvasHeightPx:n.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,n.height)),starPoints:fi.starPointsOf(e.instrument),rollRad:f*Math.PI/180})}get interpretation(){return this.interpretationShown}set interpretation(t){this.interpretationShown=t,this.updateAstronomy(this.lastTimeMs)}get accountInTheRound(){return this.inTheRound}set accountInTheRound(t){this.inTheRound=t}get compareAccount(){return this.comparing}set compareAccount(t){this.comparing=t,this.updateAstronomy(this.lastTimeMs)}get confrontation(){return this.confrontationReadings}groundAlong(t,e,i){const n=this.sceneRenderer.bodyGround,s=Qt.eyeOf(this.ufoElement.sighting,i,n);return s?Qt.lineOfSightMeetsGround(s,t,e,n):void 0}bodyReading(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=d=>Qt.eyeOf(n,d,i),a=new Qt(t,i,s).at(e),o=s(e);if(!a||!o)return;const c=a.eastM-o.eastM,l=a.northM-o.northM,h=a.upM-o.upM,u=Math.hypot(c,l);return{azimuthDeg:(Math.atan2(c,l)*180/Math.PI+360)%360,altitudeDeg:Math.atan2(h,u)*180/Math.PI,distanceM:Math.hypot(u,h),eastM:a.eastM,northM:a.northM,aboveGroundM:a.upM-a.sizeM.heightM/2-i.heightAt(a.eastM,a.northM),sizeM:a.sizeM,attitude:a.attitude,appearance:a.appearance}}directionToBody(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=p=>Qt.eyeOf(n,p,i),a=new Qt(t,i,s),o=a.at(e)?e:t.track[0]?.t,c=o===void 0?void 0:a.at(o),l=o===void 0?void 0:s(o);if(!c||!l)return;const h=c.eastM-l.eastM,u=c.northM-l.northM,d=c.upM-l.upM,f=Math.hypot(h,u);if(!(f===0&&d===0))return{azimuthDeg:(Math.atan2(h,u)*180/Math.PI+360)%360,altitudeDeg:Math.atan2(d,f)*180/Math.PI}}placeBodiesAt(t,e){const i=this.interpretationShown,n=this.ufoElement.sighting;let s=[],a=[];const o=this.sceneRenderer.bodyGround,c=p=>Qt.eyeOf(n,p,o);i&&(s=i.bodies.map(p=>new Qt(p,o,c).at(t)).filter(p=>p!==void 0));const l=Gr(n,t),h=l.windDirectionDeg*Math.PI/180,u={x:l.windSpeed*Math.sin(h),z:-l.windSpeed*Math.cos(h)};this.sceneRenderer.setBodies(s,t/1e3,i?.bodies.map(p=>p.id)??[],i?.smoke??[],u);const d=i&&this.comparing?c(t):void 0;if(d&&(a=new Qe(n.timeline).at(t,s,d,p=>p.outlineNode?this.sceneRenderer.bodyOutline?.(p.id,p.outlineNode):void 0)),this.confrontationReadings=a,!e)return;const f=JSON.stringify(a);f!==this.confrontationSignature&&(this.confrontationSignature=f,this.dispatchEvent(new CustomEvent(VE,{detail:a})))}setDistanceHypothesis(t,e){e===void 0||!(e>0)?this.distanceHypotheses.delete(t):this.distanceHypotheses.set(t,e),this.updateAstronomy(this.lastTimeMs)}depthOf(t){return this.depths.get(t)}sizeRangeOf(t){return this.sizeEstimateOf(t).sizeRange}distanceRangeAt(t,e){const i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(e,t);if(!i)return{};const n=i.angular?.widthDeg??this.projectionAt(e).pxToDeg(i.bounds.width);return this.sizeEstimateOf(t).distanceRangeAt(n)}sizeContradictory(t){return this.sizeEstimateOf(t).contradictory}updateMeteorShower(t,e){this.ensureMeteorSchedule(t),this.sceneRenderer.updateMeteors(e)}updateLightning(t,e,i){if(this.ensureLightningSchedule(t),this.sceneRenderer.updateLightning(e),i)return;const n=this.lastLightningT;if(this.lastLightningT=e,n===void 0||e<n||this.ufoElement.playbackState!=="playing")return;const s=this.lightningFlashes.filter(a=>a.t>n&&a.t<=e).pop();s&&Gr(t,s.t).storm&&this.handleLightningFlash(s)}ensureLightningSchedule(t){const e=Gr(t,0).precipitationIntensity,i=`${this.meteorInputsOf(t)}|${e}`;if(i===this.lightningScheduleFor)return;this.lightningScheduleFor=i;const n=t.event.time,s=t.event.place?.[0],a=n?.year!==void 0?Bc(n,s?.lng??0,t.event.utcOffsetHours):void 0,o=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,c=Math.round((a?.getTime()??0)/1e3)+Math.round((s?.lat??0)*1e3)+7;this.lightningFlashes=pi.schedule({durationMs:o,seed:c,intensity:e}),this.sceneRenderer.setLightning(this.lightningFlashes)}ensureMeteorSchedule(t){const e=this.meteorInputsOf(t);e!==this.meteorScheduleFor&&(this.meteorScheduleFor=e,this.scheduleMeteors(t))}meteorInputsOf(t){const e=t.event.place?.[0],i=t.event.time;return JSON.stringify([e?.lat,e?.lng,i?.year,i?.month,i?.day,i?.hour,i?.minute,i?.second,t.event.utcOffsetHours,t.event.durationSeconds,t.timeline.duration])}scheduleMeteors(t){const e=t.event.place?.[0],i=t.event.time,n=e?.lat!==void 0&&e.lng!==void 0&&i?.year!==void 0?Bc(i,e.lng,t.event.utcOffsetHours):void 0;if(!n||e?.lat===void 0||e.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const s={lat:e.lat,lng:e.lng,elevationM:0},a=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,o=Math.round(n.getTime()/1e3)+Math.round(e.lat*1e3),c=ti.schedule({ratePerHour:ti.observedRatePerHour(ti.apexPosition(n,s).altitudeDeg),durationMs:a,velocityKmS:ti.TYPICAL_VELOCITY_KM_S,seed:o}),l=xu.activeAt(n).map(u=>{const d=xu.radiantPosition(u.shower,n,s);return{entry:u,position:d,rate:xu.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!l||l.rate<=0){this.sceneRenderer.setMeteorShower(c,0,0);return}const h=Ca.schedule({ratePerHour:l.rate,durationMs:a,velocityKmS:l.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}meteorByRank(t){this.ensureMeteorSchedule(this.ufoElement.sighting);const e=[...this.sceneRenderer.meteorSchedule].filter(s=>s.t+s.durationMs<=this.ufoElement.seekableDuration).sort((s,a)=>a.brightness-s.brightness);if(e.length===0)return;const i=e[t%e.length],n=this.sceneRenderer.meteorMidpoint(i);if(n)return{t:Math.round(i.t+i.durationMs*.45),...n}}lensOpticsAt(t){const e=this.ufoElement.sighting,i=e.instrument,n=i.frame,s=di(e,t),a=s?.fNumber??i.fNumber;if(!n||a===void 0)return;const o=fi.focalLengthMmFor(i,Ji.fovOf(e,t));if(o!==void 0)return{focalLengthMm:o,fNumber:a,focusDistance:s?.focusDistanceM??0,frameHeightMm:n.heightMm}}projectionAt(t){const e=this.ufoElement.sighting;return Ss.of(e.instrument,Te.CANVAS_HEIGHT_PX,Ji.fovOf(e,t))}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new FE,this.sizeEstimates.set(t,e)),e}}const Kd="rr0-scene";function ZE(){vg(),customElements.get(Kd)||customElements.define(Kd,B0)}ZE();export{RM as $,eA as A,ee as B,st as C,dp as D,Dt as E,aA as F,nA as G,Bg as H,iA as I,sA as J,xs as K,$o as L,BM as M,sc as N,Be as O,Zg as P,Qi as Q,ko as R,Gi as S,JE as T,Ce as U,xt as V,Zi as W,tA as X,Un as Y,zg as Z,rp as _,QE as a,gl as a0,ud as a1,bl as a2,bi as a3,$g as a4,x0 as a5,y0 as a6,re as a7,ia as a8,qo as a9,Vi as aa,Rs as ab,jE as b,cA as c,xl as d,oA as e,Zt as f,R as g,Kf as h,rA as i,lA as j,wM as k,wa as l,rh as m,T2 as n,oe as o,Re as p,Ou as q,wi as r,Hg as s,Ds as t,OM as u,xa as v,ji as w,_n as x,we as y,ce as z};
7632
+ `);let s=qn.cache.get(n);return s||(s=Promise.all(i.map(a=>qn.load(a.url))).then(a=>a.reduce((o,c)=>qn.concat(o,c))),qn.cache.set(n,s)),s}static parse(t){const e=t.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),i=e*Float32Array.BYTES_PER_ELEMENT;return{count:e,ra:new Float32Array(t,0*i,e),dec:new Float32Array(t,1*i,e),mag:new Float32Array(t,2*i,e),ci:new Float32Array(t,3*i,e)}}static concat(t,e){const i=(n,s)=>{const a=new Float32Array(n.length+s.length);return a.set(n,0),a.set(s,n.length),a};return{count:t.count+e.count,ra:i(t.ra,e.ra),dec:i(t.dec,e.dec),mag:i(t.mag,e.mag),ci:i(t.ci,e.ci)}}}class $m{constructor(t){this.names=t}body(t,e){return this.names?.bodies[t]??e}star(t){return this.names?.stars[t.name]??t.name}comet(t){return this.names?.comets[t.id]??t.name}nova(t){return this.names?.novae[t.id]??t.name}satelliteClass(t){return this.names?.satelliteClasses[t.id]??t.name}shower(t){return this.names?.showers[t.id]??t.name}lightRig(t){return this.names?.lightRigs[t.id]??t.name}instrument(t){return this.names?.instruments[t.id]??t.name}decorKind(t,e){return this.names?.decorKinds[t]??e}point(t){return Ia.point(t,this.names?.compassPoints)}towards(t){return Ia.towards(t,this.names)}}const EE="“Thunder” by Jerimee",AE="https://creativecommons.org/licenses/by/3.0/",TE="CC BY 3.0";class $n{static fill(t,e){t.innerHTML="";const i=l=>t.appendChild(l),n=e.currentTerrainAttribution;n&&i($n.text(n));const s=e.currentRoadAttribution;s&&i($n.text(s));const a=e.ufoElement.observerMapCredit;a&&!n?.includes(a)&&i($n.text(a));for(const l of e.decorModelCredits){const h=l.author?` — ${l.author}`:"",u=document.createElement("li");l.sourceUrl?u.append($n.link(l.sourceUrl,l.title),document.createTextNode(`${h} (${l.license})`)):u.textContent=`${l.title}${h} (${l.license})`,i(u)}for(const l of e.ufoElement.sighting.references){if(!l.credit)continue;const h=document.createElement("li");l.creditUrl?h.appendChild($n.link(l.creditUrl,l.credit)):h.textContent=l.credit,i(h)}const o=e.satelliteState;if(o.status==="ready"&&o.credit){const l=document.createElement("li");l.appendChild($n.link(o.creditUrl??"",o.credit)),i(l)}const c=$n.text(`${EE} (`);c.append($n.link(AE,TE),document.createTextNode(")")),i(c)}static text(t){const e=document.createElement("li");return e.textContent=t,e}static link(t,e){const i=document.createElement("a");return i.href=t,i.target="_blank",i.rel="noopener",i.textContent=e,i}}const RE=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,DE=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,IE=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,CE=20,PE=1;class LE{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=0;paused=!0;requested={type:"none",intensity:0,windSpeed:0};level=1;master;output(t){return this.master||(this.master=t.createGain(),this.master.gain.value=this.level,this.master.connect(t.destination)),this.master}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",t);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(t,e,i){if(this.requested={type:t,intensity:e,windSpeed:i},!this.context)return;this.paused&&(t="none",e=0,i=0);const n=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=n==="hail"?Math.min(1,e*1.3+.2):n==="rain"?e:0,n!==this.ambientKey){this.ambientKey=n;const a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,n!=="none"&&this.startLoop(RE,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(i/CE,1);const s=i>PE;if(s!==this.windActive){this.windActive=s;const a=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,s&&this.startLoop(DE,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(t){if(t===this.paused)return;this.paused=t;const{type:e,intensity:i,windSpeed:n}=this.requested;this.setAmbient(e,i,n)}playThunder(){!this.context||this.paused||this.playOneShot(IE,.9)}dispose(){this.ambientToken++,this.windToken++,this.stopSource(this.ambientSource,this.ambientGain),this.stopSource(this.windSource,this.windGain),this.ambientSource=void 0,this.ambientGain=void 0,this.windSource=void 0,this.windGain=void 0,this.context?.close(),this.context=void 0,this.master=void 0,this.buffers.clear()}applyIfCurrent(t,e,i,n){if(e!==i()){t?.source.stop();return}n(t)}async startLoop(t,e){const i=this.context;if(i)try{const n=await this.getBuffer(t),s=i.createBufferSource();s.buffer=n,s.loop=!0;const a=i.createGain();return a.gain.value=e,s.connect(a).connect(this.output(i)),s.start(),{source:s,gain:a}}catch(n){console.warn("Weather ambient sound failed to load, staying silent:",n);return}}async playOneShot(t,e){const i=this.context;if(i)try{const n=await this.getBuffer(t),s=i.createBufferSource();s.buffer=n;const a=i.createGain();a.gain.value=e,s.connect(a).connect(this.output(i)),s.start()}catch(n){console.warn("Thunder sound failed to load:",n)}}async getBuffer(t){const e=this.context;if(!e)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(t);return i||(i=fetch(t).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${t}`);return n.arrayBuffer()}).then(n=>e.decodeAudioData(n)),this.buffers.set(t,i)),i}stopSource(t,e){try{t?.stop()}catch{}t?.disconnect(),e?.disconnect()}}class Ms{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:i}=t,[n,s]=this.perifocalAxes(),a=Math.sqrt(Ms.SUN_GM_AU3_PER_DAY2*(1+e)/i);this.perihelionPosition=this.scale(n,i),this.perihelionVelocity=this.scale(s,a),this.inverseSemiMajorAxis=(1-e)/i}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(t){const e=t-this.elements.perihelionJd,i=this.universalAnomaly(e),n=this.inverseSemiMajorAxis*i*i,s=this.elements.perihelionAu,a=1-i*i/s*Ms.stumpffC(n),o=e-i*i*i/Math.sqrt(Ms.SUN_GM_AU3_PER_DAY2)*Ms.stumpffS(n);return{x:a*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:a*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:a*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(t){const e=this.positionAt(t);return Math.hypot(e.x,e.y,e.z)}universalAnomaly(t){if(t===0)return 0;const e=Math.sign(t),i=Math.sqrt(Ms.SUN_GM_AU3_PER_DAY2)*Math.abs(t),n=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*Ms.stumpffS(c)+l*o};let s=Math.max(1,i/this.elements.perihelionAu);for(;n(s)<i;)s*=2;let a=0;for(let o=0;o<Ms.MAX_ITERATIONS&&s-a>1e-13*Math.max(1,s);o++){const c=(a+s)/2;n(c)<i?a=c:s=c}return e*(a+s)/2}perifocalAxes(){const t=this.elements.ascendingNodeDeg*Math.PI/180,e=this.elements.argumentOfPerihelionDeg*Math.PI/180,i=this.elements.inclinationDeg*Math.PI/180,n=Math.cos(t),s=Math.sin(t),a=Math.cos(e),o=Math.sin(e),c=Math.cos(i),l=Math.sin(i);return[{x:n*a-s*o*c,y:s*a+n*o*c,z:o*l},{x:-n*o-s*a*c,y:-s*o+n*a*c,z:a*l}]}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}static stumpffC(t){if(Math.abs(t)<1e-6)return 1/2-t/24+t*t/720;if(t>0)return(1-Math.cos(Math.sqrt(t)))/t;const e=Math.sqrt(-t);return(Math.cosh(e)-1)/-t}static stumpffS(t){if(Math.abs(t)<1e-6)return 1/6-t/120+t*t/5040;if(t>0){const i=Math.sqrt(t);return(i-Math.sin(i))/(i*i*i)}const e=Math.sqrt(-t);return(Math.sinh(e)-e)/(e*e*e)}}const G1=[{id:"halley-1910",designation:"1P/Halley",name:"Halley's Comet",orbit:{eccentricity:.9672960498922706,perihelionAu:.5872100477652511,inclinationDeg:162.218798367122,ascendingNodeDeg:58.56208298700436,argumentOfPerihelionDeg:111.7366940639061,perihelionJd:2.4187816784171113e6},peakMagnitude:0,peakOn:"1910-05-20",absoluteMagnitude:4.72,activityExponent:4,tailLengthDeg:100,tailLengthAu:.1638,note:"Passed 0.15 au from Earth on 20 May 1910, and the Earth crossed the outer tail the day before — the apparition that produced a genuine public panic."},{id:"brooks-1911",designation:"C/1911 O1",name:"Comet Brooks",orbit:{eccentricity:.9876404970138669,perihelionAu:.4898172916113738,inclinationDeg:33.34043866978714,ascendingNodeDeg:293.7022074981857,argumentOfPerihelionDeg:153.5578007321686,perihelionJd:2.4193378856140426e6},peakMagnitude:2,peakOn:"1911-10-25",absoluteMagnitude:5.59,activityExponent:4},{id:"skjellerup-maristany-1927",designation:"C/1927 X1",name:"Comet Skjellerup-Maristany",orbit:{eccentricity:.999839726885059,perihelionAu:.1761569619628186,inclinationDeg:85.1125991950808,ascendingNodeDeg:78.24360172472711,argumentOfPerihelionDeg:47.15877857390136,perihelionJd:2.4252326808989984e6},peakMagnitude:-6,peakOn:"1927-12-15",absoluteMagnitude:1.19,activityExponent:4,note:"One of the few comets of the century seen in full daylight."},{id:"de-kock-paraskevopoulos-1941",designation:"C/1941 B2",name:"Comet de Kock-Paraskevopoulos",orbit:{eccentricity:.9991026715181549,perihelionAu:.7900329662827822,inclinationDeg:168.2039226531089,ascendingNodeDeg:43.10609347214336,argumentOfPerihelionDeg:268.6990344196369,perihelionJd:2430022157765061e-9},peakMagnitude:2,peakOn:"1941-02-05",absoluteMagnitude:5.01,activityExponent:4},{id:"southern-1947",designation:"C/1947 X1",name:"the Southern Comet",orbit:{eccentricity:.9998424430916737,perihelionAu:.1100045955093761,inclinationDeg:138.5113919632757,ascendingNodeDeg:337.3114969669252,argumentOfPerihelionDeg:196.1820121395961,perihelionJd:2.4325220864727003e6},peakMagnitude:-3,peakOn:"1947-12-08",absoluteMagnitude:3.01,activityExponent:4,note:"A bright southern-hemisphere comet of December 1947, the month the American sighting wave of that year was still being argued over."},{id:"eclipse-1948",designation:"C/1948 V1",name:"the Eclipse Comet",orbit:{eccentricity:.9999130678247334,perihelionAu:.1354437057263306,inclinationDeg:23.11668597152911,ascendingNodeDeg:211.0454985994762,argumentOfPerihelionDeg:107.2474157073104,perihelionJd:2.4328519265329437e6},peakMagnitude:-2,peakOn:"1948-11-01",absoluteMagnitude:4.79,activityExponent:4,note:"Found during the total solar eclipse of 1 November 1948, which is how a comet that bright had gone unnoticed: it had been hidden in the Sun's glare."},{id:"arend-roland-1957",designation:"C/1956 R1",name:"Comet Arend-Roland",orbit:{eccentricity:1.0002570255357,perihelionAu:.3160532361485914,inclinationDeg:119.9440863251822,ascendingNodeDeg:215.8548157717755,argumentOfPerihelionDeg:308.775920364167,perihelionJd:2.4359365327396123e6},peakMagnitude:.5,peakOn:"1957-04-25",absoluteMagnitude:3.96,activityExponent:4,note:"Showed a spike pointing back TOWARD the Sun in late April 1957 — a real anti-tail, and much reported at the time."},{id:"mrkos-1957",designation:"C/1957 P1",name:"Comet Mrkos",orbit:{eccentricity:.9993521583504134,perihelionAu:.3549238508212375,inclinationDeg:93.9433042053929,ascendingNodeDeg:68.32441518619923,argumentOfPerihelionDeg:40.31823675802871,perihelionJd:243605193752228e-8},peakMagnitude:1,peakOn:"1957-08-05",absoluteMagnitude:5.07,activityExponent:4,note:"The second bright naked-eye comet of 1957, four months after Arend-Roland."},{id:"seki-lines-1962",designation:"C/1962 C1",name:"Comet Seki-Lines",orbit:{eccentricity:1.000003791331562,perihelionAu:.03139689112215131,inclinationDeg:65.01487186102287,ascendingNodeDeg:304.6776602796538,argumentOfPerihelionDeg:11.47295326312573,perihelionJd:2437756163010178e-9},peakMagnitude:-2.5,peakOn:"1962-04-01",absoluteMagnitude:9.3,activityExponent:4},{id:"ikeya-seki-1965",designation:"C/1965 S1",name:"Comet Ikeya-Seki",orbit:{eccentricity:.9999141178248997,perihelionAu:.007785966366889336,inclinationDeg:141.8642315267051,ascendingNodeDeg:346.9951764632611,argumentOfPerihelionDeg:69.04909813996062,perihelionJd:2.4390546837018197e6},peakMagnitude:-10,peakOn:"1965-10-21",alsoRecordedMagnitude:2,alsoRecordedOn:"1965-10-30",absoluteMagnitude:5.26,activityExponent:4.002,tailLengthDeg:25,tailLengthAu:.5048,note:"A sungrazer that passed 450 000 km above the Sun's surface and was seen beside it in broad daylight — the brightest comet of the twentieth century. It then stood in the dawn sky for a fortnight with a tail some 25 degrees long, which is the second magnitude recorded here."},{id:"bennett-1970",designation:"C/1969 Y1",name:"Comet Bennett",orbit:{eccentricity:.9962979048768408,perihelionAu:.5376209981502136,inclinationDeg:90.03975717147327,ascendingNodeDeg:224.6576652531314,argumentOfPerihelionDeg:354.1494209173161,perihelionJd:2.4406655455270996e6},peakMagnitude:0,peakOn:"1970-03-26",absoluteMagnitude:3.36,activityExponent:4},{id:"white-ortiz-bolelli-1970",designation:"C/1970 K1",name:"Comet White-Ortiz-Bolelli",orbit:{eccentricity:.9999488875801225,perihelionAu:.00884411465256722,inclinationDeg:138.9520738221631,ascendingNodeDeg:336.8194095816687,argumentOfPerihelionDeg:61.10224765396615,perihelionJd:2.4407209807728203e6},peakMagnitude:1,peakOn:"1970-05-22",absoluteMagnitude:4.35,activityExponent:4},{id:"kohoutek-1973",designation:"C/1973 E1",name:"Comet Kohoutek",orbit:{eccentricity:1.000007152175185,perihelionAu:.1424250377812859,inclinationDeg:14.30414984159355,ascendingNodeDeg:258.4893339663974,argumentOfPerihelionDeg:37.79772760699667,perihelionJd:2442044930687027e-9},peakMagnitude:0,peakOn:"1974-01-05",absoluteMagnitude:4.89,activityExponent:4,note:"Announced in advance as the comet of the century and remembered for disappointing: it was an ordinary naked-eye object, not the spectacle the press had promised."},{id:"west-1976",designation:"C/1975 V1",name:"Comet West",orbit:{eccentricity:1.000017859625611,perihelionAu:.1966006188461085,inclinationDeg:43.07319920579427,ascendingNodeDeg:118.9189245655447,argumentOfPerihelionDeg:358.4315101259072,perihelionJd:2442833721841768e-9},peakMagnitude:-3,peakOn:"1976-02-25",absoluteMagnitude:4.41,activityExponent:4,tailLengthDeg:30,tailLengthAu:.4325,note:"Broke into four pieces at perihelion. Barely reported at the time — the press had been burned by Kohoutek two years earlier."},{id:"iras-araki-alcock-1983",designation:"C/1983 H1",name:"Comet IRAS-Araki-Alcock",orbit:{eccentricity:.9898409731606003,perihelionAu:.9913412593828502,inclinationDeg:73.25000846947029,ascendingNodeDeg:49.10235754476374,argumentOfPerihelionDeg:192.8506176754439,perihelionJd:2.4454757545235856e6},peakMagnitude:1.7,peakOn:"1983-05-11",absoluteMagnitude:9.04,activityExponent:4,note:"Passed 0.031 au from Earth on 11 May 1983, one of the closest cometary approaches on record: it crossed a quarter of the sky in a night, which no other comet in this list did."},{id:"halley-1986",designation:"1P/Halley",name:"Halley's Comet",orbit:{eccentricity:.9672792271749998,perihelionAu:.5871034488173393,inclinationDeg:162.2422242700916,ascendingNodeDeg:58.85993640671803,argumentOfPerihelionDeg:111.8655480539208,perihelionJd:2.4464709589610207e6},peakMagnitude:2.1,peakOn:"1986-03-10",absoluteMagnitude:2.71,activityExponent:4,note:"The worst-placed return in two thousand years — famous, expected, and for most observers a faint smudge."},{id:"hyakutake-1996",designation:"C/1996 B2",name:"Comet Hyakutake",orbit:{eccentricity:.9997295133739305,perihelionAu:.2302272039470452,inclinationDeg:124.923592343765,ascendingNodeDeg:188.0454295899424,argumentOfPerihelionDeg:130.1724036582639,perihelionJd:2.4502048946148166e6},peakMagnitude:0,peakOn:"1996-03-25",absoluteMagnitude:4.75,activityExponent:4,tailLengthDeg:80,tailLengthAu:1,note:"Passed 0.10 au from Earth in March 1996, five weeks BEFORE perihelion, with a tail measured at some 80 degrees — the longest of the modern era."},{id:"hale-bopp-1997",designation:"C/1995 O1",name:"Comet Hale-Bopp",orbit:{eccentricity:.9951314746156615,perihelionAu:.9141695067003724,inclinationDeg:89.43017155012492,ascendingNodeDeg:282.470602866853,argumentOfPerihelionDeg:130.5872524854533,perihelionJd:2450539633099368e-9},peakMagnitude:-.8,peakOn:"1997-04-01",absoluteMagnitude:-1.06,activityExponent:4,tailLengthDeg:20,tailLengthAu:.9938,note:"Visible to the naked eye for about eighteen months, longer than any comet on record."},{id:"mcnaught-2007",designation:"C/2006 P1",name:"Comet McNaught",orbit:{eccentricity:1.00001811603225,perihelionAu:.1707325614080681,inclinationDeg:77.83726446452654,ascendingNodeDeg:267.4149080498975,argumentOfPerihelionDeg:155.9756130642756,perihelionJd:2454113298753579e-9},peakMagnitude:-5.5,peakOn:"2007-01-13",absoluteMagnitude:2.53,activityExponent:4,tailLengthDeg:35,tailLengthAu:.5009,note:"The brightest comet since Ikeya-Seki, seen in daylight beside the Sun in January 2007."},{id:"lovejoy-2011",designation:"C/2011 W3",name:"Comet Lovejoy",orbit:{eccentricity:.999915056276912,perihelionAu:.005553783989325053,inclinationDeg:134.3558712062691,ascendingNodeDeg:326.3693517957772,argumentOfPerihelionDeg:53.50991655176601,perihelionJd:2455911511809431e-9},peakMagnitude:-3,peakOn:"2011-12-16",alsoRecordedMagnitude:1.5,alsoRecordedOn:"2011-12-22",absoluteMagnitude:3.51,activityExponent:1.194,note:"A sungrazer that was expected to be destroyed at perihelion and came out the other side, to stand in the southern dawn sky for the rest of December — which is the second magnitude recorded here."},{id:"panstarrs-2013",designation:"C/2011 L4",name:"Comet PANSTARRS",orbit:{eccentricity:1.000032542889696,perihelionAu:.301544229714915,inclinationDeg:84.2081978367921,ascendingNodeDeg:65.66588626213694,argumentOfPerihelionDeg:333.6516444379993,perihelionJd:2456361669960698e-9},peakMagnitude:1,peakOn:"2013-03-10",absoluteMagnitude:5.98,activityExponent:4},{id:"neowise-2020",designation:"C/2020 F3",name:"Comet NEOWISE",orbit:{eccentricity:.9991782081129224,perihelionAu:.2946512466331692,inclinationDeg:128.9375043020912,ascendingNodeDeg:61.01042991771634,argumentOfPerihelionDeg:37.2786526292898,perihelionJd:2.4590341788972816e6},peakMagnitude:.9,peakOn:"2020-07-08",absoluteMagnitude:5.79,activityExponent:4,tailLengthDeg:10,tailLengthAu:.1808,note:"The first comet since Hale-Bopp that ordinary observers in the northern hemisphere saw without being told where to look."},{id:"tsuchinshan-atlas-2024",designation:"C/2023 A3",name:"Comet Tsuchinshan-ATLAS",orbit:{eccentricity:1.000020192843226,perihelionAu:.3914228969475176,inclinationDeg:139.1105462619479,ascendingNodeDeg:21.55945689078845,argumentOfPerihelionDeg:308.4913086299446,perihelionJd:2460581242087108e-9},peakMagnitude:0,peakOn:"2024-10-14",absoluteMagnitude:3.97,activityExponent:4,tailLengthDeg:20,tailLengthAu:.1902,note:"Briefly reported far brighter around 9 October 2024, when it stood almost between the observer and the Sun and forward-scattered the light through its own dust — a geometry this catalog's brightness model does not attempt, so what is stored is the ordinary evening-sky peak a few days later."}];class OE{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(t){const e=this.julianDayOf(t);return G1.filter(i=>Math.abs(e-i.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(t,e){return this.aroundDate(t).map(i=>this.appearanceOf(i,t,e)).sort((i,n)=>i.magnitude-n.magnitude)[0]}static appearanceOf(t,e,i){const n=$e(e),s=this.earthPositionAt(n),a=this.apparentPositionOf(t,2451545+n.tt,s),o=this.subtract(a,s),c=this.length(a),l=this.length(o),h=this.tailEndAt(t,a,s,c,n,e,i),u=this.horizontalOf(o,n,e,i);return{apparition:t,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},s)),magnitude:this.magnitudeAt(t,c,l)}}static magnitudeAt(t,e,i){const n=t.absoluteMagnitude+5*Math.log10(i)+2.5*t.activityExponent*Math.log10(e);return Math.max(n,t.peakMagnitude)}static tailEndAt(t,e,i,n,s,a,o){if(t.tailLengthAu===void 0)return{};const c=1+t.tailLengthAu/n,l=this.subtract({x:e.x*c,y:e.y*c,z:e.z*c},i),h=this.subtract(e,i);return{tailEnd:this.horizontalOf(l,s,a,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(t,e,i){const n=this.orbitOf(t);let s=n.positionAt(e);for(let a=0;a<2;a++){const o=this.length(this.subtract(s,i))/this.LIGHT_SPEED_AU_PER_DAY;s=n.positionAt(e-o)}return s}static horizontalOf(t,e,i,n){const s=Ir(Tw(),new Fe(t.x,t.y,t.z,e)),a=Ir(R1(e),s),o=rw(e,new O0(n.lat,n.lng,n.elevationM)),c=new Fe(a.x-o.x,a.y-o.y,a.z-o.z,e),l=F0(c);return U0(l.ra,l.dec,i,n)}static earthPositionAt(t){return Ir(Aw(),ea(wt.Earth,t))}static julianDayOf(t){return 2451545+$e(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const i=new Ms(t.orbit);return this.orbits.set(t.id,i),i}static subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}static length(t){return Math.hypot(t.x,t.y,t.z)}static angleBetween(t,e){const i=(t.x*e.x+t.y*e.y+t.z*e.z)/(this.length(t)*this.length(e)||1);return Math.acos(Math.min(1,Math.max(-1,i)))*180/Math.PI}}const Mu=[{id:"sn-1006",kind:"supernova",designation:"SN 1006",name:"Supernova of 1006",raHours:15.03947,decDeg:-42.09694,peakMagnitude:-7.5,peakJd:2088620,startJd:2088620,lightCurve:[[0,-7.5],[29,-5.9],[60,-4.9],[106,-3.2],[166,-1.9],[258,-1],[350,.5],[364,.7],[411,1.2],[456,1.8],[484,2.5],[785.5,7]],source:"Winkler, Gupta & Long 2003 (peak); decline borrowed from SN 1572",note:"The brightest stellar event in recorded history, seen in daylight, low in the southern sky from Europe and the Near East. The decline is modelled, not recorded, and falls below the naked eye after about two years where the chronicles speak of three."},{id:"sn-1054",kind:"supernova",designation:"SN 1054",name:"Supernova of 1054",raHours:5.5755,decDeg:22.0175,peakMagnitude:-6,peakJd:2106216,startJd:2106216,lightCurve:[[0,-6],[23,-4],[642,6]],source:"Chinese chronicles (Song huiyao), via Stephenson & Green 2002",note:"The explosion that left the Crab Nebula. Its magnitude is an estimate; the two durations are recorded."},{id:"sn-1181",kind:"supernova",designation:"SN 1181",name:"Supernova of 1181",raHours:.88645,decDeg:67.50067,peakMagnitude:0,peakJd:2152636,startJd:2152636,lightCurve:[[0,0],[185,6]],source:"Chinese and Japanese chronicles, via Stephenson & Green 2002",note:"Circumpolar from Europe and China, so never set. Its peak magnitude is uncertain by at least a magnitude."},{id:"sn-1572",kind:"supernova",designation:"SN 1572",name:"Tycho's Supernova",raHours:.42264,decDeg:64.14083,peakMagnitude:-4,peakJd:2295551,startJd:2295546,lightCurve:[[0,-3],[5,-4],[34,-2.4],[65,-1.4],[111,.3],[171,1.6],[263,2.5],[355,4],[369,4.2],[416,4.7],[461,5.3],[489,6]],source:"Tycho Brahe and contemporaries, reduced by Ruiz-Lapuente 2004",note:"Circumpolar from northern Europe. Tycho showed it had no parallax, so it was not in the air: a new star, beyond the Moon."},{id:"sn-1604",kind:"supernova",designation:"SN 1604",name:"Kepler's Supernova",raHours:17.51125,decDeg:-21.48733,peakMagnitude:-2.95,peakJd:2307210,startJd:2307191,lightCurve:[[0,.23],[3,-1.3],[6,-2.08],[9,-2.17],[19,-2.95],[27,-2.95],[32,-1.95],[36,-1.52],[86,.9],[96,.45],[103,1],[114,1.2],[118,1.55],[133,1.95],[137,2.3],[170,2.25],[185,2.25],[194,2.4],[197,2.9],[308,4.45],[324,4.45],[339,4.95],[364,4.7]],source:"Kepler, Fabricius, Maestlin and the Korean court astronomers, reduced by Ruiz-Lapuente 2017",note:"The last supernova in our Galaxy seen with the naked eye. It went behind the Sun from mid-November 1604 to January 1605, which is the gap in its record."},{id:"t-crb-1866",kind:"nova",designation:"T CrB",name:"Nova Coronae Borealis 1866",raHours:15.99171,decDeg:25.92017,peakMagnitude:2,peakJd:2402734,startJd:2402734,lightCurve:[[0,2],[1.5,3],[2.5,3.11],[6.5,5.18],[8.5,5.75],[10.5,6.85],[11.5,6.8],[12.5,7.5],[16,8.18],[32,9.27],[38,9.2],[40,8.95],[44,9.4],[48,9.07],[54,9.4],[58,9.21],[79,9.44],[107,9.26],[111,9.01],[115,8.21],[119,7.96],[159,7.51],[179,7.57],[183,7.97],[191,7.66],[199,8.2],[207,8.31],[211,8.83],[215,8.65],[223,8.97],[297,8.9],[345,9.25],[377,9.07],[425,9.3],[537,9.3]],source:"Recorded peak (Birmingham); curve borrowed from its 1946 eruption",note:"The first eruption of the recurrent nova T CrB to be seen. The decline is its 1946 one."},{id:"t-aur-1891",kind:"nova",designation:"T Aur",name:"Nova Aurigae 1891",raHours:5.53309,decDeg:30.44583,peakMagnitude:4.49,peakJd:2412083,startJd:2412079,lightCurve:[[0,5.28],[4,4.49],[24,4.58],[40,4.97],[52,4.95],[56,4.5],[60,4.9],[68,4.88],[72,5.25],[76,4.93],[84,5.44],[88,7.23],[96,8.85],[100,10.44]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"gk-per-1901",kind:"nova",designation:"GK Per",name:"Nova Persei 1901",raHours:3.52,decDeg:43.90431,peakMagnitude:.19,peakJd:24154395e-1,startJd:24154377e-1,lightCurve:[[0,2.7],[.8,.86],[1.8,.19],[2.3,.2],[5.8,1.78],[11.8,2.54],[12.8,2.98],[17.8,3.62],[18.8,3.35],[19.8,3.77],[20.8,3.59],[22.8,3.95],[24.8,3.82],[25.6,4.99],[25.9,4.89],[26.6,3.69],[27.6,3.94],[27.9,4.61],[28.6,5.28],[28.9,4.46],[29.9,3.8],[30.9,4.27],[31.6,5.21],[31.9,5.22],[32.9,3.88],[33.9,4.19],[34.6,4.85],[35.6,4.8],[36.6,4.23],[37.6,4.44],[38.9,4.15],[39.7,5.19],[40.6,5.39],[40.9,5.35],[41.9,4.01],[42.6,4.5],[42.9,4.49],[43.6,5.53],[44,5.23],[44.6,5.61],[44.9,5.5],[45.9,4.17],[46.9,4.69],[47.6,5.5],[48.6,5.59],[49.6,5.14],[49.9,4.48],[50.6,4.45],[50.9,4.55],[51.6,5.47],[52.6,5.74],[53.7,5.66],[55.7,4.41],[56.7,5.43],[58.7,5.81],[58.9,5.58],[59.7,5.64],[59.9,4.76],[60.9,4.26],[61.9,5.62],[62.7,5.85],[62.9,5.53],[63.7,5.8],[64.9,4.28],[65.6,5.33],[66.7,5.87],[66.9,5.56],[68.7,5.7],[68.9,5.3],[69.7,4.47],[70.7,5.65],[72.9,5.98],[73.9,5.71],[74.7,4.98],[74.9,4.46],[75.7,4.87],[76.9,6.05],[77.6,5.76],[78,6],[78.7,5.95],[80.7,4.98],[81.9,5.85],[82.7,6.02],[84.7,5.41],[84.9,5.08],[85.7,5.17],[85.9,5.6],[87,6.1],[88.8,6.2],[89.7,4.96],[89.9,4.93],[90.7,5.9],[91.9,6.32],[92.7,5.86],[93.1,6.24],[93.7,5.38],[93.9,6.2],[96.1,6.12],[97.1,6.37],[97.6,5.12],[98,5.85],[99.3,6.35],[101.3,6.12],[101.7,5.25],[102.3,4.95],[102.7,6.12],[103.2,5.83],[104.7,6.37],[105,6.13],[106,6.22],[106.7,4.88],[107.7,6.3],[108.1,6.4],[109,6],[109.7,5.16],[110,5.82],[112.1,5.89],[113.1,5.5],[115.7,5.8],[116,6.11],[118.7,5.68],[119,6.23],[119.7,5.85],[120,6.12],[121,4.62],[121.8,5.9],[123,5.48],[125,6.05],[126,5.89],[130.9,6.11],[146.1,6.02],[155.6,6.26],[180.4,6.09],[190.4,6.39],[245.5,6.87],[266.2,6.77],[301.1,7.16],[321.5,7.07],[346.5,7.87],[375.7,7.86],[385.8,8.09],[389.8,8.55],[406.1,8.33],[416.5,8.59],[445.9,8.62],[472.1,9.24],[565.9,9.74],[571,9.4],[589.8,9.76]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"Discovered on 21 February 1901 by Thomas Anderson in Edinburgh, and the brightest nova of the century until V603 Aql."},{id:"dn-gem-1912",kind:"nova",designation:"DN Gem",name:"Nova Geminorum 1912",raHours:6.9151,decDeg:32.14108,peakMagnitude:3.58,peakJd:241947675e-2,startJd:241947275e-2,lightCurve:[[0,11.7],[1,4.5],[4,3.58],[5,4.45],[5.5,5.32],[6,5.53],[6.5,5.11],[8,5.43],[8.5,5.16],[11,5.53],[11.5,5.13],[12,5.18],[13.75,4.5],[15.75,5.3],[18.75,6],[19.75,5.55],[26.75,6],[28.75,5.9],[31.75,6.6],[32.75,6.2],[33.75,6.5],[36.75,6.55],[39.75,6.2],[40.75,6.75],[41.75,7],[44.75,6.75],[52.75,6.75],[54.75,7.23],[58.25,7.5],[62.25,7.3],[64.25,7.47],[66.25,8.1],[70.25,7.5],[72.25,8.1],[78.25,7.55],[80.25,8.2],[86.25,7.2],[90.25,7.3],[92.25,7.8],[152.25,7.2],[160.25,7.4],[166.25,8.2],[168.25,8.2],[170.25,7.3],[180.25,7.4],[182.25,8],[186.25,7.5],[190.25,7.6],[192.25,8],[211.25,7.75],[227.25,8],[275.25,7.78],[315.25,8.6],[331.25,7.79],[339.25,8.27],[363.25,8.61],[443.25,8.93],[451.25,9.2],[535.25,10.3],[567.25,9.9],[615.25,10.8],[631.25,10.63],[647.25,10.88],[679.25,10.8],[695.25,11.07],[727.25,11]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v603-aql-1918",kind:"nova",designation:"V603 Aql",name:"Nova Aquilae 1918",raHours:18.81518,decDeg:.58414,peakMagnitude:-.5,peakJd:242175475e-2,startJd:242174875e-2,lightCurve:[[0,11.3],[2,10.5],[4,6.6],[4.5,1.04],[6,-.5],[6.5,.18],[10,1.1],[10.5,.95],[12.75,1.89],[21.75,3.07],[23.75,3.76],[29.75,3.16],[34.75,3.5],[36.75,3.86],[44.75,3.79],[48.75,4.43],[52.75,3.84],[56.75,3.95],[57.75,4.04],[58.75,4.49],[59.75,4.42],[60.75,4.69],[62.75,4.6],[63.75,4.11],[64.75,3.97],[68.75,4.18],[70.75,4.65],[71.75,4.51],[73.75,4.73],[75.75,4.44],[79.75,4.85],[83.75,4.43],[89.75,4.88],[92.75,4.86],[94.75,4.58],[96.75,4.92],[99.75,5.05],[163.25,5.45],[167.25,5.7],[179.25,5.48],[191.25,5.8],[203.25,5.5],[247.25,5.9],[251.25,6.25],[257.25,5.5],[265.25,6.13],[281.25,6.33],[345.25,6.3],[385.25,6.73],[393.25,6.43],[425.25,6.71],[433.25,6.56],[461.25,7.27],[525.25,7.6],[541.25,7.47],[637.25,8.3],[669.25,8.17],[717.25,8.55],[749.25,8.4],[765.25,8.68],[885.25,8.75],[949.25,9.4],[1013.25,9.19],[1141.25,9.57],[1269.25,9.48],[1333.25,9.95],[1653.25,9.94],[1781.25,10.28],[1909.25,10.34],[2037.25,10.1],[2101.25,10.46],[2165.25,10.51],[2357.25,10.3],[2549.25,10.77],[2741.25,10.46],[2869.25,10.83],[3125.25,10.71],[3317.25,11.22],[3381.25,10.91],[3637.25,11.42],[3829.25,10.96],[3893.25,11.65],[3957.25,11.63],[4085.25,11.14],[4213.25,11.48],[4277.25,10.7],[4341.25,11.42],[4405.25,11.47],[4469.25,11.06],[4533.25,11.08],[4597.25,11.7],[4725.25,11.45],[4789.25,10.94]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"The brightest nova of the modern era, at magnitude -0.5 on 9-10 June 1918: as bright as Vega, in a summer evening sky, in wartime."},{id:"v476-cyg-1920",kind:"nova",designation:"V476 Cyg",name:"Nova Cygni 1920",raHours:19.97347,decDeg:53.61858,peakMagnitude:1.94,peakJd:242256025e-2,startJd:242255925e-2,lightCurve:[[0,2.7],[1,1.94],[3,2.07],[4.5,2.95],[8.25,4],[31.75,6.41],[35.75,7.23],[37.75,7.08],[41.75,7.33],[43.75,7.92],[45.75,8.2],[51.75,8.59],[63.75,8.82],[65.75,9.25],[71.75,8.93],[85.75,9.43],[87.75,9.05],[95.75,9.2],[97.75,8.67],[99.75,9.07],[112.75,8.78],[120.75,9.03],[128.75,8.67],[144.75,8.94],[152.75,8.73],[168.75,8.79],[176.75,9.28],[192.75,9],[216.75,9.6],[232.75,9.27],[240.75,9.5],[288.75,9.4],[296.75,9.6],[304.75,9.3],[320.75,9.73],[328.75,9.5],[336.75,9.8],[428.75,9.61],[476.75,10.01],[492.75,9.76],[508.75,9.87],[524.75,9.65],[556.75,9.87],[572.75,9.65],[620.75,10.22],[668.75,10.44],[684.75,10.23],[716.75,10.33],[756.75,10.66],[884.75,10.59],[948.75,10.96],[1108.75,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"rr-pic-1925",kind:"nova",designation:"RR Pic",name:"Nova Pictoris 1925",raHours:6.59335,decDeg:-62.64008,peakMagnitude:.95,peakJd:24243085e-1,startJd:24242995e-1,lightCurve:[[0,2.43],[5,2.35],[6,2.1],[7,2.4],[9,.95],[13,1.8],[14,1.7],[16,2.15],[18,2.2],[19,1.9],[23,3.1],[27,3.05],[31.5,3.58],[43.5,3.08],[47.5,3.15],[57.5,2.3],[59.5,1.65],[63.5,3.03],[65.5,2.84],[67.5,3.16],[69.5,2.4],[71.5,2.04],[73.5,2.05],[75.5,2.55],[79.5,3],[83.5,3.15],[116.5,3.54],[120.5,3.78],[124.5,3.67],[136.5,4.18],[148.5,4.34],[154.5,4.17],[194.5,4.43],[226.5,4.93],[234.5,4.8],[242.5,5.4],[250.5,5.5],[266.5,5.15],[298.5,5.6],[362.5,5.4],[414.5,5.7],[430.5,5.5],[494.5,6.2],[718.5,6.52],[830.5,6.3],[862.5,6.6],[878.5,6.4],[910.5,6.77],[958.5,6.67],[1062.5,7.07],[1318.5,7.35],[1590.5,8.12],[1718.5,8.25],[2486.5,8.59],[2614.5,8.47],[2742.5,8.7],[3382.5,8.6],[3766.5,8.97],[4022.5,8.79],[4150.5,9.22],[6710.5,10.29],[7414.5,11.03],[8438.5,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A slow nova, and a southern one: more than two months within two magnitudes of its peak."},{id:"dq-her-1934",kind:"nova",designation:"DQ Her",name:"Nova Herculis 1934",raHours:18.12507,decDeg:45.85906,peakMagnitude:1.56,peakJd:24277935e-1,startJd:242778675e-2,lightCurve:[[0,3.4],[1.5,2.4],[3,2.67],[5.75,2.01],[6.75,1.56],[7.75,1.59],[11.75,2.97],[12.75,2.31],[14.75,3.07],[15.75,2.56],[16.75,2.51],[19.75,2.68],[23.75,2.53],[24.75,2.27],[26.75,2.58],[30.75,2.24],[31.75,2.63],[32.75,2.66],[34.75,2.11],[39.75,2.71],[41.75,2.31],[43.75,2.37],[46.75,3.64],[47.75,3.21],[50.75,3.23],[52.75,2.66],[55.75,2.56],[58.75,2.97],[60.75,2.77],[61.75,3.36],[63.75,3.43],[64.75,2.89],[65.75,3.22],[68.75,3.52],[69.75,2.95],[70.75,3.06],[71.75,2.7],[76.75,3.65],[79.75,3.74],[81.75,3.21],[83.75,3.75],[87.75,3.69],[92.75,4.04],[94.75,4.8],[97.75,4.24],[98.75,4.52],[100.75,4.08],[101.75,4.43],[105.75,4.58],[106.75,4.33],[107.75,4.73],[108.75,6.57],[109.75,8.08],[110.75,8.15],[111.75,8.56],[113.75,8.45],[114.75,9.15],[115.75,9.15],[116.75,9.59],[117.75,9.43],[118.75,9.8],[122.75,10.5],[123.75,10.28],[124.75,10.93],[127.75,10.83],[129.75,11.87],[131.75,12.42],[135.75,12.5],[137.75,12.9],[138.75,12.77],[139.75,13],[143.75,12],[144.75,12.33],[146.75,12.35],[147.75,11.64],[148.75,11.83],[150.75,10.9],[151.75,10.78],[152.75,11.17],[154.75,10.32],[155.75,10.4],[165.25,9.24],[185.25,7.74],[225.25,6.8],[273.25,6.72],[321.25,6.97],[333.25,6.79],[353.25,7],[357.25,6.82],[377.25,6.88],[401.25,7.29],[409.25,6.8],[413.25,6.8],[419.25,7.1],[435.25,7.09],[451.25,7.4],[475.25,7],[555.25,7.48],[823.25,7.83],[855.25,8.18],[1135.25,8.43],[1823.25,9.98],[1887.25,9.71],[2015.25,10.55],[2335.25,10.95]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"Lost about ten magnitudes in a few weeks from April 1935, when dust condensed around it, then came back to naked-eye brightness."},{id:"cp-lac-1936",kind:"nova",designation:"CP Lac",name:"Nova Lacertae 1936",raHours:22.26142,decDeg:55.61703,peakMagnitude:2.02,peakJd:242834025e-2,startJd:242833825e-2,lightCurve:[[0,4.03],[.5,2.9],[1,2.45],[2,2.02],[2.5,2.61],[4,3],[4.5,3.35],[5,3.3],[9.25,4.59],[14.25,5.45],[22.25,6.03],[23.25,6.3],[26.25,6.23],[38.25,6.74],[41.25,6.61],[50.25,7.35],[53.25,7.27],[57.25,7.7],[58.25,7.54],[60.25,7.55],[61.25,7.79],[71.25,7.6],[74.25,7.81],[76.25,8.3],[77.25,7.79],[86.25,8.21],[87.25,8],[88.25,8.25],[92.25,8.17],[94.25,8.47],[102.25,8.27],[103.25,8.7],[104.25,8.4],[110.25,8.66],[116.75,8.55],[122.75,8.83],[126.75,8.7],[140.75,9.06],[154.75,9.01],[164.75,9.36],[170.75,9.18],[174.75,9.48],[186.75,9.42],[188.75,9.73],[192.75,9.53],[200.75,9.74],[202.75,9.5],[204.75,9.77],[208.75,9.6],[214.75,9.75],[216.75,10.05],[222.75,9.7],[232.75,10.03],[236.75,9.82],[250.75,10.1],[254.75,9.9],[260.75,10.1],[264.75,9.8],[266.75,10.15],[268.75,10],[274.75,10.2],[276.75,9.9],[292.75,10.6],[294.75,10.6],[298.75,10.1],[318.75,10.35],[320.75,10.6],[322.75,10.3],[328.75,10.65],[332.75,10.3],[338.75,10.7],[348.75,10.53],[350.75,10.7],[354.75,10.37],[358.75,10.58],[365.75,10.43],[373.75,10.85],[421.75,10.94]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"cp-pup-1942",kind:"nova",designation:"CP Pup",name:"Nova Puppis 1942",raHours:8.19613,decDeg:-35.35139,peakMagnitude:.73,peakJd:243067675e-2,startJd:243067275e-2,lightCurve:[[0,.95],[4,.73],[4.5,1.3],[5.5,1.47],[6,2.01],[7.75,2.88],[8.75,2.97],[10.75,3.5],[11.75,4.02],[13.75,4.4],[14.75,3.8],[17.75,5],[18.75,4.93],[19.75,5.48],[23.75,5.5],[25.75,5.65],[26.75,5.99],[33.25,6.28],[45.25,6.6],[57.25,6.41],[81.25,6.85],[89.25,6.5],[97.25,6.67],[101.25,7],[113.25,6.66],[125.25,7.1],[135.25,6.96],[231.25,7.86],[279.25,7.8],[327.25,8.33],[407.25,8.18],[423.25,8.59],[471.25,8.53],[503.25,8.99],[551.25,8.97],[567.25,8.7],[583.25,9.47],[615.25,8.95],[655.25,9.5],[751.25,9.55],[815.25,10.09],[847.25,10.02],[879.25,10.48],[911.25,10.34],[1023.25,10.79],[1279.25,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"One of the fastest bright novae: two magnitudes gone in four days."},{id:"t-crb-1946",kind:"nova",designation:"T CrB",name:"Nova Coronae Borealis 1946",raHours:15.99171,decDeg:25.92017,peakMagnitude:2.5,peakJd:2431860,startJd:2431860,lightCurve:[[0,2.5],[1.5,3.5],[2.5,3.61],[6.5,5.68],[8.5,6.25],[10.5,7.35],[11.5,7.3],[12.5,8],[16,8.68],[32,9.77],[38,9.7],[40,9.45],[44,9.9],[48,9.57],[54,9.9],[58,9.71],[79,9.94],[107,9.76],[111,9.51],[115,8.71],[119,8.46],[159,8.01],[179,8.07],[183,8.47],[191,8.16],[199,8.7],[207,8.81],[211,9.33],[215,9.15],[223,9.47],[297,9.4],[345,9.75],[377,9.57],[425,9.8],[537,9.8]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A recurrent nova. It erupted in 1866 and in 1946, and a third eruption was expected from 2024 on."},{id:"v446-her-1960",kind:"nova",designation:"V446 Her",name:"Nova Herculis 1960",raHours:18.956,decDeg:13.24147,peakMagnitude:4.83,peakJd:24370038e-1,startJd:24370033e-1,lightCurve:[[0,5.2],[.5,4.83],[2,4.9],[2.5,5.4],[3,5.05],[3.5,5.57],[4,5.25],[5,5.5],[6.5,5.4],[7.2,5.78],[8.2,5.6],[9.2,5.98],[10.2,5.92],[11.2,6.21],[16.2,6.1],[17.2,6.23],[18.2,7.2],[19.2,6.51],[20.2,6.78],[26.2,6.97],[27.2,7.24],[28.2,7.13],[29.2,7.45],[31.2,7.2],[40.7,7.57],[44.7,8.25],[46.7,7.84],[56.7,8.15],[60.7,8.9],[70.7,8.7],[72.7,8.14],[76.7,8.71],[80.7,8.47],[82.7,8.87],[86.7,8.57],[90.7,8.93],[107.7,9.11],[111.7,8.94],[115.7,9.27],[139.7,9.38],[151.7,9.91],[155.7,9.72],[173.7,10.51],[221.7,10.95]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v533-her-1963",kind:"nova",designation:"V533 Her",name:"Nova Herculis 1963",raHours:18.23902,decDeg:41.85614,peakMagnitude:3,peakJd:24380605e-1,startJd:24380565e-1,lightCurve:[[0,8],[4,3],[4.5,3],[8,4],[13,3.95],[15,4.6],[21,4.53],[24,5.05],[27,5.15],[32,4.76],[34,4.98],[35,5.39],[37,5.43],[41,6.04],[49,6.02],[56.5,6.34],[60.5,6.11],[74.5,6.72],[102.5,6.99],[137.5,7.81],[197.5,8.31],[217.5,8.8],[225.5,8.57],[233.5,9.03],[237.5,8.78],[277.5,9.44],[301.5,9.46],[315.5,9.86],[323.5,9.73],[339.5,10.05],[355.5,10.74],[363.5,10.32],[371.5,10.6],[387.5,10.69],[427.5,10.38],[435.5,10.84],[443.5,10.74],[451.5,11.33],[459.5,10.98],[467.5,11.17],[507.5,11.16],[539.5,11.66],[603.5,11.7],[619.5,12.05],[651.5,12.03],[659.5,11.74],[667.5,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"hr-del-1967",kind:"nova",designation:"HR Del",name:"Nova Delphini 1967",raHours:20.70565,decDeg:19.16092,peakMagnitude:3.58,peakJd:2439838,startJd:2439646,lightCurve:[[0,11.9],[6,11.8],[12,8.8],[16,8.3],[20,6.7],[30,5.8],[36,5.51],[66,5.55],[78,5.35],[86,4.89],[96,5],[108,4.75],[136,5.13],[152,4.83],[182,4.93],[186,4.59],[192,3.58],[202,5],[220,5.46],[226,5.14],[230,5.45],[232,5.14],[236,5],[242,5.08],[244,4.59],[246,4.45],[254,5.3],[256,4.75],[260,5.69],[268,4.8],[274,4.94],[276,5.45],[280,5.2],[282,5.51],[286,5.58],[292,4.95],[294,5.16],[298,4.94],[311,5.09],[335,4.4],[367,5.76],[407,6.16],[423,6.55],[603,7.43],[907,8.32],[1451,9.41],[2347,10.75]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"An exceptionally slow nova: rose over months and stayed near magnitude 4 to 5 for most of 1967 and 1968."},{id:"lv-vul-1968",kind:"nova",designation:"LV Vul",name:"Nova Vulpeculae 1968",raHours:19.80012,decDeg:27.1715,peakMagnitude:4.5,peakJd:243996425e-2,startJd:243996325e-2,lightCurve:[[0,5],[1,4.5],[2,5],[2.5,4.86],[3,5.1],[3.5,4.88],[4,5.1],[5,4.9],[7,5.4],[8,5.23],[10.5,5.42],[12,5.82],[13,5.4],[13.5,5.74],[14,5.7],[14.5,6.08],[15,5.75],[15.5,5.86],[16,5.6],[17,5.8],[18,5.6],[20.5,6.34],[21,6.2],[22.5,6.84],[23,6.57],[24,6.98],[24.5,6.3],[25,7.1],[26,6.65],[34.25,7.48],[35.25,7.23],[39.25,7.32],[44.25,7.76],[45.25,7.49],[46.25,7.78],[50.25,7.84],[51.25,8.1],[53.25,7.9],[54.25,8.13],[56.25,8],[57.75,8.24],[67.75,8.52],[75.75,8.38],[83.75,8.69],[89.75,8.59],[125.75,9.32],[127.75,9.33],[129.75,8.98],[131.75,9.29],[135.75,9.43],[212.75,9.9],[220.75,10.16],[228.75,10.03],[236.75,10.3],[244.75,10.16],[264.75,10.54],[280.75,10.45],[296.75,10.79],[328.75,10.78]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"fh-ser-1970",kind:"nova",designation:"FH Ser",name:"Nova Serpentis 1970",raHours:18.51307,decDeg:2.61444,peakMagnitude:4.5,peakJd:244063425e-2,startJd:244063125e-2,lightCurve:[[0,7],[2,5],[3,4.5],[3.5,5],[4.5,4.6],[5.5,5],[6.5,4.68],[12.25,4.66],[16.25,5.3],[17.25,5.72],[18.25,5.3],[19.25,5.2],[23.25,5.84],[24.25,5.68],[27.25,5.9],[30.25,5.47],[32.25,5.9],[34.25,5.7],[43.25,6.28],[45.25,6.1],[50.25,6.62],[52.25,6.47],[57.25,6.63],[60.25,7.08],[61.25,6.87],[62.25,7.2],[63.25,6.85],[64.25,7.68],[65.25,7.3],[66.25,8.3],[67.25,7.93],[69.25,9.15],[71.25,9.2],[72.25,9.63],[74.25,9.9],[76.25,9.7],[77.25,10.25],[78.25,10.1],[79.25,10.4],[80.25,10.23],[81.25,10.57],[83.25,10.64],[85.25,10.35],[86.25,11.2],[87.25,10.1],[89.25,11.2],[96.25,11.35],[100.25,11.95],[102.25,11.1],[104.25,11.65],[106.25,11.5],[108.25,12.07],[114.75,11.32],[118.75,11.28],[122.75,10.93],[130.75,10.85],[134.75,10.52],[154.75,10.65],[162.75,10.12],[174.75,9.98],[178.75,10.34],[186.75,9.98],[214.75,10.25],[224.75,10.02],[240.75,10.2],[264.75,10],[272.75,10.2],[280.75,10.05],[288.75,10.4],[296.75,10],[348.75,10.7],[396.75,10.3],[444.75,10.73],[460.75,10.59],[540.75,10.94],[556.75,10.82]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v1500-cyg-1975",kind:"nova",designation:"V1500 Cyg",name:"Nova Cygni 1975",raHours:21.19349,decDeg:48.15056,peakMagnitude:1.88,peakJd:244265525e-2,startJd:244265425e-2,lightCurve:[[0,2.44],[1,1.88],[1.5,1.88],[2.5,2.41],[3,3.38],[4,4.28],[8.25,5.81],[11.25,6.46],[22.25,7.35],[33.25,7.73],[34.25,7.97],[37.25,7.86],[40.25,8.3],[43.25,8.19],[48.25,8.6],[49.25,8.46],[66.25,9.04],[70.25,8.93],[75.25,9.23],[76.25,9.03],[80.25,9.39],[81.25,9.19],[83.25,9.35],[84.25,9.13],[86.25,9.39],[89.25,9.32],[90.25,9.54],[93.25,9.37],[105.75,9.86],[193.75,10.43],[201.75,10.7],[209.75,10.47],[257.75,10.94],[265.75,10.81]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"One of the fastest novae on record: discovered on 29 August 1975, at its peak of magnitude 1.9 within two days, and two magnitudes down again two days later."},{id:"v842-cen-1986",kind:"nova",designation:"V842 Cen",name:"Nova Centauri 1986",raHours:14.59794,decDeg:-57.6265,peakMagnitude:4.9,peakJd:244675975e-2,startJd:244675725e-2,lightCurve:[[0,5.6],[2.5,4.9],[3.5,5.1],[15.5,5.1],[17.5,5.75],[18.5,5.4],[20.5,5.5],[22.5,5.95],[30.5,6.15],[31.5,6.3],[32,7.5],[34.5,7.2],[38.5,7.5],[39,7],[41.5,7.15],[42.5,6.7],[44.5,7.23],[45.5,6.6],[53,9.3]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"sn-1987a",kind:"supernova",designation:"SN 1987A",name:"Supernova 1987A",raHours:5.59111,decDeg:-69.26975,peakMagnitude:2.98,peakJd:24469425e-1,startJd:24468495e-1,lightCurve:[[0,6.36],[1,6.11],[2,4.63],[4,4.45],[32,3.97],[56,3.15],[93,2.98],[105,3.35],[118,4.11],[134,4.43],[504,8.15],[617,10.27]],source:"V photometry compiled by the Open Supernova Catalog (Sternberg catalogue, IAU circulars, CTIO)",note:"In the Large Magellanic Cloud, 160 000 light years away: the nearest supernova since Kepler's, and invisible north of about 20° N."},{id:"v1974-cyg-1992",kind:"nova",designation:"V1974 Cyg",name:"Nova Cygni 1992",raHours:20.50879,decDeg:52.63078,peakMagnitude:4.27,peakJd:24486753e-1,startJd:24486718e-1,lightCurve:[[0,7.2],[1,5.23],[2,4.62],[3.5,4.27],[4.5,4.59],[6,4.5],[7,4.78],[7.5,4.52],[8,4.82],[10.7,5.25],[11.7,5.66],[16.7,5.85],[21.7,6.47],[22.7,6.3],[27.7,6.46],[29.7,6.83],[34.7,6.9],[35.7,7.25],[36.7,7],[37.7,7.16],[39.7,7.03],[43.7,7.41],[45.7,7.26],[50.7,7.45],[57.7,7.78],[58.7,8.13],[61.7,7.92],[64.7,8.19],[65.7,7.99],[71.7,8.22],[76.7,8.01],[128.2,8.72],[176.2,8.89],[192.2,9.15],[216.2,9.28],[232.2,9.07],[236.2,9.3],[390.2,10.99]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v382-vel-1999",kind:"nova",designation:"V382 Vel",name:"Nova Velorum 1999",raHours:10.74678,decDeg:-52.42533,peakMagnitude:2.88,peakJd:245132225e-2,startJd:245132075e-2,lightCurve:[[0,2.99],[1.5,2.88],[2.5,3.46],[4.5,3.98],[5,4.32],[5.5,4.23],[7.5,4.85],[21.75,6.67],[30.25,7.2],[40.25,7.41],[93.25,7.95],[97.25,8.25],[101.25,8],[113.25,7.96],[129.25,8.5],[155.25,8.47],[163.25,9.1],[179.25,9],[187.25,8.7],[195.25,9.15],[211.25,9.23],[235.25,9.8],[243.25,9.71],[299.25,10.42],[383.25,10.52],[415.25,10.81]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v1494-aql-1999",kind:"nova",designation:"V1494 Aql",name:"Nova Aquilae 1999",raHours:19.38482,decDeg:4.9555,peakMagnitude:4.11,peakJd:245151575e-2,startJd:245151425e-2,lightCurve:[[0,5.15],[.5,4.86],[1,4.27],[1.5,4.11],[2.5,4.35],[5,5.48],[10.5,6.26],[14.25,6.28],[20.25,7.43],[24.25,7.25],[25.25,7.63],[27.25,7.7],[29.25,7.42],[33.25,8.08],[35.25,8.03],[36.25,7.6],[37.25,7.6],[46.25,8.5],[54.25,8.28],[56.25,8.63],[58.25,8.4],[61.25,9.53],[62.25,9],[64.25,9.13],[69.25,8.58],[70.25,8.9],[72.25,8.88],[75.25,8.57],[77.25,9],[79.25,8.8],[81.25,9.7],[83.25,9.6],[85.25,9.8],[86.75,9.5],[88.75,9.54],[90.75,8.9],[92.75,8.85],[96.75,9.63],[102.75,9.7],[104.75,8.98],[106.75,8.73],[116.75,9.63],[118.75,9.6],[120.75,9.07],[122.75,9.26],[124.75,9.8],[128.75,9.36],[134.75,9.75],[147.75,9.92],[155.75,9.81],[259.75,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v4743-sgr-2002",kind:"nova",designation:"V4743 Sgr",name:"Nova Sagittarii 2002",raHours:19.01926,decDeg:-22.00167,peakMagnitude:5,peakJd:245253775e-2,startJd:245253675e-2,lightCurve:[[0,5.2],[1,5],[2,5.89],[2.5,5.91],[3.5,6.43],[5,6.45],[5.5,6.86],[6,6.59],[7,6.77],[7.5,7.31],[8.5,6.99],[9,7.09],[10.5,7.86],[11,7.58],[11.5,7.89],[15.75,8.33],[17.75,8.18],[18.75,8.58],[19.75,8.44],[22.75,8.83],[23.75,8.6],[24.75,8.85],[27.75,8.83],[30.75,9.4],[31.75,9.09],[36.25,9.08],[38.25,9.34],[62.25,9.75],[66.25,10.1],[70.25,9.7],[74.25,10],[171.25,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"rs-oph-2006",kind:"nova",designation:"RS Oph",name:"Nova Ophiuchi 2006",raHours:17.83699,decDeg:-6.70792,peakMagnitude:4.8,peakJd:2453779,startJd:2453779,lightCurve:[[0,4.8],[1.25,4.97],[2.75,5.78],[3.25,5.7],[3.75,6.24],[4.25,6.05],[4.75,6.38],[5.25,6.3],[8.5,7.25],[14.5,7.95],[24.5,8.55],[29.5,9.08],[48,9.87],[80,10.28],[107,11.54],[119,11.54],[139,11.98],[147,11.83],[163,12.03],[171,11.97],[175,11.65],[183,11.84],[195,11.64],[203,11.8],[207,12.13],[219,11.45],[277,11.68],[325,11],[341,11.53],[357,11.62],[373,11.3],[405,11.5],[421,11.17],[469,10.96],[501,11.22],[549,10.75],[581,11.08],[597,10.98]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A recurrent nova, erupting every twenty years or so (1898, 1907, 1933, 1945, 1958, 1967, 1985, 2006, 2021)."},{id:"v1280-sco-2007",kind:"nova",designation:"V1280 Sco",name:"Nova Scorpii 2007",raHours:16.96145,decDeg:-32.34325,peakMagnitude:3.8,peakJd:2454149,startJd:2454136,lightCurve:[[0,9.7],[13,3.8],[34,5.8],[103,15]],source:"AAVSO (discovery, peak, dust minimum); t2 from Das et al. 2008",note:"Faded from sight quickly when dust formed around it, three weeks after its peak."},{id:"v339-del-2013",kind:"nova",designation:"V339 Del",name:"Nova Delphini 2013",raHours:20.39186,decDeg:20.76772,peakMagnitude:4.4,peakJd:24565214e-1,startJd:24565214e-1,lightCurve:[[0,4.4],[11,6.4],[20,7.4]],source:"Gehrz et al. 2015 (peak, t2, t3)",note:"High in the summer evening sky of the northern hemisphere, and widely photographed."},{id:"v1369-cen-2013",kind:"nova",designation:"V1369 Cen",name:"Nova Centauri 2013",raHours:13.9126,decDeg:-59.15114,peakMagnitude:3.48,peakJd:245663965e-2,startJd:24566285e-1,lightCurve:[[0,5.33],[1.57,4.08],[2.75,3.73],[4.57,4.16],[5.96,4.15],[10.26,3.77],[11.15,3.48],[12.14,3.74],[14.17,4.78],[15.46,4.97],[23.16,4.22],[26.25,4.32],[27.31,4.82],[29.56,5.11],[32.66,4.71],[33.84,4.86],[36.05,4.46],[37.15,4.99],[41.42,4.59],[42.37,4.93],[43.37,4.82],[44.54,5.09],[49.95,5.38],[51.99,5.82],[54.21,5.77]],source:"AAVSO, binned by day, as plotted by Izzo 2017 (arXiv:1704.07214, figure 1)",note:"Discovered on 2 December 2013 by John Seach at magnitude 5.5, it flared several times, reaching about 3.3 around 14 December: the brightest nova of the century so far, and a southern one."},{id:"rs-oph-2021",kind:"nova",designation:"RS Oph",name:"Nova Ophiuchi 2021",raHours:17.83699,decDeg:-6.70792,peakMagnitude:4.6,peakJd:2459436,startJd:2459435,lightCurve:[[0,5],[1,4.6],[2.25,4.77],[3.75,5.58],[4.25,5.5],[4.75,6.04],[5.25,5.85],[5.75,6.18],[6.25,6.1],[9.5,7.05],[15.5,7.75],[25.5,8.35],[30.5,8.88],[49,9.67],[81,10.08],[108,11.34],[120,11.34],[140,11.78],[148,11.63],[164,11.83],[172,11.77],[176,11.45],[184,11.64],[196,11.44],[204,11.6],[208,11.93],[220,11.25],[278,11.48],[326,10.8],[342,11.33],[358,11.42],[374,11.1],[406,11.3],[422,10.97],[470,10.76],[502,11.02],[550,10.55],[582,10.88],[598,10.78]],source:"Recorded discovery and peak (8 and 9 August 2021); curve borrowed from its 2006 eruption",note:"RS Oph's latest eruption, discovered on 8 August 2021. The decline is its 2006 one."}];class Km{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(t){const e=this.julianDayOf(t);return Mu.filter(i=>this.magnitudeAt(i,e)!==void 0)}static appearancesAt(t,e){const i=this.julianDayOf(t),n=[];for(const s of Mu){const a=this.magnitudeAt(s,i);a!==void 0&&n.push({outburst:s,position:Pn.ofJ2000(s.raHours,s.decDeg,t,e),magnitude:a})}return n.sort((s,a)=>s.magnitude-a.magnitude)}static brightestAt(t,e){return this.appearancesAt(t,e)[0]}static byId(t){return Mu.find(e=>e.id===t)}static magnitudeAt(t,e){const i=t.lightCurve,n=e-t.startJd;if(i.length===0||n<i[0][0]||n>i[i.length-1][0])return;let s=1;for(;s<i.length-1&&i[s][0]<n;)s++;const[a,o]=i[s-1]??i[0],[c,l]=i[s]??i[0];if(c===a)return o;const h=Math.min(1,Math.max(0,(n-a)/(c-a)));return o+h*(l-o)}static julianDayOf(t){return t.getTime()/864e5+this.UNIX_EPOCH_JD}}const NE=[{id:"quadrantids",code:"QUA",name:"Quadrantids",radiantRaHours:15.33,radiantDecDeg:49.7,start:{month:12,day:28},peak:{month:1,day:3},end:{month:1,day:12},peakZhr:110,velocityKmS:41,populationIndex:2.1},{id:"lyrids",code:"LYR",name:"April Lyrids",radiantRaHours:18.13,radiantDecDeg:33.3,start:{month:4,day:16},peak:{month:4,day:22},end:{month:4,day:25},peakZhr:18,velocityKmS:49,populationIndex:2.1},{id:"eta-aquariids",code:"ETA",name:"eta Aquariids",radiantRaHours:22.53,radiantDecDeg:-1,start:{month:4,day:19},peak:{month:5,day:6},end:{month:5,day:28},peakZhr:50,velocityKmS:66,populationIndex:2.4},{id:"alpha-capricornids",code:"CAP",name:"alpha Capricornids",radiantRaHours:20.47,radiantDecDeg:-9.2,start:{month:7,day:3},peak:{month:7,day:30},end:{month:8,day:15},peakZhr:5,velocityKmS:23,populationIndex:2.5},{id:"southern-delta-aquariids",code:"SDA",name:"Southern delta Aquariids",radiantRaHours:22.67,radiantDecDeg:-16.4,start:{month:7,day:12},peak:{month:7,day:30},end:{month:8,day:23},peakZhr:25,velocityKmS:41,populationIndex:3.2},{id:"perseids",code:"PER",name:"Perseids",radiantRaHours:3.22,radiantDecDeg:58,start:{month:7,day:17},peak:{month:8,day:12},end:{month:8,day:24},peakZhr:100,velocityKmS:59,populationIndex:2.2},{id:"southern-taurids",code:"STA",name:"Southern Taurids",radiantRaHours:3.47,radiantDecDeg:13,start:{month:9,day:10},peak:{month:10,day:10},end:{month:11,day:20},peakZhr:5,velocityKmS:27,populationIndex:2.3},{id:"draconids",code:"DRA",name:"October Draconids",radiantRaHours:17.47,radiantDecDeg:54,start:{month:10,day:6},peak:{month:10,day:8},end:{month:10,day:10},peakZhr:10,velocityKmS:20,populationIndex:2.6},{id:"orionids",code:"ORI",name:"Orionids",radiantRaHours:6.35,radiantDecDeg:15.6,start:{month:10,day:2},peak:{month:10,day:21},end:{month:11,day:7},peakZhr:20,velocityKmS:66,populationIndex:2.5},{id:"northern-taurids",code:"NTA",name:"Northern Taurids",radiantRaHours:3.87,radiantDecDeg:22,start:{month:10,day:20},peak:{month:11,day:12},end:{month:12,day:10},peakZhr:5,velocityKmS:29,populationIndex:2.3},{id:"leonids",code:"LEO",name:"Leonids",radiantRaHours:10.13,radiantDecDeg:21.6,start:{month:11,day:6},peak:{month:11,day:17},end:{month:11,day:30},peakZhr:15,velocityKmS:71,populationIndex:2.5},{id:"geminids",code:"GEM",name:"Geminids",radiantRaHours:7.47,radiantDecDeg:32.3,start:{month:12,day:4},peak:{month:12,day:14},end:{month:12,day:17},peakZhr:150,velocityKmS:35,populationIndex:2.6},{id:"ursids",code:"URS",name:"Ursids",radiantRaHours:14.47,radiantDecDeg:75.3,start:{month:12,day:17},peak:{month:12,day:22},end:{month:12,day:26},peakZhr:10,velocityKmS:33,populationIndex:3}],Fl=6.5;class xu{static activeAt(t){return NE.flatMap(e=>{const i=this.nearness(e,t);return i<=0?[]:[{shower:e,zhr:e.peakZhr*i,nearness:i}]})}static nearness(t,e){const i=this.dayOfYear(e),n=this.dayOfYear(this.asDate(t.start)),s=this.dayOfYear(this.asDate(t.peak)),a=this.dayOfYear(this.asDate(t.end)),o=this.wrappedDelta(i,s),c=this.wrappedDelta(s,n),l=this.wrappedDelta(a,s);return o<0?o<-c?0:1+o/c:o>0?o>l?0:1-o/l:1}static observedRatePerHour(t,e,i,n=Fl){if(e<=0)return 0;const s=Fl-n;return t*Math.sin(e*Math.PI/180)/Math.pow(i,s)}static radiantPosition(t,e,i){return Pn.ofJ2000(t.radiantRaHours,t.radiantDecDeg,e,i)}static dayOfYear(t){const e=Date.UTC(t.getUTCFullYear(),0,1);return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-e)/864e5)+1}static asDate(t){return new Date(Date.UTC(2001,t.month-1,t.day))}static wrappedDelta(t,e){const i=t-e;return i>182?i-365:i<-182?i+365:i}}class ti{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const i=$e(t),n=new Kl(0,sw(t).elon-90,1),s=Ir(Dw(i),N0(n,i)),a=F0(s);return U0(a.ra,a.dec,t,e)}static observedRatePerHour(t,e=Fl){const i=ti.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),n=Fl-e;return(ti.QUIET_RATE_PER_HOUR+i)/Math.pow(ti.POPULATION_INDEX,n)}static schedule(t){const e=new jl(t.seed^1542469173);return Ca.schedule(t).map(i=>{const n=ti.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),s=i.fromRadiantDeg*Math.PI/180,a=ti.turnAround(n,e.between(0,360)),o={x:n.x*Math.cos(s)+a.x*Math.sin(s),y:n.y*Math.cos(s)+a.y*Math.sin(s),z:n.z*Math.cos(s)+a.z*Math.sin(s)};return{...i,radiant:ti.toHorizontal(o),bearingDeg:ti.bearingFrom(o,n)}})}static turnAround(t,e){const[i,n]=ti.basisAround(t),s=e*Math.PI/180;return{x:i.x*Math.cos(s)+n.x*Math.sin(s),y:i.y*Math.cos(s)+n.y*Math.sin(s),z:i.z*Math.cos(s)+n.z*Math.sin(s)}}static bearingFrom(t,e){const[i,n]=ti.basisAround(t),s=t.x*e.x+t.y*e.y+t.z*e.z,a=ti.normalise({x:e.x-t.x*s,y:e.y-t.y*s,z:e.z-t.z*s});return(Math.atan2(a.x*n.x+a.y*n.y+a.z*n.z,a.x*i.x+a.y*i.y+a.z*i.z)*180/Math.PI%360+360)%360}static basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=ti.normalise(ti.cross(t,e));return[i,ti.normalise(ti.cross(t,i))]}static toHorizontal(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,t.y/e)))*180/Math.PI,azimuthDeg:(Math.atan2(t.x,-t.z)*180/Math.PI%360+360)%360}}static appearanceOf(t){const e=ti.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),i=ti.turnAround(e,t.bearingDeg),n=t.fromRadiantDeg*Math.PI/180;return ti.toHorizontal({x:e.x*Math.cos(n)+i.x*Math.sin(n),y:e.y*Math.cos(n)+i.y*Math.sin(n),z:e.z*Math.cos(n)+i.z*Math.sin(n)})}static toCartesian(t){const e=t.altitudeDeg*Math.PI/180,i=t.azimuthDeg*Math.PI/180,n=Math.cos(e);return{x:n*Math.sin(i),y:Math.sin(e),z:-n*Math.cos(i)}}static cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}static normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}static TYPICAL_VELOCITY_KM_S=40}const Zm="https://ufoathome.org/tle/index.json";class Ii{static MAX_ELEMENT_AGE_DAYS=7;static DAY_MS=864e5;fetchImpl;indexUrls;index;files=new Map;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Ii.defaultIndexUrls()}static defaultIndexUrls(){const t=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&t.push(new URL("/tle/index.json",location.href).href),t.includes(Zm)||t.push(Zm),t}static FIRST_SNAPSHOT="2021-02-22";async covers(t){const e=Date.parse(`${Ii.FIRST_SNAPSHOT}T00:00:00Z`)-Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS;if(t.getTime()<e)return!1;const i=await this.loadIndex();return i?Object.values(i.index.kinds).some(n=>t.getTime()>=Date.parse(n.from)-Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS&&t.getTime()<=Date.parse(n.to)+Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS):!1}async at(t){const e=await this.loadIndex();if(!e)return;const{index:i,base:n}=e,s=[],a=[];for(const o of Object.keys(i.kinds)){const c=await this.kindAt(o,t,i,n);s.push(...c),a.push(this.coverageOf(o,t,i,c.length>0))}return{objects:s,coverage:a,credit:i.credit,creditUrl:i.source}}async kindAt(t,e,i,n){const s=e.getTime(),a=i.binDays*Ii.DAY_MS,o=Math.floor(s/a),c=s-o*a<a/2?o-1:o+1,l=new Set(i.kinds[t].bins),h=[o,c].map(v=>new Date(v*a).toISOString().slice(0,10)).filter(v=>l.has(v));if(h.length===0)return[];const[u,...d]=await Promise.all([this.json(new URL(`objects-${t}.json`,n).href),...h.map(v=>this.binary(new URL(`${t}/${v}.bin`,n).href))]),f=new Map;for(const v of d)for(const m of Ii.decode(v,i.recordBytes)){const g=f.get(m.norad);(!g||Math.abs(m.epochMs-s)<Math.abs(g.epochMs-s))&&f.set(m.norad,m)}const p=[];for(const v of f.values()){const m=Math.abs(v.epochMs-s)/Ii.DAY_MS;if(m>Ii.MAX_ELEMENT_AGE_DAYS)continue;const g=u[v.norad]??{name:String(v.norad)};g.launch&&Date.parse(`${g.launch}T00:00:00Z`)>s||p.push({norad:v.norad,name:g.name,kind:t,launch:g.launch,stdMag:g.stdMag,elements:v,ageDays:m})}return p}coverageOf(t,e,i,n){const{from:s,to:a}=i.kinds[t],o=e.getTime(),c=Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS,l=n?"covered":o<Date.parse(s)-c?"before":o>Date.parse(a)+c?"after":"gap";return{kind:t,status:l,from:s,to:a}}static decode(t,e){const i=new DataView(t),n=[];for(let s=0;s+e<=t.byteLength;s+=e)n.push({norad:i.getUint32(s,!0),epochMs:i.getFloat64(s+4,!0),bstar:i.getFloat32(s+12,!0),inclinationDeg:i.getFloat32(s+16,!0),raanDeg:i.getFloat32(s+20,!0),eccentricity:i.getFloat32(s+24,!0),argOfPerigeeDeg:i.getFloat32(s+28,!0),meanAnomalyDeg:i.getFloat32(s+32,!0),meanMotion:i.getFloat64(s+36,!0)});return n}loadIndex(){return this.index??=(async()=>{for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;return{index:await e.json(),base:t}}catch{}})(),this.index}json(t){return this.cached(t,async e=>e.json())}binary(t){return this.cached(t,async e=>e.arrayBuffer())}cached(t,e){let i=this.files.get(t);return i||(i=this.fetchImpl(t).then(n=>{if(!n.ok)throw new Error(`${t}: ${n.status}`);return e(n)}),i.catch(()=>this.files.delete(t)),this.files.set(t,i)),i}}class FE{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const i=Te.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(e.inFrontM!==void 0){const i=Te.sizeMAt(e.inFrontM,t);this.upperM=this.upperM===void 0?i:Math.min(this.upperM,i)}}}get sizeRange(){return{minM:this.lowerM,maxM:this.upperM}}get empty(){return this.lowerM===void 0&&this.upperM===void 0}get contradictory(){return this.lowerM!==void 0&&this.upperM!==void 0&&this.lowerM>this.upperM}distanceRangeAt(t){return t<=0?{}:{minM:this.lowerM===void 0?void 0:Te.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:Te.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class La{static DEG_PER_SECOND=360/86164.0905;static degOver(t){return Math.max(0,t)*La.DEG_PER_SECOND}static instants(t,e){if(!(e>0))return 1;const i=La.degOver(t)/e;return i<1?1:Math.min(La.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class zi{static EYE={apertureMm:7,exposureSeconds:.1,resolutionArcsec:60};static WAVELENGTH_M=55e-8;static ARCSEC_PER_RADIAN=180*3600/Math.PI;static UNKNOWN_CAMERA_FOCAL_MM=50;static UNKNOWN_CAMERA_DETAIL_UM=20;static get skyDriftArcsecPerSecond(){return La.DEG_PER_SECOND*3600}static graspOf(t,e={}){const i=e.exposureSeconds??t.exposureSeconds,n=e.fNumber??t.fNumber;if(i===void 0||n===void 0||!(i>0)||!(n>0))return zi.EYE;const s=e.focalLengthMm??t.frame?.focalLengthMm??zi.UNKNOWN_CAMERA_FOCAL_MM,a=s/n,o=zi.resolutionArcsec(t,s,a);return{apertureMm:a,exposureSeconds:Math.min(i,zi.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(t,e,i){const s=(t.detailUm??zi.UNKNOWN_CAMERA_DETAIL_UM)/1e3/e*zi.ARCSEC_PER_RADIAN,a=1.22*zi.WAVELENGTH_M/(i/1e3)*zi.ARCSEC_PER_RADIAN;return Math.max(s,a)}static trailLimitedSeconds(t){return t/zi.skyDriftArcsecPerSecond}static gainOverEye(t,e={}){const i=zi.graspOf(t,e),n=zi.EYE,s=(i.apertureMm/n.apertureMm)**2,a=i.exposureSeconds/n.exposureSeconds,o=(n.resolutionArcsec/i.resolutionArcsec)**2;return 1.25*Math.log10(s*a*o)}static gainFor(t,e){const i=e.fieldOfViewDeg===void 0?void 0:fi.focalLengthMmFor(t,e.fieldOfViewDeg);return zi.gainOverEye(t,{fNumber:e.fNumber,focalLengthMm:i,exposureSeconds:e.exposureSeconds})}}const Jm=111320,fo=Math.PI/180,UE=1.02,kE=1;class Do{static of(t,e){const i=Do.sightings(t,e);if(i.length<2)return;const n=Do.baseline(i);if(!n)return;const{near:s,far:a,closedM:o}=n,c=Math.tan(a.widthDeg/2*fo)===0?0:Math.tan(s.widthDeg/2*fo)/Math.tan(a.widthDeg/2*fo);if(c<UE)return;const l=o/(c-1),h=Te.sizeMAt(l,s.widthDeg),u=i.map(d=>({t:d.t,m:Te.distanceMAt(h,d.widthDeg)}));return{widthM:h,distanceM:u,nearestM:Math.min(...u.map(d=>d.m)),fromT:a.t,toT:s.t,closedM:o}}static sightings(t,e){return t.timeline.allKeyframes.flatMap(i=>{const n=i.shapes.find(o=>o.sourceId===e)?.shape,s=n?.angular?.widthDeg,a=di(t,i.t);return s===void 0||s<=0||a?.lat===void 0||a.lng===void 0?[]:[{t:i.t,widthDeg:s,lat:a.lat,lng:a.lng,sightAzimuthDeg:n?.aim?.azimuthDeg??a.headingDeg}]}).sort((i,n)=>i.t-n.t)}static baseline(t){let e;for(const i of t)for(const n of t){if(i.t>=n.t)continue;const s=Do.closedAlongSight(i,n),[a,o,c]=s>=0?[n,i,s]:[i,n,-s];c<kE||a.widthDeg<=o.widthDeg||(!e||c>e.closedM)&&(e={near:a,far:o,closedM:c})}return e}static closedAlongSight(t,e){const i=(e.lat-t.lat)*Jm,n=(e.lng-t.lng)*Jm*Math.cos(t.lat*fo),s=(t.sightAzimuthDeg??0)*fo;return i*Math.cos(s)+n*Math.sin(s)}}class ki{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(t){if(t.statedM!==void 0&&t.statedM>0)return{distanceM:ki.atLeastNearest(t.statedM),basis:"stated"};if(t.hypothesisM!==void 0&&t.hypothesisM>0)return{distanceM:ki.atLeastNearest(t.hypothesisM),basis:"hypothesis"};if(t.derivedM!==void 0&&t.derivedM>0)return{distanceM:ki.atLeastNearest(t.derivedM),basis:"derived"};const e=ki.largest(t.range?.minM,t.crossing?.behindM),i=ki.smallest(t.range?.maxM,t.crossing?.inFrontM),n=e===void 0?void 0:e*ki.MARGIN,s=i===void 0?void 0:i/ki.MARGIN;return n!==void 0&&s!==void 0?{distanceM:ki.atLeastNearest(n<=s?Math.sqrt(n*s):n),basis:"bounded"}:n!==void 0?{distanceM:ki.atLeastNearest(n),basis:"bounded"}:s!==void 0&&s<ki.CONVENTIONAL_M?{distanceM:ki.atLeastNearest(s),basis:"bounded"}:{distanceM:ki.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(t){return Math.max(ki.NEAREST_M,t)}static largest(...t){const e=t.filter(i=>i!==void 0&&i>0);return e.length===0?void 0:Math.max(...e)}static smallest(...t){const e=t.filter(i=>i!==void 0&&i>0);return e.length===0?void 0:Math.min(...e)}}const yu=Math.PI/180;class te{constructor(t,e,i){this.body=t,this.ground=e;const n=[...t.track].sort((s,a)=>s.t-a.t);this.keys=this.place(n,i);for(const s of n)te.collect(this.motionKeys,s.t,s.motions),te.collect(this.lightKeys,s.t,s.lights)}static EYE_HEIGHT_M=1.6;static MAX_RANGE_M=3e4;static DEFAULT_SIZE={widthM:1,lengthM:1,heightM:1};static DEFAULT_APPEARANCE={color:"#c8c8c8",albedo:.5,luminanceCdM2:0};keys;motionKeys=new Map;lightKeys=new Map;static collect(t,e,i){for(const[n,s]of Object.entries(i??{})){const a=t.get(n)??[];a.push({t:e,value:s}),t.set(n,a)}}motionsAt(t){return te.channelsAt(this.motionKeys,t,0)}lightsAt(t){return this.lightKeys.size>0?te.channelsAt(this.lightKeys,t,void 0):void 0}static channelsAt(t,e,i){const n={};for(const[s,a]of t){let o=a.length-1;for(;o>=0&&a[o].t>e;)o--;if(o<0){i!==void 0&&(n[s]=i);continue}const c=a[o],l=a[Math.min(o+1,a.length-1)],h=l===c||l.t===c.t?0:Math.min(1,(e-c.t)/(l.t-c.t));n[s]=te.lerp(c.value,l.value,h)}return n}static eyeOf(t,e,i){const n=di(t,0),s=di(t,e),o=n?.lat!==void 0&&n.lng!==void 0&&s?.lat!==void 0&&s.lng!==void 0?ai(s.lat,s.lng,n.lat,n.lng):void 0,c=o?o.x:0,l=o?-o.z:0;return{eastM:c,northM:l,upM:i.heightAt(c,l)+te.EYE_HEIGHT_M+(s?.elevationM??0),headingDeg:s?.headingDeg}}static lineOfSightMeetsGround(t,e,i,n){const s=te.directionOf(e,i),a=l=>t.upM+s.upM*l-n.heightAt(t.eastM+s.eastM*l,t.northM+s.northM*l);let o=0,c=0;for(;c<te.MAX_RANGE_M;){if(c=o+Math.max(.5,o*.01),a(c)<=0){for(let l=0;l<30;l++){const h=(o+c)/2;a(h)<=0?c=h:o=h}return c}o=c}}static directionOf(t,e){const i=t*yu,n=e*yu;return{eastM:Math.sin(i)*Math.cos(n),northM:Math.cos(i)*Math.cos(n),upM:Math.sin(n)}}at(t){const e=this.keys;if(e.length===0||t<e[0].t)return;let i=e.length-1;for(;i>0&&e[i].t>t;)i--;const n=e[i];if(!n.present)return;const s=e[Math.min(i+1,e.length-1)],a=s===n||s.t===n.t?0:Math.min(1,(t-n.t)/(s.t-n.t)),o=te.lerp(n.eastM,s.eastM,a),c=te.lerp(n.northM,s.northM,a),l={widthM:te.lerp(n.sizeM.widthM,s.sizeM.widthM,a),lengthM:te.lerp(n.sizeM.lengthM,s.sizeM.lengthM,a),heightM:te.lerp(n.sizeM.heightM,s.sizeM.heightM,a)},h={headingDeg:te.lerpAngle(n.attitude.headingDeg,s.attitude.headingDeg,a),pitchDeg:te.lerp(n.attitude.pitchDeg,s.attitude.pitchDeg,a),rollDeg:te.lerp(n.attitude.rollDeg,s.attitude.rollDeg,a)};let u;if("aboveGroundM"in n.vertical&&"aboveGroundM"in s.vertical){const d=te.lerp(n.vertical.aboveGroundM,s.vertical.aboveGroundM,a);u=this.groundUnderFootprint(o,c,l,h.headingDeg)+d+l.heightM/2}else u=te.lerp(this.centreUpOf(n),this.centreUpOf(s),a);return{id:this.body.id,model:this.body.model,explains:this.body.explains??[],outlineNode:this.body.outlineNode,eastM:o,northM:c,upM:u,sizeM:l,attitude:h,appearance:{color:(a<1?n:s).appearance.color,albedo:te.lerp(n.appearance.albedo,s.appearance.albedo,a),luminanceCdM2:te.lerp(n.appearance.luminanceCdM2,s.appearance.luminanceCdM2,a)},flame:te.flameBetween(n.flame,s.flame,a),motions:this.motionsAt(t),lights:this.lightsAt(t),throwsFlame:this.body.track.some(d=>d.flame!==void 0&&d.flame.luminanceCdM2>0)}}static flameBetween(t,e,i){if(!t||t.luminanceCdM2<=0)return i>=1&&e&&e.luminanceCdM2>0?e:void 0;const n=t,s=e??t,a={...i<1?n:s,lengthM:te.lerp(n.lengthM,s.lengthM,i),widthM:te.lerp(n.widthM,s.widthM,i),luminanceCdM2:te.lerp(n.luminanceCdM2,s.luminanceCdM2,i)};return a.luminanceCdM2>0?a:void 0}centreUpOf(t){return"upM"in t.vertical?t.vertical.upM:this.groundUnderFootprint(t.eastM,t.northM,t.sizeM,t.attitude.headingDeg)+t.vertical.aboveGroundM+t.sizeM.heightM/2}groundUnderFootprint(t,e,i,n){const s=n*yu,a={eastM:Math.cos(s),northM:-Math.sin(s)},o={eastM:Math.sin(s),northM:Math.cos(s)};let c=this.ground.heightAt(t,e);for(const[l,h]of[[-1,-1],[1,-1],[-1,1],[1,1]]){const u=l*i.widthM/2,d=h*i.lengthM/2;c=Math.max(c,this.ground.heightAt(t+a.eastM*u+o.eastM*d,e+a.northM*u+o.northM*d))}return c}place(t,e){const i=[];let n;for(const s of t){const a=s.sizeM??n?.sizeM??te.DEFAULT_SIZE,o={headingDeg:s.attitude?.headingDeg??n?.attitude.headingDeg??0,pitchDeg:s.attitude?.pitchDeg??n?.attitude.pitchDeg??0,rollDeg:s.attitude?.rollDeg??n?.attitude.rollDeg??0},c={color:s.appearance?.color??n?.appearance.color??te.DEFAULT_APPEARANCE.color,albedo:s.appearance?.albedo??n?.appearance.albedo??te.DEFAULT_APPEARANCE.albedo,luminanceCdM2:s.appearance?.luminanceCdM2??n?.appearance.luminanceCdM2??te.DEFAULT_APPEARANCE.luminanceCdM2},l=this.positionOf(s,e)??(n&&{eastM:n.eastM,northM:n.northM,vertical:this.verticalOf(s)??n.vertical});if(!l)continue;const h=s.flame??n?.flame,u=s.present??n?.present??!0;n={t:s.t,...l,sizeM:a,attitude:o,appearance:c,flame:h,present:u},i.push(n)}return i}verticalOf(t){if(t.onGround)return{aboveGroundM:0};if(t.altitudeAboveGroundM!==void 0)return{aboveGroundM:t.altitudeAboveGroundM}}positionOf(t,e){if(t.eastM!==void 0&&t.northM!==void 0)return{eastM:t.eastM,northM:t.northM,vertical:this.verticalOf(t)??{aboveGroundM:0}};if(t.azimuthDeg===void 0||t.altitudeDeg===void 0)return;const i=e(t.t);if(!i)return;const n=t.distanceM??(t.onGround?te.lineOfSightMeetsGround(i,t.azimuthDeg,t.altitudeDeg,this.ground):void 0);if(n===void 0)return;const s=te.directionOf(t.azimuthDeg,t.altitudeDeg),a=i.eastM+s.eastM*n,o=i.northM+s.northM*n;return{eastM:a,northM:o,vertical:this.verticalOf(t)??{upM:i.upM+s.upM*n}}}static lerp(t,e,i){return t+(e-t)*i}static lerpAngle(t,e,i){const n=((e-t)%360+540)%360-180;return((t+n*i)%360+360)%360}}const hr=Math.PI/180,po=180/Math.PI;class Qe{constructor(t){this.timeline=t}static DIRECTION_TOLERANCE_DEG=1;static SIZE_TOLERANCE=1.5;static RINGS=12;static SEGMENTS=24;at(t,e,i,n){const s=[];for(const a of e){const o=Qe.projectionOf(a,i,n?.(a));if(o)for(const c of a.explains){const l=this.timeline.getInterpolatedShapeAt(t,c);!l||l.transparency>=1||s.push({...Qe.compare(c,a.id,{aim:l.aim,angular:l.angular},o),title:l.title})}}return s}static compare(t,e,i,n){const s=[],a=i.aim?Qe.separationDeg(i.aim,n.aim):void 0;if(a!==void 0){const l=Math.max(i.angular?.widthDeg??0,n.angular.widthDeg)/2;a>Math.max(Qe.DIRECTION_TOLERANCE_DEG,l)&&s.push("direction")}const o=i.angular&&i.angular.widthDeg>0?n.angular.widthDeg/i.angular.widthDeg:void 0,c=i.angular&&i.angular.heightDeg>0?n.angular.heightDeg/i.angular.heightDeg:void 0;return o!==void 0&&!Qe.withinSize(o)&&s.push("width"),c!==void 0&&!Qe.withinSize(c)&&s.push("height"),{sourceId:t,bodyId:e,stated:i,predicted:n,separationDeg:a,widthRatio:o,heightRatio:c,disagreements:s}}static projectionOf(t,e,i){const n=i&&i.length>0?i:Qe.outlineOf(t),s=i&&i.length>0?Qe.centreOf(i):t,a=Qe.normalized({eastM:s.eastM-e.eastM,northM:s.northM-e.northM,upM:s.upM-e.upM});if(!a)return;const o=Qe.normalized({eastM:a.northM,northM:-a.eastM,upM:0})??{eastM:1,northM:0,upM:0},c=Qe.cross(o,a);let l=1/0,h=-1/0,u=1/0,d=-1/0;for(const f of n){const p={eastM:f.eastM-e.eastM,northM:f.northM-e.northM,upM:f.upM-e.upM},v=Qe.dot(p,a);if(v<=0)return;const m=Math.atan2(Qe.dot(p,o),v),g=Math.atan2(Qe.dot(p,c),v);l=Math.min(l,m),h=Math.max(h,m),u=Math.min(u,g),d=Math.max(d,g)}return{aim:{azimuthDeg:(Math.atan2(a.eastM,a.northM)*po+360)%360,altitudeDeg:Math.asin(Math.max(-1,Math.min(1,a.upM)))*po},angular:{widthDeg:(h-l)*po,heightDeg:(d-u)*po}}}static centreOf(t){const e=i=>(Math.min(...t.map(n=>n[i]))+Math.max(...t.map(n=>n[i])))/2;return{eastM:e("eastM"),northM:e("northM"),upM:e("upM")}}static separationDeg(t,e){const i=t.altitudeDeg*hr,n=e.altitudeDeg*hr,s=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((t.azimuthDeg-e.azimuthDeg)*hr);return Math.acos(Math.max(-1,Math.min(1,s)))*po}static withinSize(t){return t<=Qe.SIZE_TOLERANCE&&t>=1/Qe.SIZE_TOLERANCE}static outlineOf(t){const e=t.sizeM.widthM/2,i=t.sizeM.lengthM/2,n=t.sizeM.heightM/2,s=[],a=t.model.url===void 0?t.model.id:void 0;if(a!==void 0&&a!=="box"&&z1.includes(a))for(let u=0;u<=Qe.RINGS;u++){const d=u/Qe.RINGS*Math.PI;for(let f=0;f<Qe.SEGMENTS;f++){const p=f/Qe.SEGMENTS*2*Math.PI;s.push([e*Math.sin(d)*Math.cos(p),i*Math.sin(d)*Math.sin(p),n*Math.cos(d)])}}else for(const u of[-e,e])for(const d of[-i,i])for(const f of[-n,n])s.push([u,d,f]);const c=t.attitude.headingDeg*hr,l=t.attitude.pitchDeg*hr,h=t.attitude.rollDeg*hr;return s.map(([u,d,f])=>{const p=u*Math.cos(h)+f*Math.sin(h),v=-u*Math.sin(h)+f*Math.cos(h),m=d*Math.cos(l)-v*Math.sin(l),g=d*Math.sin(l)+v*Math.cos(l);return{eastM:t.eastM+p*Math.cos(c)+m*Math.sin(c),northM:t.northM-p*Math.sin(c)+m*Math.cos(c),upM:t.upM+g}})}static dot(t,e){return t.eastM*e.eastM+t.northM*e.northM+t.upM*e.upM}static cross(t,e){return{eastM:t.northM*e.upM-t.upM*e.northM,northM:t.upM*e.eastM-t.eastM*e.upM,upM:t.eastM*e.northM-t.northM*e.eastM}}static normalized(t){const e=Math.hypot(t.eastM,t.northM,t.upM);return e>1e-9?{eastM:t.eastM/e,northM:t.northM/e,upM:t.upM/e}:void 0}}vg();const zE={sun:"Sun",moon:"Moon",Venus:"Venus",Mars:"Mars",Jupiter:"Jupiter",Saturn:"Saturn"},BE="{name} — mag {mag}, {alt}° above the horizon",HE="{name} — satellite, mag {mag}, {height} km up",GE="satellites-change",VE="rr0-confrontation",WE="{name} — mag {mag}, {alt}° below the horizontal",_u="Credits",jm="comet:",Qm="nova:",XE={building:"Building",tree:"Tree",shrub:"Shrub",bridge:"Bridge",crop:"Crop row",mound:"Stone heap",streetlight:"Streetlight",vehicle:"Vehicle",observer:"Observer",aircraft:"Aircraft",entity:"Being"},YE=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,qE=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,$E=-18,KE={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},Su={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class B0 extends HTMLElement{creditsButton;set ownCredits(t){this.creditsButton.hidden=!t}static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",yr,_r]}shadow;stageElement;frameElement;sceneCanvas;loaderNote;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;distanceHypotheses=new Map;depths=new Map;directionScratch=new R;meteorScheduleFor;lightningScheduleFor;lightningFlashes=[];lastLightningT;lastTimeMs=0;interpretationShown;confrontationReadings=[];confrontationSignature="";comparing=!1;inTheRound=!0;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new Ii;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;starCatalogDepth=0;weatherAudio=new LE;vehicleAudio=new j1;vehicleHearing=new ul;animateWhilePausedValue=!1;set animateWhilePaused(t){t!==this.animateWhilePausedValue&&(this.animateWhilePausedValue=t,this.syncAnimationsToPlayback())}get animateWhilePaused(){return this.animateWhilePausedValue}thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=t=>{this.sceneRenderer.setCompassHovered(!0);const e=this.ufoElement.canvasElement,i=e.getBoundingClientRect();if(i.width===0||i.height===0)return;const n=(t.clientX-i.left)/i.width*e.width,s=(t.clientY-i.top)/i.height*e.height;if(this.ufoElement.hasVisibleShapeAt(n,s)){this.hoverTooltip.hidden=!0;return}const a=(t.clientX-i.left)/i.width*2-1,o=-((t.clientY-i.top)/i.height*2-1),c=this.naming,l=c.names,h=this.sceneRenderer.pickBodyAt(a,o);if(h){this.showHoverTooltip(t,this.bodyName(h));return}const u=this.sceneRenderer.pickDecorAt(a,o),d=u?this.ufoElement.sighting.decor.find(v=>v.id===u):void 0;if(d){this.showHoverTooltip(t,this.said.read(d.title)||c.decorKind(d.kind,XE[d.kind]));return}const f=this.sceneRenderer.pickSatelliteAt(a,o);if(f){this.showHoverTooltip(t,(l?.satelliteTooltip??HE).replace("{name}",f.name).replace("{mag}",f.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(f.heightKm).toLocaleString()));return}const p=this.sceneRenderer.pickStarAt(a,o);if(p){const v=p.star.mag,m=p.altitudeDeg,g=m<0?l?.starTooltipBelow??WE:l?.starTooltip??BE;this.showHoverTooltip(t,g.replace("{name}",c.star(p.star)).replace("{mag}",v.toLocaleString(void 0,{maximumFractionDigits:Math.abs(v)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(m)))));return}this.hoverTooltip.hidden=!0};bodyName(t){const e=t.startsWith(jm)?t.slice(jm.length):void 0,i=e?G1.find(a=>a.id===e):void 0;if(i)return this.naming.comet(i);const n=t.startsWith(Qm)?Km.byId(t.slice(Qm.length)):void 0;if(n)return this.naming.nova(n);const s=zE[t];return s===void 0?t:this.naming.body(t,s)}get naming(){return this.sceneNaming}sceneNaming=new $m;namesLanguage="en";async loadSceneNames(){const t=ag(fl.preferencesFor(this),rg);if(t===this.namesLanguage)return;this.namesLanguage=t;const e=await Bv(t);t===this.namesLanguage&&this.applySceneNaming(new $m(e))}applySceneNaming(t){this.sceneNaming=t;const e=t.names?.credits??_u;this.creditsButton.title=e,this.creditsButton.setAttribute("aria-label",e),t.names&&(this.loaderNote.textContent=t.names.notAVideo),this.sceneRenderer.setCompassPoints(t.names?.compassPoints)}showHoverTooltip(t,e){this.hoverTooltip.textContent=e,this.hoverTooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${t.clientX-i.left+12}px`,this.hoverTooltip.style.top=`${t.clientY-i.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash(t){clearTimeout(this.thunderTimeoutId),this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),pi.thunderDelayMs(t))}handleFirstInteraction=()=>{this.removeEventListener("pointerdown",this.handleFirstInteraction,!0),this.removeEventListener("keydown",this.handleFirstInteraction,!0),this.weatherAudio.resume(),this.vehicleAudio.resume(),this.setWeather(sf(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=t=>{this.lastTimeMs=t.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"&&this.sceneRenderer.frame(performance.now())};syncAnimationsToPlayback(){const t=this.ufoElement.playbackState==="playing",e=t||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(e,t),this.weatherAudio.setPaused(!e),this.vehicleAudio.setPaused(!e),e||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${nv}</style>${iv}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new ke(this.sceneCanvas);const e=this.shadow.getElementById("scene-loader");this.loaderNote=this.shadow.getElementById("scene-loader-note"),this.sceneRenderer.onFirstFrameHold=s=>{e.hidden=!s},this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(Eu),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",s=>this.lookToward(s.detail)),this.ufoElement.style.setProperty("--ufo-canvas-background","transparent"),this.ufoElement.style.setProperty("--ufo-canvas-border","none"),this.ufoElement.fullscreenTarget=this.stageElement,this.shadow.getElementById("ufo-slot").replaceWith(this.ufoElement),this.ufoElement.creditShownExternally=!0,this.creditsButton=this.shadow.getElementById("credits-button");const i=this.shadow.getElementById("credits-panel"),n=this.shadow.getElementById("credits-list");i.addEventListener("beforetoggle",s=>{s.newState==="open"&&$n.fill(n,this)}),this.creditsButton.title=_u,this.creditsButton.setAttribute("aria-label",_u),this.sceneRenderer.onMapSubjectBounds=s=>this.ufoElement.setMapSubjectBounds(s),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.seekPreviewPainter=(s,a)=>this.seekPreviewOf(a).paint(s,a),this.ufoElement.addEventListener("mutedchange",()=>this.weatherAudio.setLevel(this.ufoElement.level)),this.ufoElement.addEventListener("referenceview",s=>this.applyReferenceView(s.detail)),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave),this.addEventListener("pointerdown",this.handleFirstInteraction,!0),this.addEventListener("keydown",this.handleFirstInteraction,!0)}get said(){return this.saidTexts??=new $s(fl.preferencesFor(this))}saidTexts;connectedCallback(){this.saidTexts=void 0,this.loadSceneNames(),this.sceneRenderer.restoreContext(),this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),document.addEventListener("fullscreenchange",this.handleFullscreenChange);const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose(),this.vehicleAudio.dispose(),this.seekPreview?.dispose(),this.seekPreview=void 0,queueMicrotask(()=>{this.isConnected||this.sceneRenderer.releaseContext()})}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),(t==="star-catalog-src"||t==="deep-star-catalog-src")&&i!==e&&this.isConnected&&this.loadStars(),t==="show-compass"&&i!==e&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),t==="max-pixel-ratio"&&i!==e){const n=Number(i);this.sceneRenderer.setMaxPixelRatio(Number.isFinite(n)&&n>0?n:Math.min(window.devicePixelRatio||1,2))}(t===yr||t===_r)&&i!==e&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const t of[yr,_r]){const e=this.getAttribute(t);e===null?this.ufoElement.removeAttribute(t):this.ufoElement.setAttribute(t,e)}}setCompassForced(t){this.sceneRenderer.setCompassForced(t)}lookToward(t){const e=di(this.ufoElement.sighting,this.lastTimeMs);if(t.kind==="observer"||e?.lat===void 0||e.lng===void 0||e.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:i,z:n}=ai(t.lat,t.lng,e.lat,e.lng);if(Math.hypot(i,n)<1)return this.setLookOffset(0,0);const s=(Math.atan2(i,-n)*180/Math.PI+360)%360;this.setLookOffset(((s-e.headingDeg)%360+540)%360-180,-e.pitchDeg)}setLookOffset(t,e){this.sceneRenderer.setLookOffset(t,e),this.ufoElement.setLookOffset(t,e),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(t,e){this.sceneRenderer.setIndoorLook(t,e)}setCloudRendering(t){this.sceneRenderer.setCloudRendering(t)}setWeather(t){this.sceneRenderer.setWeather(t),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity*(t.precipitationAmount??1),t.windSpeed)}pickCloudAt(t,e){return this.sceneRenderer.pickCloudAt(t,e)}cloudDirectionAt(t,e){return this.sceneRenderer.cloudDirectionAt(t,e)}pickDecorAt(t,e){return this.sceneRenderer.pickDecorAt(t,e)}bodyScreenBox(t){return this.sceneRenderer.bodyScreenBox(t)}pickPlacedBodyAt(t,e){return this.sceneRenderer.pickPlacedBodyAt(t,e)}resumeWeatherAudio(){this.weatherAudio.resume(),this.vehicleAudio.resume()}async loadFromSrc(t){const e=ng.json(t);this.holdForNewScene(e);const i=await e;this.documentUrl=new URL(t,location.href).href,this.sightingData=i}holdForNewScene(t){this.sceneRenderer.holdForNewScene(t)}get documentUrl(){return this.sceneRenderer.documentUrl}set documentUrl(t){this.sceneRenderer.documentUrl=t}get sightingData(){return this.ufoElement.sightingData}set sightingData(t){this.ufoElement.sightingData=t,this.seekPreview?.recordingChanged(t),this.interpretationShown=this.inTheRound?this.ufoElement.sighting.interpretation:void 0,this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}seekPreview;seekPreviewOf(t){const e=this.sceneCanvas.width>0&&this.sceneCanvas.height>0?this.sceneCanvas.width/this.sceneCanvas.height:1.7777777777777777,i=Math.round(t.width/e);return t.height!==i&&(t.height=i),this.seekPreview??=new Nl(this,()=>document.createElement(Kd))}showAt(t){this.ufoElement.currentTime=t,this.framesAtAsk=this.sceneRenderer.framesDrawn}framesAtAsk=0;snapshotTo(t){if(this.sceneRenderer.frame(performance.now()),this.sceneRenderer.framesDrawn===this.framesAtAsk)return!1;const e=t.getContext("2d");return e?(e.drawImage(this.sceneCanvas,0,0,t.width,t.height),!0):!1}referenceAspect(t){return this.sceneRenderer.referenceAspect(t)}screenPointOf(t){return this.sceneRenderer.screenPointOf(t)}directionAt(t,e){return this.sceneRenderer.directionAt(t,e)}referenceFailedToLoad(t){return this.sceneRenderer.referenceFailedToLoad(t)}applyReferenceView(t){this.sceneRenderer.setReferencesShown(t.shown);for(const e of this.ufoElement.sighting.references)this.sceneRenderer.setReferenceView(e.id,{opacity:t.opacity})}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}get currentRoadAttribution(){return this.sceneRenderer.currentRoadAttribution}setTerrainProviders(t){this.sceneRenderer.setTerrainProviders(t)}setDecorModelProvider(t){this.sceneRenderer.setDecorModelProvider(t)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const t=this.ufoElement.sighting.instrument,e=Te.CANVAS_HEIGHT_PX,i=fi.frameWidthPx(t,e);this.frameElement.style.setProperty("--frame-aspect",`${i} / ${e}`)}resizeToStage(){const t=this.frameElement.getBoundingClientRect(),e=Math.max(1,Math.round(t.width)),i=Math.max(1,Math.round(t.height));this.sceneCanvas.width=e,this.sceneCanvas.height=i,this.sceneRenderer.resize(e,i)}async loadStars(){const t=[{magnitudeLimit:gu,url:this.getAttribute("star-catalog-src")??YE},{magnitudeLimit:vu,url:this.getAttribute("deep-star-catalog-src")??qE}],e=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=e>gu?vu:gu;const n=await qn.upTo(t,e);i===this.starCatalogRequest&&(this.starCatalog=n,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=vu||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const t=this.ufoElement.sighting,e=zi.gainFor(t.instrument,{fNumber:di(t,0)?.fNumber,fieldOfViewDeg:Ji.fovOf(t,0),exposureSeconds:t.exposure});return Ed($E,e)}updateAstronomy(t){this.ensureStarsDeepEnough(),this.applySceneAt(t);const e=Cn.windowEndingAt(t,this.exposureSeconds()),i=e.seconds,n=this.degreesPerPixelAt(t),s=La.instants(i,n),a=Math.max(s,this.ufoElement.exposureTimes(t).length,Cn.instants(this.ufoElement.sighting.decor,di(this.ufoElement.sighting,t)?.elevationM??0,e.fromMs,i,n));if(a<=1){this.sceneRenderer.setExposure(1);return}this.sceneRenderer.setExposure(a,o=>this.applySceneAt(e.fromMs+e.ms*o/(a-1),{sky:Math.floor(o*s/a)!==Math.floor((o-1)*s/a),stepMs:e.ms/a}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(t){const e=this.sceneCanvas.height;return e<=0?0:Ji.fovOf(this.ufoElement.sighting,t)/e}applySceneAt(t,e){const i=this.ufoElement.sighting;this.setWeather(sf(i,t)),this.sceneRenderer.setInstrument(i.instrument),this.sceneRenderer.setLightPollution(i.lightPollution),e||this.vehicleAudio.setVoices(this.vehicleHearing.at(i,t)),this.updateMeteorShower(i,t),this.updateLightning(i,t,e!==void 0),this.sceneRenderer.setDecor(i.decor);const n=di(i,t);this.sceneRenderer.setReferences(i.references,n?.lat!==void 0&&n.lng!==void 0?{lat:n.lat,lng:n.lng}:void 0);const s=di(i,0),a=Gr(i,0),o=Object.fromEntries(dl(Gr(i,t)).map(y=>[y.id,Q0(t,i.weatherTrack,a,s,n,y.id)]));this.sceneRenderer.setCloudOffset(Q0(t,i.weatherTrack,a,s,n),o),this.sceneRenderer.setObserverPose(n??Su),this.sceneRenderer.setLensOptics(this.lensOpticsAt(t)),this.sceneRenderer.setInstrumentGain(zi.gainFor(i.instrument,{fNumber:n?.fNumber,fieldOfViewDeg:Ji.fovOf(i,t),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0),this.sceneRenderer.setMedium(i.instrument.medium,i.exposure,n?.fNumber??i.instrument.fNumber,i.iso),this.sceneRenderer.setGait(_e.bodyAt(i,t,this.ufoElement.steadyObserver)),this.sceneRenderer.updateDecorAnchoring(di(i,0),n,t),this.placeBodiesAt(t,e===void 0),this.sceneRenderer.updateDecorLitState(t,e?.stepMs??0),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng,()=>{this.placeBodiesAt(this.lastTimeMs,!0),this.sceneRenderer.render()}),this.sceneRenderer.setStatedRoads(i.roads),this.pushPhenomenaAt(t);const c=n?.lat??Su.lat,l=n?.lng??Su.lng,h=Bc(i.event.time??{},l,i.event.utcOffsetHours),u={lat:c,lng:l,elevationM:n?.elevationM??0};if(this.pushSatellitesAt(h,t,u),e&&!e.sky)return;if(!h){this.sceneRenderer.setAstronomy(KE);return}const d=new Date(h.getTime()+t),f=Math.max(1,Math.round(.25*this.degreesPerPixelAt(t)/La.DEG_PER_SECOND*1e3)),p=Math.max(1e-8,this.degreesPerPixelAt(t)*.1),v=`${Math.floor(d.getTime()/f)}|${Math.round(c/p)}|${Math.round(l/p)}|${Math.round(u.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(v===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=v;const m={...qh("Sun",d,u),magnitude:$h("Sun",d)},g={...qh("Moon",d,u),phase:Cw(d),magnitude:$h("Moon",d)},S=Iw.map(y=>({body:y,position:qh(y,d,u),magnitude:$h(y,d)}));this.sceneRenderer.setAstronomy({sun:m,moon:g,planets:S,comet:this.cometAt(d,u),novae:Km.appearancesAt(d,u).map(({outburst:y,position:M,magnitude:b})=>({id:y.id,position:M,magnitude:b})),stars:this.starCatalog?{catalog:this.starCatalog,date:d,observer:u}:void 0,frame:{date:d,observer:u}}),this.ufoElement.setSunAltitude(m.altitudeDeg)}pushSatellitesAt(t,e,i){if(this.ensureSatellites(t),!t||!this.satellites){this.sceneRenderer.setSatellites([]);return}const n=new Date(t.getTime()+e),s=[];for(const a of this.satellites.passes.positionsAt(n,i,-1))a.magnitude!==void 0&&s.push({norad:a.object.norad,name:a.object.name,position:{altitudeDeg:a.altitudeDeg,azimuthDeg:a.azimuthDeg},magnitude:a.magnitude,heightKm:a.heightKm});this.sceneRenderer.setSatellites(s)}ensureSatellites(t){const e=t?String(t.getTime()):"";if(e===this.satellitesFor)return;this.satellitesFor=e,this.satellites=void 0,this.satellitePassesMemo=void 0;const i=++this.satelliteRequest;if(!t){this.satelliteStatus="none";return}this.satelliteStatus="loading";const n=a=>{i===this.satelliteRequest&&(this.satelliteStatus=a,this.isConnected&&this.dispatchEvent(new CustomEvent(GE)))},s=B0.tleArchive;(async()=>{if(!await s.covers(t))return n("outside");const[a,o]=await Promise.all([s.at(t),is(()=>import("./SatellitePasses-Pfro2-0Z.js"),[],import.meta.url)]);if(i===this.satelliteRequest){if(!a)return n("unavailable");this.satellites={snapshot:a,passes:new o.SatellitePasses(a.objects)},n("ready"),this.isConnected&&this.updateAstronomy(this.lastTimeMs)}})().catch(()=>n("unavailable"))}get satelliteState(){const t=this.satellites?.snapshot;return{status:this.satelliteStatus,coverage:t?.coverage,credit:t?.credit,creditUrl:t?.creditUrl}}satellitePassesDuring(t){const e=this.satellites,i=this.ufoElement.sighting,n=di(i,0),s=i.event.place?.[0],a=n?.lat??s?.lat,o=n?.lng??s?.lng;if(!e||a===void 0||o===void 0)return[];const c=Bc(i.event.time??{},o,i.event.utcOffsetHours);if(!c)return[];const l=Math.min(Math.max(t,0),4*36e5),h={lat:a,lng:o,elevationM:n?.elevationM??0},u=JSON.stringify([this.satellitesFor,c.getTime(),a,o,h.elevationM,l]);if(this.satellitePassesMemo?.key===u)return this.satellitePassesMemo.passes;const d=Math.max(10,Math.ceil(l/1e3/600)),f=e.passes.passesDuring(c,new Date(c.getTime()+l),h,d);return this.satellitePassesMemo={key:u,passes:f},f}cometAt(t,e){const i=OE.brightestAt(t,e);if(i)return{id:i.apparition.id,position:i.position,tailEnd:i.tailEnd,magnitude:i.magnitude}}pushPhenomenaAt(t){const e=this.ufoElement.sighting;e!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=e);const i=e.timeline,n=this.ufoElement.canvasElement,s=this.ufoElement.frameShiftPx,a=this.projectionAt(t),o=new Map,c=new Map,l=new Set;for(const p of i.sourceIds){const v=i.getInterpolatedShapeAt(t,p);if(!v)continue;const m={...v,bounds:{...v.bounds,x:v.bounds.x+s.x,y:v.bounds.y+s.y}};o.set(p,m);const g=v.aim?this.sceneRenderer.screenPointOf(In.directionOf(v.aim,this.directionScratch)):{ndcX:(m.bounds.x+m.bounds.width/2)/n.width*2-1,ndcY:-((m.bounds.y+m.bounds.height/2)/n.height*2-1)},S=g!==void 0&&Math.abs(g.ndcX)<=1&&Math.abs(g.ndcY)<=1,y=S?this.sceneRenderer.decorDistancesAt(g.ndcX,g.ndcY,p):{};l.add(p),(S||v.aim)&&l.delete(p);const M=v.angular?.widthDeg??a.pxToDeg(v.bounds.width),b=this.sizeEstimateOf(p);b.add(M,y);const w=Do.of(e,p);c.set(p,ki.resolve({hypothesisM:this.distanceHypotheses.get(p),derivedM:w&&M>0?Te.distanceMAt(w.widthM,M):void 0,range:b.distanceRangeAt(M),crossing:y}))}for(const[p,v]of o)for(const[m,g]of o){if(m===p||g.transparency>=1||g.bounds.width*g.bounds.height<=v.bounds.width*v.bounds.height||!(v.bounds.x>=g.bounds.x&&v.bounds.y>=g.bounds.y&&v.bounds.x+v.bounds.width<=g.bounds.x+g.bounds.width&&v.bounds.y+v.bounds.height<=g.bounds.y+g.bounds.height))continue;const y=c.get(m);y&&c.set(p,{distanceM:y.distanceM*.999,basis:y.basis});break}this.depths=c;const h=i.sourceIds,u=[];for(const[p,v]of o)u.push({sourceId:p,shape:v,distanceM:c.get(p).distanceM,renderOrder:h.indexOf(p),aim:v.aim,hidden:l.has(p)||this.interpretationShown!==void 0&&(!this.comparing||v.transparency>=1),ghost:this.interpretationShown!==void 0&&this.comparing});const f=(di(e,t)?.rollDeg??0)+_e.bodyAt(e,t,this.ufoElement.steadyObserver).rollDeg;this.sceneRenderer.setPhenomena(u,{projection:a,canvasWidthPx:n.width,canvasHeightPx:n.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,n.height)),starPoints:fi.starPointsOf(e.instrument),rollRad:f*Math.PI/180})}get interpretation(){return this.interpretationShown}set interpretation(t){this.interpretationShown=t,this.updateAstronomy(this.lastTimeMs)}get accountInTheRound(){return this.inTheRound}set accountInTheRound(t){this.inTheRound=t}get compareAccount(){return this.comparing}set compareAccount(t){this.comparing=t,this.updateAstronomy(this.lastTimeMs)}get confrontation(){return this.confrontationReadings}groundAlong(t,e,i){const n=this.sceneRenderer.bodyGround,s=te.eyeOf(this.ufoElement.sighting,i,n);return s?te.lineOfSightMeetsGround(s,t,e,n):void 0}bodyReading(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=d=>te.eyeOf(n,d,i),a=new te(t,i,s).at(e),o=s(e);if(!a||!o)return;const c=a.eastM-o.eastM,l=a.northM-o.northM,h=a.upM-o.upM,u=Math.hypot(c,l);return{azimuthDeg:(Math.atan2(c,l)*180/Math.PI+360)%360,altitudeDeg:Math.atan2(h,u)*180/Math.PI,distanceM:Math.hypot(u,h),eastM:a.eastM,northM:a.northM,aboveGroundM:a.upM-a.sizeM.heightM/2-i.heightAt(a.eastM,a.northM),sizeM:a.sizeM,attitude:a.attitude,appearance:a.appearance}}directionToBody(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=p=>te.eyeOf(n,p,i),a=new te(t,i,s),o=a.at(e)?e:t.track[0]?.t,c=o===void 0?void 0:a.at(o),l=o===void 0?void 0:s(o);if(!c||!l)return;const h=c.eastM-l.eastM,u=c.northM-l.northM,d=c.upM-l.upM,f=Math.hypot(h,u);if(!(f===0&&d===0))return{azimuthDeg:(Math.atan2(h,u)*180/Math.PI+360)%360,altitudeDeg:Math.atan2(d,f)*180/Math.PI}}placeBodiesAt(t,e){const i=this.interpretationShown,n=this.ufoElement.sighting;let s=[],a=[];const o=this.sceneRenderer.bodyGround,c=p=>te.eyeOf(n,p,o);i&&(s=i.bodies.map(p=>new te(p,o,c).at(t)).filter(p=>p!==void 0));const l=Gr(n,t),h=l.windDirectionDeg*Math.PI/180,u={x:l.windSpeed*Math.sin(h),z:-l.windSpeed*Math.cos(h)};this.sceneRenderer.setBodies(s,t/1e3,i?.bodies.map(p=>p.id)??[],i?.smoke??[],u);const d=i&&this.comparing?c(t):void 0;if(d&&(a=new Qe(n.timeline).at(t,s,d,p=>p.outlineNode?this.sceneRenderer.bodyOutline?.(p.id,p.outlineNode):void 0)),this.confrontationReadings=a,!e)return;const f=JSON.stringify(a);f!==this.confrontationSignature&&(this.confrontationSignature=f,this.dispatchEvent(new CustomEvent(VE,{detail:a})))}setDistanceHypothesis(t,e){e===void 0||!(e>0)?this.distanceHypotheses.delete(t):this.distanceHypotheses.set(t,e),this.updateAstronomy(this.lastTimeMs)}depthOf(t){return this.depths.get(t)}sizeRangeOf(t){return this.sizeEstimateOf(t).sizeRange}distanceRangeAt(t,e){const i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(e,t);if(!i)return{};const n=i.angular?.widthDeg??this.projectionAt(e).pxToDeg(i.bounds.width);return this.sizeEstimateOf(t).distanceRangeAt(n)}sizeContradictory(t){return this.sizeEstimateOf(t).contradictory}updateMeteorShower(t,e){this.ensureMeteorSchedule(t),this.sceneRenderer.updateMeteors(e)}updateLightning(t,e,i){if(this.ensureLightningSchedule(t),this.sceneRenderer.updateLightning(e),i)return;const n=this.lastLightningT;if(this.lastLightningT=e,n===void 0||e<n||this.ufoElement.playbackState!=="playing")return;const s=this.lightningFlashes.filter(a=>a.t>n&&a.t<=e).pop();s&&Gr(t,s.t).storm&&this.handleLightningFlash(s)}ensureLightningSchedule(t){const e=Gr(t,0).precipitationIntensity,i=`${this.meteorInputsOf(t)}|${e}`;if(i===this.lightningScheduleFor)return;this.lightningScheduleFor=i;const n=t.event.time,s=t.event.place?.[0],a=n?.year!==void 0?Bc(n,s?.lng??0,t.event.utcOffsetHours):void 0,o=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,c=Math.round((a?.getTime()??0)/1e3)+Math.round((s?.lat??0)*1e3)+7;this.lightningFlashes=pi.schedule({durationMs:o,seed:c,intensity:e}),this.sceneRenderer.setLightning(this.lightningFlashes)}ensureMeteorSchedule(t){const e=this.meteorInputsOf(t);e!==this.meteorScheduleFor&&(this.meteorScheduleFor=e,this.scheduleMeteors(t))}meteorInputsOf(t){const e=t.event.place?.[0],i=t.event.time;return JSON.stringify([e?.lat,e?.lng,i?.year,i?.month,i?.day,i?.hour,i?.minute,i?.second,t.event.utcOffsetHours,t.event.durationSeconds,t.timeline.duration])}scheduleMeteors(t){const e=t.event.place?.[0],i=t.event.time,n=e?.lat!==void 0&&e.lng!==void 0&&i?.year!==void 0?Bc(i,e.lng,t.event.utcOffsetHours):void 0;if(!n||e?.lat===void 0||e.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const s={lat:e.lat,lng:e.lng,elevationM:0},a=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,o=Math.round(n.getTime()/1e3)+Math.round(e.lat*1e3),c=ti.schedule({ratePerHour:ti.observedRatePerHour(ti.apexPosition(n,s).altitudeDeg),durationMs:a,velocityKmS:ti.TYPICAL_VELOCITY_KM_S,seed:o}),l=xu.activeAt(n).map(u=>{const d=xu.radiantPosition(u.shower,n,s);return{entry:u,position:d,rate:xu.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!l||l.rate<=0){this.sceneRenderer.setMeteorShower(c,0,0);return}const h=Ca.schedule({ratePerHour:l.rate,durationMs:a,velocityKmS:l.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}meteorByRank(t){this.ensureMeteorSchedule(this.ufoElement.sighting);const e=[...this.sceneRenderer.meteorSchedule].filter(s=>s.t+s.durationMs<=this.ufoElement.seekableDuration).sort((s,a)=>a.brightness-s.brightness);if(e.length===0)return;const i=e[t%e.length],n=this.sceneRenderer.meteorMidpoint(i);if(n)return{t:Math.round(i.t+i.durationMs*.45),...n}}lensOpticsAt(t){const e=this.ufoElement.sighting,i=e.instrument,n=i.frame,s=di(e,t),a=s?.fNumber??i.fNumber;if(!n||a===void 0)return;const o=fi.focalLengthMmFor(i,Ji.fovOf(e,t));if(o!==void 0)return{focalLengthMm:o,fNumber:a,focusDistance:s?.focusDistanceM??0,frameHeightMm:n.heightMm}}projectionAt(t){const e=this.ufoElement.sighting;return Ss.of(e.instrument,Te.CANVAS_HEIGHT_PX,Ji.fovOf(e,t))}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new FE,this.sizeEstimates.set(t,e)),e}}const Kd="rr0-scene";function ZE(){vg(),customElements.get(Kd)||customElements.define(Kd,B0)}ZE();export{RM as $,eA as A,ie as B,st as C,dp as D,Dt as E,aA as F,nA as G,Bg as H,iA as I,sA as J,xs as K,$o as L,BM as M,sc as N,Be as O,Zg as P,Qi as Q,ko as R,Gi as S,JE as T,Ce as U,xt as V,Zi as W,tA as X,Un as Y,zg as Z,rp as _,QE as a,gl as a0,ud as a1,bl as a2,bi as a3,$g as a4,x0 as a5,y0 as a6,re as a7,ia as a8,qo as a9,Vi as aa,Rs as ab,jE as b,cA as c,xl as d,oA as e,Jt as f,R as g,Kf as h,rA as i,lA as j,wM as k,wa as l,rh as m,T2 as n,oe as o,Re as p,Ou as q,wi as r,Hg as s,Ds as t,OM as u,xa as v,ji as w,_n as x,we as y,ce as z};