@rr0/ufoathome 0.63.0 → 0.63.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.
@@ -2105,11 +2105,11 @@ input[type=range] {
2105
2105
  * @license
2106
2106
  * Copyright 2010-2026 Three.js Authors
2107
2107
  * SPDX-License-Identifier: MIT
2108
- */const Ku="185",M2=0,up=1,x2=2,po=1,S2=2,ro=3,Bs=0,Ft=1,pn=2,Vn=0,ma=1,Zi=2,fp=3,pp=4,E2=5,ir=100,_2=101,T2=102,A2=103,I2=104,D2=200,C2=201,R2=202,P2=203,Md=204,xd=205,L2=206,k2=207,N2=208,O2=209,F2=210,U2=211,B2=212,z2=213,H2=214,Sd=0,Ed=1,_d=2,Aa=3,Td=4,Ad=5,Id=6,Dd=7,$u=0,G2=1,V2=2,Wn=0,Eg=1,_g=2,Tg=3,Ag=4,Ig=5,Dg=6,Cg=7,mp="attached",W2="detached",Rg=300,gr=301,Ia=302,Kc=303,$c=304,Rc=306,Io=1e3,Ri=1001,Cd=1002,Nt=1003,X2=1004,Ko=1005,vt=1006,Zc=1007,or=1008,$i=1009,Pg=1010,Lg=1011,Do=1012,Zu=1013,yn=1014,Pi=1015,ui=1016,Ju=1017,ju=1018,Co=1020,kg=35902,Ng=35899,Og=1021,Fg=1022,Ti=1023,ds=1026,lr=1027,Pc=1028,Qu=1029,vr=1030,ef=1031,tf=1033,ql=33776,Yl=33777,Kl=33778,$l=33779,Rd=35840,Pd=35841,Ld=35842,kd=35843,Nd=36196,Od=37492,Fd=37496,Ud=37488,Bd=37489,ac=37490,zd=37491,Hd=37808,Gd=37809,Vd=37810,Wd=37811,Xd=37812,qd=37813,Yd=37814,Kd=37815,$d=37816,Zd=37817,Jd=37818,jd=37819,Qd=37820,eu=37821,tu=36492,iu=36494,nu=36495,su=36283,ru=36284,oc=36285,au=36286,lc=2300,ou=2301,Jc=2302,gp=2303,vp=2400,yp=2401,bp=2402,q2=2500,hA=0,dA=1,uA=2,Y2=3200,cc=0,K2=1,Ps="",Bi="srgb",hc="srgb-linear",dc="linear",pt="srgb",Ar=7680,wp=519,$2=512,Z2=513,J2=514,nf=515,j2=516,Q2=517,sf=518,ey=519,lu=35044,uc="300 es",Hn=2e3,Ro=2001;function ty(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}function iy(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Po(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function ny(){const r=Po("canvas");return r.style.display="block",r}const Mp={};function fc(...r){const e="THREE."+r.shift();console.log(e,...r)}function Ug(r){const e=r[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=r[1];t&&t.isStackTrace?r[0]+=" "+t.getLocation():r[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return r}function _e(...r){r=Ug(r);const e="THREE."+r.shift();{const t=r[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...r)}}function Ue(...r){r=Ug(r);const e="THREE."+r.shift();{const t=r[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...r)}}function ga(...r){const e=r.join(" ");e in Mp||(Mp[e]=!0,_e(...r))}function sy(r,e,t){return new Promise(function(i,n){function s(){switch(r.clientWaitSync(e,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:n();break;case r.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}const ry={[Sd]:Ed,[_d]:Id,[Td]:Dd,[Aa]:Ad,[Ed]:Sd,[Id]:_d,[Dd]:Td,[Ad]:Aa};class wr{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const n=i[e];if(n!==void 0){const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const n=i.slice(0);for(let s=0,a=n.length;s<a;s++)n[s].call(this,e);e.target=null}}}const Mi=["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 xp=1234567;const mo=Math.PI/180,Da=180/Math.PI;function vn(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Mi[r&255]+Mi[r>>8&255]+Mi[r>>16&255]+Mi[r>>24&255]+"-"+Mi[e&255]+Mi[e>>8&255]+"-"+Mi[e>>16&15|64]+Mi[e>>24&255]+"-"+Mi[t&63|128]+Mi[t>>8&255]+"-"+Mi[t>>16&255]+Mi[t>>24&255]+Mi[i&255]+Mi[i>>8&255]+Mi[i>>16&255]+Mi[i>>24&255]).toLowerCase()}function Je(r,e,t){return Math.max(e,Math.min(t,r))}function rf(r,e){return(r%e+e)%e}function ay(r,e,t,i,n){return i+(r-e)*(n-i)/(t-e)}function oy(r,e,t){return r!==e?(t-r)/(e-r):0}function go(r,e,t){return(1-t)*r+t*e}function ly(r,e,t,i){return go(r,e,1-Math.exp(-t*i))}function cy(r,e=1){return e-Math.abs(rf(r,e*2)-e)}function hy(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function dy(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function uy(r,e){return r+Math.floor(Math.random()*(e-r+1))}function fy(r,e){return r+Math.random()*(e-r)}function py(r){return r*(.5-Math.random())}function my(r){r!==void 0&&(xp=r);let e=xp+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function gy(r){return r*mo}function vy(r){return r*Da}function yy(r){return(r&r-1)===0&&r!==0}function by(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function wy(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function My(r,e,t,i,n){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+i)/2),h=a((e+i)/2),d=s((e-i)/2),u=a((e-i)/2),f=s((i-e)/2),p=a((i-e)/2);switch(n){case"XYX":r.set(o*h,l*d,l*u,o*c);break;case"YZY":r.set(l*u,o*h,l*d,o*c);break;case"ZXZ":r.set(l*d,l*u,o*h,o*c);break;case"XZX":r.set(o*h,l*p,l*f,o*c);break;case"YXY":r.set(l*f,o*h,l*p,o*c);break;case"ZYZ":r.set(l*p,l*f,o*h,o*c);break;default:_e("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function mn(r,e){switch(e.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 mt(r,e){switch(e.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 fA={DEG2RAD:mo,RAD2DEG:Da,generateUUID:vn,clamp:Je,euclideanModulo:rf,mapLinear:ay,inverseLerp:oy,lerp:go,damp:ly,pingpong:cy,smoothstep:hy,smootherstep:dy,randInt:uy,randFloat:fy,randFloatSpread:py,seededRandom:my,degToRad:gy,radToDeg:vy,isPowerOfTwo:yy,ceilPowerOfTwo:by,floorPowerOfTwo:wy,setQuaternionFromProperEuler:My,normalize:mt,denormalize:mn};class Te{static{Te.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),n=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*n+e.x,this.y=s*n+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class qn{constructor(e=0,t=0,i=0,n=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=n}static slerpFlat(e,t,i,n,s,a,o){let l=i[n+0],c=i[n+1],h=i[n+2],d=i[n+3],u=s[a+0],f=s[a+1],p=s[a+2],v=s[a+3];if(d!==v||l!==u||c!==f||h!==p){let m=l*u+c*f+h*p+d*v;m<0&&(u=-u,f=-f,p=-p,v=-v,m=-m);let g=1-o;if(m<.9995){const x=Math.acos(m),M=Math.sin(x);g=Math.sin(g*x)/M,o=Math.sin(o*x)/M,l=l*g+u*o,c=c*g+f*o,h=h*g+p*o,d=d*g+v*o}else{l=l*g+u*o,c=c*g+f*o,h=h*g+p*o,d=d*g+v*o;const x=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=x,c*=x,h*=x,d*=x}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,n,s,a){const o=i[n],l=i[n+1],c=i[n+2],h=i[n+3],d=s[a],u=s[a+1],f=s[a+2],p=s[a+3];return e[t]=o*p+h*d+l*f-c*u,e[t+1]=l*p+h*u+c*d-o*f,e[t+2]=c*p+h*f+o*u-l*d,e[t+3]=h*p-o*d-l*u-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,n=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),h=o(n/2),d=o(s/2),u=l(i/2),f=l(n/2),p=l(s/2);switch(a){case"XYZ":this._x=u*h*d+c*f*p,this._y=c*f*d-u*h*p,this._z=c*h*p+u*f*d,this._w=c*h*d-u*f*p;break;case"YXZ":this._x=u*h*d+c*f*p,this._y=c*f*d-u*h*p,this._z=c*h*p-u*f*d,this._w=c*h*d+u*f*p;break;case"ZXY":this._x=u*h*d-c*f*p,this._y=c*f*d+u*h*p,this._z=c*h*p+u*f*d,this._w=c*h*d-u*f*p;break;case"ZYX":this._x=u*h*d-c*f*p,this._y=c*f*d+u*h*p,this._z=c*h*p-u*f*d,this._w=c*h*d+u*f*p;break;case"YZX":this._x=u*h*d+c*f*p,this._y=c*f*d+u*h*p,this._z=c*h*p-u*f*d,this._w=c*h*d-u*f*p;break;case"XZY":this._x=u*h*d-c*f*p,this._y=c*f*d-u*h*p,this._z=c*h*p+u*f*d,this._w=c*h*d+u*f*p;break;default:_e("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],n=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],u=i+o+d;if(u>0){const f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(h-l)*f,this._y=(s-c)*f,this._z=(a-n)*f}else if(i>o&&i>d){const f=2*Math.sqrt(1+i-o-d);this._w=(h-l)/f,this._x=.25*f,this._y=(n+a)/f,this._z=(s+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-i-d);this._w=(s-c)/f,this._x=(n+a)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+d-i-o);this._w=(a-n)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Je(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const n=Math.min(1,t/i);return this.slerp(e,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,n=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=i*h+a*o+n*c-s*l,this._y=n*h+a*l+s*o-i*c,this._z=s*h+a*c+i*l-n*o,this._w=a*h-i*o-n*l-s*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,n=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,n=-n,s=-s,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+i*t,this._y=this._y*l+n*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+n*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class P{static{P.prototype.isVector3=!0}constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Sp.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Sp.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*n,this.y=s[1]*t+s[4]*i+s[7]*n,this.z=s[2]*t+s[5]*i+s[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*n+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*n+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*n+s[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*n-o*i),h=2*(o*t-s*n),d=2*(s*i-a*t);return this.x=t+l*c+a*d-o*h,this.y=i+l*h+o*c-s*d,this.z=n+l*d+s*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,n=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*n,this.y=s[1]*t+s[5]*i+s[9]*n,this.z=s[2]*t+s[6]*i+s[10]*n,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,n=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=n*l-s*o,this.y=s*a-i*l,this.z=i*o-n*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return jc.copy(this).projectOnVector(e),this.sub(jc)}reflect(e){return this.sub(jc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const jc=new P,Sp=new qn;class ze{static{ze.prototype.isMatrix3=!0}constructor(e,t,i,n,s,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,n,s,a,o,l,c)}set(e,t,i,n,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=n,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=i,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,s=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],h=i[4],d=i[7],u=i[2],f=i[5],p=i[8],v=n[0],m=n[3],g=n[6],x=n[1],M=n[4],w=n[7],S=n[2],_=n[5],D=n[8];return s[0]=a*v+o*x+l*S,s[3]=a*m+o*M+l*_,s[6]=a*g+o*w+l*D,s[1]=c*v+h*x+d*S,s[4]=c*m+h*M+d*_,s[7]=c*g+h*w+d*D,s[2]=u*v+f*x+p*S,s[5]=u*m+f*M+p*_,s[8]=u*g+f*w+p*D,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-i*s*h+i*o*l+n*s*c-n*a*l}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,u=o*l-h*s,f=c*s-a*l,p=t*d+i*u+n*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/p;return e[0]=d*v,e[1]=(n*c-h*i)*v,e[2]=(o*i-n*a)*v,e[3]=u*v,e[4]=(h*t-n*l)*v,e[5]=(n*s-o*t)*v,e[6]=f*v,e[7]=(i*l-c*t)*v,e[8]=(a*t-i*s)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,n,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-n*c,n*l,-n*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return ga("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Qc.makeScale(e,t)),this}rotate(e){return ga("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Qc.makeRotation(-e)),this}translate(e,t){return ga("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Qc.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let n=0;n<9;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Qc=new ze,Ep=new ze().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),_p=new ze().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function xy(){const r={enabled:!0,workingColorSpace:hc,spaces:{},convert:function(n,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===pt&&(n.r=cs(n.r),n.g=cs(n.g),n.b=cs(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===pt&&(n.r=va(n.r),n.g=va(n.g),n.b=va(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===Ps?dc: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 ga("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(n,s)},toWorkingColorSpace:function(n,s){return ga("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(n,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return r.define({[hc]:{primaries:e,whitePoint:i,transfer:dc,toXYZ:Ep,fromXYZ:_p,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Bi},outputColorSpaceConfig:{drawingBufferColorSpace:Bi}},[Bi]:{primaries:e,whitePoint:i,transfer:pt,toXYZ:Ep,fromXYZ:_p,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Bi}}}),r}const tt=xy();function cs(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function va(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Ir;class Sy{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Ir===void 0&&(Ir=Po("canvas")),Ir.width=e.width,Ir.height=e.height;const n=Ir.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),i=Ir}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Po("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const n=i.getImageData(0,0,e.width,e.height),s=n.data;for(let a=0;a<s.length;a++)s[a]=cs(s[a]/255)*255;return i.putImageData(n,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(cs(t[i]/255)*255):t[i]=cs(t[i]);return{data:t,width:e.width,height:e.height}}else return _e("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Ey=0;class af{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ey++}),this.uuid=vn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.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(eh(n[a].image)):s.push(eh(n[a]))}else s=eh(n);i.url=s}return t||(e.images[this.uuid]=i),i}}function eh(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?Sy.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(_e("Texture: Unable to serialize Texture."),{})}let _y=0;const th=new P;class di extends wr{constructor(e=di.DEFAULT_IMAGE,t=di.DEFAULT_MAPPING,i=Ri,n=Ri,s=vt,a=or,o=Ti,l=$i,c=di.DEFAULT_ANISOTROPY,h=Ps){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:_y++}),this.uuid=vn(),this.name="",this.source=new af(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Te(0,0),this.repeat=new Te(1,1),this.center=new Te(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ze,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=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(th).x}get height(){return this.source.getSize(th).y}get depth(){return this.source.getSize(th).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){_e(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){_e(`Texture.setValues(): property '${t}' 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[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Rg)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Io:e.x=e.x-Math.floor(e.x);break;case Ri:e.x=e.x<0?0:1;break;case Cd:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Io:e.y=e.y-Math.floor(e.y);break;case Ri:e.y=e.y<0?0:1;break;case Cd:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}di.DEFAULT_IMAGE=null;di.DEFAULT_MAPPING=Rg;di.DEFAULT_ANISOTROPY=1;class at{static{at.prototype.isVector4=!0}constructor(e=0,t=0,i=0,n=1){this.x=e,this.y=t,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*n+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*n+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*n+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*n+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,n,s;const l=e.elements,c=l[0],h=l[4],d=l[8],u=l[1],f=l[5],p=l[9],v=l[2],m=l[6],g=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-v)<.01&&Math.abs(p-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+v)<.1&&Math.abs(p+m)<.1&&Math.abs(c+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const M=(c+1)/2,w=(f+1)/2,S=(g+1)/2,_=(h+u)/4,D=(d+v)/4,y=(p+m)/4;return M>w&&M>S?M<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(M),n=_/i,s=D/i):w>S?w<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(w),i=_/n,s=y/n):S<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(S),i=D/s,n=y/s),this.set(i,n,s,t),this}let x=Math.sqrt((m-p)*(m-p)+(d-v)*(d-v)+(u-h)*(u-h));return Math.abs(x)<.001&&(x=1),this.x=(m-p)/x,this.y=(d-v)/x,this.z=(u-h)/x,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this.w=Je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this.w=Je(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Ty extends wr{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:vt,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=e,this.height=t,this.depth=i.depth,this.scissor=new at(0,0,e,t),this.scissorTest=!1,this.viewport=new at(0,0,e,t),this.textures=[];const n={width:e,height:t,depth:i.depth},s=new di(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(e={}){const t={minFilter:vt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let n=0,s=this.textures.length;n<s;n++)this.textures[n].image.width=e,this.textures[n].image.height=t,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,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const n=Object.assign({},e.textures[t].image);this.textures[t].source=new af(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class vi extends Ty{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class Bg extends di{constructor(e=null,t=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=Nt,this.minFilter=Nt,this.wrapR=Ri,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class zg extends di{constructor(e=null,t=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=Nt,this.minFilter=Nt,this.wrapR=Ri,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ye{static{Ye.prototype.isMatrix4=!0}constructor(e,t,i,n,s,a,o,l,c,h,d,u,f,p,v,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,n,s,a,o,l,c,h,d,u,f,p,v,m)}set(e,t,i,n,s,a,o,l,c,h,d,u,f,p,v,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=n,g[1]=s,g[5]=a,g[9]=o,g[13]=l,g[2]=c,g[6]=h,g[10]=d,g[14]=u,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 Ye().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,i=e.elements,n=1/Dr.setFromMatrixColumn(e,0).length(),s=1/Dr.setFromMatrixColumn(e,1).length(),a=1/Dr.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,n=e.y,s=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(n),c=Math.sin(n),h=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){const u=a*h,f=a*d,p=o*h,v=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=f+p*c,t[5]=u-v*c,t[9]=-o*l,t[2]=v-u*c,t[6]=p+f*c,t[10]=a*l}else if(e.order==="YXZ"){const u=l*h,f=l*d,p=c*h,v=c*d;t[0]=u+v*o,t[4]=p*o-f,t[8]=a*c,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=f*o-p,t[6]=v+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*h,f=l*d,p=c*h,v=c*d;t[0]=u-v*o,t[4]=-a*d,t[8]=p+f*o,t[1]=f+p*o,t[5]=a*h,t[9]=v-u*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*h,f=a*d,p=o*h,v=o*d;t[0]=l*h,t[4]=p*c-f,t[8]=u*c+v,t[1]=l*d,t[5]=v*c+u,t[9]=f*c-p,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,f=a*c,p=o*l,v=o*c;t[0]=l*h,t[4]=v-u*d,t[8]=p*d+f,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=f*d+p,t[10]=u-v*d}else if(e.order==="XZY"){const u=a*l,f=a*c,p=o*l,v=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=u*d+v,t[5]=a*h,t[9]=f*d-p,t[2]=p*d-f,t[6]=o*h,t[10]=v*d+u}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Ay,e,Iy)}lookAt(e,t,i){const n=this.elements;return Gi.subVectors(e,t),Gi.lengthSq()===0&&(Gi.z=1),Gi.normalize(),bs.crossVectors(i,Gi),bs.lengthSq()===0&&(Math.abs(i.z)===1?Gi.x+=1e-4:Gi.z+=1e-4,Gi.normalize(),bs.crossVectors(i,Gi)),bs.normalize(),$o.crossVectors(Gi,bs),n[0]=bs.x,n[4]=$o.x,n[8]=Gi.x,n[1]=bs.y,n[5]=$o.y,n[9]=Gi.y,n[2]=bs.z,n[6]=$o.z,n[10]=Gi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,s=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],h=i[1],d=i[5],u=i[9],f=i[13],p=i[2],v=i[6],m=i[10],g=i[14],x=i[3],M=i[7],w=i[11],S=i[15],_=n[0],D=n[4],y=n[8],T=n[12],A=n[1],I=n[5],R=n[9],k=n[13],z=n[2],L=n[6],B=n[10],F=n[14],V=n[3],j=n[7],$=n[11],ie=n[15];return s[0]=a*_+o*A+l*z+c*V,s[4]=a*D+o*I+l*L+c*j,s[8]=a*y+o*R+l*B+c*$,s[12]=a*T+o*k+l*F+c*ie,s[1]=h*_+d*A+u*z+f*V,s[5]=h*D+d*I+u*L+f*j,s[9]=h*y+d*R+u*B+f*$,s[13]=h*T+d*k+u*F+f*ie,s[2]=p*_+v*A+m*z+g*V,s[6]=p*D+v*I+m*L+g*j,s[10]=p*y+v*R+m*B+g*$,s[14]=p*T+v*k+m*F+g*ie,s[3]=x*_+M*A+w*z+S*V,s[7]=x*D+M*I+w*L+S*j,s[11]=x*y+M*R+w*B+S*$,s[15]=x*T+M*k+w*F+S*ie,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],n=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],u=e[10],f=e[14],p=e[3],v=e[7],m=e[11],g=e[15],x=l*f-c*u,M=o*f-c*d,w=o*u-l*d,S=a*f-c*h,_=a*u-l*h,D=a*d-o*h;return t*(v*x-m*M+g*w)-i*(p*x-m*S+g*_)+n*(p*M-v*S+g*D)-s*(p*w-v*_+m*D)}determinantAffine(){const e=this.elements,t=e[0],i=e[4],n=e[8],s=e[1],a=e[5],o=e[9],l=e[2],c=e[6],h=e[10];return t*(a*h-o*c)-i*(s*h-o*l)+n*(s*c-a*l)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],u=e[10],f=e[11],p=e[12],v=e[13],m=e[14],g=e[15],x=t*o-i*a,M=t*l-n*a,w=t*c-s*a,S=i*l-n*o,_=i*c-s*o,D=n*c-s*l,y=h*v-d*p,T=h*m-u*p,A=h*g-f*p,I=d*m-u*v,R=d*g-f*v,k=u*g-f*m,z=x*k-M*R+w*I+S*A-_*T+D*y;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const L=1/z;return e[0]=(o*k-l*R+c*I)*L,e[1]=(n*R-i*k-s*I)*L,e[2]=(v*D-m*_+g*S)*L,e[3]=(u*_-d*D-f*S)*L,e[4]=(l*A-a*k-c*T)*L,e[5]=(t*k-n*A+s*T)*L,e[6]=(m*w-p*D-g*M)*L,e[7]=(h*D-u*w+f*M)*L,e[8]=(a*R-o*A+c*y)*L,e[9]=(i*A-t*R-s*y)*L,e[10]=(p*_-v*w+g*x)*L,e[11]=(d*w-h*_-f*x)*L,e[12]=(o*T-a*I-l*y)*L,e[13]=(t*I-i*T+n*y)*L,e[14]=(v*M-p*S-m*x)*L,e[15]=(h*S-d*M+u*x)*L,this}scale(e){const t=this.elements,i=e.x,n=e.y,s=e.z;return t[0]*=i,t[4]*=n,t[8]*=s,t[1]*=i,t[5]*=n,t[9]*=s,t[2]*=i,t[6]*=n,t[10]*=s,t[3]*=i,t[7]*=n,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),n=Math.sin(t),s=1-i,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+i,c*o-n*l,c*l+n*o,0,c*o+n*l,h*o+i,h*l-n*a,0,c*l-n*o,h*l+n*a,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,s,a){return this.set(1,i,s,0,e,1,a,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,d=o+o,u=s*c,f=s*h,p=s*d,v=a*h,m=a*d,g=o*d,x=l*c,M=l*h,w=l*d,S=i.x,_=i.y,D=i.z;return n[0]=(1-(v+g))*S,n[1]=(f+w)*S,n[2]=(p-M)*S,n[3]=0,n[4]=(f-w)*_,n[5]=(1-(u+g))*_,n[6]=(m+x)*_,n[7]=0,n[8]=(p+M)*D,n[9]=(m-x)*D,n[10]=(1-(u+v))*D,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){const n=this.elements;e.x=n[12],e.y=n[13],e.z=n[14];const s=this.determinantAffine();if(s===0)return i.set(1,1,1),t.identity(),this;let a=Dr.set(n[0],n[1],n[2]).length();const o=Dr.set(n[4],n[5],n[6]).length(),l=Dr.set(n[8],n[9],n[10]).length();s<0&&(a=-a),on.copy(this);const c=1/a,h=1/o,d=1/l;return on.elements[0]*=c,on.elements[1]*=c,on.elements[2]*=c,on.elements[4]*=h,on.elements[5]*=h,on.elements[6]*=h,on.elements[8]*=d,on.elements[9]*=d,on.elements[10]*=d,t.setFromRotationMatrix(on),i.x=a,i.y=o,i.z=l,this}makePerspective(e,t,i,n,s,a,o=Hn,l=!1){const c=this.elements,h=2*s/(t-e),d=2*s/(i-n),u=(t+e)/(t-e),f=(i+n)/(i-n);let p,v;if(l)p=s/(a-s),v=a*s/(a-s);else if(o===Hn)p=-(a+s)/(a-s),v=-2*a*s/(a-s);else if(o===Ro)p=-a/(a-s),v=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=d,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,n,s,a,o=Hn,l=!1){const c=this.elements,h=2/(t-e),d=2/(i-n),u=-(t+e)/(t-e),f=-(i+n)/(i-n);let p,v;if(l)p=1/(a-s),v=a/(a-s);else if(o===Hn)p=-2/(a-s),v=-(a+s)/(a-s);else if(o===Ro)p=-1/(a-s),v=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=d,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let n=0;n<16;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Dr=new P,on=new Ye,Ay=new P(0,0,0),Iy=new P(1,1,1),bs=new P,$o=new P,Gi=new P,Tp=new Ye,Ap=new qn;class Yn{constructor(e=0,t=0,i=0,n=Yn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=n}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const n=e.elements,s=n[0],a=n[4],o=n[8],l=n[1],c=n[5],h=n[9],d=n[2],u=n[6],f=n[10];switch(t){case"XYZ":this._y=Math.asin(Je(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Je(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(Je(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Je(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Je(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Je(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:_e("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Tp.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Tp,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ap.setFromEuler(this),this.setFromQuaternion(Ap,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Yn.DEFAULT_ORDER="XYZ";class of{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Dy=0;const Ip=new P,Cr=new qn,$n=new Ye,Zo=new P,Fa=new P,Cy=new P,Ry=new qn,Dp=new P(1,0,0),Cp=new P(0,1,0),Rp=new P(0,0,1),Pp={type:"added"},Py={type:"removed"},Rr={type:"childadded",child:null},ih={type:"childremoved",child:null};class _t extends wr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Dy++}),this.uuid=vn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();const e=new P,t=new Yn,i=new qn,n=new P(1,1,1);function s(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Ye},normalMatrix:{value:new ze}}),this.matrix=new Ye,this.matrixWorld=new Ye,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new of,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(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Cr.setFromAxisAngle(e,t),this.quaternion.multiply(Cr),this}rotateOnWorldAxis(e,t){return Cr.setFromAxisAngle(e,t),this.quaternion.premultiply(Cr),this}rotateX(e){return this.rotateOnAxis(Dp,e)}rotateY(e){return this.rotateOnAxis(Cp,e)}rotateZ(e){return this.rotateOnAxis(Rp,e)}translateOnAxis(e,t){return Ip.copy(e).applyQuaternion(this.quaternion),this.position.add(Ip.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Dp,e)}translateY(e){return this.translateOnAxis(Cp,e)}translateZ(e){return this.translateOnAxis(Rp,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4($n.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Zo.copy(e):Zo.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Fa.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?$n.lookAt(Fa,Zo,this.up):$n.lookAt(Zo,Fa,this.up),this.quaternion.setFromRotationMatrix($n),n&&($n.extractRotation(n.matrixWorld),Cr.setFromRotationMatrix($n),this.quaternion.premultiply(Cr.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Ue("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Pp),Rr.child=e,this.dispatchEvent(Rr),Rr.child=null):Ue("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Py),ih.child=e,this.dispatchEvent(ih),ih.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),$n.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),$n.multiply(e.parent.matrixWorld)),e.applyMatrix4($n),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Pp),Rr.child=e,this.dispatchEvent(Rr),Rr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,n=this.children.length;i<n;i++){const a=this.children[i].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const n=this.children;for(let s=0,a=n.length;s<a;s++)n[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Fa,e,Cy),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Fa,Ry,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,i=e.y,n=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*i-s[8]*n,s[13]+=i-s[1]*t-s[5]*i-s[9]*n,s[14]+=n-s[2]*t-s[6]*i-s[10]*n}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t,i=!1){const n=this.parent;if(e===!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),t===!0){const s=this.children;for(let a=0,o=s.length;a<o;a++)s[a].updateWorldMatrix(!1,!0,i)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={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(e),n.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const d=l[c];s(e.shapes,d)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));n.material=o}else n.material=s(e.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(e).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];n.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),d=a(e.shapes),u=a(e.skeletons),f=a(e.animations),p=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),h.length>0&&(i.images=h),d.length>0&&(i.shapes=d),u.length>0&&(i.skeletons=u),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=n,i;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const n=e.children[i];this.add(n.clone())}return this}}_t.DEFAULT_UP=new P(0,1,0);_t.DEFAULT_MATRIX_AUTO_UPDATE=!0;_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class ci extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Ly={type:"move"};class nh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ci,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 ci,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ci,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let n=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const m=t.getJointPose(v,i),g=this._getHandJoint(c,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=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],u=h.position.distanceTo(d.position),f=.02,p=.005;c.inputState.pinching&&u>f+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(n=t.getPose(e.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(Ly)))}return o!==null&&(o.visible=n!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new ci;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const Hg={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},ws={h:0,s:0,l:0},Jo={h:0,s:0,l:0};function sh(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class oe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const n=e;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Bi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,tt.colorSpaceToWorking(this,t),this}setRGB(e,t,i,n=tt.workingColorSpace){return this.r=e,this.g=t,this.b=i,tt.colorSpaceToWorking(this,n),this}setHSL(e,t,i,n=tt.workingColorSpace){if(e=rf(e,1),t=Je(t,0,1),i=Je(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=sh(a,s,e+1/3),this.g=sh(a,s,e),this.b=sh(a,s,e-1/3)}return tt.colorSpaceToWorking(this,n),this}setStyle(e,t=Bi){function i(s){s!==void 0&&parseFloat(s)<1&&_e("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){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,t);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,t);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,t);break;default:_e("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){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,t);if(a===6)return this.setHex(parseInt(s,16),t);_e("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Bi){const i=Hg[e.toLowerCase()];return i!==void 0?this.setHex(i,t):_e("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=cs(e.r),this.g=cs(e.g),this.b=cs(e.b),this}copyLinearToSRGB(e){return this.r=va(e.r),this.g=va(e.g),this.b=va(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Bi){return tt.workingToColorSpace(xi.copy(this),e),Math.round(Je(xi.r*255,0,255))*65536+Math.round(Je(xi.g*255,0,255))*256+Math.round(Je(xi.b*255,0,255))}getHexString(e=Bi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=tt.workingColorSpace){tt.workingToColorSpace(xi.copy(this),t);const i=xi.r,n=xi.g,s=xi.b,a=Math.max(i,n,s),o=Math.min(i,n,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=h<=.5?d/(a+o):d/(2-a-o),a){case i:l=(n-s)/d+(n<s?6:0);break;case n:l=(s-i)/d+2;break;case s:l=(i-n)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=tt.workingColorSpace){return tt.workingToColorSpace(xi.copy(this),t),e.r=xi.r,e.g=xi.g,e.b=xi.b,e}getStyle(e=Bi){tt.workingToColorSpace(xi.copy(this),e);const t=xi.r,i=xi.g,n=xi.b;return e!==Bi?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(e,t,i){return this.getHSL(ws),this.setHSL(ws.h+e,ws.s+t,ws.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(ws),e.getHSL(Jo);const i=go(ws.h,Jo.h,t),n=go(ws.s,Jo.s,t),s=go(ws.l,Jo.l,t);return this.setHSL(i,n,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,n=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*n,this.g=s[1]*t+s[4]*i+s[7]*n,this.b=s[2]*t+s[5]*i+s[8]*n,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const xi=new oe;oe.NAMES=Hg;class pc{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new oe(e),this.near=t,this.far=i}clone(){return new pc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Ca extends _t{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 Yn,this.environmentIntensity=1,this.environmentRotation=new Yn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const ln=new P,Zn=new P,rh=new P,Jn=new P,Pr=new P,Lr=new P,Lp=new P,ah=new P,oh=new P,lh=new P,ch=new at,hh=new at,dh=new at;class nn{constructor(e=new P,t=new P,i=new P){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),ln.subVectors(e,t),n.cross(ln);const s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(e,t,i,n,s){ln.subVectors(n,t),Zn.subVectors(i,t),rh.subVectors(e,t);const a=ln.dot(ln),o=ln.dot(Zn),l=ln.dot(rh),c=Zn.dot(Zn),h=Zn.dot(rh),d=a*c-o*o;if(d===0)return s.set(0,0,0),null;const u=1/d,f=(c*l-o*h)*u,p=(a*h-o*l)*u;return s.set(1-f-p,p,f)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,Jn)===null?!1:Jn.x>=0&&Jn.y>=0&&Jn.x+Jn.y<=1}static getInterpolation(e,t,i,n,s,a,o,l){return this.getBarycoord(e,t,i,n,Jn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Jn.x),l.addScaledVector(a,Jn.y),l.addScaledVector(o,Jn.z),l)}static getInterpolatedAttribute(e,t,i,n,s,a){return ch.setScalar(0),hh.setScalar(0),dh.setScalar(0),ch.fromBufferAttribute(e,t),hh.fromBufferAttribute(e,i),dh.fromBufferAttribute(e,n),a.setScalar(0),a.addScaledVector(ch,s.x),a.addScaledVector(hh,s.y),a.addScaledVector(dh,s.z),a}static isFrontFacing(e,t,i,n){return ln.subVectors(i,t),Zn.subVectors(e,t),ln.cross(Zn).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ln.subVectors(this.c,this.b),Zn.subVectors(this.a,this.b),ln.cross(Zn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return nn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return nn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,n,s){return nn.getInterpolation(e,this.a,this.b,this.c,t,i,n,s)}containsPoint(e){return nn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return nn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,s=this.c;let a,o;Pr.subVectors(n,i),Lr.subVectors(s,i),ah.subVectors(e,i);const l=Pr.dot(ah),c=Lr.dot(ah);if(l<=0&&c<=0)return t.copy(i);oh.subVectors(e,n);const h=Pr.dot(oh),d=Lr.dot(oh);if(h>=0&&d<=h)return t.copy(n);const u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(i).addScaledVector(Pr,a);lh.subVectors(e,s);const f=Pr.dot(lh),p=Lr.dot(lh);if(p>=0&&f<=p)return t.copy(s);const v=f*c-l*p;if(v<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(i).addScaledVector(Lr,o);const m=h*p-f*d;if(m<=0&&d-h>=0&&f-p>=0)return Lp.subVectors(s,n),o=(d-h)/(d-h+(f-p)),t.copy(n).addScaledVector(Lp,o);const g=1/(m+v+u);return a=v*g,o=u*g,t.copy(i).addScaledVector(Pr,a).addScaledVector(Lr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class bn{constructor(e=new P(1/0,1/0,1/0),t=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(cn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(cn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=cn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,cn):cn.fromBufferAttribute(s,a),cn.applyMatrix4(e.matrixWorld),this.expandByPoint(cn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),jo.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),jo.copy(i.boundingBox)),jo.applyMatrix4(e.matrixWorld),this.union(jo)}const n=e.children;for(let s=0,a=n.length;s<a;s++)this.expandByObject(n[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,cn),cn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ua),Qo.subVectors(this.max,Ua),kr.subVectors(e.a,Ua),Nr.subVectors(e.b,Ua),Or.subVectors(e.c,Ua),Ms.subVectors(Nr,kr),xs.subVectors(Or,Nr),Xs.subVectors(kr,Or);let t=[0,-Ms.z,Ms.y,0,-xs.z,xs.y,0,-Xs.z,Xs.y,Ms.z,0,-Ms.x,xs.z,0,-xs.x,Xs.z,0,-Xs.x,-Ms.y,Ms.x,0,-xs.y,xs.x,0,-Xs.y,Xs.x,0];return!uh(t,kr,Nr,Or,Qo)||(t=[1,0,0,0,1,0,0,0,1],!uh(t,kr,Nr,Or,Qo))?!1:(el.crossVectors(Ms,xs),t=[el.x,el.y,el.z],uh(t,kr,Nr,Or,Qo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,cn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(cn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(jn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),jn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),jn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),jn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),jn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),jn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),jn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),jn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(jn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const jn=[new P,new P,new P,new P,new P,new P,new P,new P],cn=new P,jo=new bn,kr=new P,Nr=new P,Or=new P,Ms=new P,xs=new P,Xs=new P,Ua=new P,Qo=new P,el=new P,qs=new P;function uh(r,e,t,i,n){for(let s=0,a=r.length-3;s<=a;s+=3){qs.fromArray(r,s);const o=n.x*Math.abs(qs.x)+n.y*Math.abs(qs.y)+n.z*Math.abs(qs.z),l=e.dot(qs),c=t.dot(qs),h=i.dot(qs);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const as=ky();function ky(){const r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),i=new Uint32Array(512),n=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(i[l]=0,i[l|256]=32768,n[l]=24,n[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,n[l]=-c-1,n[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,n[l]=13,n[l|256]=13):c<128?(i[l]=31744,i[l|256]=64512,n[l]=24,n[l|256]=24):(i[l]=31744,i[l|256]=64512,n[l]=13,n[l|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:n,mantissaTable:s,exponentTable:a,offsetTable:o}}function Ny(r){Math.abs(r)>65504&&_e("DataUtils.toHalfFloat(): Value out of range."),r=Je(r,-65504,65504),as.floatView[0]=r;const e=as.uint32View[0],t=e>>23&511;return as.baseTable[t]+((e&8388607)>>as.shiftTable[t])}function Oy(r){const e=r>>10;return as.uint32View[0]=as.mantissaTable[as.offsetTable[e]+(r&1023)]+as.exponentTable[e],as.floatView[0]}class hs{static toHalfFloat(e){return Ny(e)}static fromHalfFloat(e){return Oy(e)}}const Jt=new P,tl=new Te;let Fy=0;class ht extends wr{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Fy++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=lu,this.updateRanges=[],this.gpuType=Pi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,s=this.itemSize;n<s;n++)this.array[e+n]=t.array[i+n];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)tl.fromBufferAttribute(this,t),tl.applyMatrix3(e),this.setXY(t,tl.x,tl.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Jt.fromBufferAttribute(this,t),Jt.applyMatrix3(e),this.setXYZ(t,Jt.x,Jt.y,Jt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Jt.fromBufferAttribute(this,t),Jt.applyMatrix4(e),this.setXYZ(t,Jt.x,Jt.y,Jt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Jt.fromBufferAttribute(this,t),Jt.applyNormalMatrix(e),this.setXYZ(t,Jt.x,Jt.y,Jt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Jt.fromBufferAttribute(this,t),Jt.transformDirection(e),this.setXYZ(t,Jt.x,Jt.y,Jt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=mn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=mt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=mn(t,this.array)),t}setX(e,t){return this.normalized&&(t=mt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=mn(t,this.array)),t}setY(e,t){return this.normalized&&(t=mt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=mn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=mt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=mn(t,this.array)),t}setW(e,t){return this.normalized&&(t=mt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=mt(t,this.array),i=mt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,n){return e*=this.itemSize,this.normalized&&(t=mt(t,this.array),i=mt(i,this.array),n=mt(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,s){return e*=this.itemSize,this.normalized&&(t=mt(t,this.array),i=mt(i,this.array),n=mt(n,this.array),s=mt(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==lu&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class Gg extends ht{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class lf extends ht{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Ut extends ht{constructor(e,t,i){super(new Float32Array(e),t,i)}}const Uy=new bn,Ba=new P,fh=new P;class fs{constructor(e=new P,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):Uy.setFromPoints(e).getCenter(i);let n=0;for(let s=0,a=e.length;s<a;s++)n=Math.max(n,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(n),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ba.subVectors(e,this.center);const t=Ba.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),n=(i-this.radius)*.5;this.center.addScaledVector(Ba,n/i),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(fh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ba.copy(e.center).add(fh)),this.expandByPoint(Ba.copy(e.center).sub(fh))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let By=0;const Qi=new Ye,ph=new _t,Fr=new P,Vi=new bn,za=new bn,ii=new P;class Tt extends wr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:By++}),this.uuid=vn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(ty(e)?lf:Gg)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new ze().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Qi.makeRotationFromQuaternion(e),this.applyMatrix4(Qi),this}rotateX(e){return Qi.makeRotationX(e),this.applyMatrix4(Qi),this}rotateY(e){return Qi.makeRotationY(e),this.applyMatrix4(Qi),this}rotateZ(e){return Qi.makeRotationZ(e),this.applyMatrix4(Qi),this}translate(e,t,i){return Qi.makeTranslation(e,t,i),this.applyMatrix4(Qi),this}scale(e,t,i){return Qi.makeScale(e,t,i),this.applyMatrix4(Qi),this}lookAt(e){return ph.lookAt(e),ph.updateMatrix(),this.applyMatrix4(ph.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Fr).negate(),this.translate(Fr.x,Fr.y,Fr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let n=0,s=e.length;n<s;n++){const a=e[n];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ut(i,3))}else{const i=Math.min(e.length,t.count);for(let n=0;n<i;n++){const s=e[n];t.setXYZ(n,s.x,s.y,s.z||0)}e.length>t.count&&_e("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new bn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,n=t.length;i<n;i++){const s=t[i];Vi.setFromBufferAttribute(s),this.morphTargetsRelative?(ii.addVectors(this.boundingBox.min,Vi.min),this.boundingBox.expandByPoint(ii),ii.addVectors(this.boundingBox.max,Vi.max),this.boundingBox.expandByPoint(ii)):(this.boundingBox.expandByPoint(Vi.min),this.boundingBox.expandByPoint(Vi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ue('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 fs);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(e){const i=this.boundingSphere.center;if(Vi.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];za.setFromBufferAttribute(o),this.morphTargetsRelative?(ii.addVectors(Vi.min,za.min),Vi.expandByPoint(ii),ii.addVectors(Vi.max,za.max),Vi.expandByPoint(ii)):(Vi.expandByPoint(za.min),Vi.expandByPoint(za.max))}Vi.getCenter(i);let n=0;for(let s=0,a=e.count;s<a;s++)ii.fromBufferAttribute(e,s),n=Math.max(n,i.distanceToSquared(ii));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)ii.fromBufferAttribute(o,c),l&&(Fr.fromBufferAttribute(e,c),ii.add(Fr)),n=Math.max(n,i.distanceToSquared(ii))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&Ue('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ue("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,n=t.normal,s=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==i.count)&&(a=new ht(new Float32Array(4*i.count),4),this.setAttribute("tangent",a));const o=[],l=[];for(let y=0;y<i.count;y++)o[y]=new P,l[y]=new P;const c=new P,h=new P,d=new P,u=new Te,f=new Te,p=new Te,v=new P,m=new P;function g(y,T,A){c.fromBufferAttribute(i,y),h.fromBufferAttribute(i,T),d.fromBufferAttribute(i,A),u.fromBufferAttribute(s,y),f.fromBufferAttribute(s,T),p.fromBufferAttribute(s,A),h.sub(c),d.sub(c),f.sub(u),p.sub(u);const I=1/(f.x*p.y-p.x*f.y);isFinite(I)&&(v.copy(h).multiplyScalar(p.y).addScaledVector(d,-f.y).multiplyScalar(I),m.copy(d).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(I),o[y].add(v),o[T].add(v),o[A].add(v),l[y].add(m),l[T].add(m),l[A].add(m))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let y=0,T=x.length;y<T;++y){const A=x[y],I=A.start,R=A.count;for(let k=I,z=I+R;k<z;k+=3)g(e.getX(k+0),e.getX(k+1),e.getX(k+2))}const M=new P,w=new P,S=new P,_=new P;function D(y){S.fromBufferAttribute(n,y),_.copy(S);const T=o[y];M.copy(T),M.sub(S.multiplyScalar(S.dot(T))).normalize(),w.crossVectors(_,T);const I=w.dot(l[y])<0?-1:1;a.setXYZW(y,M.x,M.y,M.z,I)}for(let y=0,T=x.length;y<T;++y){const A=x[y],I=A.start,R=A.count;for(let k=I,z=I+R;k<z;k+=3)D(e.getX(k+0)),D(e.getX(k+1)),D(e.getX(k+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==t.count)i=new ht(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let u=0,f=i.count;u<f;u++)i.setXYZ(u,0,0,0);const n=new P,s=new P,a=new P,o=new P,l=new P,c=new P,h=new P,d=new P;if(e)for(let u=0,f=e.count;u<f;u+=3){const p=e.getX(u+0),v=e.getX(u+1),m=e.getX(u+2);n.fromBufferAttribute(t,p),s.fromBufferAttribute(t,v),a.fromBufferAttribute(t,m),h.subVectors(a,s),d.subVectors(n,s),h.cross(d),o.fromBufferAttribute(i,p),l.fromBufferAttribute(i,v),c.fromBufferAttribute(i,m),o.add(h),l.add(h),c.add(h),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(v,l.x,l.y,l.z),i.setXYZ(m,c.x,c.y,c.z)}else for(let u=0,f=t.count;u<f;u+=3)n.fromBufferAttribute(t,u+0),s.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),h.subVectors(a,s),d.subVectors(n,s),h.cross(d),i.setXYZ(u+0,h.x,h.y,h.z),i.setXYZ(u+1,h.x,h.y,h.z),i.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)ii.fromBufferAttribute(e,t),ii.normalize(),e.setXYZ(t,ii.x,ii.y,ii.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,d=o.normalized,u=new c.constructor(l.length*h);let f=0,p=0;for(let v=0,m=l.length;v<m;v++){o.isInterleavedBufferAttribute?f=l[v]*o.data.stride+o.offset:f=l[v]*h;for(let g=0;g<h;g++)u[p++]=c[f++]}return new ht(u,h,d)}if(this.index===null)return _e("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Tt,i=this.index.array,n=this.attributes;for(const o in n){const l=n[o],c=e(l,i);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,d=c.length;h<d;h++){const u=c[h],f=e(u,i);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const n={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d<u;d++){const f=c[d];h.push(f.toJSON(e.data))}h.length>0&&(n[l]=h,s=!0)}s&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const n=e.attributes;for(const c in n){const h=n[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],d=s[c];for(let u=0,f=d.length;u<f;u++)h.push(d[u].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const d=a[c];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class zy{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=lu,this.updateRanges=[],this.version=0,this.uuid=vn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,s=this.stride;n<s;n++)this.array[e+n]=t.array[i+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=vn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=vn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.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 Ai=new P;class mc{constructor(e,t,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ai.fromBufferAttribute(this,t),Ai.applyMatrix4(e),this.setXYZ(t,Ai.x,Ai.y,Ai.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ai.fromBufferAttribute(this,t),Ai.applyNormalMatrix(e),this.setXYZ(t,Ai.x,Ai.y,Ai.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ai.fromBufferAttribute(this,t),Ai.transformDirection(e),this.setXYZ(t,Ai.x,Ai.y,Ai.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=mn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=mt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=mt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=mt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=mt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=mt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=mn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=mn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=mn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=mn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=mt(t,this.array),i=mt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=mt(t,this.array),i=mt(i,this.array),n=mt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=mt(t,this.array),i=mt(i,this.array),n=mt(n,this.array),s=mt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=s,this}clone(e){if(e===void 0){fc("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[n+s])}return new ht(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new mc(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){fc("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[n+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let Hy=0;class ps extends wr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Hy++}),this.uuid=vn(),this.name="",this.type="Material",this.blending=ma,this.side=Bs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Md,this.blendDst=xd,this.blendEquation=ir,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new oe(0,0,0),this.blendAlpha=0,this.depthFunc=Aa,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=wp,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ar,this.stencilZFail=Ar,this.stencilZPass=Ar,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){_e(`Material: parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){_e(`Material: '${t}' 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[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={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(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).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(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).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(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).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(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).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!==ma&&(i.blending=this.blending),this.side!==Bs&&(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!==Md&&(i.blendSrc=this.blendSrc),this.blendDst!==xd&&(i.blendDst=this.blendDst),this.blendEquation!==ir&&(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!==Aa&&(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!==wp&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ar&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ar&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ar&&(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 l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=n(e.textures),a=n(e.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new oe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Te().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Te().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const n=t.length;i=new Array(n);for(let s=0;s!==n;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class ao extends ps{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new oe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Ur;const Ha=new P,Br=new P,zr=new P,Hr=new Te,Ga=new Te,Vg=new Ye,il=new P,Va=new P,nl=new P,kp=new Te,mh=new Te,Np=new Te;class Gr extends _t{constructor(e=new ao){if(super(),this.isSprite=!0,this.type="Sprite",Ur===void 0){Ur=new Tt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new zy(t,5);Ur.setIndex([0,1,2,0,2,3]),Ur.setAttribute("position",new mc(i,3,0,!1)),Ur.setAttribute("uv",new mc(i,2,3,!1))}this.geometry=Ur,this.material=e,this.center=new Te(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Ue('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Br.setFromMatrixScale(this.matrixWorld),Vg.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),zr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Br.multiplyScalar(-zr.z);const i=this.material.rotation;let n,s;i!==0&&(s=Math.cos(i),n=Math.sin(i));const a=this.center;sl(il.set(-.5,-.5,0),zr,a,Br,n,s),sl(Va.set(.5,-.5,0),zr,a,Br,n,s),sl(nl.set(.5,.5,0),zr,a,Br,n,s),kp.set(0,0),mh.set(1,0),Np.set(1,1);let o=e.ray.intersectTriangle(il,Va,nl,!1,Ha);if(o===null&&(sl(Va.set(-.5,.5,0),zr,a,Br,n,s),mh.set(0,1),o=e.ray.intersectTriangle(il,nl,Va,!1,Ha),o===null))return;const l=e.ray.origin.distanceTo(Ha);l<e.near||l>e.far||t.push({distance:l,point:Ha.clone(),uv:nn.getInterpolation(Ha,il,Va,nl,kp,mh,Np,new Te),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function sl(r,e,t,i,n,s){Hr.subVectors(r,t).addScalar(.5).multiply(i),n!==void 0?(Ga.x=s*Hr.x-n*Hr.y,Ga.y=n*Hr.x+s*Hr.y):Ga.copy(Hr),r.copy(e),r.x+=Ga.x,r.y+=Ga.y,r.applyMatrix4(Vg)}const Qn=new P,gh=new P,rl=new P,Ss=new P,vh=new P,al=new P,yh=new P;class ko{constructor(e=new P,t=new P(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Qn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Qn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Qn.copy(this.origin).addScaledVector(this.direction,t),Qn.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){gh.copy(e).add(t).multiplyScalar(.5),rl.copy(t).sub(e).normalize(),Ss.copy(this.origin).sub(gh);const s=e.distanceTo(t)*.5,a=-this.direction.dot(rl),o=Ss.dot(this.direction),l=-Ss.dot(rl),c=Ss.lengthSq(),h=Math.abs(1-a*a);let d,u,f,p;if(h>0)if(d=a*l-o,u=a*o-l,p=s*h,d>=0)if(u>=-p)if(u<=p){const v=1/h;d*=v,u*=v,f=d*(d+a*u+2*o)+u*(a*d+u+2*l)+c}else u=s,d=Math.max(0,-(a*u+o)),f=-d*d+u*(u+2*l)+c;else u=-s,d=Math.max(0,-(a*u+o)),f=-d*d+u*(u+2*l)+c;else u<=-p?(d=Math.max(0,-(-a*s+o)),u=d>0?-s:Math.min(Math.max(-s,-l),s),f=-d*d+u*(u+2*l)+c):u<=p?(d=0,u=Math.min(Math.max(-s,-l),s),f=u*(u+2*l)+c):(d=Math.max(0,-(a*s+o)),u=d>0?s:Math.min(Math.max(-s,-l),s),f=-d*d+u*(u+2*l)+c);else u=a>0?-s:s,d=Math.max(0,-(a*u+o)),f=-d*d+u*(u+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),n&&n.copy(gh).addScaledVector(rl,u),f}intersectSphere(e,t){Qn.subVectors(e.center,this.origin);const i=Qn.dot(this.direction),n=Qn.dot(Qn)-i*i,s=e.radius*e.radius;if(n>s)return null;const a=Math.sqrt(s-n),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(i=(e.min.x-u.x)*c,n=(e.max.x-u.x)*c):(i=(e.max.x-u.x)*c,n=(e.min.x-u.x)*c),h>=0?(s=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(s=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),i>a||s>n||((s>i||isNaN(i))&&(i=s),(a<n||isNaN(n))&&(n=a),d>=0?(o=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),i>l||o>n)||((o>i||i!==i)&&(i=o),(l<n||n!==n)&&(n=l),n<0)?null:this.at(i>=0?i:n,t)}intersectsBox(e){return this.intersectBox(e,Qn)!==null}intersectTriangle(e,t,i,n,s){vh.subVectors(t,e),al.subVectors(i,e),yh.crossVectors(vh,al);let a=this.direction.dot(yh),o;if(a>0){if(n)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ss.subVectors(this.origin,e);const l=o*this.direction.dot(al.crossVectors(Ss,al));if(l<0)return null;const c=o*this.direction.dot(vh.cross(Ss));if(c<0||l+c>a)return null;const h=-o*Ss.dot(yh);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class rn extends ps{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new oe(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 Yn,this.combine=$u,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Op=new Ye,Ys=new ko,ol=new fs,Fp=new P,ll=new P,cl=new P,hl=new P,bh=new P,dl=new P,Up=new P,ul=new P;class We extends _t{constructor(e=new Tt,t=new rn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[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(e,t){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(n,e);const o=this.morphTargetInfluences;if(s&&o){dl.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],d=s[l];h!==0&&(bh.fromBufferAttribute(d,e),a?dl.addScaledVector(bh,h):dl.addScaledVector(bh.sub(t),h))}t.add(dl)}return t}raycast(e,t){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),ol.copy(i.boundingSphere),ol.applyMatrix4(s),Ys.copy(e.ray).recast(e.near),!(ol.containsPoint(Ys.origin)===!1&&(Ys.intersectSphere(ol,Fp)===null||Ys.origin.distanceToSquared(Fp)>(e.far-e.near)**2))&&(Op.copy(s).invert(),Ys.copy(e.ray).applyMatrix4(Op),!(i.boundingBox!==null&&Ys.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Ys)))}_computeIntersections(e,t,i){let n;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,d=s.attributes.normal,u=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,v=u.length;p<v;p++){const m=u[p],g=a[m.materialIndex],x=Math.max(m.start,f.start),M=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let w=x,S=M;w<S;w+=3){const _=o.getX(w),D=o.getX(w+1),y=o.getX(w+2);n=fl(this,g,e,i,c,h,d,_,D,y),n&&(n.faceIndex=Math.floor(w/3),n.face.materialIndex=m.materialIndex,t.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 x=o.getX(m),M=o.getX(m+1),w=o.getX(m+2);n=fl(this,a,e,i,c,h,d,x,M,w),n&&(n.faceIndex=Math.floor(m/3),t.push(n))}}else if(l!==void 0)if(Array.isArray(a))for(let p=0,v=u.length;p<v;p++){const m=u[p],g=a[m.materialIndex],x=Math.max(m.start,f.start),M=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let w=x,S=M;w<S;w+=3){const _=w,D=w+1,y=w+2;n=fl(this,g,e,i,c,h,d,_,D,y),n&&(n.faceIndex=Math.floor(w/3),n.face.materialIndex=m.materialIndex,t.push(n))}}else{const p=Math.max(0,f.start),v=Math.min(l.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const x=m,M=m+1,w=m+2;n=fl(this,a,e,i,c,h,d,x,M,w),n&&(n.faceIndex=Math.floor(m/3),t.push(n))}}}}function Gy(r,e,t,i,n,s,a,o){let l;if(e.side===Ft?l=i.intersectTriangle(a,s,n,!0,o):l=i.intersectTriangle(n,s,a,e.side===Bs,o),l===null)return null;ul.copy(o),ul.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(ul);return c<t.near||c>t.far?null:{distance:c,point:ul.clone(),object:r}}function fl(r,e,t,i,n,s,a,o,l,c){r.getVertexPosition(o,ll),r.getVertexPosition(l,cl),r.getVertexPosition(c,hl);const h=Gy(r,e,t,i,ll,cl,hl,Up);if(h){const d=new P;nn.getBarycoord(Up,ll,cl,hl,d),n&&(h.uv=nn.getInterpolatedAttribute(n,o,l,c,d,new Te)),s&&(h.uv1=nn.getInterpolatedAttribute(s,o,l,c,d,new Te)),a&&(h.normal=nn.getInterpolatedAttribute(a,o,l,c,d,new P),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new P,materialIndex:0};nn.getNormal(ll,cl,hl,u.normal),h.face=u,h.barycoord=d}return h}const Wa=new at,Bp=new at,zp=new at,Vy=new at,Hp=new Ye,pl=new P,wh=new fs,Gp=new Ye,Mh=new ko;class pA extends We{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=mp,this.bindMatrix=new Ye,this.bindMatrixInverse=new Ye,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new bn),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,pl),this.boundingBox.expandByPoint(pl)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new fs),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,pl),this.boundingSphere.expandByPoint(pl)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,n=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),wh.copy(this.boundingSphere),wh.applyMatrix4(n),e.ray.intersectsSphere(wh)!==!1&&(Gp.copy(n).invert(),Mh.copy(e.ray).applyMatrix4(Gp),!(this.boundingBox!==null&&Mh.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Mh)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new at,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.fromBufferAttribute(t,i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===mp?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===W2?this.bindMatrixInverse.copy(this.bindMatrix).invert():_e("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,n=this.geometry;Bp.fromBufferAttribute(n.attributes.skinIndex,e),zp.fromBufferAttribute(n.attributes.skinWeight,e),t.isVector4?(Wa.copy(t),t.set(0,0,0,0)):(Wa.set(...t,1),t.set(0,0,0)),Wa.applyMatrix4(this.bindMatrix);for(let s=0;s<4;s++){const a=zp.getComponent(s);if(a!==0){const o=Bp.getComponent(s);Hp.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(Vy.copy(Wa).applyMatrix4(Hp),a)}}return t.isVector4&&(t.w=Wa.w),t.applyMatrix4(this.bindMatrixInverse)}}class Wy extends _t{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Mr extends di{constructor(e=null,t=1,i=1,n,s,a,o,l,c=Nt,h=Nt,d,u){super(null,a,o,l,c,h,n,s,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Vp=new Ye,Xy=new Ye;class Wg{constructor(e=[],t=[]){this.uuid=vn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){_e("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 Ye)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Ye;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];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 e=this.bones,t=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:Xy;Vp.multiplyMatrices(o,t[s]),Vp.toArray(i,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new Wg(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new Mr(t,e,e,Ti,Pi);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,n=e.bones.length;i<n;i++){const s=e.bones[i];let a=t[s];a===void 0&&(_e("Skeleton: No bone found with UUID:",s),a=new Wy),this.bones.push(a),this.boneInverses.push(new Ye().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let n=0,s=t.length;n<s;n++){const a=t[n];e.bones.push(a.uuid);const o=i[n];e.boneInverses.push(o.toArray())}return e}}class Wp extends ht{constructor(e,t,i,n=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Vr=new Ye,Xp=new Ye,ml=[],qp=new bn,qy=new Ye,Xa=new We,qa=new fs;class mA extends We{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Wp(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,qy)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new bn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Vr),qp.copy(e.boundingBox).applyMatrix4(Vr),this.boundingBox.union(qp)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new fs),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Vr),qa.copy(e.boundingSphere).applyMatrix4(Vr),this.boundingSphere.union(qa)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,n=this.morphTexture.source.data.data,s=i.length+1,a=e*s+1;for(let o=0;o<i.length;o++)i[o]=n[a+o]}raycast(e,t){const i=this.matrixWorld,n=this.count;if(Xa.geometry=this.geometry,Xa.material=this.material,Xa.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),qa.copy(this.boundingSphere),qa.applyMatrix4(i),e.ray.intersectsSphere(qa)!==!1))for(let s=0;s<n;s++){this.getMatrixAt(s,Vr),Xp.multiplyMatrices(i,Vr),Xa.matrixWorld=Xp,Xa.raycast(e,ml);for(let a=0,o=ml.length;a<o;a++){const l=ml[a];l.instanceId=s,l.object=this,t.push(l)}ml.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new Wp(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){const i=t.morphTargetInfluences,n=i.length+1;this.morphTexture===null&&(this.morphTexture=new Mr(new Float32Array(n*this.count),n,this.count,Pc,Pi));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<i.length;c++)a+=i[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=n*e;return s[l]=o,s.set(i,l+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const xh=new P,Yy=new P,Ky=new ze;class Qs{constructor(e=new P(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const n=xh.subVectors(i,t).cross(Yy.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){const n=e.delta(xh),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/s;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(n,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||Ky.getNormalMatrix(e),n=this.coplanarPoint(xh).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ks=new fs,$y=new Te(.5,.5),gl=new P;class cf{constructor(e=new Qs,t=new Qs,i=new Qs,n=new Qs,s=new Qs,a=new Qs){this.planes=[e,t,i,n,s,a]}set(e,t,i,n,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(n),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Hn,i=!1){const n=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],h=s[4],d=s[5],u=s[6],f=s[7],p=s[8],v=s[9],m=s[10],g=s[11],x=s[12],M=s[13],w=s[14],S=s[15];if(n[0].setComponents(c-a,f-h,g-p,S-x).normalize(),n[1].setComponents(c+a,f+h,g+p,S+x).normalize(),n[2].setComponents(c+o,f+d,g+v,S+M).normalize(),n[3].setComponents(c-o,f-d,g-v,S-M).normalize(),i)n[4].setComponents(l,u,m,w).normalize(),n[5].setComponents(c-l,f-u,g-m,S-w).normalize();else if(n[4].setComponents(c-l,f-u,g-m,S-w).normalize(),t===Hn)n[5].setComponents(c+l,f+u,g+m,S+w).normalize();else if(t===Ro)n[5].setComponents(l,u,m,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ks.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ks.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ks)}intersectsSprite(e){Ks.center.set(0,0,0);const t=$y.distanceTo(e.center);return Ks.radius=.7071067811865476+t,Ks.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ks)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<n)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const n=t[i];if(gl.x=n.normal.x>0?e.max.x:e.min.x,gl.y=n.normal.y>0?e.max.y:e.min.y,gl.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(gl)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Zy extends ps{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const gc=new P,vc=new P,Yp=new Ye,Ya=new ko,vl=new fs,Sh=new P,Kp=new P;class Xg extends _t{constructor(e=new Tt,t=new Zy){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let n=1,s=t.count;n<s;n++)gc.fromBufferAttribute(t,n-1),vc.fromBufferAttribute(t,n),i[n]=i[n-1],i[n]+=gc.distanceTo(vc);e.setAttribute("lineDistance",new Ut(i,1))}else _e("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),vl.copy(i.boundingSphere),vl.applyMatrix4(n),vl.radius+=s,e.ray.intersectsSphere(vl)===!1)return;Yp.copy(n).invert(),Ya.copy(e.ray).applyMatrix4(Yp);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=i.index,u=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+=c){const g=h.getX(v),x=h.getX(v+1),M=yl(this,e,Ya,l,g,x,v);M&&t.push(M)}if(this.isLineLoop){const v=h.getX(p-1),m=h.getX(f),g=yl(this,e,Ya,l,v,m,p-1);g&&t.push(g)}}else{const f=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let v=f,m=p-1;v<m;v+=c){const g=yl(this,e,Ya,l,v,v+1,v);g&&t.push(g)}if(this.isLineLoop){const v=yl(this,e,Ya,l,p-1,f,p-1);v&&t.push(v)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[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 yl(r,e,t,i,n,s,a){const o=r.geometry.attributes.position;if(gc.fromBufferAttribute(o,n),vc.fromBufferAttribute(o,s),t.distanceSqToSegment(gc,vc,Sh,Kp)>i)return;Sh.applyMatrix4(r.matrixWorld);const c=e.ray.origin.distanceTo(Sh);if(!(c<e.near||c>e.far))return{distance:c,point:Kp.clone().applyMatrix4(r.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:r}}const $p=new P,Zp=new P;class gA extends Xg{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let n=0,s=t.count;n<s;n+=2)$p.fromBufferAttribute(t,n),Zp.fromBufferAttribute(t,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+$p.distanceTo(Zp);e.setAttribute("lineDistance",new Ut(i,1))}else _e("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class vA extends Xg{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class hf extends ps{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Jp=new Ye,cu=new ko,bl=new fs,wl=new P;class vo extends _t{constructor(e=new Tt,t=new hf){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,s=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),bl.copy(i.boundingSphere),bl.applyMatrix4(n),bl.radius+=s,e.ray.intersectsSphere(bl)===!1)return;Jp.copy(n).invert(),cu.copy(e.ray).applyMatrix4(Jp);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,d=i.attributes.position;if(c!==null){const u=Math.max(0,a.start),f=Math.min(c.count,a.start+a.count);for(let p=u,v=f;p<v;p++){const m=c.getX(p);wl.fromBufferAttribute(d,m),jp(wl,m,l,n,e,t,this)}}else{const u=Math.max(0,a.start),f=Math.min(d.count,a.start+a.count);for(let p=u,v=f;p<v;p++)wl.fromBufferAttribute(d,p),jp(wl,p,l,n,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[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 jp(r,e,t,i,n,s,a){const o=cu.distanceSqToPoint(r);if(o<t){const l=new P;cu.closestPointToPoint(r,l),l.applyMatrix4(i);const c=n.ray.origin.distanceTo(l);if(c<n.near||c>n.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class qg extends di{constructor(e=[],t=gr,i,n,s,a,o,l,c,h){super(e,t,i,n,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Kn extends di{constructor(e,t,i,n,s,a,o,l,c){super(e,t,i,n,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class yr extends di{constructor(e,t,i=yn,n,s,a,o=Nt,l=Nt,c,h=ds,d=1){if(h!==ds&&h!==lr)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:d};super(u,n,s,a,o,l,h,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new af(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Jy extends yr{constructor(e,t=yn,i=gr,n,s,a=Nt,o=Nt,l,c=ds){const h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,i,n,s,a,o,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Yg extends di{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class an extends Tt{constructor(e=1,t=1,i=1,n=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:s,depthSegments:a};const o=this;n=Math.floor(n),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],d=[];let u=0,f=0;p("z","y","x",-1,-1,i,t,e,a,s,0),p("z","y","x",1,-1,i,t,-e,a,s,1),p("x","z","y",1,1,e,i,t,n,a,2),p("x","z","y",1,-1,e,i,-t,n,a,3),p("x","y","z",1,-1,e,t,i,n,s,4),p("x","y","z",-1,-1,e,t,-i,n,s,5),this.setIndex(l),this.setAttribute("position",new Ut(c,3)),this.setAttribute("normal",new Ut(h,3)),this.setAttribute("uv",new Ut(d,2));function p(v,m,g,x,M,w,S,_,D,y,T){const A=w/D,I=S/y,R=w/2,k=S/2,z=_/2,L=D+1,B=y+1;let F=0,V=0;const j=new P;for(let $=0;$<B;$++){const ie=$*I-k;for(let ae=0;ae<L;ae++){const Ve=ae*A-R;j[v]=Ve*x,j[m]=ie*M,j[g]=z,c.push(j.x,j.y,j.z),j[v]=0,j[m]=0,j[g]=_>0?1:-1,h.push(j.x,j.y,j.z),d.push(ae/D),d.push(1-$/y),F+=1}}for(let $=0;$<y;$++)for(let ie=0;ie<D;ie++){const ae=u+ie+L*$,Ve=u+ie+L*($+1),je=u+(ie+1)+L*($+1),He=u+(ie+1)+L*$;l.push(ae,Ve,He),l.push(Ve,je,He),V+=6}o.addGroup(f,V,T),f+=V,u+=F}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new an(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class df extends Tt{constructor(e=1,t=32,i=0,n=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:n},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new P,h=new Te;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,u=3;d<=t;d++,u+=3){const f=i+d/t*n;c.x=e*Math.cos(f),c.y=e*Math.sin(f),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[u]/e+1)/2,h.y=(a[u+1]/e+1)/2,l.push(h.x,h.y)}for(let d=1;d<=t;d++)s.push(d,d+1,0);this.setIndex(s),this.setAttribute("position",new Ut(a,3)),this.setAttribute("normal",new Ut(o,3)),this.setAttribute("uv",new Ut(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new df(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class ms extends Tt{constructor(e=1,t=1,i=1,n=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;n=Math.floor(n),s=Math.floor(s);const h=[],d=[],u=[],f=[];let p=0;const v=[],m=i/2;let g=0;x(),a===!1&&(e>0&&M(!0),t>0&&M(!1)),this.setIndex(h),this.setAttribute("position",new Ut(d,3)),this.setAttribute("normal",new Ut(u,3)),this.setAttribute("uv",new Ut(f,2));function x(){const w=new P,S=new P;let _=0;const D=(t-e)/i;for(let y=0;y<=s;y++){const T=[],A=y/s,I=A*(t-e)+e;for(let R=0;R<=n;R++){const k=R/n,z=k*l+o,L=Math.sin(z),B=Math.cos(z);S.x=I*L,S.y=-A*i+m,S.z=I*B,d.push(S.x,S.y,S.z),w.set(L,D,B).normalize(),u.push(w.x,w.y,w.z),f.push(k,1-A),T.push(p++)}v.push(T)}for(let y=0;y<n;y++)for(let T=0;T<s;T++){const A=v[T][y],I=v[T+1][y],R=v[T+1][y+1],k=v[T][y+1];(e>0||T!==0)&&(h.push(A,I,k),_+=3),(t>0||T!==s-1)&&(h.push(I,R,k),_+=3)}c.addGroup(g,_,0),g+=_}function M(w){const S=p,_=new Te,D=new P;let y=0;const T=w===!0?e:t,A=w===!0?1:-1;for(let R=1;R<=n;R++)d.push(0,m*A,0),u.push(0,A,0),f.push(.5,.5),p++;const I=p;for(let R=0;R<=n;R++){const z=R/n*l+o,L=Math.cos(z),B=Math.sin(z);D.x=T*B,D.y=m*A,D.z=T*L,d.push(D.x,D.y,D.z),u.push(0,A,0),_.x=L*.5+.5,_.y=B*.5*A+.5,f.push(_.x,_.y),p++}for(let R=0;R<n;R++){const k=S+R,z=I+R;w===!0?h.push(z,z+1,k):h.push(z+1,z,k),y+=3}c.addGroup(g,y,w===!0?1:2),g+=y}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ms(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class No extends ms{constructor(e=1,t=1,i=32,n=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,i,n,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new No(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class wn extends Tt{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const s=e/2,a=t/2,o=Math.floor(i),l=Math.floor(n),c=o+1,h=l+1,d=e/o,u=t/l,f=[],p=[],v=[],m=[];for(let g=0;g<h;g++){const x=g*u-a;for(let M=0;M<c;M++){const w=M*d-s;p.push(w,-x,0),v.push(0,0,1),m.push(M/o),m.push(1-g/l)}}for(let g=0;g<l;g++)for(let x=0;x<o;x++){const M=x+c*g,w=x+c*(g+1),S=x+1+c*(g+1),_=x+1+c*g;f.push(M,w,_),f.push(w,S,_)}this.setIndex(f),this.setAttribute("position",new Ut(p,3)),this.setAttribute("normal",new Ut(v,3)),this.setAttribute("uv",new Ut(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wn(e.width,e.height,e.widthSegments,e.heightSegments)}}class yi extends Tt{constructor(e=1,t=32,i=16,n=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(a+o,Math.PI);let c=0;const h=[],d=new P,u=new P,f=[],p=[],v=[],m=[];for(let g=0;g<=i;g++){const x=[],M=g/i,w=a+M*o,S=e*Math.cos(w),_=Math.sqrt(e*e-S*S);let D=0;g===0&&a===0?D=.5/t:g===i&&l===Math.PI&&(D=-.5/t);for(let y=0;y<=t;y++){const T=y/t,A=n+T*s;d.x=-_*Math.cos(A),d.y=S,d.z=_*Math.sin(A),p.push(d.x,d.y,d.z),u.copy(d).normalize(),v.push(u.x,u.y,u.z),m.push(T+D,1-M),x.push(c++)}h.push(x)}for(let g=0;g<i;g++)for(let x=0;x<t;x++){const M=h[g][x+1],w=h[g][x],S=h[g+1][x],_=h[g+1][x+1];(g!==0||a>0)&&f.push(M,w,_),(g!==i-1||l<Math.PI)&&f.push(w,S,_)}this.setIndex(f),this.setAttribute("position",new Ut(p,3)),this.setAttribute("normal",new Ut(v,3)),this.setAttribute("uv",new Ut(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yi(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Ra(r){const e={};for(const t in r){e[t]={};for(const i in r[t]){const n=r[t][i];if(Qp(n))n.isRenderTargetTexture?(_e("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=n.clone();else if(Array.isArray(n))if(Qp(n[0])){const s=[];for(let a=0,o=n.length;a<o;a++)s[a]=n[a].clone();e[t][i]=s}else e[t][i]=n.slice();else e[t][i]=n}}return e}function Ii(r){const e={};for(let t=0;t<r.length;t++){const i=Ra(r[t]);for(const n in i)e[n]=i[n]}return e}function Qp(r){return r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)}function jy(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function Kg(r){const e=r.getRenderTarget();return e===null?r.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:tt.workingColorSpace}const Qy={clone:Ra,merge:Ii};var eb=`void main() {
2108
+ */const Ku="185",M2=0,up=1,x2=2,po=1,S2=2,ro=3,Bs=0,Ft=1,pn=2,Vn=0,ma=1,Zi=2,fp=3,pp=4,E2=5,ir=100,_2=101,T2=102,A2=103,I2=104,D2=200,C2=201,R2=202,P2=203,Md=204,xd=205,L2=206,k2=207,N2=208,O2=209,F2=210,U2=211,B2=212,z2=213,H2=214,Sd=0,Ed=1,_d=2,Aa=3,Td=4,Ad=5,Id=6,Dd=7,$u=0,G2=1,V2=2,Wn=0,Eg=1,_g=2,Tg=3,Ag=4,Ig=5,Dg=6,Cg=7,mp="attached",W2="detached",Rg=300,gr=301,Ia=302,Kc=303,$c=304,Rc=306,Io=1e3,Ri=1001,Cd=1002,Nt=1003,X2=1004,Ko=1005,vt=1006,Zc=1007,or=1008,$i=1009,Pg=1010,Lg=1011,Do=1012,Zu=1013,yn=1014,Pi=1015,ui=1016,Ju=1017,ju=1018,Co=1020,kg=35902,Ng=35899,Og=1021,Fg=1022,Ti=1023,ds=1026,lr=1027,Pc=1028,Qu=1029,vr=1030,ef=1031,tf=1033,ql=33776,Yl=33777,Kl=33778,$l=33779,Rd=35840,Pd=35841,Ld=35842,kd=35843,Nd=36196,Od=37492,Fd=37496,Ud=37488,Bd=37489,ac=37490,zd=37491,Hd=37808,Gd=37809,Vd=37810,Wd=37811,Xd=37812,qd=37813,Yd=37814,Kd=37815,$d=37816,Zd=37817,Jd=37818,jd=37819,Qd=37820,eu=37821,tu=36492,iu=36494,nu=36495,su=36283,ru=36284,oc=36285,au=36286,lc=2300,ou=2301,Jc=2302,gp=2303,vp=2400,yp=2401,bp=2402,q2=2500,hA=0,dA=1,uA=2,Y2=3200,cc=0,K2=1,Ps="",Bi="srgb",hc="srgb-linear",dc="linear",pt="srgb",Ar=7680,wp=519,$2=512,Z2=513,J2=514,nf=515,j2=516,Q2=517,sf=518,ey=519,lu=35044,uc="300 es",Hn=2e3,Ro=2001;function ty(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}function iy(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Po(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function ny(){const r=Po("canvas");return r.style.display="block",r}const Mp={};function fc(...r){const e="THREE."+r.shift();console.log(e,...r)}function Ug(r){const e=r[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=r[1];t&&t.isStackTrace?r[0]+=" "+t.getLocation():r[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return r}function _e(...r){r=Ug(r);const e="THREE."+r.shift();{const t=r[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...r)}}function Ue(...r){r=Ug(r);const e="THREE."+r.shift();{const t=r[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...r)}}function ga(...r){const e=r.join(" ");e in Mp||(Mp[e]=!0,_e(...r))}function sy(r,e,t){return new Promise(function(i,n){function s(){switch(r.clientWaitSync(e,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:n();break;case r.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}const ry={[Sd]:Ed,[_d]:Id,[Td]:Dd,[Aa]:Ad,[Ed]:Sd,[Id]:_d,[Dd]:Td,[Ad]:Aa};class wr{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const n=i[e];if(n!==void 0){const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const n=i.slice(0);for(let s=0,a=n.length;s<a;s++)n[s].call(this,e);e.target=null}}}const Mi=["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 xp=1234567;const mo=Math.PI/180,Da=180/Math.PI;function vn(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Mi[r&255]+Mi[r>>8&255]+Mi[r>>16&255]+Mi[r>>24&255]+"-"+Mi[e&255]+Mi[e>>8&255]+"-"+Mi[e>>16&15|64]+Mi[e>>24&255]+"-"+Mi[t&63|128]+Mi[t>>8&255]+"-"+Mi[t>>16&255]+Mi[t>>24&255]+Mi[i&255]+Mi[i>>8&255]+Mi[i>>16&255]+Mi[i>>24&255]).toLowerCase()}function Je(r,e,t){return Math.max(e,Math.min(t,r))}function rf(r,e){return(r%e+e)%e}function ay(r,e,t,i,n){return i+(r-e)*(n-i)/(t-e)}function oy(r,e,t){return r!==e?(t-r)/(e-r):0}function go(r,e,t){return(1-t)*r+t*e}function ly(r,e,t,i){return go(r,e,1-Math.exp(-t*i))}function cy(r,e=1){return e-Math.abs(rf(r,e*2)-e)}function hy(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function dy(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function uy(r,e){return r+Math.floor(Math.random()*(e-r+1))}function fy(r,e){return r+Math.random()*(e-r)}function py(r){return r*(.5-Math.random())}function my(r){r!==void 0&&(xp=r);let e=xp+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function gy(r){return r*mo}function vy(r){return r*Da}function yy(r){return(r&r-1)===0&&r!==0}function by(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function wy(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function My(r,e,t,i,n){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+i)/2),h=a((e+i)/2),d=s((e-i)/2),u=a((e-i)/2),f=s((i-e)/2),p=a((i-e)/2);switch(n){case"XYX":r.set(o*h,l*d,l*u,o*c);break;case"YZY":r.set(l*u,o*h,l*d,o*c);break;case"ZXZ":r.set(l*d,l*u,o*h,o*c);break;case"XZX":r.set(o*h,l*p,l*f,o*c);break;case"YXY":r.set(l*f,o*h,l*p,o*c);break;case"ZYZ":r.set(l*p,l*f,o*h,o*c);break;default:_e("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function mn(r,e){switch(e.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 mt(r,e){switch(e.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 fA={DEG2RAD:mo,RAD2DEG:Da,generateUUID:vn,clamp:Je,euclideanModulo:rf,mapLinear:ay,inverseLerp:oy,lerp:go,damp:ly,pingpong:cy,smoothstep:hy,smootherstep:dy,randInt:uy,randFloat:fy,randFloatSpread:py,seededRandom:my,degToRad:gy,radToDeg:vy,isPowerOfTwo:yy,ceilPowerOfTwo:by,floorPowerOfTwo:wy,setQuaternionFromProperEuler:My,normalize:mt,denormalize:mn};class Te{static{Te.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),n=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*n+e.x,this.y=s*n+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class qn{constructor(e=0,t=0,i=0,n=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=n}static slerpFlat(e,t,i,n,s,a,o){let l=i[n+0],c=i[n+1],h=i[n+2],d=i[n+3],u=s[a+0],f=s[a+1],p=s[a+2],v=s[a+3];if(d!==v||l!==u||c!==f||h!==p){let m=l*u+c*f+h*p+d*v;m<0&&(u=-u,f=-f,p=-p,v=-v,m=-m);let g=1-o;if(m<.9995){const x=Math.acos(m),M=Math.sin(x);g=Math.sin(g*x)/M,o=Math.sin(o*x)/M,l=l*g+u*o,c=c*g+f*o,h=h*g+p*o,d=d*g+v*o}else{l=l*g+u*o,c=c*g+f*o,h=h*g+p*o,d=d*g+v*o;const x=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=x,c*=x,h*=x,d*=x}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,n,s,a){const o=i[n],l=i[n+1],c=i[n+2],h=i[n+3],d=s[a],u=s[a+1],f=s[a+2],p=s[a+3];return e[t]=o*p+h*d+l*f-c*u,e[t+1]=l*p+h*u+c*d-o*f,e[t+2]=c*p+h*f+o*u-l*d,e[t+3]=h*p-o*d-l*u-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,n=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),h=o(n/2),d=o(s/2),u=l(i/2),f=l(n/2),p=l(s/2);switch(a){case"XYZ":this._x=u*h*d+c*f*p,this._y=c*f*d-u*h*p,this._z=c*h*p+u*f*d,this._w=c*h*d-u*f*p;break;case"YXZ":this._x=u*h*d+c*f*p,this._y=c*f*d-u*h*p,this._z=c*h*p-u*f*d,this._w=c*h*d+u*f*p;break;case"ZXY":this._x=u*h*d-c*f*p,this._y=c*f*d+u*h*p,this._z=c*h*p+u*f*d,this._w=c*h*d-u*f*p;break;case"ZYX":this._x=u*h*d-c*f*p,this._y=c*f*d+u*h*p,this._z=c*h*p-u*f*d,this._w=c*h*d+u*f*p;break;case"YZX":this._x=u*h*d+c*f*p,this._y=c*f*d+u*h*p,this._z=c*h*p-u*f*d,this._w=c*h*d-u*f*p;break;case"XZY":this._x=u*h*d-c*f*p,this._y=c*f*d-u*h*p,this._z=c*h*p+u*f*d,this._w=c*h*d+u*f*p;break;default:_e("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],n=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],u=i+o+d;if(u>0){const f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(h-l)*f,this._y=(s-c)*f,this._z=(a-n)*f}else if(i>o&&i>d){const f=2*Math.sqrt(1+i-o-d);this._w=(h-l)/f,this._x=.25*f,this._y=(n+a)/f,this._z=(s+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-i-d);this._w=(s-c)/f,this._x=(n+a)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+d-i-o);this._w=(a-n)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Je(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const n=Math.min(1,t/i);return this.slerp(e,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,n=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=i*h+a*o+n*c-s*l,this._y=n*h+a*l+s*o-i*c,this._z=s*h+a*c+i*l-n*o,this._w=a*h-i*o-n*l-s*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,n=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,n=-n,s=-s,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+i*t,this._y=this._y*l+n*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+n*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class P{static{P.prototype.isVector3=!0}constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Sp.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Sp.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*n,this.y=s[1]*t+s[4]*i+s[7]*n,this.z=s[2]*t+s[5]*i+s[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*n+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*n+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*n+s[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*n-o*i),h=2*(o*t-s*n),d=2*(s*i-a*t);return this.x=t+l*c+a*d-o*h,this.y=i+l*h+o*c-s*d,this.z=n+l*d+s*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,n=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*n,this.y=s[1]*t+s[5]*i+s[9]*n,this.z=s[2]*t+s[6]*i+s[10]*n,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,n=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=n*l-s*o,this.y=s*a-i*l,this.z=i*o-n*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return jc.copy(this).projectOnVector(e),this.sub(jc)}reflect(e){return this.sub(jc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const jc=new P,Sp=new qn;class He{static{He.prototype.isMatrix3=!0}constructor(e,t,i,n,s,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,n,s,a,o,l,c)}set(e,t,i,n,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=n,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=i,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,s=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],h=i[4],d=i[7],u=i[2],f=i[5],p=i[8],v=n[0],m=n[3],g=n[6],x=n[1],M=n[4],w=n[7],S=n[2],_=n[5],D=n[8];return s[0]=a*v+o*x+l*S,s[3]=a*m+o*M+l*_,s[6]=a*g+o*w+l*D,s[1]=c*v+h*x+d*S,s[4]=c*m+h*M+d*_,s[7]=c*g+h*w+d*D,s[2]=u*v+f*x+p*S,s[5]=u*m+f*M+p*_,s[8]=u*g+f*w+p*D,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-i*s*h+i*o*l+n*s*c-n*a*l}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,u=o*l-h*s,f=c*s-a*l,p=t*d+i*u+n*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/p;return e[0]=d*v,e[1]=(n*c-h*i)*v,e[2]=(o*i-n*a)*v,e[3]=u*v,e[4]=(h*t-n*l)*v,e[5]=(n*s-o*t)*v,e[6]=f*v,e[7]=(i*l-c*t)*v,e[8]=(a*t-i*s)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,n,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-n*c,n*l,-n*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return ga("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Qc.makeScale(e,t)),this}rotate(e){return ga("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Qc.makeRotation(-e)),this}translate(e,t){return ga("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Qc.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let n=0;n<9;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Qc=new He,Ep=new He().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),_p=new He().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function xy(){const r={enabled:!0,workingColorSpace:hc,spaces:{},convert:function(n,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===pt&&(n.r=cs(n.r),n.g=cs(n.g),n.b=cs(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===pt&&(n.r=va(n.r),n.g=va(n.g),n.b=va(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===Ps?dc: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 ga("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(n,s)},toWorkingColorSpace:function(n,s){return ga("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(n,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return r.define({[hc]:{primaries:e,whitePoint:i,transfer:dc,toXYZ:Ep,fromXYZ:_p,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Bi},outputColorSpaceConfig:{drawingBufferColorSpace:Bi}},[Bi]:{primaries:e,whitePoint:i,transfer:pt,toXYZ:Ep,fromXYZ:_p,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Bi}}}),r}const tt=xy();function cs(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function va(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Ir;class Sy{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Ir===void 0&&(Ir=Po("canvas")),Ir.width=e.width,Ir.height=e.height;const n=Ir.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),i=Ir}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Po("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const n=i.getImageData(0,0,e.width,e.height),s=n.data;for(let a=0;a<s.length;a++)s[a]=cs(s[a]/255)*255;return i.putImageData(n,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(cs(t[i]/255)*255):t[i]=cs(t[i]);return{data:t,width:e.width,height:e.height}}else return _e("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Ey=0;class af{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ey++}),this.uuid=vn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.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(eh(n[a].image)):s.push(eh(n[a]))}else s=eh(n);i.url=s}return t||(e.images[this.uuid]=i),i}}function eh(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?Sy.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(_e("Texture: Unable to serialize Texture."),{})}let _y=0;const th=new P;class di extends wr{constructor(e=di.DEFAULT_IMAGE,t=di.DEFAULT_MAPPING,i=Ri,n=Ri,s=vt,a=or,o=Ti,l=$i,c=di.DEFAULT_ANISOTROPY,h=Ps){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:_y++}),this.uuid=vn(),this.name="",this.source=new af(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Te(0,0),this.repeat=new Te(1,1),this.center=new Te(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new He,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=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(th).x}get height(){return this.source.getSize(th).y}get depth(){return this.source.getSize(th).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){_e(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){_e(`Texture.setValues(): property '${t}' 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[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Rg)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Io:e.x=e.x-Math.floor(e.x);break;case Ri:e.x=e.x<0?0:1;break;case Cd:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Io:e.y=e.y-Math.floor(e.y);break;case Ri:e.y=e.y<0?0:1;break;case Cd:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}di.DEFAULT_IMAGE=null;di.DEFAULT_MAPPING=Rg;di.DEFAULT_ANISOTROPY=1;class at{static{at.prototype.isVector4=!0}constructor(e=0,t=0,i=0,n=1){this.x=e,this.y=t,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*n+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*n+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*n+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*n+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,n,s;const l=e.elements,c=l[0],h=l[4],d=l[8],u=l[1],f=l[5],p=l[9],v=l[2],m=l[6],g=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-v)<.01&&Math.abs(p-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+v)<.1&&Math.abs(p+m)<.1&&Math.abs(c+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const M=(c+1)/2,w=(f+1)/2,S=(g+1)/2,_=(h+u)/4,D=(d+v)/4,y=(p+m)/4;return M>w&&M>S?M<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(M),n=_/i,s=D/i):w>S?w<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(w),i=_/n,s=y/n):S<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(S),i=D/s,n=y/s),this.set(i,n,s,t),this}let x=Math.sqrt((m-p)*(m-p)+(d-v)*(d-v)+(u-h)*(u-h));return Math.abs(x)<.001&&(x=1),this.x=(m-p)/x,this.y=(d-v)/x,this.z=(u-h)/x,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this.w=Je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this.w=Je(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Ty extends wr{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:vt,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=e,this.height=t,this.depth=i.depth,this.scissor=new at(0,0,e,t),this.scissorTest=!1,this.viewport=new at(0,0,e,t),this.textures=[];const n={width:e,height:t,depth:i.depth},s=new di(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(e={}){const t={minFilter:vt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let n=0,s=this.textures.length;n<s;n++)this.textures[n].image.width=e,this.textures[n].image.height=t,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,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const n=Object.assign({},e.textures[t].image);this.textures[t].source=new af(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class vi extends Ty{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class Bg extends di{constructor(e=null,t=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=Nt,this.minFilter=Nt,this.wrapR=Ri,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class zg extends di{constructor(e=null,t=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=Nt,this.minFilter=Nt,this.wrapR=Ri,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ye{static{Ye.prototype.isMatrix4=!0}constructor(e,t,i,n,s,a,o,l,c,h,d,u,f,p,v,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,n,s,a,o,l,c,h,d,u,f,p,v,m)}set(e,t,i,n,s,a,o,l,c,h,d,u,f,p,v,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=n,g[1]=s,g[5]=a,g[9]=o,g[13]=l,g[2]=c,g[6]=h,g[10]=d,g[14]=u,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 Ye().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,i=e.elements,n=1/Dr.setFromMatrixColumn(e,0).length(),s=1/Dr.setFromMatrixColumn(e,1).length(),a=1/Dr.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,n=e.y,s=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(n),c=Math.sin(n),h=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){const u=a*h,f=a*d,p=o*h,v=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=f+p*c,t[5]=u-v*c,t[9]=-o*l,t[2]=v-u*c,t[6]=p+f*c,t[10]=a*l}else if(e.order==="YXZ"){const u=l*h,f=l*d,p=c*h,v=c*d;t[0]=u+v*o,t[4]=p*o-f,t[8]=a*c,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=f*o-p,t[6]=v+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*h,f=l*d,p=c*h,v=c*d;t[0]=u-v*o,t[4]=-a*d,t[8]=p+f*o,t[1]=f+p*o,t[5]=a*h,t[9]=v-u*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*h,f=a*d,p=o*h,v=o*d;t[0]=l*h,t[4]=p*c-f,t[8]=u*c+v,t[1]=l*d,t[5]=v*c+u,t[9]=f*c-p,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,f=a*c,p=o*l,v=o*c;t[0]=l*h,t[4]=v-u*d,t[8]=p*d+f,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=f*d+p,t[10]=u-v*d}else if(e.order==="XZY"){const u=a*l,f=a*c,p=o*l,v=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=u*d+v,t[5]=a*h,t[9]=f*d-p,t[2]=p*d-f,t[6]=o*h,t[10]=v*d+u}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Ay,e,Iy)}lookAt(e,t,i){const n=this.elements;return Gi.subVectors(e,t),Gi.lengthSq()===0&&(Gi.z=1),Gi.normalize(),bs.crossVectors(i,Gi),bs.lengthSq()===0&&(Math.abs(i.z)===1?Gi.x+=1e-4:Gi.z+=1e-4,Gi.normalize(),bs.crossVectors(i,Gi)),bs.normalize(),$o.crossVectors(Gi,bs),n[0]=bs.x,n[4]=$o.x,n[8]=Gi.x,n[1]=bs.y,n[5]=$o.y,n[9]=Gi.y,n[2]=bs.z,n[6]=$o.z,n[10]=Gi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,s=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],h=i[1],d=i[5],u=i[9],f=i[13],p=i[2],v=i[6],m=i[10],g=i[14],x=i[3],M=i[7],w=i[11],S=i[15],_=n[0],D=n[4],y=n[8],T=n[12],A=n[1],I=n[5],R=n[9],k=n[13],z=n[2],L=n[6],B=n[10],F=n[14],V=n[3],j=n[7],$=n[11],ie=n[15];return s[0]=a*_+o*A+l*z+c*V,s[4]=a*D+o*I+l*L+c*j,s[8]=a*y+o*R+l*B+c*$,s[12]=a*T+o*k+l*F+c*ie,s[1]=h*_+d*A+u*z+f*V,s[5]=h*D+d*I+u*L+f*j,s[9]=h*y+d*R+u*B+f*$,s[13]=h*T+d*k+u*F+f*ie,s[2]=p*_+v*A+m*z+g*V,s[6]=p*D+v*I+m*L+g*j,s[10]=p*y+v*R+m*B+g*$,s[14]=p*T+v*k+m*F+g*ie,s[3]=x*_+M*A+w*z+S*V,s[7]=x*D+M*I+w*L+S*j,s[11]=x*y+M*R+w*B+S*$,s[15]=x*T+M*k+w*F+S*ie,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],n=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],u=e[10],f=e[14],p=e[3],v=e[7],m=e[11],g=e[15],x=l*f-c*u,M=o*f-c*d,w=o*u-l*d,S=a*f-c*h,_=a*u-l*h,D=a*d-o*h;return t*(v*x-m*M+g*w)-i*(p*x-m*S+g*_)+n*(p*M-v*S+g*D)-s*(p*w-v*_+m*D)}determinantAffine(){const e=this.elements,t=e[0],i=e[4],n=e[8],s=e[1],a=e[5],o=e[9],l=e[2],c=e[6],h=e[10];return t*(a*h-o*c)-i*(s*h-o*l)+n*(s*c-a*l)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],u=e[10],f=e[11],p=e[12],v=e[13],m=e[14],g=e[15],x=t*o-i*a,M=t*l-n*a,w=t*c-s*a,S=i*l-n*o,_=i*c-s*o,D=n*c-s*l,y=h*v-d*p,T=h*m-u*p,A=h*g-f*p,I=d*m-u*v,R=d*g-f*v,k=u*g-f*m,z=x*k-M*R+w*I+S*A-_*T+D*y;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const L=1/z;return e[0]=(o*k-l*R+c*I)*L,e[1]=(n*R-i*k-s*I)*L,e[2]=(v*D-m*_+g*S)*L,e[3]=(u*_-d*D-f*S)*L,e[4]=(l*A-a*k-c*T)*L,e[5]=(t*k-n*A+s*T)*L,e[6]=(m*w-p*D-g*M)*L,e[7]=(h*D-u*w+f*M)*L,e[8]=(a*R-o*A+c*y)*L,e[9]=(i*A-t*R-s*y)*L,e[10]=(p*_-v*w+g*x)*L,e[11]=(d*w-h*_-f*x)*L,e[12]=(o*T-a*I-l*y)*L,e[13]=(t*I-i*T+n*y)*L,e[14]=(v*M-p*S-m*x)*L,e[15]=(h*S-d*M+u*x)*L,this}scale(e){const t=this.elements,i=e.x,n=e.y,s=e.z;return t[0]*=i,t[4]*=n,t[8]*=s,t[1]*=i,t[5]*=n,t[9]*=s,t[2]*=i,t[6]*=n,t[10]*=s,t[3]*=i,t[7]*=n,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),n=Math.sin(t),s=1-i,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+i,c*o-n*l,c*l+n*o,0,c*o+n*l,h*o+i,h*l-n*a,0,c*l-n*o,h*l+n*a,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,s,a){return this.set(1,i,s,0,e,1,a,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,d=o+o,u=s*c,f=s*h,p=s*d,v=a*h,m=a*d,g=o*d,x=l*c,M=l*h,w=l*d,S=i.x,_=i.y,D=i.z;return n[0]=(1-(v+g))*S,n[1]=(f+w)*S,n[2]=(p-M)*S,n[3]=0,n[4]=(f-w)*_,n[5]=(1-(u+g))*_,n[6]=(m+x)*_,n[7]=0,n[8]=(p+M)*D,n[9]=(m-x)*D,n[10]=(1-(u+v))*D,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){const n=this.elements;e.x=n[12],e.y=n[13],e.z=n[14];const s=this.determinantAffine();if(s===0)return i.set(1,1,1),t.identity(),this;let a=Dr.set(n[0],n[1],n[2]).length();const o=Dr.set(n[4],n[5],n[6]).length(),l=Dr.set(n[8],n[9],n[10]).length();s<0&&(a=-a),on.copy(this);const c=1/a,h=1/o,d=1/l;return on.elements[0]*=c,on.elements[1]*=c,on.elements[2]*=c,on.elements[4]*=h,on.elements[5]*=h,on.elements[6]*=h,on.elements[8]*=d,on.elements[9]*=d,on.elements[10]*=d,t.setFromRotationMatrix(on),i.x=a,i.y=o,i.z=l,this}makePerspective(e,t,i,n,s,a,o=Hn,l=!1){const c=this.elements,h=2*s/(t-e),d=2*s/(i-n),u=(t+e)/(t-e),f=(i+n)/(i-n);let p,v;if(l)p=s/(a-s),v=a*s/(a-s);else if(o===Hn)p=-(a+s)/(a-s),v=-2*a*s/(a-s);else if(o===Ro)p=-a/(a-s),v=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=d,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,n,s,a,o=Hn,l=!1){const c=this.elements,h=2/(t-e),d=2/(i-n),u=-(t+e)/(t-e),f=-(i+n)/(i-n);let p,v;if(l)p=1/(a-s),v=a/(a-s);else if(o===Hn)p=-2/(a-s),v=-(a+s)/(a-s);else if(o===Ro)p=-1/(a-s),v=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=d,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let n=0;n<16;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Dr=new P,on=new Ye,Ay=new P(0,0,0),Iy=new P(1,1,1),bs=new P,$o=new P,Gi=new P,Tp=new Ye,Ap=new qn;class Yn{constructor(e=0,t=0,i=0,n=Yn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=n}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const n=e.elements,s=n[0],a=n[4],o=n[8],l=n[1],c=n[5],h=n[9],d=n[2],u=n[6],f=n[10];switch(t){case"XYZ":this._y=Math.asin(Je(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Je(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(Je(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Je(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Je(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Je(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:_e("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Tp.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Tp,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ap.setFromEuler(this),this.setFromQuaternion(Ap,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Yn.DEFAULT_ORDER="XYZ";class of{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Dy=0;const Ip=new P,Cr=new qn,$n=new Ye,Zo=new P,Fa=new P,Cy=new P,Ry=new qn,Dp=new P(1,0,0),Cp=new P(0,1,0),Rp=new P(0,0,1),Pp={type:"added"},Py={type:"removed"},Rr={type:"childadded",child:null},ih={type:"childremoved",child:null};class _t extends wr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Dy++}),this.uuid=vn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();const e=new P,t=new Yn,i=new qn,n=new P(1,1,1);function s(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Ye},normalMatrix:{value:new He}}),this.matrix=new Ye,this.matrixWorld=new Ye,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new of,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(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Cr.setFromAxisAngle(e,t),this.quaternion.multiply(Cr),this}rotateOnWorldAxis(e,t){return Cr.setFromAxisAngle(e,t),this.quaternion.premultiply(Cr),this}rotateX(e){return this.rotateOnAxis(Dp,e)}rotateY(e){return this.rotateOnAxis(Cp,e)}rotateZ(e){return this.rotateOnAxis(Rp,e)}translateOnAxis(e,t){return Ip.copy(e).applyQuaternion(this.quaternion),this.position.add(Ip.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Dp,e)}translateY(e){return this.translateOnAxis(Cp,e)}translateZ(e){return this.translateOnAxis(Rp,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4($n.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Zo.copy(e):Zo.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Fa.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?$n.lookAt(Fa,Zo,this.up):$n.lookAt(Zo,Fa,this.up),this.quaternion.setFromRotationMatrix($n),n&&($n.extractRotation(n.matrixWorld),Cr.setFromRotationMatrix($n),this.quaternion.premultiply(Cr.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Ue("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Pp),Rr.child=e,this.dispatchEvent(Rr),Rr.child=null):Ue("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Py),ih.child=e,this.dispatchEvent(ih),ih.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),$n.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),$n.multiply(e.parent.matrixWorld)),e.applyMatrix4($n),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Pp),Rr.child=e,this.dispatchEvent(Rr),Rr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,n=this.children.length;i<n;i++){const a=this.children[i].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const n=this.children;for(let s=0,a=n.length;s<a;s++)n[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Fa,e,Cy),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Fa,Ry,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,i=e.y,n=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*i-s[8]*n,s[13]+=i-s[1]*t-s[5]*i-s[9]*n,s[14]+=n-s[2]*t-s[6]*i-s[10]*n}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t,i=!1){const n=this.parent;if(e===!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),t===!0){const s=this.children;for(let a=0,o=s.length;a<o;a++)s[a].updateWorldMatrix(!1,!0,i)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={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(e),n.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const d=l[c];s(e.shapes,d)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));n.material=o}else n.material=s(e.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(e).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];n.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),d=a(e.shapes),u=a(e.skeletons),f=a(e.animations),p=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),h.length>0&&(i.images=h),d.length>0&&(i.shapes=d),u.length>0&&(i.skeletons=u),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=n,i;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const n=e.children[i];this.add(n.clone())}return this}}_t.DEFAULT_UP=new P(0,1,0);_t.DEFAULT_MATRIX_AUTO_UPDATE=!0;_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class ci extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Ly={type:"move"};class nh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ci,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 ci,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ci,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let n=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const m=t.getJointPose(v,i),g=this._getHandJoint(c,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=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],u=h.position.distanceTo(d.position),f=.02,p=.005;c.inputState.pinching&&u>f+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(n=t.getPose(e.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(Ly)))}return o!==null&&(o.visible=n!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new ci;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const Hg={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},ws={h:0,s:0,l:0},Jo={h:0,s:0,l:0};function sh(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class oe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const n=e;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Bi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,tt.colorSpaceToWorking(this,t),this}setRGB(e,t,i,n=tt.workingColorSpace){return this.r=e,this.g=t,this.b=i,tt.colorSpaceToWorking(this,n),this}setHSL(e,t,i,n=tt.workingColorSpace){if(e=rf(e,1),t=Je(t,0,1),i=Je(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=sh(a,s,e+1/3),this.g=sh(a,s,e),this.b=sh(a,s,e-1/3)}return tt.colorSpaceToWorking(this,n),this}setStyle(e,t=Bi){function i(s){s!==void 0&&parseFloat(s)<1&&_e("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){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,t);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,t);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,t);break;default:_e("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){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,t);if(a===6)return this.setHex(parseInt(s,16),t);_e("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Bi){const i=Hg[e.toLowerCase()];return i!==void 0?this.setHex(i,t):_e("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=cs(e.r),this.g=cs(e.g),this.b=cs(e.b),this}copyLinearToSRGB(e){return this.r=va(e.r),this.g=va(e.g),this.b=va(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Bi){return tt.workingToColorSpace(xi.copy(this),e),Math.round(Je(xi.r*255,0,255))*65536+Math.round(Je(xi.g*255,0,255))*256+Math.round(Je(xi.b*255,0,255))}getHexString(e=Bi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=tt.workingColorSpace){tt.workingToColorSpace(xi.copy(this),t);const i=xi.r,n=xi.g,s=xi.b,a=Math.max(i,n,s),o=Math.min(i,n,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=h<=.5?d/(a+o):d/(2-a-o),a){case i:l=(n-s)/d+(n<s?6:0);break;case n:l=(s-i)/d+2;break;case s:l=(i-n)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=tt.workingColorSpace){return tt.workingToColorSpace(xi.copy(this),t),e.r=xi.r,e.g=xi.g,e.b=xi.b,e}getStyle(e=Bi){tt.workingToColorSpace(xi.copy(this),e);const t=xi.r,i=xi.g,n=xi.b;return e!==Bi?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(e,t,i){return this.getHSL(ws),this.setHSL(ws.h+e,ws.s+t,ws.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(ws),e.getHSL(Jo);const i=go(ws.h,Jo.h,t),n=go(ws.s,Jo.s,t),s=go(ws.l,Jo.l,t);return this.setHSL(i,n,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,n=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*n,this.g=s[1]*t+s[4]*i+s[7]*n,this.b=s[2]*t+s[5]*i+s[8]*n,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const xi=new oe;oe.NAMES=Hg;class pc{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new oe(e),this.near=t,this.far=i}clone(){return new pc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Ca extends _t{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 Yn,this.environmentIntensity=1,this.environmentRotation=new Yn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const ln=new P,Zn=new P,rh=new P,Jn=new P,Pr=new P,Lr=new P,Lp=new P,ah=new P,oh=new P,lh=new P,ch=new at,hh=new at,dh=new at;class nn{constructor(e=new P,t=new P,i=new P){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),ln.subVectors(e,t),n.cross(ln);const s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(e,t,i,n,s){ln.subVectors(n,t),Zn.subVectors(i,t),rh.subVectors(e,t);const a=ln.dot(ln),o=ln.dot(Zn),l=ln.dot(rh),c=Zn.dot(Zn),h=Zn.dot(rh),d=a*c-o*o;if(d===0)return s.set(0,0,0),null;const u=1/d,f=(c*l-o*h)*u,p=(a*h-o*l)*u;return s.set(1-f-p,p,f)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,Jn)===null?!1:Jn.x>=0&&Jn.y>=0&&Jn.x+Jn.y<=1}static getInterpolation(e,t,i,n,s,a,o,l){return this.getBarycoord(e,t,i,n,Jn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Jn.x),l.addScaledVector(a,Jn.y),l.addScaledVector(o,Jn.z),l)}static getInterpolatedAttribute(e,t,i,n,s,a){return ch.setScalar(0),hh.setScalar(0),dh.setScalar(0),ch.fromBufferAttribute(e,t),hh.fromBufferAttribute(e,i),dh.fromBufferAttribute(e,n),a.setScalar(0),a.addScaledVector(ch,s.x),a.addScaledVector(hh,s.y),a.addScaledVector(dh,s.z),a}static isFrontFacing(e,t,i,n){return ln.subVectors(i,t),Zn.subVectors(e,t),ln.cross(Zn).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ln.subVectors(this.c,this.b),Zn.subVectors(this.a,this.b),ln.cross(Zn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return nn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return nn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,n,s){return nn.getInterpolation(e,this.a,this.b,this.c,t,i,n,s)}containsPoint(e){return nn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return nn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,s=this.c;let a,o;Pr.subVectors(n,i),Lr.subVectors(s,i),ah.subVectors(e,i);const l=Pr.dot(ah),c=Lr.dot(ah);if(l<=0&&c<=0)return t.copy(i);oh.subVectors(e,n);const h=Pr.dot(oh),d=Lr.dot(oh);if(h>=0&&d<=h)return t.copy(n);const u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(i).addScaledVector(Pr,a);lh.subVectors(e,s);const f=Pr.dot(lh),p=Lr.dot(lh);if(p>=0&&f<=p)return t.copy(s);const v=f*c-l*p;if(v<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(i).addScaledVector(Lr,o);const m=h*p-f*d;if(m<=0&&d-h>=0&&f-p>=0)return Lp.subVectors(s,n),o=(d-h)/(d-h+(f-p)),t.copy(n).addScaledVector(Lp,o);const g=1/(m+v+u);return a=v*g,o=u*g,t.copy(i).addScaledVector(Pr,a).addScaledVector(Lr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class bn{constructor(e=new P(1/0,1/0,1/0),t=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(cn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(cn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=cn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,cn):cn.fromBufferAttribute(s,a),cn.applyMatrix4(e.matrixWorld),this.expandByPoint(cn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),jo.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),jo.copy(i.boundingBox)),jo.applyMatrix4(e.matrixWorld),this.union(jo)}const n=e.children;for(let s=0,a=n.length;s<a;s++)this.expandByObject(n[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,cn),cn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ua),Qo.subVectors(this.max,Ua),kr.subVectors(e.a,Ua),Nr.subVectors(e.b,Ua),Or.subVectors(e.c,Ua),Ms.subVectors(Nr,kr),xs.subVectors(Or,Nr),Xs.subVectors(kr,Or);let t=[0,-Ms.z,Ms.y,0,-xs.z,xs.y,0,-Xs.z,Xs.y,Ms.z,0,-Ms.x,xs.z,0,-xs.x,Xs.z,0,-Xs.x,-Ms.y,Ms.x,0,-xs.y,xs.x,0,-Xs.y,Xs.x,0];return!uh(t,kr,Nr,Or,Qo)||(t=[1,0,0,0,1,0,0,0,1],!uh(t,kr,Nr,Or,Qo))?!1:(el.crossVectors(Ms,xs),t=[el.x,el.y,el.z],uh(t,kr,Nr,Or,Qo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,cn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(cn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(jn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),jn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),jn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),jn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),jn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),jn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),jn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),jn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(jn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const jn=[new P,new P,new P,new P,new P,new P,new P,new P],cn=new P,jo=new bn,kr=new P,Nr=new P,Or=new P,Ms=new P,xs=new P,Xs=new P,Ua=new P,Qo=new P,el=new P,qs=new P;function uh(r,e,t,i,n){for(let s=0,a=r.length-3;s<=a;s+=3){qs.fromArray(r,s);const o=n.x*Math.abs(qs.x)+n.y*Math.abs(qs.y)+n.z*Math.abs(qs.z),l=e.dot(qs),c=t.dot(qs),h=i.dot(qs);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const as=ky();function ky(){const r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),i=new Uint32Array(512),n=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(i[l]=0,i[l|256]=32768,n[l]=24,n[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,n[l]=-c-1,n[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,n[l]=13,n[l|256]=13):c<128?(i[l]=31744,i[l|256]=64512,n[l]=24,n[l|256]=24):(i[l]=31744,i[l|256]=64512,n[l]=13,n[l|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:n,mantissaTable:s,exponentTable:a,offsetTable:o}}function Ny(r){Math.abs(r)>65504&&_e("DataUtils.toHalfFloat(): Value out of range."),r=Je(r,-65504,65504),as.floatView[0]=r;const e=as.uint32View[0],t=e>>23&511;return as.baseTable[t]+((e&8388607)>>as.shiftTable[t])}function Oy(r){const e=r>>10;return as.uint32View[0]=as.mantissaTable[as.offsetTable[e]+(r&1023)]+as.exponentTable[e],as.floatView[0]}class hs{static toHalfFloat(e){return Ny(e)}static fromHalfFloat(e){return Oy(e)}}const Jt=new P,tl=new Te;let Fy=0;class ht extends wr{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Fy++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=lu,this.updateRanges=[],this.gpuType=Pi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,s=this.itemSize;n<s;n++)this.array[e+n]=t.array[i+n];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)tl.fromBufferAttribute(this,t),tl.applyMatrix3(e),this.setXY(t,tl.x,tl.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Jt.fromBufferAttribute(this,t),Jt.applyMatrix3(e),this.setXYZ(t,Jt.x,Jt.y,Jt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Jt.fromBufferAttribute(this,t),Jt.applyMatrix4(e),this.setXYZ(t,Jt.x,Jt.y,Jt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Jt.fromBufferAttribute(this,t),Jt.applyNormalMatrix(e),this.setXYZ(t,Jt.x,Jt.y,Jt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Jt.fromBufferAttribute(this,t),Jt.transformDirection(e),this.setXYZ(t,Jt.x,Jt.y,Jt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=mn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=mt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=mn(t,this.array)),t}setX(e,t){return this.normalized&&(t=mt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=mn(t,this.array)),t}setY(e,t){return this.normalized&&(t=mt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=mn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=mt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=mn(t,this.array)),t}setW(e,t){return this.normalized&&(t=mt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=mt(t,this.array),i=mt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,n){return e*=this.itemSize,this.normalized&&(t=mt(t,this.array),i=mt(i,this.array),n=mt(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,s){return e*=this.itemSize,this.normalized&&(t=mt(t,this.array),i=mt(i,this.array),n=mt(n,this.array),s=mt(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==lu&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class Gg extends ht{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class lf extends ht{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Ut extends ht{constructor(e,t,i){super(new Float32Array(e),t,i)}}const Uy=new bn,Ba=new P,fh=new P;class fs{constructor(e=new P,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):Uy.setFromPoints(e).getCenter(i);let n=0;for(let s=0,a=e.length;s<a;s++)n=Math.max(n,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(n),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ba.subVectors(e,this.center);const t=Ba.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),n=(i-this.radius)*.5;this.center.addScaledVector(Ba,n/i),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(fh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ba.copy(e.center).add(fh)),this.expandByPoint(Ba.copy(e.center).sub(fh))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let By=0;const Qi=new Ye,ph=new _t,Fr=new P,Vi=new bn,za=new bn,ii=new P;class Tt extends wr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:By++}),this.uuid=vn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(ty(e)?lf:Gg)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new He().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Qi.makeRotationFromQuaternion(e),this.applyMatrix4(Qi),this}rotateX(e){return Qi.makeRotationX(e),this.applyMatrix4(Qi),this}rotateY(e){return Qi.makeRotationY(e),this.applyMatrix4(Qi),this}rotateZ(e){return Qi.makeRotationZ(e),this.applyMatrix4(Qi),this}translate(e,t,i){return Qi.makeTranslation(e,t,i),this.applyMatrix4(Qi),this}scale(e,t,i){return Qi.makeScale(e,t,i),this.applyMatrix4(Qi),this}lookAt(e){return ph.lookAt(e),ph.updateMatrix(),this.applyMatrix4(ph.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Fr).negate(),this.translate(Fr.x,Fr.y,Fr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let n=0,s=e.length;n<s;n++){const a=e[n];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ut(i,3))}else{const i=Math.min(e.length,t.count);for(let n=0;n<i;n++){const s=e[n];t.setXYZ(n,s.x,s.y,s.z||0)}e.length>t.count&&_e("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new bn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,n=t.length;i<n;i++){const s=t[i];Vi.setFromBufferAttribute(s),this.morphTargetsRelative?(ii.addVectors(this.boundingBox.min,Vi.min),this.boundingBox.expandByPoint(ii),ii.addVectors(this.boundingBox.max,Vi.max),this.boundingBox.expandByPoint(ii)):(this.boundingBox.expandByPoint(Vi.min),this.boundingBox.expandByPoint(Vi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ue('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 fs);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(e){const i=this.boundingSphere.center;if(Vi.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];za.setFromBufferAttribute(o),this.morphTargetsRelative?(ii.addVectors(Vi.min,za.min),Vi.expandByPoint(ii),ii.addVectors(Vi.max,za.max),Vi.expandByPoint(ii)):(Vi.expandByPoint(za.min),Vi.expandByPoint(za.max))}Vi.getCenter(i);let n=0;for(let s=0,a=e.count;s<a;s++)ii.fromBufferAttribute(e,s),n=Math.max(n,i.distanceToSquared(ii));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)ii.fromBufferAttribute(o,c),l&&(Fr.fromBufferAttribute(e,c),ii.add(Fr)),n=Math.max(n,i.distanceToSquared(ii))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&Ue('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ue("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,n=t.normal,s=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==i.count)&&(a=new ht(new Float32Array(4*i.count),4),this.setAttribute("tangent",a));const o=[],l=[];for(let y=0;y<i.count;y++)o[y]=new P,l[y]=new P;const c=new P,h=new P,d=new P,u=new Te,f=new Te,p=new Te,v=new P,m=new P;function g(y,T,A){c.fromBufferAttribute(i,y),h.fromBufferAttribute(i,T),d.fromBufferAttribute(i,A),u.fromBufferAttribute(s,y),f.fromBufferAttribute(s,T),p.fromBufferAttribute(s,A),h.sub(c),d.sub(c),f.sub(u),p.sub(u);const I=1/(f.x*p.y-p.x*f.y);isFinite(I)&&(v.copy(h).multiplyScalar(p.y).addScaledVector(d,-f.y).multiplyScalar(I),m.copy(d).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(I),o[y].add(v),o[T].add(v),o[A].add(v),l[y].add(m),l[T].add(m),l[A].add(m))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let y=0,T=x.length;y<T;++y){const A=x[y],I=A.start,R=A.count;for(let k=I,z=I+R;k<z;k+=3)g(e.getX(k+0),e.getX(k+1),e.getX(k+2))}const M=new P,w=new P,S=new P,_=new P;function D(y){S.fromBufferAttribute(n,y),_.copy(S);const T=o[y];M.copy(T),M.sub(S.multiplyScalar(S.dot(T))).normalize(),w.crossVectors(_,T);const I=w.dot(l[y])<0?-1:1;a.setXYZW(y,M.x,M.y,M.z,I)}for(let y=0,T=x.length;y<T;++y){const A=x[y],I=A.start,R=A.count;for(let k=I,z=I+R;k<z;k+=3)D(e.getX(k+0)),D(e.getX(k+1)),D(e.getX(k+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==t.count)i=new ht(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let u=0,f=i.count;u<f;u++)i.setXYZ(u,0,0,0);const n=new P,s=new P,a=new P,o=new P,l=new P,c=new P,h=new P,d=new P;if(e)for(let u=0,f=e.count;u<f;u+=3){const p=e.getX(u+0),v=e.getX(u+1),m=e.getX(u+2);n.fromBufferAttribute(t,p),s.fromBufferAttribute(t,v),a.fromBufferAttribute(t,m),h.subVectors(a,s),d.subVectors(n,s),h.cross(d),o.fromBufferAttribute(i,p),l.fromBufferAttribute(i,v),c.fromBufferAttribute(i,m),o.add(h),l.add(h),c.add(h),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(v,l.x,l.y,l.z),i.setXYZ(m,c.x,c.y,c.z)}else for(let u=0,f=t.count;u<f;u+=3)n.fromBufferAttribute(t,u+0),s.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),h.subVectors(a,s),d.subVectors(n,s),h.cross(d),i.setXYZ(u+0,h.x,h.y,h.z),i.setXYZ(u+1,h.x,h.y,h.z),i.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)ii.fromBufferAttribute(e,t),ii.normalize(),e.setXYZ(t,ii.x,ii.y,ii.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,d=o.normalized,u=new c.constructor(l.length*h);let f=0,p=0;for(let v=0,m=l.length;v<m;v++){o.isInterleavedBufferAttribute?f=l[v]*o.data.stride+o.offset:f=l[v]*h;for(let g=0;g<h;g++)u[p++]=c[f++]}return new ht(u,h,d)}if(this.index===null)return _e("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Tt,i=this.index.array,n=this.attributes;for(const o in n){const l=n[o],c=e(l,i);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,d=c.length;h<d;h++){const u=c[h],f=e(u,i);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const n={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d<u;d++){const f=c[d];h.push(f.toJSON(e.data))}h.length>0&&(n[l]=h,s=!0)}s&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const n=e.attributes;for(const c in n){const h=n[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],d=s[c];for(let u=0,f=d.length;u<f;u++)h.push(d[u].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const d=a[c];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class zy{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=lu,this.updateRanges=[],this.version=0,this.uuid=vn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,s=this.stride;n<s;n++)this.array[e+n]=t.array[i+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=vn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=vn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.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 Ai=new P;class mc{constructor(e,t,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ai.fromBufferAttribute(this,t),Ai.applyMatrix4(e),this.setXYZ(t,Ai.x,Ai.y,Ai.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ai.fromBufferAttribute(this,t),Ai.applyNormalMatrix(e),this.setXYZ(t,Ai.x,Ai.y,Ai.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ai.fromBufferAttribute(this,t),Ai.transformDirection(e),this.setXYZ(t,Ai.x,Ai.y,Ai.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=mn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=mt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=mt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=mt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=mt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=mt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=mn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=mn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=mn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=mn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=mt(t,this.array),i=mt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=mt(t,this.array),i=mt(i,this.array),n=mt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=mt(t,this.array),i=mt(i,this.array),n=mt(n,this.array),s=mt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=s,this}clone(e){if(e===void 0){fc("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[n+s])}return new ht(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new mc(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){fc("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[n+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let Hy=0;class ps extends wr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Hy++}),this.uuid=vn(),this.name="",this.type="Material",this.blending=ma,this.side=Bs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Md,this.blendDst=xd,this.blendEquation=ir,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new oe(0,0,0),this.blendAlpha=0,this.depthFunc=Aa,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=wp,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ar,this.stencilZFail=Ar,this.stencilZPass=Ar,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){_e(`Material: parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){_e(`Material: '${t}' 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[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={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(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).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(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).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(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).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(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).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!==ma&&(i.blending=this.blending),this.side!==Bs&&(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!==Md&&(i.blendSrc=this.blendSrc),this.blendDst!==xd&&(i.blendDst=this.blendDst),this.blendEquation!==ir&&(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!==Aa&&(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!==wp&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ar&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ar&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ar&&(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 l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=n(e.textures),a=n(e.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new oe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Te().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Te().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const n=t.length;i=new Array(n);for(let s=0;s!==n;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class ao extends ps{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new oe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Ur;const Ha=new P,Br=new P,zr=new P,Hr=new Te,Ga=new Te,Vg=new Ye,il=new P,Va=new P,nl=new P,kp=new Te,mh=new Te,Np=new Te;class Gr extends _t{constructor(e=new ao){if(super(),this.isSprite=!0,this.type="Sprite",Ur===void 0){Ur=new Tt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new zy(t,5);Ur.setIndex([0,1,2,0,2,3]),Ur.setAttribute("position",new mc(i,3,0,!1)),Ur.setAttribute("uv",new mc(i,2,3,!1))}this.geometry=Ur,this.material=e,this.center=new Te(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Ue('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Br.setFromMatrixScale(this.matrixWorld),Vg.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),zr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Br.multiplyScalar(-zr.z);const i=this.material.rotation;let n,s;i!==0&&(s=Math.cos(i),n=Math.sin(i));const a=this.center;sl(il.set(-.5,-.5,0),zr,a,Br,n,s),sl(Va.set(.5,-.5,0),zr,a,Br,n,s),sl(nl.set(.5,.5,0),zr,a,Br,n,s),kp.set(0,0),mh.set(1,0),Np.set(1,1);let o=e.ray.intersectTriangle(il,Va,nl,!1,Ha);if(o===null&&(sl(Va.set(-.5,.5,0),zr,a,Br,n,s),mh.set(0,1),o=e.ray.intersectTriangle(il,nl,Va,!1,Ha),o===null))return;const l=e.ray.origin.distanceTo(Ha);l<e.near||l>e.far||t.push({distance:l,point:Ha.clone(),uv:nn.getInterpolation(Ha,il,Va,nl,kp,mh,Np,new Te),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function sl(r,e,t,i,n,s){Hr.subVectors(r,t).addScalar(.5).multiply(i),n!==void 0?(Ga.x=s*Hr.x-n*Hr.y,Ga.y=n*Hr.x+s*Hr.y):Ga.copy(Hr),r.copy(e),r.x+=Ga.x,r.y+=Ga.y,r.applyMatrix4(Vg)}const Qn=new P,gh=new P,rl=new P,Ss=new P,vh=new P,al=new P,yh=new P;class ko{constructor(e=new P,t=new P(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Qn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Qn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Qn.copy(this.origin).addScaledVector(this.direction,t),Qn.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){gh.copy(e).add(t).multiplyScalar(.5),rl.copy(t).sub(e).normalize(),Ss.copy(this.origin).sub(gh);const s=e.distanceTo(t)*.5,a=-this.direction.dot(rl),o=Ss.dot(this.direction),l=-Ss.dot(rl),c=Ss.lengthSq(),h=Math.abs(1-a*a);let d,u,f,p;if(h>0)if(d=a*l-o,u=a*o-l,p=s*h,d>=0)if(u>=-p)if(u<=p){const v=1/h;d*=v,u*=v,f=d*(d+a*u+2*o)+u*(a*d+u+2*l)+c}else u=s,d=Math.max(0,-(a*u+o)),f=-d*d+u*(u+2*l)+c;else u=-s,d=Math.max(0,-(a*u+o)),f=-d*d+u*(u+2*l)+c;else u<=-p?(d=Math.max(0,-(-a*s+o)),u=d>0?-s:Math.min(Math.max(-s,-l),s),f=-d*d+u*(u+2*l)+c):u<=p?(d=0,u=Math.min(Math.max(-s,-l),s),f=u*(u+2*l)+c):(d=Math.max(0,-(a*s+o)),u=d>0?s:Math.min(Math.max(-s,-l),s),f=-d*d+u*(u+2*l)+c);else u=a>0?-s:s,d=Math.max(0,-(a*u+o)),f=-d*d+u*(u+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),n&&n.copy(gh).addScaledVector(rl,u),f}intersectSphere(e,t){Qn.subVectors(e.center,this.origin);const i=Qn.dot(this.direction),n=Qn.dot(Qn)-i*i,s=e.radius*e.radius;if(n>s)return null;const a=Math.sqrt(s-n),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(i=(e.min.x-u.x)*c,n=(e.max.x-u.x)*c):(i=(e.max.x-u.x)*c,n=(e.min.x-u.x)*c),h>=0?(s=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(s=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),i>a||s>n||((s>i||isNaN(i))&&(i=s),(a<n||isNaN(n))&&(n=a),d>=0?(o=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),i>l||o>n)||((o>i||i!==i)&&(i=o),(l<n||n!==n)&&(n=l),n<0)?null:this.at(i>=0?i:n,t)}intersectsBox(e){return this.intersectBox(e,Qn)!==null}intersectTriangle(e,t,i,n,s){vh.subVectors(t,e),al.subVectors(i,e),yh.crossVectors(vh,al);let a=this.direction.dot(yh),o;if(a>0){if(n)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ss.subVectors(this.origin,e);const l=o*this.direction.dot(al.crossVectors(Ss,al));if(l<0)return null;const c=o*this.direction.dot(vh.cross(Ss));if(c<0||l+c>a)return null;const h=-o*Ss.dot(yh);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class rn extends ps{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new oe(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 Yn,this.combine=$u,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Op=new Ye,Ys=new ko,ol=new fs,Fp=new P,ll=new P,cl=new P,hl=new P,bh=new P,dl=new P,Up=new P,ul=new P;class We extends _t{constructor(e=new Tt,t=new rn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[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(e,t){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(n,e);const o=this.morphTargetInfluences;if(s&&o){dl.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],d=s[l];h!==0&&(bh.fromBufferAttribute(d,e),a?dl.addScaledVector(bh,h):dl.addScaledVector(bh.sub(t),h))}t.add(dl)}return t}raycast(e,t){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),ol.copy(i.boundingSphere),ol.applyMatrix4(s),Ys.copy(e.ray).recast(e.near),!(ol.containsPoint(Ys.origin)===!1&&(Ys.intersectSphere(ol,Fp)===null||Ys.origin.distanceToSquared(Fp)>(e.far-e.near)**2))&&(Op.copy(s).invert(),Ys.copy(e.ray).applyMatrix4(Op),!(i.boundingBox!==null&&Ys.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Ys)))}_computeIntersections(e,t,i){let n;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,d=s.attributes.normal,u=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,v=u.length;p<v;p++){const m=u[p],g=a[m.materialIndex],x=Math.max(m.start,f.start),M=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let w=x,S=M;w<S;w+=3){const _=o.getX(w),D=o.getX(w+1),y=o.getX(w+2);n=fl(this,g,e,i,c,h,d,_,D,y),n&&(n.faceIndex=Math.floor(w/3),n.face.materialIndex=m.materialIndex,t.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 x=o.getX(m),M=o.getX(m+1),w=o.getX(m+2);n=fl(this,a,e,i,c,h,d,x,M,w),n&&(n.faceIndex=Math.floor(m/3),t.push(n))}}else if(l!==void 0)if(Array.isArray(a))for(let p=0,v=u.length;p<v;p++){const m=u[p],g=a[m.materialIndex],x=Math.max(m.start,f.start),M=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let w=x,S=M;w<S;w+=3){const _=w,D=w+1,y=w+2;n=fl(this,g,e,i,c,h,d,_,D,y),n&&(n.faceIndex=Math.floor(w/3),n.face.materialIndex=m.materialIndex,t.push(n))}}else{const p=Math.max(0,f.start),v=Math.min(l.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const x=m,M=m+1,w=m+2;n=fl(this,a,e,i,c,h,d,x,M,w),n&&(n.faceIndex=Math.floor(m/3),t.push(n))}}}}function Gy(r,e,t,i,n,s,a,o){let l;if(e.side===Ft?l=i.intersectTriangle(a,s,n,!0,o):l=i.intersectTriangle(n,s,a,e.side===Bs,o),l===null)return null;ul.copy(o),ul.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(ul);return c<t.near||c>t.far?null:{distance:c,point:ul.clone(),object:r}}function fl(r,e,t,i,n,s,a,o,l,c){r.getVertexPosition(o,ll),r.getVertexPosition(l,cl),r.getVertexPosition(c,hl);const h=Gy(r,e,t,i,ll,cl,hl,Up);if(h){const d=new P;nn.getBarycoord(Up,ll,cl,hl,d),n&&(h.uv=nn.getInterpolatedAttribute(n,o,l,c,d,new Te)),s&&(h.uv1=nn.getInterpolatedAttribute(s,o,l,c,d,new Te)),a&&(h.normal=nn.getInterpolatedAttribute(a,o,l,c,d,new P),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new P,materialIndex:0};nn.getNormal(ll,cl,hl,u.normal),h.face=u,h.barycoord=d}return h}const Wa=new at,Bp=new at,zp=new at,Vy=new at,Hp=new Ye,pl=new P,wh=new fs,Gp=new Ye,Mh=new ko;class pA extends We{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=mp,this.bindMatrix=new Ye,this.bindMatrixInverse=new Ye,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new bn),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,pl),this.boundingBox.expandByPoint(pl)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new fs),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,pl),this.boundingSphere.expandByPoint(pl)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,n=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),wh.copy(this.boundingSphere),wh.applyMatrix4(n),e.ray.intersectsSphere(wh)!==!1&&(Gp.copy(n).invert(),Mh.copy(e.ray).applyMatrix4(Gp),!(this.boundingBox!==null&&Mh.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Mh)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new at,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.fromBufferAttribute(t,i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===mp?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===W2?this.bindMatrixInverse.copy(this.bindMatrix).invert():_e("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,n=this.geometry;Bp.fromBufferAttribute(n.attributes.skinIndex,e),zp.fromBufferAttribute(n.attributes.skinWeight,e),t.isVector4?(Wa.copy(t),t.set(0,0,0,0)):(Wa.set(...t,1),t.set(0,0,0)),Wa.applyMatrix4(this.bindMatrix);for(let s=0;s<4;s++){const a=zp.getComponent(s);if(a!==0){const o=Bp.getComponent(s);Hp.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(Vy.copy(Wa).applyMatrix4(Hp),a)}}return t.isVector4&&(t.w=Wa.w),t.applyMatrix4(this.bindMatrixInverse)}}class Wy extends _t{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Mr extends di{constructor(e=null,t=1,i=1,n,s,a,o,l,c=Nt,h=Nt,d,u){super(null,a,o,l,c,h,n,s,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Vp=new Ye,Xy=new Ye;class Wg{constructor(e=[],t=[]){this.uuid=vn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){_e("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 Ye)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Ye;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];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 e=this.bones,t=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:Xy;Vp.multiplyMatrices(o,t[s]),Vp.toArray(i,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new Wg(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new Mr(t,e,e,Ti,Pi);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,n=e.bones.length;i<n;i++){const s=e.bones[i];let a=t[s];a===void 0&&(_e("Skeleton: No bone found with UUID:",s),a=new Wy),this.bones.push(a),this.boneInverses.push(new Ye().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let n=0,s=t.length;n<s;n++){const a=t[n];e.bones.push(a.uuid);const o=i[n];e.boneInverses.push(o.toArray())}return e}}class Wp extends ht{constructor(e,t,i,n=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Vr=new Ye,Xp=new Ye,ml=[],qp=new bn,qy=new Ye,Xa=new We,qa=new fs;class mA extends We{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Wp(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,qy)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new bn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Vr),qp.copy(e.boundingBox).applyMatrix4(Vr),this.boundingBox.union(qp)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new fs),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Vr),qa.copy(e.boundingSphere).applyMatrix4(Vr),this.boundingSphere.union(qa)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,n=this.morphTexture.source.data.data,s=i.length+1,a=e*s+1;for(let o=0;o<i.length;o++)i[o]=n[a+o]}raycast(e,t){const i=this.matrixWorld,n=this.count;if(Xa.geometry=this.geometry,Xa.material=this.material,Xa.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),qa.copy(this.boundingSphere),qa.applyMatrix4(i),e.ray.intersectsSphere(qa)!==!1))for(let s=0;s<n;s++){this.getMatrixAt(s,Vr),Xp.multiplyMatrices(i,Vr),Xa.matrixWorld=Xp,Xa.raycast(e,ml);for(let a=0,o=ml.length;a<o;a++){const l=ml[a];l.instanceId=s,l.object=this,t.push(l)}ml.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new Wp(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){const i=t.morphTargetInfluences,n=i.length+1;this.morphTexture===null&&(this.morphTexture=new Mr(new Float32Array(n*this.count),n,this.count,Pc,Pi));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<i.length;c++)a+=i[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=n*e;return s[l]=o,s.set(i,l+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const xh=new P,Yy=new P,Ky=new He;class Qs{constructor(e=new P(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const n=xh.subVectors(i,t).cross(Yy.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){const n=e.delta(xh),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/s;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(n,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||Ky.getNormalMatrix(e),n=this.coplanarPoint(xh).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ks=new fs,$y=new Te(.5,.5),gl=new P;class cf{constructor(e=new Qs,t=new Qs,i=new Qs,n=new Qs,s=new Qs,a=new Qs){this.planes=[e,t,i,n,s,a]}set(e,t,i,n,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(n),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Hn,i=!1){const n=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],h=s[4],d=s[5],u=s[6],f=s[7],p=s[8],v=s[9],m=s[10],g=s[11],x=s[12],M=s[13],w=s[14],S=s[15];if(n[0].setComponents(c-a,f-h,g-p,S-x).normalize(),n[1].setComponents(c+a,f+h,g+p,S+x).normalize(),n[2].setComponents(c+o,f+d,g+v,S+M).normalize(),n[3].setComponents(c-o,f-d,g-v,S-M).normalize(),i)n[4].setComponents(l,u,m,w).normalize(),n[5].setComponents(c-l,f-u,g-m,S-w).normalize();else if(n[4].setComponents(c-l,f-u,g-m,S-w).normalize(),t===Hn)n[5].setComponents(c+l,f+u,g+m,S+w).normalize();else if(t===Ro)n[5].setComponents(l,u,m,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ks.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ks.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ks)}intersectsSprite(e){Ks.center.set(0,0,0);const t=$y.distanceTo(e.center);return Ks.radius=.7071067811865476+t,Ks.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ks)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<n)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const n=t[i];if(gl.x=n.normal.x>0?e.max.x:e.min.x,gl.y=n.normal.y>0?e.max.y:e.min.y,gl.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(gl)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Zy extends ps{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const gc=new P,vc=new P,Yp=new Ye,Ya=new ko,vl=new fs,Sh=new P,Kp=new P;class Xg extends _t{constructor(e=new Tt,t=new Zy){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let n=1,s=t.count;n<s;n++)gc.fromBufferAttribute(t,n-1),vc.fromBufferAttribute(t,n),i[n]=i[n-1],i[n]+=gc.distanceTo(vc);e.setAttribute("lineDistance",new Ut(i,1))}else _e("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),vl.copy(i.boundingSphere),vl.applyMatrix4(n),vl.radius+=s,e.ray.intersectsSphere(vl)===!1)return;Yp.copy(n).invert(),Ya.copy(e.ray).applyMatrix4(Yp);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=i.index,u=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+=c){const g=h.getX(v),x=h.getX(v+1),M=yl(this,e,Ya,l,g,x,v);M&&t.push(M)}if(this.isLineLoop){const v=h.getX(p-1),m=h.getX(f),g=yl(this,e,Ya,l,v,m,p-1);g&&t.push(g)}}else{const f=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let v=f,m=p-1;v<m;v+=c){const g=yl(this,e,Ya,l,v,v+1,v);g&&t.push(g)}if(this.isLineLoop){const v=yl(this,e,Ya,l,p-1,f,p-1);v&&t.push(v)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[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 yl(r,e,t,i,n,s,a){const o=r.geometry.attributes.position;if(gc.fromBufferAttribute(o,n),vc.fromBufferAttribute(o,s),t.distanceSqToSegment(gc,vc,Sh,Kp)>i)return;Sh.applyMatrix4(r.matrixWorld);const c=e.ray.origin.distanceTo(Sh);if(!(c<e.near||c>e.far))return{distance:c,point:Kp.clone().applyMatrix4(r.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:r}}const $p=new P,Zp=new P;class gA extends Xg{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let n=0,s=t.count;n<s;n+=2)$p.fromBufferAttribute(t,n),Zp.fromBufferAttribute(t,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+$p.distanceTo(Zp);e.setAttribute("lineDistance",new Ut(i,1))}else _e("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class vA extends Xg{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class hf extends ps{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Jp=new Ye,cu=new ko,bl=new fs,wl=new P;class vo extends _t{constructor(e=new Tt,t=new hf){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,s=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),bl.copy(i.boundingSphere),bl.applyMatrix4(n),bl.radius+=s,e.ray.intersectsSphere(bl)===!1)return;Jp.copy(n).invert(),cu.copy(e.ray).applyMatrix4(Jp);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,d=i.attributes.position;if(c!==null){const u=Math.max(0,a.start),f=Math.min(c.count,a.start+a.count);for(let p=u,v=f;p<v;p++){const m=c.getX(p);wl.fromBufferAttribute(d,m),jp(wl,m,l,n,e,t,this)}}else{const u=Math.max(0,a.start),f=Math.min(d.count,a.start+a.count);for(let p=u,v=f;p<v;p++)wl.fromBufferAttribute(d,p),jp(wl,p,l,n,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[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 jp(r,e,t,i,n,s,a){const o=cu.distanceSqToPoint(r);if(o<t){const l=new P;cu.closestPointToPoint(r,l),l.applyMatrix4(i);const c=n.ray.origin.distanceTo(l);if(c<n.near||c>n.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class qg extends di{constructor(e=[],t=gr,i,n,s,a,o,l,c,h){super(e,t,i,n,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Kn extends di{constructor(e,t,i,n,s,a,o,l,c){super(e,t,i,n,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class yr extends di{constructor(e,t,i=yn,n,s,a,o=Nt,l=Nt,c,h=ds,d=1){if(h!==ds&&h!==lr)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:d};super(u,n,s,a,o,l,h,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new af(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Jy extends yr{constructor(e,t=yn,i=gr,n,s,a=Nt,o=Nt,l,c=ds){const h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,i,n,s,a,o,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Yg extends di{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class an extends Tt{constructor(e=1,t=1,i=1,n=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:s,depthSegments:a};const o=this;n=Math.floor(n),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],d=[];let u=0,f=0;p("z","y","x",-1,-1,i,t,e,a,s,0),p("z","y","x",1,-1,i,t,-e,a,s,1),p("x","z","y",1,1,e,i,t,n,a,2),p("x","z","y",1,-1,e,i,-t,n,a,3),p("x","y","z",1,-1,e,t,i,n,s,4),p("x","y","z",-1,-1,e,t,-i,n,s,5),this.setIndex(l),this.setAttribute("position",new Ut(c,3)),this.setAttribute("normal",new Ut(h,3)),this.setAttribute("uv",new Ut(d,2));function p(v,m,g,x,M,w,S,_,D,y,T){const A=w/D,I=S/y,R=w/2,k=S/2,z=_/2,L=D+1,B=y+1;let F=0,V=0;const j=new P;for(let $=0;$<B;$++){const ie=$*I-k;for(let ae=0;ae<L;ae++){const Ve=ae*A-R;j[v]=Ve*x,j[m]=ie*M,j[g]=z,c.push(j.x,j.y,j.z),j[v]=0,j[m]=0,j[g]=_>0?1:-1,h.push(j.x,j.y,j.z),d.push(ae/D),d.push(1-$/y),F+=1}}for(let $=0;$<y;$++)for(let ie=0;ie<D;ie++){const ae=u+ie+L*$,Ve=u+ie+L*($+1),je=u+(ie+1)+L*($+1),Ge=u+(ie+1)+L*$;l.push(ae,Ve,Ge),l.push(Ve,je,Ge),V+=6}o.addGroup(f,V,T),f+=V,u+=F}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new an(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class df extends Tt{constructor(e=1,t=32,i=0,n=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:n},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new P,h=new Te;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,u=3;d<=t;d++,u+=3){const f=i+d/t*n;c.x=e*Math.cos(f),c.y=e*Math.sin(f),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[u]/e+1)/2,h.y=(a[u+1]/e+1)/2,l.push(h.x,h.y)}for(let d=1;d<=t;d++)s.push(d,d+1,0);this.setIndex(s),this.setAttribute("position",new Ut(a,3)),this.setAttribute("normal",new Ut(o,3)),this.setAttribute("uv",new Ut(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new df(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class ms extends Tt{constructor(e=1,t=1,i=1,n=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;n=Math.floor(n),s=Math.floor(s);const h=[],d=[],u=[],f=[];let p=0;const v=[],m=i/2;let g=0;x(),a===!1&&(e>0&&M(!0),t>0&&M(!1)),this.setIndex(h),this.setAttribute("position",new Ut(d,3)),this.setAttribute("normal",new Ut(u,3)),this.setAttribute("uv",new Ut(f,2));function x(){const w=new P,S=new P;let _=0;const D=(t-e)/i;for(let y=0;y<=s;y++){const T=[],A=y/s,I=A*(t-e)+e;for(let R=0;R<=n;R++){const k=R/n,z=k*l+o,L=Math.sin(z),B=Math.cos(z);S.x=I*L,S.y=-A*i+m,S.z=I*B,d.push(S.x,S.y,S.z),w.set(L,D,B).normalize(),u.push(w.x,w.y,w.z),f.push(k,1-A),T.push(p++)}v.push(T)}for(let y=0;y<n;y++)for(let T=0;T<s;T++){const A=v[T][y],I=v[T+1][y],R=v[T+1][y+1],k=v[T][y+1];(e>0||T!==0)&&(h.push(A,I,k),_+=3),(t>0||T!==s-1)&&(h.push(I,R,k),_+=3)}c.addGroup(g,_,0),g+=_}function M(w){const S=p,_=new Te,D=new P;let y=0;const T=w===!0?e:t,A=w===!0?1:-1;for(let R=1;R<=n;R++)d.push(0,m*A,0),u.push(0,A,0),f.push(.5,.5),p++;const I=p;for(let R=0;R<=n;R++){const z=R/n*l+o,L=Math.cos(z),B=Math.sin(z);D.x=T*B,D.y=m*A,D.z=T*L,d.push(D.x,D.y,D.z),u.push(0,A,0),_.x=L*.5+.5,_.y=B*.5*A+.5,f.push(_.x,_.y),p++}for(let R=0;R<n;R++){const k=S+R,z=I+R;w===!0?h.push(z,z+1,k):h.push(z+1,z,k),y+=3}c.addGroup(g,y,w===!0?1:2),g+=y}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ms(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class No extends ms{constructor(e=1,t=1,i=32,n=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,i,n,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new No(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class wn extends Tt{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const s=e/2,a=t/2,o=Math.floor(i),l=Math.floor(n),c=o+1,h=l+1,d=e/o,u=t/l,f=[],p=[],v=[],m=[];for(let g=0;g<h;g++){const x=g*u-a;for(let M=0;M<c;M++){const w=M*d-s;p.push(w,-x,0),v.push(0,0,1),m.push(M/o),m.push(1-g/l)}}for(let g=0;g<l;g++)for(let x=0;x<o;x++){const M=x+c*g,w=x+c*(g+1),S=x+1+c*(g+1),_=x+1+c*g;f.push(M,w,_),f.push(w,S,_)}this.setIndex(f),this.setAttribute("position",new Ut(p,3)),this.setAttribute("normal",new Ut(v,3)),this.setAttribute("uv",new Ut(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wn(e.width,e.height,e.widthSegments,e.heightSegments)}}class yi extends Tt{constructor(e=1,t=32,i=16,n=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(a+o,Math.PI);let c=0;const h=[],d=new P,u=new P,f=[],p=[],v=[],m=[];for(let g=0;g<=i;g++){const x=[],M=g/i,w=a+M*o,S=e*Math.cos(w),_=Math.sqrt(e*e-S*S);let D=0;g===0&&a===0?D=.5/t:g===i&&l===Math.PI&&(D=-.5/t);for(let y=0;y<=t;y++){const T=y/t,A=n+T*s;d.x=-_*Math.cos(A),d.y=S,d.z=_*Math.sin(A),p.push(d.x,d.y,d.z),u.copy(d).normalize(),v.push(u.x,u.y,u.z),m.push(T+D,1-M),x.push(c++)}h.push(x)}for(let g=0;g<i;g++)for(let x=0;x<t;x++){const M=h[g][x+1],w=h[g][x],S=h[g+1][x],_=h[g+1][x+1];(g!==0||a>0)&&f.push(M,w,_),(g!==i-1||l<Math.PI)&&f.push(w,S,_)}this.setIndex(f),this.setAttribute("position",new Ut(p,3)),this.setAttribute("normal",new Ut(v,3)),this.setAttribute("uv",new Ut(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yi(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Ra(r){const e={};for(const t in r){e[t]={};for(const i in r[t]){const n=r[t][i];if(Qp(n))n.isRenderTargetTexture?(_e("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=n.clone();else if(Array.isArray(n))if(Qp(n[0])){const s=[];for(let a=0,o=n.length;a<o;a++)s[a]=n[a].clone();e[t][i]=s}else e[t][i]=n.slice();else e[t][i]=n}}return e}function Ii(r){const e={};for(let t=0;t<r.length;t++){const i=Ra(r[t]);for(const n in i)e[n]=i[n]}return e}function Qp(r){return r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)}function jy(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function Kg(r){const e=r.getRenderTarget();return e===null?r.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:tt.workingColorSpace}const Qy={clone:Ra,merge:Ii};var eb=`void main() {
2109
2109
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
2110
2110
  }`,tb=`void main() {
2111
2111
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
2112
- }`;class Ot extends ps{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=eb,this.fragmentShader=tb,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,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ra(e.uniforms),this.uniformsGroups=jy(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const n in this.uniforms){const a=this.uniforms[n].value;a&&a.isTexture?t.uniforms[n]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[n]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[n]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[n]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[n]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[n]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[n]={type:"m4",value:a.toArray()}:t.uniforms[n]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const n=e.uniforms[i];switch(this.uniforms[i]={},n.type){case"t":this.uniforms[i].value=t[n.value]||null;break;case"c":this.uniforms[i].value=new oe().setHex(n.value);break;case"v2":this.uniforms[i].value=new Te().fromArray(n.value);break;case"v3":this.uniforms[i].value=new P().fromArray(n.value);break;case"v4":this.uniforms[i].value=new at().fromArray(n.value);break;case"m3":this.uniforms[i].value=new ze().fromArray(n.value);break;case"m4":this.uniforms[i].value=new Ye().fromArray(n.value);break;default:this.uniforms[i].value=n.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class $g extends Ot{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class ib extends ps{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new oe(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 oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cc,this.normalScale=new Te(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 Yn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class yA extends ib{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Te(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Je(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new oe(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 oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new oe(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(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Oo extends ps{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cc,this.normalScale=new Te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Yn,this.combine=$u,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class nb extends ps{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Y2,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class sb extends ps{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Ml(r,e){return!r||r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function rb(r){function e(n,s){return r[n]-r[s]}const t=r.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort(e),i}function e0(r,e,t){const i=r.length,n=new r.constructor(i);for(let s=0,a=0;a!==i;++s){const o=t[s]*e;for(let l=0;l!==e;++l)n[a++]=r[o+l]}return n}function ab(r,e,t,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&&(e.push(s.time),t.push(...a)),s=r[n++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[i],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=r[n++];while(s!==void 0);else do a=s[i],a!==void 0&&(e.push(s.time),t.push(a)),s=r[n++];while(s!==void 0)}class Fo{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,n=t[i],s=t[i-1];i:{e:{let a;t:{n:if(!(e<n)){for(let o=i+2;;){if(n===void 0){if(e<s)break n;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=n,n=t[++i],e<n)break e}a=t.length;break t}if(!(e>=s)){const o=t[1];e<o&&(i=2,s=o);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(n=s,s=t[--i-1],e>=s)break e}a=i,i=0;break t}break i}for(;i<a;){const o=i+a>>>1;e<t[o]?a=o:i=o+1}if(n=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=e*n;for(let a=0;a!==n;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class ob extends Fo{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:vp,endingEnd:vp}}intervalChanged_(e,t,i){const n=this.parameterPositions;let s=e-2,a=e+1,o=n[s],l=n[a];if(o===void 0)switch(this.getSettings_().endingStart){case yp:s=e,o=2*t-i;break;case bp:s=n.length-2,o=t+n[s]-n[s+1];break;default:s=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case yp:a=e,l=2*i-t;break;case bp:a=1,l=i+n[1]-n[0];break;default:a=e-1,l=t}const c=(i-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-i),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,d=this._offsetNext,u=this._weightPrev,f=this._weightNext,p=(i-t)/(n-t),v=p*p,m=v*p,g=-u*m+2*u*v-u*p,x=(1+u)*m+(-1.5-2*u)*v+(-.5+u)*p+1,M=(-1-f)*m+(1.5+f)*v+.5*p,w=f*m-f*v;for(let S=0;S!==o;++S)s[S]=g*a[h+S]+x*a[c+S]+M*a[l+S]+w*a[d+S];return s}}class lb extends Fo{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(i-t)/(n-t),d=1-h;for(let u=0;u!==o;++u)s[u]=a[c+u]*d+a[l+u]*h;return s}}class cb extends Fo{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class hb extends Fo{interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this.inTangents,d=this.outTangents;if(!h||!d){const p=(i-t)/(n-t),v=1-p;for(let m=0;m!==o;++m)s[m]=a[c+m]*v+a[l+m]*p;return s}const u=o*2,f=e-1;for(let p=0;p!==o;++p){const v=a[c+p],m=a[l+p],g=f*u+p*2,x=d[g],M=d[g+1],w=e*u+p*2,S=h[w],_=h[w+1];let D=(i-t)/(n-t),y,T,A,I,R;for(let k=0;k<8;k++){y=D*D,T=y*D,A=1-D,I=A*A,R=I*A;const L=R*t+3*I*D*x+3*A*y*S+T*n-i;if(Math.abs(L)<1e-10)break;const B=3*I*(x-t)+6*A*D*(S-x)+3*y*(n-S);if(Math.abs(B)<1e-10)break;D=D-L/B,D=Math.max(0,Math.min(1,D))}s[p]=R*v+3*I*D*M+3*A*y*_+T*m}return s}}class Mn{constructor(e,t,i,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Ml(t,this.TimeBufferType),this.values=Ml(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Ml(e.times,Array),values:Ml(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(i.interpolation=n)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new cb(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new lb(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ob(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new hb(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case lc:t=this.InterpolantFactoryMethodDiscrete;break;case ou:t=this.InterpolantFactoryMethodLinear;break;case Jc:t=this.InterpolantFactoryMethodSmooth;break;case gp:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return _e("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return lc;case this.InterpolantFactoryMethodLinear:return ou;case this.InterpolantFactoryMethodSmooth:return Jc;case this.InterpolantFactoryMethodBezier:return gp}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){const i=this.times,n=i.length;let s=0,a=n-1;for(;s!==n&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--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 e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Ue("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,s=i.length;s===0&&(Ue("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){Ue("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){Ue("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(n!==void 0&&iy(n))for(let o=0,l=n.length;o!==l;++o){const c=n[o];if(isNaN(c)){Ue("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===Jc,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],h=e[o+1];if(c!==h&&(o!==1||c!==e[0]))if(n)l=!0;else{const d=o*i,u=d-i,f=d+i;for(let p=0;p!==i;++p){const v=t[d+p];if(v!==t[u+p]||v!==t[f+p]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const d=o*i,u=a*i;for(let f=0;f!==i;++f)t[u+f]=t[d+f]}++a}}if(s>0){e[a]=e[s];for(let o=s*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,n=new i(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Mn.prototype.ValueTypeName="";Mn.prototype.TimeBufferType=Float32Array;Mn.prototype.ValueBufferType=Float32Array;Mn.prototype.DefaultInterpolation=ou;class ka extends Mn{constructor(e,t,i){super(e,t,i)}}ka.prototype.ValueTypeName="bool";ka.prototype.ValueBufferType=Array;ka.prototype.DefaultInterpolation=lc;ka.prototype.InterpolantFactoryMethodLinear=void 0;ka.prototype.InterpolantFactoryMethodSmooth=void 0;class Zg extends Mn{constructor(e,t,i,n){super(e,t,i,n)}}Zg.prototype.ValueTypeName="color";class uf extends Mn{constructor(e,t,i,n){super(e,t,i,n)}}uf.prototype.ValueTypeName="number";class db extends Fo{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(n-t);let c=e*o;for(let h=c+o;c!==h;c+=4)qn.slerpFlat(s,0,a,c-o,a,c,l);return s}}class ff extends Mn{constructor(e,t,i,n){super(e,t,i,n)}InterpolantFactoryMethodLinear(e){return new db(this.times,this.values,this.getValueSize(),e)}}ff.prototype.ValueTypeName="quaternion";ff.prototype.InterpolantFactoryMethodSmooth=void 0;class Na extends Mn{constructor(e,t,i){super(e,t,i)}}Na.prototype.ValueTypeName="string";Na.prototype.ValueBufferType=Array;Na.prototype.DefaultInterpolation=lc;Na.prototype.InterpolantFactoryMethodLinear=void 0;Na.prototype.InterpolantFactoryMethodSmooth=void 0;class Jg extends Mn{constructor(e,t,i,n){super(e,t,i,n)}}Jg.prototype.ValueTypeName="vector";class bA{constructor(e="",t=-1,i=[],n=q2){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=vn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(fb(i[a]).scale(n));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let s=0,a=i.length;s!==a;++s)t.push(Mn.toJSON(i[s]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const h=rb(l);l=e0(l,1,h),c=e0(c,1,h),!n&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new uf(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const n=e;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===t)return i[n];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const n={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],h=c.name.match(s);if(h&&h.length>1){const d=h[1];let u=n[d];u||(n[d]=u=[]),u.push(c)}}const a=[];for(const o in n)a.push(this.CreateFromMorphTargetSequence(o,n[o],t,i));return a}resetDuration(){const e=this.tracks;let t=0;for(let i=0,n=e.length;i!==n;++i){const s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let i=0;i<this.tracks.length;i++)e.push(this.tracks[i].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function ub(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return uf;case"vector":case"vector2":case"vector3":case"vector4":return Jg;case"color":return Zg;case"quaternion":return ff;case"bool":case"boolean":return ka;case"string":return Na}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function fb(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=ub(r.type);if(r.times===void 0){const t=[],i=[];ab(r.keys,t,i,"value"),r.times=t,r.values=i}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}const ls={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(t0(r)||(this.files[r]=e))},get:function(r){if(this.enabled!==!1&&!t0(r))return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};function t0(r){try{const e=r.slice(r.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class pb{constructor(e,t,i){const n=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,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"),l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){const d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=c.length;d<u;d+=2){const f=c[d],p=c[d+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 mb=new pb;class Uo{constructor(e){this.manager=e!==void 0?e:mb,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(e,t){const i=this;return new Promise(function(n,s){i.load(e,n,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Uo.DEFAULT_MATERIAL_NAME="__DEFAULT";const es={};class gb extends Error{constructor(e,t){super(e),this.response=t}}class wA extends Uo{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=ls.get(`file:${e}`);if(s!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0);return}if(es[e]!==void 0){es[e].push({onLoad:t,onProgress:i,onError:n});return}es[e]=[],es[e].push({onLoad:t,onProgress:i,onError:n});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&_e("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=es[e],d=c.body.getReader(),u=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=u?parseInt(u):0,p=f!==0;let v=0;const m=new ReadableStream({start(g){x();function x(){d.read().then(({done:M,value:w})=>{if(M)g.close();else{v+=w.byteLength;const S=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:f});for(let _=0,D=h.length;_<D;_++){const y=h[_];y.onProgress&&y.onProgress(S)}g.enqueue(w),x()}},M=>{g.error(M)})}}});return new Response(m)}else throw new gb(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o==="")return c.text();{const d=/charset="?([^;"\s]*)"?/i.exec(o),u=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(u);return c.arrayBuffer().then(p=>f.decode(p))}}}).then(c=>{ls.add(`file:${e}`,c);const h=es[e];delete es[e];for(let d=0,u=h.length;d<u;d++){const f=h[d];f.onLoad&&f.onLoad(c)}}).catch(c=>{const h=es[e];if(h===void 0)throw this.manager.itemError(e),c;delete es[e];for(let d=0,u=h.length;d<u;d++){const f=h[d];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Wr=new WeakMap;class vb extends Uo{constructor(e){super(e)}load(e,t,i,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=ls.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0);else{let d=Wr.get(a);d===void 0&&(d=[],Wr.set(a,d)),d.push({onLoad:t,onError:n})}return a}const o=Po("img");function l(){h(),t&&t(this);const d=Wr.get(this)||[];for(let u=0;u<d.length;u++){const f=d[u];f.onLoad&&f.onLoad(this)}Wr.delete(this),s.manager.itemEnd(e)}function c(d){h(),n&&n(d),ls.remove(`image:${e}`);const u=Wr.get(this)||[];for(let f=0;f<u.length;f++){const p=u[f];p.onError&&p.onError(d)}Wr.delete(this),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),ls.add(`image:${e}`,o),s.manager.itemStart(e),o.src=e,o}}class MA extends Uo{constructor(e){super(e)}load(e,t,i,n){const s=new di,a=new vb(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},i,n),s}}class Lc extends _t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new oe(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class yb extends Lc{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const Eh=new Ye,i0=new P,n0=new P;class pf{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Te(512,512),this.mapType=$i,this.map=null,this.mapPass=null,this.matrix=new Ye,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new cf,this._frameExtents=new Te(1,1),this._viewportCount=1,this._viewports=[new at(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;i0.setFromMatrixPosition(e.matrixWorld),t.position.copy(i0),n0.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(n0),t.updateMatrixWorld(),Eh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Eh,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Ro||t.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(Eh)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const xl=new P,Sl=new qn,Tn=new P;class jg extends _t{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ye,this.projectionMatrix=new Ye,this.projectionMatrixInverse=new Ye,this.coordinateSystem=Hn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(xl,Sl,Tn),Tn.x===1&&Tn.y===1&&Tn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(xl,Sl,Tn.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(xl,Sl,Tn),Tn.x===1&&Tn.y===1&&Tn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(xl,Sl,Tn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Es=new P,s0=new Te,r0=new Te;class zi extends jg{constructor(e=50,t=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Da*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(mo*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Da*2*Math.atan(Math.tan(mo*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Es.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Es.x,Es.y).multiplyScalar(-e/Es.z),Es.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Es.x,Es.y).multiplyScalar(-e/Es.z)}getViewSize(e,t){return this.getViewBounds(e,s0,r0),t.subVectors(r0,s0)}setViewOffset(e,t,i,n,s,a){this.aspect=e/t,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=e,this.view.fullHeight=t,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 e=this.near;let t=e*Math.tan(mo*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,s=-.5*n;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*n/l,t-=a.offsetY*i/c,n*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class bb extends pf{constructor(){super(new zi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=Da*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(i!==t.fov||n!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=n,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class xA extends Lc{constructor(e,t,i=0,n=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=i,this.angle=n,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new bb}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class wb extends pf{constructor(){super(new zi(90,1,.5,500)),this.isPointLightShadow=!0}}class Mb extends Lc{constructor(e,t,i=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new wb}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Hs extends jg{constructor(e=-1,t=1,i=1,n=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,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=e,this.view.fullHeight=t,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 e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let s=i-e,a=i+e,o=n+t,l=n-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class xb extends pf{constructor(){super(new Hs(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class a0 extends Lc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new xb}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class SA{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const _h=new WeakMap;class EA extends Uo{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&_e("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&_e("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=ls.get(`image-bitmap:${e}`);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{_h.has(a)===!0?(n&&n(_h.get(a)),s.manager.itemError(e),s.manager.itemEnd(e)):(t&&t(c),s.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},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 l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){ls.add(`image-bitmap:${e}`,c),t&&t(c),s.manager.itemEnd(e)}).catch(function(c){n&&n(c),_h.set(l,c),ls.remove(`image-bitmap:${e}`),s.manager.itemError(e),s.manager.itemEnd(e)});ls.add(`image-bitmap:${e}`,l),s.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Xr=-90,qr=1;class Sb extends _t{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new zi(Xr,qr,e,t);n.layers=this.layers,this.add(n);const s=new zi(Xr,qr,e,t);s.layers=this.layers,this.add(s);const a=new zi(Xr,qr,e,t);a.layers=this.layers,this.add(a);const o=new zi(Xr,qr,e,t);o.layers=this.layers,this.add(o);const l=new zi(Xr,qr,e,t);l.layers=this.layers,this.add(l);const c=new zi(Xr,qr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,n,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===Hn)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),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Ro)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),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,1,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=v,e.setRenderTarget(i,5,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class Eb extends zi{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const mf="\\[\\]\\.:\\/",_b=new RegExp("["+mf+"]","g"),gf="[^"+mf+"]",Tb="[^"+mf.replace("\\.","")+"]",Ab=/((?:WC+[\/:])*)/.source.replace("WC",gf),Ib=/(WCOD+)?/.source.replace("WCOD",Tb),Db=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",gf),Cb=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",gf),Rb=new RegExp("^"+Ab+Ib+Db+Cb+"$"),Pb=["material","materials","bones","map"];class Lb{constructor(e,t,i){const n=i||bt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=i.length;n!==s;++n)i[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class bt{constructor(e,t,i){this.path=t,this.parsedPath=i||bt.parseTrackName(t),this.node=bt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new bt.Composite(e,t,i):new bt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(_b,"")}static parseTrackName(e){const t=Rb.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const s=i.nodeName.substring(n+1);Pb.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: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const l=i(o.children);if(l)return l}return null},n=i(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)e[t++]=i[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,n=t.propertyName;let s=t.propertyIndex;if(e||(e=bt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){_e("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ue("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Ue("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ue("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){Ue("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){Ue("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[n];if(a===void 0){const c=t.nodeName;Ue("PropertyBinding: Trying to update property for track: "+c+"."+n+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=n;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}bt.Composite=Lb;bt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};bt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};bt.prototype.GetterByBindingType=[bt.prototype._getValue_direct,bt.prototype._getValue_array,bt.prototype._getValue_arrayElement,bt.prototype._getValue_toArray];bt.prototype.SetterByBindingTypeAndVersioning=[[bt.prototype._setValue_direct,bt.prototype._setValue_direct_setNeedsUpdate,bt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[bt.prototype._setValue_array,bt.prototype._setValue_array_setNeedsUpdate,bt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[bt.prototype._setValue_arrayElement,bt.prototype._setValue_arrayElement_setNeedsUpdate,bt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[bt.prototype._setValue_fromArray,bt.prototype._setValue_fromArray_setNeedsUpdate,bt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const o0=new Ye;class Th{constructor(e,t,i=0,n=1/0){this.ray=new ko(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new of,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Ue("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return o0.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(o0),this}intersectObject(e,t=!0,i=[]){return hu(e,this,i,t),i.sort(l0),i}intersectObjects(e,t=!0,i=[]){for(let n=0,s=e.length;n<s;n++)hu(e[n],this,i,t);return i.sort(l0),i}}function l0(r,e){return r.distance-e.distance}function hu(r,e,t,i){let n=!0;if(r.layers.test(e.layers)&&r.raycast(e,t)===!1&&(n=!1),n===!0&&i===!0){const s=r.children;for(let a=0,o=s.length;a<o;a++)hu(s[a],e,t,!0)}}class Qg{static{Qg.prototype.isMatrix2=!0}constructor(e,t,i,n){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,n)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,n){const s=this.elements;return s[0]=e,s[2]=t,s[1]=i,s[3]=n,this}}function c0(r,e,t,i){const n=kb(i);switch(t){case Og:return r*e;case Pc:return r*e/n.components*n.byteLength;case Qu:return r*e/n.components*n.byteLength;case vr:return r*e*2/n.components*n.byteLength;case ef:return r*e*2/n.components*n.byteLength;case Fg:return r*e*3/n.components*n.byteLength;case Ti:return r*e*4/n.components*n.byteLength;case tf:return r*e*4/n.components*n.byteLength;case ql:case Yl:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case Kl:case $l:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Pd:case kd:return Math.max(r,16)*Math.max(e,8)/4;case Rd:case Ld:return Math.max(r,8)*Math.max(e,8)/2;case Nd:case Od:case Ud:case Bd:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case Fd:case ac:case zd:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Hd:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Gd:return Math.floor((r+4)/5)*Math.floor((e+3)/4)*16;case Vd:return Math.floor((r+4)/5)*Math.floor((e+4)/5)*16;case Wd:return Math.floor((r+5)/6)*Math.floor((e+4)/5)*16;case Xd:return Math.floor((r+5)/6)*Math.floor((e+5)/6)*16;case qd:return Math.floor((r+7)/8)*Math.floor((e+4)/5)*16;case Yd:return Math.floor((r+7)/8)*Math.floor((e+5)/6)*16;case Kd:return Math.floor((r+7)/8)*Math.floor((e+7)/8)*16;case $d:return Math.floor((r+9)/10)*Math.floor((e+4)/5)*16;case Zd:return Math.floor((r+9)/10)*Math.floor((e+5)/6)*16;case Jd:return Math.floor((r+9)/10)*Math.floor((e+7)/8)*16;case jd:return Math.floor((r+9)/10)*Math.floor((e+9)/10)*16;case Qd:return Math.floor((r+11)/12)*Math.floor((e+9)/10)*16;case eu:return Math.floor((r+11)/12)*Math.floor((e+11)/12)*16;case tu:case iu:case nu:return Math.ceil(r/4)*Math.ceil(e/4)*16;case su:case ru:return Math.ceil(r/4)*Math.ceil(e/4)*8;case oc:case au:return Math.ceil(r/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function kb(r){switch(r){case $i:case Pg:return{byteLength:1,components:1};case Do:case Lg:case ui:return{byteLength:2,components:1};case Ju:case ju:return{byteLength:2,components:4};case yn:case Zu:case Pi:return{byteLength:4,components:1};case kg:case Ng: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:Ku}}));typeof window<"u"&&(window.__THREE__?_e("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ku);/**
2112
+ }`;class Ot extends ps{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=eb,this.fragmentShader=tb,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,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ra(e.uniforms),this.uniformsGroups=jy(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const n in this.uniforms){const a=this.uniforms[n].value;a&&a.isTexture?t.uniforms[n]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[n]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[n]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[n]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[n]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[n]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[n]={type:"m4",value:a.toArray()}:t.uniforms[n]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const n=e.uniforms[i];switch(this.uniforms[i]={},n.type){case"t":this.uniforms[i].value=t[n.value]||null;break;case"c":this.uniforms[i].value=new oe().setHex(n.value);break;case"v2":this.uniforms[i].value=new Te().fromArray(n.value);break;case"v3":this.uniforms[i].value=new P().fromArray(n.value);break;case"v4":this.uniforms[i].value=new at().fromArray(n.value);break;case"m3":this.uniforms[i].value=new He().fromArray(n.value);break;case"m4":this.uniforms[i].value=new Ye().fromArray(n.value);break;default:this.uniforms[i].value=n.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class $g extends Ot{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class ib extends ps{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new oe(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 oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cc,this.normalScale=new Te(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 Yn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class yA extends ib{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Te(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Je(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new oe(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 oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new oe(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(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Oo extends ps{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cc,this.normalScale=new Te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Yn,this.combine=$u,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class nb extends ps{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Y2,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class sb extends ps{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Ml(r,e){return!r||r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function rb(r){function e(n,s){return r[n]-r[s]}const t=r.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort(e),i}function e0(r,e,t){const i=r.length,n=new r.constructor(i);for(let s=0,a=0;a!==i;++s){const o=t[s]*e;for(let l=0;l!==e;++l)n[a++]=r[o+l]}return n}function ab(r,e,t,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&&(e.push(s.time),t.push(...a)),s=r[n++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[i],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=r[n++];while(s!==void 0);else do a=s[i],a!==void 0&&(e.push(s.time),t.push(a)),s=r[n++];while(s!==void 0)}class Fo{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,n=t[i],s=t[i-1];i:{e:{let a;t:{n:if(!(e<n)){for(let o=i+2;;){if(n===void 0){if(e<s)break n;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=n,n=t[++i],e<n)break e}a=t.length;break t}if(!(e>=s)){const o=t[1];e<o&&(i=2,s=o);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(n=s,s=t[--i-1],e>=s)break e}a=i,i=0;break t}break i}for(;i<a;){const o=i+a>>>1;e<t[o]?a=o:i=o+1}if(n=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=e*n;for(let a=0;a!==n;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class ob extends Fo{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:vp,endingEnd:vp}}intervalChanged_(e,t,i){const n=this.parameterPositions;let s=e-2,a=e+1,o=n[s],l=n[a];if(o===void 0)switch(this.getSettings_().endingStart){case yp:s=e,o=2*t-i;break;case bp:s=n.length-2,o=t+n[s]-n[s+1];break;default:s=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case yp:a=e,l=2*i-t;break;case bp:a=1,l=i+n[1]-n[0];break;default:a=e-1,l=t}const c=(i-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-i),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,d=this._offsetNext,u=this._weightPrev,f=this._weightNext,p=(i-t)/(n-t),v=p*p,m=v*p,g=-u*m+2*u*v-u*p,x=(1+u)*m+(-1.5-2*u)*v+(-.5+u)*p+1,M=(-1-f)*m+(1.5+f)*v+.5*p,w=f*m-f*v;for(let S=0;S!==o;++S)s[S]=g*a[h+S]+x*a[c+S]+M*a[l+S]+w*a[d+S];return s}}class lb extends Fo{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(i-t)/(n-t),d=1-h;for(let u=0;u!==o;++u)s[u]=a[c+u]*d+a[l+u]*h;return s}}class cb extends Fo{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class hb extends Fo{interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this.inTangents,d=this.outTangents;if(!h||!d){const p=(i-t)/(n-t),v=1-p;for(let m=0;m!==o;++m)s[m]=a[c+m]*v+a[l+m]*p;return s}const u=o*2,f=e-1;for(let p=0;p!==o;++p){const v=a[c+p],m=a[l+p],g=f*u+p*2,x=d[g],M=d[g+1],w=e*u+p*2,S=h[w],_=h[w+1];let D=(i-t)/(n-t),y,T,A,I,R;for(let k=0;k<8;k++){y=D*D,T=y*D,A=1-D,I=A*A,R=I*A;const L=R*t+3*I*D*x+3*A*y*S+T*n-i;if(Math.abs(L)<1e-10)break;const B=3*I*(x-t)+6*A*D*(S-x)+3*y*(n-S);if(Math.abs(B)<1e-10)break;D=D-L/B,D=Math.max(0,Math.min(1,D))}s[p]=R*v+3*I*D*M+3*A*y*_+T*m}return s}}class Mn{constructor(e,t,i,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Ml(t,this.TimeBufferType),this.values=Ml(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Ml(e.times,Array),values:Ml(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(i.interpolation=n)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new cb(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new lb(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ob(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new hb(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case lc:t=this.InterpolantFactoryMethodDiscrete;break;case ou:t=this.InterpolantFactoryMethodLinear;break;case Jc:t=this.InterpolantFactoryMethodSmooth;break;case gp:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return _e("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return lc;case this.InterpolantFactoryMethodLinear:return ou;case this.InterpolantFactoryMethodSmooth:return Jc;case this.InterpolantFactoryMethodBezier:return gp}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){const i=this.times,n=i.length;let s=0,a=n-1;for(;s!==n&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--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 e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Ue("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,s=i.length;s===0&&(Ue("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){Ue("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){Ue("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(n!==void 0&&iy(n))for(let o=0,l=n.length;o!==l;++o){const c=n[o];if(isNaN(c)){Ue("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===Jc,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],h=e[o+1];if(c!==h&&(o!==1||c!==e[0]))if(n)l=!0;else{const d=o*i,u=d-i,f=d+i;for(let p=0;p!==i;++p){const v=t[d+p];if(v!==t[u+p]||v!==t[f+p]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const d=o*i,u=a*i;for(let f=0;f!==i;++f)t[u+f]=t[d+f]}++a}}if(s>0){e[a]=e[s];for(let o=s*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,n=new i(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Mn.prototype.ValueTypeName="";Mn.prototype.TimeBufferType=Float32Array;Mn.prototype.ValueBufferType=Float32Array;Mn.prototype.DefaultInterpolation=ou;class ka extends Mn{constructor(e,t,i){super(e,t,i)}}ka.prototype.ValueTypeName="bool";ka.prototype.ValueBufferType=Array;ka.prototype.DefaultInterpolation=lc;ka.prototype.InterpolantFactoryMethodLinear=void 0;ka.prototype.InterpolantFactoryMethodSmooth=void 0;class Zg extends Mn{constructor(e,t,i,n){super(e,t,i,n)}}Zg.prototype.ValueTypeName="color";class uf extends Mn{constructor(e,t,i,n){super(e,t,i,n)}}uf.prototype.ValueTypeName="number";class db extends Fo{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(n-t);let c=e*o;for(let h=c+o;c!==h;c+=4)qn.slerpFlat(s,0,a,c-o,a,c,l);return s}}class ff extends Mn{constructor(e,t,i,n){super(e,t,i,n)}InterpolantFactoryMethodLinear(e){return new db(this.times,this.values,this.getValueSize(),e)}}ff.prototype.ValueTypeName="quaternion";ff.prototype.InterpolantFactoryMethodSmooth=void 0;class Na extends Mn{constructor(e,t,i){super(e,t,i)}}Na.prototype.ValueTypeName="string";Na.prototype.ValueBufferType=Array;Na.prototype.DefaultInterpolation=lc;Na.prototype.InterpolantFactoryMethodLinear=void 0;Na.prototype.InterpolantFactoryMethodSmooth=void 0;class Jg extends Mn{constructor(e,t,i,n){super(e,t,i,n)}}Jg.prototype.ValueTypeName="vector";class bA{constructor(e="",t=-1,i=[],n=q2){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=vn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(fb(i[a]).scale(n));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let s=0,a=i.length;s!==a;++s)t.push(Mn.toJSON(i[s]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const h=rb(l);l=e0(l,1,h),c=e0(c,1,h),!n&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new uf(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const n=e;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===t)return i[n];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const n={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],h=c.name.match(s);if(h&&h.length>1){const d=h[1];let u=n[d];u||(n[d]=u=[]),u.push(c)}}const a=[];for(const o in n)a.push(this.CreateFromMorphTargetSequence(o,n[o],t,i));return a}resetDuration(){const e=this.tracks;let t=0;for(let i=0,n=e.length;i!==n;++i){const s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let i=0;i<this.tracks.length;i++)e.push(this.tracks[i].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function ub(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return uf;case"vector":case"vector2":case"vector3":case"vector4":return Jg;case"color":return Zg;case"quaternion":return ff;case"bool":case"boolean":return ka;case"string":return Na}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function fb(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=ub(r.type);if(r.times===void 0){const t=[],i=[];ab(r.keys,t,i,"value"),r.times=t,r.values=i}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}const ls={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(t0(r)||(this.files[r]=e))},get:function(r){if(this.enabled!==!1&&!t0(r))return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};function t0(r){try{const e=r.slice(r.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class pb{constructor(e,t,i){const n=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,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"),l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){const d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=c.length;d<u;d+=2){const f=c[d],p=c[d+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 mb=new pb;class Uo{constructor(e){this.manager=e!==void 0?e:mb,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(e,t){const i=this;return new Promise(function(n,s){i.load(e,n,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Uo.DEFAULT_MATERIAL_NAME="__DEFAULT";const es={};class gb extends Error{constructor(e,t){super(e),this.response=t}}class wA extends Uo{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=ls.get(`file:${e}`);if(s!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0);return}if(es[e]!==void 0){es[e].push({onLoad:t,onProgress:i,onError:n});return}es[e]=[],es[e].push({onLoad:t,onProgress:i,onError:n});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&_e("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=es[e],d=c.body.getReader(),u=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=u?parseInt(u):0,p=f!==0;let v=0;const m=new ReadableStream({start(g){x();function x(){d.read().then(({done:M,value:w})=>{if(M)g.close();else{v+=w.byteLength;const S=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:f});for(let _=0,D=h.length;_<D;_++){const y=h[_];y.onProgress&&y.onProgress(S)}g.enqueue(w),x()}},M=>{g.error(M)})}}});return new Response(m)}else throw new gb(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o==="")return c.text();{const d=/charset="?([^;"\s]*)"?/i.exec(o),u=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(u);return c.arrayBuffer().then(p=>f.decode(p))}}}).then(c=>{ls.add(`file:${e}`,c);const h=es[e];delete es[e];for(let d=0,u=h.length;d<u;d++){const f=h[d];f.onLoad&&f.onLoad(c)}}).catch(c=>{const h=es[e];if(h===void 0)throw this.manager.itemError(e),c;delete es[e];for(let d=0,u=h.length;d<u;d++){const f=h[d];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Wr=new WeakMap;class vb extends Uo{constructor(e){super(e)}load(e,t,i,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=ls.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0);else{let d=Wr.get(a);d===void 0&&(d=[],Wr.set(a,d)),d.push({onLoad:t,onError:n})}return a}const o=Po("img");function l(){h(),t&&t(this);const d=Wr.get(this)||[];for(let u=0;u<d.length;u++){const f=d[u];f.onLoad&&f.onLoad(this)}Wr.delete(this),s.manager.itemEnd(e)}function c(d){h(),n&&n(d),ls.remove(`image:${e}`);const u=Wr.get(this)||[];for(let f=0;f<u.length;f++){const p=u[f];p.onError&&p.onError(d)}Wr.delete(this),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),ls.add(`image:${e}`,o),s.manager.itemStart(e),o.src=e,o}}class MA extends Uo{constructor(e){super(e)}load(e,t,i,n){const s=new di,a=new vb(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},i,n),s}}class Lc extends _t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new oe(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class yb extends Lc{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const Eh=new Ye,i0=new P,n0=new P;class pf{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Te(512,512),this.mapType=$i,this.map=null,this.mapPass=null,this.matrix=new Ye,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new cf,this._frameExtents=new Te(1,1),this._viewportCount=1,this._viewports=[new at(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;i0.setFromMatrixPosition(e.matrixWorld),t.position.copy(i0),n0.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(n0),t.updateMatrixWorld(),Eh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Eh,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Ro||t.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(Eh)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const xl=new P,Sl=new qn,Tn=new P;class jg extends _t{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ye,this.projectionMatrix=new Ye,this.projectionMatrixInverse=new Ye,this.coordinateSystem=Hn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(xl,Sl,Tn),Tn.x===1&&Tn.y===1&&Tn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(xl,Sl,Tn.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(xl,Sl,Tn),Tn.x===1&&Tn.y===1&&Tn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(xl,Sl,Tn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Es=new P,s0=new Te,r0=new Te;class zi extends jg{constructor(e=50,t=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Da*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(mo*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Da*2*Math.atan(Math.tan(mo*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Es.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Es.x,Es.y).multiplyScalar(-e/Es.z),Es.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Es.x,Es.y).multiplyScalar(-e/Es.z)}getViewSize(e,t){return this.getViewBounds(e,s0,r0),t.subVectors(r0,s0)}setViewOffset(e,t,i,n,s,a){this.aspect=e/t,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=e,this.view.fullHeight=t,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 e=this.near;let t=e*Math.tan(mo*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,s=-.5*n;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*n/l,t-=a.offsetY*i/c,n*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class bb extends pf{constructor(){super(new zi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=Da*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(i!==t.fov||n!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=n,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class xA extends Lc{constructor(e,t,i=0,n=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=i,this.angle=n,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new bb}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class wb extends pf{constructor(){super(new zi(90,1,.5,500)),this.isPointLightShadow=!0}}class Mb extends Lc{constructor(e,t,i=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new wb}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Hs extends jg{constructor(e=-1,t=1,i=1,n=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,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=e,this.view.fullHeight=t,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 e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let s=i-e,a=i+e,o=n+t,l=n-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class xb extends pf{constructor(){super(new Hs(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class a0 extends Lc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new xb}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class SA{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const _h=new WeakMap;class EA extends Uo{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&_e("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&_e("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=ls.get(`image-bitmap:${e}`);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{_h.has(a)===!0?(n&&n(_h.get(a)),s.manager.itemError(e),s.manager.itemEnd(e)):(t&&t(c),s.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},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 l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){ls.add(`image-bitmap:${e}`,c),t&&t(c),s.manager.itemEnd(e)}).catch(function(c){n&&n(c),_h.set(l,c),ls.remove(`image-bitmap:${e}`),s.manager.itemError(e),s.manager.itemEnd(e)});ls.add(`image-bitmap:${e}`,l),s.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Xr=-90,qr=1;class Sb extends _t{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new zi(Xr,qr,e,t);n.layers=this.layers,this.add(n);const s=new zi(Xr,qr,e,t);s.layers=this.layers,this.add(s);const a=new zi(Xr,qr,e,t);a.layers=this.layers,this.add(a);const o=new zi(Xr,qr,e,t);o.layers=this.layers,this.add(o);const l=new zi(Xr,qr,e,t);l.layers=this.layers,this.add(l);const c=new zi(Xr,qr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,n,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===Hn)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),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Ro)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),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,1,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=v,e.setRenderTarget(i,5,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class Eb extends zi{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const mf="\\[\\]\\.:\\/",_b=new RegExp("["+mf+"]","g"),gf="[^"+mf+"]",Tb="[^"+mf.replace("\\.","")+"]",Ab=/((?:WC+[\/:])*)/.source.replace("WC",gf),Ib=/(WCOD+)?/.source.replace("WCOD",Tb),Db=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",gf),Cb=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",gf),Rb=new RegExp("^"+Ab+Ib+Db+Cb+"$"),Pb=["material","materials","bones","map"];class Lb{constructor(e,t,i){const n=i||bt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=i.length;n!==s;++n)i[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class bt{constructor(e,t,i){this.path=t,this.parsedPath=i||bt.parseTrackName(t),this.node=bt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new bt.Composite(e,t,i):new bt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(_b,"")}static parseTrackName(e){const t=Rb.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const s=i.nodeName.substring(n+1);Pb.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: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const l=i(o.children);if(l)return l}return null},n=i(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)e[t++]=i[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,n=t.propertyName;let s=t.propertyIndex;if(e||(e=bt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){_e("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ue("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Ue("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ue("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){Ue("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){Ue("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[n];if(a===void 0){const c=t.nodeName;Ue("PropertyBinding: Trying to update property for track: "+c+"."+n+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=n;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}bt.Composite=Lb;bt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};bt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};bt.prototype.GetterByBindingType=[bt.prototype._getValue_direct,bt.prototype._getValue_array,bt.prototype._getValue_arrayElement,bt.prototype._getValue_toArray];bt.prototype.SetterByBindingTypeAndVersioning=[[bt.prototype._setValue_direct,bt.prototype._setValue_direct_setNeedsUpdate,bt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[bt.prototype._setValue_array,bt.prototype._setValue_array_setNeedsUpdate,bt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[bt.prototype._setValue_arrayElement,bt.prototype._setValue_arrayElement_setNeedsUpdate,bt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[bt.prototype._setValue_fromArray,bt.prototype._setValue_fromArray_setNeedsUpdate,bt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const o0=new Ye;class Th{constructor(e,t,i=0,n=1/0){this.ray=new ko(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new of,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Ue("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return o0.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(o0),this}intersectObject(e,t=!0,i=[]){return hu(e,this,i,t),i.sort(l0),i}intersectObjects(e,t=!0,i=[]){for(let n=0,s=e.length;n<s;n++)hu(e[n],this,i,t);return i.sort(l0),i}}function l0(r,e){return r.distance-e.distance}function hu(r,e,t,i){let n=!0;if(r.layers.test(e.layers)&&r.raycast(e,t)===!1&&(n=!1),n===!0&&i===!0){const s=r.children;for(let a=0,o=s.length;a<o;a++)hu(s[a],e,t,!0)}}class Qg{static{Qg.prototype.isMatrix2=!0}constructor(e,t,i,n){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,n)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,n){const s=this.elements;return s[0]=e,s[2]=t,s[1]=i,s[3]=n,this}}function c0(r,e,t,i){const n=kb(i);switch(t){case Og:return r*e;case Pc:return r*e/n.components*n.byteLength;case Qu:return r*e/n.components*n.byteLength;case vr:return r*e*2/n.components*n.byteLength;case ef:return r*e*2/n.components*n.byteLength;case Fg:return r*e*3/n.components*n.byteLength;case Ti:return r*e*4/n.components*n.byteLength;case tf:return r*e*4/n.components*n.byteLength;case ql:case Yl:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case Kl:case $l:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Pd:case kd:return Math.max(r,16)*Math.max(e,8)/4;case Rd:case Ld:return Math.max(r,8)*Math.max(e,8)/2;case Nd:case Od:case Ud:case Bd:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case Fd:case ac:case zd:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Hd:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Gd:return Math.floor((r+4)/5)*Math.floor((e+3)/4)*16;case Vd:return Math.floor((r+4)/5)*Math.floor((e+4)/5)*16;case Wd:return Math.floor((r+5)/6)*Math.floor((e+4)/5)*16;case Xd:return Math.floor((r+5)/6)*Math.floor((e+5)/6)*16;case qd:return Math.floor((r+7)/8)*Math.floor((e+4)/5)*16;case Yd:return Math.floor((r+7)/8)*Math.floor((e+5)/6)*16;case Kd:return Math.floor((r+7)/8)*Math.floor((e+7)/8)*16;case $d:return Math.floor((r+9)/10)*Math.floor((e+4)/5)*16;case Zd:return Math.floor((r+9)/10)*Math.floor((e+5)/6)*16;case Jd:return Math.floor((r+9)/10)*Math.floor((e+7)/8)*16;case jd:return Math.floor((r+9)/10)*Math.floor((e+9)/10)*16;case Qd:return Math.floor((r+11)/12)*Math.floor((e+9)/10)*16;case eu:return Math.floor((r+11)/12)*Math.floor((e+11)/12)*16;case tu:case iu:case nu:return Math.ceil(r/4)*Math.ceil(e/4)*16;case su:case ru:return Math.ceil(r/4)*Math.ceil(e/4)*8;case oc:case au:return Math.ceil(r/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function kb(r){switch(r){case $i:case Pg:return{byteLength:1,components:1};case Do:case Lg:case ui:return{byteLength:2,components:1};case Ju:case ju:return{byteLength:2,components:4};case yn:case Zu:case Pi:return{byteLength:4,components:1};case kg:case Ng: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:Ku}}));typeof window<"u"&&(window.__THREE__?_e("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ku);/**
2113
2113
  * @license
2114
2114
  * Copyright 2010-2026 Three.js Authors
2115
2115
  * SPDX-License-Identifier: MIT
@@ -5779,7 +5779,7 @@ void main() {
5779
5779
  #include <tonemapping_fragment>
5780
5780
  #include <colorspace_fragment>
5781
5781
  #include <fog_fragment>
5782
- }`,Ke={alphahash_fragment:Ob,alphahash_pars_fragment:Fb,alphamap_fragment:Ub,alphamap_pars_fragment:Bb,alphatest_fragment:zb,alphatest_pars_fragment:Hb,aomap_fragment:Gb,aomap_pars_fragment:Vb,batching_pars_vertex:Wb,batching_vertex:Xb,begin_vertex:qb,beginnormal_vertex:Yb,bsdfs:Kb,iridescence_fragment:$b,bumpmap_pars_fragment:Zb,clipping_planes_fragment:Jb,clipping_planes_pars_fragment:jb,clipping_planes_pars_vertex:Qb,clipping_planes_vertex:ew,color_fragment:tw,color_pars_fragment:iw,color_pars_vertex:nw,color_vertex:sw,common:rw,cube_uv_reflection_fragment:aw,defaultnormal_vertex:ow,displacementmap_pars_vertex:lw,displacementmap_vertex:cw,emissivemap_fragment:hw,emissivemap_pars_fragment:dw,colorspace_fragment:uw,colorspace_pars_fragment:fw,envmap_fragment:pw,envmap_common_pars_fragment:mw,envmap_pars_fragment:gw,envmap_pars_vertex:vw,envmap_physical_pars_fragment:Iw,envmap_vertex:yw,fog_vertex:bw,fog_pars_vertex:ww,fog_fragment:Mw,fog_pars_fragment:xw,gradientmap_pars_fragment:Sw,lightmap_pars_fragment:Ew,lights_lambert_fragment:_w,lights_lambert_pars_fragment:Tw,lights_pars_begin:Aw,lights_toon_fragment:Dw,lights_toon_pars_fragment:Cw,lights_phong_fragment:Rw,lights_phong_pars_fragment:Pw,lights_physical_fragment:Lw,lights_physical_pars_fragment:kw,lights_fragment_begin:Nw,lights_fragment_maps:Ow,lights_fragment_end:Fw,lightprobes_pars_fragment:Uw,logdepthbuf_fragment:Bw,logdepthbuf_pars_fragment:zw,logdepthbuf_pars_vertex:Hw,logdepthbuf_vertex:Gw,map_fragment:Vw,map_pars_fragment:Ww,map_particle_fragment:Xw,map_particle_pars_fragment:qw,metalnessmap_fragment:Yw,metalnessmap_pars_fragment:Kw,morphinstance_vertex:$w,morphcolor_vertex:Zw,morphnormal_vertex:Jw,morphtarget_pars_vertex:jw,morphtarget_vertex:Qw,normal_fragment_begin:eM,normal_fragment_maps:tM,normal_pars_fragment:iM,normal_pars_vertex:nM,normal_vertex:sM,normalmap_pars_fragment:rM,clearcoat_normal_fragment_begin:aM,clearcoat_normal_fragment_maps:oM,clearcoat_pars_fragment:lM,iridescence_pars_fragment:cM,opaque_fragment:hM,packing:dM,premultiplied_alpha_fragment:uM,project_vertex:fM,dithering_fragment:pM,dithering_pars_fragment:mM,roughnessmap_fragment:gM,roughnessmap_pars_fragment:vM,shadowmap_pars_fragment:yM,shadowmap_pars_vertex:bM,shadowmap_vertex:wM,shadowmask_pars_fragment:MM,skinbase_vertex:xM,skinning_pars_vertex:SM,skinning_vertex:EM,skinnormal_vertex:_M,specularmap_fragment:TM,specularmap_pars_fragment:AM,tonemapping_fragment:IM,tonemapping_pars_fragment:DM,transmission_fragment:CM,transmission_pars_fragment:RM,uv_pars_fragment:PM,uv_pars_vertex:LM,uv_vertex:kM,worldpos_vertex:NM,background_vert:OM,background_frag:FM,backgroundCube_vert:UM,backgroundCube_frag:BM,cube_vert:zM,cube_frag:HM,depth_vert:GM,depth_frag:VM,distance_vert:WM,distance_frag:XM,equirect_vert:qM,equirect_frag:YM,linedashed_vert:KM,linedashed_frag:$M,meshbasic_vert:ZM,meshbasic_frag:JM,meshlambert_vert:jM,meshlambert_frag:QM,meshmatcap_vert:ex,meshmatcap_frag:tx,meshnormal_vert:ix,meshnormal_frag:nx,meshphong_vert:sx,meshphong_frag:rx,meshphysical_vert:ax,meshphysical_frag:ox,meshtoon_vert:lx,meshtoon_frag:cx,points_vert:hx,points_frag:dx,shadow_vert:ux,shadow_frag:fx,sprite_vert:px,sprite_frag:mx},pe={common:{diffuse:{value:new oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ze}},envmap:{envMap:{value:null},envMapRotation:{value:new ze},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ze}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ze}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ze},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ze},normalScale:{value:new Te(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ze},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ze}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ze}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ze}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new oe(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 P},probesMax:{value:new P},probesResolution:{value:new P}},points:{diffuse:{value:new oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0},uvTransform:{value:new ze}},sprite:{diffuse:{value:new oe(16777215)},opacity:{value:1},center:{value:new Te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}}},kn={basic:{uniforms:Ii([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:Ke.meshbasic_vert,fragmentShader:Ke.meshbasic_frag},lambert:{uniforms:Ii([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new oe(0)},envMapIntensity:{value:1}}]),vertexShader:Ke.meshlambert_vert,fragmentShader:Ke.meshlambert_frag},phong:{uniforms:Ii([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new oe(0)},specular:{value:new oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphong_vert,fragmentShader:Ke.meshphong_frag},standard:{uniforms:Ii([pe.common,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.roughnessmap,pe.metalnessmap,pe.fog,pe.lights,{emissive:{value:new oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag},toon:{uniforms:Ii([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new oe(0)}}]),vertexShader:Ke.meshtoon_vert,fragmentShader:Ke.meshtoon_frag},matcap:{uniforms:Ii([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:Ke.meshmatcap_vert,fragmentShader:Ke.meshmatcap_frag},points:{uniforms:Ii([pe.points,pe.fog]),vertexShader:Ke.points_vert,fragmentShader:Ke.points_frag},dashed:{uniforms:Ii([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ke.linedashed_vert,fragmentShader:Ke.linedashed_frag},depth:{uniforms:Ii([pe.common,pe.displacementmap]),vertexShader:Ke.depth_vert,fragmentShader:Ke.depth_frag},normal:{uniforms:Ii([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:Ke.meshnormal_vert,fragmentShader:Ke.meshnormal_frag},sprite:{uniforms:Ii([pe.sprite,pe.fog]),vertexShader:Ke.sprite_vert,fragmentShader:Ke.sprite_frag},background:{uniforms:{uvTransform:{value:new ze},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ke.background_vert,fragmentShader:Ke.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ze}},vertexShader:Ke.backgroundCube_vert,fragmentShader:Ke.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ke.cube_vert,fragmentShader:Ke.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ke.equirect_vert,fragmentShader:Ke.equirect_frag},distance:{uniforms:Ii([pe.common,pe.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ke.distance_vert,fragmentShader:Ke.distance_frag},shadow:{uniforms:Ii([pe.lights,pe.fog,{color:{value:new oe(0)},opacity:{value:1}}]),vertexShader:Ke.shadow_vert,fragmentShader:Ke.shadow_frag}};kn.physical={uniforms:Ii([kn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ze},clearcoatNormalScale:{value:new Te(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ze},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ze},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ze},sheen:{value:0},sheenColor:{value:new oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ze},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ze},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ze},transmissionSamplerSize:{value:new Te},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ze},attenuationDistance:{value:0},attenuationColor:{value:new oe(0)},specularColor:{value:new oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ze},anisotropyVector:{value:new Te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ze}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag};const El={r:0,b:0,g:0},gx=new Ye,t1=new ze;t1.set(-1,0,0,0,1,0,0,0,1);function vx(r,e,t,i,n,s){const a=new oe(0);let o=n===!0?0:1,l,c,h=null,d=0,u=null;function f(x){let M=x.isScene===!0?x.background:null;if(M&&M.isTexture){const w=x.backgroundBlurriness>0;M=e.get(M,w)}return M}function p(x){let M=!1;const w=f(x);w===null?m(a,o):w&&w.isColor&&(m(w,1),M=!0);const S=r.xr.getEnvironmentBlendMode();S==="additive"?t.buffers.color.setClear(0,0,0,1,s):S==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(r.autoClear||M)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function v(x,M){const w=f(M);w&&(w.isCubeTexture||w.mapping===Rc)?(c===void 0&&(c=new We(new an(1,1,1),new Ot({name:"BackgroundCubeMaterial",uniforms:Ra(kn.backgroundCube.uniforms),vertexShader:kn.backgroundCube.vertexShader,fragmentShader:kn.backgroundCube.fragmentShader,side:Ft,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(S,_,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=w,c.material.uniforms.backgroundBlurriness.value=M.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=M.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(gx.makeRotationFromEuler(M.backgroundRotation)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(t1),c.material.toneMapped=tt.getTransfer(w.colorSpace)!==pt,(h!==w||d!==w.version||u!==r.toneMapping)&&(c.material.needsUpdate=!0,h=w,d=w.version,u=r.toneMapping),c.layers.enableAll(),x.unshift(c,c.geometry,c.material,0,0,null)):w&&w.isTexture&&(l===void 0&&(l=new We(new wn(2,2),new Ot({name:"BackgroundMaterial",uniforms:Ra(kn.background.uniforms),vertexShader:kn.background.vertexShader,fragmentShader:kn.background.fragmentShader,side:Bs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=w,l.material.uniforms.backgroundIntensity.value=M.backgroundIntensity,l.material.toneMapped=tt.getTransfer(w.colorSpace)!==pt,w.matrixAutoUpdate===!0&&w.updateMatrix(),l.material.uniforms.uvTransform.value.copy(w.matrix),(h!==w||d!==w.version||u!==r.toneMapping)&&(l.material.needsUpdate=!0,h=w,d=w.version,u=r.toneMapping),l.layers.enableAll(),x.unshift(l,l.geometry,l.material,0,0,null))}function m(x,M){x.getRGB(El,Kg(r)),t.buffers.color.setClear(El.r,El.g,El.b,M,s)}function g(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(x,M=1){a.set(x),o=M,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(x){o=x,m(a,o)},render:p,addToRenderList:v,dispose:g}}function yx(r,e){const t=r.getParameter(r.MAX_VERTEX_ATTRIBS),i={},n=u(null);let s=n,a=!1;function o(I,R,k,z,L){let B=!1;const F=d(I,z,k,R);s!==F&&(s=F,c(s.object)),B=f(I,z,k,L),B&&p(I,z,k,L),L!==null&&e.update(L,r.ELEMENT_ARRAY_BUFFER),(B||a)&&(a=!1,w(I,R,k,z),L!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,e.get(L).buffer))}function l(){return r.createVertexArray()}function c(I){return r.bindVertexArray(I)}function h(I){return r.deleteVertexArray(I)}function d(I,R,k,z){const L=z.wireframe===!0;let B=i[R.id];B===void 0&&(B={},i[R.id]=B);const F=I.isInstancedMesh===!0?I.id:0;let V=B[F];V===void 0&&(V={},B[F]=V);let j=V[k.id];j===void 0&&(j={},V[k.id]=j);let $=j[L];return $===void 0&&($=u(l()),j[L]=$),$}function u(I){const R=[],k=[],z=[];for(let L=0;L<t;L++)R[L]=0,k[L]=0,z[L]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:k,attributeDivisors:z,object:I,attributes:{},index:null}}function f(I,R,k,z){const L=s.attributes,B=R.attributes;let F=0;const V=k.getAttributes();for(const j in V)if(V[j].location>=0){const ie=L[j];let ae=B[j];if(ae===void 0&&(j==="instanceMatrix"&&I.instanceMatrix&&(ae=I.instanceMatrix),j==="instanceColor"&&I.instanceColor&&(ae=I.instanceColor)),ie===void 0||ie.attribute!==ae||ae&&ie.data!==ae.data)return!0;F++}return s.attributesNum!==F||s.index!==z}function p(I,R,k,z){const L={},B=R.attributes;let F=0;const V=k.getAttributes();for(const j in V)if(V[j].location>=0){let ie=B[j];ie===void 0&&(j==="instanceMatrix"&&I.instanceMatrix&&(ie=I.instanceMatrix),j==="instanceColor"&&I.instanceColor&&(ie=I.instanceColor));const ae={};ae.attribute=ie,ie&&ie.data&&(ae.data=ie.data),L[j]=ae,F++}s.attributes=L,s.attributesNum=F,s.index=z}function v(){const I=s.newAttributes;for(let R=0,k=I.length;R<k;R++)I[R]=0}function m(I){g(I,0)}function g(I,R){const k=s.newAttributes,z=s.enabledAttributes,L=s.attributeDivisors;k[I]=1,z[I]===0&&(r.enableVertexAttribArray(I),z[I]=1),L[I]!==R&&(r.vertexAttribDivisor(I,R),L[I]=R)}function x(){const I=s.newAttributes,R=s.enabledAttributes;for(let k=0,z=R.length;k<z;k++)R[k]!==I[k]&&(r.disableVertexAttribArray(k),R[k]=0)}function M(I,R,k,z,L,B,F){F===!0?r.vertexAttribIPointer(I,R,k,L,B):r.vertexAttribPointer(I,R,k,z,L,B)}function w(I,R,k,z){v();const L=z.attributes,B=k.getAttributes(),F=R.defaultAttributeValues;for(const V in B){const j=B[V];if(j.location>=0){let $=L[V];if($===void 0&&(V==="instanceMatrix"&&I.instanceMatrix&&($=I.instanceMatrix),V==="instanceColor"&&I.instanceColor&&($=I.instanceColor)),$!==void 0){const ie=$.normalized,ae=$.itemSize,Ve=e.get($);if(Ve===void 0)continue;const je=Ve.buffer,He=Ve.type,K=Ve.bytesPerElement,re=He===r.INT||He===r.UNSIGNED_INT||$.gpuType===Zu;if($.isInterleavedBufferAttribute){const ne=$.data,G=ne.stride,Ee=$.offset;if(ne.isInstancedInterleavedBuffer){for(let Pe=0;Pe<j.locationSize;Pe++)g(j.location+Pe,ne.meshPerAttribute);I.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Pe=0;Pe<j.locationSize;Pe++)m(j.location+Pe);r.bindBuffer(r.ARRAY_BUFFER,je);for(let Pe=0;Pe<j.locationSize;Pe++)M(j.location+Pe,ae/j.locationSize,He,ie,G*K,(Ee+ae/j.locationSize*Pe)*K,re)}else{if($.isInstancedBufferAttribute){for(let ne=0;ne<j.locationSize;ne++)g(j.location+ne,$.meshPerAttribute);I.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=$.meshPerAttribute*$.count)}else for(let ne=0;ne<j.locationSize;ne++)m(j.location+ne);r.bindBuffer(r.ARRAY_BUFFER,je);for(let ne=0;ne<j.locationSize;ne++)M(j.location+ne,ae/j.locationSize,He,ie,ae*K,ae/j.locationSize*ne*K,re)}}else if(F!==void 0){const ie=F[V];if(ie!==void 0)switch(ie.length){case 2:r.vertexAttrib2fv(j.location,ie);break;case 3:r.vertexAttrib3fv(j.location,ie);break;case 4:r.vertexAttrib4fv(j.location,ie);break;default:r.vertexAttrib1fv(j.location,ie)}}}}x()}function S(){T();for(const I in i){const R=i[I];for(const k in R){const z=R[k];for(const L in z){const B=z[L];for(const F in B)h(B[F].object),delete B[F];delete z[L]}}delete i[I]}}function _(I){if(i[I.id]===void 0)return;const R=i[I.id];for(const k in R){const z=R[k];for(const L in z){const B=z[L];for(const F in B)h(B[F].object),delete B[F];delete z[L]}}delete i[I.id]}function D(I){for(const R in i){const k=i[R];for(const z in k){const L=k[z];if(L[I.id]===void 0)continue;const B=L[I.id];for(const F in B)h(B[F].object),delete B[F];delete L[I.id]}}}function y(I){for(const R in i){const k=i[R],z=I.isInstancedMesh===!0?I.id:0,L=k[z];if(L!==void 0){for(const B in L){const F=L[B];for(const V in F)h(F[V].object),delete F[V];delete L[B]}delete k[z],Object.keys(k).length===0&&delete i[R]}}}function T(){A(),a=!0,s!==n&&(s=n,c(s.object))}function A(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:o,reset:T,resetDefaultState:A,dispose:S,releaseStatesOfGeometry:_,releaseStatesOfObject:y,releaseStatesOfProgram:D,initAttributes:v,enableAttribute:m,disableUnusedAttributes:x}}function bx(r,e,t){let i;function n(l){i=l}function s(l,c){r.drawArrays(i,l,c),t.update(c,i,1)}function a(l,c,h){h!==0&&(r.drawArraysInstanced(i,l,c,h),t.update(c,i,h))}function o(l,c,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,l,0,c,0,h);let u=0;for(let f=0;f<h;f++)u+=c[f];t.update(u,i,1)}this.setMode=n,this.render=s,this.renderInstances=a,this.renderMultiDraw=o}function wx(r,e,t,i){let n;function s(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const D=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(D.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function a(D){return!(D!==Ti&&i.convert(D)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(D){const y=D===ui&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(D!==$i&&i.convert(D)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)&&D!==Pi&&!y)}function l(D){if(D==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";D="mediump"}return D==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(_e("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&_e("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),x=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),M=r.getParameter(r.MAX_VARYING_VECTORS),w=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),S=r.getParameter(r.MAX_SAMPLES),_=r.getParameter(r.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:p,maxTextureSize:v,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:x,maxVaryings:M,maxFragmentUniforms:w,maxSamples:S,samples:_}}function Mx(r){const e=this;let t=null,i=0,n=!1,s=!1;const a=new Qs,o=new ze,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){const f=d.length!==0||u||i!==0||n;return n=u,i=d.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,f){const p=d.clippingPlanes,v=d.clipIntersection,m=d.clipShadows,g=r.get(d);if(!n||p===null||p.length===0||s&&!m)s?h(null):c();else{const x=s?0:i,M=x*4;let w=g.clippingState||null;l.value=w,w=h(p,u,M,f);for(let S=0;S!==M;++S)w[S]=t[S];g.clippingState=w,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(d,u,f,p){const v=d!==null?d.length:0;let m=null;if(v!==0){if(m=l.value,p!==!0||m===null){const g=f+v*4,x=u.matrixWorldInverse;o.getNormalMatrix(x),(m===null||m.length<g)&&(m=new Float32Array(g));for(let M=0,w=f;M!==v;++M,w+=4)a.copy(d[M]).applyMatrix4(x,o),a.normal.toArray(m,w),m[w+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,m}}const Os=4,h0=[.125,.215,.35,.446,.526,.582],nr=20,xx=256,Ka=new Hs,d0=new oe;let Ah=null,Ih=0,Dh=0,Ch=!1;const Sx=new P;class u0{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,n=100,s={}){const{size:a=256,position:o=Sx}=s;Ah=this._renderer.getRenderTarget(),Ih=this._renderer.getActiveCubeFace(),Dh=this._renderer.getActiveMipmapLevel(),Ch=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,n,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=m0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=p0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=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 e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Ah,Ih,Dh),this._renderer.xr.enabled=Ch,e.scissorTest=!1,Yr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===gr||e.mapping===Ia?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ah=this._renderer.getRenderTarget(),Ih=this._renderer.getActiveCubeFace(),Dh=this._renderer.getActiveMipmapLevel(),Ch=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:vt,minFilter:vt,generateMipmaps:!1,type:ui,format:Ti,colorSpace:hc,depthBuffer:!1},n=f0(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=f0(e,t,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Ex(s)),this._blurMaterial=Tx(s,e,t),this._ggxMaterial=_x(s,e,t)}return n}_compileMaterial(e){const t=new We(new Tt,e);this._renderer.compile(t,Ka)}_sceneToCubeUV(e,t,i,n,s){const l=new zi(90,1,t,i),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,u=d.autoClear,f=d.toneMapping;d.getClearColor(d0),d.toneMapping=Wn,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(n),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new We(new an,new rn({name:"PMREM.Background",side:Ft,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let g=!1;const x=e.background;x?x.isColor&&(m.color.copy(x),e.background=null,g=!0):(m.color.copy(d0),g=!0);for(let M=0;M<6;M++){const w=M%3;w===0?(l.up.set(0,c[M],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[M],s.y,s.z)):w===1?(l.up.set(0,0,c[M]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[M],s.z)):(l.up.set(0,c[M],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[M]));const S=this._cubeSize;Yr(n,w*S,M>2?S:0,S,S),d.setRenderTarget(n),g&&d.render(v,l),d.render(e,l)}d.toneMapping=f,d.autoClear=u,e.background=x}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===gr||e.mapping===Ia;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=m0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=p0());const s=n?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;Yr(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,Ka)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const n=this._lodMeshes.length;for(let s=1;s<n;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=i}_applyGGXFilter(e,t,i){const n=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const l=a.uniforms,c=i/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),d=Math.sqrt(c*c-h*h),u=0+c*1.25,f=d*u,{_lodMax:p}=this,v=this._sizeLods[i],m=3*v*(i>p-Os?i-p+Os:0),g=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=p-t,Yr(s,m,g,3*v,2*v),n.setRenderTarget(s),n.render(o,Ka),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=p-i,Yr(e,m,g,3*v,2*v),n.setRenderTarget(e),n.render(o,Ka)}_blur(e,t,i,n,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,n,"latitudinal",s),this._halfBlur(a,e,i,i,n,"longitudinal",s)}_halfBlur(e,t,i,n,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Ue("blur direction must be either latitudinal or longitudinal!");const h=3,d=this._lodMeshes[n];d.material=c;const u=c.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*nr-1),v=s/p,m=isFinite(s)?1+Math.floor(h*v):nr;m>nr&&_e(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${nr}`);const g=[];let x=0;for(let D=0;D<nr;++D){const y=D/v,T=Math.exp(-y*y/2);g.push(T),D===0?x+=T:D<m&&(x+=2*T)}for(let D=0;D<g.length;D++)g[D]=g[D]/x;u.envMap.value=e.texture,u.samples.value=m,u.weights.value=g,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:M}=this;u.dTheta.value=p,u.mipInt.value=M-i;const w=this._sizeLods[n],S=3*w*(n>M-Os?n-M+Os:0),_=4*(this._cubeSize-w);Yr(t,S,_,3*w,2*w),l.setRenderTarget(t),l.render(d,Ka)}}function Ex(r){const e=[],t=[],i=[];let n=r;const s=r-Os+1+h0.length;for(let a=0;a<s;a++){const o=Math.pow(2,n);e.push(o);let l=1/o;a>r-Os?l=h0[a-r+Os-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,d=1+c,u=[h,h,d,h,d,d,h,h,d,d,h,d],f=6,p=6,v=3,m=2,g=1,x=new Float32Array(v*p*f),M=new Float32Array(m*p*f),w=new Float32Array(g*p*f);for(let _=0;_<f;_++){const D=_%3*2/3-1,y=_>2?0:-1,T=[D,y,0,D+2/3,y,0,D+2/3,y+1,0,D,y,0,D+2/3,y+1,0,D,y+1,0];x.set(T,v*p*_),M.set(u,m*p*_);const A=[_,_,_,_,_,_];w.set(A,g*p*_)}const S=new Tt;S.setAttribute("position",new ht(x,v)),S.setAttribute("uv",new ht(M,m)),S.setAttribute("faceIndex",new ht(w,g)),i.push(new We(S,null)),n>Os&&n--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function f0(r,e,t){const i=new vi(r,e,t);return i.texture.mapping=Rc,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Yr(r,e,t,i,n){r.viewport.set(e,t,i,n),r.scissor.set(e,t,i,n)}function _x(r,e,t){return new Ot({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:xx,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:kc(),fragmentShader:`
5782
+ }`,Ke={alphahash_fragment:Ob,alphahash_pars_fragment:Fb,alphamap_fragment:Ub,alphamap_pars_fragment:Bb,alphatest_fragment:zb,alphatest_pars_fragment:Hb,aomap_fragment:Gb,aomap_pars_fragment:Vb,batching_pars_vertex:Wb,batching_vertex:Xb,begin_vertex:qb,beginnormal_vertex:Yb,bsdfs:Kb,iridescence_fragment:$b,bumpmap_pars_fragment:Zb,clipping_planes_fragment:Jb,clipping_planes_pars_fragment:jb,clipping_planes_pars_vertex:Qb,clipping_planes_vertex:ew,color_fragment:tw,color_pars_fragment:iw,color_pars_vertex:nw,color_vertex:sw,common:rw,cube_uv_reflection_fragment:aw,defaultnormal_vertex:ow,displacementmap_pars_vertex:lw,displacementmap_vertex:cw,emissivemap_fragment:hw,emissivemap_pars_fragment:dw,colorspace_fragment:uw,colorspace_pars_fragment:fw,envmap_fragment:pw,envmap_common_pars_fragment:mw,envmap_pars_fragment:gw,envmap_pars_vertex:vw,envmap_physical_pars_fragment:Iw,envmap_vertex:yw,fog_vertex:bw,fog_pars_vertex:ww,fog_fragment:Mw,fog_pars_fragment:xw,gradientmap_pars_fragment:Sw,lightmap_pars_fragment:Ew,lights_lambert_fragment:_w,lights_lambert_pars_fragment:Tw,lights_pars_begin:Aw,lights_toon_fragment:Dw,lights_toon_pars_fragment:Cw,lights_phong_fragment:Rw,lights_phong_pars_fragment:Pw,lights_physical_fragment:Lw,lights_physical_pars_fragment:kw,lights_fragment_begin:Nw,lights_fragment_maps:Ow,lights_fragment_end:Fw,lightprobes_pars_fragment:Uw,logdepthbuf_fragment:Bw,logdepthbuf_pars_fragment:zw,logdepthbuf_pars_vertex:Hw,logdepthbuf_vertex:Gw,map_fragment:Vw,map_pars_fragment:Ww,map_particle_fragment:Xw,map_particle_pars_fragment:qw,metalnessmap_fragment:Yw,metalnessmap_pars_fragment:Kw,morphinstance_vertex:$w,morphcolor_vertex:Zw,morphnormal_vertex:Jw,morphtarget_pars_vertex:jw,morphtarget_vertex:Qw,normal_fragment_begin:eM,normal_fragment_maps:tM,normal_pars_fragment:iM,normal_pars_vertex:nM,normal_vertex:sM,normalmap_pars_fragment:rM,clearcoat_normal_fragment_begin:aM,clearcoat_normal_fragment_maps:oM,clearcoat_pars_fragment:lM,iridescence_pars_fragment:cM,opaque_fragment:hM,packing:dM,premultiplied_alpha_fragment:uM,project_vertex:fM,dithering_fragment:pM,dithering_pars_fragment:mM,roughnessmap_fragment:gM,roughnessmap_pars_fragment:vM,shadowmap_pars_fragment:yM,shadowmap_pars_vertex:bM,shadowmap_vertex:wM,shadowmask_pars_fragment:MM,skinbase_vertex:xM,skinning_pars_vertex:SM,skinning_vertex:EM,skinnormal_vertex:_M,specularmap_fragment:TM,specularmap_pars_fragment:AM,tonemapping_fragment:IM,tonemapping_pars_fragment:DM,transmission_fragment:CM,transmission_pars_fragment:RM,uv_pars_fragment:PM,uv_pars_vertex:LM,uv_vertex:kM,worldpos_vertex:NM,background_vert:OM,background_frag:FM,backgroundCube_vert:UM,backgroundCube_frag:BM,cube_vert:zM,cube_frag:HM,depth_vert:GM,depth_frag:VM,distance_vert:WM,distance_frag:XM,equirect_vert:qM,equirect_frag:YM,linedashed_vert:KM,linedashed_frag:$M,meshbasic_vert:ZM,meshbasic_frag:JM,meshlambert_vert:jM,meshlambert_frag:QM,meshmatcap_vert:ex,meshmatcap_frag:tx,meshnormal_vert:ix,meshnormal_frag:nx,meshphong_vert:sx,meshphong_frag:rx,meshphysical_vert:ax,meshphysical_frag:ox,meshtoon_vert:lx,meshtoon_frag:cx,points_vert:hx,points_frag:dx,shadow_vert:ux,shadow_frag:fx,sprite_vert:px,sprite_frag:mx},pe={common:{diffuse:{value:new oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new He}},envmap:{envMap:{value:null},envMapRotation:{value:new He},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new He}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new He}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new He},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new He},normalScale:{value:new Te(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new He},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new He}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new He}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new He}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new oe(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 P},probesMax:{value:new P},probesResolution:{value:new P}},points:{diffuse:{value:new oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0},uvTransform:{value:new He}},sprite:{diffuse:{value:new oe(16777215)},opacity:{value:1},center:{value:new Te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}}},kn={basic:{uniforms:Ii([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:Ke.meshbasic_vert,fragmentShader:Ke.meshbasic_frag},lambert:{uniforms:Ii([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new oe(0)},envMapIntensity:{value:1}}]),vertexShader:Ke.meshlambert_vert,fragmentShader:Ke.meshlambert_frag},phong:{uniforms:Ii([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new oe(0)},specular:{value:new oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphong_vert,fragmentShader:Ke.meshphong_frag},standard:{uniforms:Ii([pe.common,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.roughnessmap,pe.metalnessmap,pe.fog,pe.lights,{emissive:{value:new oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag},toon:{uniforms:Ii([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new oe(0)}}]),vertexShader:Ke.meshtoon_vert,fragmentShader:Ke.meshtoon_frag},matcap:{uniforms:Ii([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:Ke.meshmatcap_vert,fragmentShader:Ke.meshmatcap_frag},points:{uniforms:Ii([pe.points,pe.fog]),vertexShader:Ke.points_vert,fragmentShader:Ke.points_frag},dashed:{uniforms:Ii([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ke.linedashed_vert,fragmentShader:Ke.linedashed_frag},depth:{uniforms:Ii([pe.common,pe.displacementmap]),vertexShader:Ke.depth_vert,fragmentShader:Ke.depth_frag},normal:{uniforms:Ii([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:Ke.meshnormal_vert,fragmentShader:Ke.meshnormal_frag},sprite:{uniforms:Ii([pe.sprite,pe.fog]),vertexShader:Ke.sprite_vert,fragmentShader:Ke.sprite_frag},background:{uniforms:{uvTransform:{value:new He},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ke.background_vert,fragmentShader:Ke.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new He}},vertexShader:Ke.backgroundCube_vert,fragmentShader:Ke.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ke.cube_vert,fragmentShader:Ke.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ke.equirect_vert,fragmentShader:Ke.equirect_frag},distance:{uniforms:Ii([pe.common,pe.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ke.distance_vert,fragmentShader:Ke.distance_frag},shadow:{uniforms:Ii([pe.lights,pe.fog,{color:{value:new oe(0)},opacity:{value:1}}]),vertexShader:Ke.shadow_vert,fragmentShader:Ke.shadow_frag}};kn.physical={uniforms:Ii([kn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new He},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new He},clearcoatNormalScale:{value:new Te(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new He},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new He},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new He},sheen:{value:0},sheenColor:{value:new oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new He},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new He},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new He},transmissionSamplerSize:{value:new Te},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new He},attenuationDistance:{value:0},attenuationColor:{value:new oe(0)},specularColor:{value:new oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new He},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new He},anisotropyVector:{value:new Te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new He}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag};const El={r:0,b:0,g:0},gx=new Ye,t1=new He;t1.set(-1,0,0,0,1,0,0,0,1);function vx(r,e,t,i,n,s){const a=new oe(0);let o=n===!0?0:1,l,c,h=null,d=0,u=null;function f(x){let M=x.isScene===!0?x.background:null;if(M&&M.isTexture){const w=x.backgroundBlurriness>0;M=e.get(M,w)}return M}function p(x){let M=!1;const w=f(x);w===null?m(a,o):w&&w.isColor&&(m(w,1),M=!0);const S=r.xr.getEnvironmentBlendMode();S==="additive"?t.buffers.color.setClear(0,0,0,1,s):S==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(r.autoClear||M)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function v(x,M){const w=f(M);w&&(w.isCubeTexture||w.mapping===Rc)?(c===void 0&&(c=new We(new an(1,1,1),new Ot({name:"BackgroundCubeMaterial",uniforms:Ra(kn.backgroundCube.uniforms),vertexShader:kn.backgroundCube.vertexShader,fragmentShader:kn.backgroundCube.fragmentShader,side:Ft,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(S,_,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=w,c.material.uniforms.backgroundBlurriness.value=M.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=M.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(gx.makeRotationFromEuler(M.backgroundRotation)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(t1),c.material.toneMapped=tt.getTransfer(w.colorSpace)!==pt,(h!==w||d!==w.version||u!==r.toneMapping)&&(c.material.needsUpdate=!0,h=w,d=w.version,u=r.toneMapping),c.layers.enableAll(),x.unshift(c,c.geometry,c.material,0,0,null)):w&&w.isTexture&&(l===void 0&&(l=new We(new wn(2,2),new Ot({name:"BackgroundMaterial",uniforms:Ra(kn.background.uniforms),vertexShader:kn.background.vertexShader,fragmentShader:kn.background.fragmentShader,side:Bs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=w,l.material.uniforms.backgroundIntensity.value=M.backgroundIntensity,l.material.toneMapped=tt.getTransfer(w.colorSpace)!==pt,w.matrixAutoUpdate===!0&&w.updateMatrix(),l.material.uniforms.uvTransform.value.copy(w.matrix),(h!==w||d!==w.version||u!==r.toneMapping)&&(l.material.needsUpdate=!0,h=w,d=w.version,u=r.toneMapping),l.layers.enableAll(),x.unshift(l,l.geometry,l.material,0,0,null))}function m(x,M){x.getRGB(El,Kg(r)),t.buffers.color.setClear(El.r,El.g,El.b,M,s)}function g(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(x,M=1){a.set(x),o=M,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(x){o=x,m(a,o)},render:p,addToRenderList:v,dispose:g}}function yx(r,e){const t=r.getParameter(r.MAX_VERTEX_ATTRIBS),i={},n=u(null);let s=n,a=!1;function o(I,R,k,z,L){let B=!1;const F=d(I,z,k,R);s!==F&&(s=F,c(s.object)),B=f(I,z,k,L),B&&p(I,z,k,L),L!==null&&e.update(L,r.ELEMENT_ARRAY_BUFFER),(B||a)&&(a=!1,w(I,R,k,z),L!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,e.get(L).buffer))}function l(){return r.createVertexArray()}function c(I){return r.bindVertexArray(I)}function h(I){return r.deleteVertexArray(I)}function d(I,R,k,z){const L=z.wireframe===!0;let B=i[R.id];B===void 0&&(B={},i[R.id]=B);const F=I.isInstancedMesh===!0?I.id:0;let V=B[F];V===void 0&&(V={},B[F]=V);let j=V[k.id];j===void 0&&(j={},V[k.id]=j);let $=j[L];return $===void 0&&($=u(l()),j[L]=$),$}function u(I){const R=[],k=[],z=[];for(let L=0;L<t;L++)R[L]=0,k[L]=0,z[L]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:k,attributeDivisors:z,object:I,attributes:{},index:null}}function f(I,R,k,z){const L=s.attributes,B=R.attributes;let F=0;const V=k.getAttributes();for(const j in V)if(V[j].location>=0){const ie=L[j];let ae=B[j];if(ae===void 0&&(j==="instanceMatrix"&&I.instanceMatrix&&(ae=I.instanceMatrix),j==="instanceColor"&&I.instanceColor&&(ae=I.instanceColor)),ie===void 0||ie.attribute!==ae||ae&&ie.data!==ae.data)return!0;F++}return s.attributesNum!==F||s.index!==z}function p(I,R,k,z){const L={},B=R.attributes;let F=0;const V=k.getAttributes();for(const j in V)if(V[j].location>=0){let ie=B[j];ie===void 0&&(j==="instanceMatrix"&&I.instanceMatrix&&(ie=I.instanceMatrix),j==="instanceColor"&&I.instanceColor&&(ie=I.instanceColor));const ae={};ae.attribute=ie,ie&&ie.data&&(ae.data=ie.data),L[j]=ae,F++}s.attributes=L,s.attributesNum=F,s.index=z}function v(){const I=s.newAttributes;for(let R=0,k=I.length;R<k;R++)I[R]=0}function m(I){g(I,0)}function g(I,R){const k=s.newAttributes,z=s.enabledAttributes,L=s.attributeDivisors;k[I]=1,z[I]===0&&(r.enableVertexAttribArray(I),z[I]=1),L[I]!==R&&(r.vertexAttribDivisor(I,R),L[I]=R)}function x(){const I=s.newAttributes,R=s.enabledAttributes;for(let k=0,z=R.length;k<z;k++)R[k]!==I[k]&&(r.disableVertexAttribArray(k),R[k]=0)}function M(I,R,k,z,L,B,F){F===!0?r.vertexAttribIPointer(I,R,k,L,B):r.vertexAttribPointer(I,R,k,z,L,B)}function w(I,R,k,z){v();const L=z.attributes,B=k.getAttributes(),F=R.defaultAttributeValues;for(const V in B){const j=B[V];if(j.location>=0){let $=L[V];if($===void 0&&(V==="instanceMatrix"&&I.instanceMatrix&&($=I.instanceMatrix),V==="instanceColor"&&I.instanceColor&&($=I.instanceColor)),$!==void 0){const ie=$.normalized,ae=$.itemSize,Ve=e.get($);if(Ve===void 0)continue;const je=Ve.buffer,Ge=Ve.type,K=Ve.bytesPerElement,re=Ge===r.INT||Ge===r.UNSIGNED_INT||$.gpuType===Zu;if($.isInterleavedBufferAttribute){const ne=$.data,G=ne.stride,Ee=$.offset;if(ne.isInstancedInterleavedBuffer){for(let Pe=0;Pe<j.locationSize;Pe++)g(j.location+Pe,ne.meshPerAttribute);I.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Pe=0;Pe<j.locationSize;Pe++)m(j.location+Pe);r.bindBuffer(r.ARRAY_BUFFER,je);for(let Pe=0;Pe<j.locationSize;Pe++)M(j.location+Pe,ae/j.locationSize,Ge,ie,G*K,(Ee+ae/j.locationSize*Pe)*K,re)}else{if($.isInstancedBufferAttribute){for(let ne=0;ne<j.locationSize;ne++)g(j.location+ne,$.meshPerAttribute);I.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=$.meshPerAttribute*$.count)}else for(let ne=0;ne<j.locationSize;ne++)m(j.location+ne);r.bindBuffer(r.ARRAY_BUFFER,je);for(let ne=0;ne<j.locationSize;ne++)M(j.location+ne,ae/j.locationSize,Ge,ie,ae*K,ae/j.locationSize*ne*K,re)}}else if(F!==void 0){const ie=F[V];if(ie!==void 0)switch(ie.length){case 2:r.vertexAttrib2fv(j.location,ie);break;case 3:r.vertexAttrib3fv(j.location,ie);break;case 4:r.vertexAttrib4fv(j.location,ie);break;default:r.vertexAttrib1fv(j.location,ie)}}}}x()}function S(){T();for(const I in i){const R=i[I];for(const k in R){const z=R[k];for(const L in z){const B=z[L];for(const F in B)h(B[F].object),delete B[F];delete z[L]}}delete i[I]}}function _(I){if(i[I.id]===void 0)return;const R=i[I.id];for(const k in R){const z=R[k];for(const L in z){const B=z[L];for(const F in B)h(B[F].object),delete B[F];delete z[L]}}delete i[I.id]}function D(I){for(const R in i){const k=i[R];for(const z in k){const L=k[z];if(L[I.id]===void 0)continue;const B=L[I.id];for(const F in B)h(B[F].object),delete B[F];delete L[I.id]}}}function y(I){for(const R in i){const k=i[R],z=I.isInstancedMesh===!0?I.id:0,L=k[z];if(L!==void 0){for(const B in L){const F=L[B];for(const V in F)h(F[V].object),delete F[V];delete L[B]}delete k[z],Object.keys(k).length===0&&delete i[R]}}}function T(){A(),a=!0,s!==n&&(s=n,c(s.object))}function A(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:o,reset:T,resetDefaultState:A,dispose:S,releaseStatesOfGeometry:_,releaseStatesOfObject:y,releaseStatesOfProgram:D,initAttributes:v,enableAttribute:m,disableUnusedAttributes:x}}function bx(r,e,t){let i;function n(l){i=l}function s(l,c){r.drawArrays(i,l,c),t.update(c,i,1)}function a(l,c,h){h!==0&&(r.drawArraysInstanced(i,l,c,h),t.update(c,i,h))}function o(l,c,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,l,0,c,0,h);let u=0;for(let f=0;f<h;f++)u+=c[f];t.update(u,i,1)}this.setMode=n,this.render=s,this.renderInstances=a,this.renderMultiDraw=o}function wx(r,e,t,i){let n;function s(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const D=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(D.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function a(D){return!(D!==Ti&&i.convert(D)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(D){const y=D===ui&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(D!==$i&&i.convert(D)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)&&D!==Pi&&!y)}function l(D){if(D==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";D="mediump"}return D==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(_e("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&_e("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),x=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),M=r.getParameter(r.MAX_VARYING_VECTORS),w=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),S=r.getParameter(r.MAX_SAMPLES),_=r.getParameter(r.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:p,maxTextureSize:v,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:x,maxVaryings:M,maxFragmentUniforms:w,maxSamples:S,samples:_}}function Mx(r){const e=this;let t=null,i=0,n=!1,s=!1;const a=new Qs,o=new He,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){const f=d.length!==0||u||i!==0||n;return n=u,i=d.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,f){const p=d.clippingPlanes,v=d.clipIntersection,m=d.clipShadows,g=r.get(d);if(!n||p===null||p.length===0||s&&!m)s?h(null):c();else{const x=s?0:i,M=x*4;let w=g.clippingState||null;l.value=w,w=h(p,u,M,f);for(let S=0;S!==M;++S)w[S]=t[S];g.clippingState=w,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(d,u,f,p){const v=d!==null?d.length:0;let m=null;if(v!==0){if(m=l.value,p!==!0||m===null){const g=f+v*4,x=u.matrixWorldInverse;o.getNormalMatrix(x),(m===null||m.length<g)&&(m=new Float32Array(g));for(let M=0,w=f;M!==v;++M,w+=4)a.copy(d[M]).applyMatrix4(x,o),a.normal.toArray(m,w),m[w+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,m}}const Os=4,h0=[.125,.215,.35,.446,.526,.582],nr=20,xx=256,Ka=new Hs,d0=new oe;let Ah=null,Ih=0,Dh=0,Ch=!1;const Sx=new P;class u0{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,n=100,s={}){const{size:a=256,position:o=Sx}=s;Ah=this._renderer.getRenderTarget(),Ih=this._renderer.getActiveCubeFace(),Dh=this._renderer.getActiveMipmapLevel(),Ch=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,n,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=m0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=p0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=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 e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Ah,Ih,Dh),this._renderer.xr.enabled=Ch,e.scissorTest=!1,Yr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===gr||e.mapping===Ia?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ah=this._renderer.getRenderTarget(),Ih=this._renderer.getActiveCubeFace(),Dh=this._renderer.getActiveMipmapLevel(),Ch=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:vt,minFilter:vt,generateMipmaps:!1,type:ui,format:Ti,colorSpace:hc,depthBuffer:!1},n=f0(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=f0(e,t,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Ex(s)),this._blurMaterial=Tx(s,e,t),this._ggxMaterial=_x(s,e,t)}return n}_compileMaterial(e){const t=new We(new Tt,e);this._renderer.compile(t,Ka)}_sceneToCubeUV(e,t,i,n,s){const l=new zi(90,1,t,i),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,u=d.autoClear,f=d.toneMapping;d.getClearColor(d0),d.toneMapping=Wn,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(n),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new We(new an,new rn({name:"PMREM.Background",side:Ft,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let g=!1;const x=e.background;x?x.isColor&&(m.color.copy(x),e.background=null,g=!0):(m.color.copy(d0),g=!0);for(let M=0;M<6;M++){const w=M%3;w===0?(l.up.set(0,c[M],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[M],s.y,s.z)):w===1?(l.up.set(0,0,c[M]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[M],s.z)):(l.up.set(0,c[M],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[M]));const S=this._cubeSize;Yr(n,w*S,M>2?S:0,S,S),d.setRenderTarget(n),g&&d.render(v,l),d.render(e,l)}d.toneMapping=f,d.autoClear=u,e.background=x}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===gr||e.mapping===Ia;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=m0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=p0());const s=n?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;Yr(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,Ka)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const n=this._lodMeshes.length;for(let s=1;s<n;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=i}_applyGGXFilter(e,t,i){const n=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const l=a.uniforms,c=i/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),d=Math.sqrt(c*c-h*h),u=0+c*1.25,f=d*u,{_lodMax:p}=this,v=this._sizeLods[i],m=3*v*(i>p-Os?i-p+Os:0),g=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=p-t,Yr(s,m,g,3*v,2*v),n.setRenderTarget(s),n.render(o,Ka),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=p-i,Yr(e,m,g,3*v,2*v),n.setRenderTarget(e),n.render(o,Ka)}_blur(e,t,i,n,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,n,"latitudinal",s),this._halfBlur(a,e,i,i,n,"longitudinal",s)}_halfBlur(e,t,i,n,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Ue("blur direction must be either latitudinal or longitudinal!");const h=3,d=this._lodMeshes[n];d.material=c;const u=c.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*nr-1),v=s/p,m=isFinite(s)?1+Math.floor(h*v):nr;m>nr&&_e(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${nr}`);const g=[];let x=0;for(let D=0;D<nr;++D){const y=D/v,T=Math.exp(-y*y/2);g.push(T),D===0?x+=T:D<m&&(x+=2*T)}for(let D=0;D<g.length;D++)g[D]=g[D]/x;u.envMap.value=e.texture,u.samples.value=m,u.weights.value=g,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:M}=this;u.dTheta.value=p,u.mipInt.value=M-i;const w=this._sizeLods[n],S=3*w*(n>M-Os?n-M+Os:0),_=4*(this._cubeSize-w);Yr(t,S,_,3*w,2*w),l.setRenderTarget(t),l.render(d,Ka)}}function Ex(r){const e=[],t=[],i=[];let n=r;const s=r-Os+1+h0.length;for(let a=0;a<s;a++){const o=Math.pow(2,n);e.push(o);let l=1/o;a>r-Os?l=h0[a-r+Os-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,d=1+c,u=[h,h,d,h,d,d,h,h,d,d,h,d],f=6,p=6,v=3,m=2,g=1,x=new Float32Array(v*p*f),M=new Float32Array(m*p*f),w=new Float32Array(g*p*f);for(let _=0;_<f;_++){const D=_%3*2/3-1,y=_>2?0:-1,T=[D,y,0,D+2/3,y,0,D+2/3,y+1,0,D,y,0,D+2/3,y+1,0,D,y+1,0];x.set(T,v*p*_),M.set(u,m*p*_);const A=[_,_,_,_,_,_];w.set(A,g*p*_)}const S=new Tt;S.setAttribute("position",new ht(x,v)),S.setAttribute("uv",new ht(M,m)),S.setAttribute("faceIndex",new ht(w,g)),i.push(new We(S,null)),n>Os&&n--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function f0(r,e,t){const i=new vi(r,e,t);return i.texture.mapping=Rc,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Yr(r,e,t,i,n){r.viewport.set(e,t,i,n),r.scissor.set(e,t,i,n)}function _x(r,e,t){return new Ot({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:xx,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:kc(),fragmentShader:`
5783
5783
 
5784
5784
  precision highp float;
5785
5785
  precision highp int;
@@ -6116,7 +6116,7 @@ void main() {
6116
6116
  #endif
6117
6117
  }`,depthTest:!1,depthWrite:!1}),h=new We(l,c),d=new Hs(-1,1,1,-1,0,1);let u=null,f=null,p=!1,v,m=null,g=[],x=!1;this.setSize=function(M,w){a.setSize(M,w),o.setSize(M,w);for(let S=0;S<g.length;S++){const _=g[S];_.setSize&&_.setSize(M,w)}},this.setEffects=function(M){g=M,x=g.length>0&&g[0].isRenderPass===!0;const w=a.width,S=a.height;for(let _=0;_<g.length;_++){const D=g[_];D.setSize&&D.setSize(w,S)}},this.begin=function(M,w){if(p||M.toneMapping===Wn&&g.length===0)return!1;if(m=w,w!==null){const S=w.width,_=w.height;(a.width!==S||a.height!==_)&&this.setSize(S,_)}return x===!1&&M.setRenderTarget(a),v=M.toneMapping,M.toneMapping=Wn,!0},this.hasRenderPass=function(){return x},this.end=function(M,w){M.toneMapping=v,p=!0;let S=a,_=o;for(let D=0;D<g.length;D++){const y=g[D];if(y.enabled!==!1&&(y.render(M,_,S,w),y.needsSwap!==!1)){const T=S;S=_,_=T}}if(u!==M.outputColorSpace||f!==M.toneMapping){u=M.outputColorSpace,f=M.toneMapping,c.defines={},tt.getTransfer(u)===pt&&(c.defines.SRGB_TRANSFER="");const D=kx[f];D&&(c.defines[D]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=S.texture,M.setRenderTarget(m),M.render(h,d),m=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),l.dispose(),c.dispose()}}const n1=new di,du=new yr(1,1),s1=new Bg,r1=new zg,a1=new qg,g0=[],v0=[],y0=new Float32Array(16),b0=new Float32Array(9),w0=new Float32Array(4);function Oa(r,e,t){const i=r[0];if(i<=0||i>0)return r;const n=e*t;let s=g0[n];if(s===void 0&&(s=new Float32Array(n),g0[n]=s),e!==0){i.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,r[a].toArray(s,o)}return s}function ei(r,e){if(r.length!==e.length)return!1;for(let t=0,i=r.length;t<i;t++)if(r[t]!==e[t])return!1;return!0}function ti(r,e){for(let t=0,i=e.length;t<i;t++)r[t]=e[t]}function Nc(r,e){let t=v0[e];t===void 0&&(t=new Int32Array(e),v0[e]=t);for(let i=0;i!==e;++i)t[i]=r.allocateTextureUnit();return t}function Ox(r,e){const t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function Fx(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ei(t,e))return;r.uniform2fv(this.addr,e),ti(t,e)}}function Ux(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(ei(t,e))return;r.uniform3fv(this.addr,e),ti(t,e)}}function Bx(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ei(t,e))return;r.uniform4fv(this.addr,e),ti(t,e)}}function zx(r,e){const t=this.cache,i=e.elements;if(i===void 0){if(ei(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),ti(t,e)}else{if(ei(t,i))return;w0.set(i),r.uniformMatrix2fv(this.addr,!1,w0),ti(t,i)}}function Hx(r,e){const t=this.cache,i=e.elements;if(i===void 0){if(ei(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),ti(t,e)}else{if(ei(t,i))return;b0.set(i),r.uniformMatrix3fv(this.addr,!1,b0),ti(t,i)}}function Gx(r,e){const t=this.cache,i=e.elements;if(i===void 0){if(ei(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),ti(t,e)}else{if(ei(t,i))return;y0.set(i),r.uniformMatrix4fv(this.addr,!1,y0),ti(t,i)}}function Vx(r,e){const t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function Wx(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ei(t,e))return;r.uniform2iv(this.addr,e),ti(t,e)}}function Xx(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ei(t,e))return;r.uniform3iv(this.addr,e),ti(t,e)}}function qx(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ei(t,e))return;r.uniform4iv(this.addr,e),ti(t,e)}}function Yx(r,e){const t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function Kx(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ei(t,e))return;r.uniform2uiv(this.addr,e),ti(t,e)}}function $x(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ei(t,e))return;r.uniform3uiv(this.addr,e),ti(t,e)}}function Zx(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ei(t,e))return;r.uniform4uiv(this.addr,e),ti(t,e)}}function Jx(r,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n);let s;this.type===r.SAMPLER_2D_SHADOW?(du.compareFunction=t.isReversedDepthBuffer()?sf:nf,s=du):s=n1,t.setTexture2D(e||s,n)}function jx(r,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n),t.setTexture3D(e||r1,n)}function Qx(r,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n),t.setTextureCube(e||a1,n)}function eS(r,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n),t.setTexture2DArray(e||s1,n)}function tS(r){switch(r){case 5126:return Ox;case 35664:return Fx;case 35665:return Ux;case 35666:return Bx;case 35674:return zx;case 35675:return Hx;case 35676:return Gx;case 5124:case 35670:return Vx;case 35667:case 35671:return Wx;case 35668:case 35672:return Xx;case 35669:case 35673:return qx;case 5125:return Yx;case 36294:return Kx;case 36295:return $x;case 36296:return Zx;case 35678:case 36198:case 36298:case 36306:case 35682:return Jx;case 35679:case 36299:case 36307:return jx;case 35680:case 36300:case 36308:case 36293:return Qx;case 36289:case 36303:case 36311:case 36292:return eS}}function iS(r,e){r.uniform1fv(this.addr,e)}function nS(r,e){const t=Oa(e,this.size,2);r.uniform2fv(this.addr,t)}function sS(r,e){const t=Oa(e,this.size,3);r.uniform3fv(this.addr,t)}function rS(r,e){const t=Oa(e,this.size,4);r.uniform4fv(this.addr,t)}function aS(r,e){const t=Oa(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function oS(r,e){const t=Oa(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function lS(r,e){const t=Oa(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function cS(r,e){r.uniform1iv(this.addr,e)}function hS(r,e){r.uniform2iv(this.addr,e)}function dS(r,e){r.uniform3iv(this.addr,e)}function uS(r,e){r.uniform4iv(this.addr,e)}function fS(r,e){r.uniform1uiv(this.addr,e)}function pS(r,e){r.uniform2uiv(this.addr,e)}function mS(r,e){r.uniform3uiv(this.addr,e)}function gS(r,e){r.uniform4uiv(this.addr,e)}function vS(r,e,t){const i=this.cache,n=e.length,s=Nc(t,n);ei(i,s)||(r.uniform1iv(this.addr,s),ti(i,s));let a;this.type===r.SAMPLER_2D_SHADOW?a=du:a=n1;for(let o=0;o!==n;++o)t.setTexture2D(e[o]||a,s[o])}function yS(r,e,t){const i=this.cache,n=e.length,s=Nc(t,n);ei(i,s)||(r.uniform1iv(this.addr,s),ti(i,s));for(let a=0;a!==n;++a)t.setTexture3D(e[a]||r1,s[a])}function bS(r,e,t){const i=this.cache,n=e.length,s=Nc(t,n);ei(i,s)||(r.uniform1iv(this.addr,s),ti(i,s));for(let a=0;a!==n;++a)t.setTextureCube(e[a]||a1,s[a])}function wS(r,e,t){const i=this.cache,n=e.length,s=Nc(t,n);ei(i,s)||(r.uniform1iv(this.addr,s),ti(i,s));for(let a=0;a!==n;++a)t.setTexture2DArray(e[a]||s1,s[a])}function MS(r){switch(r){case 5126:return iS;case 35664:return nS;case 35665:return sS;case 35666:return rS;case 35674:return aS;case 35675:return oS;case 35676:return lS;case 5124:case 35670:return cS;case 35667:case 35671:return hS;case 35668:case 35672:return dS;case 35669:case 35673:return uS;case 5125:return fS;case 36294:return pS;case 36295:return mS;case 36296:return gS;case 35678:case 36198:case 36298:case 36306:case 35682:return vS;case 35679:case 36299:case 36307:return yS;case 35680:case 36300:case 36308:case 36293:return bS;case 36289:case 36303:case 36311:case 36292:return wS}}class xS{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=tS(t.type)}}class SS{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=MS(t.type)}}class ES{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const n=this.seq;for(let s=0,a=n.length;s!==a;++s){const o=n[s];o.setValue(e,t[o.id],i)}}}const Rh=/(\w+)(\])?(\[|\.)?/g;function M0(r,e){r.seq.push(e),r.map[e.id]=e}function _S(r,e,t){const i=r.name,n=i.length;for(Rh.lastIndex=0;;){const s=Rh.exec(i),a=Rh.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===n){M0(t,c===void 0?new xS(o,r,e):new SS(o,r,e));break}else{let d=t.map[o];d===void 0&&(d=new ES(o),M0(t,d)),t=d}}}class Zl{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<i;++a){const o=e.getActiveUniform(t,a),l=e.getUniformLocation(t,o.name);_S(o,l,this)}const n=[],s=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?n.push(a):s.push(a);n.length>0&&(this.seq=n.concat(s))}setValue(e,t,i,n){const s=this.map[t];s!==void 0&&s.setValue(e,i,n)}setOptional(e,t,i){const n=t[i];n!==void 0&&this.setValue(e,i,n)}static upload(e,t,i,n){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,n)}}static seqWithValue(e,t){const i=[];for(let n=0,s=e.length;n!==s;++n){const a=e[n];a.id in t&&i.push(a)}return i}}function x0(r,e,t){const i=r.createShader(e);return r.shaderSource(i,t),r.compileShader(i),i}const TS=37297;let AS=0;function IS(r,e){const t=r.split(`
6118
6118
  `),i=[],n=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=n;a<s;a++){const o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
6119
- `)}const S0=new ze;function DS(r){tt._getMatrix(S0,tt.workingColorSpace,r);const e=`mat3( ${S0.elements.map(t=>t.toFixed(4))} )`;switch(tt.getTransfer(r)){case dc:return[e,"LinearTransferOETF"];case pt:return[e,"sRGBTransferOETF"];default:return _e("WebGLProgram: Unsupported color space: ",r),[e,"LinearTransferOETF"]}}function E0(r,e,t){const i=r.getShaderParameter(e,r.COMPILE_STATUS),s=(r.getShaderInfoLog(e)||"").trim();if(i&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
6119
+ `)}const S0=new He;function DS(r){tt._getMatrix(S0,tt.workingColorSpace,r);const e=`mat3( ${S0.elements.map(t=>t.toFixed(4))} )`;switch(tt.getTransfer(r)){case dc:return[e,"LinearTransferOETF"];case pt:return[e,"sRGBTransferOETF"];default:return _e("WebGLProgram: Unsupported color space: ",r),[e,"LinearTransferOETF"]}}function E0(r,e,t){const i=r.getShaderParameter(e,r.COMPILE_STATUS),s=(r.getShaderInfoLog(e)||"").trim();if(i&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
6120
6120
 
6121
6121
  `+s+`
6122
6122
 
@@ -6165,7 +6165,7 @@ Material Type: `+I.type+`
6165
6165
 
6166
6166
  Program Info Log: `+L+`
6167
6167
  `+$+`
6168
- `+ie)}else L!==""?_e("WebGLProgram: Program Info Log:",L):(B===""||F==="")&&(j=!1);j&&(I.diagnostics={runnable:V,programLog:L,vertexShader:{log:B,prefix:m},fragmentShader:{log:F,prefix:g}})}n.deleteShader(S),n.deleteShader(_),y=new Zl(n,v),T=OS(n,v)}let y;this.getUniforms=function(){return y===void 0&&D(this),y};let T;this.getAttributes=function(){return T===void 0&&D(this),T};let A=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return A===!1&&(A=n.getProgramParameter(v,TS)),A},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=AS++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=_,this}let jS=0;class QS{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const n=this._getShaderCacheForMaterial(e);return n.has(t)===!1&&(n.add(t),t.usedTimes++),n.has(i)===!1&&(n.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new e3(e),t.set(e,i)),i}}class e3{constructor(e){this.id=jS++,this.code=e,this.usedTimes=0}}function t3(r){return r===vr||r===ac||r===oc}function i3(r,e,t,i,n,s){const a=new of,o=new QS,l=new Set,c=[],h=new Map,d=i.logarithmicDepthBuffer;let u=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(y){return l.add(y),y===0?"uv":`uv${y}`}function v(y,T,A,I,R,k){const z=I.fog,L=R.geometry,B=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?I.environment:null,F=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap,V=e.get(y.envMap||B,F),j=V&&V.mapping===Rc?V.image.height:null,$=f[y.type];y.precision!==null&&(u=i.getMaxPrecision(y.precision),u!==y.precision&&_e("WebGLProgram.getParameters:",y.precision,"not supported, using",u,"instead."));const ie=L.morphAttributes.position||L.morphAttributes.normal||L.morphAttributes.color,ae=ie!==void 0?ie.length:0;let Ve=0;L.morphAttributes.position!==void 0&&(Ve=1),L.morphAttributes.normal!==void 0&&(Ve=2),L.morphAttributes.color!==void 0&&(Ve=3);let je,He,K,re;if($){const Me=kn[$];je=Me.vertexShader,He=Me.fragmentShader}else{je=y.vertexShader,He=y.fragmentShader;const Me=o.getVertexShaderStage(y),Gt=o.getFragmentShaderStage(y);o.update(y,Me,Gt),K=Me.id,re=Gt.id}const ne=r.getRenderTarget(),G=r.state.buffers.depth.getReversed(),Ee=R.isInstancedMesh===!0,Pe=R.isBatchedMesh===!0,Ie=!!y.map,be=!!y.matcap,ke=!!V,Ne=!!y.aoMap,Oe=!!y.lightMap,dt=!!y.bumpMap&&y.wireframe===!1,ut=!!y.normalMap,zt=!!y.displacementMap,It=!!y.emissiveMap,Ht=!!y.metalnessMap,Zt=!!y.roughnessMap,O=y.anisotropy>0,Li=y.clearcoat>0,ft=y.dispersion>0,C=y.iridescence>0,b=y.sheen>0,H=y.transmission>0,q=O&&!!y.anisotropyMap,Z=Li&&!!y.clearcoatMap,se=Li&&!!y.clearcoatNormalMap,ce=Li&&!!y.clearcoatRoughnessMap,J=C&&!!y.iridescenceMap,ee=C&&!!y.iridescenceThicknessMap,he=b&&!!y.sheenColorMap,De=b&&!!y.sheenRoughnessMap,fe=!!y.specularMap,de=!!y.specularColorMap,Le=!!y.specularIntensityMap,Fe=H&&!!y.transmissionMap,Xe=H&&!!y.thicknessMap,N=!!y.gradientMap,le=!!y.alphaMap,Q=y.alphaTest>0,ue=!!y.alphaHash,ve=!!y.extensions;let te=Wn;y.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(te=r.toneMapping);const Ae={shaderID:$,shaderType:y.type,shaderName:y.name,vertexShader:je,fragmentShader:He,defines:y.defines,customVertexShaderID:K,customFragmentShaderID:re,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:u,batching:Pe,batchingColor:Pe&&R._colorsTexture!==null,instancing:Ee,instancingColor:Ee&&R.instanceColor!==null,instancingMorph:Ee&&R.morphTexture!==null,outputColorSpace:ne===null?r.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:tt.workingColorSpace,alphaToCoverage:!!y.alphaToCoverage,map:Ie,matcap:be,envMap:ke,envMapMode:ke&&V.mapping,envMapCubeUVHeight:j,aoMap:Ne,lightMap:Oe,bumpMap:dt,normalMap:ut,displacementMap:zt,emissiveMap:It,normalMapObjectSpace:ut&&y.normalMapType===K2,normalMapTangentSpace:ut&&y.normalMapType===cc,packedNormalMap:ut&&y.normalMapType===cc&&t3(y.normalMap.format),metalnessMap:Ht,roughnessMap:Zt,anisotropy:O,anisotropyMap:q,clearcoat:Li,clearcoatMap:Z,clearcoatNormalMap:se,clearcoatRoughnessMap:ce,dispersion:ft,iridescence:C,iridescenceMap:J,iridescenceThicknessMap:ee,sheen:b,sheenColorMap:he,sheenRoughnessMap:De,specularMap:fe,specularColorMap:de,specularIntensityMap:Le,transmission:H,transmissionMap:Fe,thicknessMap:Xe,gradientMap:N,opaque:y.transparent===!1&&y.blending===ma&&y.alphaToCoverage===!1,alphaMap:le,alphaTest:Q,alphaHash:ue,combine:y.combine,mapUv:Ie&&p(y.map.channel),aoMapUv:Ne&&p(y.aoMap.channel),lightMapUv:Oe&&p(y.lightMap.channel),bumpMapUv:dt&&p(y.bumpMap.channel),normalMapUv:ut&&p(y.normalMap.channel),displacementMapUv:zt&&p(y.displacementMap.channel),emissiveMapUv:It&&p(y.emissiveMap.channel),metalnessMapUv:Ht&&p(y.metalnessMap.channel),roughnessMapUv:Zt&&p(y.roughnessMap.channel),anisotropyMapUv:q&&p(y.anisotropyMap.channel),clearcoatMapUv:Z&&p(y.clearcoatMap.channel),clearcoatNormalMapUv:se&&p(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ce&&p(y.clearcoatRoughnessMap.channel),iridescenceMapUv:J&&p(y.iridescenceMap.channel),iridescenceThicknessMapUv:ee&&p(y.iridescenceThicknessMap.channel),sheenColorMapUv:he&&p(y.sheenColorMap.channel),sheenRoughnessMapUv:De&&p(y.sheenRoughnessMap.channel),specularMapUv:fe&&p(y.specularMap.channel),specularColorMapUv:de&&p(y.specularColorMap.channel),specularIntensityMapUv:Le&&p(y.specularIntensityMap.channel),transmissionMapUv:Fe&&p(y.transmissionMap.channel),thicknessMapUv:Xe&&p(y.thicknessMap.channel),alphaMapUv:le&&p(y.alphaMap.channel),vertexTangents:!!L.attributes.tangent&&(ut||O),vertexNormals:!!L.attributes.normal,vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!L.attributes.color&&L.attributes.color.itemSize===4,pointsUvs:R.isPoints===!0&&!!L.attributes.uv&&(Ie||le),fog:!!z,useFog:y.fog===!0,fogExp2:!!z&&z.isFogExp2,flatShading:y.wireframe===!1&&(y.flatShading===!0||L.attributes.normal===void 0&&ut===!1&&(y.isMeshLambertMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isMeshPhysicalMaterial)),sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:G,skinning:R.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:ae,morphTextureStride:Ve,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:k.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:y.dithering,shadowMapEnabled:r.shadowMap.enabled&&A.length>0,shadowMapType:r.shadowMap.type,toneMapping:te,decodeVideoTexture:Ie&&y.map.isVideoTexture===!0&&tt.getTransfer(y.map.colorSpace)===pt,decodeVideoTextureEmissive:It&&y.emissiveMap.isVideoTexture===!0&&tt.getTransfer(y.emissiveMap.colorSpace)===pt,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===pn,flipSided:y.side===Ft,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:ve&&y.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ve&&y.extensions.multiDraw===!0||Pe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return Ae.vertexUv1s=l.has(1),Ae.vertexUv2s=l.has(2),Ae.vertexUv3s=l.has(3),l.clear(),Ae}function m(y){const T=[];if(y.shaderID?T.push(y.shaderID):(T.push(y.customVertexShaderID),T.push(y.customFragmentShaderID)),y.defines!==void 0)for(const A in y.defines)T.push(A),T.push(y.defines[A]);return y.isRawShaderMaterial===!1&&(g(T,y),x(T,y),T.push(r.outputColorSpace)),T.push(y.customProgramCacheKey),T.join()}function g(y,T){y.push(T.precision),y.push(T.outputColorSpace),y.push(T.envMapMode),y.push(T.envMapCubeUVHeight),y.push(T.mapUv),y.push(T.alphaMapUv),y.push(T.lightMapUv),y.push(T.aoMapUv),y.push(T.bumpMapUv),y.push(T.normalMapUv),y.push(T.displacementMapUv),y.push(T.emissiveMapUv),y.push(T.metalnessMapUv),y.push(T.roughnessMapUv),y.push(T.anisotropyMapUv),y.push(T.clearcoatMapUv),y.push(T.clearcoatNormalMapUv),y.push(T.clearcoatRoughnessMapUv),y.push(T.iridescenceMapUv),y.push(T.iridescenceThicknessMapUv),y.push(T.sheenColorMapUv),y.push(T.sheenRoughnessMapUv),y.push(T.specularMapUv),y.push(T.specularColorMapUv),y.push(T.specularIntensityMapUv),y.push(T.transmissionMapUv),y.push(T.thicknessMapUv),y.push(T.combine),y.push(T.fogExp2),y.push(T.sizeAttenuation),y.push(T.morphTargetsCount),y.push(T.morphAttributeCount),y.push(T.numDirLights),y.push(T.numPointLights),y.push(T.numSpotLights),y.push(T.numSpotLightMaps),y.push(T.numHemiLights),y.push(T.numRectAreaLights),y.push(T.numDirLightShadows),y.push(T.numPointLightShadows),y.push(T.numSpotLightShadows),y.push(T.numSpotLightShadowsWithMaps),y.push(T.numLightProbes),y.push(T.shadowMapType),y.push(T.toneMapping),y.push(T.numClippingPlanes),y.push(T.numClipIntersection),y.push(T.depthPacking)}function x(y,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),y.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),y.push(a.mask)}function M(y){const T=f[y.type];let A;if(T){const I=kn[T];A=Qy.clone(I.uniforms)}else A=y.uniforms;return A}function w(y,T){let A=h.get(T);return A!==void 0?++A.usedTimes:(A=new JS(r,T,y,n),c.push(A),h.set(T,A)),A}function S(y){if(--y.usedTimes===0){const T=c.indexOf(y);c[T]=c[c.length-1],c.pop(),h.delete(y.cacheKey),y.destroy()}}function _(y){o.remove(y)}function D(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:M,acquireProgram:w,releaseProgram:S,releaseShaderCache:_,programs:c,dispose:D}}function n3(){let r=new WeakMap;function e(a){return r.has(a)}function t(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,l){r.get(a)[o]=l}function s(){r=new WeakMap}return{has:e,get:t,remove:i,update:n,dispose:s}}function s3(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.materialVariant!==e.materialVariant?r.materialVariant-e.materialVariant:r.z!==e.z?r.z-e.z:r.id-e.id}function D0(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function C0(){const r=[];let e=0;const t=[],i=[],n=[];function s(){e=0,t.length=0,i.length=0,n.length=0}function a(u){let f=0;return u.isInstancedMesh&&(f+=2),u.isSkinnedMesh&&(f+=1),f}function o(u,f,p,v,m,g){let x=r[e];return x===void 0?(x={id:u.id,object:u,geometry:f,material:p,materialVariant:a(u),groupOrder:v,renderOrder:u.renderOrder,z:m,group:g},r[e]=x):(x.id=u.id,x.object=u,x.geometry=f,x.material=p,x.materialVariant=a(u),x.groupOrder=v,x.renderOrder=u.renderOrder,x.z=m,x.group=g),e++,x}function l(u,f,p,v,m,g){const x=o(u,f,p,v,m,g);p.transmission>0?i.push(x):p.transparent===!0?n.push(x):t.push(x)}function c(u,f,p,v,m,g){const x=o(u,f,p,v,m,g);p.transmission>0?i.unshift(x):p.transparent===!0?n.unshift(x):t.unshift(x)}function h(u,f,p){t.length>1&&t.sort(u||s3),i.length>1&&i.sort(f||D0),n.length>1&&n.sort(f||D0),p&&(t.reverse(),i.reverse(),n.reverse())}function d(){for(let u=e,f=r.length;u<f;u++){const p=r[u];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:i,transparent:n,init:s,push:l,unshift:c,finish:d,sort:h}}function r3(){let r=new WeakMap;function e(i,n){const s=r.get(i);let a;return s===void 0?(a=new C0,r.set(i,[a])):n>=s.length?(a=new C0,s.push(a)):a=s[n],a}function t(){r=new WeakMap}return{get:e,dispose:t}}function a3(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new P,color:new oe};break;case"SpotLight":t={position:new P,direction:new P,color:new oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new P,color:new oe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new P,skyColor:new oe,groundColor:new oe};break;case"RectAreaLight":t={color:new oe,position:new P,halfWidth:new P,halfHeight:new P};break}return r[e.id]=t,t}}}function o3(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Te};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Te};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Te,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let l3=0;function c3(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function h3(r){const e=new a3,t=o3(),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 c=0;c<9;c++)i.probe.push(new P);const n=new P,s=new Ye,a=new Ye;function o(c){let h=0,d=0,u=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let f=0,p=0,v=0,m=0,g=0,x=0,M=0,w=0,S=0,_=0,D=0;c.sort(c3);for(let T=0,A=c.length;T<A;T++){const I=c[T],R=I.color,k=I.intensity,z=I.distance;let L=null;if(I.shadow&&I.shadow.map&&(I.shadow.map.texture.format===vr?L=I.shadow.map.texture:L=I.shadow.map.depthTexture||I.shadow.map.texture),I.isAmbientLight)h+=R.r*k,d+=R.g*k,u+=R.b*k;else if(I.isLightProbe){for(let B=0;B<9;B++)i.probe[B].addScaledVector(I.sh.coefficients[B],k);D++}else if(I.isDirectionalLight){const B=e.get(I);if(B.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){const F=I.shadow,V=t.get(I);V.shadowIntensity=F.intensity,V.shadowBias=F.bias,V.shadowNormalBias=F.normalBias,V.shadowRadius=F.radius,V.shadowMapSize=F.mapSize,i.directionalShadow[f]=V,i.directionalShadowMap[f]=L,i.directionalShadowMatrix[f]=I.shadow.matrix,x++}i.directional[f]=B,f++}else if(I.isSpotLight){const B=e.get(I);B.position.setFromMatrixPosition(I.matrixWorld),B.color.copy(R).multiplyScalar(k),B.distance=z,B.coneCos=Math.cos(I.angle),B.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),B.decay=I.decay,i.spot[v]=B;const F=I.shadow;if(I.map&&(i.spotLightMap[S]=I.map,S++,F.updateMatrices(I),I.castShadow&&_++),i.spotLightMatrix[v]=F.matrix,I.castShadow){const V=t.get(I);V.shadowIntensity=F.intensity,V.shadowBias=F.bias,V.shadowNormalBias=F.normalBias,V.shadowRadius=F.radius,V.shadowMapSize=F.mapSize,i.spotShadow[v]=V,i.spotShadowMap[v]=L,w++}v++}else if(I.isRectAreaLight){const B=e.get(I);B.color.copy(R).multiplyScalar(k),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=e.get(I);if(B.color.copy(I.color).multiplyScalar(I.intensity),B.distance=I.distance,B.decay=I.decay,I.castShadow){const F=I.shadow,V=t.get(I);V.shadowIntensity=F.intensity,V.shadowBias=F.bias,V.shadowNormalBias=F.normalBias,V.shadowRadius=F.radius,V.shadowMapSize=F.mapSize,V.shadowCameraNear=F.camera.near,V.shadowCameraFar=F.camera.far,i.pointShadow[p]=V,i.pointShadowMap[p]=L,i.pointShadowMatrix[p]=I.shadow.matrix,M++}i.point[p]=B,p++}else if(I.isHemisphereLight){const B=e.get(I);B.skyColor.copy(I.color).multiplyScalar(k),B.groundColor.copy(I.groundColor).multiplyScalar(k),i.hemi[g]=B,g++}}m>0&&(r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=pe.LTC_FLOAT_1,i.rectAreaLTC2=pe.LTC_FLOAT_2):(i.rectAreaLTC1=pe.LTC_HALF_1,i.rectAreaLTC2=pe.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=d,i.ambient[2]=u;const y=i.hash;(y.directionalLength!==f||y.pointLength!==p||y.spotLength!==v||y.rectAreaLength!==m||y.hemiLength!==g||y.numDirectionalShadows!==x||y.numPointShadows!==M||y.numSpotShadows!==w||y.numSpotMaps!==S||y.numLightProbes!==D)&&(i.directional.length=f,i.spot.length=v,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=x,i.directionalShadowMap.length=x,i.pointShadow.length=M,i.pointShadowMap.length=M,i.spotShadow.length=w,i.spotShadowMap.length=w,i.directionalShadowMatrix.length=x,i.pointShadowMatrix.length=M,i.spotLightMatrix.length=w+S-_,i.spotLightMap.length=S,i.numSpotLightShadowsWithMaps=_,i.numLightProbes=D,y.directionalLength=f,y.pointLength=p,y.spotLength=v,y.rectAreaLength=m,y.hemiLength=g,y.numDirectionalShadows=x,y.numPointShadows=M,y.numSpotShadows=w,y.numSpotMaps=S,y.numLightProbes=D,i.version=l3++)}function l(c,h){let d=0,u=0,f=0,p=0,v=0;const m=h.matrixWorldInverse;for(let g=0,x=c.length;g<x;g++){const M=c[g];if(M.isDirectionalLight){const w=i.directional[d];w.direction.setFromMatrixPosition(M.matrixWorld),n.setFromMatrixPosition(M.target.matrixWorld),w.direction.sub(n),w.direction.transformDirection(m),d++}else if(M.isSpotLight){const w=i.spot[f];w.position.setFromMatrixPosition(M.matrixWorld),w.position.applyMatrix4(m),w.direction.setFromMatrixPosition(M.matrixWorld),n.setFromMatrixPosition(M.target.matrixWorld),w.direction.sub(n),w.direction.transformDirection(m),f++}else if(M.isRectAreaLight){const w=i.rectArea[p];w.position.setFromMatrixPosition(M.matrixWorld),w.position.applyMatrix4(m),a.identity(),s.copy(M.matrixWorld),s.premultiply(m),a.extractRotation(s),w.halfWidth.set(M.width*.5,0,0),w.halfHeight.set(0,M.height*.5,0),w.halfWidth.applyMatrix4(a),w.halfHeight.applyMatrix4(a),p++}else if(M.isPointLight){const w=i.point[u];w.position.setFromMatrixPosition(M.matrixWorld),w.position.applyMatrix4(m),u++}else if(M.isHemisphereLight){const w=i.hemi[v];w.direction.setFromMatrixPosition(M.matrixWorld),w.direction.transformDirection(m),v++}}}return{setup:o,setupView:l,state:i}}function R0(r){const e=new h3(r),t=[],i=[],n=[];function s(u){d.camera=u,t.length=0,i.length=0,n.length=0}function a(u){t.push(u)}function o(u){i.push(u)}function l(u){n.push(u)}function c(){e.setup(t)}function h(u){e.setupView(t,u)}const d={lightsArray:t,shadowsArray:i,lightProbeGridArray:n,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:d,setupLights:c,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function d3(r){let e=new WeakMap;function t(n,s=0){const a=e.get(n);let o;return a===void 0?(o=new R0(r),e.set(n,[o])):s>=a.length?(o=new R0(r),a.push(o)):o=a[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const u3=`void main() {
6168
+ `+ie)}else L!==""?_e("WebGLProgram: Program Info Log:",L):(B===""||F==="")&&(j=!1);j&&(I.diagnostics={runnable:V,programLog:L,vertexShader:{log:B,prefix:m},fragmentShader:{log:F,prefix:g}})}n.deleteShader(S),n.deleteShader(_),y=new Zl(n,v),T=OS(n,v)}let y;this.getUniforms=function(){return y===void 0&&D(this),y};let T;this.getAttributes=function(){return T===void 0&&D(this),T};let A=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return A===!1&&(A=n.getProgramParameter(v,TS)),A},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=AS++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=_,this}let jS=0;class QS{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const n=this._getShaderCacheForMaterial(e);return n.has(t)===!1&&(n.add(t),t.usedTimes++),n.has(i)===!1&&(n.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new e3(e),t.set(e,i)),i}}class e3{constructor(e){this.id=jS++,this.code=e,this.usedTimes=0}}function t3(r){return r===vr||r===ac||r===oc}function i3(r,e,t,i,n,s){const a=new of,o=new QS,l=new Set,c=[],h=new Map,d=i.logarithmicDepthBuffer;let u=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(y){return l.add(y),y===0?"uv":`uv${y}`}function v(y,T,A,I,R,k){const z=I.fog,L=R.geometry,B=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?I.environment:null,F=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap,V=e.get(y.envMap||B,F),j=V&&V.mapping===Rc?V.image.height:null,$=f[y.type];y.precision!==null&&(u=i.getMaxPrecision(y.precision),u!==y.precision&&_e("WebGLProgram.getParameters:",y.precision,"not supported, using",u,"instead."));const ie=L.morphAttributes.position||L.morphAttributes.normal||L.morphAttributes.color,ae=ie!==void 0?ie.length:0;let Ve=0;L.morphAttributes.position!==void 0&&(Ve=1),L.morphAttributes.normal!==void 0&&(Ve=2),L.morphAttributes.color!==void 0&&(Ve=3);let je,Ge,K,re;if($){const Me=kn[$];je=Me.vertexShader,Ge=Me.fragmentShader}else{je=y.vertexShader,Ge=y.fragmentShader;const Me=o.getVertexShaderStage(y),Gt=o.getFragmentShaderStage(y);o.update(y,Me,Gt),K=Me.id,re=Gt.id}const ne=r.getRenderTarget(),G=r.state.buffers.depth.getReversed(),Ee=R.isInstancedMesh===!0,Pe=R.isBatchedMesh===!0,Ie=!!y.map,be=!!y.matcap,ke=!!V,Ne=!!y.aoMap,Oe=!!y.lightMap,dt=!!y.bumpMap&&y.wireframe===!1,ut=!!y.normalMap,zt=!!y.displacementMap,It=!!y.emissiveMap,Ht=!!y.metalnessMap,Zt=!!y.roughnessMap,O=y.anisotropy>0,Li=y.clearcoat>0,ft=y.dispersion>0,C=y.iridescence>0,b=y.sheen>0,H=y.transmission>0,q=O&&!!y.anisotropyMap,Z=Li&&!!y.clearcoatMap,se=Li&&!!y.clearcoatNormalMap,ce=Li&&!!y.clearcoatRoughnessMap,J=C&&!!y.iridescenceMap,ee=C&&!!y.iridescenceThicknessMap,he=b&&!!y.sheenColorMap,De=b&&!!y.sheenRoughnessMap,fe=!!y.specularMap,de=!!y.specularColorMap,Le=!!y.specularIntensityMap,Fe=H&&!!y.transmissionMap,Xe=H&&!!y.thicknessMap,N=!!y.gradientMap,le=!!y.alphaMap,Q=y.alphaTest>0,ue=!!y.alphaHash,ve=!!y.extensions;let te=Wn;y.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(te=r.toneMapping);const Ae={shaderID:$,shaderType:y.type,shaderName:y.name,vertexShader:je,fragmentShader:Ge,defines:y.defines,customVertexShaderID:K,customFragmentShaderID:re,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:u,batching:Pe,batchingColor:Pe&&R._colorsTexture!==null,instancing:Ee,instancingColor:Ee&&R.instanceColor!==null,instancingMorph:Ee&&R.morphTexture!==null,outputColorSpace:ne===null?r.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:tt.workingColorSpace,alphaToCoverage:!!y.alphaToCoverage,map:Ie,matcap:be,envMap:ke,envMapMode:ke&&V.mapping,envMapCubeUVHeight:j,aoMap:Ne,lightMap:Oe,bumpMap:dt,normalMap:ut,displacementMap:zt,emissiveMap:It,normalMapObjectSpace:ut&&y.normalMapType===K2,normalMapTangentSpace:ut&&y.normalMapType===cc,packedNormalMap:ut&&y.normalMapType===cc&&t3(y.normalMap.format),metalnessMap:Ht,roughnessMap:Zt,anisotropy:O,anisotropyMap:q,clearcoat:Li,clearcoatMap:Z,clearcoatNormalMap:se,clearcoatRoughnessMap:ce,dispersion:ft,iridescence:C,iridescenceMap:J,iridescenceThicknessMap:ee,sheen:b,sheenColorMap:he,sheenRoughnessMap:De,specularMap:fe,specularColorMap:de,specularIntensityMap:Le,transmission:H,transmissionMap:Fe,thicknessMap:Xe,gradientMap:N,opaque:y.transparent===!1&&y.blending===ma&&y.alphaToCoverage===!1,alphaMap:le,alphaTest:Q,alphaHash:ue,combine:y.combine,mapUv:Ie&&p(y.map.channel),aoMapUv:Ne&&p(y.aoMap.channel),lightMapUv:Oe&&p(y.lightMap.channel),bumpMapUv:dt&&p(y.bumpMap.channel),normalMapUv:ut&&p(y.normalMap.channel),displacementMapUv:zt&&p(y.displacementMap.channel),emissiveMapUv:It&&p(y.emissiveMap.channel),metalnessMapUv:Ht&&p(y.metalnessMap.channel),roughnessMapUv:Zt&&p(y.roughnessMap.channel),anisotropyMapUv:q&&p(y.anisotropyMap.channel),clearcoatMapUv:Z&&p(y.clearcoatMap.channel),clearcoatNormalMapUv:se&&p(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ce&&p(y.clearcoatRoughnessMap.channel),iridescenceMapUv:J&&p(y.iridescenceMap.channel),iridescenceThicknessMapUv:ee&&p(y.iridescenceThicknessMap.channel),sheenColorMapUv:he&&p(y.sheenColorMap.channel),sheenRoughnessMapUv:De&&p(y.sheenRoughnessMap.channel),specularMapUv:fe&&p(y.specularMap.channel),specularColorMapUv:de&&p(y.specularColorMap.channel),specularIntensityMapUv:Le&&p(y.specularIntensityMap.channel),transmissionMapUv:Fe&&p(y.transmissionMap.channel),thicknessMapUv:Xe&&p(y.thicknessMap.channel),alphaMapUv:le&&p(y.alphaMap.channel),vertexTangents:!!L.attributes.tangent&&(ut||O),vertexNormals:!!L.attributes.normal,vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!L.attributes.color&&L.attributes.color.itemSize===4,pointsUvs:R.isPoints===!0&&!!L.attributes.uv&&(Ie||le),fog:!!z,useFog:y.fog===!0,fogExp2:!!z&&z.isFogExp2,flatShading:y.wireframe===!1&&(y.flatShading===!0||L.attributes.normal===void 0&&ut===!1&&(y.isMeshLambertMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isMeshPhysicalMaterial)),sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:G,skinning:R.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:ae,morphTextureStride:Ve,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:k.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:y.dithering,shadowMapEnabled:r.shadowMap.enabled&&A.length>0,shadowMapType:r.shadowMap.type,toneMapping:te,decodeVideoTexture:Ie&&y.map.isVideoTexture===!0&&tt.getTransfer(y.map.colorSpace)===pt,decodeVideoTextureEmissive:It&&y.emissiveMap.isVideoTexture===!0&&tt.getTransfer(y.emissiveMap.colorSpace)===pt,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===pn,flipSided:y.side===Ft,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:ve&&y.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ve&&y.extensions.multiDraw===!0||Pe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return Ae.vertexUv1s=l.has(1),Ae.vertexUv2s=l.has(2),Ae.vertexUv3s=l.has(3),l.clear(),Ae}function m(y){const T=[];if(y.shaderID?T.push(y.shaderID):(T.push(y.customVertexShaderID),T.push(y.customFragmentShaderID)),y.defines!==void 0)for(const A in y.defines)T.push(A),T.push(y.defines[A]);return y.isRawShaderMaterial===!1&&(g(T,y),x(T,y),T.push(r.outputColorSpace)),T.push(y.customProgramCacheKey),T.join()}function g(y,T){y.push(T.precision),y.push(T.outputColorSpace),y.push(T.envMapMode),y.push(T.envMapCubeUVHeight),y.push(T.mapUv),y.push(T.alphaMapUv),y.push(T.lightMapUv),y.push(T.aoMapUv),y.push(T.bumpMapUv),y.push(T.normalMapUv),y.push(T.displacementMapUv),y.push(T.emissiveMapUv),y.push(T.metalnessMapUv),y.push(T.roughnessMapUv),y.push(T.anisotropyMapUv),y.push(T.clearcoatMapUv),y.push(T.clearcoatNormalMapUv),y.push(T.clearcoatRoughnessMapUv),y.push(T.iridescenceMapUv),y.push(T.iridescenceThicknessMapUv),y.push(T.sheenColorMapUv),y.push(T.sheenRoughnessMapUv),y.push(T.specularMapUv),y.push(T.specularColorMapUv),y.push(T.specularIntensityMapUv),y.push(T.transmissionMapUv),y.push(T.thicknessMapUv),y.push(T.combine),y.push(T.fogExp2),y.push(T.sizeAttenuation),y.push(T.morphTargetsCount),y.push(T.morphAttributeCount),y.push(T.numDirLights),y.push(T.numPointLights),y.push(T.numSpotLights),y.push(T.numSpotLightMaps),y.push(T.numHemiLights),y.push(T.numRectAreaLights),y.push(T.numDirLightShadows),y.push(T.numPointLightShadows),y.push(T.numSpotLightShadows),y.push(T.numSpotLightShadowsWithMaps),y.push(T.numLightProbes),y.push(T.shadowMapType),y.push(T.toneMapping),y.push(T.numClippingPlanes),y.push(T.numClipIntersection),y.push(T.depthPacking)}function x(y,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),y.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),y.push(a.mask)}function M(y){const T=f[y.type];let A;if(T){const I=kn[T];A=Qy.clone(I.uniforms)}else A=y.uniforms;return A}function w(y,T){let A=h.get(T);return A!==void 0?++A.usedTimes:(A=new JS(r,T,y,n),c.push(A),h.set(T,A)),A}function S(y){if(--y.usedTimes===0){const T=c.indexOf(y);c[T]=c[c.length-1],c.pop(),h.delete(y.cacheKey),y.destroy()}}function _(y){o.remove(y)}function D(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:M,acquireProgram:w,releaseProgram:S,releaseShaderCache:_,programs:c,dispose:D}}function n3(){let r=new WeakMap;function e(a){return r.has(a)}function t(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,l){r.get(a)[o]=l}function s(){r=new WeakMap}return{has:e,get:t,remove:i,update:n,dispose:s}}function s3(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.materialVariant!==e.materialVariant?r.materialVariant-e.materialVariant:r.z!==e.z?r.z-e.z:r.id-e.id}function D0(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function C0(){const r=[];let e=0;const t=[],i=[],n=[];function s(){e=0,t.length=0,i.length=0,n.length=0}function a(u){let f=0;return u.isInstancedMesh&&(f+=2),u.isSkinnedMesh&&(f+=1),f}function o(u,f,p,v,m,g){let x=r[e];return x===void 0?(x={id:u.id,object:u,geometry:f,material:p,materialVariant:a(u),groupOrder:v,renderOrder:u.renderOrder,z:m,group:g},r[e]=x):(x.id=u.id,x.object=u,x.geometry=f,x.material=p,x.materialVariant=a(u),x.groupOrder=v,x.renderOrder=u.renderOrder,x.z=m,x.group=g),e++,x}function l(u,f,p,v,m,g){const x=o(u,f,p,v,m,g);p.transmission>0?i.push(x):p.transparent===!0?n.push(x):t.push(x)}function c(u,f,p,v,m,g){const x=o(u,f,p,v,m,g);p.transmission>0?i.unshift(x):p.transparent===!0?n.unshift(x):t.unshift(x)}function h(u,f,p){t.length>1&&t.sort(u||s3),i.length>1&&i.sort(f||D0),n.length>1&&n.sort(f||D0),p&&(t.reverse(),i.reverse(),n.reverse())}function d(){for(let u=e,f=r.length;u<f;u++){const p=r[u];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:i,transparent:n,init:s,push:l,unshift:c,finish:d,sort:h}}function r3(){let r=new WeakMap;function e(i,n){const s=r.get(i);let a;return s===void 0?(a=new C0,r.set(i,[a])):n>=s.length?(a=new C0,s.push(a)):a=s[n],a}function t(){r=new WeakMap}return{get:e,dispose:t}}function a3(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new P,color:new oe};break;case"SpotLight":t={position:new P,direction:new P,color:new oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new P,color:new oe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new P,skyColor:new oe,groundColor:new oe};break;case"RectAreaLight":t={color:new oe,position:new P,halfWidth:new P,halfHeight:new P};break}return r[e.id]=t,t}}}function o3(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Te};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Te};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Te,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let l3=0;function c3(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function h3(r){const e=new a3,t=o3(),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 c=0;c<9;c++)i.probe.push(new P);const n=new P,s=new Ye,a=new Ye;function o(c){let h=0,d=0,u=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let f=0,p=0,v=0,m=0,g=0,x=0,M=0,w=0,S=0,_=0,D=0;c.sort(c3);for(let T=0,A=c.length;T<A;T++){const I=c[T],R=I.color,k=I.intensity,z=I.distance;let L=null;if(I.shadow&&I.shadow.map&&(I.shadow.map.texture.format===vr?L=I.shadow.map.texture:L=I.shadow.map.depthTexture||I.shadow.map.texture),I.isAmbientLight)h+=R.r*k,d+=R.g*k,u+=R.b*k;else if(I.isLightProbe){for(let B=0;B<9;B++)i.probe[B].addScaledVector(I.sh.coefficients[B],k);D++}else if(I.isDirectionalLight){const B=e.get(I);if(B.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){const F=I.shadow,V=t.get(I);V.shadowIntensity=F.intensity,V.shadowBias=F.bias,V.shadowNormalBias=F.normalBias,V.shadowRadius=F.radius,V.shadowMapSize=F.mapSize,i.directionalShadow[f]=V,i.directionalShadowMap[f]=L,i.directionalShadowMatrix[f]=I.shadow.matrix,x++}i.directional[f]=B,f++}else if(I.isSpotLight){const B=e.get(I);B.position.setFromMatrixPosition(I.matrixWorld),B.color.copy(R).multiplyScalar(k),B.distance=z,B.coneCos=Math.cos(I.angle),B.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),B.decay=I.decay,i.spot[v]=B;const F=I.shadow;if(I.map&&(i.spotLightMap[S]=I.map,S++,F.updateMatrices(I),I.castShadow&&_++),i.spotLightMatrix[v]=F.matrix,I.castShadow){const V=t.get(I);V.shadowIntensity=F.intensity,V.shadowBias=F.bias,V.shadowNormalBias=F.normalBias,V.shadowRadius=F.radius,V.shadowMapSize=F.mapSize,i.spotShadow[v]=V,i.spotShadowMap[v]=L,w++}v++}else if(I.isRectAreaLight){const B=e.get(I);B.color.copy(R).multiplyScalar(k),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=e.get(I);if(B.color.copy(I.color).multiplyScalar(I.intensity),B.distance=I.distance,B.decay=I.decay,I.castShadow){const F=I.shadow,V=t.get(I);V.shadowIntensity=F.intensity,V.shadowBias=F.bias,V.shadowNormalBias=F.normalBias,V.shadowRadius=F.radius,V.shadowMapSize=F.mapSize,V.shadowCameraNear=F.camera.near,V.shadowCameraFar=F.camera.far,i.pointShadow[p]=V,i.pointShadowMap[p]=L,i.pointShadowMatrix[p]=I.shadow.matrix,M++}i.point[p]=B,p++}else if(I.isHemisphereLight){const B=e.get(I);B.skyColor.copy(I.color).multiplyScalar(k),B.groundColor.copy(I.groundColor).multiplyScalar(k),i.hemi[g]=B,g++}}m>0&&(r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=pe.LTC_FLOAT_1,i.rectAreaLTC2=pe.LTC_FLOAT_2):(i.rectAreaLTC1=pe.LTC_HALF_1,i.rectAreaLTC2=pe.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=d,i.ambient[2]=u;const y=i.hash;(y.directionalLength!==f||y.pointLength!==p||y.spotLength!==v||y.rectAreaLength!==m||y.hemiLength!==g||y.numDirectionalShadows!==x||y.numPointShadows!==M||y.numSpotShadows!==w||y.numSpotMaps!==S||y.numLightProbes!==D)&&(i.directional.length=f,i.spot.length=v,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=x,i.directionalShadowMap.length=x,i.pointShadow.length=M,i.pointShadowMap.length=M,i.spotShadow.length=w,i.spotShadowMap.length=w,i.directionalShadowMatrix.length=x,i.pointShadowMatrix.length=M,i.spotLightMatrix.length=w+S-_,i.spotLightMap.length=S,i.numSpotLightShadowsWithMaps=_,i.numLightProbes=D,y.directionalLength=f,y.pointLength=p,y.spotLength=v,y.rectAreaLength=m,y.hemiLength=g,y.numDirectionalShadows=x,y.numPointShadows=M,y.numSpotShadows=w,y.numSpotMaps=S,y.numLightProbes=D,i.version=l3++)}function l(c,h){let d=0,u=0,f=0,p=0,v=0;const m=h.matrixWorldInverse;for(let g=0,x=c.length;g<x;g++){const M=c[g];if(M.isDirectionalLight){const w=i.directional[d];w.direction.setFromMatrixPosition(M.matrixWorld),n.setFromMatrixPosition(M.target.matrixWorld),w.direction.sub(n),w.direction.transformDirection(m),d++}else if(M.isSpotLight){const w=i.spot[f];w.position.setFromMatrixPosition(M.matrixWorld),w.position.applyMatrix4(m),w.direction.setFromMatrixPosition(M.matrixWorld),n.setFromMatrixPosition(M.target.matrixWorld),w.direction.sub(n),w.direction.transformDirection(m),f++}else if(M.isRectAreaLight){const w=i.rectArea[p];w.position.setFromMatrixPosition(M.matrixWorld),w.position.applyMatrix4(m),a.identity(),s.copy(M.matrixWorld),s.premultiply(m),a.extractRotation(s),w.halfWidth.set(M.width*.5,0,0),w.halfHeight.set(0,M.height*.5,0),w.halfWidth.applyMatrix4(a),w.halfHeight.applyMatrix4(a),p++}else if(M.isPointLight){const w=i.point[u];w.position.setFromMatrixPosition(M.matrixWorld),w.position.applyMatrix4(m),u++}else if(M.isHemisphereLight){const w=i.hemi[v];w.direction.setFromMatrixPosition(M.matrixWorld),w.direction.transformDirection(m),v++}}}return{setup:o,setupView:l,state:i}}function R0(r){const e=new h3(r),t=[],i=[],n=[];function s(u){d.camera=u,t.length=0,i.length=0,n.length=0}function a(u){t.push(u)}function o(u){i.push(u)}function l(u){n.push(u)}function c(){e.setup(t)}function h(u){e.setupView(t,u)}const d={lightsArray:t,shadowsArray:i,lightProbeGridArray:n,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:d,setupLights:c,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function d3(r){let e=new WeakMap;function t(n,s=0){const a=e.get(n);let o;return a===void 0?(o=new R0(r),e.set(n,[o])):s>=a.length?(o=new R0(r),a.push(o)):o=a[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const u3=`void main() {
6169
6169
  gl_Position = vec4( position, 1.0 );
6170
6170
  }`,f3=`uniform sampler2D shadow_pass;
6171
6171
  uniform vec2 resolution;
@@ -6192,7 +6192,7 @@ void main() {
6192
6192
  squared_mean = squared_mean / samples;
6193
6193
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
6194
6194
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
6195
- }`,p3=[new P(1,0,0),new P(-1,0,0),new P(0,1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1)],m3=[new P(0,-1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1),new P(0,-1,0),new P(0,-1,0)],P0=new Ye,$a=new P,Ph=new P;function g3(r,e,t){let i=new cf;const n=new Te,s=new Te,a=new at,o=new nb,l=new sb,c={},h=t.maxTextureSize,d={[Bs]:Ft,[Ft]:Bs,[pn]:pn},u=new Ot({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Te},radius:{value:4}},vertexShader:u3,fragmentShader:f3}),f=u.clone();f.defines.HORIZONTAL_PASS=1;const p=new Tt;p.setAttribute("position",new ht(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new We(p,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=po;let g=this.type;this.render=function(_,D,y){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||_.length===0)return;this.type===S2&&(_e("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=po);const T=r.getRenderTarget(),A=r.getActiveCubeFace(),I=r.getActiveMipmapLevel(),R=r.state;R.setBlending(Vn),R.buffers.depth.getReversed()===!0?R.buffers.color.setClear(0,0,0,0):R.buffers.color.setClear(1,1,1,1),R.buffers.depth.setTest(!0),R.setScissorTest(!1);const k=g!==this.type;k&&D.traverse(function(z){z.material&&(Array.isArray(z.material)?z.material.forEach(L=>L.needsUpdate=!0):z.material.needsUpdate=!0)});for(let z=0,L=_.length;z<L;z++){const B=_[z],F=B.shadow;if(F===void 0){_e("WebGLShadowMap:",B,"has no shadow.");continue}if(F.autoUpdate===!1&&F.needsUpdate===!1)continue;n.copy(F.mapSize);const V=F.getFrameExtents();n.multiply(V),s.copy(F.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(s.x=Math.floor(h/V.x),n.x=s.x*V.x,F.mapSize.x=s.x),n.y>h&&(s.y=Math.floor(h/V.y),n.y=s.y*V.y,F.mapSize.y=s.y));const j=r.state.buffers.depth.getReversed();if(F.camera._reversedDepth=j,F.map===null||k===!0){if(F.map!==null&&(F.map.depthTexture!==null&&(F.map.depthTexture.dispose(),F.map.depthTexture=null),F.map.dispose()),this.type===ro){if(B.isPointLight){_e("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}F.map=new vi(n.x,n.y,{format:vr,type:ui,minFilter:vt,magFilter:vt,generateMipmaps:!1}),F.map.texture.name=B.name+".shadowMap",F.map.depthTexture=new yr(n.x,n.y,Pi),F.map.depthTexture.name=B.name+".shadowMapDepth",F.map.depthTexture.format=ds,F.map.depthTexture.compareFunction=null,F.map.depthTexture.minFilter=Nt,F.map.depthTexture.magFilter=Nt}else B.isPointLight?(F.map=new i1(n.x),F.map.depthTexture=new Jy(n.x,yn)):(F.map=new vi(n.x,n.y),F.map.depthTexture=new yr(n.x,n.y,yn)),F.map.depthTexture.name=B.name+".shadowMap",F.map.depthTexture.format=ds,this.type===po?(F.map.depthTexture.compareFunction=j?sf:nf,F.map.depthTexture.minFilter=vt,F.map.depthTexture.magFilter=vt):(F.map.depthTexture.compareFunction=null,F.map.depthTexture.minFilter=Nt,F.map.depthTexture.magFilter=Nt);F.camera.updateProjectionMatrix()}const $=F.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie<$;ie++){if(F.map.isWebGLCubeRenderTarget)r.setRenderTarget(F.map,ie),r.clear();else{ie===0&&(r.setRenderTarget(F.map),r.clear());const ae=F.getViewport(ie);a.set(s.x*ae.x,s.y*ae.y,s.x*ae.z,s.y*ae.w),R.viewport(a)}if(B.isPointLight){const ae=F.camera,Ve=F.matrix,je=B.distance||ae.far;je!==ae.far&&(ae.far=je,ae.updateProjectionMatrix()),$a.setFromMatrixPosition(B.matrixWorld),ae.position.copy($a),Ph.copy(ae.position),Ph.add(p3[ie]),ae.up.copy(m3[ie]),ae.lookAt(Ph),ae.updateMatrixWorld(),Ve.makeTranslation(-$a.x,-$a.y,-$a.z),P0.multiplyMatrices(ae.projectionMatrix,ae.matrixWorldInverse),F._frustum.setFromProjectionMatrix(P0,ae.coordinateSystem,ae.reversedDepth)}else F.updateMatrices(B);i=F.getFrustum(),w(D,y,F.camera,B,this.type)}F.isPointLightShadow!==!0&&this.type===ro&&x(F,y),F.needsUpdate=!1}g=this.type,m.needsUpdate=!1,r.setRenderTarget(T,A,I)};function x(_,D){const y=e.update(v);u.defines.VSM_SAMPLES!==_.blurSamples&&(u.defines.VSM_SAMPLES=_.blurSamples,f.defines.VSM_SAMPLES=_.blurSamples,u.needsUpdate=!0,f.needsUpdate=!0),_.mapPass===null&&(_.mapPass=new vi(n.x,n.y,{format:vr,type:ui})),u.uniforms.shadow_pass.value=_.map.depthTexture,u.uniforms.resolution.value=_.mapSize,u.uniforms.radius.value=_.radius,r.setRenderTarget(_.mapPass),r.clear(),r.renderBufferDirect(D,null,y,u,v,null),f.uniforms.shadow_pass.value=_.mapPass.texture,f.uniforms.resolution.value=_.mapSize,f.uniforms.radius.value=_.radius,r.setRenderTarget(_.map),r.clear(),r.renderBufferDirect(D,null,y,f,v,null)}function M(_,D,y,T){let A=null;const I=y.isPointLight===!0?_.customDistanceMaterial:_.customDepthMaterial;if(I!==void 0)A=I;else if(A=y.isPointLight===!0?l:o,r.localClippingEnabled&&D.clipShadows===!0&&Array.isArray(D.clippingPlanes)&&D.clippingPlanes.length!==0||D.displacementMap&&D.displacementScale!==0||D.alphaMap&&D.alphaTest>0||D.map&&D.alphaTest>0||D.alphaToCoverage===!0){const R=A.uuid,k=D.uuid;let z=c[R];z===void 0&&(z={},c[R]=z);let L=z[k];L===void 0&&(L=A.clone(),z[k]=L,D.addEventListener("dispose",S)),A=L}if(A.visible=D.visible,A.wireframe=D.wireframe,T===ro?A.side=D.shadowSide!==null?D.shadowSide:D.side:A.side=D.shadowSide!==null?D.shadowSide:d[D.side],A.alphaMap=D.alphaMap,A.alphaTest=D.alphaToCoverage===!0?.5:D.alphaTest,A.map=D.map,A.clipShadows=D.clipShadows,A.clippingPlanes=D.clippingPlanes,A.clipIntersection=D.clipIntersection,A.displacementMap=D.displacementMap,A.displacementScale=D.displacementScale,A.displacementBias=D.displacementBias,A.wireframeLinewidth=D.wireframeLinewidth,A.linewidth=D.linewidth,y.isPointLight===!0&&A.isMeshDistanceMaterial===!0){const R=r.properties.get(A);R.light=y}return A}function w(_,D,y,T,A){if(_.visible===!1)return;if(_.layers.test(D.layers)&&(_.isMesh||_.isLine||_.isPoints)&&(_.castShadow||_.receiveShadow&&A===ro)&&(!_.frustumCulled||i.intersectsObject(_))){_.modelViewMatrix.multiplyMatrices(y.matrixWorldInverse,_.matrixWorld);const k=e.update(_),z=_.material;if(Array.isArray(z)){const L=k.groups;for(let B=0,F=L.length;B<F;B++){const V=L[B],j=z[V.materialIndex];if(j&&j.visible){const $=M(_,j,T,A);_.onBeforeShadow(r,_,D,y,k,$,V),r.renderBufferDirect(y,null,k,$,_,V),_.onAfterShadow(r,_,D,y,k,$,V)}}}else if(z.visible){const L=M(_,z,T,A);_.onBeforeShadow(r,_,D,y,k,L,null),r.renderBufferDirect(y,null,k,L,_,null),_.onAfterShadow(r,_,D,y,k,L,null)}}const R=_.children;for(let k=0,z=R.length;k<z;k++)w(R[k],D,y,T,A)}function S(_){_.target.removeEventListener("dispose",S);for(const y in c){const T=c[y],A=_.target.uuid;A in T&&(T[A].dispose(),delete T[A])}}}function v3(r,e){function t(){let N=!1;const le=new at;let Q=null;const ue=new at(0,0,0,0);return{setMask:function(ve){Q!==ve&&!N&&(r.colorMask(ve,ve,ve,ve),Q=ve)},setLocked:function(ve){N=ve},setClear:function(ve,te,Ae,Me,Gt){Gt===!0&&(ve*=Me,te*=Me,Ae*=Me),le.set(ve,te,Ae,Me),ue.equals(le)===!1&&(r.clearColor(ve,te,Ae,Me),ue.copy(le))},reset:function(){N=!1,Q=null,ue.set(-1,0,0,0)}}}function i(){let N=!1,le=!1,Q=null,ue=null,ve=null;return{setReversed:function(te){if(le!==te){const Ae=e.get("EXT_clip_control");te?Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.ZERO_TO_ONE_EXT):Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.NEGATIVE_ONE_TO_ONE_EXT),le=te;const Me=ve;ve=null,this.setClear(Me)}},getReversed:function(){return le},setTest:function(te){te?ne(r.DEPTH_TEST):G(r.DEPTH_TEST)},setMask:function(te){Q!==te&&!N&&(r.depthMask(te),Q=te)},setFunc:function(te){if(le&&(te=ry[te]),ue!==te){switch(te){case Sd:r.depthFunc(r.NEVER);break;case Ed:r.depthFunc(r.ALWAYS);break;case _d:r.depthFunc(r.LESS);break;case Aa:r.depthFunc(r.LEQUAL);break;case Td:r.depthFunc(r.EQUAL);break;case Ad:r.depthFunc(r.GEQUAL);break;case Id:r.depthFunc(r.GREATER);break;case Dd:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}ue=te}},setLocked:function(te){N=te},setClear:function(te){ve!==te&&(ve=te,le&&(te=1-te),r.clearDepth(te))},reset:function(){N=!1,Q=null,ue=null,ve=null,le=!1}}}function n(){let N=!1,le=null,Q=null,ue=null,ve=null,te=null,Ae=null,Me=null,Gt=null;return{setTest:function(xt){N||(xt?ne(r.STENCIL_TEST):G(r.STENCIL_TEST))},setMask:function(xt){le!==xt&&!N&&(r.stencilMask(xt),le=xt)},setFunc:function(xt,xn,Sn){(Q!==xt||ue!==xn||ve!==Sn)&&(r.stencilFunc(xt,xn,Sn),Q=xt,ue=xn,ve=Sn)},setOp:function(xt,xn,Sn){(te!==xt||Ae!==xn||Me!==Sn)&&(r.stencilOp(xt,xn,Sn),te=xt,Ae=xn,Me=Sn)},setLocked:function(xt){N=xt},setClear:function(xt){Gt!==xt&&(r.clearStencil(xt),Gt=xt)},reset:function(){N=!1,le=null,Q=null,ue=null,ve=null,te=null,Ae=null,Me=null,Gt=null}}}const s=new t,a=new i,o=new n,l=new WeakMap,c=new WeakMap;let h={},d={},u={},f=new WeakMap,p=[],v=null,m=!1,g=null,x=null,M=null,w=null,S=null,_=null,D=null,y=new oe(0,0,0),T=0,A=!1,I=null,R=null,k=null,z=null,L=null;const B=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let F=!1,V=0;const j=r.getParameter(r.VERSION);j.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(j)[1]),F=V>=1):j.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),F=V>=2);let $=null,ie={};const ae=r.getParameter(r.SCISSOR_BOX),Ve=r.getParameter(r.VIEWPORT),je=new at().fromArray(ae),He=new at().fromArray(Ve);function K(N,le,Q,ue){const ve=new Uint8Array(4),te=r.createTexture();r.bindTexture(N,te),r.texParameteri(N,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(N,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let Ae=0;Ae<Q;Ae++)N===r.TEXTURE_3D||N===r.TEXTURE_2D_ARRAY?r.texImage3D(le,0,r.RGBA,1,1,ue,0,r.RGBA,r.UNSIGNED_BYTE,ve):r.texImage2D(le+Ae,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,ve);return te}const re={};re[r.TEXTURE_2D]=K(r.TEXTURE_2D,r.TEXTURE_2D,1),re[r.TEXTURE_CUBE_MAP]=K(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[r.TEXTURE_2D_ARRAY]=K(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),re[r.TEXTURE_3D]=K(r.TEXTURE_3D,r.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ne(r.DEPTH_TEST),a.setFunc(Aa),dt(!1),ut(up),ne(r.CULL_FACE),Ne(Vn);function ne(N){h[N]!==!0&&(r.enable(N),h[N]=!0)}function G(N){h[N]!==!1&&(r.disable(N),h[N]=!1)}function Ee(N,le){return u[N]!==le?(r.bindFramebuffer(N,le),u[N]=le,N===r.DRAW_FRAMEBUFFER&&(u[r.FRAMEBUFFER]=le),N===r.FRAMEBUFFER&&(u[r.DRAW_FRAMEBUFFER]=le),!0):!1}function Pe(N,le){let Q=p,ue=!1;if(N){Q=f.get(le),Q===void 0&&(Q=[],f.set(le,Q));const ve=N.textures;if(Q.length!==ve.length||Q[0]!==r.COLOR_ATTACHMENT0){for(let te=0,Ae=ve.length;te<Ae;te++)Q[te]=r.COLOR_ATTACHMENT0+te;Q.length=ve.length,ue=!0}}else Q[0]!==r.BACK&&(Q[0]=r.BACK,ue=!0);ue&&r.drawBuffers(Q)}function Ie(N){return v!==N?(r.useProgram(N),v=N,!0):!1}const be={[ir]:r.FUNC_ADD,[_2]:r.FUNC_SUBTRACT,[T2]:r.FUNC_REVERSE_SUBTRACT};be[A2]=r.MIN,be[I2]=r.MAX;const ke={[D2]:r.ZERO,[C2]:r.ONE,[R2]:r.SRC_COLOR,[Md]:r.SRC_ALPHA,[F2]:r.SRC_ALPHA_SATURATE,[N2]:r.DST_COLOR,[L2]:r.DST_ALPHA,[P2]:r.ONE_MINUS_SRC_COLOR,[xd]:r.ONE_MINUS_SRC_ALPHA,[O2]:r.ONE_MINUS_DST_COLOR,[k2]:r.ONE_MINUS_DST_ALPHA,[U2]:r.CONSTANT_COLOR,[B2]:r.ONE_MINUS_CONSTANT_COLOR,[z2]:r.CONSTANT_ALPHA,[H2]:r.ONE_MINUS_CONSTANT_ALPHA};function Ne(N,le,Q,ue,ve,te,Ae,Me,Gt,xt){if(N===Vn){m===!0&&(G(r.BLEND),m=!1);return}if(m===!1&&(ne(r.BLEND),m=!0),N!==E2){if(N!==g||xt!==A){if((x!==ir||S!==ir)&&(r.blendEquation(r.FUNC_ADD),x=ir,S=ir),xt)switch(N){case ma:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Zi:r.blendFunc(r.ONE,r.ONE);break;case fp:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case pp:r.blendFuncSeparate(r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:Ue("WebGLState: Invalid blending: ",N);break}else switch(N){case ma:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Zi:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE,r.ONE,r.ONE);break;case fp:Ue("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case pp:Ue("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ue("WebGLState: Invalid blending: ",N);break}M=null,w=null,_=null,D=null,y.set(0,0,0),T=0,g=N,A=xt}return}ve=ve||le,te=te||Q,Ae=Ae||ue,(le!==x||ve!==S)&&(r.blendEquationSeparate(be[le],be[ve]),x=le,S=ve),(Q!==M||ue!==w||te!==_||Ae!==D)&&(r.blendFuncSeparate(ke[Q],ke[ue],ke[te],ke[Ae]),M=Q,w=ue,_=te,D=Ae),(Me.equals(y)===!1||Gt!==T)&&(r.blendColor(Me.r,Me.g,Me.b,Gt),y.copy(Me),T=Gt),g=N,A=!1}function Oe(N,le){N.side===pn?G(r.CULL_FACE):ne(r.CULL_FACE);let Q=N.side===Ft;le&&(Q=!Q),dt(Q),N.blending===ma&&N.transparent===!1?Ne(Vn):Ne(N.blending,N.blendEquation,N.blendSrc,N.blendDst,N.blendEquationAlpha,N.blendSrcAlpha,N.blendDstAlpha,N.blendColor,N.blendAlpha,N.premultipliedAlpha),a.setFunc(N.depthFunc),a.setTest(N.depthTest),a.setMask(N.depthWrite),s.setMask(N.colorWrite);const ue=N.stencilWrite;o.setTest(ue),ue&&(o.setMask(N.stencilWriteMask),o.setFunc(N.stencilFunc,N.stencilRef,N.stencilFuncMask),o.setOp(N.stencilFail,N.stencilZFail,N.stencilZPass)),It(N.polygonOffset,N.polygonOffsetFactor,N.polygonOffsetUnits),N.alphaToCoverage===!0?ne(r.SAMPLE_ALPHA_TO_COVERAGE):G(r.SAMPLE_ALPHA_TO_COVERAGE)}function dt(N){I!==N&&(N?r.frontFace(r.CW):r.frontFace(r.CCW),I=N)}function ut(N){N!==M2?(ne(r.CULL_FACE),N!==R&&(N===up?r.cullFace(r.BACK):N===x2?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):G(r.CULL_FACE),R=N}function zt(N){N!==k&&(F&&r.lineWidth(N),k=N)}function It(N,le,Q){N?(ne(r.POLYGON_OFFSET_FILL),(z!==le||L!==Q)&&(z=le,L=Q,a.getReversed()&&(le=-le),r.polygonOffset(le,Q))):G(r.POLYGON_OFFSET_FILL)}function Ht(N){N?ne(r.SCISSOR_TEST):G(r.SCISSOR_TEST)}function Zt(N){N===void 0&&(N=r.TEXTURE0+B-1),$!==N&&(r.activeTexture(N),$=N)}function O(N,le,Q){Q===void 0&&($===null?Q=r.TEXTURE0+B-1:Q=$);let ue=ie[Q];ue===void 0&&(ue={type:void 0,texture:void 0},ie[Q]=ue),(ue.type!==N||ue.texture!==le)&&($!==Q&&(r.activeTexture(Q),$=Q),r.bindTexture(N,le||re[N]),ue.type=N,ue.texture=le)}function Li(){const N=ie[$];N!==void 0&&N.type!==void 0&&(r.bindTexture(N.type,null),N.type=void 0,N.texture=void 0)}function ft(){try{r.compressedTexImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function C(){try{r.compressedTexImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function b(){try{r.texSubImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function H(){try{r.texSubImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function q(){try{r.compressedTexSubImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function Z(){try{r.compressedTexSubImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function se(){try{r.texStorage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function ce(){try{r.texStorage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function J(){try{r.texImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function ee(){try{r.texImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function he(N){return d[N]!==void 0?d[N]:r.getParameter(N)}function De(N,le){d[N]!==le&&(r.pixelStorei(N,le),d[N]=le)}function fe(N){je.equals(N)===!1&&(r.scissor(N.x,N.y,N.z,N.w),je.copy(N))}function de(N){He.equals(N)===!1&&(r.viewport(N.x,N.y,N.z,N.w),He.copy(N))}function Le(N,le){let Q=c.get(le);Q===void 0&&(Q=new WeakMap,c.set(le,Q));let ue=Q.get(N);ue===void 0&&(ue=r.getUniformBlockIndex(le,N.name),Q.set(N,ue))}function Fe(N,le){const ue=c.get(le).get(N);l.get(le)!==ue&&(r.uniformBlockBinding(le,ue,N.__bindingPointIndex),l.set(le,ue))}function Xe(){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={},d={},$=null,ie={},u={},f=new WeakMap,p=[],v=null,m=!1,g=null,x=null,M=null,w=null,S=null,_=null,D=null,y=new oe(0,0,0),T=0,A=!1,I=null,R=null,k=null,z=null,L=null,je.set(0,0,r.canvas.width,r.canvas.height),He.set(0,0,r.canvas.width,r.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:ne,disable:G,bindFramebuffer:Ee,drawBuffers:Pe,useProgram:Ie,setBlending:Ne,setMaterial:Oe,setFlipSided:dt,setCullFace:ut,setLineWidth:zt,setPolygonOffset:It,setScissorTest:Ht,activeTexture:Zt,bindTexture:O,unbindTexture:Li,compressedTexImage2D:ft,compressedTexImage3D:C,texImage2D:J,texImage3D:ee,pixelStorei:De,getParameter:he,updateUBOMapping:Le,uniformBlockBinding:Fe,texStorage2D:se,texStorage3D:ce,texSubImage2D:b,texSubImage3D:H,compressedTexSubImage2D:q,compressedTexSubImage3D:Z,scissor:fe,viewport:de,reset:Xe}}function y3(r,e,t,i,n,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Te,h=new WeakMap,d=new Set;let u;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(C,b){return p?new OffscreenCanvas(C,b):Po("canvas")}function m(C,b,H){let q=1;const Z=ft(C);if((Z.width>H||Z.height>H)&&(q=H/Math.max(Z.width,Z.height)),q<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){const se=Math.floor(q*Z.width),ce=Math.floor(q*Z.height);u===void 0&&(u=v(se,ce));const J=b?v(se,ce):u;return J.width=se,J.height=ce,J.getContext("2d").drawImage(C,0,0,se,ce),_e("WebGLRenderer: Texture has been resized from ("+Z.width+"x"+Z.height+") to ("+se+"x"+ce+")."),J}else return"data"in C&&_e("WebGLRenderer: Image in DataTexture is too big ("+Z.width+"x"+Z.height+")."),C;return C}function g(C){return C.generateMipmaps}function x(C){r.generateMipmap(C)}function M(C){return C.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:C.isWebGL3DRenderTarget?r.TEXTURE_3D:C.isWebGLArrayRenderTarget||C.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function w(C,b,H,q,Z,se=!1){if(C!==null){if(r[C]!==void 0)return r[C];_e("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let ce;q&&(ce=e.get("EXT_texture_norm16"),ce||_e("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let J=b;if(b===r.RED&&(H===r.FLOAT&&(J=r.R32F),H===r.HALF_FLOAT&&(J=r.R16F),H===r.UNSIGNED_BYTE&&(J=r.R8),H===r.UNSIGNED_SHORT&&ce&&(J=ce.R16_EXT),H===r.SHORT&&ce&&(J=ce.R16_SNORM_EXT)),b===r.RED_INTEGER&&(H===r.UNSIGNED_BYTE&&(J=r.R8UI),H===r.UNSIGNED_SHORT&&(J=r.R16UI),H===r.UNSIGNED_INT&&(J=r.R32UI),H===r.BYTE&&(J=r.R8I),H===r.SHORT&&(J=r.R16I),H===r.INT&&(J=r.R32I)),b===r.RG&&(H===r.FLOAT&&(J=r.RG32F),H===r.HALF_FLOAT&&(J=r.RG16F),H===r.UNSIGNED_BYTE&&(J=r.RG8),H===r.UNSIGNED_SHORT&&ce&&(J=ce.RG16_EXT),H===r.SHORT&&ce&&(J=ce.RG16_SNORM_EXT)),b===r.RG_INTEGER&&(H===r.UNSIGNED_BYTE&&(J=r.RG8UI),H===r.UNSIGNED_SHORT&&(J=r.RG16UI),H===r.UNSIGNED_INT&&(J=r.RG32UI),H===r.BYTE&&(J=r.RG8I),H===r.SHORT&&(J=r.RG16I),H===r.INT&&(J=r.RG32I)),b===r.RGB_INTEGER&&(H===r.UNSIGNED_BYTE&&(J=r.RGB8UI),H===r.UNSIGNED_SHORT&&(J=r.RGB16UI),H===r.UNSIGNED_INT&&(J=r.RGB32UI),H===r.BYTE&&(J=r.RGB8I),H===r.SHORT&&(J=r.RGB16I),H===r.INT&&(J=r.RGB32I)),b===r.RGBA_INTEGER&&(H===r.UNSIGNED_BYTE&&(J=r.RGBA8UI),H===r.UNSIGNED_SHORT&&(J=r.RGBA16UI),H===r.UNSIGNED_INT&&(J=r.RGBA32UI),H===r.BYTE&&(J=r.RGBA8I),H===r.SHORT&&(J=r.RGBA16I),H===r.INT&&(J=r.RGBA32I)),b===r.RGB&&(H===r.UNSIGNED_SHORT&&ce&&(J=ce.RGB16_EXT),H===r.SHORT&&ce&&(J=ce.RGB16_SNORM_EXT),H===r.UNSIGNED_INT_5_9_9_9_REV&&(J=r.RGB9_E5),H===r.UNSIGNED_INT_10F_11F_11F_REV&&(J=r.R11F_G11F_B10F)),b===r.RGBA){const ee=se?dc:tt.getTransfer(Z);H===r.FLOAT&&(J=r.RGBA32F),H===r.HALF_FLOAT&&(J=r.RGBA16F),H===r.UNSIGNED_BYTE&&(J=ee===pt?r.SRGB8_ALPHA8:r.RGBA8),H===r.UNSIGNED_SHORT&&ce&&(J=ce.RGBA16_EXT),H===r.SHORT&&ce&&(J=ce.RGBA16_SNORM_EXT),H===r.UNSIGNED_SHORT_4_4_4_4&&(J=r.RGBA4),H===r.UNSIGNED_SHORT_5_5_5_1&&(J=r.RGB5_A1)}return(J===r.R16F||J===r.R32F||J===r.RG16F||J===r.RG32F||J===r.RGBA16F||J===r.RGBA32F)&&e.get("EXT_color_buffer_float"),J}function S(C,b){let H;return C?b===null||b===yn||b===Co?H=r.DEPTH24_STENCIL8:b===Pi?H=r.DEPTH32F_STENCIL8:b===Do&&(H=r.DEPTH24_STENCIL8,_e("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===yn||b===Co?H=r.DEPTH_COMPONENT24:b===Pi?H=r.DEPTH_COMPONENT32F:b===Do&&(H=r.DEPTH_COMPONENT16),H}function _(C,b){return g(C)===!0||C.isFramebufferTexture&&C.minFilter!==Nt&&C.minFilter!==vt?Math.log2(Math.max(b.width,b.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?b.mipmaps.length:1}function D(C){const b=C.target;b.removeEventListener("dispose",D),T(b),b.isVideoTexture&&h.delete(b),b.isHTMLTexture&&d.delete(b)}function y(C){const b=C.target;b.removeEventListener("dispose",y),I(b)}function T(C){const b=i.get(C);if(b.__webglInit===void 0)return;const H=C.source,q=f.get(H);if(q){const Z=q[b.__cacheKey];Z.usedTimes--,Z.usedTimes===0&&A(C),Object.keys(q).length===0&&f.delete(H)}i.remove(C)}function A(C){const b=i.get(C);r.deleteTexture(b.__webglTexture);const H=C.source,q=f.get(H);delete q[b.__cacheKey],a.memory.textures--}function I(C){const b=i.get(C);if(C.depthTexture&&(C.depthTexture.dispose(),i.remove(C.depthTexture)),C.isWebGLCubeRenderTarget)for(let q=0;q<6;q++){if(Array.isArray(b.__webglFramebuffer[q]))for(let Z=0;Z<b.__webglFramebuffer[q].length;Z++)r.deleteFramebuffer(b.__webglFramebuffer[q][Z]);else r.deleteFramebuffer(b.__webglFramebuffer[q]);b.__webglDepthbuffer&&r.deleteRenderbuffer(b.__webglDepthbuffer[q])}else{if(Array.isArray(b.__webglFramebuffer))for(let q=0;q<b.__webglFramebuffer.length;q++)r.deleteFramebuffer(b.__webglFramebuffer[q]);else r.deleteFramebuffer(b.__webglFramebuffer);if(b.__webglDepthbuffer&&r.deleteRenderbuffer(b.__webglDepthbuffer),b.__webglMultisampledFramebuffer&&r.deleteFramebuffer(b.__webglMultisampledFramebuffer),b.__webglColorRenderbuffer)for(let q=0;q<b.__webglColorRenderbuffer.length;q++)b.__webglColorRenderbuffer[q]&&r.deleteRenderbuffer(b.__webglColorRenderbuffer[q]);b.__webglDepthRenderbuffer&&r.deleteRenderbuffer(b.__webglDepthRenderbuffer)}const H=C.textures;for(let q=0,Z=H.length;q<Z;q++){const se=i.get(H[q]);se.__webglTexture&&(r.deleteTexture(se.__webglTexture),a.memory.textures--),i.remove(H[q])}i.remove(C)}let R=0;function k(){R=0}function z(){return R}function L(C){R=C}function B(){const C=R;return C>=n.maxTextures&&_e("WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+n.maxTextures),R+=1,C}function F(C){const b=[];return b.push(C.wrapS),b.push(C.wrapT),b.push(C.wrapR||0),b.push(C.magFilter),b.push(C.minFilter),b.push(C.anisotropy),b.push(C.internalFormat),b.push(C.format),b.push(C.type),b.push(C.generateMipmaps),b.push(C.premultiplyAlpha),b.push(C.flipY),b.push(C.unpackAlignment),b.push(C.colorSpace),b.join()}function V(C,b){const H=i.get(C);if(C.isVideoTexture&&O(C),C.isRenderTargetTexture===!1&&C.isExternalTexture!==!0&&C.version>0&&H.__version!==C.version){const q=C.image;if(q===null)_e("WebGLRenderer: Texture marked for update but no image data found.");else if(q.complete===!1)_e("WebGLRenderer: Texture marked for update but image is incomplete");else{G(H,C,b);return}}else C.isExternalTexture&&(H.__webglTexture=C.sourceTexture?C.sourceTexture:null);t.bindTexture(r.TEXTURE_2D,H.__webglTexture,r.TEXTURE0+b)}function j(C,b){const H=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&H.__version!==C.version){G(H,C,b);return}else C.isExternalTexture&&(H.__webglTexture=C.sourceTexture?C.sourceTexture:null);t.bindTexture(r.TEXTURE_2D_ARRAY,H.__webglTexture,r.TEXTURE0+b)}function $(C,b){const H=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&H.__version!==C.version){G(H,C,b);return}t.bindTexture(r.TEXTURE_3D,H.__webglTexture,r.TEXTURE0+b)}function ie(C,b){const H=i.get(C);if(C.isCubeDepthTexture!==!0&&C.version>0&&H.__version!==C.version){Ee(H,C,b);return}t.bindTexture(r.TEXTURE_CUBE_MAP,H.__webglTexture,r.TEXTURE0+b)}const ae={[Io]:r.REPEAT,[Ri]:r.CLAMP_TO_EDGE,[Cd]:r.MIRRORED_REPEAT},Ve={[Nt]:r.NEAREST,[X2]:r.NEAREST_MIPMAP_NEAREST,[Ko]:r.NEAREST_MIPMAP_LINEAR,[vt]:r.LINEAR,[Zc]:r.LINEAR_MIPMAP_NEAREST,[or]:r.LINEAR_MIPMAP_LINEAR},je={[$2]:r.NEVER,[ey]:r.ALWAYS,[Z2]:r.LESS,[nf]:r.LEQUAL,[J2]:r.EQUAL,[sf]:r.GEQUAL,[j2]:r.GREATER,[Q2]:r.NOTEQUAL};function He(C,b){if(b.type===Pi&&e.has("OES_texture_float_linear")===!1&&(b.magFilter===vt||b.magFilter===Zc||b.magFilter===Ko||b.magFilter===or||b.minFilter===vt||b.minFilter===Zc||b.minFilter===Ko||b.minFilter===or)&&_e("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(C,r.TEXTURE_WRAP_S,ae[b.wrapS]),r.texParameteri(C,r.TEXTURE_WRAP_T,ae[b.wrapT]),(C===r.TEXTURE_3D||C===r.TEXTURE_2D_ARRAY)&&r.texParameteri(C,r.TEXTURE_WRAP_R,ae[b.wrapR]),r.texParameteri(C,r.TEXTURE_MAG_FILTER,Ve[b.magFilter]),r.texParameteri(C,r.TEXTURE_MIN_FILTER,Ve[b.minFilter]),b.compareFunction&&(r.texParameteri(C,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(C,r.TEXTURE_COMPARE_FUNC,je[b.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===Nt||b.minFilter!==Ko&&b.minFilter!==or||b.type===Pi&&e.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||i.get(b).__currentAnisotropy){const H=e.get("EXT_texture_filter_anisotropic");r.texParameterf(C,H.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,n.getMaxAnisotropy())),i.get(b).__currentAnisotropy=b.anisotropy}}}function K(C,b){let H=!1;C.__webglInit===void 0&&(C.__webglInit=!0,b.addEventListener("dispose",D));const q=b.source;let Z=f.get(q);Z===void 0&&(Z={},f.set(q,Z));const se=F(b);if(se!==C.__cacheKey){Z[se]===void 0&&(Z[se]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,H=!0),Z[se].usedTimes++;const ce=Z[C.__cacheKey];ce!==void 0&&(Z[C.__cacheKey].usedTimes--,ce.usedTimes===0&&A(b)),C.__cacheKey=se,C.__webglTexture=Z[se].texture}return H}function re(C,b,H){return Math.floor(Math.floor(C/H)/b)}function ne(C,b,H,q){const se=C.updateRanges;if(se.length===0)t.texSubImage2D(r.TEXTURE_2D,0,0,0,b.width,b.height,H,q,b.data);else{se.sort((De,fe)=>De.start-fe.start);let ce=0;for(let De=1;De<se.length;De++){const fe=se[ce],de=se[De],Le=fe.start+fe.count,Fe=re(de.start,b.width,4),Xe=re(fe.start,b.width,4);de.start<=Le+1&&Fe===Xe&&re(de.start+de.count-1,b.width,4)===Fe?fe.count=Math.max(fe.count,de.start+de.count-fe.start):(++ce,se[ce]=de)}se.length=ce+1;const J=t.getParameter(r.UNPACK_ROW_LENGTH),ee=t.getParameter(r.UNPACK_SKIP_PIXELS),he=t.getParameter(r.UNPACK_SKIP_ROWS);t.pixelStorei(r.UNPACK_ROW_LENGTH,b.width);for(let De=0,fe=se.length;De<fe;De++){const de=se[De],Le=Math.floor(de.start/4),Fe=Math.ceil(de.count/4),Xe=Le%b.width,N=Math.floor(Le/b.width),le=Fe,Q=1;t.pixelStorei(r.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(r.UNPACK_SKIP_ROWS,N),t.texSubImage2D(r.TEXTURE_2D,0,Xe,N,le,Q,H,q,b.data)}C.clearUpdateRanges(),t.pixelStorei(r.UNPACK_ROW_LENGTH,J),t.pixelStorei(r.UNPACK_SKIP_PIXELS,ee),t.pixelStorei(r.UNPACK_SKIP_ROWS,he)}}function G(C,b,H){let q=r.TEXTURE_2D;(b.isDataArrayTexture||b.isCompressedArrayTexture)&&(q=r.TEXTURE_2D_ARRAY),b.isData3DTexture&&(q=r.TEXTURE_3D);const Z=K(C,b),se=b.source;t.bindTexture(q,C.__webglTexture,r.TEXTURE0+H);const ce=i.get(se);if(se.version!==ce.__version||Z===!0){if(t.activeTexture(r.TEXTURE0+H),(typeof ImageBitmap<"u"&&b.image instanceof ImageBitmap)===!1){const Q=tt.getPrimaries(tt.workingColorSpace),ue=b.colorSpace===Ps?null:tt.getPrimaries(b.colorSpace),ve=b.colorSpace===Ps||Q===ue?r.NONE:r.BROWSER_DEFAULT_WEBGL;t.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,b.flipY),t.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),t.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,ve)}t.pixelStorei(r.UNPACK_ALIGNMENT,b.unpackAlignment);let ee=m(b.image,!1,n.maxTextureSize);ee=Li(b,ee);const he=s.convert(b.format,b.colorSpace),De=s.convert(b.type);let fe=w(b.internalFormat,he,De,b.normalized,b.colorSpace,b.isVideoTexture);He(q,b);let de;const Le=b.mipmaps,Fe=b.isVideoTexture!==!0,Xe=ce.__version===void 0||Z===!0,N=se.dataReady,le=_(b,ee);if(b.isDepthTexture)fe=S(b.format===lr,b.type),Xe&&(Fe?t.texStorage2D(r.TEXTURE_2D,1,fe,ee.width,ee.height):t.texImage2D(r.TEXTURE_2D,0,fe,ee.width,ee.height,0,he,De,null));else if(b.isDataTexture)if(Le.length>0){Fe&&Xe&&t.texStorage2D(r.TEXTURE_2D,le,fe,Le[0].width,Le[0].height);for(let Q=0,ue=Le.length;Q<ue;Q++)de=Le[Q],Fe?N&&t.texSubImage2D(r.TEXTURE_2D,Q,0,0,de.width,de.height,he,De,de.data):t.texImage2D(r.TEXTURE_2D,Q,fe,de.width,de.height,0,he,De,de.data);b.generateMipmaps=!1}else Fe?(Xe&&t.texStorage2D(r.TEXTURE_2D,le,fe,ee.width,ee.height),N&&ne(b,ee,he,De)):t.texImage2D(r.TEXTURE_2D,0,fe,ee.width,ee.height,0,he,De,ee.data);else if(b.isCompressedTexture)if(b.isCompressedArrayTexture){Fe&&Xe&&t.texStorage3D(r.TEXTURE_2D_ARRAY,le,fe,Le[0].width,Le[0].height,ee.depth);for(let Q=0,ue=Le.length;Q<ue;Q++)if(de=Le[Q],b.format!==Ti)if(he!==null)if(Fe){if(N)if(b.layerUpdates.size>0){const ve=c0(de.width,de.height,b.format,b.type);for(const te of b.layerUpdates){const Ae=de.data.subarray(te*ve/de.data.BYTES_PER_ELEMENT,(te+1)*ve/de.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,Q,0,0,te,de.width,de.height,1,he,Ae)}b.clearLayerUpdates()}else t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,Q,0,0,0,de.width,de.height,ee.depth,he,de.data)}else t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,Q,fe,de.width,de.height,ee.depth,0,de.data,0,0);else _e("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Fe?N&&t.texSubImage3D(r.TEXTURE_2D_ARRAY,Q,0,0,0,de.width,de.height,ee.depth,he,De,de.data):t.texImage3D(r.TEXTURE_2D_ARRAY,Q,fe,de.width,de.height,ee.depth,0,he,De,de.data)}else{Fe&&Xe&&t.texStorage2D(r.TEXTURE_2D,le,fe,Le[0].width,Le[0].height);for(let Q=0,ue=Le.length;Q<ue;Q++)de=Le[Q],b.format!==Ti?he!==null?Fe?N&&t.compressedTexSubImage2D(r.TEXTURE_2D,Q,0,0,de.width,de.height,he,de.data):t.compressedTexImage2D(r.TEXTURE_2D,Q,fe,de.width,de.height,0,de.data):_e("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Fe?N&&t.texSubImage2D(r.TEXTURE_2D,Q,0,0,de.width,de.height,he,De,de.data):t.texImage2D(r.TEXTURE_2D,Q,fe,de.width,de.height,0,he,De,de.data)}else if(b.isDataArrayTexture)if(Fe){if(Xe&&t.texStorage3D(r.TEXTURE_2D_ARRAY,le,fe,ee.width,ee.height,ee.depth),N)if(b.layerUpdates.size>0){const Q=c0(ee.width,ee.height,b.format,b.type);for(const ue of b.layerUpdates){const ve=ee.data.subarray(ue*Q/ee.data.BYTES_PER_ELEMENT,(ue+1)*Q/ee.data.BYTES_PER_ELEMENT);t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,ue,ee.width,ee.height,1,he,De,ve)}b.clearLayerUpdates()}else t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,ee.width,ee.height,ee.depth,he,De,ee.data)}else t.texImage3D(r.TEXTURE_2D_ARRAY,0,fe,ee.width,ee.height,ee.depth,0,he,De,ee.data);else if(b.isData3DTexture)Fe?(Xe&&t.texStorage3D(r.TEXTURE_3D,le,fe,ee.width,ee.height,ee.depth),N&&t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,ee.width,ee.height,ee.depth,he,De,ee.data)):t.texImage3D(r.TEXTURE_3D,0,fe,ee.width,ee.height,ee.depth,0,he,De,ee.data);else if(b.isFramebufferTexture){if(Xe)if(Fe)t.texStorage2D(r.TEXTURE_2D,le,fe,ee.width,ee.height);else{let Q=ee.width,ue=ee.height;for(let ve=0;ve<le;ve++)t.texImage2D(r.TEXTURE_2D,ve,fe,Q,ue,0,he,De,null),Q>>=1,ue>>=1}}else if(b.isHTMLTexture){if("texElementImage2D"in r){const Q=r.canvas;if(Q.hasAttribute("layoutsubtree")||Q.setAttribute("layoutsubtree","true"),ee.parentNode!==Q){Q.appendChild(ee),d.add(b),Q.onpaint=ue=>{const ve=ue.changedElements;for(const te of d)ve.includes(te.image)&&(te.needsUpdate=!0)},Q.requestPaint();return}if(r.texElementImage2D.length===3)r.texElementImage2D(r.TEXTURE_2D,r.RGBA8,ee);else{const ve=r.RGBA,te=r.RGBA,Ae=r.UNSIGNED_BYTE;r.texElementImage2D(r.TEXTURE_2D,0,ve,te,Ae,ee)}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(Le.length>0){if(Fe&&Xe){const Q=ft(Le[0]);t.texStorage2D(r.TEXTURE_2D,le,fe,Q.width,Q.height)}for(let Q=0,ue=Le.length;Q<ue;Q++)de=Le[Q],Fe?N&&t.texSubImage2D(r.TEXTURE_2D,Q,0,0,he,De,de):t.texImage2D(r.TEXTURE_2D,Q,fe,he,De,de);b.generateMipmaps=!1}else if(Fe){if(Xe){const Q=ft(ee);t.texStorage2D(r.TEXTURE_2D,le,fe,Q.width,Q.height)}N&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,he,De,ee)}else t.texImage2D(r.TEXTURE_2D,0,fe,he,De,ee);g(b)&&x(q),ce.__version=se.version,b.onUpdate&&b.onUpdate(b)}C.__version=b.version}function Ee(C,b,H){if(b.image.length!==6)return;const q=K(C,b),Z=b.source;t.bindTexture(r.TEXTURE_CUBE_MAP,C.__webglTexture,r.TEXTURE0+H);const se=i.get(Z);if(Z.version!==se.__version||q===!0){t.activeTexture(r.TEXTURE0+H);const ce=tt.getPrimaries(tt.workingColorSpace),J=b.colorSpace===Ps?null:tt.getPrimaries(b.colorSpace),ee=b.colorSpace===Ps||ce===J?r.NONE:r.BROWSER_DEFAULT_WEBGL;t.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,b.flipY),t.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),t.pixelStorei(r.UNPACK_ALIGNMENT,b.unpackAlignment),t.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,ee);const he=b.isCompressedTexture||b.image[0].isCompressedTexture,De=b.image[0]&&b.image[0].isDataTexture,fe=[];for(let te=0;te<6;te++)!he&&!De?fe[te]=m(b.image[te],!0,n.maxCubemapSize):fe[te]=De?b.image[te].image:b.image[te],fe[te]=Li(b,fe[te]);const de=fe[0],Le=s.convert(b.format,b.colorSpace),Fe=s.convert(b.type),Xe=w(b.internalFormat,Le,Fe,b.normalized,b.colorSpace),N=b.isVideoTexture!==!0,le=se.__version===void 0||q===!0,Q=Z.dataReady;let ue=_(b,de);He(r.TEXTURE_CUBE_MAP,b);let ve;if(he){N&&le&&t.texStorage2D(r.TEXTURE_CUBE_MAP,ue,Xe,de.width,de.height);for(let te=0;te<6;te++){ve=fe[te].mipmaps;for(let Ae=0;Ae<ve.length;Ae++){const Me=ve[Ae];b.format!==Ti?Le!==null?N?Q&&t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae,0,0,Me.width,Me.height,Le,Me.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae,Xe,Me.width,Me.height,0,Me.data):_e("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):N?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae,0,0,Me.width,Me.height,Le,Fe,Me.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae,Xe,Me.width,Me.height,0,Le,Fe,Me.data)}}}else{if(ve=b.mipmaps,N&&le){ve.length>0&&ue++;const te=ft(fe[0]);t.texStorage2D(r.TEXTURE_CUBE_MAP,ue,Xe,te.width,te.height)}for(let te=0;te<6;te++)if(De){N?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,fe[te].width,fe[te].height,Le,Fe,fe[te].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Xe,fe[te].width,fe[te].height,0,Le,Fe,fe[te].data);for(let Ae=0;Ae<ve.length;Ae++){const Gt=ve[Ae].image[te].image;N?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae+1,0,0,Gt.width,Gt.height,Le,Fe,Gt.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae+1,Xe,Gt.width,Gt.height,0,Le,Fe,Gt.data)}}else{N?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,Le,Fe,fe[te]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Xe,Le,Fe,fe[te]);for(let Ae=0;Ae<ve.length;Ae++){const Me=ve[Ae];N?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae+1,0,0,Le,Fe,Me.image[te]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae+1,Xe,Le,Fe,Me.image[te])}}}g(b)&&x(r.TEXTURE_CUBE_MAP),se.__version=Z.version,b.onUpdate&&b.onUpdate(b)}C.__version=b.version}function Pe(C,b,H,q,Z,se){const ce=s.convert(H.format,H.colorSpace),J=s.convert(H.type),ee=w(H.internalFormat,ce,J,H.normalized,H.colorSpace),he=i.get(b),De=i.get(H);if(De.__renderTarget=b,!he.__hasExternalTextures){const fe=Math.max(1,b.width>>se),de=Math.max(1,b.height>>se);Z===r.TEXTURE_3D||Z===r.TEXTURE_2D_ARRAY?t.texImage3D(Z,se,ee,fe,de,b.depth,0,ce,J,null):t.texImage2D(Z,se,ee,fe,de,0,ce,J,null)}t.bindFramebuffer(r.FRAMEBUFFER,C),Zt(b)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,q,Z,De.__webglTexture,0,Ht(b)):(Z===r.TEXTURE_2D||Z>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&Z<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,q,Z,De.__webglTexture,se),t.bindFramebuffer(r.FRAMEBUFFER,null)}function Ie(C,b,H){if(r.bindRenderbuffer(r.RENDERBUFFER,C),b.depthBuffer){const q=b.depthTexture,Z=q&&q.isDepthTexture?q.type:null,se=S(b.stencilBuffer,Z),ce=b.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;Zt(b)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Ht(b),se,b.width,b.height):H?r.renderbufferStorageMultisample(r.RENDERBUFFER,Ht(b),se,b.width,b.height):r.renderbufferStorage(r.RENDERBUFFER,se,b.width,b.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,ce,r.RENDERBUFFER,C)}else{const q=b.textures;for(let Z=0;Z<q.length;Z++){const se=q[Z],ce=s.convert(se.format,se.colorSpace),J=s.convert(se.type),ee=w(se.internalFormat,ce,J,se.normalized,se.colorSpace);Zt(b)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Ht(b),ee,b.width,b.height):H?r.renderbufferStorageMultisample(r.RENDERBUFFER,Ht(b),ee,b.width,b.height):r.renderbufferStorage(r.RENDERBUFFER,ee,b.width,b.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function be(C,b,H){const q=b.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(r.FRAMEBUFFER,C),!(b.depthTexture&&b.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const Z=i.get(b.depthTexture);if(Z.__renderTarget=b,(!Z.__webglTexture||b.depthTexture.image.width!==b.width||b.depthTexture.image.height!==b.height)&&(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0),q){if(Z.__webglInit===void 0&&(Z.__webglInit=!0,b.depthTexture.addEventListener("dispose",D)),Z.__webglTexture===void 0){Z.__webglTexture=r.createTexture(),t.bindTexture(r.TEXTURE_CUBE_MAP,Z.__webglTexture),He(r.TEXTURE_CUBE_MAP,b.depthTexture);const he=s.convert(b.depthTexture.format),De=s.convert(b.depthTexture.type);let fe;b.depthTexture.format===ds?fe=r.DEPTH_COMPONENT24:b.depthTexture.format===lr&&(fe=r.DEPTH24_STENCIL8);for(let de=0;de<6;de++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,fe,b.width,b.height,0,he,De,null)}}else V(b.depthTexture,0);const se=Z.__webglTexture,ce=Ht(b),J=q?r.TEXTURE_CUBE_MAP_POSITIVE_X+H:r.TEXTURE_2D,ee=b.depthTexture.format===lr?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;if(b.depthTexture.format===ds)Zt(b)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,ee,J,se,0,ce):r.framebufferTexture2D(r.FRAMEBUFFER,ee,J,se,0);else if(b.depthTexture.format===lr)Zt(b)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,ee,J,se,0,ce):r.framebufferTexture2D(r.FRAMEBUFFER,ee,J,se,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function ke(C){const b=i.get(C),H=C.isWebGLCubeRenderTarget===!0;if(b.__boundDepthTexture!==C.depthTexture){const q=C.depthTexture;if(b.__depthDisposeCallback&&b.__depthDisposeCallback(),q){const Z=()=>{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,q.removeEventListener("dispose",Z)};q.addEventListener("dispose",Z),b.__depthDisposeCallback=Z}b.__boundDepthTexture=q}if(C.depthTexture&&!b.__autoAllocateDepthBuffer)if(H)for(let q=0;q<6;q++)be(b.__webglFramebuffer[q],C,q);else{const q=C.texture.mipmaps;q&&q.length>0?be(b.__webglFramebuffer[0],C,0):be(b.__webglFramebuffer,C,0)}else if(H){b.__webglDepthbuffer=[];for(let q=0;q<6;q++)if(t.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer[q]),b.__webglDepthbuffer[q]===void 0)b.__webglDepthbuffer[q]=r.createRenderbuffer(),Ie(b.__webglDepthbuffer[q],C,!1);else{const Z=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,se=b.__webglDepthbuffer[q];r.bindRenderbuffer(r.RENDERBUFFER,se),r.framebufferRenderbuffer(r.FRAMEBUFFER,Z,r.RENDERBUFFER,se)}}else{const q=C.texture.mipmaps;if(q&&q.length>0?t.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer[0]):t.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=r.createRenderbuffer(),Ie(b.__webglDepthbuffer,C,!1);else{const Z=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,se=b.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,se),r.framebufferRenderbuffer(r.FRAMEBUFFER,Z,r.RENDERBUFFER,se)}}t.bindFramebuffer(r.FRAMEBUFFER,null)}function Ne(C,b,H){const q=i.get(C);b!==void 0&&Pe(q.__webglFramebuffer,C,C.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),H!==void 0&&ke(C)}function Oe(C){const b=C.texture,H=i.get(C),q=i.get(b);C.addEventListener("dispose",y);const Z=C.textures,se=C.isWebGLCubeRenderTarget===!0,ce=Z.length>1;if(ce||(q.__webglTexture===void 0&&(q.__webglTexture=r.createTexture()),q.__version=b.version,a.memory.textures++),se){H.__webglFramebuffer=[];for(let J=0;J<6;J++)if(b.mipmaps&&b.mipmaps.length>0){H.__webglFramebuffer[J]=[];for(let ee=0;ee<b.mipmaps.length;ee++)H.__webglFramebuffer[J][ee]=r.createFramebuffer()}else H.__webglFramebuffer[J]=r.createFramebuffer()}else{if(b.mipmaps&&b.mipmaps.length>0){H.__webglFramebuffer=[];for(let J=0;J<b.mipmaps.length;J++)H.__webglFramebuffer[J]=r.createFramebuffer()}else H.__webglFramebuffer=r.createFramebuffer();if(ce)for(let J=0,ee=Z.length;J<ee;J++){const he=i.get(Z[J]);he.__webglTexture===void 0&&(he.__webglTexture=r.createTexture(),a.memory.textures++)}if(C.samples>0&&Zt(C)===!1){H.__webglMultisampledFramebuffer=r.createFramebuffer(),H.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,H.__webglMultisampledFramebuffer);for(let J=0;J<Z.length;J++){const ee=Z[J];H.__webglColorRenderbuffer[J]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,H.__webglColorRenderbuffer[J]);const he=s.convert(ee.format,ee.colorSpace),De=s.convert(ee.type),fe=w(ee.internalFormat,he,De,ee.normalized,ee.colorSpace,C.isXRRenderTarget===!0),de=Ht(C);r.renderbufferStorageMultisample(r.RENDERBUFFER,de,fe,C.width,C.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+J,r.RENDERBUFFER,H.__webglColorRenderbuffer[J])}r.bindRenderbuffer(r.RENDERBUFFER,null),C.depthBuffer&&(H.__webglDepthRenderbuffer=r.createRenderbuffer(),Ie(H.__webglDepthRenderbuffer,C,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(se){t.bindTexture(r.TEXTURE_CUBE_MAP,q.__webglTexture),He(r.TEXTURE_CUBE_MAP,b);for(let J=0;J<6;J++)if(b.mipmaps&&b.mipmaps.length>0)for(let ee=0;ee<b.mipmaps.length;ee++)Pe(H.__webglFramebuffer[J][ee],C,b,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+J,ee);else Pe(H.__webglFramebuffer[J],C,b,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0);g(b)&&x(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ce){for(let J=0,ee=Z.length;J<ee;J++){const he=Z[J],De=i.get(he);let fe=r.TEXTURE_2D;(C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(fe=C.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(fe,De.__webglTexture),He(fe,he),Pe(H.__webglFramebuffer,C,he,r.COLOR_ATTACHMENT0+J,fe,0),g(he)&&x(fe)}t.unbindTexture()}else{let J=r.TEXTURE_2D;if((C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(J=C.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(J,q.__webglTexture),He(J,b),b.mipmaps&&b.mipmaps.length>0)for(let ee=0;ee<b.mipmaps.length;ee++)Pe(H.__webglFramebuffer[ee],C,b,r.COLOR_ATTACHMENT0,J,ee);else Pe(H.__webglFramebuffer,C,b,r.COLOR_ATTACHMENT0,J,0);g(b)&&x(J),t.unbindTexture()}C.depthBuffer&&ke(C)}function dt(C){const b=C.textures;for(let H=0,q=b.length;H<q;H++){const Z=b[H];if(g(Z)){const se=M(C),ce=i.get(Z).__webglTexture;t.bindTexture(se,ce),x(se),t.unbindTexture()}}}const ut=[],zt=[];function It(C){if(C.samples>0){if(Zt(C)===!1){const b=C.textures,H=C.width,q=C.height;let Z=r.COLOR_BUFFER_BIT;const se=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ce=i.get(C),J=b.length>1;if(J)for(let he=0;he<b.length;he++)t.bindFramebuffer(r.FRAMEBUFFER,ce.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+he,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,ce.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+he,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,ce.__webglMultisampledFramebuffer);const ee=C.texture.mipmaps;ee&&ee.length>0?t.bindFramebuffer(r.DRAW_FRAMEBUFFER,ce.__webglFramebuffer[0]):t.bindFramebuffer(r.DRAW_FRAMEBUFFER,ce.__webglFramebuffer);for(let he=0;he<b.length;he++){if(C.resolveDepthBuffer&&(C.depthBuffer&&(Z|=r.DEPTH_BUFFER_BIT),C.stencilBuffer&&C.resolveStencilBuffer&&(Z|=r.STENCIL_BUFFER_BIT)),J){r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,ce.__webglColorRenderbuffer[he]);const De=i.get(b[he]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,De,0)}r.blitFramebuffer(0,0,H,q,0,0,H,q,Z,r.NEAREST),l===!0&&(ut.length=0,zt.length=0,ut.push(r.COLOR_ATTACHMENT0+he),C.depthBuffer&&C.resolveDepthBuffer===!1&&(ut.push(se),zt.push(se),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,zt)),r.invalidateFramebuffer(r.READ_FRAMEBUFFER,ut))}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),J)for(let he=0;he<b.length;he++){t.bindFramebuffer(r.FRAMEBUFFER,ce.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+he,r.RENDERBUFFER,ce.__webglColorRenderbuffer[he]);const De=i.get(b[he]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,ce.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+he,r.TEXTURE_2D,De,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,ce.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.resolveDepthBuffer===!1&&l){const b=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[b])}}}function Ht(C){return Math.min(n.maxSamples,C.samples)}function Zt(C){const b=i.get(C);return C.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&b.__useRenderToTexture!==!1}function O(C){const b=a.render.frame;h.get(C)!==b&&(h.set(C,b),C.update())}function Li(C,b){const H=C.colorSpace,q=C.format,Z=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||H!==hc&&H!==Ps&&(tt.getTransfer(H)===pt?(q!==Ti||Z!==$i)&&_e("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ue("WebGLTextures: Unsupported texture color space:",H)),b}function ft(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=B,this.resetTextureUnits=k,this.getTextureUnits=z,this.setTextureUnits=L,this.setTexture2D=V,this.setTexture2DArray=j,this.setTexture3D=$,this.setTextureCube=ie,this.rebindTextures=Ne,this.setupRenderTarget=Oe,this.updateRenderTargetMipmap=dt,this.updateMultisampleRenderTarget=It,this.setupDepthRenderbuffer=ke,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=Zt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function b3(r,e){function t(i,n=Ps){let s;const a=tt.getTransfer(n);if(i===$i)return r.UNSIGNED_BYTE;if(i===Ju)return r.UNSIGNED_SHORT_4_4_4_4;if(i===ju)return r.UNSIGNED_SHORT_5_5_5_1;if(i===kg)return r.UNSIGNED_INT_5_9_9_9_REV;if(i===Ng)return r.UNSIGNED_INT_10F_11F_11F_REV;if(i===Pg)return r.BYTE;if(i===Lg)return r.SHORT;if(i===Do)return r.UNSIGNED_SHORT;if(i===Zu)return r.INT;if(i===yn)return r.UNSIGNED_INT;if(i===Pi)return r.FLOAT;if(i===ui)return r.HALF_FLOAT;if(i===Og)return r.ALPHA;if(i===Fg)return r.RGB;if(i===Ti)return r.RGBA;if(i===ds)return r.DEPTH_COMPONENT;if(i===lr)return r.DEPTH_STENCIL;if(i===Pc)return r.RED;if(i===Qu)return r.RED_INTEGER;if(i===vr)return r.RG;if(i===ef)return r.RG_INTEGER;if(i===tf)return r.RGBA_INTEGER;if(i===ql||i===Yl||i===Kl||i===$l)if(a===pt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===ql)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Yl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Kl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===$l)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===ql)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Yl)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Kl)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===$l)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Rd||i===Pd||i===Ld||i===kd)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Rd)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Pd)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ld)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===kd)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Nd||i===Od||i===Fd||i===Ud||i===Bd||i===ac||i===zd)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Nd||i===Od)return a===pt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Fd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Ud)return s.COMPRESSED_R11_EAC;if(i===Bd)return s.COMPRESSED_SIGNED_R11_EAC;if(i===ac)return s.COMPRESSED_RG11_EAC;if(i===zd)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Hd||i===Gd||i===Vd||i===Wd||i===Xd||i===qd||i===Yd||i===Kd||i===$d||i===Zd||i===Jd||i===jd||i===Qd||i===eu)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Hd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Gd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Vd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Wd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Xd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===qd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Yd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Kd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===$d)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Zd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Jd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===jd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Qd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===eu)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===tu||i===iu||i===nu)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===tu)return a===pt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===iu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===nu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===su||i===ru||i===oc||i===au)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===su)return s.COMPRESSED_RED_RGTC1_EXT;if(i===ru)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===oc)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===au)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Co?r.UNSIGNED_INT_24_8:r[i]!==void 0?r[i]:null}return{convert:t}}const w3=`
6195
+ }`,p3=[new P(1,0,0),new P(-1,0,0),new P(0,1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1)],m3=[new P(0,-1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1),new P(0,-1,0),new P(0,-1,0)],P0=new Ye,$a=new P,Ph=new P;function g3(r,e,t){let i=new cf;const n=new Te,s=new Te,a=new at,o=new nb,l=new sb,c={},h=t.maxTextureSize,d={[Bs]:Ft,[Ft]:Bs,[pn]:pn},u=new Ot({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Te},radius:{value:4}},vertexShader:u3,fragmentShader:f3}),f=u.clone();f.defines.HORIZONTAL_PASS=1;const p=new Tt;p.setAttribute("position",new ht(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new We(p,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=po;let g=this.type;this.render=function(_,D,y){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||_.length===0)return;this.type===S2&&(_e("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=po);const T=r.getRenderTarget(),A=r.getActiveCubeFace(),I=r.getActiveMipmapLevel(),R=r.state;R.setBlending(Vn),R.buffers.depth.getReversed()===!0?R.buffers.color.setClear(0,0,0,0):R.buffers.color.setClear(1,1,1,1),R.buffers.depth.setTest(!0),R.setScissorTest(!1);const k=g!==this.type;k&&D.traverse(function(z){z.material&&(Array.isArray(z.material)?z.material.forEach(L=>L.needsUpdate=!0):z.material.needsUpdate=!0)});for(let z=0,L=_.length;z<L;z++){const B=_[z],F=B.shadow;if(F===void 0){_e("WebGLShadowMap:",B,"has no shadow.");continue}if(F.autoUpdate===!1&&F.needsUpdate===!1)continue;n.copy(F.mapSize);const V=F.getFrameExtents();n.multiply(V),s.copy(F.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(s.x=Math.floor(h/V.x),n.x=s.x*V.x,F.mapSize.x=s.x),n.y>h&&(s.y=Math.floor(h/V.y),n.y=s.y*V.y,F.mapSize.y=s.y));const j=r.state.buffers.depth.getReversed();if(F.camera._reversedDepth=j,F.map===null||k===!0){if(F.map!==null&&(F.map.depthTexture!==null&&(F.map.depthTexture.dispose(),F.map.depthTexture=null),F.map.dispose()),this.type===ro){if(B.isPointLight){_e("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}F.map=new vi(n.x,n.y,{format:vr,type:ui,minFilter:vt,magFilter:vt,generateMipmaps:!1}),F.map.texture.name=B.name+".shadowMap",F.map.depthTexture=new yr(n.x,n.y,Pi),F.map.depthTexture.name=B.name+".shadowMapDepth",F.map.depthTexture.format=ds,F.map.depthTexture.compareFunction=null,F.map.depthTexture.minFilter=Nt,F.map.depthTexture.magFilter=Nt}else B.isPointLight?(F.map=new i1(n.x),F.map.depthTexture=new Jy(n.x,yn)):(F.map=new vi(n.x,n.y),F.map.depthTexture=new yr(n.x,n.y,yn)),F.map.depthTexture.name=B.name+".shadowMap",F.map.depthTexture.format=ds,this.type===po?(F.map.depthTexture.compareFunction=j?sf:nf,F.map.depthTexture.minFilter=vt,F.map.depthTexture.magFilter=vt):(F.map.depthTexture.compareFunction=null,F.map.depthTexture.minFilter=Nt,F.map.depthTexture.magFilter=Nt);F.camera.updateProjectionMatrix()}const $=F.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie<$;ie++){if(F.map.isWebGLCubeRenderTarget)r.setRenderTarget(F.map,ie),r.clear();else{ie===0&&(r.setRenderTarget(F.map),r.clear());const ae=F.getViewport(ie);a.set(s.x*ae.x,s.y*ae.y,s.x*ae.z,s.y*ae.w),R.viewport(a)}if(B.isPointLight){const ae=F.camera,Ve=F.matrix,je=B.distance||ae.far;je!==ae.far&&(ae.far=je,ae.updateProjectionMatrix()),$a.setFromMatrixPosition(B.matrixWorld),ae.position.copy($a),Ph.copy(ae.position),Ph.add(p3[ie]),ae.up.copy(m3[ie]),ae.lookAt(Ph),ae.updateMatrixWorld(),Ve.makeTranslation(-$a.x,-$a.y,-$a.z),P0.multiplyMatrices(ae.projectionMatrix,ae.matrixWorldInverse),F._frustum.setFromProjectionMatrix(P0,ae.coordinateSystem,ae.reversedDepth)}else F.updateMatrices(B);i=F.getFrustum(),w(D,y,F.camera,B,this.type)}F.isPointLightShadow!==!0&&this.type===ro&&x(F,y),F.needsUpdate=!1}g=this.type,m.needsUpdate=!1,r.setRenderTarget(T,A,I)};function x(_,D){const y=e.update(v);u.defines.VSM_SAMPLES!==_.blurSamples&&(u.defines.VSM_SAMPLES=_.blurSamples,f.defines.VSM_SAMPLES=_.blurSamples,u.needsUpdate=!0,f.needsUpdate=!0),_.mapPass===null&&(_.mapPass=new vi(n.x,n.y,{format:vr,type:ui})),u.uniforms.shadow_pass.value=_.map.depthTexture,u.uniforms.resolution.value=_.mapSize,u.uniforms.radius.value=_.radius,r.setRenderTarget(_.mapPass),r.clear(),r.renderBufferDirect(D,null,y,u,v,null),f.uniforms.shadow_pass.value=_.mapPass.texture,f.uniforms.resolution.value=_.mapSize,f.uniforms.radius.value=_.radius,r.setRenderTarget(_.map),r.clear(),r.renderBufferDirect(D,null,y,f,v,null)}function M(_,D,y,T){let A=null;const I=y.isPointLight===!0?_.customDistanceMaterial:_.customDepthMaterial;if(I!==void 0)A=I;else if(A=y.isPointLight===!0?l:o,r.localClippingEnabled&&D.clipShadows===!0&&Array.isArray(D.clippingPlanes)&&D.clippingPlanes.length!==0||D.displacementMap&&D.displacementScale!==0||D.alphaMap&&D.alphaTest>0||D.map&&D.alphaTest>0||D.alphaToCoverage===!0){const R=A.uuid,k=D.uuid;let z=c[R];z===void 0&&(z={},c[R]=z);let L=z[k];L===void 0&&(L=A.clone(),z[k]=L,D.addEventListener("dispose",S)),A=L}if(A.visible=D.visible,A.wireframe=D.wireframe,T===ro?A.side=D.shadowSide!==null?D.shadowSide:D.side:A.side=D.shadowSide!==null?D.shadowSide:d[D.side],A.alphaMap=D.alphaMap,A.alphaTest=D.alphaToCoverage===!0?.5:D.alphaTest,A.map=D.map,A.clipShadows=D.clipShadows,A.clippingPlanes=D.clippingPlanes,A.clipIntersection=D.clipIntersection,A.displacementMap=D.displacementMap,A.displacementScale=D.displacementScale,A.displacementBias=D.displacementBias,A.wireframeLinewidth=D.wireframeLinewidth,A.linewidth=D.linewidth,y.isPointLight===!0&&A.isMeshDistanceMaterial===!0){const R=r.properties.get(A);R.light=y}return A}function w(_,D,y,T,A){if(_.visible===!1)return;if(_.layers.test(D.layers)&&(_.isMesh||_.isLine||_.isPoints)&&(_.castShadow||_.receiveShadow&&A===ro)&&(!_.frustumCulled||i.intersectsObject(_))){_.modelViewMatrix.multiplyMatrices(y.matrixWorldInverse,_.matrixWorld);const k=e.update(_),z=_.material;if(Array.isArray(z)){const L=k.groups;for(let B=0,F=L.length;B<F;B++){const V=L[B],j=z[V.materialIndex];if(j&&j.visible){const $=M(_,j,T,A);_.onBeforeShadow(r,_,D,y,k,$,V),r.renderBufferDirect(y,null,k,$,_,V),_.onAfterShadow(r,_,D,y,k,$,V)}}}else if(z.visible){const L=M(_,z,T,A);_.onBeforeShadow(r,_,D,y,k,L,null),r.renderBufferDirect(y,null,k,L,_,null),_.onAfterShadow(r,_,D,y,k,L,null)}}const R=_.children;for(let k=0,z=R.length;k<z;k++)w(R[k],D,y,T,A)}function S(_){_.target.removeEventListener("dispose",S);for(const y in c){const T=c[y],A=_.target.uuid;A in T&&(T[A].dispose(),delete T[A])}}}function v3(r,e){function t(){let N=!1;const le=new at;let Q=null;const ue=new at(0,0,0,0);return{setMask:function(ve){Q!==ve&&!N&&(r.colorMask(ve,ve,ve,ve),Q=ve)},setLocked:function(ve){N=ve},setClear:function(ve,te,Ae,Me,Gt){Gt===!0&&(ve*=Me,te*=Me,Ae*=Me),le.set(ve,te,Ae,Me),ue.equals(le)===!1&&(r.clearColor(ve,te,Ae,Me),ue.copy(le))},reset:function(){N=!1,Q=null,ue.set(-1,0,0,0)}}}function i(){let N=!1,le=!1,Q=null,ue=null,ve=null;return{setReversed:function(te){if(le!==te){const Ae=e.get("EXT_clip_control");te?Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.ZERO_TO_ONE_EXT):Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.NEGATIVE_ONE_TO_ONE_EXT),le=te;const Me=ve;ve=null,this.setClear(Me)}},getReversed:function(){return le},setTest:function(te){te?ne(r.DEPTH_TEST):G(r.DEPTH_TEST)},setMask:function(te){Q!==te&&!N&&(r.depthMask(te),Q=te)},setFunc:function(te){if(le&&(te=ry[te]),ue!==te){switch(te){case Sd:r.depthFunc(r.NEVER);break;case Ed:r.depthFunc(r.ALWAYS);break;case _d:r.depthFunc(r.LESS);break;case Aa:r.depthFunc(r.LEQUAL);break;case Td:r.depthFunc(r.EQUAL);break;case Ad:r.depthFunc(r.GEQUAL);break;case Id:r.depthFunc(r.GREATER);break;case Dd:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}ue=te}},setLocked:function(te){N=te},setClear:function(te){ve!==te&&(ve=te,le&&(te=1-te),r.clearDepth(te))},reset:function(){N=!1,Q=null,ue=null,ve=null,le=!1}}}function n(){let N=!1,le=null,Q=null,ue=null,ve=null,te=null,Ae=null,Me=null,Gt=null;return{setTest:function(xt){N||(xt?ne(r.STENCIL_TEST):G(r.STENCIL_TEST))},setMask:function(xt){le!==xt&&!N&&(r.stencilMask(xt),le=xt)},setFunc:function(xt,xn,Sn){(Q!==xt||ue!==xn||ve!==Sn)&&(r.stencilFunc(xt,xn,Sn),Q=xt,ue=xn,ve=Sn)},setOp:function(xt,xn,Sn){(te!==xt||Ae!==xn||Me!==Sn)&&(r.stencilOp(xt,xn,Sn),te=xt,Ae=xn,Me=Sn)},setLocked:function(xt){N=xt},setClear:function(xt){Gt!==xt&&(r.clearStencil(xt),Gt=xt)},reset:function(){N=!1,le=null,Q=null,ue=null,ve=null,te=null,Ae=null,Me=null,Gt=null}}}const s=new t,a=new i,o=new n,l=new WeakMap,c=new WeakMap;let h={},d={},u={},f=new WeakMap,p=[],v=null,m=!1,g=null,x=null,M=null,w=null,S=null,_=null,D=null,y=new oe(0,0,0),T=0,A=!1,I=null,R=null,k=null,z=null,L=null;const B=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let F=!1,V=0;const j=r.getParameter(r.VERSION);j.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(j)[1]),F=V>=1):j.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),F=V>=2);let $=null,ie={};const ae=r.getParameter(r.SCISSOR_BOX),Ve=r.getParameter(r.VIEWPORT),je=new at().fromArray(ae),Ge=new at().fromArray(Ve);function K(N,le,Q,ue){const ve=new Uint8Array(4),te=r.createTexture();r.bindTexture(N,te),r.texParameteri(N,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(N,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let Ae=0;Ae<Q;Ae++)N===r.TEXTURE_3D||N===r.TEXTURE_2D_ARRAY?r.texImage3D(le,0,r.RGBA,1,1,ue,0,r.RGBA,r.UNSIGNED_BYTE,ve):r.texImage2D(le+Ae,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,ve);return te}const re={};re[r.TEXTURE_2D]=K(r.TEXTURE_2D,r.TEXTURE_2D,1),re[r.TEXTURE_CUBE_MAP]=K(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[r.TEXTURE_2D_ARRAY]=K(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),re[r.TEXTURE_3D]=K(r.TEXTURE_3D,r.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ne(r.DEPTH_TEST),a.setFunc(Aa),dt(!1),ut(up),ne(r.CULL_FACE),Ne(Vn);function ne(N){h[N]!==!0&&(r.enable(N),h[N]=!0)}function G(N){h[N]!==!1&&(r.disable(N),h[N]=!1)}function Ee(N,le){return u[N]!==le?(r.bindFramebuffer(N,le),u[N]=le,N===r.DRAW_FRAMEBUFFER&&(u[r.FRAMEBUFFER]=le),N===r.FRAMEBUFFER&&(u[r.DRAW_FRAMEBUFFER]=le),!0):!1}function Pe(N,le){let Q=p,ue=!1;if(N){Q=f.get(le),Q===void 0&&(Q=[],f.set(le,Q));const ve=N.textures;if(Q.length!==ve.length||Q[0]!==r.COLOR_ATTACHMENT0){for(let te=0,Ae=ve.length;te<Ae;te++)Q[te]=r.COLOR_ATTACHMENT0+te;Q.length=ve.length,ue=!0}}else Q[0]!==r.BACK&&(Q[0]=r.BACK,ue=!0);ue&&r.drawBuffers(Q)}function Ie(N){return v!==N?(r.useProgram(N),v=N,!0):!1}const be={[ir]:r.FUNC_ADD,[_2]:r.FUNC_SUBTRACT,[T2]:r.FUNC_REVERSE_SUBTRACT};be[A2]=r.MIN,be[I2]=r.MAX;const ke={[D2]:r.ZERO,[C2]:r.ONE,[R2]:r.SRC_COLOR,[Md]:r.SRC_ALPHA,[F2]:r.SRC_ALPHA_SATURATE,[N2]:r.DST_COLOR,[L2]:r.DST_ALPHA,[P2]:r.ONE_MINUS_SRC_COLOR,[xd]:r.ONE_MINUS_SRC_ALPHA,[O2]:r.ONE_MINUS_DST_COLOR,[k2]:r.ONE_MINUS_DST_ALPHA,[U2]:r.CONSTANT_COLOR,[B2]:r.ONE_MINUS_CONSTANT_COLOR,[z2]:r.CONSTANT_ALPHA,[H2]:r.ONE_MINUS_CONSTANT_ALPHA};function Ne(N,le,Q,ue,ve,te,Ae,Me,Gt,xt){if(N===Vn){m===!0&&(G(r.BLEND),m=!1);return}if(m===!1&&(ne(r.BLEND),m=!0),N!==E2){if(N!==g||xt!==A){if((x!==ir||S!==ir)&&(r.blendEquation(r.FUNC_ADD),x=ir,S=ir),xt)switch(N){case ma:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Zi:r.blendFunc(r.ONE,r.ONE);break;case fp:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case pp:r.blendFuncSeparate(r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:Ue("WebGLState: Invalid blending: ",N);break}else switch(N){case ma:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Zi:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE,r.ONE,r.ONE);break;case fp:Ue("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case pp:Ue("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ue("WebGLState: Invalid blending: ",N);break}M=null,w=null,_=null,D=null,y.set(0,0,0),T=0,g=N,A=xt}return}ve=ve||le,te=te||Q,Ae=Ae||ue,(le!==x||ve!==S)&&(r.blendEquationSeparate(be[le],be[ve]),x=le,S=ve),(Q!==M||ue!==w||te!==_||Ae!==D)&&(r.blendFuncSeparate(ke[Q],ke[ue],ke[te],ke[Ae]),M=Q,w=ue,_=te,D=Ae),(Me.equals(y)===!1||Gt!==T)&&(r.blendColor(Me.r,Me.g,Me.b,Gt),y.copy(Me),T=Gt),g=N,A=!1}function Oe(N,le){N.side===pn?G(r.CULL_FACE):ne(r.CULL_FACE);let Q=N.side===Ft;le&&(Q=!Q),dt(Q),N.blending===ma&&N.transparent===!1?Ne(Vn):Ne(N.blending,N.blendEquation,N.blendSrc,N.blendDst,N.blendEquationAlpha,N.blendSrcAlpha,N.blendDstAlpha,N.blendColor,N.blendAlpha,N.premultipliedAlpha),a.setFunc(N.depthFunc),a.setTest(N.depthTest),a.setMask(N.depthWrite),s.setMask(N.colorWrite);const ue=N.stencilWrite;o.setTest(ue),ue&&(o.setMask(N.stencilWriteMask),o.setFunc(N.stencilFunc,N.stencilRef,N.stencilFuncMask),o.setOp(N.stencilFail,N.stencilZFail,N.stencilZPass)),It(N.polygonOffset,N.polygonOffsetFactor,N.polygonOffsetUnits),N.alphaToCoverage===!0?ne(r.SAMPLE_ALPHA_TO_COVERAGE):G(r.SAMPLE_ALPHA_TO_COVERAGE)}function dt(N){I!==N&&(N?r.frontFace(r.CW):r.frontFace(r.CCW),I=N)}function ut(N){N!==M2?(ne(r.CULL_FACE),N!==R&&(N===up?r.cullFace(r.BACK):N===x2?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):G(r.CULL_FACE),R=N}function zt(N){N!==k&&(F&&r.lineWidth(N),k=N)}function It(N,le,Q){N?(ne(r.POLYGON_OFFSET_FILL),(z!==le||L!==Q)&&(z=le,L=Q,a.getReversed()&&(le=-le),r.polygonOffset(le,Q))):G(r.POLYGON_OFFSET_FILL)}function Ht(N){N?ne(r.SCISSOR_TEST):G(r.SCISSOR_TEST)}function Zt(N){N===void 0&&(N=r.TEXTURE0+B-1),$!==N&&(r.activeTexture(N),$=N)}function O(N,le,Q){Q===void 0&&($===null?Q=r.TEXTURE0+B-1:Q=$);let ue=ie[Q];ue===void 0&&(ue={type:void 0,texture:void 0},ie[Q]=ue),(ue.type!==N||ue.texture!==le)&&($!==Q&&(r.activeTexture(Q),$=Q),r.bindTexture(N,le||re[N]),ue.type=N,ue.texture=le)}function Li(){const N=ie[$];N!==void 0&&N.type!==void 0&&(r.bindTexture(N.type,null),N.type=void 0,N.texture=void 0)}function ft(){try{r.compressedTexImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function C(){try{r.compressedTexImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function b(){try{r.texSubImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function H(){try{r.texSubImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function q(){try{r.compressedTexSubImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function Z(){try{r.compressedTexSubImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function se(){try{r.texStorage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function ce(){try{r.texStorage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function J(){try{r.texImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function ee(){try{r.texImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function he(N){return d[N]!==void 0?d[N]:r.getParameter(N)}function De(N,le){d[N]!==le&&(r.pixelStorei(N,le),d[N]=le)}function fe(N){je.equals(N)===!1&&(r.scissor(N.x,N.y,N.z,N.w),je.copy(N))}function de(N){Ge.equals(N)===!1&&(r.viewport(N.x,N.y,N.z,N.w),Ge.copy(N))}function Le(N,le){let Q=c.get(le);Q===void 0&&(Q=new WeakMap,c.set(le,Q));let ue=Q.get(N);ue===void 0&&(ue=r.getUniformBlockIndex(le,N.name),Q.set(N,ue))}function Fe(N,le){const ue=c.get(le).get(N);l.get(le)!==ue&&(r.uniformBlockBinding(le,ue,N.__bindingPointIndex),l.set(le,ue))}function Xe(){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={},d={},$=null,ie={},u={},f=new WeakMap,p=[],v=null,m=!1,g=null,x=null,M=null,w=null,S=null,_=null,D=null,y=new oe(0,0,0),T=0,A=!1,I=null,R=null,k=null,z=null,L=null,je.set(0,0,r.canvas.width,r.canvas.height),Ge.set(0,0,r.canvas.width,r.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:ne,disable:G,bindFramebuffer:Ee,drawBuffers:Pe,useProgram:Ie,setBlending:Ne,setMaterial:Oe,setFlipSided:dt,setCullFace:ut,setLineWidth:zt,setPolygonOffset:It,setScissorTest:Ht,activeTexture:Zt,bindTexture:O,unbindTexture:Li,compressedTexImage2D:ft,compressedTexImage3D:C,texImage2D:J,texImage3D:ee,pixelStorei:De,getParameter:he,updateUBOMapping:Le,uniformBlockBinding:Fe,texStorage2D:se,texStorage3D:ce,texSubImage2D:b,texSubImage3D:H,compressedTexSubImage2D:q,compressedTexSubImage3D:Z,scissor:fe,viewport:de,reset:Xe}}function y3(r,e,t,i,n,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Te,h=new WeakMap,d=new Set;let u;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(C,b){return p?new OffscreenCanvas(C,b):Po("canvas")}function m(C,b,H){let q=1;const Z=ft(C);if((Z.width>H||Z.height>H)&&(q=H/Math.max(Z.width,Z.height)),q<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){const se=Math.floor(q*Z.width),ce=Math.floor(q*Z.height);u===void 0&&(u=v(se,ce));const J=b?v(se,ce):u;return J.width=se,J.height=ce,J.getContext("2d").drawImage(C,0,0,se,ce),_e("WebGLRenderer: Texture has been resized from ("+Z.width+"x"+Z.height+") to ("+se+"x"+ce+")."),J}else return"data"in C&&_e("WebGLRenderer: Image in DataTexture is too big ("+Z.width+"x"+Z.height+")."),C;return C}function g(C){return C.generateMipmaps}function x(C){r.generateMipmap(C)}function M(C){return C.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:C.isWebGL3DRenderTarget?r.TEXTURE_3D:C.isWebGLArrayRenderTarget||C.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function w(C,b,H,q,Z,se=!1){if(C!==null){if(r[C]!==void 0)return r[C];_e("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let ce;q&&(ce=e.get("EXT_texture_norm16"),ce||_e("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let J=b;if(b===r.RED&&(H===r.FLOAT&&(J=r.R32F),H===r.HALF_FLOAT&&(J=r.R16F),H===r.UNSIGNED_BYTE&&(J=r.R8),H===r.UNSIGNED_SHORT&&ce&&(J=ce.R16_EXT),H===r.SHORT&&ce&&(J=ce.R16_SNORM_EXT)),b===r.RED_INTEGER&&(H===r.UNSIGNED_BYTE&&(J=r.R8UI),H===r.UNSIGNED_SHORT&&(J=r.R16UI),H===r.UNSIGNED_INT&&(J=r.R32UI),H===r.BYTE&&(J=r.R8I),H===r.SHORT&&(J=r.R16I),H===r.INT&&(J=r.R32I)),b===r.RG&&(H===r.FLOAT&&(J=r.RG32F),H===r.HALF_FLOAT&&(J=r.RG16F),H===r.UNSIGNED_BYTE&&(J=r.RG8),H===r.UNSIGNED_SHORT&&ce&&(J=ce.RG16_EXT),H===r.SHORT&&ce&&(J=ce.RG16_SNORM_EXT)),b===r.RG_INTEGER&&(H===r.UNSIGNED_BYTE&&(J=r.RG8UI),H===r.UNSIGNED_SHORT&&(J=r.RG16UI),H===r.UNSIGNED_INT&&(J=r.RG32UI),H===r.BYTE&&(J=r.RG8I),H===r.SHORT&&(J=r.RG16I),H===r.INT&&(J=r.RG32I)),b===r.RGB_INTEGER&&(H===r.UNSIGNED_BYTE&&(J=r.RGB8UI),H===r.UNSIGNED_SHORT&&(J=r.RGB16UI),H===r.UNSIGNED_INT&&(J=r.RGB32UI),H===r.BYTE&&(J=r.RGB8I),H===r.SHORT&&(J=r.RGB16I),H===r.INT&&(J=r.RGB32I)),b===r.RGBA_INTEGER&&(H===r.UNSIGNED_BYTE&&(J=r.RGBA8UI),H===r.UNSIGNED_SHORT&&(J=r.RGBA16UI),H===r.UNSIGNED_INT&&(J=r.RGBA32UI),H===r.BYTE&&(J=r.RGBA8I),H===r.SHORT&&(J=r.RGBA16I),H===r.INT&&(J=r.RGBA32I)),b===r.RGB&&(H===r.UNSIGNED_SHORT&&ce&&(J=ce.RGB16_EXT),H===r.SHORT&&ce&&(J=ce.RGB16_SNORM_EXT),H===r.UNSIGNED_INT_5_9_9_9_REV&&(J=r.RGB9_E5),H===r.UNSIGNED_INT_10F_11F_11F_REV&&(J=r.R11F_G11F_B10F)),b===r.RGBA){const ee=se?dc:tt.getTransfer(Z);H===r.FLOAT&&(J=r.RGBA32F),H===r.HALF_FLOAT&&(J=r.RGBA16F),H===r.UNSIGNED_BYTE&&(J=ee===pt?r.SRGB8_ALPHA8:r.RGBA8),H===r.UNSIGNED_SHORT&&ce&&(J=ce.RGBA16_EXT),H===r.SHORT&&ce&&(J=ce.RGBA16_SNORM_EXT),H===r.UNSIGNED_SHORT_4_4_4_4&&(J=r.RGBA4),H===r.UNSIGNED_SHORT_5_5_5_1&&(J=r.RGB5_A1)}return(J===r.R16F||J===r.R32F||J===r.RG16F||J===r.RG32F||J===r.RGBA16F||J===r.RGBA32F)&&e.get("EXT_color_buffer_float"),J}function S(C,b){let H;return C?b===null||b===yn||b===Co?H=r.DEPTH24_STENCIL8:b===Pi?H=r.DEPTH32F_STENCIL8:b===Do&&(H=r.DEPTH24_STENCIL8,_e("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===yn||b===Co?H=r.DEPTH_COMPONENT24:b===Pi?H=r.DEPTH_COMPONENT32F:b===Do&&(H=r.DEPTH_COMPONENT16),H}function _(C,b){return g(C)===!0||C.isFramebufferTexture&&C.minFilter!==Nt&&C.minFilter!==vt?Math.log2(Math.max(b.width,b.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?b.mipmaps.length:1}function D(C){const b=C.target;b.removeEventListener("dispose",D),T(b),b.isVideoTexture&&h.delete(b),b.isHTMLTexture&&d.delete(b)}function y(C){const b=C.target;b.removeEventListener("dispose",y),I(b)}function T(C){const b=i.get(C);if(b.__webglInit===void 0)return;const H=C.source,q=f.get(H);if(q){const Z=q[b.__cacheKey];Z.usedTimes--,Z.usedTimes===0&&A(C),Object.keys(q).length===0&&f.delete(H)}i.remove(C)}function A(C){const b=i.get(C);r.deleteTexture(b.__webglTexture);const H=C.source,q=f.get(H);delete q[b.__cacheKey],a.memory.textures--}function I(C){const b=i.get(C);if(C.depthTexture&&(C.depthTexture.dispose(),i.remove(C.depthTexture)),C.isWebGLCubeRenderTarget)for(let q=0;q<6;q++){if(Array.isArray(b.__webglFramebuffer[q]))for(let Z=0;Z<b.__webglFramebuffer[q].length;Z++)r.deleteFramebuffer(b.__webglFramebuffer[q][Z]);else r.deleteFramebuffer(b.__webglFramebuffer[q]);b.__webglDepthbuffer&&r.deleteRenderbuffer(b.__webglDepthbuffer[q])}else{if(Array.isArray(b.__webglFramebuffer))for(let q=0;q<b.__webglFramebuffer.length;q++)r.deleteFramebuffer(b.__webglFramebuffer[q]);else r.deleteFramebuffer(b.__webglFramebuffer);if(b.__webglDepthbuffer&&r.deleteRenderbuffer(b.__webglDepthbuffer),b.__webglMultisampledFramebuffer&&r.deleteFramebuffer(b.__webglMultisampledFramebuffer),b.__webglColorRenderbuffer)for(let q=0;q<b.__webglColorRenderbuffer.length;q++)b.__webglColorRenderbuffer[q]&&r.deleteRenderbuffer(b.__webglColorRenderbuffer[q]);b.__webglDepthRenderbuffer&&r.deleteRenderbuffer(b.__webglDepthRenderbuffer)}const H=C.textures;for(let q=0,Z=H.length;q<Z;q++){const se=i.get(H[q]);se.__webglTexture&&(r.deleteTexture(se.__webglTexture),a.memory.textures--),i.remove(H[q])}i.remove(C)}let R=0;function k(){R=0}function z(){return R}function L(C){R=C}function B(){const C=R;return C>=n.maxTextures&&_e("WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+n.maxTextures),R+=1,C}function F(C){const b=[];return b.push(C.wrapS),b.push(C.wrapT),b.push(C.wrapR||0),b.push(C.magFilter),b.push(C.minFilter),b.push(C.anisotropy),b.push(C.internalFormat),b.push(C.format),b.push(C.type),b.push(C.generateMipmaps),b.push(C.premultiplyAlpha),b.push(C.flipY),b.push(C.unpackAlignment),b.push(C.colorSpace),b.join()}function V(C,b){const H=i.get(C);if(C.isVideoTexture&&O(C),C.isRenderTargetTexture===!1&&C.isExternalTexture!==!0&&C.version>0&&H.__version!==C.version){const q=C.image;if(q===null)_e("WebGLRenderer: Texture marked for update but no image data found.");else if(q.complete===!1)_e("WebGLRenderer: Texture marked for update but image is incomplete");else{G(H,C,b);return}}else C.isExternalTexture&&(H.__webglTexture=C.sourceTexture?C.sourceTexture:null);t.bindTexture(r.TEXTURE_2D,H.__webglTexture,r.TEXTURE0+b)}function j(C,b){const H=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&H.__version!==C.version){G(H,C,b);return}else C.isExternalTexture&&(H.__webglTexture=C.sourceTexture?C.sourceTexture:null);t.bindTexture(r.TEXTURE_2D_ARRAY,H.__webglTexture,r.TEXTURE0+b)}function $(C,b){const H=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&H.__version!==C.version){G(H,C,b);return}t.bindTexture(r.TEXTURE_3D,H.__webglTexture,r.TEXTURE0+b)}function ie(C,b){const H=i.get(C);if(C.isCubeDepthTexture!==!0&&C.version>0&&H.__version!==C.version){Ee(H,C,b);return}t.bindTexture(r.TEXTURE_CUBE_MAP,H.__webglTexture,r.TEXTURE0+b)}const ae={[Io]:r.REPEAT,[Ri]:r.CLAMP_TO_EDGE,[Cd]:r.MIRRORED_REPEAT},Ve={[Nt]:r.NEAREST,[X2]:r.NEAREST_MIPMAP_NEAREST,[Ko]:r.NEAREST_MIPMAP_LINEAR,[vt]:r.LINEAR,[Zc]:r.LINEAR_MIPMAP_NEAREST,[or]:r.LINEAR_MIPMAP_LINEAR},je={[$2]:r.NEVER,[ey]:r.ALWAYS,[Z2]:r.LESS,[nf]:r.LEQUAL,[J2]:r.EQUAL,[sf]:r.GEQUAL,[j2]:r.GREATER,[Q2]:r.NOTEQUAL};function Ge(C,b){if(b.type===Pi&&e.has("OES_texture_float_linear")===!1&&(b.magFilter===vt||b.magFilter===Zc||b.magFilter===Ko||b.magFilter===or||b.minFilter===vt||b.minFilter===Zc||b.minFilter===Ko||b.minFilter===or)&&_e("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(C,r.TEXTURE_WRAP_S,ae[b.wrapS]),r.texParameteri(C,r.TEXTURE_WRAP_T,ae[b.wrapT]),(C===r.TEXTURE_3D||C===r.TEXTURE_2D_ARRAY)&&r.texParameteri(C,r.TEXTURE_WRAP_R,ae[b.wrapR]),r.texParameteri(C,r.TEXTURE_MAG_FILTER,Ve[b.magFilter]),r.texParameteri(C,r.TEXTURE_MIN_FILTER,Ve[b.minFilter]),b.compareFunction&&(r.texParameteri(C,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(C,r.TEXTURE_COMPARE_FUNC,je[b.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===Nt||b.minFilter!==Ko&&b.minFilter!==or||b.type===Pi&&e.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||i.get(b).__currentAnisotropy){const H=e.get("EXT_texture_filter_anisotropic");r.texParameterf(C,H.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,n.getMaxAnisotropy())),i.get(b).__currentAnisotropy=b.anisotropy}}}function K(C,b){let H=!1;C.__webglInit===void 0&&(C.__webglInit=!0,b.addEventListener("dispose",D));const q=b.source;let Z=f.get(q);Z===void 0&&(Z={},f.set(q,Z));const se=F(b);if(se!==C.__cacheKey){Z[se]===void 0&&(Z[se]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,H=!0),Z[se].usedTimes++;const ce=Z[C.__cacheKey];ce!==void 0&&(Z[C.__cacheKey].usedTimes--,ce.usedTimes===0&&A(b)),C.__cacheKey=se,C.__webglTexture=Z[se].texture}return H}function re(C,b,H){return Math.floor(Math.floor(C/H)/b)}function ne(C,b,H,q){const se=C.updateRanges;if(se.length===0)t.texSubImage2D(r.TEXTURE_2D,0,0,0,b.width,b.height,H,q,b.data);else{se.sort((De,fe)=>De.start-fe.start);let ce=0;for(let De=1;De<se.length;De++){const fe=se[ce],de=se[De],Le=fe.start+fe.count,Fe=re(de.start,b.width,4),Xe=re(fe.start,b.width,4);de.start<=Le+1&&Fe===Xe&&re(de.start+de.count-1,b.width,4)===Fe?fe.count=Math.max(fe.count,de.start+de.count-fe.start):(++ce,se[ce]=de)}se.length=ce+1;const J=t.getParameter(r.UNPACK_ROW_LENGTH),ee=t.getParameter(r.UNPACK_SKIP_PIXELS),he=t.getParameter(r.UNPACK_SKIP_ROWS);t.pixelStorei(r.UNPACK_ROW_LENGTH,b.width);for(let De=0,fe=se.length;De<fe;De++){const de=se[De],Le=Math.floor(de.start/4),Fe=Math.ceil(de.count/4),Xe=Le%b.width,N=Math.floor(Le/b.width),le=Fe,Q=1;t.pixelStorei(r.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(r.UNPACK_SKIP_ROWS,N),t.texSubImage2D(r.TEXTURE_2D,0,Xe,N,le,Q,H,q,b.data)}C.clearUpdateRanges(),t.pixelStorei(r.UNPACK_ROW_LENGTH,J),t.pixelStorei(r.UNPACK_SKIP_PIXELS,ee),t.pixelStorei(r.UNPACK_SKIP_ROWS,he)}}function G(C,b,H){let q=r.TEXTURE_2D;(b.isDataArrayTexture||b.isCompressedArrayTexture)&&(q=r.TEXTURE_2D_ARRAY),b.isData3DTexture&&(q=r.TEXTURE_3D);const Z=K(C,b),se=b.source;t.bindTexture(q,C.__webglTexture,r.TEXTURE0+H);const ce=i.get(se);if(se.version!==ce.__version||Z===!0){if(t.activeTexture(r.TEXTURE0+H),(typeof ImageBitmap<"u"&&b.image instanceof ImageBitmap)===!1){const Q=tt.getPrimaries(tt.workingColorSpace),ue=b.colorSpace===Ps?null:tt.getPrimaries(b.colorSpace),ve=b.colorSpace===Ps||Q===ue?r.NONE:r.BROWSER_DEFAULT_WEBGL;t.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,b.flipY),t.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),t.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,ve)}t.pixelStorei(r.UNPACK_ALIGNMENT,b.unpackAlignment);let ee=m(b.image,!1,n.maxTextureSize);ee=Li(b,ee);const he=s.convert(b.format,b.colorSpace),De=s.convert(b.type);let fe=w(b.internalFormat,he,De,b.normalized,b.colorSpace,b.isVideoTexture);Ge(q,b);let de;const Le=b.mipmaps,Fe=b.isVideoTexture!==!0,Xe=ce.__version===void 0||Z===!0,N=se.dataReady,le=_(b,ee);if(b.isDepthTexture)fe=S(b.format===lr,b.type),Xe&&(Fe?t.texStorage2D(r.TEXTURE_2D,1,fe,ee.width,ee.height):t.texImage2D(r.TEXTURE_2D,0,fe,ee.width,ee.height,0,he,De,null));else if(b.isDataTexture)if(Le.length>0){Fe&&Xe&&t.texStorage2D(r.TEXTURE_2D,le,fe,Le[0].width,Le[0].height);for(let Q=0,ue=Le.length;Q<ue;Q++)de=Le[Q],Fe?N&&t.texSubImage2D(r.TEXTURE_2D,Q,0,0,de.width,de.height,he,De,de.data):t.texImage2D(r.TEXTURE_2D,Q,fe,de.width,de.height,0,he,De,de.data);b.generateMipmaps=!1}else Fe?(Xe&&t.texStorage2D(r.TEXTURE_2D,le,fe,ee.width,ee.height),N&&ne(b,ee,he,De)):t.texImage2D(r.TEXTURE_2D,0,fe,ee.width,ee.height,0,he,De,ee.data);else if(b.isCompressedTexture)if(b.isCompressedArrayTexture){Fe&&Xe&&t.texStorage3D(r.TEXTURE_2D_ARRAY,le,fe,Le[0].width,Le[0].height,ee.depth);for(let Q=0,ue=Le.length;Q<ue;Q++)if(de=Le[Q],b.format!==Ti)if(he!==null)if(Fe){if(N)if(b.layerUpdates.size>0){const ve=c0(de.width,de.height,b.format,b.type);for(const te of b.layerUpdates){const Ae=de.data.subarray(te*ve/de.data.BYTES_PER_ELEMENT,(te+1)*ve/de.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,Q,0,0,te,de.width,de.height,1,he,Ae)}b.clearLayerUpdates()}else t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,Q,0,0,0,de.width,de.height,ee.depth,he,de.data)}else t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,Q,fe,de.width,de.height,ee.depth,0,de.data,0,0);else _e("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Fe?N&&t.texSubImage3D(r.TEXTURE_2D_ARRAY,Q,0,0,0,de.width,de.height,ee.depth,he,De,de.data):t.texImage3D(r.TEXTURE_2D_ARRAY,Q,fe,de.width,de.height,ee.depth,0,he,De,de.data)}else{Fe&&Xe&&t.texStorage2D(r.TEXTURE_2D,le,fe,Le[0].width,Le[0].height);for(let Q=0,ue=Le.length;Q<ue;Q++)de=Le[Q],b.format!==Ti?he!==null?Fe?N&&t.compressedTexSubImage2D(r.TEXTURE_2D,Q,0,0,de.width,de.height,he,de.data):t.compressedTexImage2D(r.TEXTURE_2D,Q,fe,de.width,de.height,0,de.data):_e("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Fe?N&&t.texSubImage2D(r.TEXTURE_2D,Q,0,0,de.width,de.height,he,De,de.data):t.texImage2D(r.TEXTURE_2D,Q,fe,de.width,de.height,0,he,De,de.data)}else if(b.isDataArrayTexture)if(Fe){if(Xe&&t.texStorage3D(r.TEXTURE_2D_ARRAY,le,fe,ee.width,ee.height,ee.depth),N)if(b.layerUpdates.size>0){const Q=c0(ee.width,ee.height,b.format,b.type);for(const ue of b.layerUpdates){const ve=ee.data.subarray(ue*Q/ee.data.BYTES_PER_ELEMENT,(ue+1)*Q/ee.data.BYTES_PER_ELEMENT);t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,ue,ee.width,ee.height,1,he,De,ve)}b.clearLayerUpdates()}else t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,ee.width,ee.height,ee.depth,he,De,ee.data)}else t.texImage3D(r.TEXTURE_2D_ARRAY,0,fe,ee.width,ee.height,ee.depth,0,he,De,ee.data);else if(b.isData3DTexture)Fe?(Xe&&t.texStorage3D(r.TEXTURE_3D,le,fe,ee.width,ee.height,ee.depth),N&&t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,ee.width,ee.height,ee.depth,he,De,ee.data)):t.texImage3D(r.TEXTURE_3D,0,fe,ee.width,ee.height,ee.depth,0,he,De,ee.data);else if(b.isFramebufferTexture){if(Xe)if(Fe)t.texStorage2D(r.TEXTURE_2D,le,fe,ee.width,ee.height);else{let Q=ee.width,ue=ee.height;for(let ve=0;ve<le;ve++)t.texImage2D(r.TEXTURE_2D,ve,fe,Q,ue,0,he,De,null),Q>>=1,ue>>=1}}else if(b.isHTMLTexture){if("texElementImage2D"in r){const Q=r.canvas;if(Q.hasAttribute("layoutsubtree")||Q.setAttribute("layoutsubtree","true"),ee.parentNode!==Q){Q.appendChild(ee),d.add(b),Q.onpaint=ue=>{const ve=ue.changedElements;for(const te of d)ve.includes(te.image)&&(te.needsUpdate=!0)},Q.requestPaint();return}if(r.texElementImage2D.length===3)r.texElementImage2D(r.TEXTURE_2D,r.RGBA8,ee);else{const ve=r.RGBA,te=r.RGBA,Ae=r.UNSIGNED_BYTE;r.texElementImage2D(r.TEXTURE_2D,0,ve,te,Ae,ee)}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(Le.length>0){if(Fe&&Xe){const Q=ft(Le[0]);t.texStorage2D(r.TEXTURE_2D,le,fe,Q.width,Q.height)}for(let Q=0,ue=Le.length;Q<ue;Q++)de=Le[Q],Fe?N&&t.texSubImage2D(r.TEXTURE_2D,Q,0,0,he,De,de):t.texImage2D(r.TEXTURE_2D,Q,fe,he,De,de);b.generateMipmaps=!1}else if(Fe){if(Xe){const Q=ft(ee);t.texStorage2D(r.TEXTURE_2D,le,fe,Q.width,Q.height)}N&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,he,De,ee)}else t.texImage2D(r.TEXTURE_2D,0,fe,he,De,ee);g(b)&&x(q),ce.__version=se.version,b.onUpdate&&b.onUpdate(b)}C.__version=b.version}function Ee(C,b,H){if(b.image.length!==6)return;const q=K(C,b),Z=b.source;t.bindTexture(r.TEXTURE_CUBE_MAP,C.__webglTexture,r.TEXTURE0+H);const se=i.get(Z);if(Z.version!==se.__version||q===!0){t.activeTexture(r.TEXTURE0+H);const ce=tt.getPrimaries(tt.workingColorSpace),J=b.colorSpace===Ps?null:tt.getPrimaries(b.colorSpace),ee=b.colorSpace===Ps||ce===J?r.NONE:r.BROWSER_DEFAULT_WEBGL;t.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,b.flipY),t.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),t.pixelStorei(r.UNPACK_ALIGNMENT,b.unpackAlignment),t.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,ee);const he=b.isCompressedTexture||b.image[0].isCompressedTexture,De=b.image[0]&&b.image[0].isDataTexture,fe=[];for(let te=0;te<6;te++)!he&&!De?fe[te]=m(b.image[te],!0,n.maxCubemapSize):fe[te]=De?b.image[te].image:b.image[te],fe[te]=Li(b,fe[te]);const de=fe[0],Le=s.convert(b.format,b.colorSpace),Fe=s.convert(b.type),Xe=w(b.internalFormat,Le,Fe,b.normalized,b.colorSpace),N=b.isVideoTexture!==!0,le=se.__version===void 0||q===!0,Q=Z.dataReady;let ue=_(b,de);Ge(r.TEXTURE_CUBE_MAP,b);let ve;if(he){N&&le&&t.texStorage2D(r.TEXTURE_CUBE_MAP,ue,Xe,de.width,de.height);for(let te=0;te<6;te++){ve=fe[te].mipmaps;for(let Ae=0;Ae<ve.length;Ae++){const Me=ve[Ae];b.format!==Ti?Le!==null?N?Q&&t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae,0,0,Me.width,Me.height,Le,Me.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae,Xe,Me.width,Me.height,0,Me.data):_e("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):N?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae,0,0,Me.width,Me.height,Le,Fe,Me.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae,Xe,Me.width,Me.height,0,Le,Fe,Me.data)}}}else{if(ve=b.mipmaps,N&&le){ve.length>0&&ue++;const te=ft(fe[0]);t.texStorage2D(r.TEXTURE_CUBE_MAP,ue,Xe,te.width,te.height)}for(let te=0;te<6;te++)if(De){N?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,fe[te].width,fe[te].height,Le,Fe,fe[te].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Xe,fe[te].width,fe[te].height,0,Le,Fe,fe[te].data);for(let Ae=0;Ae<ve.length;Ae++){const Gt=ve[Ae].image[te].image;N?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae+1,0,0,Gt.width,Gt.height,Le,Fe,Gt.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae+1,Xe,Gt.width,Gt.height,0,Le,Fe,Gt.data)}}else{N?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,Le,Fe,fe[te]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Xe,Le,Fe,fe[te]);for(let Ae=0;Ae<ve.length;Ae++){const Me=ve[Ae];N?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae+1,0,0,Le,Fe,Me.image[te]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+te,Ae+1,Xe,Le,Fe,Me.image[te])}}}g(b)&&x(r.TEXTURE_CUBE_MAP),se.__version=Z.version,b.onUpdate&&b.onUpdate(b)}C.__version=b.version}function Pe(C,b,H,q,Z,se){const ce=s.convert(H.format,H.colorSpace),J=s.convert(H.type),ee=w(H.internalFormat,ce,J,H.normalized,H.colorSpace),he=i.get(b),De=i.get(H);if(De.__renderTarget=b,!he.__hasExternalTextures){const fe=Math.max(1,b.width>>se),de=Math.max(1,b.height>>se);Z===r.TEXTURE_3D||Z===r.TEXTURE_2D_ARRAY?t.texImage3D(Z,se,ee,fe,de,b.depth,0,ce,J,null):t.texImage2D(Z,se,ee,fe,de,0,ce,J,null)}t.bindFramebuffer(r.FRAMEBUFFER,C),Zt(b)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,q,Z,De.__webglTexture,0,Ht(b)):(Z===r.TEXTURE_2D||Z>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&Z<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,q,Z,De.__webglTexture,se),t.bindFramebuffer(r.FRAMEBUFFER,null)}function Ie(C,b,H){if(r.bindRenderbuffer(r.RENDERBUFFER,C),b.depthBuffer){const q=b.depthTexture,Z=q&&q.isDepthTexture?q.type:null,se=S(b.stencilBuffer,Z),ce=b.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;Zt(b)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Ht(b),se,b.width,b.height):H?r.renderbufferStorageMultisample(r.RENDERBUFFER,Ht(b),se,b.width,b.height):r.renderbufferStorage(r.RENDERBUFFER,se,b.width,b.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,ce,r.RENDERBUFFER,C)}else{const q=b.textures;for(let Z=0;Z<q.length;Z++){const se=q[Z],ce=s.convert(se.format,se.colorSpace),J=s.convert(se.type),ee=w(se.internalFormat,ce,J,se.normalized,se.colorSpace);Zt(b)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Ht(b),ee,b.width,b.height):H?r.renderbufferStorageMultisample(r.RENDERBUFFER,Ht(b),ee,b.width,b.height):r.renderbufferStorage(r.RENDERBUFFER,ee,b.width,b.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function be(C,b,H){const q=b.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(r.FRAMEBUFFER,C),!(b.depthTexture&&b.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const Z=i.get(b.depthTexture);if(Z.__renderTarget=b,(!Z.__webglTexture||b.depthTexture.image.width!==b.width||b.depthTexture.image.height!==b.height)&&(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0),q){if(Z.__webglInit===void 0&&(Z.__webglInit=!0,b.depthTexture.addEventListener("dispose",D)),Z.__webglTexture===void 0){Z.__webglTexture=r.createTexture(),t.bindTexture(r.TEXTURE_CUBE_MAP,Z.__webglTexture),Ge(r.TEXTURE_CUBE_MAP,b.depthTexture);const he=s.convert(b.depthTexture.format),De=s.convert(b.depthTexture.type);let fe;b.depthTexture.format===ds?fe=r.DEPTH_COMPONENT24:b.depthTexture.format===lr&&(fe=r.DEPTH24_STENCIL8);for(let de=0;de<6;de++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,fe,b.width,b.height,0,he,De,null)}}else V(b.depthTexture,0);const se=Z.__webglTexture,ce=Ht(b),J=q?r.TEXTURE_CUBE_MAP_POSITIVE_X+H:r.TEXTURE_2D,ee=b.depthTexture.format===lr?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;if(b.depthTexture.format===ds)Zt(b)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,ee,J,se,0,ce):r.framebufferTexture2D(r.FRAMEBUFFER,ee,J,se,0);else if(b.depthTexture.format===lr)Zt(b)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,ee,J,se,0,ce):r.framebufferTexture2D(r.FRAMEBUFFER,ee,J,se,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function ke(C){const b=i.get(C),H=C.isWebGLCubeRenderTarget===!0;if(b.__boundDepthTexture!==C.depthTexture){const q=C.depthTexture;if(b.__depthDisposeCallback&&b.__depthDisposeCallback(),q){const Z=()=>{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,q.removeEventListener("dispose",Z)};q.addEventListener("dispose",Z),b.__depthDisposeCallback=Z}b.__boundDepthTexture=q}if(C.depthTexture&&!b.__autoAllocateDepthBuffer)if(H)for(let q=0;q<6;q++)be(b.__webglFramebuffer[q],C,q);else{const q=C.texture.mipmaps;q&&q.length>0?be(b.__webglFramebuffer[0],C,0):be(b.__webglFramebuffer,C,0)}else if(H){b.__webglDepthbuffer=[];for(let q=0;q<6;q++)if(t.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer[q]),b.__webglDepthbuffer[q]===void 0)b.__webglDepthbuffer[q]=r.createRenderbuffer(),Ie(b.__webglDepthbuffer[q],C,!1);else{const Z=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,se=b.__webglDepthbuffer[q];r.bindRenderbuffer(r.RENDERBUFFER,se),r.framebufferRenderbuffer(r.FRAMEBUFFER,Z,r.RENDERBUFFER,se)}}else{const q=C.texture.mipmaps;if(q&&q.length>0?t.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer[0]):t.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=r.createRenderbuffer(),Ie(b.__webglDepthbuffer,C,!1);else{const Z=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,se=b.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,se),r.framebufferRenderbuffer(r.FRAMEBUFFER,Z,r.RENDERBUFFER,se)}}t.bindFramebuffer(r.FRAMEBUFFER,null)}function Ne(C,b,H){const q=i.get(C);b!==void 0&&Pe(q.__webglFramebuffer,C,C.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),H!==void 0&&ke(C)}function Oe(C){const b=C.texture,H=i.get(C),q=i.get(b);C.addEventListener("dispose",y);const Z=C.textures,se=C.isWebGLCubeRenderTarget===!0,ce=Z.length>1;if(ce||(q.__webglTexture===void 0&&(q.__webglTexture=r.createTexture()),q.__version=b.version,a.memory.textures++),se){H.__webglFramebuffer=[];for(let J=0;J<6;J++)if(b.mipmaps&&b.mipmaps.length>0){H.__webglFramebuffer[J]=[];for(let ee=0;ee<b.mipmaps.length;ee++)H.__webglFramebuffer[J][ee]=r.createFramebuffer()}else H.__webglFramebuffer[J]=r.createFramebuffer()}else{if(b.mipmaps&&b.mipmaps.length>0){H.__webglFramebuffer=[];for(let J=0;J<b.mipmaps.length;J++)H.__webglFramebuffer[J]=r.createFramebuffer()}else H.__webglFramebuffer=r.createFramebuffer();if(ce)for(let J=0,ee=Z.length;J<ee;J++){const he=i.get(Z[J]);he.__webglTexture===void 0&&(he.__webglTexture=r.createTexture(),a.memory.textures++)}if(C.samples>0&&Zt(C)===!1){H.__webglMultisampledFramebuffer=r.createFramebuffer(),H.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,H.__webglMultisampledFramebuffer);for(let J=0;J<Z.length;J++){const ee=Z[J];H.__webglColorRenderbuffer[J]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,H.__webglColorRenderbuffer[J]);const he=s.convert(ee.format,ee.colorSpace),De=s.convert(ee.type),fe=w(ee.internalFormat,he,De,ee.normalized,ee.colorSpace,C.isXRRenderTarget===!0),de=Ht(C);r.renderbufferStorageMultisample(r.RENDERBUFFER,de,fe,C.width,C.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+J,r.RENDERBUFFER,H.__webglColorRenderbuffer[J])}r.bindRenderbuffer(r.RENDERBUFFER,null),C.depthBuffer&&(H.__webglDepthRenderbuffer=r.createRenderbuffer(),Ie(H.__webglDepthRenderbuffer,C,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(se){t.bindTexture(r.TEXTURE_CUBE_MAP,q.__webglTexture),Ge(r.TEXTURE_CUBE_MAP,b);for(let J=0;J<6;J++)if(b.mipmaps&&b.mipmaps.length>0)for(let ee=0;ee<b.mipmaps.length;ee++)Pe(H.__webglFramebuffer[J][ee],C,b,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+J,ee);else Pe(H.__webglFramebuffer[J],C,b,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0);g(b)&&x(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ce){for(let J=0,ee=Z.length;J<ee;J++){const he=Z[J],De=i.get(he);let fe=r.TEXTURE_2D;(C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(fe=C.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(fe,De.__webglTexture),Ge(fe,he),Pe(H.__webglFramebuffer,C,he,r.COLOR_ATTACHMENT0+J,fe,0),g(he)&&x(fe)}t.unbindTexture()}else{let J=r.TEXTURE_2D;if((C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(J=C.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(J,q.__webglTexture),Ge(J,b),b.mipmaps&&b.mipmaps.length>0)for(let ee=0;ee<b.mipmaps.length;ee++)Pe(H.__webglFramebuffer[ee],C,b,r.COLOR_ATTACHMENT0,J,ee);else Pe(H.__webglFramebuffer,C,b,r.COLOR_ATTACHMENT0,J,0);g(b)&&x(J),t.unbindTexture()}C.depthBuffer&&ke(C)}function dt(C){const b=C.textures;for(let H=0,q=b.length;H<q;H++){const Z=b[H];if(g(Z)){const se=M(C),ce=i.get(Z).__webglTexture;t.bindTexture(se,ce),x(se),t.unbindTexture()}}}const ut=[],zt=[];function It(C){if(C.samples>0){if(Zt(C)===!1){const b=C.textures,H=C.width,q=C.height;let Z=r.COLOR_BUFFER_BIT;const se=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ce=i.get(C),J=b.length>1;if(J)for(let he=0;he<b.length;he++)t.bindFramebuffer(r.FRAMEBUFFER,ce.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+he,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,ce.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+he,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,ce.__webglMultisampledFramebuffer);const ee=C.texture.mipmaps;ee&&ee.length>0?t.bindFramebuffer(r.DRAW_FRAMEBUFFER,ce.__webglFramebuffer[0]):t.bindFramebuffer(r.DRAW_FRAMEBUFFER,ce.__webglFramebuffer);for(let he=0;he<b.length;he++){if(C.resolveDepthBuffer&&(C.depthBuffer&&(Z|=r.DEPTH_BUFFER_BIT),C.stencilBuffer&&C.resolveStencilBuffer&&(Z|=r.STENCIL_BUFFER_BIT)),J){r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,ce.__webglColorRenderbuffer[he]);const De=i.get(b[he]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,De,0)}r.blitFramebuffer(0,0,H,q,0,0,H,q,Z,r.NEAREST),l===!0&&(ut.length=0,zt.length=0,ut.push(r.COLOR_ATTACHMENT0+he),C.depthBuffer&&C.resolveDepthBuffer===!1&&(ut.push(se),zt.push(se),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,zt)),r.invalidateFramebuffer(r.READ_FRAMEBUFFER,ut))}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),J)for(let he=0;he<b.length;he++){t.bindFramebuffer(r.FRAMEBUFFER,ce.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+he,r.RENDERBUFFER,ce.__webglColorRenderbuffer[he]);const De=i.get(b[he]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,ce.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+he,r.TEXTURE_2D,De,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,ce.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.resolveDepthBuffer===!1&&l){const b=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[b])}}}function Ht(C){return Math.min(n.maxSamples,C.samples)}function Zt(C){const b=i.get(C);return C.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&b.__useRenderToTexture!==!1}function O(C){const b=a.render.frame;h.get(C)!==b&&(h.set(C,b),C.update())}function Li(C,b){const H=C.colorSpace,q=C.format,Z=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||H!==hc&&H!==Ps&&(tt.getTransfer(H)===pt?(q!==Ti||Z!==$i)&&_e("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ue("WebGLTextures: Unsupported texture color space:",H)),b}function ft(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=B,this.resetTextureUnits=k,this.getTextureUnits=z,this.setTextureUnits=L,this.setTexture2D=V,this.setTexture2DArray=j,this.setTexture3D=$,this.setTextureCube=ie,this.rebindTextures=Ne,this.setupRenderTarget=Oe,this.updateRenderTargetMipmap=dt,this.updateMultisampleRenderTarget=It,this.setupDepthRenderbuffer=ke,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=Zt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function b3(r,e){function t(i,n=Ps){let s;const a=tt.getTransfer(n);if(i===$i)return r.UNSIGNED_BYTE;if(i===Ju)return r.UNSIGNED_SHORT_4_4_4_4;if(i===ju)return r.UNSIGNED_SHORT_5_5_5_1;if(i===kg)return r.UNSIGNED_INT_5_9_9_9_REV;if(i===Ng)return r.UNSIGNED_INT_10F_11F_11F_REV;if(i===Pg)return r.BYTE;if(i===Lg)return r.SHORT;if(i===Do)return r.UNSIGNED_SHORT;if(i===Zu)return r.INT;if(i===yn)return r.UNSIGNED_INT;if(i===Pi)return r.FLOAT;if(i===ui)return r.HALF_FLOAT;if(i===Og)return r.ALPHA;if(i===Fg)return r.RGB;if(i===Ti)return r.RGBA;if(i===ds)return r.DEPTH_COMPONENT;if(i===lr)return r.DEPTH_STENCIL;if(i===Pc)return r.RED;if(i===Qu)return r.RED_INTEGER;if(i===vr)return r.RG;if(i===ef)return r.RG_INTEGER;if(i===tf)return r.RGBA_INTEGER;if(i===ql||i===Yl||i===Kl||i===$l)if(a===pt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===ql)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Yl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Kl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===$l)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===ql)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Yl)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Kl)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===$l)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Rd||i===Pd||i===Ld||i===kd)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Rd)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Pd)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ld)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===kd)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Nd||i===Od||i===Fd||i===Ud||i===Bd||i===ac||i===zd)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Nd||i===Od)return a===pt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Fd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Ud)return s.COMPRESSED_R11_EAC;if(i===Bd)return s.COMPRESSED_SIGNED_R11_EAC;if(i===ac)return s.COMPRESSED_RG11_EAC;if(i===zd)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Hd||i===Gd||i===Vd||i===Wd||i===Xd||i===qd||i===Yd||i===Kd||i===$d||i===Zd||i===Jd||i===jd||i===Qd||i===eu)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Hd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Gd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Vd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Wd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Xd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===qd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Yd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Kd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===$d)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Zd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Jd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===jd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Qd)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===eu)return a===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===tu||i===iu||i===nu)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===tu)return a===pt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===iu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===nu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===su||i===ru||i===oc||i===au)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===su)return s.COMPRESSED_RED_RGTC1_EXT;if(i===ru)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===oc)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===au)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Co?r.UNSIGNED_INT_24_8:r[i]!==void 0?r[i]:null}return{convert:t}}const w3=`
6196
6196
  void main() {
6197
6197
 
6198
6198
  gl_Position = vec4( position, 1.0 );
@@ -6216,7 +6216,7 @@ void main() {
6216
6216
 
6217
6217
  }
6218
6218
 
6219
- }`;class x3{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new Yg(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Ot({vertexShader:w3,fragmentShader:M3,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new We(new wn(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class S3 extends wr{constructor(e,t){super();const i=this;let n=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,u=null,f=null,p=null;const v=typeof XRWebGLBinding<"u",m=new x3,g={},x=t.getContextAttributes();let M=null,w=null;const S=[],_=[],D=new Te;let y=null;const T=new zi;T.viewport=new at;const A=new zi;A.viewport=new at;const I=[T,A],R=new Eb;let k=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let re=S[K];return re===void 0&&(re=new nh,S[K]=re),re.getTargetRaySpace()},this.getControllerGrip=function(K){let re=S[K];return re===void 0&&(re=new nh,S[K]=re),re.getGripSpace()},this.getHand=function(K){let re=S[K];return re===void 0&&(re=new nh,S[K]=re),re.getHandSpace()};function L(K){const re=_.indexOf(K.inputSource);if(re===-1)return;const ne=S[re];ne!==void 0&&(ne.update(K.inputSource,K.frame,c||a),ne.dispatchEvent({type:K.type,data:K.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",F);for(let K=0;K<S.length;K++){const re=_[K];re!==null&&(_[K]=null,S[K].disconnect(re))}k=null,z=null,m.reset();for(const K in g)delete g[K];e.setRenderTarget(M),f=null,u=null,d=null,n=null,w=null,He.stop(),i.isPresenting=!1,e.setPixelRatio(y),e.setSize(D.width,D.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){s=K,i.isPresenting===!0&&_e("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){o=K,i.isPresenting===!0&&_e("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(K){c=K},this.getBaseLayer=function(){return u!==null?u:f},this.getBinding=function(){return d===null&&v&&(d=new XRWebGLBinding(n,t)),d},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(K){if(n=K,n!==null){if(M=e.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",F),x.xrCompatible!==!0&&await t.makeXRCompatible(),y=e.getPixelRatio(),e.getSize(D),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,G=null,Ee=null;x.depth&&(Ee=x.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=x.stencil?lr:ds,G=x.stencil?Co:yn);const Pe={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:s};d=this.getBinding(),u=d.createProjectionLayer(Pe),n.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),w=new vi(u.textureWidth,u.textureHeight,{format:Ti,type:$i,depthTexture:new yr(u.textureWidth,u.textureHeight,G,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:x.stencil,colorSpace:e.outputColorSpace,samples:x.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const ne={antialias:x.antialias,alpha:!0,depth:x.depth,stencil:x.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,t,ne),n.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),w=new vi(f.framebufferWidth,f.framebufferHeight,{format:Ti,type:$i,colorSpace:e.outputColorSpace,stencilBuffer:x.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}w.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await n.requestReferenceSpace(o),He.setContext(n),He.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function F(K){for(let re=0;re<K.removed.length;re++){const ne=K.removed[re],G=_.indexOf(ne);G>=0&&(_[G]=null,S[G].disconnect(ne))}for(let re=0;re<K.added.length;re++){const ne=K.added[re];let G=_.indexOf(ne);if(G===-1){for(let Pe=0;Pe<S.length;Pe++)if(Pe>=_.length){_.push(ne),G=Pe;break}else if(_[Pe]===null){_[Pe]=ne,G=Pe;break}if(G===-1)break}const Ee=S[G];Ee&&Ee.connect(ne)}}const V=new P,j=new P;function $(K,re,ne){V.setFromMatrixPosition(re.matrixWorld),j.setFromMatrixPosition(ne.matrixWorld);const G=V.distanceTo(j),Ee=re.projectionMatrix.elements,Pe=ne.projectionMatrix.elements,Ie=Ee[14]/(Ee[10]-1),be=Ee[14]/(Ee[10]+1),ke=(Ee[9]+1)/Ee[5],Ne=(Ee[9]-1)/Ee[5],Oe=(Ee[8]-1)/Ee[0],dt=(Pe[8]+1)/Pe[0],ut=Ie*Oe,zt=Ie*dt,It=G/(-Oe+dt),Ht=It*-Oe;if(re.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Ht),K.translateZ(It),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),Ee[10]===-1)K.projectionMatrix.copy(re.projectionMatrix),K.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const Zt=Ie+It,O=be+It,Li=ut-Ht,ft=zt+(G-Ht),C=ke*be/O*Zt,b=Ne*be/O*Zt;K.projectionMatrix.makePerspective(Li,ft,C,b,Zt,O),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function ie(K,re){re===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(re.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(n===null)return;let re=K.near,ne=K.far;m.texture!==null&&(m.depthNear>0&&(re=m.depthNear),m.depthFar>0&&(ne=m.depthFar)),R.near=A.near=T.near=re,R.far=A.far=T.far=ne,(k!==R.near||z!==R.far)&&(n.updateRenderState({depthNear:R.near,depthFar:R.far}),k=R.near,z=R.far),R.layers.mask=K.layers.mask|6,T.layers.mask=R.layers.mask&-5,A.layers.mask=R.layers.mask&-3;const G=K.parent,Ee=R.cameras;ie(R,G);for(let Pe=0;Pe<Ee.length;Pe++)ie(Ee[Pe],G);Ee.length===2?$(R,T,A):R.projectionMatrix.copy(T.projectionMatrix),ae(K,R,G)};function ae(K,re,ne){ne===null?K.matrix.copy(re.matrixWorld):(K.matrix.copy(ne.matrixWorld),K.matrix.invert(),K.matrix.multiply(re.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(re.projectionMatrix),K.projectionMatrixInverse.copy(re.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=Da*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return R},this.getFoveation=function(){if(!(u===null&&f===null))return l},this.setFoveation=function(K){l=K,u!==null&&(u.fixedFoveation=K),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=K)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(R)},this.getCameraTexture=function(K){return g[K]};let Ve=null;function je(K,re){if(h=re.getViewerPose(c||a),p=re,h!==null){const ne=h.views;f!==null&&(e.setRenderTargetFramebuffer(w,f.framebuffer),e.setRenderTarget(w));let G=!1;ne.length!==R.cameras.length&&(R.cameras.length=0,G=!0);for(let be=0;be<ne.length;be++){const ke=ne[be];let Ne=null;if(f!==null)Ne=f.getViewport(ke);else{const dt=d.getViewSubImage(u,ke);Ne=dt.viewport,be===0&&(e.setRenderTargetTextures(w,dt.colorTexture,dt.depthStencilTexture),e.setRenderTarget(w))}let Oe=I[be];Oe===void 0&&(Oe=new zi,Oe.layers.enable(be),Oe.viewport=new at,I[be]=Oe),Oe.matrix.fromArray(ke.transform.matrix),Oe.matrix.decompose(Oe.position,Oe.quaternion,Oe.scale),Oe.projectionMatrix.fromArray(ke.projectionMatrix),Oe.projectionMatrixInverse.copy(Oe.projectionMatrix).invert(),Oe.viewport.set(Ne.x,Ne.y,Ne.width,Ne.height),be===0&&(R.matrix.copy(Oe.matrix),R.matrix.decompose(R.position,R.quaternion,R.scale)),G===!0&&R.cameras.push(Oe)}const Ee=n.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&v){d=i.getBinding();const be=d.getDepthInformation(ne[0]);be&&be.isValid&&be.texture&&m.init(be,n.renderState)}if(Ee&&Ee.includes("camera-access")&&v){e.state.unbindTexture(),d=i.getBinding();for(let be=0;be<ne.length;be++){const ke=ne[be].camera;if(ke){let Ne=g[ke];Ne||(Ne=new Yg,g[ke]=Ne);const Oe=d.getCameraImage(ke);Ne.sourceTexture=Oe}}}}for(let ne=0;ne<S.length;ne++){const G=_[ne],Ee=S[ne];G!==null&&Ee!==void 0&&Ee.update(G,re,c||a)}Ve&&Ve(K,re),re.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:re}),p=null}const He=new e1;He.setAnimationLoop(je),this.setAnimationLoop=function(K){Ve=K},this.dispose=function(){}}}const E3=new Ye,o1=new ze;o1.set(-1,0,0,0,1,0,0,0,1);function _3(r,e){function t(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function i(m,g){g.color.getRGB(m.fogColor.value,Kg(r)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,x,M,w){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),d(m,g)):g.isMeshPhongMaterial?(s(m,g),h(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(s(m,g),u(m,g),g.isMeshPhysicalMaterial&&f(m,g,w)):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?l(m,g,x,M):g.isSpriteMaterial?c(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,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,t(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===Ft&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,t(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===Ft&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,t(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,t(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const x=e.get(g),M=x.envMap,w=x.envMapRotation;M&&(m.envMap.value=M,m.envMapRotation.value.setFromMatrix4(E3.makeRotationFromEuler(w)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(o1),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,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(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,t(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 l(m,g,x,M){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*x,m.scale.value=M*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function c(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,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(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 d(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function u(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,x){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,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===Ft&&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,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=x.texture,m.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(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,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function v(m,g){const x=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(x.matrixWorld),m.nearDistance.value=x.shadow.camera.near,m.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function T3(r,e,t,i){let n={},s={},a=[];const o=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function l(w,S){const _=S.program;i.uniformBlockBinding(w,_)}function c(w,S){let _=n[w.id];_===void 0&&(m(w),_=h(w),n[w.id]=_,w.addEventListener("dispose",x));const D=S.program;i.updateUBOMapping(w,D);const y=e.render.frame;s[w.id]!==y&&(u(w),s[w.id]=y)}function h(w){const S=d();w.__bindingPointIndex=S;const _=r.createBuffer(),D=w.__size,y=w.usage;return r.bindBuffer(r.UNIFORM_BUFFER,_),r.bufferData(r.UNIFORM_BUFFER,D,y),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,S,_),_}function d(){for(let w=0;w<o;w++)if(a.indexOf(w)===-1)return a.push(w),w;return Ue("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(w){const S=n[w.id],_=w.uniforms,D=w.__cache;r.bindBuffer(r.UNIFORM_BUFFER,S);for(let y=0,T=_.length;y<T;y++){const A=_[y];if(Array.isArray(A))for(let I=0,R=A.length;I<R;I++)f(A[I],y,I,D);else f(A,y,0,D)}r.bindBuffer(r.UNIFORM_BUFFER,null)}function f(w,S,_,D){if(v(w,S,_,D)===!0){const y=w.__offset,T=w.value;if(Array.isArray(T)){let A=0;for(let I=0;I<T.length;I++){const R=T[I],k=g(R);p(R,w.__data,A),typeof R!="number"&&typeof R!="boolean"&&!R.isMatrix3&&!ArrayBuffer.isView(R)&&(A+=k.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(T,w.__data,0);r.bufferSubData(r.UNIFORM_BUFFER,y,w.__data)}}function p(w,S,_){typeof w=="number"||typeof w=="boolean"?S[0]=w:w.isMatrix3?(S[0]=w.elements[0],S[1]=w.elements[1],S[2]=w.elements[2],S[3]=0,S[4]=w.elements[3],S[5]=w.elements[4],S[6]=w.elements[5],S[7]=0,S[8]=w.elements[6],S[9]=w.elements[7],S[10]=w.elements[8],S[11]=0):ArrayBuffer.isView(w)?S.set(new w.constructor(w.buffer,w.byteOffset,S.length)):w.toArray(S,_)}function v(w,S,_,D){const y=w.value,T=S+"_"+_;if(D[T]===void 0)return typeof y=="number"||typeof y=="boolean"?D[T]=y:ArrayBuffer.isView(y)?D[T]=y.slice():D[T]=y.clone(),!0;{const A=D[T];if(typeof y=="number"||typeof y=="boolean"){if(A!==y)return D[T]=y,!0}else{if(ArrayBuffer.isView(y))return!0;if(A.equals(y)===!1)return A.copy(y),!0}}return!1}function m(w){const S=w.uniforms;let _=0;const D=16;for(let T=0,A=S.length;T<A;T++){const I=Array.isArray(S[T])?S[T]:[S[T]];for(let R=0,k=I.length;R<k;R++){const z=I[R],L=Array.isArray(z.value)?z.value:[z.value];for(let B=0,F=L.length;B<F;B++){const V=L[B],j=g(V),$=_%D,ie=$%j.boundary,ae=$+ie;_+=ie,ae!==0&&D-ae<j.storage&&(_+=D-ae),z.__data=new Float32Array(j.storage/Float32Array.BYTES_PER_ELEMENT),z.__offset=_,_+=j.storage}}}const y=_%D;return y>0&&(_+=D-y),w.__size=_,w.__cache={},this}function g(w){const S={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(S.boundary=4,S.storage=4):w.isVector2?(S.boundary=8,S.storage=8):w.isVector3||w.isColor?(S.boundary=16,S.storage=12):w.isVector4?(S.boundary=16,S.storage=16):w.isMatrix3?(S.boundary=48,S.storage=48):w.isMatrix4?(S.boundary=64,S.storage=64):w.isTexture?_e("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(w)?(S.boundary=16,S.storage=w.byteLength):_e("WebGLRenderer: Unsupported uniform value type.",w),S}function x(w){const S=w.target;S.removeEventListener("dispose",x);const _=a.indexOf(S.__bindingPointIndex);a.splice(_,1),r.deleteBuffer(n[S.id]),delete n[S.id],delete s[S.id]}function M(){for(const w in n)r.deleteBuffer(n[w]);a=[],n={},s={}}return{bind:l,update:c,dispose:M}}const A3=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 An=null;function I3(){return An===null&&(An=new Mr(A3,16,16,vr,ui),An.name="DFG_LUT",An.minFilter=vt,An.magFilter=vt,An.wrapS=Ri,An.wrapT=Ri,An.generateMipmaps=!1,An.needsUpdate=!0),An}class D3{constructor(e={}){const{canvas:t=ny(),context:i=null,depth:n=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:f=$i}=e;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([tf,ef,Qu]),g=new Set([$i,yn,Do,Co,Ju,ju]),x=new Uint32Array(4),M=new Int32Array(4),w=new P;let S=null,_=null;const D=[],y=[];let T=null;this.domElement=t,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=Wn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const A=this;let I=!1,R=null,k=null,z=null,L=null;this._outputColorSpace=Bi;let B=0,F=0,V=null,j=-1,$=null;const ie=new at,ae=new at;let Ve=null;const je=new oe(0);let He=0,K=t.width,re=t.height,ne=1,G=null,Ee=null;const Pe=new at(0,0,K,re),Ie=new at(0,0,K,re);let be=!1;const ke=new cf;let Ne=!1,Oe=!1;const dt=new Ye,ut=new P,zt=new at,It={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ht=!1;function Zt(){return V===null?ne:1}let O=i;function Li(E,U){return t.getContext(E,U)}try{const E={alpha:!0,depth:n,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ku}`),t.addEventListener("webglcontextlost",Gt,!1),t.addEventListener("webglcontextrestored",xt,!1),t.addEventListener("webglcontextcreationerror",xn,!1),O===null){const U="webgl2";if(O=Li(U,E),O===null)throw Li(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(E){throw Ue("WebGLRenderer: "+E.message),E}let ft,C,b,H,q,Z,se,ce,J,ee,he,De,fe,de,Le,Fe,Xe,N,le,Q,ue,ve,te;function Ae(){ft=new Ix(O),ft.init(),ue=new b3(O,ft),C=new wx(O,ft,e,ue),b=new v3(O,ft),C.reversedDepthBuffer&&u&&b.buffers.depth.setReversed(!0),k=O.createFramebuffer(),z=O.createFramebuffer(),L=O.createFramebuffer(),H=new Rx(O),q=new n3,Z=new y3(O,ft,b,q,C,ue,H),se=new Ax(A),ce=new Nb(O),ve=new yx(O,ce),J=new Dx(O,ce,H,ve),ee=new Lx(O,J,ce,ve,H),N=new Px(O,C,Z),Le=new Mx(q),he=new i3(A,se,ft,C,ve,Le),De=new _3(A,q),fe=new r3,de=new d3(ft),Xe=new vx(A,se,b,ee,p,l),Fe=new g3(A,ee,C),te=new T3(O,H,C,b),le=new bx(O,ft,H),Q=new Cx(O,ft,H),H.programs=he.programs,A.capabilities=C,A.extensions=ft,A.properties=q,A.renderLists=fe,A.shadowMap=Fe,A.state=b,A.info=H}Ae(),v!==$i&&(T=new Nx(v,t.width,t.height,o,n,s));const Me=new S3(A,O);this.xr=Me,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){const E=ft.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=ft.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(E){E!==void 0&&(ne=E,this.setSize(K,re,!1))},this.getSize=function(E){return E.set(K,re)},this.setSize=function(E,U,Y=!0){if(Me.isPresenting){_e("WebGLRenderer: Can't change size while VR device is presenting.");return}K=E,re=U,t.width=Math.floor(E*ne),t.height=Math.floor(U*ne),Y===!0&&(t.style.width=E+"px",t.style.height=U+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,E,U)},this.getDrawingBufferSize=function(E){return E.set(K*ne,re*ne).floor()},this.setDrawingBufferSize=function(E,U,Y){K=E,re=U,ne=Y,t.width=Math.floor(E*Y),t.height=Math.floor(U*Y),this.setViewport(0,0,E,U)},this.setEffects=function(E){if(v===$i){Ue("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let U=0;U<E.length;U++)if(E[U].isOutputPass===!0){_e("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(E||[])},this.getCurrentViewport=function(E){return E.copy(ie)},this.getViewport=function(E){return E.copy(Pe)},this.setViewport=function(E,U,Y,W){E.isVector4?Pe.set(E.x,E.y,E.z,E.w):Pe.set(E,U,Y,W),b.viewport(ie.copy(Pe).multiplyScalar(ne).round())},this.getScissor=function(E){return E.copy(Ie)},this.setScissor=function(E,U,Y,W){E.isVector4?Ie.set(E.x,E.y,E.z,E.w):Ie.set(E,U,Y,W),b.scissor(ae.copy(Ie).multiplyScalar(ne).round())},this.getScissorTest=function(){return be},this.setScissorTest=function(E){b.setScissorTest(be=E)},this.setOpaqueSort=function(E){G=E},this.setTransparentSort=function(E){Ee=E},this.getClearColor=function(E){return E.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor(...arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha(...arguments)},this.clear=function(E=!0,U=!0,Y=!0){let W=0;if(E){let X=!1;if(V!==null){const ge=V.texture.format;X=m.has(ge)}if(X){const ge=V.texture.type,we=g.has(ge),me=Xe.getClearColor(),Se=Xe.getClearAlpha(),Ce=me.r,qe=me.g,$e=me.b;we?(x[0]=Ce,x[1]=qe,x[2]=$e,x[3]=Se,O.clearBufferuiv(O.COLOR,0,x)):(M[0]=Ce,M[1]=qe,M[2]=$e,M[3]=Se,O.clearBufferiv(O.COLOR,0,M))}else W|=O.COLOR_BUFFER_BIT}U&&(W|=O.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Y&&(W|=O.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),W!==0&&O.clear(W)},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),R=E},this.dispose=function(){t.removeEventListener("webglcontextlost",Gt,!1),t.removeEventListener("webglcontextrestored",xt,!1),t.removeEventListener("webglcontextcreationerror",xn,!1),Xe.dispose(),fe.dispose(),de.dispose(),q.dispose(),se.dispose(),ee.dispose(),ve.dispose(),te.dispose(),he.dispose(),Me.dispose(),Me.removeEventListener("sessionstart",Pf),Me.removeEventListener("sessionend",Lf),Gs.stop()};function Gt(E){E.preventDefault(),fc("WebGLRenderer: Context Lost."),I=!0}function xt(){fc("WebGLRenderer: Context Restored."),I=!1;const E=H.autoReset,U=Fe.enabled,Y=Fe.autoUpdate,W=Fe.needsUpdate,X=Fe.type;Ae(),H.autoReset=E,Fe.enabled=U,Fe.autoUpdate=Y,Fe.needsUpdate=W,Fe.type=X}function xn(E){Ue("WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Sn(E){const U=E.target;U.removeEventListener("dispose",Sn),$1(U)}function $1(E){Z1(E),q.remove(E)}function Z1(E){const U=q.get(E).programs;U!==void 0&&(U.forEach(function(Y){he.releaseProgram(Y)}),E.isShaderMaterial&&he.releaseShaderCache(E))}this.renderBufferDirect=function(E,U,Y,W,X,ge){U===null&&(U=It);const we=X.isMesh&&X.matrixWorld.determinantAffine()<0,me=Q1(E,U,Y,W,X);b.setMaterial(W,we);let Se=Y.index,Ce=1;if(W.wireframe===!0){if(Se=J.getWireframeAttribute(Y),Se===void 0)return;Ce=2}const qe=Y.drawRange,$e=Y.attributes.position;let Re=qe.start*Ce,yt=(qe.start+qe.count)*Ce;ge!==null&&(Re=Math.max(Re,ge.start*Ce),yt=Math.min(yt,(ge.start+ge.count)*Ce)),Se!==null?(Re=Math.max(Re,0),yt=Math.min(yt,Se.count)):$e!=null&&(Re=Math.max(Re,0),yt=Math.min(yt,$e.count));const Xt=yt-Re;if(Xt<0||Xt===1/0)return;ve.setup(X,W,me,Y,Se);let Vt,wt=le;if(Se!==null&&(Vt=ce.get(Se),wt=Q,wt.setIndex(Vt)),X.isMesh)W.wireframe===!0?(b.setLineWidth(W.wireframeLinewidth*Zt()),wt.setMode(O.LINES)):wt.setMode(O.TRIANGLES);else if(X.isLine){let wi=W.linewidth;wi===void 0&&(wi=1),b.setLineWidth(wi*Zt()),X.isLineSegments?wt.setMode(O.LINES):X.isLineLoop?wt.setMode(O.LINE_LOOP):wt.setMode(O.LINE_STRIP)}else X.isPoints?wt.setMode(O.POINTS):X.isSprite&&wt.setMode(O.TRIANGLES);if(X.isBatchedMesh)if(ft.get("WEBGL_multi_draw"))wt.renderMultiDraw(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount);else{const wi=X._multiDrawStarts,ye=X._multiDrawCounts,Hi=X._multiDrawCount,st=Se?ce.get(Se).bytesPerElement:1,Ji=q.get(W).currentProgram.getUniforms();for(let En=0;En<Hi;En++)Ji.setValue(O,"_gl_DrawID",En),wt.render(wi[En]/st,ye[En])}else if(X.isInstancedMesh)wt.renderInstances(Re,Xt,X.count);else if(Y.isInstancedBufferGeometry){const wi=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,ye=Math.min(Y.instanceCount,wi);wt.renderInstances(Re,Xt,ye)}else wt.render(Re,Xt)};function Rf(E,U,Y){E.transparent===!0&&E.side===pn&&E.forceSinglePass===!1?(E.side=Ft,E.needsUpdate=!0,Go(E,U,Y),E.side=Bs,E.needsUpdate=!0,Go(E,U,Y),E.side=pn):Go(E,U,Y)}this.compile=function(E,U,Y=null){Y===null&&(Y=E),_=de.get(Y),_.init(U),y.push(_),Y.traverseVisible(function(X){X.isLight&&X.layers.test(U.layers)&&(_.pushLight(X),X.castShadow&&_.pushShadow(X))}),E!==Y&&E.traverseVisible(function(X){X.isLight&&X.layers.test(U.layers)&&(_.pushLight(X),X.castShadow&&_.pushShadow(X))}),_.setupLights();const W=new Set;return E.traverse(function(X){if(!(X.isMesh||X.isPoints||X.isLine||X.isSprite))return;const ge=X.material;if(ge)if(Array.isArray(ge))for(let we=0;we<ge.length;we++){const me=ge[we];Rf(me,Y,X),W.add(me)}else Rf(ge,Y,X),W.add(ge)}),_=y.pop(),W},this.compileAsync=function(E,U,Y=null){const W=this.compile(E,U,Y);return new Promise(X=>{function ge(){if(W.forEach(function(we){q.get(we).currentProgram.isReady()&&W.delete(we)}),W.size===0){X(E);return}setTimeout(ge,10)}ft.get("KHR_parallel_shader_compile")!==null?ge():setTimeout(ge,10)})};let Gc=null;function J1(E){Gc&&Gc(E)}function Pf(){Gs.stop()}function Lf(){Gs.start()}const Gs=new e1;Gs.setAnimationLoop(J1),typeof self<"u"&&Gs.setContext(self),this.setAnimationLoop=function(E){Gc=E,Me.setAnimationLoop(E),E===null?Gs.stop():Gs.start()},Me.addEventListener("sessionstart",Pf),Me.addEventListener("sessionend",Lf),this.render=function(E,U){if(U!==void 0&&U.isCamera!==!0){Ue("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(I===!0)return;R!==null&&R.renderStart(E,U);const Y=Me.enabled===!0&&Me.isPresenting===!0,W=T!==null&&(V===null||Y)&&T.begin(A,V);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),Me.enabled===!0&&Me.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Me.cameraAutoUpdate===!0&&Me.updateCamera(U),U=Me.getCamera()),E.isScene===!0&&E.onBeforeRender(A,E,U,V),_=de.get(E,y.length),_.init(U),_.state.textureUnits=Z.getTextureUnits(),y.push(_),dt.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),ke.setFromProjectionMatrix(dt,Hn,U.reversedDepth),Oe=this.localClippingEnabled,Ne=Le.init(this.clippingPlanes,Oe),S=fe.get(E,D.length),S.init(),D.push(S),Me.enabled===!0&&Me.isPresenting===!0){const we=A.xr.getDepthSensingMesh();we!==null&&Vc(we,U,-1/0,A.sortObjects)}Vc(E,U,0,A.sortObjects),S.finish(),A.sortObjects===!0&&S.sort(G,Ee,U.reversedDepth),Ht=Me.enabled===!1||Me.isPresenting===!1||Me.hasDepthSensing()===!1,Ht&&Xe.addToRenderList(S,E),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ne===!0&&Le.beginShadows();const X=_.state.shadowsArray;if(Fe.render(X,E,U),Ne===!0&&Le.endShadows(),(W&&T.hasRenderPass())===!1){const we=S.opaque,me=S.transmissive;if(_.setupLights(),U.isArrayCamera){const Se=U.cameras;if(me.length>0)for(let Ce=0,qe=Se.length;Ce<qe;Ce++){const $e=Se[Ce];Nf(we,me,E,$e)}Ht&&Xe.render(E);for(let Ce=0,qe=Se.length;Ce<qe;Ce++){const $e=Se[Ce];kf(S,E,$e,$e.viewport)}}else me.length>0&&Nf(we,me,E,U),Ht&&Xe.render(E),kf(S,E,U)}V!==null&&F===0&&(Z.updateMultisampleRenderTarget(V),Z.updateRenderTargetMipmap(V)),W&&T.end(A),E.isScene===!0&&E.onAfterRender(A,E,U),ve.resetDefaultState(),j=-1,$=null,y.pop(),y.length>0?(_=y[y.length-1],Z.setTextureUnits(_.state.textureUnits),Ne===!0&&Le.setGlobalState(A.clippingPlanes,_.state.camera)):_=null,D.pop(),D.length>0?S=D[D.length-1]:S=null,R!==null&&R.renderEnd()};function Vc(E,U,Y,W){if(E.visible===!1)return;if(E.layers.test(U.layers)){if(E.isGroup)Y=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(U);else if(E.isLightProbeGrid)_.pushLightProbeGrid(E);else if(E.isLight)_.pushLight(E),E.castShadow&&_.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||ke.intersectsSprite(E)){W&&zt.setFromMatrixPosition(E.matrixWorld).applyMatrix4(dt);const we=ee.update(E),me=E.material;me.visible&&S.push(E,we,me,Y,zt.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||ke.intersectsObject(E))){const we=ee.update(E),me=E.material;if(W&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),zt.copy(E.boundingSphere.center)):(we.boundingSphere===null&&we.computeBoundingSphere(),zt.copy(we.boundingSphere.center)),zt.applyMatrix4(E.matrixWorld).applyMatrix4(dt)),Array.isArray(me)){const Se=we.groups;for(let Ce=0,qe=Se.length;Ce<qe;Ce++){const $e=Se[Ce],Re=me[$e.materialIndex];Re&&Re.visible&&S.push(E,we,Re,Y,zt.z,$e)}}else me.visible&&S.push(E,we,me,Y,zt.z,null)}}const ge=E.children;for(let we=0,me=ge.length;we<me;we++)Vc(ge[we],U,Y,W)}function kf(E,U,Y,W){const{opaque:X,transmissive:ge,transparent:we}=E;_.setupLightsView(Y),Ne===!0&&Le.setGlobalState(A.clippingPlanes,Y),W&&b.viewport(ie.copy(W)),X.length>0&&Ho(X,U,Y),ge.length>0&&Ho(ge,U,Y),we.length>0&&Ho(we,U,Y),b.buffers.depth.setTest(!0),b.buffers.depth.setMask(!0),b.buffers.color.setMask(!0),b.setPolygonOffset(!1)}function Nf(E,U,Y,W){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;if(_.state.transmissionRenderTarget[W.id]===void 0){const Re=ft.has("EXT_color_buffer_half_float")||ft.has("EXT_color_buffer_float");_.state.transmissionRenderTarget[W.id]=new vi(1,1,{generateMipmaps:!0,type:Re?ui:$i,minFilter:or,samples:Math.max(4,C.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:tt.workingColorSpace})}const ge=_.state.transmissionRenderTarget[W.id],we=W.viewport||ie;ge.setSize(we.z*A.transmissionResolutionScale,we.w*A.transmissionResolutionScale);const me=A.getRenderTarget(),Se=A.getActiveCubeFace(),Ce=A.getActiveMipmapLevel();A.setRenderTarget(ge),A.getClearColor(je),He=A.getClearAlpha(),He<1&&A.setClearColor(16777215,.5),A.clear(),Ht&&Xe.render(Y);const qe=A.toneMapping;A.toneMapping=Wn;const $e=W.viewport;if(W.viewport!==void 0&&(W.viewport=void 0),_.setupLightsView(W),Ne===!0&&Le.setGlobalState(A.clippingPlanes,W),Ho(E,Y,W),Z.updateMultisampleRenderTarget(ge),Z.updateRenderTargetMipmap(ge),ft.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let yt=0,Xt=U.length;yt<Xt;yt++){const Vt=U[yt],{object:wt,geometry:wi,material:ye,group:Hi}=Vt;if(ye.side===pn&&wt.layers.test(W.layers)){const st=ye.side;ye.side=Ft,ye.needsUpdate=!0,Of(wt,Y,W,wi,ye,Hi),ye.side=st,ye.needsUpdate=!0,Re=!0}}Re===!0&&(Z.updateMultisampleRenderTarget(ge),Z.updateRenderTargetMipmap(ge))}A.setRenderTarget(me,Se,Ce),A.setClearColor(je,He),$e!==void 0&&(W.viewport=$e),A.toneMapping=qe}function Ho(E,U,Y){const W=U.isScene===!0?U.overrideMaterial:null;for(let X=0,ge=E.length;X<ge;X++){const we=E[X],{object:me,geometry:Se,group:Ce}=we;let qe=we.material;qe.allowOverride===!0&&W!==null&&(qe=W),me.layers.test(Y.layers)&&Of(me,U,Y,Se,qe,Ce)}}function Of(E,U,Y,W,X,ge){E.onBeforeRender(A,U,Y,W,X,ge),E.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),X.onBeforeRender(A,U,Y,W,E,ge),X.transparent===!0&&X.side===pn&&X.forceSinglePass===!1?(X.side=Ft,X.needsUpdate=!0,A.renderBufferDirect(Y,U,W,X,E,ge),X.side=Bs,X.needsUpdate=!0,A.renderBufferDirect(Y,U,W,X,E,ge),X.side=pn):A.renderBufferDirect(Y,U,W,X,E,ge),E.onAfterRender(A,U,Y,W,X,ge)}function Go(E,U,Y){U.isScene!==!0&&(U=It);const W=q.get(E),X=_.state.lights,ge=_.state.shadowsArray,we=X.state.version,me=he.getParameters(E,X.state,ge,U,Y,_.state.lightProbeGridArray),Se=he.getProgramCacheKey(me);let Ce=W.programs;W.environment=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?U.environment:null,W.fog=U.fog;const qe=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap;W.envMap=se.get(E.envMap||W.environment,qe),W.envMapRotation=W.environment!==null&&E.envMap===null?U.environmentRotation:E.envMapRotation,Ce===void 0&&(E.addEventListener("dispose",Sn),Ce=new Map,W.programs=Ce);let $e=Ce.get(Se);if($e!==void 0){if(W.currentProgram===$e&&W.lightsStateVersion===we)return Uf(E,me),$e}else me.uniforms=he.getUniforms(E),R!==null&&E.isNodeMaterial&&R.build(E,Y,me),E.onBeforeCompile(me,A),$e=he.acquireProgram(me,Se),Ce.set(Se,$e),W.uniforms=me.uniforms;const Re=W.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Re.clippingPlanes=Le.uniform),Uf(E,me),W.needsLights=tv(E),W.lightsStateVersion=we,W.needsLights&&(Re.ambientLightColor.value=X.state.ambient,Re.lightProbe.value=X.state.probe,Re.directionalLights.value=X.state.directional,Re.directionalLightShadows.value=X.state.directionalShadow,Re.spotLights.value=X.state.spot,Re.spotLightShadows.value=X.state.spotShadow,Re.rectAreaLights.value=X.state.rectArea,Re.ltc_1.value=X.state.rectAreaLTC1,Re.ltc_2.value=X.state.rectAreaLTC2,Re.pointLights.value=X.state.point,Re.pointLightShadows.value=X.state.pointShadow,Re.hemisphereLights.value=X.state.hemi,Re.directionalShadowMatrix.value=X.state.directionalShadowMatrix,Re.spotLightMatrix.value=X.state.spotLightMatrix,Re.spotLightMap.value=X.state.spotLightMap,Re.pointShadowMatrix.value=X.state.pointShadowMatrix),W.lightProbeGrid=_.state.lightProbeGridArray.length>0,W.currentProgram=$e,W.uniformsList=null,$e}function Ff(E){if(E.uniformsList===null){const U=E.currentProgram.getUniforms();E.uniformsList=Zl.seqWithValue(U.seq,E.uniforms)}return E.uniformsList}function Uf(E,U){const Y=q.get(E);Y.outputColorSpace=U.outputColorSpace,Y.batching=U.batching,Y.batchingColor=U.batchingColor,Y.instancing=U.instancing,Y.instancingColor=U.instancingColor,Y.instancingMorph=U.instancingMorph,Y.skinning=U.skinning,Y.morphTargets=U.morphTargets,Y.morphNormals=U.morphNormals,Y.morphColors=U.morphColors,Y.morphTargetsCount=U.morphTargetsCount,Y.numClippingPlanes=U.numClippingPlanes,Y.numIntersection=U.numClipIntersection,Y.vertexAlphas=U.vertexAlphas,Y.vertexTangents=U.vertexTangents,Y.toneMapping=U.toneMapping}function j1(E,U){if(E.length===0)return null;if(E.length===1)return E[0].texture!==null?E[0]:null;w.setFromMatrixPosition(U.matrixWorld);for(let Y=0,W=E.length;Y<W;Y++){const X=E[Y];if(X.texture!==null&&X.boundingBox.containsPoint(w))return X}return null}function Q1(E,U,Y,W,X){U.isScene!==!0&&(U=It),Z.resetTextureUnits();const ge=U.fog,we=W.isMeshStandardMaterial||W.isMeshLambertMaterial||W.isMeshPhongMaterial?U.environment:null,me=V===null?A.outputColorSpace:V.isXRRenderTarget===!0?V.texture.colorSpace:tt.workingColorSpace,Se=W.isMeshStandardMaterial||W.isMeshLambertMaterial&&!W.envMap||W.isMeshPhongMaterial&&!W.envMap,Ce=se.get(W.envMap||we,Se),qe=W.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,$e=!!Y.attributes.tangent&&(!!W.normalMap||W.anisotropy>0),Re=!!Y.morphAttributes.position,yt=!!Y.morphAttributes.normal,Xt=!!Y.morphAttributes.color;let Vt=Wn;W.toneMapped&&(V===null||V.isXRRenderTarget===!0)&&(Vt=A.toneMapping);const wt=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,wi=wt!==void 0?wt.length:0,ye=q.get(W),Hi=_.state.lights;if(Ne===!0&&(Oe===!0||E!==$)){const St=E===$&&W.id===j;Le.setState(W,E,St)}let st=!1;W.version===ye.__version?(ye.needsLights&&ye.lightsStateVersion!==Hi.state.version||ye.outputColorSpace!==me||X.isBatchedMesh&&ye.batching===!1||!X.isBatchedMesh&&ye.batching===!0||X.isBatchedMesh&&ye.batchingColor===!0&&X.colorTexture===null||X.isBatchedMesh&&ye.batchingColor===!1&&X.colorTexture!==null||X.isInstancedMesh&&ye.instancing===!1||!X.isInstancedMesh&&ye.instancing===!0||X.isSkinnedMesh&&ye.skinning===!1||!X.isSkinnedMesh&&ye.skinning===!0||X.isInstancedMesh&&ye.instancingColor===!0&&X.instanceColor===null||X.isInstancedMesh&&ye.instancingColor===!1&&X.instanceColor!==null||X.isInstancedMesh&&ye.instancingMorph===!0&&X.morphTexture===null||X.isInstancedMesh&&ye.instancingMorph===!1&&X.morphTexture!==null||ye.envMap!==Ce||W.fog===!0&&ye.fog!==ge||ye.numClippingPlanes!==void 0&&(ye.numClippingPlanes!==Le.numPlanes||ye.numIntersection!==Le.numIntersection)||ye.vertexAlphas!==qe||ye.vertexTangents!==$e||ye.morphTargets!==Re||ye.morphNormals!==yt||ye.morphColors!==Xt||ye.toneMapping!==Vt||ye.morphTargetsCount!==wi||!!ye.lightProbeGrid!=_.state.lightProbeGridArray.length>0)&&(st=!0):(st=!0,ye.__version=W.version);let Ji=ye.currentProgram;st===!0&&(Ji=Go(W,U,X),R&&W.isNodeMaterial&&R.onUpdateProgram(W,Ji,ye));let En=!1,gs=!1,xr=!1;const Mt=Ji.getUniforms(),qt=ye.uniforms;if(b.useProgram(Ji.program)&&(En=!0,gs=!0,xr=!0),W.id!==j&&(j=W.id,gs=!0),ye.needsLights){const St=j1(_.state.lightProbeGridArray,X);ye.lightProbeGrid!==St&&(ye.lightProbeGrid=St,gs=!0)}if(En||$!==E){b.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),Mt.setValue(O,"projectionMatrix",E.projectionMatrix),Mt.setValue(O,"viewMatrix",E.matrixWorldInverse);const ys=Mt.map.cameraPosition;ys!==void 0&&ys.setValue(O,ut.setFromMatrixPosition(E.matrixWorld)),C.logarithmicDepthBuffer&&Mt.setValue(O,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(W.isMeshPhongMaterial||W.isMeshToonMaterial||W.isMeshLambertMaterial||W.isMeshBasicMaterial||W.isMeshStandardMaterial||W.isShaderMaterial)&&Mt.setValue(O,"isOrthographic",E.isOrthographicCamera===!0),$!==E&&($=E,gs=!0,xr=!0)}if(ye.needsLights&&(Hi.state.directionalShadowMap.length>0&&Mt.setValue(O,"directionalShadowMap",Hi.state.directionalShadowMap,Z),Hi.state.spotShadowMap.length>0&&Mt.setValue(O,"spotShadowMap",Hi.state.spotShadowMap,Z),Hi.state.pointShadowMap.length>0&&Mt.setValue(O,"pointShadowMap",Hi.state.pointShadowMap,Z)),X.isSkinnedMesh){Mt.setOptional(O,X,"bindMatrix"),Mt.setOptional(O,X,"bindMatrixInverse");const St=X.skeleton;St&&(St.boneTexture===null&&St.computeBoneTexture(),Mt.setValue(O,"boneTexture",St.boneTexture,Z))}X.isBatchedMesh&&(Mt.setOptional(O,X,"batchingTexture"),Mt.setValue(O,"batchingTexture",X._matricesTexture,Z),Mt.setOptional(O,X,"batchingIdTexture"),Mt.setValue(O,"batchingIdTexture",X._indirectTexture,Z),Mt.setOptional(O,X,"batchingColorTexture"),X._colorsTexture!==null&&Mt.setValue(O,"batchingColorTexture",X._colorsTexture,Z));const vs=Y.morphAttributes;if((vs.position!==void 0||vs.normal!==void 0||vs.color!==void 0)&&N.update(X,Y,Ji),(gs||ye.receiveShadow!==X.receiveShadow)&&(ye.receiveShadow=X.receiveShadow,Mt.setValue(O,"receiveShadow",X.receiveShadow)),(W.isMeshStandardMaterial||W.isMeshLambertMaterial||W.isMeshPhongMaterial)&&W.envMap===null&&U.environment!==null&&(qt.envMapIntensity.value=U.environmentIntensity),qt.dfgLUT!==void 0&&(qt.dfgLUT.value=I3()),gs){if(Mt.setValue(O,"toneMappingExposure",A.toneMappingExposure),ye.needsLights&&ev(qt,xr),ge&&W.fog===!0&&De.refreshFogUniforms(qt,ge),De.refreshMaterialUniforms(qt,W,ne,re,_.state.transmissionRenderTarget[E.id]),ye.needsLights&&ye.lightProbeGrid){const St=ye.lightProbeGrid;qt.probesSH.value=St.texture,qt.probesMin.value.copy(St.boundingBox.min),qt.probesMax.value.copy(St.boundingBox.max),qt.probesResolution.value.copy(St.resolution)}Zl.upload(O,Ff(ye),qt,Z)}if(W.isShaderMaterial&&W.uniformsNeedUpdate===!0&&(Zl.upload(O,Ff(ye),qt,Z),W.uniformsNeedUpdate=!1),W.isSpriteMaterial&&Mt.setValue(O,"center",X.center),Mt.setValue(O,"modelViewMatrix",X.modelViewMatrix),Mt.setValue(O,"normalMatrix",X.normalMatrix),Mt.setValue(O,"modelMatrix",X.matrixWorld),W.uniformsGroups!==void 0){const St=W.uniformsGroups;for(let ys=0,Sr=St.length;ys<Sr;ys++){const Bf=St[ys];te.update(Bf,Ji),te.bind(Bf,Ji)}}return Ji}function ev(E,U){E.ambientLightColor.needsUpdate=U,E.lightProbe.needsUpdate=U,E.directionalLights.needsUpdate=U,E.directionalLightShadows.needsUpdate=U,E.pointLights.needsUpdate=U,E.pointLightShadows.needsUpdate=U,E.spotLights.needsUpdate=U,E.spotLightShadows.needsUpdate=U,E.rectAreaLights.needsUpdate=U,E.hemisphereLights.needsUpdate=U}function tv(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 F},this.getRenderTarget=function(){return V},this.setRenderTargetTextures=function(E,U,Y){const W=q.get(E);W.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,W.__autoAllocateDepthBuffer===!1&&(W.__useRenderToTexture=!1),q.get(E.texture).__webglTexture=U,q.get(E.depthTexture).__webglTexture=W.__autoAllocateDepthBuffer?void 0:Y,W.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,U){const Y=q.get(E);Y.__webglFramebuffer=U,Y.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(E,U=0,Y=0){V=E,B=U,F=Y;let W=null,X=!1,ge=!1;if(E){const me=q.get(E);if(me.__useDefaultFramebuffer!==void 0){b.bindFramebuffer(O.FRAMEBUFFER,me.__webglFramebuffer),ie.copy(E.viewport),ae.copy(E.scissor),Ve=E.scissorTest,b.viewport(ie),b.scissor(ae),b.setScissorTest(Ve),j=-1;return}else if(me.__webglFramebuffer===void 0)Z.setupRenderTarget(E);else if(me.__hasExternalTextures)Z.rebindTextures(E,q.get(E.texture).__webglTexture,q.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const qe=E.depthTexture;if(me.__boundDepthTexture!==qe){if(qe!==null&&q.has(qe)&&(E.width!==qe.image.width||E.height!==qe.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Z.setupDepthRenderbuffer(E)}}const Se=E.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(ge=!0);const Ce=q.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Ce[U])?W=Ce[U][Y]:W=Ce[U],X=!0):E.samples>0&&Z.useMultisampledRTT(E)===!1?W=q.get(E).__webglMultisampledFramebuffer:Array.isArray(Ce)?W=Ce[Y]:W=Ce,ie.copy(E.viewport),ae.copy(E.scissor),Ve=E.scissorTest}else ie.copy(Pe).multiplyScalar(ne).floor(),ae.copy(Ie).multiplyScalar(ne).floor(),Ve=be;if(Y!==0&&(W=k),b.bindFramebuffer(O.FRAMEBUFFER,W)&&b.drawBuffers(E,W),b.viewport(ie),b.scissor(ae),b.setScissorTest(Ve),X){const me=q.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_CUBE_MAP_POSITIVE_X+U,me.__webglTexture,Y)}else if(ge){const me=U;for(let Se=0;Se<E.textures.length;Se++){const Ce=q.get(E.textures[Se]);O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0+Se,Ce.__webglTexture,Y,me)}}else if(E!==null&&Y!==0){const me=q.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,me.__webglTexture,Y)}j=-1},this.readRenderTargetPixels=function(E,U,Y,W,X,ge,we,me=0){if(!(E&&E.isWebGLRenderTarget)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=q.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&we!==void 0&&(Se=Se[we]),Se){b.bindFramebuffer(O.FRAMEBUFFER,Se);try{const Ce=E.textures[me],qe=Ce.format,$e=Ce.type;if(E.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+me),!C.textureFormatReadable(qe)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!C.textureTypeReadable($e)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=E.width-W&&Y>=0&&Y<=E.height-X&&O.readPixels(U,Y,W,X,ue.convert(qe),ue.convert($e),ge)}finally{const Ce=V!==null?q.get(V).__webglFramebuffer:null;b.bindFramebuffer(O.FRAMEBUFFER,Ce)}}},this.readRenderTargetPixelsAsync=async function(E,U,Y,W,X,ge,we,me=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=q.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&we!==void 0&&(Se=Se[we]),Se)if(U>=0&&U<=E.width-W&&Y>=0&&Y<=E.height-X){b.bindFramebuffer(O.FRAMEBUFFER,Se);const Ce=E.textures[me],qe=Ce.format,$e=Ce.type;if(E.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+me),!C.textureFormatReadable(qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!C.textureTypeReadable($e))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Re=O.createBuffer();O.bindBuffer(O.PIXEL_PACK_BUFFER,Re),O.bufferData(O.PIXEL_PACK_BUFFER,ge.byteLength,O.STREAM_READ),O.readPixels(U,Y,W,X,ue.convert(qe),ue.convert($e),0);const yt=V!==null?q.get(V).__webglFramebuffer:null;b.bindFramebuffer(O.FRAMEBUFFER,yt);const Xt=O.fenceSync(O.SYNC_GPU_COMMANDS_COMPLETE,0);return O.flush(),await sy(O,Xt,4),O.bindBuffer(O.PIXEL_PACK_BUFFER,Re),O.getBufferSubData(O.PIXEL_PACK_BUFFER,0,ge),O.deleteBuffer(Re),O.deleteSync(Xt),ge}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,U=null,Y=0){const W=Math.pow(2,-Y),X=Math.floor(E.image.width*W),ge=Math.floor(E.image.height*W),we=U!==null?U.x:0,me=U!==null?U.y:0;Z.setTexture2D(E,0),O.copyTexSubImage2D(O.TEXTURE_2D,Y,0,0,we,me,X,ge),b.unbindTexture()},this.copyTextureToTexture=function(E,U,Y=null,W=null,X=0,ge=0){let we,me,Se,Ce,qe,$e,Re,yt,Xt;const Vt=E.isCompressedTexture?E.mipmaps[ge]:E.image;if(Y!==null)we=Y.max.x-Y.min.x,me=Y.max.y-Y.min.y,Se=Y.isBox3?Y.max.z-Y.min.z:1,Ce=Y.min.x,qe=Y.min.y,$e=Y.isBox3?Y.min.z:0;else{const qt=Math.pow(2,-X);we=Math.floor(Vt.width*qt),me=Math.floor(Vt.height*qt),E.isDataArrayTexture?Se=Vt.depth:E.isData3DTexture?Se=Math.floor(Vt.depth*qt):Se=1,Ce=0,qe=0,$e=0}W!==null?(Re=W.x,yt=W.y,Xt=W.z):(Re=0,yt=0,Xt=0);const wt=ue.convert(U.format),wi=ue.convert(U.type);let ye;U.isData3DTexture?(Z.setTexture3D(U,0),ye=O.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(Z.setTexture2DArray(U,0),ye=O.TEXTURE_2D_ARRAY):(Z.setTexture2D(U,0),ye=O.TEXTURE_2D),b.activeTexture(O.TEXTURE0),b.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,U.flipY),b.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),b.pixelStorei(O.UNPACK_ALIGNMENT,U.unpackAlignment);const Hi=b.getParameter(O.UNPACK_ROW_LENGTH),st=b.getParameter(O.UNPACK_IMAGE_HEIGHT),Ji=b.getParameter(O.UNPACK_SKIP_PIXELS),En=b.getParameter(O.UNPACK_SKIP_ROWS),gs=b.getParameter(O.UNPACK_SKIP_IMAGES);b.pixelStorei(O.UNPACK_ROW_LENGTH,Vt.width),b.pixelStorei(O.UNPACK_IMAGE_HEIGHT,Vt.height),b.pixelStorei(O.UNPACK_SKIP_PIXELS,Ce),b.pixelStorei(O.UNPACK_SKIP_ROWS,qe),b.pixelStorei(O.UNPACK_SKIP_IMAGES,$e);const xr=E.isDataArrayTexture||E.isData3DTexture,Mt=U.isDataArrayTexture||U.isData3DTexture;if(E.isDepthTexture){const qt=q.get(E),vs=q.get(U),St=q.get(qt.__renderTarget),ys=q.get(vs.__renderTarget);b.bindFramebuffer(O.READ_FRAMEBUFFER,St.__webglFramebuffer),b.bindFramebuffer(O.DRAW_FRAMEBUFFER,ys.__webglFramebuffer);for(let Sr=0;Sr<Se;Sr++)xr&&(O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,q.get(E).__webglTexture,X,$e+Sr),O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,q.get(U).__webglTexture,ge,Xt+Sr)),O.blitFramebuffer(Ce,qe,we,me,Re,yt,we,me,O.DEPTH_BUFFER_BIT,O.NEAREST);b.bindFramebuffer(O.READ_FRAMEBUFFER,null),b.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(X!==0||E.isRenderTargetTexture||q.has(E)){const qt=q.get(E),vs=q.get(U);b.bindFramebuffer(O.READ_FRAMEBUFFER,z),b.bindFramebuffer(O.DRAW_FRAMEBUFFER,L);for(let St=0;St<Se;St++)xr?O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,qt.__webglTexture,X,$e+St):O.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,qt.__webglTexture,X),Mt?O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,vs.__webglTexture,ge,Xt+St):O.framebufferTexture2D(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,vs.__webglTexture,ge),X!==0?O.blitFramebuffer(Ce,qe,we,me,Re,yt,we,me,O.COLOR_BUFFER_BIT,O.NEAREST):Mt?O.copyTexSubImage3D(ye,ge,Re,yt,Xt+St,Ce,qe,we,me):O.copyTexSubImage2D(ye,ge,Re,yt,Ce,qe,we,me);b.bindFramebuffer(O.READ_FRAMEBUFFER,null),b.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else Mt?E.isDataTexture||E.isData3DTexture?O.texSubImage3D(ye,ge,Re,yt,Xt,we,me,Se,wt,wi,Vt.data):U.isCompressedArrayTexture?O.compressedTexSubImage3D(ye,ge,Re,yt,Xt,we,me,Se,wt,Vt.data):O.texSubImage3D(ye,ge,Re,yt,Xt,we,me,Se,wt,wi,Vt):E.isDataTexture?O.texSubImage2D(O.TEXTURE_2D,ge,Re,yt,we,me,wt,wi,Vt.data):E.isCompressedTexture?O.compressedTexSubImage2D(O.TEXTURE_2D,ge,Re,yt,Vt.width,Vt.height,wt,Vt.data):O.texSubImage2D(O.TEXTURE_2D,ge,Re,yt,we,me,wt,wi,Vt);b.pixelStorei(O.UNPACK_ROW_LENGTH,Hi),b.pixelStorei(O.UNPACK_IMAGE_HEIGHT,st),b.pixelStorei(O.UNPACK_SKIP_PIXELS,Ji),b.pixelStorei(O.UNPACK_SKIP_ROWS,En),b.pixelStorei(O.UNPACK_SKIP_IMAGES,gs),ge===0&&U.generateMipmaps&&O.generateMipmap(ye),b.unbindTexture()},this.initRenderTarget=function(E){q.get(E).__webglFramebuffer===void 0&&Z.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?Z.setTextureCube(E,0):E.isData3DTexture?Z.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?Z.setTexture2DArray(E,0):Z.setTexture2D(E,0),b.unbindTexture()},this.resetState=function(){B=0,F=0,V=null,b.reset(),ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Hn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=tt._getDrawingBufferColorSpace(e),t.unpackColorSpace=tt._getUnpackColorSpace()}}const C3=`
6219
+ }`;class x3{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new Yg(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Ot({vertexShader:w3,fragmentShader:M3,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new We(new wn(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class S3 extends wr{constructor(e,t){super();const i=this;let n=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,u=null,f=null,p=null;const v=typeof XRWebGLBinding<"u",m=new x3,g={},x=t.getContextAttributes();let M=null,w=null;const S=[],_=[],D=new Te;let y=null;const T=new zi;T.viewport=new at;const A=new zi;A.viewport=new at;const I=[T,A],R=new Eb;let k=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let re=S[K];return re===void 0&&(re=new nh,S[K]=re),re.getTargetRaySpace()},this.getControllerGrip=function(K){let re=S[K];return re===void 0&&(re=new nh,S[K]=re),re.getGripSpace()},this.getHand=function(K){let re=S[K];return re===void 0&&(re=new nh,S[K]=re),re.getHandSpace()};function L(K){const re=_.indexOf(K.inputSource);if(re===-1)return;const ne=S[re];ne!==void 0&&(ne.update(K.inputSource,K.frame,c||a),ne.dispatchEvent({type:K.type,data:K.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",F);for(let K=0;K<S.length;K++){const re=_[K];re!==null&&(_[K]=null,S[K].disconnect(re))}k=null,z=null,m.reset();for(const K in g)delete g[K];e.setRenderTarget(M),f=null,u=null,d=null,n=null,w=null,Ge.stop(),i.isPresenting=!1,e.setPixelRatio(y),e.setSize(D.width,D.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){s=K,i.isPresenting===!0&&_e("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){o=K,i.isPresenting===!0&&_e("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(K){c=K},this.getBaseLayer=function(){return u!==null?u:f},this.getBinding=function(){return d===null&&v&&(d=new XRWebGLBinding(n,t)),d},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(K){if(n=K,n!==null){if(M=e.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",F),x.xrCompatible!==!0&&await t.makeXRCompatible(),y=e.getPixelRatio(),e.getSize(D),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,G=null,Ee=null;x.depth&&(Ee=x.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=x.stencil?lr:ds,G=x.stencil?Co:yn);const Pe={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:s};d=this.getBinding(),u=d.createProjectionLayer(Pe),n.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),w=new vi(u.textureWidth,u.textureHeight,{format:Ti,type:$i,depthTexture:new yr(u.textureWidth,u.textureHeight,G,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:x.stencil,colorSpace:e.outputColorSpace,samples:x.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const ne={antialias:x.antialias,alpha:!0,depth:x.depth,stencil:x.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,t,ne),n.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),w=new vi(f.framebufferWidth,f.framebufferHeight,{format:Ti,type:$i,colorSpace:e.outputColorSpace,stencilBuffer:x.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}w.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await n.requestReferenceSpace(o),Ge.setContext(n),Ge.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function F(K){for(let re=0;re<K.removed.length;re++){const ne=K.removed[re],G=_.indexOf(ne);G>=0&&(_[G]=null,S[G].disconnect(ne))}for(let re=0;re<K.added.length;re++){const ne=K.added[re];let G=_.indexOf(ne);if(G===-1){for(let Pe=0;Pe<S.length;Pe++)if(Pe>=_.length){_.push(ne),G=Pe;break}else if(_[Pe]===null){_[Pe]=ne,G=Pe;break}if(G===-1)break}const Ee=S[G];Ee&&Ee.connect(ne)}}const V=new P,j=new P;function $(K,re,ne){V.setFromMatrixPosition(re.matrixWorld),j.setFromMatrixPosition(ne.matrixWorld);const G=V.distanceTo(j),Ee=re.projectionMatrix.elements,Pe=ne.projectionMatrix.elements,Ie=Ee[14]/(Ee[10]-1),be=Ee[14]/(Ee[10]+1),ke=(Ee[9]+1)/Ee[5],Ne=(Ee[9]-1)/Ee[5],Oe=(Ee[8]-1)/Ee[0],dt=(Pe[8]+1)/Pe[0],ut=Ie*Oe,zt=Ie*dt,It=G/(-Oe+dt),Ht=It*-Oe;if(re.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Ht),K.translateZ(It),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),Ee[10]===-1)K.projectionMatrix.copy(re.projectionMatrix),K.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const Zt=Ie+It,O=be+It,Li=ut-Ht,ft=zt+(G-Ht),C=ke*be/O*Zt,b=Ne*be/O*Zt;K.projectionMatrix.makePerspective(Li,ft,C,b,Zt,O),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function ie(K,re){re===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(re.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(n===null)return;let re=K.near,ne=K.far;m.texture!==null&&(m.depthNear>0&&(re=m.depthNear),m.depthFar>0&&(ne=m.depthFar)),R.near=A.near=T.near=re,R.far=A.far=T.far=ne,(k!==R.near||z!==R.far)&&(n.updateRenderState({depthNear:R.near,depthFar:R.far}),k=R.near,z=R.far),R.layers.mask=K.layers.mask|6,T.layers.mask=R.layers.mask&-5,A.layers.mask=R.layers.mask&-3;const G=K.parent,Ee=R.cameras;ie(R,G);for(let Pe=0;Pe<Ee.length;Pe++)ie(Ee[Pe],G);Ee.length===2?$(R,T,A):R.projectionMatrix.copy(T.projectionMatrix),ae(K,R,G)};function ae(K,re,ne){ne===null?K.matrix.copy(re.matrixWorld):(K.matrix.copy(ne.matrixWorld),K.matrix.invert(),K.matrix.multiply(re.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(re.projectionMatrix),K.projectionMatrixInverse.copy(re.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=Da*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return R},this.getFoveation=function(){if(!(u===null&&f===null))return l},this.setFoveation=function(K){l=K,u!==null&&(u.fixedFoveation=K),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=K)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(R)},this.getCameraTexture=function(K){return g[K]};let Ve=null;function je(K,re){if(h=re.getViewerPose(c||a),p=re,h!==null){const ne=h.views;f!==null&&(e.setRenderTargetFramebuffer(w,f.framebuffer),e.setRenderTarget(w));let G=!1;ne.length!==R.cameras.length&&(R.cameras.length=0,G=!0);for(let be=0;be<ne.length;be++){const ke=ne[be];let Ne=null;if(f!==null)Ne=f.getViewport(ke);else{const dt=d.getViewSubImage(u,ke);Ne=dt.viewport,be===0&&(e.setRenderTargetTextures(w,dt.colorTexture,dt.depthStencilTexture),e.setRenderTarget(w))}let Oe=I[be];Oe===void 0&&(Oe=new zi,Oe.layers.enable(be),Oe.viewport=new at,I[be]=Oe),Oe.matrix.fromArray(ke.transform.matrix),Oe.matrix.decompose(Oe.position,Oe.quaternion,Oe.scale),Oe.projectionMatrix.fromArray(ke.projectionMatrix),Oe.projectionMatrixInverse.copy(Oe.projectionMatrix).invert(),Oe.viewport.set(Ne.x,Ne.y,Ne.width,Ne.height),be===0&&(R.matrix.copy(Oe.matrix),R.matrix.decompose(R.position,R.quaternion,R.scale)),G===!0&&R.cameras.push(Oe)}const Ee=n.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&v){d=i.getBinding();const be=d.getDepthInformation(ne[0]);be&&be.isValid&&be.texture&&m.init(be,n.renderState)}if(Ee&&Ee.includes("camera-access")&&v){e.state.unbindTexture(),d=i.getBinding();for(let be=0;be<ne.length;be++){const ke=ne[be].camera;if(ke){let Ne=g[ke];Ne||(Ne=new Yg,g[ke]=Ne);const Oe=d.getCameraImage(ke);Ne.sourceTexture=Oe}}}}for(let ne=0;ne<S.length;ne++){const G=_[ne],Ee=S[ne];G!==null&&Ee!==void 0&&Ee.update(G,re,c||a)}Ve&&Ve(K,re),re.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:re}),p=null}const Ge=new e1;Ge.setAnimationLoop(je),this.setAnimationLoop=function(K){Ve=K},this.dispose=function(){}}}const E3=new Ye,o1=new He;o1.set(-1,0,0,0,1,0,0,0,1);function _3(r,e){function t(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function i(m,g){g.color.getRGB(m.fogColor.value,Kg(r)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,x,M,w){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),d(m,g)):g.isMeshPhongMaterial?(s(m,g),h(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(s(m,g),u(m,g),g.isMeshPhysicalMaterial&&f(m,g,w)):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?l(m,g,x,M):g.isSpriteMaterial?c(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,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,t(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===Ft&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,t(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===Ft&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,t(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,t(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const x=e.get(g),M=x.envMap,w=x.envMapRotation;M&&(m.envMap.value=M,m.envMapRotation.value.setFromMatrix4(E3.makeRotationFromEuler(w)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(o1),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,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(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,t(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 l(m,g,x,M){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*x,m.scale.value=M*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function c(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,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(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 d(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function u(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,x){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,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===Ft&&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,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=x.texture,m.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(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,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function v(m,g){const x=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(x.matrixWorld),m.nearDistance.value=x.shadow.camera.near,m.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function T3(r,e,t,i){let n={},s={},a=[];const o=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function l(w,S){const _=S.program;i.uniformBlockBinding(w,_)}function c(w,S){let _=n[w.id];_===void 0&&(m(w),_=h(w),n[w.id]=_,w.addEventListener("dispose",x));const D=S.program;i.updateUBOMapping(w,D);const y=e.render.frame;s[w.id]!==y&&(u(w),s[w.id]=y)}function h(w){const S=d();w.__bindingPointIndex=S;const _=r.createBuffer(),D=w.__size,y=w.usage;return r.bindBuffer(r.UNIFORM_BUFFER,_),r.bufferData(r.UNIFORM_BUFFER,D,y),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,S,_),_}function d(){for(let w=0;w<o;w++)if(a.indexOf(w)===-1)return a.push(w),w;return Ue("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(w){const S=n[w.id],_=w.uniforms,D=w.__cache;r.bindBuffer(r.UNIFORM_BUFFER,S);for(let y=0,T=_.length;y<T;y++){const A=_[y];if(Array.isArray(A))for(let I=0,R=A.length;I<R;I++)f(A[I],y,I,D);else f(A,y,0,D)}r.bindBuffer(r.UNIFORM_BUFFER,null)}function f(w,S,_,D){if(v(w,S,_,D)===!0){const y=w.__offset,T=w.value;if(Array.isArray(T)){let A=0;for(let I=0;I<T.length;I++){const R=T[I],k=g(R);p(R,w.__data,A),typeof R!="number"&&typeof R!="boolean"&&!R.isMatrix3&&!ArrayBuffer.isView(R)&&(A+=k.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(T,w.__data,0);r.bufferSubData(r.UNIFORM_BUFFER,y,w.__data)}}function p(w,S,_){typeof w=="number"||typeof w=="boolean"?S[0]=w:w.isMatrix3?(S[0]=w.elements[0],S[1]=w.elements[1],S[2]=w.elements[2],S[3]=0,S[4]=w.elements[3],S[5]=w.elements[4],S[6]=w.elements[5],S[7]=0,S[8]=w.elements[6],S[9]=w.elements[7],S[10]=w.elements[8],S[11]=0):ArrayBuffer.isView(w)?S.set(new w.constructor(w.buffer,w.byteOffset,S.length)):w.toArray(S,_)}function v(w,S,_,D){const y=w.value,T=S+"_"+_;if(D[T]===void 0)return typeof y=="number"||typeof y=="boolean"?D[T]=y:ArrayBuffer.isView(y)?D[T]=y.slice():D[T]=y.clone(),!0;{const A=D[T];if(typeof y=="number"||typeof y=="boolean"){if(A!==y)return D[T]=y,!0}else{if(ArrayBuffer.isView(y))return!0;if(A.equals(y)===!1)return A.copy(y),!0}}return!1}function m(w){const S=w.uniforms;let _=0;const D=16;for(let T=0,A=S.length;T<A;T++){const I=Array.isArray(S[T])?S[T]:[S[T]];for(let R=0,k=I.length;R<k;R++){const z=I[R],L=Array.isArray(z.value)?z.value:[z.value];for(let B=0,F=L.length;B<F;B++){const V=L[B],j=g(V),$=_%D,ie=$%j.boundary,ae=$+ie;_+=ie,ae!==0&&D-ae<j.storage&&(_+=D-ae),z.__data=new Float32Array(j.storage/Float32Array.BYTES_PER_ELEMENT),z.__offset=_,_+=j.storage}}}const y=_%D;return y>0&&(_+=D-y),w.__size=_,w.__cache={},this}function g(w){const S={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(S.boundary=4,S.storage=4):w.isVector2?(S.boundary=8,S.storage=8):w.isVector3||w.isColor?(S.boundary=16,S.storage=12):w.isVector4?(S.boundary=16,S.storage=16):w.isMatrix3?(S.boundary=48,S.storage=48):w.isMatrix4?(S.boundary=64,S.storage=64):w.isTexture?_e("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(w)?(S.boundary=16,S.storage=w.byteLength):_e("WebGLRenderer: Unsupported uniform value type.",w),S}function x(w){const S=w.target;S.removeEventListener("dispose",x);const _=a.indexOf(S.__bindingPointIndex);a.splice(_,1),r.deleteBuffer(n[S.id]),delete n[S.id],delete s[S.id]}function M(){for(const w in n)r.deleteBuffer(n[w]);a=[],n={},s={}}return{bind:l,update:c,dispose:M}}const A3=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 An=null;function I3(){return An===null&&(An=new Mr(A3,16,16,vr,ui),An.name="DFG_LUT",An.minFilter=vt,An.magFilter=vt,An.wrapS=Ri,An.wrapT=Ri,An.generateMipmaps=!1,An.needsUpdate=!0),An}class D3{constructor(e={}){const{canvas:t=ny(),context:i=null,depth:n=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:f=$i}=e;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([tf,ef,Qu]),g=new Set([$i,yn,Do,Co,Ju,ju]),x=new Uint32Array(4),M=new Int32Array(4),w=new P;let S=null,_=null;const D=[],y=[];let T=null;this.domElement=t,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=Wn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const A=this;let I=!1,R=null,k=null,z=null,L=null;this._outputColorSpace=Bi;let B=0,F=0,V=null,j=-1,$=null;const ie=new at,ae=new at;let Ve=null;const je=new oe(0);let Ge=0,K=t.width,re=t.height,ne=1,G=null,Ee=null;const Pe=new at(0,0,K,re),Ie=new at(0,0,K,re);let be=!1;const ke=new cf;let Ne=!1,Oe=!1;const dt=new Ye,ut=new P,zt=new at,It={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ht=!1;function Zt(){return V===null?ne:1}let O=i;function Li(E,U){return t.getContext(E,U)}try{const E={alpha:!0,depth:n,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ku}`),t.addEventListener("webglcontextlost",Gt,!1),t.addEventListener("webglcontextrestored",xt,!1),t.addEventListener("webglcontextcreationerror",xn,!1),O===null){const U="webgl2";if(O=Li(U,E),O===null)throw Li(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(E){throw Ue("WebGLRenderer: "+E.message),E}let ft,C,b,H,q,Z,se,ce,J,ee,he,De,fe,de,Le,Fe,Xe,N,le,Q,ue,ve,te;function Ae(){ft=new Ix(O),ft.init(),ue=new b3(O,ft),C=new wx(O,ft,e,ue),b=new v3(O,ft),C.reversedDepthBuffer&&u&&b.buffers.depth.setReversed(!0),k=O.createFramebuffer(),z=O.createFramebuffer(),L=O.createFramebuffer(),H=new Rx(O),q=new n3,Z=new y3(O,ft,b,q,C,ue,H),se=new Ax(A),ce=new Nb(O),ve=new yx(O,ce),J=new Dx(O,ce,H,ve),ee=new Lx(O,J,ce,ve,H),N=new Px(O,C,Z),Le=new Mx(q),he=new i3(A,se,ft,C,ve,Le),De=new _3(A,q),fe=new r3,de=new d3(ft),Xe=new vx(A,se,b,ee,p,l),Fe=new g3(A,ee,C),te=new T3(O,H,C,b),le=new bx(O,ft,H),Q=new Cx(O,ft,H),H.programs=he.programs,A.capabilities=C,A.extensions=ft,A.properties=q,A.renderLists=fe,A.shadowMap=Fe,A.state=b,A.info=H}Ae(),v!==$i&&(T=new Nx(v,t.width,t.height,o,n,s));const Me=new S3(A,O);this.xr=Me,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){const E=ft.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=ft.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(E){E!==void 0&&(ne=E,this.setSize(K,re,!1))},this.getSize=function(E){return E.set(K,re)},this.setSize=function(E,U,Y=!0){if(Me.isPresenting){_e("WebGLRenderer: Can't change size while VR device is presenting.");return}K=E,re=U,t.width=Math.floor(E*ne),t.height=Math.floor(U*ne),Y===!0&&(t.style.width=E+"px",t.style.height=U+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,E,U)},this.getDrawingBufferSize=function(E){return E.set(K*ne,re*ne).floor()},this.setDrawingBufferSize=function(E,U,Y){K=E,re=U,ne=Y,t.width=Math.floor(E*Y),t.height=Math.floor(U*Y),this.setViewport(0,0,E,U)},this.setEffects=function(E){if(v===$i){Ue("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let U=0;U<E.length;U++)if(E[U].isOutputPass===!0){_e("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(E||[])},this.getCurrentViewport=function(E){return E.copy(ie)},this.getViewport=function(E){return E.copy(Pe)},this.setViewport=function(E,U,Y,W){E.isVector4?Pe.set(E.x,E.y,E.z,E.w):Pe.set(E,U,Y,W),b.viewport(ie.copy(Pe).multiplyScalar(ne).round())},this.getScissor=function(E){return E.copy(Ie)},this.setScissor=function(E,U,Y,W){E.isVector4?Ie.set(E.x,E.y,E.z,E.w):Ie.set(E,U,Y,W),b.scissor(ae.copy(Ie).multiplyScalar(ne).round())},this.getScissorTest=function(){return be},this.setScissorTest=function(E){b.setScissorTest(be=E)},this.setOpaqueSort=function(E){G=E},this.setTransparentSort=function(E){Ee=E},this.getClearColor=function(E){return E.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor(...arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha(...arguments)},this.clear=function(E=!0,U=!0,Y=!0){let W=0;if(E){let X=!1;if(V!==null){const ge=V.texture.format;X=m.has(ge)}if(X){const ge=V.texture.type,we=g.has(ge),me=Xe.getClearColor(),Se=Xe.getClearAlpha(),Ce=me.r,qe=me.g,$e=me.b;we?(x[0]=Ce,x[1]=qe,x[2]=$e,x[3]=Se,O.clearBufferuiv(O.COLOR,0,x)):(M[0]=Ce,M[1]=qe,M[2]=$e,M[3]=Se,O.clearBufferiv(O.COLOR,0,M))}else W|=O.COLOR_BUFFER_BIT}U&&(W|=O.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Y&&(W|=O.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),W!==0&&O.clear(W)},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),R=E},this.dispose=function(){t.removeEventListener("webglcontextlost",Gt,!1),t.removeEventListener("webglcontextrestored",xt,!1),t.removeEventListener("webglcontextcreationerror",xn,!1),Xe.dispose(),fe.dispose(),de.dispose(),q.dispose(),se.dispose(),ee.dispose(),ve.dispose(),te.dispose(),he.dispose(),Me.dispose(),Me.removeEventListener("sessionstart",Pf),Me.removeEventListener("sessionend",Lf),Gs.stop()};function Gt(E){E.preventDefault(),fc("WebGLRenderer: Context Lost."),I=!0}function xt(){fc("WebGLRenderer: Context Restored."),I=!1;const E=H.autoReset,U=Fe.enabled,Y=Fe.autoUpdate,W=Fe.needsUpdate,X=Fe.type;Ae(),H.autoReset=E,Fe.enabled=U,Fe.autoUpdate=Y,Fe.needsUpdate=W,Fe.type=X}function xn(E){Ue("WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Sn(E){const U=E.target;U.removeEventListener("dispose",Sn),$1(U)}function $1(E){Z1(E),q.remove(E)}function Z1(E){const U=q.get(E).programs;U!==void 0&&(U.forEach(function(Y){he.releaseProgram(Y)}),E.isShaderMaterial&&he.releaseShaderCache(E))}this.renderBufferDirect=function(E,U,Y,W,X,ge){U===null&&(U=It);const we=X.isMesh&&X.matrixWorld.determinantAffine()<0,me=Q1(E,U,Y,W,X);b.setMaterial(W,we);let Se=Y.index,Ce=1;if(W.wireframe===!0){if(Se=J.getWireframeAttribute(Y),Se===void 0)return;Ce=2}const qe=Y.drawRange,$e=Y.attributes.position;let Re=qe.start*Ce,yt=(qe.start+qe.count)*Ce;ge!==null&&(Re=Math.max(Re,ge.start*Ce),yt=Math.min(yt,(ge.start+ge.count)*Ce)),Se!==null?(Re=Math.max(Re,0),yt=Math.min(yt,Se.count)):$e!=null&&(Re=Math.max(Re,0),yt=Math.min(yt,$e.count));const Xt=yt-Re;if(Xt<0||Xt===1/0)return;ve.setup(X,W,me,Y,Se);let Vt,wt=le;if(Se!==null&&(Vt=ce.get(Se),wt=Q,wt.setIndex(Vt)),X.isMesh)W.wireframe===!0?(b.setLineWidth(W.wireframeLinewidth*Zt()),wt.setMode(O.LINES)):wt.setMode(O.TRIANGLES);else if(X.isLine){let wi=W.linewidth;wi===void 0&&(wi=1),b.setLineWidth(wi*Zt()),X.isLineSegments?wt.setMode(O.LINES):X.isLineLoop?wt.setMode(O.LINE_LOOP):wt.setMode(O.LINE_STRIP)}else X.isPoints?wt.setMode(O.POINTS):X.isSprite&&wt.setMode(O.TRIANGLES);if(X.isBatchedMesh)if(ft.get("WEBGL_multi_draw"))wt.renderMultiDraw(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount);else{const wi=X._multiDrawStarts,ye=X._multiDrawCounts,Hi=X._multiDrawCount,st=Se?ce.get(Se).bytesPerElement:1,Ji=q.get(W).currentProgram.getUniforms();for(let En=0;En<Hi;En++)Ji.setValue(O,"_gl_DrawID",En),wt.render(wi[En]/st,ye[En])}else if(X.isInstancedMesh)wt.renderInstances(Re,Xt,X.count);else if(Y.isInstancedBufferGeometry){const wi=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,ye=Math.min(Y.instanceCount,wi);wt.renderInstances(Re,Xt,ye)}else wt.render(Re,Xt)};function Rf(E,U,Y){E.transparent===!0&&E.side===pn&&E.forceSinglePass===!1?(E.side=Ft,E.needsUpdate=!0,Go(E,U,Y),E.side=Bs,E.needsUpdate=!0,Go(E,U,Y),E.side=pn):Go(E,U,Y)}this.compile=function(E,U,Y=null){Y===null&&(Y=E),_=de.get(Y),_.init(U),y.push(_),Y.traverseVisible(function(X){X.isLight&&X.layers.test(U.layers)&&(_.pushLight(X),X.castShadow&&_.pushShadow(X))}),E!==Y&&E.traverseVisible(function(X){X.isLight&&X.layers.test(U.layers)&&(_.pushLight(X),X.castShadow&&_.pushShadow(X))}),_.setupLights();const W=new Set;return E.traverse(function(X){if(!(X.isMesh||X.isPoints||X.isLine||X.isSprite))return;const ge=X.material;if(ge)if(Array.isArray(ge))for(let we=0;we<ge.length;we++){const me=ge[we];Rf(me,Y,X),W.add(me)}else Rf(ge,Y,X),W.add(ge)}),_=y.pop(),W},this.compileAsync=function(E,U,Y=null){const W=this.compile(E,U,Y);return new Promise(X=>{function ge(){if(W.forEach(function(we){q.get(we).currentProgram.isReady()&&W.delete(we)}),W.size===0){X(E);return}setTimeout(ge,10)}ft.get("KHR_parallel_shader_compile")!==null?ge():setTimeout(ge,10)})};let Gc=null;function J1(E){Gc&&Gc(E)}function Pf(){Gs.stop()}function Lf(){Gs.start()}const Gs=new e1;Gs.setAnimationLoop(J1),typeof self<"u"&&Gs.setContext(self),this.setAnimationLoop=function(E){Gc=E,Me.setAnimationLoop(E),E===null?Gs.stop():Gs.start()},Me.addEventListener("sessionstart",Pf),Me.addEventListener("sessionend",Lf),this.render=function(E,U){if(U!==void 0&&U.isCamera!==!0){Ue("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(I===!0)return;R!==null&&R.renderStart(E,U);const Y=Me.enabled===!0&&Me.isPresenting===!0,W=T!==null&&(V===null||Y)&&T.begin(A,V);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),Me.enabled===!0&&Me.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Me.cameraAutoUpdate===!0&&Me.updateCamera(U),U=Me.getCamera()),E.isScene===!0&&E.onBeforeRender(A,E,U,V),_=de.get(E,y.length),_.init(U),_.state.textureUnits=Z.getTextureUnits(),y.push(_),dt.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),ke.setFromProjectionMatrix(dt,Hn,U.reversedDepth),Oe=this.localClippingEnabled,Ne=Le.init(this.clippingPlanes,Oe),S=fe.get(E,D.length),S.init(),D.push(S),Me.enabled===!0&&Me.isPresenting===!0){const we=A.xr.getDepthSensingMesh();we!==null&&Vc(we,U,-1/0,A.sortObjects)}Vc(E,U,0,A.sortObjects),S.finish(),A.sortObjects===!0&&S.sort(G,Ee,U.reversedDepth),Ht=Me.enabled===!1||Me.isPresenting===!1||Me.hasDepthSensing()===!1,Ht&&Xe.addToRenderList(S,E),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ne===!0&&Le.beginShadows();const X=_.state.shadowsArray;if(Fe.render(X,E,U),Ne===!0&&Le.endShadows(),(W&&T.hasRenderPass())===!1){const we=S.opaque,me=S.transmissive;if(_.setupLights(),U.isArrayCamera){const Se=U.cameras;if(me.length>0)for(let Ce=0,qe=Se.length;Ce<qe;Ce++){const $e=Se[Ce];Nf(we,me,E,$e)}Ht&&Xe.render(E);for(let Ce=0,qe=Se.length;Ce<qe;Ce++){const $e=Se[Ce];kf(S,E,$e,$e.viewport)}}else me.length>0&&Nf(we,me,E,U),Ht&&Xe.render(E),kf(S,E,U)}V!==null&&F===0&&(Z.updateMultisampleRenderTarget(V),Z.updateRenderTargetMipmap(V)),W&&T.end(A),E.isScene===!0&&E.onAfterRender(A,E,U),ve.resetDefaultState(),j=-1,$=null,y.pop(),y.length>0?(_=y[y.length-1],Z.setTextureUnits(_.state.textureUnits),Ne===!0&&Le.setGlobalState(A.clippingPlanes,_.state.camera)):_=null,D.pop(),D.length>0?S=D[D.length-1]:S=null,R!==null&&R.renderEnd()};function Vc(E,U,Y,W){if(E.visible===!1)return;if(E.layers.test(U.layers)){if(E.isGroup)Y=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(U);else if(E.isLightProbeGrid)_.pushLightProbeGrid(E);else if(E.isLight)_.pushLight(E),E.castShadow&&_.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||ke.intersectsSprite(E)){W&&zt.setFromMatrixPosition(E.matrixWorld).applyMatrix4(dt);const we=ee.update(E),me=E.material;me.visible&&S.push(E,we,me,Y,zt.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||ke.intersectsObject(E))){const we=ee.update(E),me=E.material;if(W&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),zt.copy(E.boundingSphere.center)):(we.boundingSphere===null&&we.computeBoundingSphere(),zt.copy(we.boundingSphere.center)),zt.applyMatrix4(E.matrixWorld).applyMatrix4(dt)),Array.isArray(me)){const Se=we.groups;for(let Ce=0,qe=Se.length;Ce<qe;Ce++){const $e=Se[Ce],Re=me[$e.materialIndex];Re&&Re.visible&&S.push(E,we,Re,Y,zt.z,$e)}}else me.visible&&S.push(E,we,me,Y,zt.z,null)}}const ge=E.children;for(let we=0,me=ge.length;we<me;we++)Vc(ge[we],U,Y,W)}function kf(E,U,Y,W){const{opaque:X,transmissive:ge,transparent:we}=E;_.setupLightsView(Y),Ne===!0&&Le.setGlobalState(A.clippingPlanes,Y),W&&b.viewport(ie.copy(W)),X.length>0&&Ho(X,U,Y),ge.length>0&&Ho(ge,U,Y),we.length>0&&Ho(we,U,Y),b.buffers.depth.setTest(!0),b.buffers.depth.setMask(!0),b.buffers.color.setMask(!0),b.setPolygonOffset(!1)}function Nf(E,U,Y,W){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;if(_.state.transmissionRenderTarget[W.id]===void 0){const Re=ft.has("EXT_color_buffer_half_float")||ft.has("EXT_color_buffer_float");_.state.transmissionRenderTarget[W.id]=new vi(1,1,{generateMipmaps:!0,type:Re?ui:$i,minFilter:or,samples:Math.max(4,C.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:tt.workingColorSpace})}const ge=_.state.transmissionRenderTarget[W.id],we=W.viewport||ie;ge.setSize(we.z*A.transmissionResolutionScale,we.w*A.transmissionResolutionScale);const me=A.getRenderTarget(),Se=A.getActiveCubeFace(),Ce=A.getActiveMipmapLevel();A.setRenderTarget(ge),A.getClearColor(je),Ge=A.getClearAlpha(),Ge<1&&A.setClearColor(16777215,.5),A.clear(),Ht&&Xe.render(Y);const qe=A.toneMapping;A.toneMapping=Wn;const $e=W.viewport;if(W.viewport!==void 0&&(W.viewport=void 0),_.setupLightsView(W),Ne===!0&&Le.setGlobalState(A.clippingPlanes,W),Ho(E,Y,W),Z.updateMultisampleRenderTarget(ge),Z.updateRenderTargetMipmap(ge),ft.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let yt=0,Xt=U.length;yt<Xt;yt++){const Vt=U[yt],{object:wt,geometry:wi,material:ye,group:Hi}=Vt;if(ye.side===pn&&wt.layers.test(W.layers)){const st=ye.side;ye.side=Ft,ye.needsUpdate=!0,Of(wt,Y,W,wi,ye,Hi),ye.side=st,ye.needsUpdate=!0,Re=!0}}Re===!0&&(Z.updateMultisampleRenderTarget(ge),Z.updateRenderTargetMipmap(ge))}A.setRenderTarget(me,Se,Ce),A.setClearColor(je,Ge),$e!==void 0&&(W.viewport=$e),A.toneMapping=qe}function Ho(E,U,Y){const W=U.isScene===!0?U.overrideMaterial:null;for(let X=0,ge=E.length;X<ge;X++){const we=E[X],{object:me,geometry:Se,group:Ce}=we;let qe=we.material;qe.allowOverride===!0&&W!==null&&(qe=W),me.layers.test(Y.layers)&&Of(me,U,Y,Se,qe,Ce)}}function Of(E,U,Y,W,X,ge){E.onBeforeRender(A,U,Y,W,X,ge),E.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),X.onBeforeRender(A,U,Y,W,E,ge),X.transparent===!0&&X.side===pn&&X.forceSinglePass===!1?(X.side=Ft,X.needsUpdate=!0,A.renderBufferDirect(Y,U,W,X,E,ge),X.side=Bs,X.needsUpdate=!0,A.renderBufferDirect(Y,U,W,X,E,ge),X.side=pn):A.renderBufferDirect(Y,U,W,X,E,ge),E.onAfterRender(A,U,Y,W,X,ge)}function Go(E,U,Y){U.isScene!==!0&&(U=It);const W=q.get(E),X=_.state.lights,ge=_.state.shadowsArray,we=X.state.version,me=he.getParameters(E,X.state,ge,U,Y,_.state.lightProbeGridArray),Se=he.getProgramCacheKey(me);let Ce=W.programs;W.environment=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?U.environment:null,W.fog=U.fog;const qe=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap;W.envMap=se.get(E.envMap||W.environment,qe),W.envMapRotation=W.environment!==null&&E.envMap===null?U.environmentRotation:E.envMapRotation,Ce===void 0&&(E.addEventListener("dispose",Sn),Ce=new Map,W.programs=Ce);let $e=Ce.get(Se);if($e!==void 0){if(W.currentProgram===$e&&W.lightsStateVersion===we)return Uf(E,me),$e}else me.uniforms=he.getUniforms(E),R!==null&&E.isNodeMaterial&&R.build(E,Y,me),E.onBeforeCompile(me,A),$e=he.acquireProgram(me,Se),Ce.set(Se,$e),W.uniforms=me.uniforms;const Re=W.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Re.clippingPlanes=Le.uniform),Uf(E,me),W.needsLights=tv(E),W.lightsStateVersion=we,W.needsLights&&(Re.ambientLightColor.value=X.state.ambient,Re.lightProbe.value=X.state.probe,Re.directionalLights.value=X.state.directional,Re.directionalLightShadows.value=X.state.directionalShadow,Re.spotLights.value=X.state.spot,Re.spotLightShadows.value=X.state.spotShadow,Re.rectAreaLights.value=X.state.rectArea,Re.ltc_1.value=X.state.rectAreaLTC1,Re.ltc_2.value=X.state.rectAreaLTC2,Re.pointLights.value=X.state.point,Re.pointLightShadows.value=X.state.pointShadow,Re.hemisphereLights.value=X.state.hemi,Re.directionalShadowMatrix.value=X.state.directionalShadowMatrix,Re.spotLightMatrix.value=X.state.spotLightMatrix,Re.spotLightMap.value=X.state.spotLightMap,Re.pointShadowMatrix.value=X.state.pointShadowMatrix),W.lightProbeGrid=_.state.lightProbeGridArray.length>0,W.currentProgram=$e,W.uniformsList=null,$e}function Ff(E){if(E.uniformsList===null){const U=E.currentProgram.getUniforms();E.uniformsList=Zl.seqWithValue(U.seq,E.uniforms)}return E.uniformsList}function Uf(E,U){const Y=q.get(E);Y.outputColorSpace=U.outputColorSpace,Y.batching=U.batching,Y.batchingColor=U.batchingColor,Y.instancing=U.instancing,Y.instancingColor=U.instancingColor,Y.instancingMorph=U.instancingMorph,Y.skinning=U.skinning,Y.morphTargets=U.morphTargets,Y.morphNormals=U.morphNormals,Y.morphColors=U.morphColors,Y.morphTargetsCount=U.morphTargetsCount,Y.numClippingPlanes=U.numClippingPlanes,Y.numIntersection=U.numClipIntersection,Y.vertexAlphas=U.vertexAlphas,Y.vertexTangents=U.vertexTangents,Y.toneMapping=U.toneMapping}function j1(E,U){if(E.length===0)return null;if(E.length===1)return E[0].texture!==null?E[0]:null;w.setFromMatrixPosition(U.matrixWorld);for(let Y=0,W=E.length;Y<W;Y++){const X=E[Y];if(X.texture!==null&&X.boundingBox.containsPoint(w))return X}return null}function Q1(E,U,Y,W,X){U.isScene!==!0&&(U=It),Z.resetTextureUnits();const ge=U.fog,we=W.isMeshStandardMaterial||W.isMeshLambertMaterial||W.isMeshPhongMaterial?U.environment:null,me=V===null?A.outputColorSpace:V.isXRRenderTarget===!0?V.texture.colorSpace:tt.workingColorSpace,Se=W.isMeshStandardMaterial||W.isMeshLambertMaterial&&!W.envMap||W.isMeshPhongMaterial&&!W.envMap,Ce=se.get(W.envMap||we,Se),qe=W.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,$e=!!Y.attributes.tangent&&(!!W.normalMap||W.anisotropy>0),Re=!!Y.morphAttributes.position,yt=!!Y.morphAttributes.normal,Xt=!!Y.morphAttributes.color;let Vt=Wn;W.toneMapped&&(V===null||V.isXRRenderTarget===!0)&&(Vt=A.toneMapping);const wt=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,wi=wt!==void 0?wt.length:0,ye=q.get(W),Hi=_.state.lights;if(Ne===!0&&(Oe===!0||E!==$)){const St=E===$&&W.id===j;Le.setState(W,E,St)}let st=!1;W.version===ye.__version?(ye.needsLights&&ye.lightsStateVersion!==Hi.state.version||ye.outputColorSpace!==me||X.isBatchedMesh&&ye.batching===!1||!X.isBatchedMesh&&ye.batching===!0||X.isBatchedMesh&&ye.batchingColor===!0&&X.colorTexture===null||X.isBatchedMesh&&ye.batchingColor===!1&&X.colorTexture!==null||X.isInstancedMesh&&ye.instancing===!1||!X.isInstancedMesh&&ye.instancing===!0||X.isSkinnedMesh&&ye.skinning===!1||!X.isSkinnedMesh&&ye.skinning===!0||X.isInstancedMesh&&ye.instancingColor===!0&&X.instanceColor===null||X.isInstancedMesh&&ye.instancingColor===!1&&X.instanceColor!==null||X.isInstancedMesh&&ye.instancingMorph===!0&&X.morphTexture===null||X.isInstancedMesh&&ye.instancingMorph===!1&&X.morphTexture!==null||ye.envMap!==Ce||W.fog===!0&&ye.fog!==ge||ye.numClippingPlanes!==void 0&&(ye.numClippingPlanes!==Le.numPlanes||ye.numIntersection!==Le.numIntersection)||ye.vertexAlphas!==qe||ye.vertexTangents!==$e||ye.morphTargets!==Re||ye.morphNormals!==yt||ye.morphColors!==Xt||ye.toneMapping!==Vt||ye.morphTargetsCount!==wi||!!ye.lightProbeGrid!=_.state.lightProbeGridArray.length>0)&&(st=!0):(st=!0,ye.__version=W.version);let Ji=ye.currentProgram;st===!0&&(Ji=Go(W,U,X),R&&W.isNodeMaterial&&R.onUpdateProgram(W,Ji,ye));let En=!1,gs=!1,xr=!1;const Mt=Ji.getUniforms(),qt=ye.uniforms;if(b.useProgram(Ji.program)&&(En=!0,gs=!0,xr=!0),W.id!==j&&(j=W.id,gs=!0),ye.needsLights){const St=j1(_.state.lightProbeGridArray,X);ye.lightProbeGrid!==St&&(ye.lightProbeGrid=St,gs=!0)}if(En||$!==E){b.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),Mt.setValue(O,"projectionMatrix",E.projectionMatrix),Mt.setValue(O,"viewMatrix",E.matrixWorldInverse);const ys=Mt.map.cameraPosition;ys!==void 0&&ys.setValue(O,ut.setFromMatrixPosition(E.matrixWorld)),C.logarithmicDepthBuffer&&Mt.setValue(O,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(W.isMeshPhongMaterial||W.isMeshToonMaterial||W.isMeshLambertMaterial||W.isMeshBasicMaterial||W.isMeshStandardMaterial||W.isShaderMaterial)&&Mt.setValue(O,"isOrthographic",E.isOrthographicCamera===!0),$!==E&&($=E,gs=!0,xr=!0)}if(ye.needsLights&&(Hi.state.directionalShadowMap.length>0&&Mt.setValue(O,"directionalShadowMap",Hi.state.directionalShadowMap,Z),Hi.state.spotShadowMap.length>0&&Mt.setValue(O,"spotShadowMap",Hi.state.spotShadowMap,Z),Hi.state.pointShadowMap.length>0&&Mt.setValue(O,"pointShadowMap",Hi.state.pointShadowMap,Z)),X.isSkinnedMesh){Mt.setOptional(O,X,"bindMatrix"),Mt.setOptional(O,X,"bindMatrixInverse");const St=X.skeleton;St&&(St.boneTexture===null&&St.computeBoneTexture(),Mt.setValue(O,"boneTexture",St.boneTexture,Z))}X.isBatchedMesh&&(Mt.setOptional(O,X,"batchingTexture"),Mt.setValue(O,"batchingTexture",X._matricesTexture,Z),Mt.setOptional(O,X,"batchingIdTexture"),Mt.setValue(O,"batchingIdTexture",X._indirectTexture,Z),Mt.setOptional(O,X,"batchingColorTexture"),X._colorsTexture!==null&&Mt.setValue(O,"batchingColorTexture",X._colorsTexture,Z));const vs=Y.morphAttributes;if((vs.position!==void 0||vs.normal!==void 0||vs.color!==void 0)&&N.update(X,Y,Ji),(gs||ye.receiveShadow!==X.receiveShadow)&&(ye.receiveShadow=X.receiveShadow,Mt.setValue(O,"receiveShadow",X.receiveShadow)),(W.isMeshStandardMaterial||W.isMeshLambertMaterial||W.isMeshPhongMaterial)&&W.envMap===null&&U.environment!==null&&(qt.envMapIntensity.value=U.environmentIntensity),qt.dfgLUT!==void 0&&(qt.dfgLUT.value=I3()),gs){if(Mt.setValue(O,"toneMappingExposure",A.toneMappingExposure),ye.needsLights&&ev(qt,xr),ge&&W.fog===!0&&De.refreshFogUniforms(qt,ge),De.refreshMaterialUniforms(qt,W,ne,re,_.state.transmissionRenderTarget[E.id]),ye.needsLights&&ye.lightProbeGrid){const St=ye.lightProbeGrid;qt.probesSH.value=St.texture,qt.probesMin.value.copy(St.boundingBox.min),qt.probesMax.value.copy(St.boundingBox.max),qt.probesResolution.value.copy(St.resolution)}Zl.upload(O,Ff(ye),qt,Z)}if(W.isShaderMaterial&&W.uniformsNeedUpdate===!0&&(Zl.upload(O,Ff(ye),qt,Z),W.uniformsNeedUpdate=!1),W.isSpriteMaterial&&Mt.setValue(O,"center",X.center),Mt.setValue(O,"modelViewMatrix",X.modelViewMatrix),Mt.setValue(O,"normalMatrix",X.normalMatrix),Mt.setValue(O,"modelMatrix",X.matrixWorld),W.uniformsGroups!==void 0){const St=W.uniformsGroups;for(let ys=0,Sr=St.length;ys<Sr;ys++){const Bf=St[ys];te.update(Bf,Ji),te.bind(Bf,Ji)}}return Ji}function ev(E,U){E.ambientLightColor.needsUpdate=U,E.lightProbe.needsUpdate=U,E.directionalLights.needsUpdate=U,E.directionalLightShadows.needsUpdate=U,E.pointLights.needsUpdate=U,E.pointLightShadows.needsUpdate=U,E.spotLights.needsUpdate=U,E.spotLightShadows.needsUpdate=U,E.rectAreaLights.needsUpdate=U,E.hemisphereLights.needsUpdate=U}function tv(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 F},this.getRenderTarget=function(){return V},this.setRenderTargetTextures=function(E,U,Y){const W=q.get(E);W.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,W.__autoAllocateDepthBuffer===!1&&(W.__useRenderToTexture=!1),q.get(E.texture).__webglTexture=U,q.get(E.depthTexture).__webglTexture=W.__autoAllocateDepthBuffer?void 0:Y,W.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,U){const Y=q.get(E);Y.__webglFramebuffer=U,Y.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(E,U=0,Y=0){V=E,B=U,F=Y;let W=null,X=!1,ge=!1;if(E){const me=q.get(E);if(me.__useDefaultFramebuffer!==void 0){b.bindFramebuffer(O.FRAMEBUFFER,me.__webglFramebuffer),ie.copy(E.viewport),ae.copy(E.scissor),Ve=E.scissorTest,b.viewport(ie),b.scissor(ae),b.setScissorTest(Ve),j=-1;return}else if(me.__webglFramebuffer===void 0)Z.setupRenderTarget(E);else if(me.__hasExternalTextures)Z.rebindTextures(E,q.get(E.texture).__webglTexture,q.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const qe=E.depthTexture;if(me.__boundDepthTexture!==qe){if(qe!==null&&q.has(qe)&&(E.width!==qe.image.width||E.height!==qe.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Z.setupDepthRenderbuffer(E)}}const Se=E.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(ge=!0);const Ce=q.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Ce[U])?W=Ce[U][Y]:W=Ce[U],X=!0):E.samples>0&&Z.useMultisampledRTT(E)===!1?W=q.get(E).__webglMultisampledFramebuffer:Array.isArray(Ce)?W=Ce[Y]:W=Ce,ie.copy(E.viewport),ae.copy(E.scissor),Ve=E.scissorTest}else ie.copy(Pe).multiplyScalar(ne).floor(),ae.copy(Ie).multiplyScalar(ne).floor(),Ve=be;if(Y!==0&&(W=k),b.bindFramebuffer(O.FRAMEBUFFER,W)&&b.drawBuffers(E,W),b.viewport(ie),b.scissor(ae),b.setScissorTest(Ve),X){const me=q.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_CUBE_MAP_POSITIVE_X+U,me.__webglTexture,Y)}else if(ge){const me=U;for(let Se=0;Se<E.textures.length;Se++){const Ce=q.get(E.textures[Se]);O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0+Se,Ce.__webglTexture,Y,me)}}else if(E!==null&&Y!==0){const me=q.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,me.__webglTexture,Y)}j=-1},this.readRenderTargetPixels=function(E,U,Y,W,X,ge,we,me=0){if(!(E&&E.isWebGLRenderTarget)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=q.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&we!==void 0&&(Se=Se[we]),Se){b.bindFramebuffer(O.FRAMEBUFFER,Se);try{const Ce=E.textures[me],qe=Ce.format,$e=Ce.type;if(E.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+me),!C.textureFormatReadable(qe)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!C.textureTypeReadable($e)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=E.width-W&&Y>=0&&Y<=E.height-X&&O.readPixels(U,Y,W,X,ue.convert(qe),ue.convert($e),ge)}finally{const Ce=V!==null?q.get(V).__webglFramebuffer:null;b.bindFramebuffer(O.FRAMEBUFFER,Ce)}}},this.readRenderTargetPixelsAsync=async function(E,U,Y,W,X,ge,we,me=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=q.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&we!==void 0&&(Se=Se[we]),Se)if(U>=0&&U<=E.width-W&&Y>=0&&Y<=E.height-X){b.bindFramebuffer(O.FRAMEBUFFER,Se);const Ce=E.textures[me],qe=Ce.format,$e=Ce.type;if(E.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+me),!C.textureFormatReadable(qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!C.textureTypeReadable($e))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Re=O.createBuffer();O.bindBuffer(O.PIXEL_PACK_BUFFER,Re),O.bufferData(O.PIXEL_PACK_BUFFER,ge.byteLength,O.STREAM_READ),O.readPixels(U,Y,W,X,ue.convert(qe),ue.convert($e),0);const yt=V!==null?q.get(V).__webglFramebuffer:null;b.bindFramebuffer(O.FRAMEBUFFER,yt);const Xt=O.fenceSync(O.SYNC_GPU_COMMANDS_COMPLETE,0);return O.flush(),await sy(O,Xt,4),O.bindBuffer(O.PIXEL_PACK_BUFFER,Re),O.getBufferSubData(O.PIXEL_PACK_BUFFER,0,ge),O.deleteBuffer(Re),O.deleteSync(Xt),ge}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,U=null,Y=0){const W=Math.pow(2,-Y),X=Math.floor(E.image.width*W),ge=Math.floor(E.image.height*W),we=U!==null?U.x:0,me=U!==null?U.y:0;Z.setTexture2D(E,0),O.copyTexSubImage2D(O.TEXTURE_2D,Y,0,0,we,me,X,ge),b.unbindTexture()},this.copyTextureToTexture=function(E,U,Y=null,W=null,X=0,ge=0){let we,me,Se,Ce,qe,$e,Re,yt,Xt;const Vt=E.isCompressedTexture?E.mipmaps[ge]:E.image;if(Y!==null)we=Y.max.x-Y.min.x,me=Y.max.y-Y.min.y,Se=Y.isBox3?Y.max.z-Y.min.z:1,Ce=Y.min.x,qe=Y.min.y,$e=Y.isBox3?Y.min.z:0;else{const qt=Math.pow(2,-X);we=Math.floor(Vt.width*qt),me=Math.floor(Vt.height*qt),E.isDataArrayTexture?Se=Vt.depth:E.isData3DTexture?Se=Math.floor(Vt.depth*qt):Se=1,Ce=0,qe=0,$e=0}W!==null?(Re=W.x,yt=W.y,Xt=W.z):(Re=0,yt=0,Xt=0);const wt=ue.convert(U.format),wi=ue.convert(U.type);let ye;U.isData3DTexture?(Z.setTexture3D(U,0),ye=O.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(Z.setTexture2DArray(U,0),ye=O.TEXTURE_2D_ARRAY):(Z.setTexture2D(U,0),ye=O.TEXTURE_2D),b.activeTexture(O.TEXTURE0),b.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,U.flipY),b.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),b.pixelStorei(O.UNPACK_ALIGNMENT,U.unpackAlignment);const Hi=b.getParameter(O.UNPACK_ROW_LENGTH),st=b.getParameter(O.UNPACK_IMAGE_HEIGHT),Ji=b.getParameter(O.UNPACK_SKIP_PIXELS),En=b.getParameter(O.UNPACK_SKIP_ROWS),gs=b.getParameter(O.UNPACK_SKIP_IMAGES);b.pixelStorei(O.UNPACK_ROW_LENGTH,Vt.width),b.pixelStorei(O.UNPACK_IMAGE_HEIGHT,Vt.height),b.pixelStorei(O.UNPACK_SKIP_PIXELS,Ce),b.pixelStorei(O.UNPACK_SKIP_ROWS,qe),b.pixelStorei(O.UNPACK_SKIP_IMAGES,$e);const xr=E.isDataArrayTexture||E.isData3DTexture,Mt=U.isDataArrayTexture||U.isData3DTexture;if(E.isDepthTexture){const qt=q.get(E),vs=q.get(U),St=q.get(qt.__renderTarget),ys=q.get(vs.__renderTarget);b.bindFramebuffer(O.READ_FRAMEBUFFER,St.__webglFramebuffer),b.bindFramebuffer(O.DRAW_FRAMEBUFFER,ys.__webglFramebuffer);for(let Sr=0;Sr<Se;Sr++)xr&&(O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,q.get(E).__webglTexture,X,$e+Sr),O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,q.get(U).__webglTexture,ge,Xt+Sr)),O.blitFramebuffer(Ce,qe,we,me,Re,yt,we,me,O.DEPTH_BUFFER_BIT,O.NEAREST);b.bindFramebuffer(O.READ_FRAMEBUFFER,null),b.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(X!==0||E.isRenderTargetTexture||q.has(E)){const qt=q.get(E),vs=q.get(U);b.bindFramebuffer(O.READ_FRAMEBUFFER,z),b.bindFramebuffer(O.DRAW_FRAMEBUFFER,L);for(let St=0;St<Se;St++)xr?O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,qt.__webglTexture,X,$e+St):O.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,qt.__webglTexture,X),Mt?O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,vs.__webglTexture,ge,Xt+St):O.framebufferTexture2D(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,vs.__webglTexture,ge),X!==0?O.blitFramebuffer(Ce,qe,we,me,Re,yt,we,me,O.COLOR_BUFFER_BIT,O.NEAREST):Mt?O.copyTexSubImage3D(ye,ge,Re,yt,Xt+St,Ce,qe,we,me):O.copyTexSubImage2D(ye,ge,Re,yt,Ce,qe,we,me);b.bindFramebuffer(O.READ_FRAMEBUFFER,null),b.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else Mt?E.isDataTexture||E.isData3DTexture?O.texSubImage3D(ye,ge,Re,yt,Xt,we,me,Se,wt,wi,Vt.data):U.isCompressedArrayTexture?O.compressedTexSubImage3D(ye,ge,Re,yt,Xt,we,me,Se,wt,Vt.data):O.texSubImage3D(ye,ge,Re,yt,Xt,we,me,Se,wt,wi,Vt):E.isDataTexture?O.texSubImage2D(O.TEXTURE_2D,ge,Re,yt,we,me,wt,wi,Vt.data):E.isCompressedTexture?O.compressedTexSubImage2D(O.TEXTURE_2D,ge,Re,yt,Vt.width,Vt.height,wt,Vt.data):O.texSubImage2D(O.TEXTURE_2D,ge,Re,yt,we,me,wt,wi,Vt);b.pixelStorei(O.UNPACK_ROW_LENGTH,Hi),b.pixelStorei(O.UNPACK_IMAGE_HEIGHT,st),b.pixelStorei(O.UNPACK_SKIP_PIXELS,Ji),b.pixelStorei(O.UNPACK_SKIP_ROWS,En),b.pixelStorei(O.UNPACK_SKIP_IMAGES,gs),ge===0&&U.generateMipmaps&&O.generateMipmap(ye),b.unbindTexture()},this.initRenderTarget=function(E){q.get(E).__webglFramebuffer===void 0&&Z.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?Z.setTextureCube(E,0):E.isData3DTexture?Z.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?Z.setTexture2DArray(E,0):Z.setTexture2D(E,0),b.unbindTexture()},this.resetState=function(){B=0,F=0,V=null,b.reset(),ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Hn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=tt._getDrawingBufferColorSpace(e),t.unpackColorSpace=tt._getUnpackColorSpace()}}const C3=`
6220
6220
  varying vec3 vDir;
6221
6221
 
6222
6222
  void main() {
@@ -6588,7 +6588,7 @@ float transmissionAt(vec3 dir, float distanceM) {
6588
6588
  if (transmission < 0.015) break;
6589
6589
  }
6590
6590
  return transmission;
6591
- }`,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(e+t).replace(i,n=>r+n)}class yc{mesh;uniforms;constructor(e,t){this.uniforms={noiseMap:{value:e},sunDir:{value:new P(0,1,0)},sunColor:{value:new oe(1,1,1)},ambientColor:{value:new oe(.4,.45,.5)},hazeColor:{value:new oe(.5,.6,.7)},offsetM:{value:new P},seedOffset:{value:new P},localCenter:{value:new P},localSize:{value:new P},localRotation:{value:0},holeCount:{value:0},holeCenter:{value:Array.from({length:Za},()=>new P)},holeSize:{value:Array.from({length:Za},()=>new P)},holeRotation:{value:new Array(Za).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 Ot({uniforms:this.uniforms,vertexShader:F3,fragmentShader:gu,transparent:!0,depthWrite:!1,depthTest:!0,side:Ft});this.mesh=new We(new yi(t,32,16),i),this.mesh.frustumCulled=!1}update(e,t,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(Za,n.length),n.slice(0,Za).forEach((o,l)=>{s.holeCenter.value[l].set(o.eastM,o.baseM+o.thicknessM/2,-o.northM),s.holeSize.value[l].set(o.widthM,o.thicknessM,o.depthM),s.holeRotation.value[l]=o.rotationDeg*Math.PI/180}),s.baseM.value=Math.max(0,e.baseM),s.thicknessM.value=Math.max(10,e.thicknessM),s.coverage.value=Math.max(0,Math.min(1,e.coverage)),s.sizeM.value=Math.max(50,e.sizeM),s.density.value=Math.max(0,Math.min(2,e.density)),s.darkness.value=Math.max(0,Math.min(1,e.darkness??0)),s.eyeM.value=Math.max(.1,t),s.flatness.value=e.type==="stratus"?1:e.type==="stratocumulus"?.45:0;const a=mu(e);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(e){const t=Math.min(.999,Math.max(.001,e));return .645-.23*(Math.sqrt(3)/Math.PI)*Math.log(t/(1-t))}densityAt(e){const t=this.uniforms,i=(k,z,L)=>{const B=Math.max(0,Math.min(1,(L-k)/(z-k)));return B*B*(3-2*B)},n=(k,z,L)=>k+(z-k)*L,s=t.eyeM.value+e.y,a=2*aa*s+e.x**2+s**2+e.z**2,o=a/(Math.sqrt(aa**2+a)+aa),l=(o-t.baseM.value)/t.thicknessM.value,c=t.localSize.value.x>0;if(l<=0||l>=1||t.coverage.value<=0&&!c)return 0;const h=(k,z,L)=>{const B=e.x+t.offsetM.value.x-k.x,F=e.z+t.offsetM.value.z-k.z,V=Math.cos(L),j=Math.sin(L);return Math.hypot((V*B-j*F)/(z.x*.5),(o-k.y)/(z.y*.5),(j*B+V*F)/(z.z*.5))},d=c?h(t.localCenter.value,t.localSize.value,t.localRotation.value):0;if(d>1.3)return 0;const u=[e.x,e.y,e.z].map((k,z)=>(k+t.offsetM.value.getComponent(z))/(t.sizeM.value*4)+t.seedOffset.value.getComponent(z)),f=t.noiseMap.value.image.data,p=(k,z,L)=>{const B=[k,z,L].map($=>($%1+1)%1*Kt-.5),F=B.map(Math.floor),V=B.map(($,ie)=>$-F[ie]);let j=0;for(let $=0;$<2;$++)for(let ie=0;ie<2;ie++)for(let ae=0;ae<2;ae++){const Ve=(F[0]+ae+Kt)%Kt,je=(F[1]+ie+Kt)%Kt,He=(F[2]+$+Kt)%Kt;j+=f[Ve+Kt*(je+Kt*He)]/255*(ae?V[0]:1-V[0])*(ie?V[1]:1-V[1])*($?V[2]:1-V[2])}return j},v=[u[0]*.173,Lh,u[2]*.173];u[0]+=(p(v[0]+.13,v[1]+.27,v[2]+.41)-.5)*1.3,u[2]+=(p(v[0]+.67,v[1]+.53,v[2]+.19)-.5)*1.3;const m=(u[0]*.731+u[2]*.682)*1.371,g=(-u[0]*.682+u[2]*.731)*1.371;let x=i(.2,.8,p(u[0],Lh,u[2])*.65+p(m,Lh+.37,g)*.35);const M=i(8e3,4e4,Math.hypot(e.x,e.y,e.z)),w=n(p(u[0]*2,u[1]*3,u[2]*2),.5,M),S=n(p(u[0]*7,u[1]*7,u[2]*7),.5,M);let _=yc.thresholdFor(t.coverage.value),D=1,y=0;if(c){const k=d+(w-.5)*.18;y=1-i(.35,1,k),D=1-i(.85,1.15,k),x=n(x,1,y),_=Math.min(_,yc.thresholdFor(.5))}for(let k=0;k<t.holeCount.value;k++)D*=i(.85,1.15,h(t.holeCenter.value[k],t.holeSize.value[k],t.holeRotation.value[k])+(w-.5)*.18);if(D<.001)return 0;let T=i(_-.1,_+.1,x);if(T=n(T,1,i(.92,1,t.coverage.value)),T=n(T,Math.max(t.coverage.value,y),M),T<.001)return 0;const A=n(.45+.55*w,.96,t.flatness.value),I=i(0,.09,l)*(1-i(A-.22,A,l)),R=n(Math.max(0,T-(1-w)*.38-(1-S)*.1),T*.8,t.flatness.value);return I*R*t.density.value*D}transmissionAt(e,t=1/0){const i=this.uniforms,n=O3(e.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*aa);const d=i.localSize.value.length()*.5+25,u=e.x*h.x+e.y*h.y+e.z*h.z,f=u*u-h.lengthSq()+d*d;if(f<0)return 1;s=Math.max(s,u-Math.sqrt(f)),a=Math.min(a,u+Math.sqrt(f))}const o=Math.min(a,t,s+18e3);if(o<=s)return 1;const l=(o-s)/48;let c=1;for(let h=0;h<48;h++){const d=s+(h+.5)*l;if(c*=Math.exp(-this.densityAt({x:e.x*d,y:e.y*d,z:e.z*d})*l*.006),c<.015)break}return c}dispose(){this.mesh.removeFromParent(),this.mesh.geometry.dispose(),this.mesh.material.dispose()}}class pi{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=pi.build(24);static build(e){const t=[];let i=0,n=0,s=0;for(let a=0;a<e;a++){const o=pi.VIOLET_NM+(a+.5)/e*(pi.DEEP_RED_NM-pi.VIOLET_NM),[l,c,h]=pi.colourMatching(o),d={wavelengthNm:o,r:Math.max(0,3.2406*l-1.5372*c-.4986*h),g:Math.max(0,-.9689*l+1.8758*c+.0415*h),b:Math.max(0,.0557*l-.204*c+1.057*h)};i+=d.r,n+=d.g,s+=d.b,t.push(d)}for(const a of t)a.r/=i,a.g/=n,a.b/=s;return t}static tristimulus(e,t,i){let n=0,s=0,a=0;for(let l=0;l<e.length;l++){const[c,h,d]=pi.colourMatching(e[l]);n+=c*t[l],s+=h*t[l],a+=d*t[l]}const o=683*i;return[n*o,s*o,a*o]}static scotopic(e){const t=e/1e3;return .992*Math.exp(-321.9*(t-.5)**2)}static linearSrgbOf([e,t,i]){return[3.2406*e-1.5372*t-.4986*i,-.9689*e+1.8758*t+.0415*i,.0557*e-.204*t+1.057*i]}static colourMatching(e){const t=(i,n,s)=>{const a=(e-i)/(e<i?n:s);return Math.exp(-.5*a*a)};return[1.056*t(599.8,37.9,31)+.362*t(442,16,26.7)-.065*t(501.1,20.4,26.2),.821*t(568.8,46.9,40.5)+.286*t(530.9,16.3,31.1),1.217*t(437,11.8,36)+.681*t(459,26,13.8)]}}class bc{static reflectance(e,t,i){const s=t/i*Math.sqrt(Math.max(0,1-e*e));if(s>=1)return 1;const a=Math.sqrt(Math.max(0,1-s*s)),o=(i*e-t*a)/(i*e+t*a),l=(t*e-i*a)/(t*e+i*a);return(o*o+l*l)/2}}class ai{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(ai.ANCHOR_BLUE-ai.ANCHOR_RED)/(1/(ai.BLUE_NM*ai.BLUE_NM)-1/(ai.RED_NM*ai.RED_NM));static A=ai.ANCHOR_RED-ai.B/(ai.RED_NM*ai.RED_NM);static indexAt(e){return ai.A+ai.B/(e*e)}}class ya{static MAX_CHORDS=4;index=1.333;set refractiveIndex(e){this.index=e}trace(e,t){const i=Math.min(1,Math.max(0,e)),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),l=Math.asin(s),c=bc.reflectance(n,1,this.index);let h=0;t[h].chords=0,t[h].scatteringAngle=ya.folded(Math.PI-2*o),t[h].weight=c,h++;const d=bc.reflectance(a,this.index,1);let u=1-c;for(let f=1;f<=ya.MAX_CHORDS&&h<t.length;f++){const p=2*(o-l)+(f-1)*(Math.PI-2*l);t[h].chords=f,t[h].scatteringAngle=ya.folded(p),t[h].weight=u*(1-d),h++,u*=d}return h}static folded(e){const t=2*Math.PI;let i=e%t;return i<0&&(i+=t),i>Math.PI?t-i:i}}class Yt{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new ya;previous=Yt.emergences();current=Yt.emergences();tally=new Float32Array(Yt.BINS*3);radiance=new Float32Array(Yt.BINS*3);scratch=new Float32Array(Yt.BINS*3);static emergences(){return Array.from({length:ya.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const e of pi.SAMPLES)this.sweep(e);return this.toRadiance(),this.blurBySourceDisc(),{bins:Yt.BINS,data:this.radiance,binDeg:180/Yt.BINS}}sweep(e){this.drop.refractiveIndex=ai.indexAt(e.wavelengthNm);const t=Yt.IMPACT_STEPS;let i=this.drop.trace(0,this.previous);const n=1/t;for(let s=1;s<=t;s++){const a=this.drop.trace(Math.sqrt(s/t),this.current);for(let o=0;o<Math.min(a,i);o++){const l=this.previous[o],c=this.current[o];l.chords===c.chords&&this.deposit(l.scatteringAngle,c.scatteringAngle,(l.weight+c.weight)/2*n,e)}i=a,this.copyInto(this.current,this.previous)}}copyInto(e,t){for(let i=0;i<e.length;i++)t[i].chords=e[i].chords,t[i].scatteringAngle=e[i].scatteringAngle,t[i].weight=e[i].weight}deposit(e,t,i,n){if(i<=0)return;const s=Yt.BINS,a=Math.PI/s,o=Math.min(e,t),l=Math.max(e,t),c=l-o,h=Math.min(s-1,Math.max(0,Math.floor(o/a))),d=Math.min(s-1,Math.max(0,Math.floor(l/a)));if(c<=0||h===d){this.add(h,i,n);return}for(let u=h;u<=d;u++){const f=Math.min(l,(u+1)*a)-Math.max(o,u*a);f>0&&this.add(u,i*f/c,n)}}add(e,t,i){const n=e*3,s=t*pi.SAMPLES.length;this.tally[n]+=s*i.r,this.tally[n+1]+=s*i.g,this.tally[n+2]+=s*i.b}toRadiance(){const e=Yt.BINS,t=Math.PI/e;for(let i=0;i<e;i++){const n=2*Math.PI*(Math.cos(i*t)-Math.cos((i+1)*t)),s=n>0?this.backwardShare((i+.5)*(180/e))/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(e){const t=180-e;if(t<=Yt.FULL_UNTIL_DEG)return 1;if(t>=Yt.FADED_BY_DEG)return 0;const i=(t-Yt.FULL_UNTIL_DEG)/(Yt.FADED_BY_DEG-Yt.FULL_UNTIL_DEG);return Math.cos(i*Math.PI/2)**2}blurBySourceDisc(){const e=Yt.BINS,t=Yt.SOURCE_RADIUS_DEG*e/180,i=Math.max(1,Math.ceil(t)),n=[];let s=0;for(let a=-i;a<=i;a++){const o=Math.max(0,t*t-a*a),l=Math.sqrt(o);n.push(l),s+=l}if(!(s<=0)){this.scratch.set(this.radiance);for(let a=0;a<e;a++){let o=0,l=0,c=0;for(let d=-i;d<=i;d++){const u=Math.min(e-1,Math.max(0,a+d))*3,f=n[d+i];o+=this.scratch[u]*f,l+=this.scratch[u+1]*f,c+=this.scratch[u+2]*f}const h=a*3;this.radiance[h]=o/s,this.radiance[h+1]=l/s,this.radiance[h+2]=c/s}}}}class cr{static RADIUS=880;static RENDER_ORDER=5.5;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Yt;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Yt.BINS*4),this.texture=new Mr(this.texels,Yt.BINS,1,Ti,ui),this.texture.minFilter=vt,this.texture.magFilter=vt,this.texture.wrapS=Ri,this.texture.wrapT=Ri,this.texture.needsUpdate=!0,this.material=new Ot({uniforms:{uSource:{value:new P(0,1,0)},uStrength:{value:0},uTint:{value:new P(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:cr.GAIN}},vertexShader:`
6591
+ }`,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(e+t).replace(i,n=>r+n)}class yc{mesh;uniforms;constructor(e,t){this.uniforms={noiseMap:{value:e},sunDir:{value:new P(0,1,0)},sunColor:{value:new oe(1,1,1)},ambientColor:{value:new oe(.4,.45,.5)},hazeColor:{value:new oe(.5,.6,.7)},offsetM:{value:new P},seedOffset:{value:new P},localCenter:{value:new P},localSize:{value:new P},localRotation:{value:0},holeCount:{value:0},holeCenter:{value:Array.from({length:Za},()=>new P)},holeSize:{value:Array.from({length:Za},()=>new P)},holeRotation:{value:new Array(Za).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 Ot({uniforms:this.uniforms,vertexShader:F3,fragmentShader:gu,transparent:!0,depthWrite:!1,depthTest:!0,side:Ft});this.mesh=new We(new yi(t,32,16),i),this.mesh.frustumCulled=!1}update(e,t,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(Za,n.length),n.slice(0,Za).forEach((o,l)=>{s.holeCenter.value[l].set(o.eastM,o.baseM+o.thicknessM/2,-o.northM),s.holeSize.value[l].set(o.widthM,o.thicknessM,o.depthM),s.holeRotation.value[l]=o.rotationDeg*Math.PI/180}),s.baseM.value=Math.max(0,e.baseM),s.thicknessM.value=Math.max(10,e.thicknessM),s.coverage.value=Math.max(0,Math.min(1,e.coverage)),s.sizeM.value=Math.max(50,e.sizeM),s.density.value=Math.max(0,Math.min(2,e.density)),s.darkness.value=Math.max(0,Math.min(1,e.darkness??0)),s.eyeM.value=Math.max(.1,t),s.flatness.value=e.type==="stratus"?1:e.type==="stratocumulus"?.45:0;const a=mu(e);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(e){const t=Math.min(.999,Math.max(.001,e));return .645-.23*(Math.sqrt(3)/Math.PI)*Math.log(t/(1-t))}densityAt(e){const t=this.uniforms,i=(k,z,L)=>{const B=Math.max(0,Math.min(1,(L-k)/(z-k)));return B*B*(3-2*B)},n=(k,z,L)=>k+(z-k)*L,s=t.eyeM.value+e.y,a=2*aa*s+e.x**2+s**2+e.z**2,o=a/(Math.sqrt(aa**2+a)+aa),l=(o-t.baseM.value)/t.thicknessM.value,c=t.localSize.value.x>0;if(l<=0||l>=1||t.coverage.value<=0&&!c)return 0;const h=(k,z,L)=>{const B=e.x+t.offsetM.value.x-k.x,F=e.z+t.offsetM.value.z-k.z,V=Math.cos(L),j=Math.sin(L);return Math.hypot((V*B-j*F)/(z.x*.5),(o-k.y)/(z.y*.5),(j*B+V*F)/(z.z*.5))},d=c?h(t.localCenter.value,t.localSize.value,t.localRotation.value):0;if(d>1.3)return 0;const u=[e.x,e.y,e.z].map((k,z)=>(k+t.offsetM.value.getComponent(z))/(t.sizeM.value*4)+t.seedOffset.value.getComponent(z)),f=t.noiseMap.value.image.data,p=(k,z,L)=>{const B=[k,z,L].map($=>($%1+1)%1*Kt-.5),F=B.map(Math.floor),V=B.map(($,ie)=>$-F[ie]);let j=0;for(let $=0;$<2;$++)for(let ie=0;ie<2;ie++)for(let ae=0;ae<2;ae++){const Ve=(F[0]+ae+Kt)%Kt,je=(F[1]+ie+Kt)%Kt,Ge=(F[2]+$+Kt)%Kt;j+=f[Ve+Kt*(je+Kt*Ge)]/255*(ae?V[0]:1-V[0])*(ie?V[1]:1-V[1])*($?V[2]:1-V[2])}return j},v=[u[0]*.173,Lh,u[2]*.173];u[0]+=(p(v[0]+.13,v[1]+.27,v[2]+.41)-.5)*1.3,u[2]+=(p(v[0]+.67,v[1]+.53,v[2]+.19)-.5)*1.3;const m=(u[0]*.731+u[2]*.682)*1.371,g=(-u[0]*.682+u[2]*.731)*1.371;let x=i(.2,.8,p(u[0],Lh,u[2])*.65+p(m,Lh+.37,g)*.35);const M=i(8e3,4e4,Math.hypot(e.x,e.y,e.z)),w=n(p(u[0]*2,u[1]*3,u[2]*2),.5,M),S=n(p(u[0]*7,u[1]*7,u[2]*7),.5,M);let _=yc.thresholdFor(t.coverage.value),D=1,y=0;if(c){const k=d+(w-.5)*.18;y=1-i(.35,1,k),D=1-i(.85,1.15,k),x=n(x,1,y),_=Math.min(_,yc.thresholdFor(.5))}for(let k=0;k<t.holeCount.value;k++)D*=i(.85,1.15,h(t.holeCenter.value[k],t.holeSize.value[k],t.holeRotation.value[k])+(w-.5)*.18);if(D<.001)return 0;let T=i(_-.1,_+.1,x);if(T=n(T,1,i(.92,1,t.coverage.value)),T=n(T,Math.max(t.coverage.value,y),M),T<.001)return 0;const A=n(.45+.55*w,.96,t.flatness.value),I=i(0,.09,l)*(1-i(A-.22,A,l)),R=n(Math.max(0,T-(1-w)*.38-(1-S)*.1),T*.8,t.flatness.value);return I*R*t.density.value*D}transmissionAt(e,t=1/0){const i=this.uniforms,n=O3(e.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*aa);const d=i.localSize.value.length()*.5+25,u=e.x*h.x+e.y*h.y+e.z*h.z,f=u*u-h.lengthSq()+d*d;if(f<0)return 1;s=Math.max(s,u-Math.sqrt(f)),a=Math.min(a,u+Math.sqrt(f))}const o=Math.min(a,t,s+18e3);if(o<=s)return 1;const l=(o-s)/48;let c=1;for(let h=0;h<48;h++){const d=s+(h+.5)*l;if(c*=Math.exp(-this.densityAt({x:e.x*d,y:e.y*d,z:e.z*d})*l*.006),c<.015)break}return c}dispose(){this.mesh.removeFromParent(),this.mesh.geometry.dispose(),this.mesh.material.dispose()}}class pi{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=pi.build(24);static build(e){const t=[];let i=0,n=0,s=0;for(let a=0;a<e;a++){const o=pi.VIOLET_NM+(a+.5)/e*(pi.DEEP_RED_NM-pi.VIOLET_NM),[l,c,h]=pi.colourMatching(o),d={wavelengthNm:o,r:Math.max(0,3.2406*l-1.5372*c-.4986*h),g:Math.max(0,-.9689*l+1.8758*c+.0415*h),b:Math.max(0,.0557*l-.204*c+1.057*h)};i+=d.r,n+=d.g,s+=d.b,t.push(d)}for(const a of t)a.r/=i,a.g/=n,a.b/=s;return t}static tristimulus(e,t,i){let n=0,s=0,a=0;for(let l=0;l<e.length;l++){const[c,h,d]=pi.colourMatching(e[l]);n+=c*t[l],s+=h*t[l],a+=d*t[l]}const o=683*i;return[n*o,s*o,a*o]}static scotopic(e){const t=e/1e3;return .992*Math.exp(-321.9*(t-.5)**2)}static linearSrgbOf([e,t,i]){return[3.2406*e-1.5372*t-.4986*i,-.9689*e+1.8758*t+.0415*i,.0557*e-.204*t+1.057*i]}static colourMatching(e){const t=(i,n,s)=>{const a=(e-i)/(e<i?n:s);return Math.exp(-.5*a*a)};return[1.056*t(599.8,37.9,31)+.362*t(442,16,26.7)-.065*t(501.1,20.4,26.2),.821*t(568.8,46.9,40.5)+.286*t(530.9,16.3,31.1),1.217*t(437,11.8,36)+.681*t(459,26,13.8)]}}class bc{static reflectance(e,t,i){const s=t/i*Math.sqrt(Math.max(0,1-e*e));if(s>=1)return 1;const a=Math.sqrt(Math.max(0,1-s*s)),o=(i*e-t*a)/(i*e+t*a),l=(t*e-i*a)/(t*e+i*a);return(o*o+l*l)/2}}class ai{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(ai.ANCHOR_BLUE-ai.ANCHOR_RED)/(1/(ai.BLUE_NM*ai.BLUE_NM)-1/(ai.RED_NM*ai.RED_NM));static A=ai.ANCHOR_RED-ai.B/(ai.RED_NM*ai.RED_NM);static indexAt(e){return ai.A+ai.B/(e*e)}}class ya{static MAX_CHORDS=4;index=1.333;set refractiveIndex(e){this.index=e}trace(e,t){const i=Math.min(1,Math.max(0,e)),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),l=Math.asin(s),c=bc.reflectance(n,1,this.index);let h=0;t[h].chords=0,t[h].scatteringAngle=ya.folded(Math.PI-2*o),t[h].weight=c,h++;const d=bc.reflectance(a,this.index,1);let u=1-c;for(let f=1;f<=ya.MAX_CHORDS&&h<t.length;f++){const p=2*(o-l)+(f-1)*(Math.PI-2*l);t[h].chords=f,t[h].scatteringAngle=ya.folded(p),t[h].weight=u*(1-d),h++,u*=d}return h}static folded(e){const t=2*Math.PI;let i=e%t;return i<0&&(i+=t),i>Math.PI?t-i:i}}class Yt{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new ya;previous=Yt.emergences();current=Yt.emergences();tally=new Float32Array(Yt.BINS*3);radiance=new Float32Array(Yt.BINS*3);scratch=new Float32Array(Yt.BINS*3);static emergences(){return Array.from({length:ya.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const e of pi.SAMPLES)this.sweep(e);return this.toRadiance(),this.blurBySourceDisc(),{bins:Yt.BINS,data:this.radiance,binDeg:180/Yt.BINS}}sweep(e){this.drop.refractiveIndex=ai.indexAt(e.wavelengthNm);const t=Yt.IMPACT_STEPS;let i=this.drop.trace(0,this.previous);const n=1/t;for(let s=1;s<=t;s++){const a=this.drop.trace(Math.sqrt(s/t),this.current);for(let o=0;o<Math.min(a,i);o++){const l=this.previous[o],c=this.current[o];l.chords===c.chords&&this.deposit(l.scatteringAngle,c.scatteringAngle,(l.weight+c.weight)/2*n,e)}i=a,this.copyInto(this.current,this.previous)}}copyInto(e,t){for(let i=0;i<e.length;i++)t[i].chords=e[i].chords,t[i].scatteringAngle=e[i].scatteringAngle,t[i].weight=e[i].weight}deposit(e,t,i,n){if(i<=0)return;const s=Yt.BINS,a=Math.PI/s,o=Math.min(e,t),l=Math.max(e,t),c=l-o,h=Math.min(s-1,Math.max(0,Math.floor(o/a))),d=Math.min(s-1,Math.max(0,Math.floor(l/a)));if(c<=0||h===d){this.add(h,i,n);return}for(let u=h;u<=d;u++){const f=Math.min(l,(u+1)*a)-Math.max(o,u*a);f>0&&this.add(u,i*f/c,n)}}add(e,t,i){const n=e*3,s=t*pi.SAMPLES.length;this.tally[n]+=s*i.r,this.tally[n+1]+=s*i.g,this.tally[n+2]+=s*i.b}toRadiance(){const e=Yt.BINS,t=Math.PI/e;for(let i=0;i<e;i++){const n=2*Math.PI*(Math.cos(i*t)-Math.cos((i+1)*t)),s=n>0?this.backwardShare((i+.5)*(180/e))/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(e){const t=180-e;if(t<=Yt.FULL_UNTIL_DEG)return 1;if(t>=Yt.FADED_BY_DEG)return 0;const i=(t-Yt.FULL_UNTIL_DEG)/(Yt.FADED_BY_DEG-Yt.FULL_UNTIL_DEG);return Math.cos(i*Math.PI/2)**2}blurBySourceDisc(){const e=Yt.BINS,t=Yt.SOURCE_RADIUS_DEG*e/180,i=Math.max(1,Math.ceil(t)),n=[];let s=0;for(let a=-i;a<=i;a++){const o=Math.max(0,t*t-a*a),l=Math.sqrt(o);n.push(l),s+=l}if(!(s<=0)){this.scratch.set(this.radiance);for(let a=0;a<e;a++){let o=0,l=0,c=0;for(let d=-i;d<=i;d++){const u=Math.min(e-1,Math.max(0,a+d))*3,f=n[d+i];o+=this.scratch[u]*f,l+=this.scratch[u+1]*f,c+=this.scratch[u+2]*f}const h=a*3;this.radiance[h]=o/s,this.radiance[h+1]=l/s,this.radiance[h+2]=c/s}}}}class cr{static RADIUS=880;static RENDER_ORDER=5.5;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Yt;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Yt.BINS*4),this.texture=new Mr(this.texels,Yt.BINS,1,Ti,ui),this.texture.minFilter=vt,this.texture.magFilter=vt,this.texture.wrapS=Ri,this.texture.wrapT=Ri,this.texture.needsUpdate=!0,this.material=new Ot({uniforms:{uSource:{value:new P(0,1,0)},uStrength:{value:0},uTint:{value:new P(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:cr.GAIN}},vertexShader:`
6592
6592
  varying vec3 vDirection;
6593
6593
  void main() {
6594
6594
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -6677,7 +6677,7 @@ vec3 encodeSrgb(vec3 linear) {
6677
6677
  * @fileoverview Astronomy calculation library for browser scripting and Node.js.
6678
6678
  * @author Don Cross <cosinekitty@gmail.com>
6679
6679
  * @license MIT
6680
- */const yf=173.1446326846693,sr=14959787069098932e-8,gt=.017453292519943295,U0=.26179938779914946,Xn=57.29577951308232,f1=3.819718634205488,uE=365.24217,B0=new Date("2000-01-01T12:00:00Z"),ts=2*Math.PI,Ts=3600*(180/Math.PI),oa=484813681109536e-20,p1=10800*60,fE=2*p1,z0=7292115e-11,pE=p1/Math.PI,mE=-.17-5*Math.log10(pE),bu=.996647180302104,gE=bu*bu,wu=6378.1366,vE=wu/sr,m1=81.30056,bf=.0002959122082855911,Mu=2825345909524226e-22,xu=8459715185680659e-23,Su=1292024916781969e-23,Eu=1524358900784276e-23;function xc(r){if(r!==!0&&r!==!1)throw console.trace(),`Value is not boolean: ${r}`;return r}function hi(r){if(!Number.isFinite(r))throw console.trace(),`Value is not a finite number: ${r}`;return r}function Kr(r){return r-Math.floor(r)}function yE(r,e){const t=r.x*r.x+r.y*r.y+r.z*r.z;if(Math.abs(t)<1e-8)throw"AngleBetween: first vector is too short.";const i=e.x*e.x+e.y*e.y+e.z*e.z;if(Math.abs(i)<1e-8)throw"AngleBetween: second vector is too short.";const n=(r.x*e.x+r.y*e.y+r.z*e.z)/Math.sqrt(t*i);return n<=-1?180:n>=1?0:Xn*Math.acos(n)}var xe;(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"})(xe||(xe={}));const bE=[xe.Star1,xe.Star2,xe.Star3,xe.Star4,xe.Star5,xe.Star6,xe.Star7,xe.Star8],wE=[{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 ME(r){const e=bE.indexOf(r);return e>=0?wE[e]:null}function wf(r){const e=ME(r);return e&&e.dist>0?e:null}var bi;(function(r){r[r.From2000=0]="From2000",r[r.Into2000=1]="Into2000"})(bi||(bi={}));const Gn={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 xE(r){var e,t,i,n,s,a,o;const l=2e3+(r-14)/uE;return l<-500?(e=(l-1820)/100,-20+32*e*e):l<500?(e=l/100,t=e*e,i=e*t,n=t*t,s=t*i,a=i*i,10583.6-1014.41*e+33.78311*t-5.952053*i-.1798452*n+.022174192*s+.0090316521*a):l<1600?(e=(l-1e3)/100,t=e*e,i=e*t,n=t*t,s=t*i,a=i*i,1574.2-556.01*e+71.23472*t+.319781*i-.8503463*n-.005050998*s+.0083572073*a):l<1700?(e=l-1600,t=e*e,i=e*t,120-.9808*e-.01532*t+i/7129):l<1800?(e=l-1700,t=e*e,i=e*t,n=t*t,8.83+.1603*e-.0059285*t+13336e-8*i-n/1174e3):l<1860?(e=l-1800,t=e*e,i=e*t,n=t*t,s=t*i,a=i*i,o=i*n,13.72-.332447*e+.0068612*t+.0041116*i-37436e-8*n+121272e-10*s-1699e-10*a+875e-12*o):l<1900?(e=l-1860,t=e*e,i=e*t,n=t*t,s=t*i,7.62+.5737*e-.251754*t+.01680668*i-.0004473624*n+s/233174):l<1920?(e=l-1900,t=e*e,i=e*t,n=t*t,-2.79+1.494119*e-.0598939*t+.0061966*i-197e-6*n):l<1941?(e=l-1920,t=e*e,i=e*t,21.2+.84493*e-.0761*t+.0020936*i):l<1961?(e=l-1950,t=e*e,i=e*t,29.07+.407*e-t/233+i/2547):l<1986?(e=l-1975,t=e*e,i=e*t,45.45+1.067*e-t/260-i/718):l<2005?(e=l-2e3,t=e*e,i=e*t,n=t*t,s=t*i,63.86+.3345*e-.060374*t+.0017275*i+651814e-9*n+2373599e-11*s):l<2050?(e=l-2e3,62.92+.32217*e+.005589*e*e):l<2150?(e=(l-1820)/100,-20+32*e*e-.5628*(2150-l)):(e=(l-1820)/100,-20+32*e*e)}let SE=xE;function H0(r){return r+SE(r)/86400}class ba{constructor(e){if(e instanceof ba){this.date=e.date,this.ut=e.ut,this.tt=e.tt;return}const t=1e3*3600*24;if(e instanceof Date&&Number.isFinite(e.getTime())){this.date=e,this.ut=(e.getTime()-B0.getTime())/t,this.tt=H0(this.ut);return}if(Number.isFinite(e)){this.date=new Date(B0.getTime()+e*t),this.ut=e,this.tt=H0(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(e){let t=new ba(e);for(;;){const i=e-t.tt;if(Math.abs(i)<1e-12)return t;t=t.AddDays(i)}}toString(){return this.date.toISOString()}AddDays(e){return new ba(this.ut+e)}}function Bt(r){return r instanceof ba?r:new ba(r)}function EE(r){function e(u){return u%fE*oa}const t=r.tt/36525,i=e(128710479305e-5+t*1295965810481e-4),n=e(335779.526232+t*17395272628478e-4),s=e(107226070369e-5+t*1602961601209e-3),a=e(450160.398036-t*69628905431e-4);let o=Math.sin(a),l=Math.cos(a),c=(-172064161-174666*t)*o+33386*l,h=(92052331+9086*t)*l+15377*o,d=2*(n-s+a);return o=Math.sin(d),l=Math.cos(d),c+=(-13170906-1675*t)*o-13696*l,h+=(5730336-3015*t)*l-4587*o,d=2*(n+a),o=Math.sin(d),l=Math.cos(d),c+=(-2276413-234*t)*o+2796*l,h+=(978459-485*t)*l+1374*o,d=2*a,o=Math.sin(d),l=Math.cos(d),c+=(2074554+207*t)*o-698*l,h+=(-897492+470*t)*l-291*o,o=Math.sin(i),l=Math.cos(i),c+=(1475877-3633*t)*o+11817*l,h+=(73871-184*t)*l-1924*o,{dpsi:-135e-6+c*1e-7,deps:388e-6+h*1e-7}}function g1(r){var e=r.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var Tl;function zo(r){if(!Tl||Math.abs(Tl.tt-r.tt)>1e-6){const e=EE(r),t=g1(r),i=t+e.deps/3600;Tl={tt:r.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*gt)/15,mobl:t,tobl:i}}return Tl}function _E(r,e){const t=r*gt,i=Math.cos(t),n=Math.sin(t);return[e[0],e[1]*i-e[2]*n,e[1]*n+e[2]*i]}function TE(r,e){return _E(g1(r),e)}function AE(r){const e=r.tt/36525;function t(Ie,be){const ke=[];let Ne;for(Ne=0;Ne<=be-Ie;++Ne)ke.push(0);return{min:Ie,array:ke}}function i(Ie,be,ke,Ne){const Oe=[];for(let dt=0;dt<=be-Ie;++dt)Oe.push(t(ke,Ne));return{min:Ie,array:Oe}}function n(Ie,be,ke){const Ne=Ie.array[be-Ie.min];return Ne.array[ke-Ne.min]}function s(Ie,be,ke,Ne){const Oe=Ie.array[be-Ie.min];Oe.array[ke-Oe.min]=Ne}let a,o,l,c,h,d,u,f,p,v,m,g,x,M,w,S,_,D,y,T,A,I,R,k=i(-6,6,1,4),z=i(-6,6,1,4);function L(Ie,be){return n(k,Ie,be)}function B(Ie,be){return n(z,Ie,be)}function F(Ie,be,ke){return s(k,Ie,be,ke)}function V(Ie,be,ke){return s(z,Ie,be,ke)}function j(Ie,be,ke,Ne,Oe){Oe(Ie*ke-be*Ne,be*ke+Ie*Ne)}function $(Ie){return Math.sin(ts*Ie)}u=e*e,p=0,R=0,m=0,g=3422.7;var ie=$(.19833+.05611*e),ae=$(.27869+.04508*e),Ve=$(.16827-.36903*e),je=$(.34734-5.37261*e),He=$(.10498-5.37899*e),K=$(.42681-.41855*e),re=$(.14943-5.37511*e);for(D=.84*ie+.31*ae+14.27*Ve+7.26*je+.28*He+.24*K,y=2.94*ie+.31*ae+14.27*Ve+9.34*je+1.12*He+.83*K,T=-6.4*ie-1.89*K,A=.21*ie+.31*ae+14.27*Ve-88.7*je-15.3*He+.24*K-1.86*re,I=D-T,f=-3332e-9*$(.59734-5.37261*e)-539e-9*$(.35498-5.37899*e)-64e-9*$(.39943-5.37511*e),x=ts*Kr(.60643382+1336.85522467*e-313e-8*u)+D/Ts,M=ts*Kr(.37489701+1325.55240982*e+2565e-8*u)+y/Ts,w=ts*Kr(.99312619+99.99735956*e-44e-8*u)+T/Ts,S=ts*Kr(.25909118+1342.2278298*e-892e-8*u)+A/Ts,_=ts*Kr(.82736186+1236.85308708*e-397e-8*u)+I/Ts,h=1;h<=4;++h){switch(h){case 1:l=M,o=4,c=1.000002208;break;case 2:l=w,o=3,c=.997504612-.002495388*e;break;case 3:l=S,o=4,c=1.000002708+139.978*f;break;case 4:l=_,o=6,c=1;break;default:throw`Internal error: I = ${h}`}for(F(0,h,1),F(1,h,Math.cos(l)*c),V(0,h,0),V(1,h,Math.sin(l)*c),d=2;d<=o;++d)j(L(d-1,h),B(d-1,h),L(1,h),B(1,h),(Ie,be)=>(F(d,h,Ie),V(d,h,be)));for(d=1;d<=o;++d)F(-d,h,L(d,h)),V(-d,h,-B(d,h))}function ne(Ie,be,ke,Ne){for(var Oe={x:1,y:0},dt=[0,Ie,be,ke,Ne],ut=1;ut<=4;++ut)dt[ut]!==0&&j(Oe.x,Oe.y,L(dt[ut],ut),B(dt[ut],ut),(zt,It)=>(Oe.x=zt,Oe.y=It));return Oe}function G(Ie,be,ke,Ne,Oe,dt,ut,zt){var It=ne(Oe,dt,ut,zt);p+=Ie*It.y,R+=be*It.y,m+=ke*It.x,g+=Ne*It.x}G(13.902,14.06,-.001,.2607,0,0,0,4),G(.403,-4.01,.394,.0023,0,0,0,3),G(2369.912,2373.36,.601,28.2333,0,0,0,2),G(-125.154,-112.79,-.725,-.9781,0,0,0,1),G(1.979,6.98,-.445,.0433,1,0,0,4),G(191.953,192.72,.029,3.0861,1,0,0,2),G(-8.466,-13.51,.455,-.1093,1,0,0,1),G(22639.5,22609.07,.079,186.5398,1,0,0,0),G(18.609,3.59,-.094,.0118,1,0,0,-1),G(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),G(3.215,5.44,.192,-.0386,1,0,0,-3),G(-38.428,-38.64,.001,.6008,1,0,0,-4),G(-.393,-1.43,-.092,.0086,1,0,0,-6),G(-.289,-1.59,.123,-.0053,0,1,0,4),G(-24.42,-25.1,.04,-.3,0,1,0,2),G(18.023,17.93,.007,.1494,0,1,0,1),G(-668.146,-126.98,-1.302,-.3997,0,1,0,0),G(.56,.32,-.001,-.0037,0,1,0,-1),G(-165.145,-165.06,.054,1.9178,0,1,0,-2),G(-1.877,-6.46,-.416,.0339,0,1,0,-4),G(.213,1.02,-.074,.0054,2,0,0,4),G(14.387,14.78,-.017,.2833,2,0,0,2),G(-.586,-1.2,.054,-.01,2,0,0,1),G(769.016,767.96,.107,10.1657,2,0,0,0),G(1.75,2.01,-.018,.0155,2,0,0,-1),G(-211.656,-152.53,5.679,-.3039,2,0,0,-2),G(1.225,.91,-.03,-.0088,2,0,0,-3),G(-30.773,-34.07,-.308,.3722,2,0,0,-4),G(-.57,-1.4,-.074,.0109,2,0,0,-6),G(-2.921,-11.75,.787,-.0484,1,1,0,2),G(1.267,1.52,-.022,.0164,1,1,0,1),G(-109.673,-115.18,.461,-.949,1,1,0,0),G(-205.962,-182.36,2.056,1.4437,1,1,0,-2),G(.233,.36,.012,-.0025,1,1,0,-3),G(-4.391,-9.66,-.471,.0673,1,1,0,-4),G(.283,1.53,-.111,.006,1,-1,0,4),G(14.577,31.7,-1.54,.2302,1,-1,0,2),G(147.687,138.76,.679,1.1528,1,-1,0,0),G(-1.089,.55,.021,0,1,-1,0,-1),G(28.475,23.59,-.443,-.2257,1,-1,0,-2),G(-.276,-.38,-.006,-.0036,1,-1,0,-3),G(.636,2.27,.146,-.0102,1,-1,0,-4),G(-.189,-1.68,.131,-.0028,0,2,0,2),G(-7.486,-.66,-.037,-.0086,0,2,0,0),G(-8.096,-16.35,-.74,.0918,0,2,0,-2),G(-5.741,-.04,0,-9e-4,0,0,2,2),G(.255,0,0,0,0,0,2,1),G(-411.608,-.2,0,-.0124,0,0,2,0),G(.584,.84,0,.0071,0,0,2,-1),G(-55.173,-52.14,0,-.1052,0,0,2,-2),G(.254,.25,0,-.0017,0,0,2,-3),G(.025,-1.67,0,.0031,0,0,2,-4),G(1.06,2.96,-.166,.0243,3,0,0,2),G(36.124,50.64,-1.3,.6215,3,0,0,0),G(-13.193,-16.4,.258,-.1187,3,0,0,-2),G(-1.187,-.74,.042,.0074,3,0,0,-4),G(-.293,-.31,-.002,.0046,3,0,0,-6),G(-.29,-1.45,.116,-.0051,2,1,0,2),G(-7.649,-10.56,.259,-.1038,2,1,0,0),G(-8.627,-7.59,.078,-.0192,2,1,0,-2),G(-2.74,-2.54,.022,.0324,2,1,0,-4),G(1.181,3.32,-.212,.0213,2,-1,0,2),G(9.703,11.67,-.151,.1268,2,-1,0,0),G(-.352,-.37,.001,-.0028,2,-1,0,-1),G(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),G(.36,.2,-.012,-.0043,2,-1,0,-4),G(-1.167,-1.25,.008,-.0106,1,2,0,0),G(-7.412,-6.12,.117,.0484,1,2,0,-2),G(-.311,-.65,-.032,.0044,1,2,0,-4),G(.757,1.82,-.105,.0112,1,-2,0,2),G(2.58,2.32,.027,.0196,1,-2,0,0),G(2.533,2.4,-.014,-.0212,1,-2,0,-2),G(-.344,-.57,-.025,.0036,0,3,0,-2),G(-.992,-.02,0,0,1,0,2,2),G(-45.099,-.02,0,-.001,1,0,2,0),G(-.179,-9.52,0,-.0833,1,0,2,-2),G(-.301,-.33,0,.0014,1,0,2,-4),G(-6.382,-3.37,0,-.0481,1,0,-2,2),G(39.528,85.13,0,-.7136,1,0,-2,0),G(9.366,.71,0,-.0112,1,0,-2,-2),G(.202,.02,0,0,1,0,-2,-4),G(.415,.1,0,.0013,0,1,2,0),G(-2.152,-2.26,0,-.0066,0,1,2,-2),G(-1.44,-1.3,0,.0014,0,1,-2,2),G(.384,-.04,0,0,0,1,-2,-2),G(1.938,3.6,-.145,.0401,4,0,0,0),G(-.952,-1.58,.052,-.013,4,0,0,-2),G(-.551,-.94,.032,-.0097,3,1,0,0),G(-.482,-.57,.005,-.0045,3,1,0,-2),G(.681,.96,-.026,.0115,3,-1,0,0),G(-.297,-.27,.002,-9e-4,2,2,0,-2),G(.254,.21,-.003,0,2,-2,0,-2),G(-.25,-.22,.004,.0014,1,3,0,-2),G(-3.996,0,0,4e-4,2,0,2,0),G(.557,-.75,0,-.009,2,0,2,-2),G(-.459,-.38,0,-.0053,2,0,-2,2),G(-1.298,.74,0,4e-4,2,0,-2,0),G(.538,1.14,0,-.0141,2,0,-2,-2),G(.263,.02,0,0,1,1,2,0),G(.426,.07,0,-6e-4,1,1,-2,-2),G(-.304,.03,0,3e-4,1,-1,2,0),G(-.372,-.19,0,-.0027,1,-1,-2,2),G(.418,0,0,0,0,0,4,0),G(-.33,-.04,0,0,3,0,2,0);function Ee(Ie,be,ke,Ne,Oe){return Ie*ne(be,ke,Ne,Oe).y}v=0,v+=Ee(-526.069,0,0,1,-2),v+=Ee(-3.352,0,0,1,-4),v+=Ee(44.297,1,0,1,-2),v+=Ee(-6,1,0,1,-4),v+=Ee(20.599,-1,0,1,0),v+=Ee(-30.598,-1,0,1,-2),v+=Ee(-24.649,-2,0,1,0),v+=Ee(-2,-2,0,1,-2),v+=Ee(-22.571,0,1,1,-2),v+=Ee(10.985,0,-1,1,-2),p+=.82*$(.7736-62.5512*e)+.31*$(.0466-125.1025*e)+.35*$(.5785-25.1042*e)+.66*$(.4591+1335.8075*e)+.64*$(.313-91.568*e)+1.14*$(.148+1331.2898*e)+.21*$(.5918+1056.5859*e)+.44*$(.5784+1322.8595*e)+.24*$(.2275-5.7374*e)+.28*$(.2965+2.6929*e)+.33*$(.3132+6.3368*e),a=S+R/Ts;let Pe=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+v;return{geo_eclip_lon:ts*Kr((x+p/Ts)/ts),geo_eclip_lat:Math.PI/(180*3600)*Pe,distance_au:Ts*vE/(.999953253*g)}}function v1(r,e){return[r.rot[0][0]*e[0]+r.rot[1][0]*e[1]+r.rot[2][0]*e[2],r.rot[0][1]*e[0]+r.rot[1][1]*e[1]+r.rot[2][1]*e[2],r.rot[0][2]*e[0]+r.rot[1][2]*e[1]+r.rot[2][2]*e[2]]}function Sc(r,e,t){const i=Mf(e,t);return v1(i,r)}function Mf(r,e){const t=r.tt/36525;let i=84381.406,n=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,s=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+i,a=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;i*=oa,n*=oa,s*=oa,a*=oa;const o=Math.sin(i),l=Math.cos(i),c=Math.sin(-n),h=Math.cos(-n),d=Math.sin(-s),u=Math.cos(-s),f=Math.sin(a),p=Math.cos(a),v=p*h-c*f*u,m=p*c*l+f*u*h*l-o*f*d,g=p*c*o+f*u*h*o+l*f*d,x=-f*h-c*p*u,M=-f*c*l+p*u*h*l-o*p*d,w=-f*c*o+p*u*h*o+l*p*d,S=c*d,_=-d*h*l-o*u,D=-d*h*o+u*l;if(e===bi.Into2000)return new zs([[v,m,g],[x,M,w],[S,_,D]]);if(e===bi.From2000)return new zs([[v,x,S],[m,M,_],[g,w,D]]);throw"Invalid precess direction"}function IE(r){const e=.779057273264+.00273781191135448*r.ut,t=r.ut%1;let i=360*((e+t)%1);return i<0&&(i+=360),i}let Al;function Fc(r){if(!Al||Al.tt!==r.tt){const e=r.tt/36525;let t=15*zo(r).ee;const i=IE(r);let s=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+i)%360/15;s<0&&(s+=24),Al={tt:r.tt,st:s}}return Al.st}function DE(r){const e=Bt(r);return Fc(e)}function y1(r,e){const t=r.latitude*gt,i=Math.sin(t),n=Math.cos(t),s=1/Math.hypot(n,bu*i),a=gE*s,o=r.height/1e3,l=wu*s+o,c=wu*a+o,h=(15*e+r.longitude)*gt,d=Math.sin(h),u=Math.cos(h);return{pos:[l*n*u/sr,l*n*d/sr,c*i/sr],vel:[-z0*l*n*d*86400/sr,z0*l*n*u*86400/sr,0]}}function _u(r,e,t){const i=xf(e,t);return v1(i,r)}function xf(r,e){const t=zo(r),i=t.mobl*gt,n=t.tobl*gt,s=t.dpsi*oa,a=Math.cos(i),o=Math.sin(i),l=Math.cos(n),c=Math.sin(n),h=Math.cos(s),d=Math.sin(s),u=h,f=-d*a,p=-d*o,v=d*l,m=h*a*l+o*c,g=h*o*l-a*c,x=d*c,M=h*a*c-o*l,w=h*o*c+a*l;if(e===bi.From2000)return new zs([[u,v,x],[f,m,M],[p,g,w]]);if(e===bi.Into2000)return new zs([[u,f,p],[v,m,g],[x,M,w]]);throw"Invalid precess direction"}function Sf(r,e,t){return t===bi.Into2000?Sc(_u(r,e,t),e,t):_u(Sc(r,e,t),e,t)}function CE(r,e){const t=Fc(r),i=y1(e,t).pos;return Sf(i,r,bi.Into2000)}class Et{constructor(e,t,i,n){this.x=e,this.y=t,this.z=i,this.t=n}Length(){return Math.hypot(this.x,this.y,this.z)}}class Fs{constructor(e,t,i,n,s,a,o){this.x=e,this.y=t,this.z=i,this.vx=n,this.vy=s,this.vz=a,this.t=o}}class Uc{constructor(e,t,i){this.lat=hi(e),this.lon=hi(t),this.dist=hi(i)}}class Tu{constructor(e,t,i,n){this.ra=hi(e),this.dec=hi(t),this.dist=hi(i),this.vec=n}}class zs{constructor(e){this.rot=e}}class RE{constructor(e,t,i,n){this.azimuth=hi(e),this.altitude=hi(t),this.ra=hi(i),this.dec=hi(n)}}class PE{constructor(e,t,i){this.vec=e,this.elat=hi(t),this.elon=hi(i)}}function b1(r,e){return new Et(r[0],r[1],r[2],e)}function LE(r,e){const t=b1(r,e),i=t.x*t.x+t.y*t.y,n=Math.sqrt(i+t.z*t.z);if(i===0){if(t.z===0)throw"Indeterminate sky coordinates";return new Tu(0,t.z<0?-90:90,n,t)}let s=f1*Math.atan2(t.y,t.x);s<0&&(s+=24);const a=Xn*Math.atan2(r[2],Math.sqrt(i));return new Tu(s,a,n,t)}function Nh(r,e){const t=r*gt,i=Math.cos(t),n=Math.sin(t);return[i*e[0]+n*e[1],i*e[1]-n*e[0],e[2]]}function w1(r,e,t,i,n){let s=Bt(r);Ef(e),hi(t),hi(i);const a=Math.sin(e.latitude*gt),o=Math.cos(e.latitude*gt),l=Math.sin(e.longitude*gt),c=Math.cos(e.longitude*gt),h=Math.sin(i*gt),d=Math.cos(i*gt),u=Math.sin(t*U0),f=Math.cos(t*U0);let p=[o*c,o*l,a],v=[-a*c,-a*l,o],m=[l,-c,0];const g=-15*Fc(s);let x=Nh(g,p),M=Nh(g,v),w=Nh(g,m),S=[d*f,d*u,h];const _=S[0]*x[0]+S[1]*x[1]+S[2]*x[2],D=S[0]*M[0]+S[1]*M[1]+S[2]*M[2],y=S[0]*w[0]+S[1]*w[1]+S[2]*w[2];let T=Math.hypot(D,y),A;T>0?(A=-Xn*Math.atan2(y,D),A<0&&(A+=360)):A=0;let I=Xn*Math.atan2(T,_),R=t,k=i;if(n){let z=I,L=D1(n,90-I);if(I-=L,L>0&&I>3e-4){const B=Math.sin(I*gt),F=Math.cos(I*gt),V=Math.sin(z*gt),j=Math.cos(z*gt),$=[];for(let ie=0;ie<3;++ie)$.push((S[ie]-j*x[ie])/V*B+x[ie]*F);T=Math.hypot($[0],$[1]),T>0?(R=f1*Math.atan2($[1],$[0]),R<0&&(R+=24)):R=0,k=Xn*Math.atan2($[2],T)}}return new RE(A,90-I,R,k)}function Ef(r){if(!(r instanceof _f))throw`Not an instance of the Observer class: ${r}`;if(hi(r.latitude),hi(r.longitude),hi(r.height),r.latitude<-90||r.latitude>90)throw`Latitude ${r.latitude} is out of range. Must be -90..+90.`;return r}class _f{constructor(e,t,i){this.latitude=e,this.longitude=t,this.height=i,Ef(this)}}function kE(r){const e=Bt(r).AddDays(-1/yf),t=Ma(Gn.Earth,e),i=[-t.x,-t.y,-t.z],[n,s,a]=Sf(i,e,bi.From2000),o=gt*zo(e).tobl,l=Math.cos(o),c=Math.sin(o),h=new Et(n,s,a,e);return M1(h,l,c)}function NE(r,e,t,i,n){Ef(t),xc(i),xc(n);const s=Bt(e),a=CE(s,t),o=Ou(r,s,n),l=[o.x-a[0],o.y-a[1],o.z-a[2]],c=Sf(l,s,bi.From2000);return LE(c,s)}function OE(r,e,t){const i=Bt(r),n=Fc(i);let s=y1(e,n).pos;return b1(s,i)}function M1(r,e,t){const i=r.x,n=r.y*e+r.z*t,s=-r.y*t+r.z*e,a=Math.hypot(i,n);let o=0;a>0&&(o=Xn*Math.atan2(n,i),o<0&&(o+=360));let l=Xn*Math.atan2(s,a),c=new Et(i,n,s,r.t);return new PE(c,l,o)}function Au(r){const e=zo(r.t),t=[r.x,r.y,r.z],i=Sc(t,r.t,bi.From2000),[n,s,a]=_u(i,r.t,bi.From2000),o=new Et(n,s,a,r.t),l=e.tobl*gt;return M1(o,Math.cos(l),Math.sin(l))}function Pa(r){const e=Bt(r),t=AE(e),i=t.distance_au*Math.cos(t.geo_eclip_lat),n=[i*Math.cos(t.geo_eclip_lon),i*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],s=TE(e,n),a=Sc(s,e,bi.Into2000);return new Et(a[0],a[1],a[2],e)}function x1(r){const e=Bt(r),t=1e-5,i=e.AddDays(-t),n=e.AddDays(+t),s=Pa(i),a=Pa(n);return new Fs((s.x+a.x)/2,(s.y+a.y)/2,(s.z+a.z)/2,(a.x-s.x)/(2*t),(a.y-s.y)/(2*t),(a.z-s.z)/(2*t),e)}function FE(r){const e=Bt(r),t=x1(e),i=1+m1;return new Fs(t.x/i,t.y/i,t.z/i,t.vx/i,t.vy/i,t.vz/i,e)}function wa(r,e,t){let i=1,n=0;for(let s of r){let a=0;for(let[l,c,h]of s)a+=l*Math.cos(c+e*h);let o=i*a;t&&(o%=ts),n+=o,i*=e}return n}function Oh(r,e){let t=1,i=0,n=0,s=0;for(let a of r){let o=0,l=0;for(let[c,h,d]of a){let u=h+e*d;o+=c*d*Math.sin(u),s>0&&(l+=c*Math.cos(u))}n+=s*i*l-t*o,i=t,t*=e,++s}return n}const ho=365250,Iu=0,Du=1,Cu=2;function Ru(r){return new _i(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 S1(r,e,t){const i=t*Math.cos(e),n=Math.cos(r),s=Math.sin(r);return[i*n,i*s,t*Math.sin(e)]}function Ma(r,e){const t=e.tt/ho,i=wa(r[Iu],t,!0),n=wa(r[Du],t,!1),s=wa(r[Cu],t,!1),a=S1(i,n,s);return Ru(a).ToAstroVector(e)}function Pu(r,e){const t=e/ho,i=wa(r[Iu],t,!0),n=wa(r[Du],t,!1),s=wa(r[Cu],t,!1),a=Oh(r[Iu],t),o=Oh(r[Du],t),l=Oh(r[Cu],t),c=Math.cos(i),h=Math.sin(i),d=Math.cos(n),u=Math.sin(n),f=+(l*d*c)-s*u*c*o-s*d*h*a,p=+(l*d*h)-s*u*h*o+s*d*c*a,v=+(l*u)+s*d*o,m=S1(i,n,s),g=[f/ho,p/ho,v/ho],x=Ru(m),M=Ru(g);return new br(e,x,M)}function Il(r,e,t,i){const n=i/(i+bf),s=Ma(Gn[t],e);r.x+=n*s.x,r.y+=n*s.y,r.z+=n*s.z}function UE(r){const e=new Et(0,0,0,r);return Il(e,r,xe.Jupiter,Mu),Il(e,r,xe.Saturn,xu),Il(e,r,xe.Uranus,Su),Il(e,r,xe.Neptune,Eu),e}const Lu=51,BE=29200,la=146,is=201,dr=[[-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 _i{constructor(e,t,i){this.x=e,this.y=t,this.z=i}clone(){return new _i(this.x,this.y,this.z)}ToAstroVector(e){return new Et(this.x,this.y,this.z,e)}static zero(){return new _i(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new _i(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new _i(this.x-e.x,this.y-e.y,this.z-e.z)}incr(e){this.x+=e.x,this.y+=e.y,this.z+=e.z}decr(e){this.x-=e.x,this.y-=e.y,this.z-=e.z}mul(e){return new _i(e*this.x,e*this.y,e*this.z)}div(e){return new _i(this.x/e,this.y/e,this.z/e)}mean(e){return new _i((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new _i(-this.x,-this.y,-this.z)}}class br{constructor(e,t,i){this.tt=e,this.r=t,this.v=i}clone(){return new br(this.tt,this.r,this.v)}sub(e){return new br(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function zE(r){let[e,[t,i,n],[s,a,o]]=r;return new br(e,new _i(t,i,n),new _i(s,a,o))}function Dl(r,e,t,i){const n=i/(i+bf),s=Pu(Gn[t],e);return r.r.incr(s.r.mul(n)),r.v.incr(s.v.mul(n)),s}function Ja(r,e,t){const i=t.sub(r),n=i.quadrature();return i.mul(e/(n*Math.sqrt(n)))}class Bc{constructor(e){let t=new br(e,new _i(0,0,0),new _i(0,0,0));this.Jupiter=Dl(t,e,xe.Jupiter,Mu),this.Saturn=Dl(t,e,xe.Saturn,xu),this.Uranus=Dl(t,e,xe.Uranus,Su),this.Neptune=Dl(t,e,xe.Neptune,Eu),this.Jupiter.r.decr(t.r),this.Jupiter.v.decr(t.v),this.Saturn.r.decr(t.r),this.Saturn.v.decr(t.v),this.Uranus.r.decr(t.r),this.Uranus.v.decr(t.v),this.Neptune.r.decr(t.r),this.Neptune.v.decr(t.v),this.Sun=new br(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=Ja(e,bf,this.Sun.r);return t.incr(Ja(e,Mu,this.Jupiter.r)),t.incr(Ja(e,xu,this.Saturn.r)),t.incr(Ja(e,Su,this.Uranus.r)),t.incr(Ja(e,Eu,this.Neptune.r)),t}}class zc{constructor(e,t,i,n){this.tt=e,this.r=t,this.v=i,this.a=n}clone(){return new zc(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class E1{constructor(e,t){this.bary=e,this.grav=t}}function Ec(r,e,t,i){return new _i(e.x+r*(t.x+r*i.x/2),e.y+r*(t.y+r*i.y/2),e.z+r*(t.z+r*i.z/2))}function G0(r,e,t){return new _i(e.x+r*t.x,e.y+r*t.y,e.z+r*t.z)}function ku(r,e){const t=r-e.tt,i=new Bc(r),n=Ec(t,e.r,e.v,e.a),s=i.Acceleration(n).mean(e.a),a=Ec(t,e.r,e.v,s),o=e.v.add(s.mul(t)),l=i.Acceleration(a),c=new zc(r,a,o,l);return new E1(i,c)}const HE=[];function _1(r,e){const t=Math.floor(r);return t<0?0:t>=e?e-1:t}function Nu(r){const e=zE(r),t=new Bc(e.tt),i=e.r.add(t.Sun.r),n=e.v.add(t.Sun.v),s=t.Acceleration(i),a=new zc(e.tt,i,n,s);return new E1(t,a)}function GE(r,e){const t=dr[0][0];if(e<t||e>dr[Lu-1][0])return null;const i=_1((e-t)/BE,Lu-1);if(!r[i]){const s=r[i]=[];s[0]=Nu(dr[i]).grav,s[is-1]=Nu(dr[i+1]).grav;let a,o=s[0].tt;for(a=1;a<is-1;++a)s[a]=ku(o+=la,s[a-1]).grav;o=s[is-1].tt;var n=[];for(n[is-1]=s[is-1],a=is-2;a>0;--a)n[a]=ku(o-=la,n[a+1]).grav;for(a=is-2;a>0;--a){const l=a/(is-1);s[a].r=s[a].r.mul(1-l).add(n[a].r.mul(l)),s[a].v=s[a].v.mul(1-l).add(n[a].v.mul(l)),s[a].a=s[a].a.mul(1-l).add(n[a].a.mul(l))}}return r[i]}function V0(r,e,t){let i=Nu(r);const n=Math.ceil((e-i.grav.tt)/t);for(let s=0;s<n;++s)i=ku(s+1===n?e:i.grav.tt+t,i.grav);return i}function T1(r,e){let t,i,n;const s=GE(HE,r.tt);if(s){const a=_1((r.tt-s[0].tt)/la,is-1),o=s[a],l=s[a+1],c=o.a.mean(l.a),h=Ec(r.tt-o.tt,o.r,o.v,c),d=G0(r.tt-o.tt,o.v,c),u=Ec(r.tt-l.tt,l.r,l.v,c),f=G0(r.tt-l.tt,l.v,c),p=(r.tt-o.tt)/la;t=h.mul(1-p).add(u.mul(p)),i=d.mul(1-p).add(f.mul(p))}else{let a;r.tt<dr[0][0]?a=V0(dr[0],r.tt,-la):a=V0(dr[Lu-1],r.tt,+la),t=a.grav.r,i=a.grav.v,n=a.bary}return n||(n=new Bc(r.tt)),t=t.sub(n.Sun.r),i=i.sub(n.Sun.v),new Fs(t.x,t.y,t.z,i.x,i.y,i.z,r)}function Us(r,e){var t=Bt(e);if(r in Gn)return Ma(Gn[r],t);if(r===xe.Pluto){const a=T1(t);return new Et(a.x,a.y,a.z,t)}if(r===xe.Sun)return new Et(0,0,0,t);if(r===xe.Moon){var i=Ma(Gn.Earth,t),n=Pa(t);return new Et(i.x+n.x,i.y+n.y,i.z+n.z,t)}if(r===xe.EMB){const a=Ma(Gn.Earth,t),o=Pa(t),l=1+m1;return new Et(a.x+o.x/l,a.y+o.y/l,a.z+o.z/l,t)}if(r===xe.SSB)return UE(t);const s=wf(r);if(s){const a=new Uc(s.dec,15*s.ra,s.dist);return Tf(a,t)}throw`HelioVector: Unknown body "${r}"`}function VE(r,e){let t=e,i=0;for(let n=0;n<10;++n){const s=r(t),a=s.Length()/yf;if(a>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-a);if(i=Math.abs(o.tt-t.tt),i<1e-9)return s;t=o}throw`Light-travel time solver did not converge: dt = ${i}`}class WE{constructor(e,t,i,n){this.observerBody=e,this.targetBody=t,this.aberration=i,this.observerPos=n}Position(e){this.aberration&&(this.observerPos=Us(this.observerBody,e));const t=Us(this.targetBody,e);return new Et(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function XE(r,e,t,i){xc(i);const n=Bt(r);if(wf(t)){const o=Us(t,n);if(i){const c=YE(e,n),h=new Et(o.x-c.x,o.y-c.y,o.z-c.z,n),d=yf/h.Length();return new Et(h.x+c.vx/d,h.y+c.vy/d,h.z+c.vz/d,n)}const l=Us(e,n);return new Et(o.x-l.x,o.y-l.y,o.z-l.z,n)}let s;i?s=new Et(0,0,0,n):s=Us(e,n);const a=new WE(e,t,i,s);return VE(o=>a.Position(o),n)}function Ou(r,e,t){xc(t);const i=Bt(e);switch(r){case xe.Earth:return new Et(0,0,0,i);case xe.Moon:return Pa(i);default:const n=XE(i,xe.Earth,r,t);return n.t=i,n}}function qE(r,e){return new Fs(r.r.x,r.r.y,r.r.z,r.v.x,r.v.y,r.v.z,e)}function YE(r,e){const t=Bt(e);switch(r){case xe.Sun:return new Fs(0,0,0,0,0,0,t);case xe.SSB:const i=new Bc(t.tt);return new Fs(-i.Sun.r.x,-i.Sun.r.y,-i.Sun.r.z,-i.Sun.v.x,-i.Sun.v.y,-i.Sun.v.z,t);case xe.Mercury:case xe.Venus:case xe.Earth:case xe.Mars:case xe.Jupiter:case xe.Saturn:case xe.Uranus:case xe.Neptune:const n=Pu(Gn[r],t.tt);return qE(n,t);case xe.Pluto:return T1(t);case xe.Moon:case xe.EMB:const s=Pu(Gn.Earth,t.tt),a=r==xe.Moon?x1(t):FE(t);return new Fs(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,t);default:if(wf(r)){const o=Us(r,t);return new Fs(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${r}"`}}function KE(r){for(;r<0;)r+=360;for(;r>=360;)r-=360;return r}function $E(r,e,t){if(r===xe.Earth||e===xe.Earth)throw"The Earth does not have a longitude as seen from itself.";const i=Bt(t),n=Ou(r,i,!1),s=Au(n),a=Ou(e,i,!1),o=Au(a);return KE(s.elon-o.elon)}function ZE(r,e,t,i){let n,s=0,a=0,o=0;switch(r){case xe.Mercury:n=-.6,s=4.98,a=-4.88,o=3.02;break;case xe.Venus:e<163.6?(n=-4.47,s=1.03,a=.57,o=.13):(n=.98,s=-1.02);break;case xe.Mars:n=-1.52,s=1.6;break;case xe.Jupiter:n=-9.4,s=.5;break;case xe.Uranus:n=-7.19,s=.25;break;case xe.Neptune:n=-6.87;break;case xe.Pluto:n=-1,s=4;break;default:throw`VisualMagnitude: unsupported body ${r}`}const l=e/100;let c=n+l*(s+l*(a+l*o));return c+=5*Math.log10(t*i),c}function JE(r,e,t,i,n){const s=Au(i),a=gt*28.06,o=gt*(169.51+382e-7*n.tt),l=gt*s.elat,c=gt*s.elon,h=Math.asin(Math.sin(l)*Math.cos(a)-Math.cos(l)*Math.sin(a)*Math.sin(c-o)),d=Math.sin(Math.abs(h));let u=-9+.044*r;return u+=d*(-2.6+1.2*d),u+=5*Math.log10(e*t),{mag:u,ring_tilt:Xn*h}}function jE(r,e,t){let i=r*gt,n=i*i,s=n*n,a=-12.717+1.49*Math.abs(i)+.0431*s;const o=385000.6/sr;let l=t/o;return a+=5*Math.log10(e*l),a}class QE{constructor(e,t,i,n,s,a,o,l){this.time=e,this.mag=t,this.phase_angle=i,this.helio_dist=n,this.geo_dist=s,this.gc=a,this.hc=o,this.ring_tilt=l,this.phase_fraction=(1+Math.cos(gt*i))/2}}function A1(r,e){if(r===xe.Earth)throw"The illumination of the Earth is not defined.";const t=Bt(e),i=Ma(Gn.Earth,t);let n,s,a,o;r===xe.Sun?(a=new Et(-i.x,-i.y,-i.z,t),s=new Et(0,0,0,t),n=0):(r===xe.Moon?(a=Pa(t),s=new Et(i.x+a.x,i.y+a.y,i.z+a.z,t)):(s=Us(r,e),a=new Et(s.x-i.x,s.y-i.y,s.z-i.z,t)),n=yE(a,s));let l=a.Length(),c=s.Length(),h;if(r===xe.Sun)o=mE+5*Math.log10(l);else if(r===xe.Moon)o=jE(n,c,l);else if(r===xe.Saturn){const d=JE(n,c,l,a,t);o=d.mag,h=d.ring_tilt}else o=ZE(r,n,c,l);return new QE(t,o,n,c,l,a,s,h)}function e_(r){return $E(xe.Moon,xe.Sun,r)}var W0;(function(r){r[r.Pericenter=0]="Pericenter",r[r.Apocenter=1]="Apocenter"})(W0||(W0={}));function I1(r,e){return new zs([[e.rot[0][0]*r.rot[0][0]+e.rot[1][0]*r.rot[0][1]+e.rot[2][0]*r.rot[0][2],e.rot[0][1]*r.rot[0][0]+e.rot[1][1]*r.rot[0][1]+e.rot[2][1]*r.rot[0][2],e.rot[0][2]*r.rot[0][0]+e.rot[1][2]*r.rot[0][1]+e.rot[2][2]*r.rot[0][2]],[e.rot[0][0]*r.rot[1][0]+e.rot[1][0]*r.rot[1][1]+e.rot[2][0]*r.rot[1][2],e.rot[0][1]*r.rot[1][0]+e.rot[1][1]*r.rot[1][1]+e.rot[2][1]*r.rot[1][2],e.rot[0][2]*r.rot[1][0]+e.rot[1][2]*r.rot[1][1]+e.rot[2][2]*r.rot[1][2]],[e.rot[0][0]*r.rot[2][0]+e.rot[1][0]*r.rot[2][1]+e.rot[2][0]*r.rot[2][2],e.rot[0][1]*r.rot[2][0]+e.rot[1][1]*r.rot[2][1]+e.rot[2][1]*r.rot[2][2],e.rot[0][2]*r.rot[2][0]+e.rot[1][2]*r.rot[2][1]+e.rot[2][2]*r.rot[2][2]]])}function Tf(r,e){e=Bt(e);const t=r.lat*gt,i=r.lon*gt,n=r.dist*Math.cos(t);return new Et(n*Math.cos(i),n*Math.sin(i),r.dist*Math.sin(t),e)}function Af(r){const e=t_(r);return new Tu(e.lon/15,e.lat,e.dist,r)}function t_(r){const e=r.x*r.x+r.y*r.y,t=Math.sqrt(e+r.z*r.z);let i,n;if(e===0){if(r.z===0)throw"Zero-length vector not allowed.";n=0,i=r.z<0?-90:90}else n=Xn*Math.atan2(r.y,r.x),n<0&&(n+=360),i=Xn*Math.atan2(r.z,Math.sqrt(e));return new Uc(i,n,t)}function D1(r,e){let t;if(hi(e),e<-90||e>90)return 0;if(r==="normal"||r==="jplhor"){let i=e;i<-1&&(i=-1),t=1.02/Math.tan((i+10.3/(i+5.11))*gt)/60,r==="normal"&&e<-1&&(t*=(e+90)/89)}else if(!r)t=0;else throw`Invalid refraction option: ${r}`;return t}function xa(r,e){return new Et(r.rot[0][0]*e.x+r.rot[1][0]*e.y+r.rot[2][0]*e.z,r.rot[0][1]*e.x+r.rot[1][1]*e.y+r.rot[2][1]*e.z,r.rot[0][2]*e.x+r.rot[1][2]*e.y+r.rot[2][2]*e.z,e.t)}function i_(){return new zs([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function n_(){return new zs([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function C1(r){r=Bt(r);const e=Mf(r,bi.From2000),t=xf(r,bi.From2000);return I1(e,t)}function s_(r){r=Bt(r);const e=xf(r,bi.Into2000),t=Mf(r,bi.Into2000);return I1(e,t)}function r_(r){const t=zo(Bt(r)).tobl*gt,i=Math.cos(t),n=Math.sin(t);return new zs([[1,0,0],[0,+i,+n],[0,-n,+i]])}var X0;(function(r){r.Penumbral="penumbral",r.Partial="partial",r.Annular="annular",r.Total="total"})(X0||(X0={}));var q0;(function(r){r[r.Invalid=0]="Invalid",r[r.Ascending=1]="Ascending",r[r.Descending=-1]="Descending"})(q0||(q0={}));const a_=["Venus","Mars","Jupiter","Saturn"];function R1(r){return new _f(r.lat,r.lng,r.elevationM)}function If(r,e,t,i,n=!0){const s=w1(t,R1(i),r,e,n?"normal":void 0);return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}class fn{up;north;west;constructor(e,t){const i=Bt(e),n=Math.sin(t.lat*ns),s=Math.cos(t.lat*ns),a=Math.sin(t.lng*ns),o=Math.cos(t.lng*ns),l=-15*DE(i),c=s_(i);this.up=fn.rotate(c,fn.spin(l,[s*o,s*a,n]),i),this.north=fn.rotate(c,fn.spin(l,[-n*o,-n*a,s]),i),this.west=fn.rotate(c,fn.spin(l,[a,-o,0]),i)}static ofJ2000(e,t,i,n,s=!0){const a=Bt(i),o=Tf(new Uc(t,e*15,1),a),l=Af(xa(C1(a),o));return If(l.ra,l.dec,i,n,s)}position(e,t){const i=Math.sin(t*ns),n=Math.cos(t*ns),s=Math.sin(e*K0),a=Math.cos(e*K0),o=n*a,l=n*s,c=i,h=o*this.up[0]+l*this.up[1]+c*this.up[2],d=o*this.north[0]+l*this.north[1]+c*this.north[2],u=o*this.west[0]+l*this.west[1]+c*this.west[2],f=Math.hypot(d,u);let p=0;f>0&&(p=-Y0*Math.atan2(u,d),p<0&&(p+=360));let v=Y0*Math.atan2(f,h);return v-=D1("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(e,[t,i,n]){const s=Math.cos(e*ns),a=Math.sin(e*ns);return[s*t+a*i,s*i-a*t,n]}static rotate(e,[t,i,n],s){const a=xa(e,new Et(t,i,n,s));return[a.x,a.y,a.z]}}const ns=Math.PI/180,Y0=180/Math.PI,K0=15*ns;function Ui(r,e,t){const i=R1(t),n=NE(xe[r],e,i,!0,!0),s=w1(e,i,n.ra,n.dec,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Fh(r,e){return A1(xe[r],e).mag}function _c(r){const e=e_(r),t=A1(xe.Moon,r);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const o_=2e3,l_=3,c_=20;function zn(r,e,t){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??o_,s=r.month??(i?1:l_),a=r.day??(i?1:c_),o=t??Math.round(e/15);return new Date(Date.UTC(n,s-1,a,(r.hour??12)-o,r.minute??0,r.second??0))}class Ls{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(e){e.transparent=!0,e.depthWrite=!1,e.onBeforeCompile=t=>{t.fragmentShader=Ls.patch(t.fragmentShader)}}static patch(e){return e.replace(Ls.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
6680
+ */const yf=173.1446326846693,sr=14959787069098932e-8,gt=.017453292519943295,U0=.26179938779914946,Xn=57.29577951308232,f1=3.819718634205488,uE=365.24217,B0=new Date("2000-01-01T12:00:00Z"),ts=2*Math.PI,Ts=3600*(180/Math.PI),oa=484813681109536e-20,p1=10800*60,fE=2*p1,z0=7292115e-11,pE=p1/Math.PI,mE=-.17-5*Math.log10(pE),bu=.996647180302104,gE=bu*bu,wu=6378.1366,vE=wu/sr,m1=81.30056,bf=.0002959122082855911,Mu=2825345909524226e-22,xu=8459715185680659e-23,Su=1292024916781969e-23,Eu=1524358900784276e-23;function xc(r){if(r!==!0&&r!==!1)throw console.trace(),`Value is not boolean: ${r}`;return r}function hi(r){if(!Number.isFinite(r))throw console.trace(),`Value is not a finite number: ${r}`;return r}function Kr(r){return r-Math.floor(r)}function yE(r,e){const t=r.x*r.x+r.y*r.y+r.z*r.z;if(Math.abs(t)<1e-8)throw"AngleBetween: first vector is too short.";const i=e.x*e.x+e.y*e.y+e.z*e.z;if(Math.abs(i)<1e-8)throw"AngleBetween: second vector is too short.";const n=(r.x*e.x+r.y*e.y+r.z*e.z)/Math.sqrt(t*i);return n<=-1?180:n>=1?0:Xn*Math.acos(n)}var xe;(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"})(xe||(xe={}));const bE=[xe.Star1,xe.Star2,xe.Star3,xe.Star4,xe.Star5,xe.Star6,xe.Star7,xe.Star8],wE=[{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 ME(r){const e=bE.indexOf(r);return e>=0?wE[e]:null}function wf(r){const e=ME(r);return e&&e.dist>0?e:null}var bi;(function(r){r[r.From2000=0]="From2000",r[r.Into2000=1]="Into2000"})(bi||(bi={}));const Gn={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 xE(r){var e,t,i,n,s,a,o;const l=2e3+(r-14)/uE;return l<-500?(e=(l-1820)/100,-20+32*e*e):l<500?(e=l/100,t=e*e,i=e*t,n=t*t,s=t*i,a=i*i,10583.6-1014.41*e+33.78311*t-5.952053*i-.1798452*n+.022174192*s+.0090316521*a):l<1600?(e=(l-1e3)/100,t=e*e,i=e*t,n=t*t,s=t*i,a=i*i,1574.2-556.01*e+71.23472*t+.319781*i-.8503463*n-.005050998*s+.0083572073*a):l<1700?(e=l-1600,t=e*e,i=e*t,120-.9808*e-.01532*t+i/7129):l<1800?(e=l-1700,t=e*e,i=e*t,n=t*t,8.83+.1603*e-.0059285*t+13336e-8*i-n/1174e3):l<1860?(e=l-1800,t=e*e,i=e*t,n=t*t,s=t*i,a=i*i,o=i*n,13.72-.332447*e+.0068612*t+.0041116*i-37436e-8*n+121272e-10*s-1699e-10*a+875e-12*o):l<1900?(e=l-1860,t=e*e,i=e*t,n=t*t,s=t*i,7.62+.5737*e-.251754*t+.01680668*i-.0004473624*n+s/233174):l<1920?(e=l-1900,t=e*e,i=e*t,n=t*t,-2.79+1.494119*e-.0598939*t+.0061966*i-197e-6*n):l<1941?(e=l-1920,t=e*e,i=e*t,21.2+.84493*e-.0761*t+.0020936*i):l<1961?(e=l-1950,t=e*e,i=e*t,29.07+.407*e-t/233+i/2547):l<1986?(e=l-1975,t=e*e,i=e*t,45.45+1.067*e-t/260-i/718):l<2005?(e=l-2e3,t=e*e,i=e*t,n=t*t,s=t*i,63.86+.3345*e-.060374*t+.0017275*i+651814e-9*n+2373599e-11*s):l<2050?(e=l-2e3,62.92+.32217*e+.005589*e*e):l<2150?(e=(l-1820)/100,-20+32*e*e-.5628*(2150-l)):(e=(l-1820)/100,-20+32*e*e)}let SE=xE;function H0(r){return r+SE(r)/86400}class ba{constructor(e){if(e instanceof ba){this.date=e.date,this.ut=e.ut,this.tt=e.tt;return}const t=1e3*3600*24;if(e instanceof Date&&Number.isFinite(e.getTime())){this.date=e,this.ut=(e.getTime()-B0.getTime())/t,this.tt=H0(this.ut);return}if(Number.isFinite(e)){this.date=new Date(B0.getTime()+e*t),this.ut=e,this.tt=H0(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(e){let t=new ba(e);for(;;){const i=e-t.tt;if(Math.abs(i)<1e-12)return t;t=t.AddDays(i)}}toString(){return this.date.toISOString()}AddDays(e){return new ba(this.ut+e)}}function Bt(r){return r instanceof ba?r:new ba(r)}function EE(r){function e(u){return u%fE*oa}const t=r.tt/36525,i=e(128710479305e-5+t*1295965810481e-4),n=e(335779.526232+t*17395272628478e-4),s=e(107226070369e-5+t*1602961601209e-3),a=e(450160.398036-t*69628905431e-4);let o=Math.sin(a),l=Math.cos(a),c=(-172064161-174666*t)*o+33386*l,h=(92052331+9086*t)*l+15377*o,d=2*(n-s+a);return o=Math.sin(d),l=Math.cos(d),c+=(-13170906-1675*t)*o-13696*l,h+=(5730336-3015*t)*l-4587*o,d=2*(n+a),o=Math.sin(d),l=Math.cos(d),c+=(-2276413-234*t)*o+2796*l,h+=(978459-485*t)*l+1374*o,d=2*a,o=Math.sin(d),l=Math.cos(d),c+=(2074554+207*t)*o-698*l,h+=(-897492+470*t)*l-291*o,o=Math.sin(i),l=Math.cos(i),c+=(1475877-3633*t)*o+11817*l,h+=(73871-184*t)*l-1924*o,{dpsi:-135e-6+c*1e-7,deps:388e-6+h*1e-7}}function g1(r){var e=r.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var Tl;function zo(r){if(!Tl||Math.abs(Tl.tt-r.tt)>1e-6){const e=EE(r),t=g1(r),i=t+e.deps/3600;Tl={tt:r.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*gt)/15,mobl:t,tobl:i}}return Tl}function _E(r,e){const t=r*gt,i=Math.cos(t),n=Math.sin(t);return[e[0],e[1]*i-e[2]*n,e[1]*n+e[2]*i]}function TE(r,e){return _E(g1(r),e)}function AE(r){const e=r.tt/36525;function t(Ie,be){const ke=[];let Ne;for(Ne=0;Ne<=be-Ie;++Ne)ke.push(0);return{min:Ie,array:ke}}function i(Ie,be,ke,Ne){const Oe=[];for(let dt=0;dt<=be-Ie;++dt)Oe.push(t(ke,Ne));return{min:Ie,array:Oe}}function n(Ie,be,ke){const Ne=Ie.array[be-Ie.min];return Ne.array[ke-Ne.min]}function s(Ie,be,ke,Ne){const Oe=Ie.array[be-Ie.min];Oe.array[ke-Oe.min]=Ne}let a,o,l,c,h,d,u,f,p,v,m,g,x,M,w,S,_,D,y,T,A,I,R,k=i(-6,6,1,4),z=i(-6,6,1,4);function L(Ie,be){return n(k,Ie,be)}function B(Ie,be){return n(z,Ie,be)}function F(Ie,be,ke){return s(k,Ie,be,ke)}function V(Ie,be,ke){return s(z,Ie,be,ke)}function j(Ie,be,ke,Ne,Oe){Oe(Ie*ke-be*Ne,be*ke+Ie*Ne)}function $(Ie){return Math.sin(ts*Ie)}u=e*e,p=0,R=0,m=0,g=3422.7;var ie=$(.19833+.05611*e),ae=$(.27869+.04508*e),Ve=$(.16827-.36903*e),je=$(.34734-5.37261*e),Ge=$(.10498-5.37899*e),K=$(.42681-.41855*e),re=$(.14943-5.37511*e);for(D=.84*ie+.31*ae+14.27*Ve+7.26*je+.28*Ge+.24*K,y=2.94*ie+.31*ae+14.27*Ve+9.34*je+1.12*Ge+.83*K,T=-6.4*ie-1.89*K,A=.21*ie+.31*ae+14.27*Ve-88.7*je-15.3*Ge+.24*K-1.86*re,I=D-T,f=-3332e-9*$(.59734-5.37261*e)-539e-9*$(.35498-5.37899*e)-64e-9*$(.39943-5.37511*e),x=ts*Kr(.60643382+1336.85522467*e-313e-8*u)+D/Ts,M=ts*Kr(.37489701+1325.55240982*e+2565e-8*u)+y/Ts,w=ts*Kr(.99312619+99.99735956*e-44e-8*u)+T/Ts,S=ts*Kr(.25909118+1342.2278298*e-892e-8*u)+A/Ts,_=ts*Kr(.82736186+1236.85308708*e-397e-8*u)+I/Ts,h=1;h<=4;++h){switch(h){case 1:l=M,o=4,c=1.000002208;break;case 2:l=w,o=3,c=.997504612-.002495388*e;break;case 3:l=S,o=4,c=1.000002708+139.978*f;break;case 4:l=_,o=6,c=1;break;default:throw`Internal error: I = ${h}`}for(F(0,h,1),F(1,h,Math.cos(l)*c),V(0,h,0),V(1,h,Math.sin(l)*c),d=2;d<=o;++d)j(L(d-1,h),B(d-1,h),L(1,h),B(1,h),(Ie,be)=>(F(d,h,Ie),V(d,h,be)));for(d=1;d<=o;++d)F(-d,h,L(d,h)),V(-d,h,-B(d,h))}function ne(Ie,be,ke,Ne){for(var Oe={x:1,y:0},dt=[0,Ie,be,ke,Ne],ut=1;ut<=4;++ut)dt[ut]!==0&&j(Oe.x,Oe.y,L(dt[ut],ut),B(dt[ut],ut),(zt,It)=>(Oe.x=zt,Oe.y=It));return Oe}function G(Ie,be,ke,Ne,Oe,dt,ut,zt){var It=ne(Oe,dt,ut,zt);p+=Ie*It.y,R+=be*It.y,m+=ke*It.x,g+=Ne*It.x}G(13.902,14.06,-.001,.2607,0,0,0,4),G(.403,-4.01,.394,.0023,0,0,0,3),G(2369.912,2373.36,.601,28.2333,0,0,0,2),G(-125.154,-112.79,-.725,-.9781,0,0,0,1),G(1.979,6.98,-.445,.0433,1,0,0,4),G(191.953,192.72,.029,3.0861,1,0,0,2),G(-8.466,-13.51,.455,-.1093,1,0,0,1),G(22639.5,22609.07,.079,186.5398,1,0,0,0),G(18.609,3.59,-.094,.0118,1,0,0,-1),G(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),G(3.215,5.44,.192,-.0386,1,0,0,-3),G(-38.428,-38.64,.001,.6008,1,0,0,-4),G(-.393,-1.43,-.092,.0086,1,0,0,-6),G(-.289,-1.59,.123,-.0053,0,1,0,4),G(-24.42,-25.1,.04,-.3,0,1,0,2),G(18.023,17.93,.007,.1494,0,1,0,1),G(-668.146,-126.98,-1.302,-.3997,0,1,0,0),G(.56,.32,-.001,-.0037,0,1,0,-1),G(-165.145,-165.06,.054,1.9178,0,1,0,-2),G(-1.877,-6.46,-.416,.0339,0,1,0,-4),G(.213,1.02,-.074,.0054,2,0,0,4),G(14.387,14.78,-.017,.2833,2,0,0,2),G(-.586,-1.2,.054,-.01,2,0,0,1),G(769.016,767.96,.107,10.1657,2,0,0,0),G(1.75,2.01,-.018,.0155,2,0,0,-1),G(-211.656,-152.53,5.679,-.3039,2,0,0,-2),G(1.225,.91,-.03,-.0088,2,0,0,-3),G(-30.773,-34.07,-.308,.3722,2,0,0,-4),G(-.57,-1.4,-.074,.0109,2,0,0,-6),G(-2.921,-11.75,.787,-.0484,1,1,0,2),G(1.267,1.52,-.022,.0164,1,1,0,1),G(-109.673,-115.18,.461,-.949,1,1,0,0),G(-205.962,-182.36,2.056,1.4437,1,1,0,-2),G(.233,.36,.012,-.0025,1,1,0,-3),G(-4.391,-9.66,-.471,.0673,1,1,0,-4),G(.283,1.53,-.111,.006,1,-1,0,4),G(14.577,31.7,-1.54,.2302,1,-1,0,2),G(147.687,138.76,.679,1.1528,1,-1,0,0),G(-1.089,.55,.021,0,1,-1,0,-1),G(28.475,23.59,-.443,-.2257,1,-1,0,-2),G(-.276,-.38,-.006,-.0036,1,-1,0,-3),G(.636,2.27,.146,-.0102,1,-1,0,-4),G(-.189,-1.68,.131,-.0028,0,2,0,2),G(-7.486,-.66,-.037,-.0086,0,2,0,0),G(-8.096,-16.35,-.74,.0918,0,2,0,-2),G(-5.741,-.04,0,-9e-4,0,0,2,2),G(.255,0,0,0,0,0,2,1),G(-411.608,-.2,0,-.0124,0,0,2,0),G(.584,.84,0,.0071,0,0,2,-1),G(-55.173,-52.14,0,-.1052,0,0,2,-2),G(.254,.25,0,-.0017,0,0,2,-3),G(.025,-1.67,0,.0031,0,0,2,-4),G(1.06,2.96,-.166,.0243,3,0,0,2),G(36.124,50.64,-1.3,.6215,3,0,0,0),G(-13.193,-16.4,.258,-.1187,3,0,0,-2),G(-1.187,-.74,.042,.0074,3,0,0,-4),G(-.293,-.31,-.002,.0046,3,0,0,-6),G(-.29,-1.45,.116,-.0051,2,1,0,2),G(-7.649,-10.56,.259,-.1038,2,1,0,0),G(-8.627,-7.59,.078,-.0192,2,1,0,-2),G(-2.74,-2.54,.022,.0324,2,1,0,-4),G(1.181,3.32,-.212,.0213,2,-1,0,2),G(9.703,11.67,-.151,.1268,2,-1,0,0),G(-.352,-.37,.001,-.0028,2,-1,0,-1),G(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),G(.36,.2,-.012,-.0043,2,-1,0,-4),G(-1.167,-1.25,.008,-.0106,1,2,0,0),G(-7.412,-6.12,.117,.0484,1,2,0,-2),G(-.311,-.65,-.032,.0044,1,2,0,-4),G(.757,1.82,-.105,.0112,1,-2,0,2),G(2.58,2.32,.027,.0196,1,-2,0,0),G(2.533,2.4,-.014,-.0212,1,-2,0,-2),G(-.344,-.57,-.025,.0036,0,3,0,-2),G(-.992,-.02,0,0,1,0,2,2),G(-45.099,-.02,0,-.001,1,0,2,0),G(-.179,-9.52,0,-.0833,1,0,2,-2),G(-.301,-.33,0,.0014,1,0,2,-4),G(-6.382,-3.37,0,-.0481,1,0,-2,2),G(39.528,85.13,0,-.7136,1,0,-2,0),G(9.366,.71,0,-.0112,1,0,-2,-2),G(.202,.02,0,0,1,0,-2,-4),G(.415,.1,0,.0013,0,1,2,0),G(-2.152,-2.26,0,-.0066,0,1,2,-2),G(-1.44,-1.3,0,.0014,0,1,-2,2),G(.384,-.04,0,0,0,1,-2,-2),G(1.938,3.6,-.145,.0401,4,0,0,0),G(-.952,-1.58,.052,-.013,4,0,0,-2),G(-.551,-.94,.032,-.0097,3,1,0,0),G(-.482,-.57,.005,-.0045,3,1,0,-2),G(.681,.96,-.026,.0115,3,-1,0,0),G(-.297,-.27,.002,-9e-4,2,2,0,-2),G(.254,.21,-.003,0,2,-2,0,-2),G(-.25,-.22,.004,.0014,1,3,0,-2),G(-3.996,0,0,4e-4,2,0,2,0),G(.557,-.75,0,-.009,2,0,2,-2),G(-.459,-.38,0,-.0053,2,0,-2,2),G(-1.298,.74,0,4e-4,2,0,-2,0),G(.538,1.14,0,-.0141,2,0,-2,-2),G(.263,.02,0,0,1,1,2,0),G(.426,.07,0,-6e-4,1,1,-2,-2),G(-.304,.03,0,3e-4,1,-1,2,0),G(-.372,-.19,0,-.0027,1,-1,-2,2),G(.418,0,0,0,0,0,4,0),G(-.33,-.04,0,0,3,0,2,0);function Ee(Ie,be,ke,Ne,Oe){return Ie*ne(be,ke,Ne,Oe).y}v=0,v+=Ee(-526.069,0,0,1,-2),v+=Ee(-3.352,0,0,1,-4),v+=Ee(44.297,1,0,1,-2),v+=Ee(-6,1,0,1,-4),v+=Ee(20.599,-1,0,1,0),v+=Ee(-30.598,-1,0,1,-2),v+=Ee(-24.649,-2,0,1,0),v+=Ee(-2,-2,0,1,-2),v+=Ee(-22.571,0,1,1,-2),v+=Ee(10.985,0,-1,1,-2),p+=.82*$(.7736-62.5512*e)+.31*$(.0466-125.1025*e)+.35*$(.5785-25.1042*e)+.66*$(.4591+1335.8075*e)+.64*$(.313-91.568*e)+1.14*$(.148+1331.2898*e)+.21*$(.5918+1056.5859*e)+.44*$(.5784+1322.8595*e)+.24*$(.2275-5.7374*e)+.28*$(.2965+2.6929*e)+.33*$(.3132+6.3368*e),a=S+R/Ts;let Pe=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+v;return{geo_eclip_lon:ts*Kr((x+p/Ts)/ts),geo_eclip_lat:Math.PI/(180*3600)*Pe,distance_au:Ts*vE/(.999953253*g)}}function v1(r,e){return[r.rot[0][0]*e[0]+r.rot[1][0]*e[1]+r.rot[2][0]*e[2],r.rot[0][1]*e[0]+r.rot[1][1]*e[1]+r.rot[2][1]*e[2],r.rot[0][2]*e[0]+r.rot[1][2]*e[1]+r.rot[2][2]*e[2]]}function Sc(r,e,t){const i=Mf(e,t);return v1(i,r)}function Mf(r,e){const t=r.tt/36525;let i=84381.406,n=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,s=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+i,a=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;i*=oa,n*=oa,s*=oa,a*=oa;const o=Math.sin(i),l=Math.cos(i),c=Math.sin(-n),h=Math.cos(-n),d=Math.sin(-s),u=Math.cos(-s),f=Math.sin(a),p=Math.cos(a),v=p*h-c*f*u,m=p*c*l+f*u*h*l-o*f*d,g=p*c*o+f*u*h*o+l*f*d,x=-f*h-c*p*u,M=-f*c*l+p*u*h*l-o*p*d,w=-f*c*o+p*u*h*o+l*p*d,S=c*d,_=-d*h*l-o*u,D=-d*h*o+u*l;if(e===bi.Into2000)return new zs([[v,m,g],[x,M,w],[S,_,D]]);if(e===bi.From2000)return new zs([[v,x,S],[m,M,_],[g,w,D]]);throw"Invalid precess direction"}function IE(r){const e=.779057273264+.00273781191135448*r.ut,t=r.ut%1;let i=360*((e+t)%1);return i<0&&(i+=360),i}let Al;function Fc(r){if(!Al||Al.tt!==r.tt){const e=r.tt/36525;let t=15*zo(r).ee;const i=IE(r);let s=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+i)%360/15;s<0&&(s+=24),Al={tt:r.tt,st:s}}return Al.st}function DE(r){const e=Bt(r);return Fc(e)}function y1(r,e){const t=r.latitude*gt,i=Math.sin(t),n=Math.cos(t),s=1/Math.hypot(n,bu*i),a=gE*s,o=r.height/1e3,l=wu*s+o,c=wu*a+o,h=(15*e+r.longitude)*gt,d=Math.sin(h),u=Math.cos(h);return{pos:[l*n*u/sr,l*n*d/sr,c*i/sr],vel:[-z0*l*n*d*86400/sr,z0*l*n*u*86400/sr,0]}}function _u(r,e,t){const i=xf(e,t);return v1(i,r)}function xf(r,e){const t=zo(r),i=t.mobl*gt,n=t.tobl*gt,s=t.dpsi*oa,a=Math.cos(i),o=Math.sin(i),l=Math.cos(n),c=Math.sin(n),h=Math.cos(s),d=Math.sin(s),u=h,f=-d*a,p=-d*o,v=d*l,m=h*a*l+o*c,g=h*o*l-a*c,x=d*c,M=h*a*c-o*l,w=h*o*c+a*l;if(e===bi.From2000)return new zs([[u,v,x],[f,m,M],[p,g,w]]);if(e===bi.Into2000)return new zs([[u,f,p],[v,m,g],[x,M,w]]);throw"Invalid precess direction"}function Sf(r,e,t){return t===bi.Into2000?Sc(_u(r,e,t),e,t):_u(Sc(r,e,t),e,t)}function CE(r,e){const t=Fc(r),i=y1(e,t).pos;return Sf(i,r,bi.Into2000)}class Et{constructor(e,t,i,n){this.x=e,this.y=t,this.z=i,this.t=n}Length(){return Math.hypot(this.x,this.y,this.z)}}class Fs{constructor(e,t,i,n,s,a,o){this.x=e,this.y=t,this.z=i,this.vx=n,this.vy=s,this.vz=a,this.t=o}}class Uc{constructor(e,t,i){this.lat=hi(e),this.lon=hi(t),this.dist=hi(i)}}class Tu{constructor(e,t,i,n){this.ra=hi(e),this.dec=hi(t),this.dist=hi(i),this.vec=n}}class zs{constructor(e){this.rot=e}}class RE{constructor(e,t,i,n){this.azimuth=hi(e),this.altitude=hi(t),this.ra=hi(i),this.dec=hi(n)}}class PE{constructor(e,t,i){this.vec=e,this.elat=hi(t),this.elon=hi(i)}}function b1(r,e){return new Et(r[0],r[1],r[2],e)}function LE(r,e){const t=b1(r,e),i=t.x*t.x+t.y*t.y,n=Math.sqrt(i+t.z*t.z);if(i===0){if(t.z===0)throw"Indeterminate sky coordinates";return new Tu(0,t.z<0?-90:90,n,t)}let s=f1*Math.atan2(t.y,t.x);s<0&&(s+=24);const a=Xn*Math.atan2(r[2],Math.sqrt(i));return new Tu(s,a,n,t)}function Nh(r,e){const t=r*gt,i=Math.cos(t),n=Math.sin(t);return[i*e[0]+n*e[1],i*e[1]-n*e[0],e[2]]}function w1(r,e,t,i,n){let s=Bt(r);Ef(e),hi(t),hi(i);const a=Math.sin(e.latitude*gt),o=Math.cos(e.latitude*gt),l=Math.sin(e.longitude*gt),c=Math.cos(e.longitude*gt),h=Math.sin(i*gt),d=Math.cos(i*gt),u=Math.sin(t*U0),f=Math.cos(t*U0);let p=[o*c,o*l,a],v=[-a*c,-a*l,o],m=[l,-c,0];const g=-15*Fc(s);let x=Nh(g,p),M=Nh(g,v),w=Nh(g,m),S=[d*f,d*u,h];const _=S[0]*x[0]+S[1]*x[1]+S[2]*x[2],D=S[0]*M[0]+S[1]*M[1]+S[2]*M[2],y=S[0]*w[0]+S[1]*w[1]+S[2]*w[2];let T=Math.hypot(D,y),A;T>0?(A=-Xn*Math.atan2(y,D),A<0&&(A+=360)):A=0;let I=Xn*Math.atan2(T,_),R=t,k=i;if(n){let z=I,L=D1(n,90-I);if(I-=L,L>0&&I>3e-4){const B=Math.sin(I*gt),F=Math.cos(I*gt),V=Math.sin(z*gt),j=Math.cos(z*gt),$=[];for(let ie=0;ie<3;++ie)$.push((S[ie]-j*x[ie])/V*B+x[ie]*F);T=Math.hypot($[0],$[1]),T>0?(R=f1*Math.atan2($[1],$[0]),R<0&&(R+=24)):R=0,k=Xn*Math.atan2($[2],T)}}return new RE(A,90-I,R,k)}function Ef(r){if(!(r instanceof _f))throw`Not an instance of the Observer class: ${r}`;if(hi(r.latitude),hi(r.longitude),hi(r.height),r.latitude<-90||r.latitude>90)throw`Latitude ${r.latitude} is out of range. Must be -90..+90.`;return r}class _f{constructor(e,t,i){this.latitude=e,this.longitude=t,this.height=i,Ef(this)}}function kE(r){const e=Bt(r).AddDays(-1/yf),t=Ma(Gn.Earth,e),i=[-t.x,-t.y,-t.z],[n,s,a]=Sf(i,e,bi.From2000),o=gt*zo(e).tobl,l=Math.cos(o),c=Math.sin(o),h=new Et(n,s,a,e);return M1(h,l,c)}function NE(r,e,t,i,n){Ef(t),xc(i),xc(n);const s=Bt(e),a=CE(s,t),o=Ou(r,s,n),l=[o.x-a[0],o.y-a[1],o.z-a[2]],c=Sf(l,s,bi.From2000);return LE(c,s)}function OE(r,e,t){const i=Bt(r),n=Fc(i);let s=y1(e,n).pos;return b1(s,i)}function M1(r,e,t){const i=r.x,n=r.y*e+r.z*t,s=-r.y*t+r.z*e,a=Math.hypot(i,n);let o=0;a>0&&(o=Xn*Math.atan2(n,i),o<0&&(o+=360));let l=Xn*Math.atan2(s,a),c=new Et(i,n,s,r.t);return new PE(c,l,o)}function Au(r){const e=zo(r.t),t=[r.x,r.y,r.z],i=Sc(t,r.t,bi.From2000),[n,s,a]=_u(i,r.t,bi.From2000),o=new Et(n,s,a,r.t),l=e.tobl*gt;return M1(o,Math.cos(l),Math.sin(l))}function Pa(r){const e=Bt(r),t=AE(e),i=t.distance_au*Math.cos(t.geo_eclip_lat),n=[i*Math.cos(t.geo_eclip_lon),i*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],s=TE(e,n),a=Sc(s,e,bi.Into2000);return new Et(a[0],a[1],a[2],e)}function x1(r){const e=Bt(r),t=1e-5,i=e.AddDays(-t),n=e.AddDays(+t),s=Pa(i),a=Pa(n);return new Fs((s.x+a.x)/2,(s.y+a.y)/2,(s.z+a.z)/2,(a.x-s.x)/(2*t),(a.y-s.y)/(2*t),(a.z-s.z)/(2*t),e)}function FE(r){const e=Bt(r),t=x1(e),i=1+m1;return new Fs(t.x/i,t.y/i,t.z/i,t.vx/i,t.vy/i,t.vz/i,e)}function wa(r,e,t){let i=1,n=0;for(let s of r){let a=0;for(let[l,c,h]of s)a+=l*Math.cos(c+e*h);let o=i*a;t&&(o%=ts),n+=o,i*=e}return n}function Oh(r,e){let t=1,i=0,n=0,s=0;for(let a of r){let o=0,l=0;for(let[c,h,d]of a){let u=h+e*d;o+=c*d*Math.sin(u),s>0&&(l+=c*Math.cos(u))}n+=s*i*l-t*o,i=t,t*=e,++s}return n}const ho=365250,Iu=0,Du=1,Cu=2;function Ru(r){return new _i(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 S1(r,e,t){const i=t*Math.cos(e),n=Math.cos(r),s=Math.sin(r);return[i*n,i*s,t*Math.sin(e)]}function Ma(r,e){const t=e.tt/ho,i=wa(r[Iu],t,!0),n=wa(r[Du],t,!1),s=wa(r[Cu],t,!1),a=S1(i,n,s);return Ru(a).ToAstroVector(e)}function Pu(r,e){const t=e/ho,i=wa(r[Iu],t,!0),n=wa(r[Du],t,!1),s=wa(r[Cu],t,!1),a=Oh(r[Iu],t),o=Oh(r[Du],t),l=Oh(r[Cu],t),c=Math.cos(i),h=Math.sin(i),d=Math.cos(n),u=Math.sin(n),f=+(l*d*c)-s*u*c*o-s*d*h*a,p=+(l*d*h)-s*u*h*o+s*d*c*a,v=+(l*u)+s*d*o,m=S1(i,n,s),g=[f/ho,p/ho,v/ho],x=Ru(m),M=Ru(g);return new br(e,x,M)}function Il(r,e,t,i){const n=i/(i+bf),s=Ma(Gn[t],e);r.x+=n*s.x,r.y+=n*s.y,r.z+=n*s.z}function UE(r){const e=new Et(0,0,0,r);return Il(e,r,xe.Jupiter,Mu),Il(e,r,xe.Saturn,xu),Il(e,r,xe.Uranus,Su),Il(e,r,xe.Neptune,Eu),e}const Lu=51,BE=29200,la=146,is=201,dr=[[-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 _i{constructor(e,t,i){this.x=e,this.y=t,this.z=i}clone(){return new _i(this.x,this.y,this.z)}ToAstroVector(e){return new Et(this.x,this.y,this.z,e)}static zero(){return new _i(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new _i(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new _i(this.x-e.x,this.y-e.y,this.z-e.z)}incr(e){this.x+=e.x,this.y+=e.y,this.z+=e.z}decr(e){this.x-=e.x,this.y-=e.y,this.z-=e.z}mul(e){return new _i(e*this.x,e*this.y,e*this.z)}div(e){return new _i(this.x/e,this.y/e,this.z/e)}mean(e){return new _i((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new _i(-this.x,-this.y,-this.z)}}class br{constructor(e,t,i){this.tt=e,this.r=t,this.v=i}clone(){return new br(this.tt,this.r,this.v)}sub(e){return new br(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function zE(r){let[e,[t,i,n],[s,a,o]]=r;return new br(e,new _i(t,i,n),new _i(s,a,o))}function Dl(r,e,t,i){const n=i/(i+bf),s=Pu(Gn[t],e);return r.r.incr(s.r.mul(n)),r.v.incr(s.v.mul(n)),s}function Ja(r,e,t){const i=t.sub(r),n=i.quadrature();return i.mul(e/(n*Math.sqrt(n)))}class Bc{constructor(e){let t=new br(e,new _i(0,0,0),new _i(0,0,0));this.Jupiter=Dl(t,e,xe.Jupiter,Mu),this.Saturn=Dl(t,e,xe.Saturn,xu),this.Uranus=Dl(t,e,xe.Uranus,Su),this.Neptune=Dl(t,e,xe.Neptune,Eu),this.Jupiter.r.decr(t.r),this.Jupiter.v.decr(t.v),this.Saturn.r.decr(t.r),this.Saturn.v.decr(t.v),this.Uranus.r.decr(t.r),this.Uranus.v.decr(t.v),this.Neptune.r.decr(t.r),this.Neptune.v.decr(t.v),this.Sun=new br(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=Ja(e,bf,this.Sun.r);return t.incr(Ja(e,Mu,this.Jupiter.r)),t.incr(Ja(e,xu,this.Saturn.r)),t.incr(Ja(e,Su,this.Uranus.r)),t.incr(Ja(e,Eu,this.Neptune.r)),t}}class zc{constructor(e,t,i,n){this.tt=e,this.r=t,this.v=i,this.a=n}clone(){return new zc(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class E1{constructor(e,t){this.bary=e,this.grav=t}}function Ec(r,e,t,i){return new _i(e.x+r*(t.x+r*i.x/2),e.y+r*(t.y+r*i.y/2),e.z+r*(t.z+r*i.z/2))}function G0(r,e,t){return new _i(e.x+r*t.x,e.y+r*t.y,e.z+r*t.z)}function ku(r,e){const t=r-e.tt,i=new Bc(r),n=Ec(t,e.r,e.v,e.a),s=i.Acceleration(n).mean(e.a),a=Ec(t,e.r,e.v,s),o=e.v.add(s.mul(t)),l=i.Acceleration(a),c=new zc(r,a,o,l);return new E1(i,c)}const HE=[];function _1(r,e){const t=Math.floor(r);return t<0?0:t>=e?e-1:t}function Nu(r){const e=zE(r),t=new Bc(e.tt),i=e.r.add(t.Sun.r),n=e.v.add(t.Sun.v),s=t.Acceleration(i),a=new zc(e.tt,i,n,s);return new E1(t,a)}function GE(r,e){const t=dr[0][0];if(e<t||e>dr[Lu-1][0])return null;const i=_1((e-t)/BE,Lu-1);if(!r[i]){const s=r[i]=[];s[0]=Nu(dr[i]).grav,s[is-1]=Nu(dr[i+1]).grav;let a,o=s[0].tt;for(a=1;a<is-1;++a)s[a]=ku(o+=la,s[a-1]).grav;o=s[is-1].tt;var n=[];for(n[is-1]=s[is-1],a=is-2;a>0;--a)n[a]=ku(o-=la,n[a+1]).grav;for(a=is-2;a>0;--a){const l=a/(is-1);s[a].r=s[a].r.mul(1-l).add(n[a].r.mul(l)),s[a].v=s[a].v.mul(1-l).add(n[a].v.mul(l)),s[a].a=s[a].a.mul(1-l).add(n[a].a.mul(l))}}return r[i]}function V0(r,e,t){let i=Nu(r);const n=Math.ceil((e-i.grav.tt)/t);for(let s=0;s<n;++s)i=ku(s+1===n?e:i.grav.tt+t,i.grav);return i}function T1(r,e){let t,i,n;const s=GE(HE,r.tt);if(s){const a=_1((r.tt-s[0].tt)/la,is-1),o=s[a],l=s[a+1],c=o.a.mean(l.a),h=Ec(r.tt-o.tt,o.r,o.v,c),d=G0(r.tt-o.tt,o.v,c),u=Ec(r.tt-l.tt,l.r,l.v,c),f=G0(r.tt-l.tt,l.v,c),p=(r.tt-o.tt)/la;t=h.mul(1-p).add(u.mul(p)),i=d.mul(1-p).add(f.mul(p))}else{let a;r.tt<dr[0][0]?a=V0(dr[0],r.tt,-la):a=V0(dr[Lu-1],r.tt,+la),t=a.grav.r,i=a.grav.v,n=a.bary}return n||(n=new Bc(r.tt)),t=t.sub(n.Sun.r),i=i.sub(n.Sun.v),new Fs(t.x,t.y,t.z,i.x,i.y,i.z,r)}function Us(r,e){var t=Bt(e);if(r in Gn)return Ma(Gn[r],t);if(r===xe.Pluto){const a=T1(t);return new Et(a.x,a.y,a.z,t)}if(r===xe.Sun)return new Et(0,0,0,t);if(r===xe.Moon){var i=Ma(Gn.Earth,t),n=Pa(t);return new Et(i.x+n.x,i.y+n.y,i.z+n.z,t)}if(r===xe.EMB){const a=Ma(Gn.Earth,t),o=Pa(t),l=1+m1;return new Et(a.x+o.x/l,a.y+o.y/l,a.z+o.z/l,t)}if(r===xe.SSB)return UE(t);const s=wf(r);if(s){const a=new Uc(s.dec,15*s.ra,s.dist);return Tf(a,t)}throw`HelioVector: Unknown body "${r}"`}function VE(r,e){let t=e,i=0;for(let n=0;n<10;++n){const s=r(t),a=s.Length()/yf;if(a>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-a);if(i=Math.abs(o.tt-t.tt),i<1e-9)return s;t=o}throw`Light-travel time solver did not converge: dt = ${i}`}class WE{constructor(e,t,i,n){this.observerBody=e,this.targetBody=t,this.aberration=i,this.observerPos=n}Position(e){this.aberration&&(this.observerPos=Us(this.observerBody,e));const t=Us(this.targetBody,e);return new Et(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function XE(r,e,t,i){xc(i);const n=Bt(r);if(wf(t)){const o=Us(t,n);if(i){const c=YE(e,n),h=new Et(o.x-c.x,o.y-c.y,o.z-c.z,n),d=yf/h.Length();return new Et(h.x+c.vx/d,h.y+c.vy/d,h.z+c.vz/d,n)}const l=Us(e,n);return new Et(o.x-l.x,o.y-l.y,o.z-l.z,n)}let s;i?s=new Et(0,0,0,n):s=Us(e,n);const a=new WE(e,t,i,s);return VE(o=>a.Position(o),n)}function Ou(r,e,t){xc(t);const i=Bt(e);switch(r){case xe.Earth:return new Et(0,0,0,i);case xe.Moon:return Pa(i);default:const n=XE(i,xe.Earth,r,t);return n.t=i,n}}function qE(r,e){return new Fs(r.r.x,r.r.y,r.r.z,r.v.x,r.v.y,r.v.z,e)}function YE(r,e){const t=Bt(e);switch(r){case xe.Sun:return new Fs(0,0,0,0,0,0,t);case xe.SSB:const i=new Bc(t.tt);return new Fs(-i.Sun.r.x,-i.Sun.r.y,-i.Sun.r.z,-i.Sun.v.x,-i.Sun.v.y,-i.Sun.v.z,t);case xe.Mercury:case xe.Venus:case xe.Earth:case xe.Mars:case xe.Jupiter:case xe.Saturn:case xe.Uranus:case xe.Neptune:const n=Pu(Gn[r],t.tt);return qE(n,t);case xe.Pluto:return T1(t);case xe.Moon:case xe.EMB:const s=Pu(Gn.Earth,t.tt),a=r==xe.Moon?x1(t):FE(t);return new Fs(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,t);default:if(wf(r)){const o=Us(r,t);return new Fs(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${r}"`}}function KE(r){for(;r<0;)r+=360;for(;r>=360;)r-=360;return r}function $E(r,e,t){if(r===xe.Earth||e===xe.Earth)throw"The Earth does not have a longitude as seen from itself.";const i=Bt(t),n=Ou(r,i,!1),s=Au(n),a=Ou(e,i,!1),o=Au(a);return KE(s.elon-o.elon)}function ZE(r,e,t,i){let n,s=0,a=0,o=0;switch(r){case xe.Mercury:n=-.6,s=4.98,a=-4.88,o=3.02;break;case xe.Venus:e<163.6?(n=-4.47,s=1.03,a=.57,o=.13):(n=.98,s=-1.02);break;case xe.Mars:n=-1.52,s=1.6;break;case xe.Jupiter:n=-9.4,s=.5;break;case xe.Uranus:n=-7.19,s=.25;break;case xe.Neptune:n=-6.87;break;case xe.Pluto:n=-1,s=4;break;default:throw`VisualMagnitude: unsupported body ${r}`}const l=e/100;let c=n+l*(s+l*(a+l*o));return c+=5*Math.log10(t*i),c}function JE(r,e,t,i,n){const s=Au(i),a=gt*28.06,o=gt*(169.51+382e-7*n.tt),l=gt*s.elat,c=gt*s.elon,h=Math.asin(Math.sin(l)*Math.cos(a)-Math.cos(l)*Math.sin(a)*Math.sin(c-o)),d=Math.sin(Math.abs(h));let u=-9+.044*r;return u+=d*(-2.6+1.2*d),u+=5*Math.log10(e*t),{mag:u,ring_tilt:Xn*h}}function jE(r,e,t){let i=r*gt,n=i*i,s=n*n,a=-12.717+1.49*Math.abs(i)+.0431*s;const o=385000.6/sr;let l=t/o;return a+=5*Math.log10(e*l),a}class QE{constructor(e,t,i,n,s,a,o,l){this.time=e,this.mag=t,this.phase_angle=i,this.helio_dist=n,this.geo_dist=s,this.gc=a,this.hc=o,this.ring_tilt=l,this.phase_fraction=(1+Math.cos(gt*i))/2}}function A1(r,e){if(r===xe.Earth)throw"The illumination of the Earth is not defined.";const t=Bt(e),i=Ma(Gn.Earth,t);let n,s,a,o;r===xe.Sun?(a=new Et(-i.x,-i.y,-i.z,t),s=new Et(0,0,0,t),n=0):(r===xe.Moon?(a=Pa(t),s=new Et(i.x+a.x,i.y+a.y,i.z+a.z,t)):(s=Us(r,e),a=new Et(s.x-i.x,s.y-i.y,s.z-i.z,t)),n=yE(a,s));let l=a.Length(),c=s.Length(),h;if(r===xe.Sun)o=mE+5*Math.log10(l);else if(r===xe.Moon)o=jE(n,c,l);else if(r===xe.Saturn){const d=JE(n,c,l,a,t);o=d.mag,h=d.ring_tilt}else o=ZE(r,n,c,l);return new QE(t,o,n,c,l,a,s,h)}function e_(r){return $E(xe.Moon,xe.Sun,r)}var W0;(function(r){r[r.Pericenter=0]="Pericenter",r[r.Apocenter=1]="Apocenter"})(W0||(W0={}));function I1(r,e){return new zs([[e.rot[0][0]*r.rot[0][0]+e.rot[1][0]*r.rot[0][1]+e.rot[2][0]*r.rot[0][2],e.rot[0][1]*r.rot[0][0]+e.rot[1][1]*r.rot[0][1]+e.rot[2][1]*r.rot[0][2],e.rot[0][2]*r.rot[0][0]+e.rot[1][2]*r.rot[0][1]+e.rot[2][2]*r.rot[0][2]],[e.rot[0][0]*r.rot[1][0]+e.rot[1][0]*r.rot[1][1]+e.rot[2][0]*r.rot[1][2],e.rot[0][1]*r.rot[1][0]+e.rot[1][1]*r.rot[1][1]+e.rot[2][1]*r.rot[1][2],e.rot[0][2]*r.rot[1][0]+e.rot[1][2]*r.rot[1][1]+e.rot[2][2]*r.rot[1][2]],[e.rot[0][0]*r.rot[2][0]+e.rot[1][0]*r.rot[2][1]+e.rot[2][0]*r.rot[2][2],e.rot[0][1]*r.rot[2][0]+e.rot[1][1]*r.rot[2][1]+e.rot[2][1]*r.rot[2][2],e.rot[0][2]*r.rot[2][0]+e.rot[1][2]*r.rot[2][1]+e.rot[2][2]*r.rot[2][2]]])}function Tf(r,e){e=Bt(e);const t=r.lat*gt,i=r.lon*gt,n=r.dist*Math.cos(t);return new Et(n*Math.cos(i),n*Math.sin(i),r.dist*Math.sin(t),e)}function Af(r){const e=t_(r);return new Tu(e.lon/15,e.lat,e.dist,r)}function t_(r){const e=r.x*r.x+r.y*r.y,t=Math.sqrt(e+r.z*r.z);let i,n;if(e===0){if(r.z===0)throw"Zero-length vector not allowed.";n=0,i=r.z<0?-90:90}else n=Xn*Math.atan2(r.y,r.x),n<0&&(n+=360),i=Xn*Math.atan2(r.z,Math.sqrt(e));return new Uc(i,n,t)}function D1(r,e){let t;if(hi(e),e<-90||e>90)return 0;if(r==="normal"||r==="jplhor"){let i=e;i<-1&&(i=-1),t=1.02/Math.tan((i+10.3/(i+5.11))*gt)/60,r==="normal"&&e<-1&&(t*=(e+90)/89)}else if(!r)t=0;else throw`Invalid refraction option: ${r}`;return t}function xa(r,e){return new Et(r.rot[0][0]*e.x+r.rot[1][0]*e.y+r.rot[2][0]*e.z,r.rot[0][1]*e.x+r.rot[1][1]*e.y+r.rot[2][1]*e.z,r.rot[0][2]*e.x+r.rot[1][2]*e.y+r.rot[2][2]*e.z,e.t)}function i_(){return new zs([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function n_(){return new zs([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function C1(r){r=Bt(r);const e=Mf(r,bi.From2000),t=xf(r,bi.From2000);return I1(e,t)}function s_(r){r=Bt(r);const e=xf(r,bi.Into2000),t=Mf(r,bi.Into2000);return I1(e,t)}function r_(r){const t=zo(Bt(r)).tobl*gt,i=Math.cos(t),n=Math.sin(t);return new zs([[1,0,0],[0,+i,+n],[0,-n,+i]])}var X0;(function(r){r.Penumbral="penumbral",r.Partial="partial",r.Annular="annular",r.Total="total"})(X0||(X0={}));var q0;(function(r){r[r.Invalid=0]="Invalid",r[r.Ascending=1]="Ascending",r[r.Descending=-1]="Descending"})(q0||(q0={}));const a_=["Venus","Mars","Jupiter","Saturn"];function R1(r){return new _f(r.lat,r.lng,r.elevationM)}function If(r,e,t,i,n=!0){const s=w1(t,R1(i),r,e,n?"normal":void 0);return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}class fn{up;north;west;constructor(e,t){const i=Bt(e),n=Math.sin(t.lat*ns),s=Math.cos(t.lat*ns),a=Math.sin(t.lng*ns),o=Math.cos(t.lng*ns),l=-15*DE(i),c=s_(i);this.up=fn.rotate(c,fn.spin(l,[s*o,s*a,n]),i),this.north=fn.rotate(c,fn.spin(l,[-n*o,-n*a,s]),i),this.west=fn.rotate(c,fn.spin(l,[a,-o,0]),i)}static ofJ2000(e,t,i,n,s=!0){const a=Bt(i),o=Tf(new Uc(t,e*15,1),a),l=Af(xa(C1(a),o));return If(l.ra,l.dec,i,n,s)}position(e,t){const i=Math.sin(t*ns),n=Math.cos(t*ns),s=Math.sin(e*K0),a=Math.cos(e*K0),o=n*a,l=n*s,c=i,h=o*this.up[0]+l*this.up[1]+c*this.up[2],d=o*this.north[0]+l*this.north[1]+c*this.north[2],u=o*this.west[0]+l*this.west[1]+c*this.west[2],f=Math.hypot(d,u);let p=0;f>0&&(p=-Y0*Math.atan2(u,d),p<0&&(p+=360));let v=Y0*Math.atan2(f,h);return v-=D1("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(e,[t,i,n]){const s=Math.cos(e*ns),a=Math.sin(e*ns);return[s*t+a*i,s*i-a*t,n]}static rotate(e,[t,i,n],s){const a=xa(e,new Et(t,i,n,s));return[a.x,a.y,a.z]}}const ns=Math.PI/180,Y0=180/Math.PI,K0=15*ns;function Ui(r,e,t){const i=R1(t),n=NE(xe[r],e,i,!0,!0),s=w1(e,i,n.ra,n.dec,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Fh(r,e){return A1(xe[r],e).mag}function _c(r){const e=e_(r),t=A1(xe.Moon,r);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const o_=2e3,l_=3,c_=20;function zn(r,e,t){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??o_,s=r.month??(i?1:l_),a=r.day??(i?1:c_),o=t??Math.round(e/15);return new Date(Date.UTC(n,s-1,a,(r.hour??12)-o,r.minute??0,r.second??0))}class Ls{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(e){e.transparent=!0,e.depthWrite=!1,e.onBeforeCompile=t=>{t.fragmentShader=Ls.patch(t.fragmentShader)}}static patch(e){return e.replace(Ls.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
6681
6681
  // Outside the inscribed circle there is no star at all — this is what kills the corners.
6682
6682
  if ( distanceFromCentre > ${Ls.RIM.toFixed(2)} ) discard;
6683
6683
  float glare = 1.0 - smoothstep( ${Ls.CORE.toFixed(2)}, ${Ls.RIM.toFixed(2)}, distanceFromCentre );
@@ -6781,7 +6781,7 @@ void main() {
6781
6781
  float blur = max(vNearBlur, vHaze);
6782
6782
  gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${w_.toFixed(2)}));
6783
6783
  }
6784
- `;function S_(r){let e=r;return function(){e|=0,e=e+1831565813|0;let i=Math.imul(e^e>>>15,1|e);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}const E_=.14,Z0=4.5;let Cl;function __(){if(Cl)return Cl;const r=128,e=document.createElement("canvas");e.width=r,e.height=r;const t=e.getContext("2d"),i=t.createImageData(r,r),n=r/2,s=r*E_,a=r-s;for(let o=0;o<r;o++)for(let l=0;l<r;l++){const c=l+.5-n,h=o+.5<s?o+.5-s:o+.5>a?o+.5-a:0,d=Math.hypot(c,h),u=Math.exp(-(d*d)/(2*Z0*Z0)),f=(o*r+l)*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,u))}return t.putImageData(i,0,0),Cl=new Kn(e),Cl}function T_(r){const e=S_(r.seed),t=new Float32Array(r.count*3),i=new Float32Array(r.count),n=r.radiusM;for(let c=0;c<r.count;c++){const h=e()*Math.PI*2,d=Math.sqrt(e())*r.radiusM;t[c*3]=Math.cos(h)*d,t[c*3+1]=e()*r.heightM,t[c*3+2]=Math.sin(h)*d,i[c]=.85+e()*.3}const s=new Tt;s.setAttribute("position",new ht(t,3)),s.setAttribute("aSpeed",new ht(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 Te(0,0)},uDropVelocity:{value:new P(0,-1,0)},uAspect:{value:1},uHeight:{value:r.heightM},uBottomY:{value:r.bottomYM},uHalfWidth:{value:n},uTexture:{value:__()},uNearFocusDistance:{value:r.nearFocusDistanceM},uHazeDistance:{value:r.hazeDistanceM},uHazeColor:{value:r.hazeColor}},o=new Ot({uniforms:a,vertexShader:M_,fragmentShader:x_,transparent:!0,depthWrite:!1,depthTest:!0}),l=new vo(s,o);return l.frustumCulled=!1,{points:l,uniforms:a}}class us{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(e){return us.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(e,1e-12))}static fromMagPerArcsec2(e){return 10**(.4*(us.S10_MAG_PER_ARCSEC2-e))}static latitudeOfRowCoord(e){const t=2*e-1;return 90*Math.sign(t)*t*t}static rowCoordOfLatitude(e){return(Math.sign(e)*Math.sqrt(Math.min(Math.abs(e),90)/90)+1)/2}static angleOfColumnCoord(e){return 180*e*e}static columnCoordOfAngle(e){return Math.sqrt(Math.min(Math.max(e,0),180)/180)}}class Qe{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(e,t){return this.radianceTowards(e,t)*Qe.anchor()}static anchor(){return us.fromMagPerArcsec2(Qe.PEAK_MAG_PER_ARCSEC2)/Qe.PEAK_RADIANCE}radianceTowards(e,t){return this.trace(e,t).light}extinctionTowards(e,t){return this.trace(e,t).extinctionMag}trace(e,t){const i=e*Math.PI/180,n=t*Math.PI/180,s=-Math.cos(n)*Math.cos(i),a=Math.cos(n)*Math.sin(i),o=Math.sin(n);let l=0,c=0,h=0;const d=Math.log(Qe.NEAR_LIMIT_KPC),u=Math.log(Qe.FAR_LIMIT_KPC)-d;for(let f=0;f<Qe.STEPS;f++){const p=Math.exp(d+u*f/(Qe.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=Qe.SUN_RADIUS_KPC+m*s,x=m*a,M=Qe.SUN_HEIGHT_KPC+m*o,w=Math.hypot(g,x),S=Math.exp(-(w-Qe.SUN_RADIUS_KPC)/Qe.DISK_SCALE_LENGTH_KPC-Math.abs(M)/Qe.DISK_SCALE_HEIGHT_KPC),_=Math.hypot(w,M/Qe.BULGE_FLATTENING),D=Qe.BULGE_TO_LOCAL_DISK*Math.exp(-_/Qe.BULGE_SCALE_KPC);if(l+=(S+D)*v*10**(-.4*c),c+=Qe.EXTINCTION_MAG_PER_KPC*Math.exp(-(w-Qe.SUN_RADIUS_KPC)/Qe.DUST_SCALE_LENGTH_KPC-(Math.abs(M)-Qe.SUN_HEIGHT_KPC)/Qe.DUST_SCALE_HEIGHT_KPC)*v,c>Qe.OPAQUE_MAG)break}return{light:l,extinctionMag:c}}values=new Float32Array(Qe.LONGITUDE_STEPS*Qe.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Qe.LATITUDE_STEPS}walk(e){const t=Qe.LONGITUDE_STEPS,i=Math.min(Qe.LATITUDE_STEPS,this.walked+e);for(;this.walked<i;this.walked++){const n=us.latitudeOfRowCoord((this.walked+.5)/Qe.LATITUDE_STEPS);for(let s=0;s<t;s++)this.values[this.walked*t+s]=this.radianceTowards(360*(s+.5)/t,n)}}harvest(){let e=Number.POSITIVE_INFINITY;for(const n of this.values)n<e&&(e=n);const t=Qe.anchor(),i=new Float32Array(this.values.length);for(let n=0;n<i.length;n++)i[n]=(this.values[n]-e)*t;return{width:Qe.LONGITUDE_STEPS,height:Qe.LATITUDE_STEPS,data:i}}}class Pt{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(e,t){return this.radianceTowards(e,t)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=Pt.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(e,t){const i=e*Math.PI/180,n=t*Math.PI/180,s=-Math.cos(n)*Math.cos(i),a=-Math.cos(n)*Math.sin(i),o=Math.sin(n),l=-s;let c=0,h=0;const d=Math.log(Pt.NEAR_LIMIT_AU),u=Math.log(Pt.FAR_LIMIT_AU)-d;for(let f=0;f<Pt.STEPS;f++){const p=Math.exp(d+u*f/(Pt.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=1+m*s,x=m*a,M=m*o,w=Math.hypot(g,x,M);if(w<Pt.SUBLIMATION_AU)continue;const S=M/w,_=w**-1.3*Math.exp(-2.6*Math.abs(S)),D=(l-m)/w;c+=_*this.scattering(D)*v/(w*w)}return c}scattering(e){let t=0;for(let i=0;i<Pt.LOBE_ASYMMETRY.length;i++){const n=Pt.LOBE_ASYMMETRY[i],s=1+n*n-2*n*e;t+=Pt.LOBE_WEIGHT[i]*(1-n*n)/(4*Math.PI*s**1.5)}return t}values=new Float32Array(Pt.LONGITUDE_STEPS*Pt.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Pt.LATITUDE_STEPS}walk(e){const t=Pt.LONGITUDE_STEPS,i=Math.min(Pt.LATITUDE_STEPS,this.walked+e);for(;this.walked<i;this.walked++){const n=us.latitudeOfRowCoord((this.walked+.5)/Pt.LATITUDE_STEPS);for(let s=0;s<t;s++){const a=us.angleOfColumnCoord((s+.5)/t);this.values[this.walked*t+s]=this.radianceTowards(a,n)}}}harvest(){const e=this.anchor();let t=Number.POSITIVE_INFINITY;for(const n of this.values)n<t&&(t=n);const i=new Float32Array(this.values.length);for(let n=0;n<i.length;n++)i[n]=(this.values[n]-t)*e;return{width:Pt.LONGITUDE_STEPS,height:Pt.LATITUDE_STEPS,data:i}}}class Be{static get NANOLAMBERTS_PER_S10(){return Be.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(e){return e*Be.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},...Array.from({length:15},(e,t)=>{const i=-4-t;return{sunAltitudeDeg:i,magPerArcsec2:Be.patatV(i)}}),{sunAltitudeDeg:-24,magPerArcsec2:22}];static patatV(e){const t=90-e-95;return 11.84+1.518*t-.057*t*t}static moonlessMagPerArcsec2(e){const t=Be.TWILIGHT;for(let i=0;i<t.length-1;i++){const n=t[i],s=t[i+1];if(e<=n.sunAltitudeDeg&&e>=s.sunAltitudeDeg){const a=(n.sunAltitudeDeg-e)/(n.sunAltitudeDeg-s.sunAltitudeDeg);return n.magPerArcsec2+(s.magPerArcsec2-n.magPerArcsec2)*a}}return e>0?t[0].magPerArcsec2:t[t.length-1].magPerArcsec2}static toNanolamberts(e){return 34.08*Math.exp(Be.NANOLAMBERT_OFFSET-Be.PER_MAGNITUDE*e)}static fromNanolamberts(e){return(Be.NANOLAMBERT_OFFSET-Math.log(Math.max(e,1e-6)/34.08))/Be.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(e){const t=Math.cos(Math.max(e,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*t*t,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(e){const t=Math.min(Math.max(e,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(t)**2)+10**(6.15-Math.min(e,180)/40)}static scatteredFraction(e){return 1-10**(-.4*Be.EXTINCTION_PER_AIR_MASS*Be.airMass(e))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(e){return Math.max(0,Be.toNanolamberts(Be.moonlessMagPerArcsec2(e))-Be.toNanolamberts(Be.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(e){const t=Be.scatteringAt(90-e)*Be.scatteredFraction(90);return Be.twilightExcessNanolamberts(e)/t}static moonNanolamberts(e,t,i,n){return Be.scatteringAt(i)*Be.moonOutput(e,t)*Be.scatteredFraction(n)}static moonOutput(e,t){if(t<=0)return 0;const i=Math.min(Math.abs(e),180);return 10**(-.4*(3.84+.026*i+4e-9*i**4))*10**(-.4*Be.EXTINCTION_PER_AIR_MASS*Be.airMass(t))}static phaseAngleOf(e){return Math.acos(Math.min(Math.max(2*e-1,-1),1))*180/Math.PI}static magPerArcsec2(e,t,i){const n=Be.scatteredFraction(i),s=Be.scatteringAt(e.separationDeg)*Be.twilightOutput(e.altitudeDeg)*n,a=Be.scatteringAt(t.separationDeg)*Be.moonOutput(t.phaseAngleDeg,t.altitudeDeg)*n;return Be.fromNanolamberts(Be.toNanolamberts(Be.AIRGLOW_MAG_PER_ARCSEC2)+s+a)}}class Cs{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=rr.shared;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;repaint;constructor(){this.milkyWayTexels=this.maps.milkyWayTexels,this.milkyWayTexture=Cs.buildTexture(this.milkyWayTexels,Qe.LONGITUDE_STEPS,Qe.LATITUDE_STEPS,Io),this.zodiacalTexels=this.maps.zodiacalTexels,this.zodiacalTexture=Cs.buildTexture(this.zodiacalTexels,Pt.LONGITUDE_STEPS,Pt.LATITUDE_STEPS,Ri),this.material=new Ot({uniforms:{uMilkyWay:{value:this.milkyWayTexture},uZodiacal:{value:this.zodiacalTexture},uGalactic:{value:new ze},uEclipticPole:{value:new P(0,1,0)},uSunLongitude:{value:new P(1,0,0)},uMoonDirection:{value:new P(0,-1,0)},uMoonOutput:{value:0},uSunDirection:{value:new P(0,-1,0)},uTwilightOutput:{value:0},uAirglowNanolamberts:{value:Be.toNanolamberts(Be.AIRGLOW_MAG_PER_ARCSEC2)},uSkyColor:{value:new P(0,0,0)},uMilkyWayTint:{value:new P(...Cs.MILKY_WAY_TINT)},uZodiacalTint:{value:new P(...Cs.ZODIACAL_TINT)},uReady:{value:this.maps.done?1:0},uEncodeDestination:{value:1}},vertexShader:`
6784
+ `;function S_(r){let e=r;return function(){e|=0,e=e+1831565813|0;let i=Math.imul(e^e>>>15,1|e);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}const E_=.14,Z0=4.5;let Cl;function __(){if(Cl)return Cl;const r=128,e=document.createElement("canvas");e.width=r,e.height=r;const t=e.getContext("2d"),i=t.createImageData(r,r),n=r/2,s=r*E_,a=r-s;for(let o=0;o<r;o++)for(let l=0;l<r;l++){const c=l+.5-n,h=o+.5<s?o+.5-s:o+.5>a?o+.5-a:0,d=Math.hypot(c,h),u=Math.exp(-(d*d)/(2*Z0*Z0)),f=(o*r+l)*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,u))}return t.putImageData(i,0,0),Cl=new Kn(e),Cl}function T_(r){const e=S_(r.seed),t=new Float32Array(r.count*3),i=new Float32Array(r.count),n=r.radiusM;for(let c=0;c<r.count;c++){const h=e()*Math.PI*2,d=Math.sqrt(e())*r.radiusM;t[c*3]=Math.cos(h)*d,t[c*3+1]=e()*r.heightM,t[c*3+2]=Math.sin(h)*d,i[c]=.85+e()*.3}const s=new Tt;s.setAttribute("position",new ht(t,3)),s.setAttribute("aSpeed",new ht(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 Te(0,0)},uDropVelocity:{value:new P(0,-1,0)},uAspect:{value:1},uHeight:{value:r.heightM},uBottomY:{value:r.bottomYM},uHalfWidth:{value:n},uTexture:{value:__()},uNearFocusDistance:{value:r.nearFocusDistanceM},uHazeDistance:{value:r.hazeDistanceM},uHazeColor:{value:r.hazeColor}},o=new Ot({uniforms:a,vertexShader:M_,fragmentShader:x_,transparent:!0,depthWrite:!1,depthTest:!0}),l=new vo(s,o);return l.frustumCulled=!1,{points:l,uniforms:a}}class us{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(e){return us.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(e,1e-12))}static fromMagPerArcsec2(e){return 10**(.4*(us.S10_MAG_PER_ARCSEC2-e))}static latitudeOfRowCoord(e){const t=2*e-1;return 90*Math.sign(t)*t*t}static rowCoordOfLatitude(e){return(Math.sign(e)*Math.sqrt(Math.min(Math.abs(e),90)/90)+1)/2}static angleOfColumnCoord(e){return 180*e*e}static columnCoordOfAngle(e){return Math.sqrt(Math.min(Math.max(e,0),180)/180)}}class Qe{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(e,t){return this.radianceTowards(e,t)*Qe.anchor()}static anchor(){return us.fromMagPerArcsec2(Qe.PEAK_MAG_PER_ARCSEC2)/Qe.PEAK_RADIANCE}radianceTowards(e,t){return this.trace(e,t).light}extinctionTowards(e,t){return this.trace(e,t).extinctionMag}trace(e,t){const i=e*Math.PI/180,n=t*Math.PI/180,s=-Math.cos(n)*Math.cos(i),a=Math.cos(n)*Math.sin(i),o=Math.sin(n);let l=0,c=0,h=0;const d=Math.log(Qe.NEAR_LIMIT_KPC),u=Math.log(Qe.FAR_LIMIT_KPC)-d;for(let f=0;f<Qe.STEPS;f++){const p=Math.exp(d+u*f/(Qe.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=Qe.SUN_RADIUS_KPC+m*s,x=m*a,M=Qe.SUN_HEIGHT_KPC+m*o,w=Math.hypot(g,x),S=Math.exp(-(w-Qe.SUN_RADIUS_KPC)/Qe.DISK_SCALE_LENGTH_KPC-Math.abs(M)/Qe.DISK_SCALE_HEIGHT_KPC),_=Math.hypot(w,M/Qe.BULGE_FLATTENING),D=Qe.BULGE_TO_LOCAL_DISK*Math.exp(-_/Qe.BULGE_SCALE_KPC);if(l+=(S+D)*v*10**(-.4*c),c+=Qe.EXTINCTION_MAG_PER_KPC*Math.exp(-(w-Qe.SUN_RADIUS_KPC)/Qe.DUST_SCALE_LENGTH_KPC-(Math.abs(M)-Qe.SUN_HEIGHT_KPC)/Qe.DUST_SCALE_HEIGHT_KPC)*v,c>Qe.OPAQUE_MAG)break}return{light:l,extinctionMag:c}}values=new Float32Array(Qe.LONGITUDE_STEPS*Qe.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Qe.LATITUDE_STEPS}walk(e){const t=Qe.LONGITUDE_STEPS,i=Math.min(Qe.LATITUDE_STEPS,this.walked+e);for(;this.walked<i;this.walked++){const n=us.latitudeOfRowCoord((this.walked+.5)/Qe.LATITUDE_STEPS);for(let s=0;s<t;s++)this.values[this.walked*t+s]=this.radianceTowards(360*(s+.5)/t,n)}}harvest(){let e=Number.POSITIVE_INFINITY;for(const n of this.values)n<e&&(e=n);const t=Qe.anchor(),i=new Float32Array(this.values.length);for(let n=0;n<i.length;n++)i[n]=(this.values[n]-e)*t;return{width:Qe.LONGITUDE_STEPS,height:Qe.LATITUDE_STEPS,data:i}}}class Pt{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(e,t){return this.radianceTowards(e,t)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=Pt.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(e,t){const i=e*Math.PI/180,n=t*Math.PI/180,s=-Math.cos(n)*Math.cos(i),a=-Math.cos(n)*Math.sin(i),o=Math.sin(n),l=-s;let c=0,h=0;const d=Math.log(Pt.NEAR_LIMIT_AU),u=Math.log(Pt.FAR_LIMIT_AU)-d;for(let f=0;f<Pt.STEPS;f++){const p=Math.exp(d+u*f/(Pt.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=1+m*s,x=m*a,M=m*o,w=Math.hypot(g,x,M);if(w<Pt.SUBLIMATION_AU)continue;const S=M/w,_=w**-1.3*Math.exp(-2.6*Math.abs(S)),D=(l-m)/w;c+=_*this.scattering(D)*v/(w*w)}return c}scattering(e){let t=0;for(let i=0;i<Pt.LOBE_ASYMMETRY.length;i++){const n=Pt.LOBE_ASYMMETRY[i],s=1+n*n-2*n*e;t+=Pt.LOBE_WEIGHT[i]*(1-n*n)/(4*Math.PI*s**1.5)}return t}values=new Float32Array(Pt.LONGITUDE_STEPS*Pt.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Pt.LATITUDE_STEPS}walk(e){const t=Pt.LONGITUDE_STEPS,i=Math.min(Pt.LATITUDE_STEPS,this.walked+e);for(;this.walked<i;this.walked++){const n=us.latitudeOfRowCoord((this.walked+.5)/Pt.LATITUDE_STEPS);for(let s=0;s<t;s++){const a=us.angleOfColumnCoord((s+.5)/t);this.values[this.walked*t+s]=this.radianceTowards(a,n)}}}harvest(){const e=this.anchor();let t=Number.POSITIVE_INFINITY;for(const n of this.values)n<t&&(t=n);const i=new Float32Array(this.values.length);for(let n=0;n<i.length;n++)i[n]=(this.values[n]-t)*e;return{width:Pt.LONGITUDE_STEPS,height:Pt.LATITUDE_STEPS,data:i}}}class Be{static get NANOLAMBERTS_PER_S10(){return Be.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(e){return e*Be.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},...Array.from({length:15},(e,t)=>{const i=-4-t;return{sunAltitudeDeg:i,magPerArcsec2:Be.patatV(i)}}),{sunAltitudeDeg:-24,magPerArcsec2:22}];static patatV(e){const t=90-e-95;return 11.84+1.518*t-.057*t*t}static moonlessMagPerArcsec2(e){const t=Be.TWILIGHT;for(let i=0;i<t.length-1;i++){const n=t[i],s=t[i+1];if(e<=n.sunAltitudeDeg&&e>=s.sunAltitudeDeg){const a=(n.sunAltitudeDeg-e)/(n.sunAltitudeDeg-s.sunAltitudeDeg);return n.magPerArcsec2+(s.magPerArcsec2-n.magPerArcsec2)*a}}return e>0?t[0].magPerArcsec2:t[t.length-1].magPerArcsec2}static toNanolamberts(e){return 34.08*Math.exp(Be.NANOLAMBERT_OFFSET-Be.PER_MAGNITUDE*e)}static fromNanolamberts(e){return(Be.NANOLAMBERT_OFFSET-Math.log(Math.max(e,1e-6)/34.08))/Be.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(e){const t=Math.cos(Math.max(e,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*t*t,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(e){const t=Math.min(Math.max(e,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(t)**2)+10**(6.15-Math.min(e,180)/40)}static scatteredFraction(e){return 1-10**(-.4*Be.EXTINCTION_PER_AIR_MASS*Be.airMass(e))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(e){return Math.max(0,Be.toNanolamberts(Be.moonlessMagPerArcsec2(e))-Be.toNanolamberts(Be.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(e){const t=Be.scatteringAt(90-e)*Be.scatteredFraction(90);return Be.twilightExcessNanolamberts(e)/t}static moonNanolamberts(e,t,i,n){return Be.scatteringAt(i)*Be.moonOutput(e,t)*Be.scatteredFraction(n)}static moonOutput(e,t){if(t<=0)return 0;const i=Math.min(Math.abs(e),180);return 10**(-.4*(3.84+.026*i+4e-9*i**4))*10**(-.4*Be.EXTINCTION_PER_AIR_MASS*Be.airMass(t))}static phaseAngleOf(e){return Math.acos(Math.min(Math.max(2*e-1,-1),1))*180/Math.PI}static magPerArcsec2(e,t,i){const n=Be.scatteredFraction(i),s=Be.scatteringAt(e.separationDeg)*Be.twilightOutput(e.altitudeDeg)*n,a=Be.scatteringAt(t.separationDeg)*Be.moonOutput(t.phaseAngleDeg,t.altitudeDeg)*n;return Be.fromNanolamberts(Be.toNanolamberts(Be.AIRGLOW_MAG_PER_ARCSEC2)+s+a)}}class Cs{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=rr.shared;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;repaint;constructor(){this.milkyWayTexels=this.maps.milkyWayTexels,this.milkyWayTexture=Cs.buildTexture(this.milkyWayTexels,Qe.LONGITUDE_STEPS,Qe.LATITUDE_STEPS,Io),this.zodiacalTexels=this.maps.zodiacalTexels,this.zodiacalTexture=Cs.buildTexture(this.zodiacalTexels,Pt.LONGITUDE_STEPS,Pt.LATITUDE_STEPS,Ri),this.material=new Ot({uniforms:{uMilkyWay:{value:this.milkyWayTexture},uZodiacal:{value:this.zodiacalTexture},uGalactic:{value:new He},uEclipticPole:{value:new P(0,1,0)},uSunLongitude:{value:new P(1,0,0)},uMoonDirection:{value:new P(0,-1,0)},uMoonOutput:{value:0},uSunDirection:{value:new P(0,-1,0)},uTwilightOutput:{value:0},uAirglowNanolamberts:{value:Be.toNanolamberts(Be.AIRGLOW_MAG_PER_ARCSEC2)},uSkyColor:{value:new P(0,0,0)},uMilkyWayTint:{value:new P(...Cs.MILKY_WAY_TINT)},uZodiacalTint:{value:new P(...Cs.ZODIACAL_TINT)},uReady:{value:this.maps.done?1:0},uEncodeDestination:{value:1}},vertexShader:`
6785
6785
  varying vec3 vDirection;
6786
6786
  void main() {
6787
6787
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -7449,7 +7449,7 @@ void main()
7449
7449
  // values — and encoded only at the very end. See colorSpace.ts.
7450
7450
  gl_FragColor = vec4(forDestination(total / weight), colour.a);
7451
7451
  }
7452
- `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new We(new wn(2,2),this.material))}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height)}setLens(e,t,i,n){const s=this.material.uniforms;s.uApertureMm2.value=e*e/Math.max(.1,t),s.uFocusDistance.value=Math.max(0,i),s.uFocalLengthMm.value=e,s.uPixelsPerMm.value=this.height/Math.max(.1,n)}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}render(e,t,i,n){const s=this.material.uniforms;s.uNear.value=i.near,s.uFar.value=i.far;const a=e.getRenderTarget();e.setRenderTarget(this.target),e.clear(),e.render(t,i),n?.(),e.setRenderTarget(a),e.render(this.quadScene,this.quadCamera)}dispose(){this.target.depthTexture?.dispose(),this.target.dispose(),this.material.dispose()}}class Dt{static MIN_RATIO=1;static STEP=.25;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(e,t){this.maxRatio=Dt.clamp(e),this.ratio=this.maxRatio,this.timer=t?Tc.create(t):void 0}get pixelRatio(){return this.ratio}get timesGpu(){return this.timer!==void 0}set maximum(e){this.maxRatio=Dt.clamp(e),this.ratio>this.maxRatio&&(this.ratio=this.maxRatio)}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(e,t){const i=this.timer?.poll();if(!(this.timer&&i===void 0))return i!==void 0?this.followGpu(e,i):this.followIntervals(e,t)}followGpu(e,t){if(t>Dt.GPU_LATE_MS)return this.lower(e,Dt.LOWER_COOLDOWN_MS);if(t<Dt.GPU_ROOM_MS)return this.raise(e,Dt.RAISE_COOLDOWN_MS)}followIntervals(e,t){if(!(t>0)||t>1e3)return;this.intervalMs=this.intervalMs===void 0?t:this.intervalMs*.9+t*.1;const i=this.intervalMs>Dt.INTERVAL_LATE_MS;if(this.probe){if(i)return this.ratio=this.probe.ratioBefore,this.probe=void 0,this.lastChangeMs=e,this.nextProbeMs=e+Dt.PROBE_BACKOFF_MS,this.ratio;e-this.probe.sinceMs>=Dt.PROBE_WATCH_MS&&(this.probe=void 0,this.nextProbeMs=e+Dt.PROBE_EVERY_MS);return}if(i){const n=this.lower(e,Dt.LOWER_COOLDOWN_MS);return n!==void 0&&(this.nextProbeMs=e+Dt.PROBE_EVERY_MS),n}if(this.ratio<this.maxRatio&&e>=this.nextProbeMs&&e-this.lastChangeMs>=Dt.RAISE_COOLDOWN_MS){const n=this.ratio,s=this.raise(e,0);return s!==void 0&&(this.probe={sinceMs:e,ratioBefore:n}),s}}lower(e,t){if(!(this.ratio<=Dt.MIN_RATIO||e-this.lastChangeMs<t))return this.ratio=Dt.clamp(this.ratio-Dt.STEP),this.lastChangeMs=e,this.ratio}raise(e,t){if(!(this.ratio>=this.maxRatio||e-this.lastChangeMs<t))return this.ratio=Math.min(this.maxRatio,Dt.clamp(this.ratio+Dt.STEP)),this.lastChangeMs=e,this.ratio}static clamp(e){return Number.isFinite(e)?Math.max(Dt.MIN_RATIO,Math.round(e/Dt.STEP)*Dt.STEP):Dt.MIN_RATIO}}class Tc{constructor(e,t){this.gl=e,this.extension=t}static IN_FLIGHT_MAX=8;static create(e){if(!(e instanceof WebGL2RenderingContext))return;const t=e.getExtension("EXT_disjoint_timer_query_webgl2");return t?new Tc(e,t):void 0}pending=[];active;smoothedMs;begin(){if(!(this.active||this.pending.length>=Tc.IN_FLIGHT_MAX))try{const e=this.gl.createQuery();if(!e)return;this.gl.beginQuery(this.extension.TIME_ELAPSED_EXT,e),this.active=e}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 e=this.gl;try{for(let t=0;t<this.pending.length;t++){const i=this.pending[t];if(!e.getQueryParameter(i,e.QUERY_RESULT_AVAILABLE))continue;if(!e.getParameter(this.extension.GPU_DISJOINT_EXT)){const s=e.getQueryParameter(i,e.QUERY_RESULT)/1e6;this.smoothedMs=this.smoothedMs===void 0?s:this.smoothedMs*.8+s*.2}e.deleteQuery(i),this.pending.splice(t,1),t--}}catch{this.pending.length=0}return this.smoothedMs}reset(){this.smoothedMs=void 0}}class et{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 e=et.ICE_INDEX_RED,t=Math.sqrt((4-e*e)/3);return Math.asin(Math.min(1,t))*180/Math.PI}static minimumDeviationDeg(e,t){const i=e*Math.PI/180,n=t*Math.sin(i/2);return n>1?Number.NaN:(2*Math.asin(n)-i)*180/Math.PI}static effectiveIndex(e,t){const i=t*Math.PI/180,n=Math.cos(i);return n<=0?Number.POSITIVE_INFINITY:Math.sqrt(e*e-Math.sin(i)**2)/n}static parheliaAzimuthDeg(e,t=et.ICE_INDEX_RED){const i=et.minimumDeviationDeg(et.SIDE_PRISM_ANGLE_DEG,et.effectiveIndex(t,e));return Number.isFinite(i)?i:void 0}static parheliaDistanceDeg(e,t=et.ICE_INDEX_RED){const i=et.parheliaAzimuthDeg(e,t);if(i===void 0)return;const n=e*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 e=et.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(e*e-1)))*180/Math.PI}static circumzenithalAltitudeDeg(e,t=et.ICE_INDEX_RED){if(e<0||e>90-et.PLATE_END_FACE_LIMIT_DEG)return;const i=Math.cos(e*Math.PI/180),n=Math.sqrt(t*t-i*i);if(!(n>=1))return Math.asin(n)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(e){return Math.acos(6371e3/(6371e3+Math.max(0,e)))*180/Math.PI}static halo22(){return et.ringOf("halo22",et.SIDE_PRISM_ANGLE_DEG)}static halo46(){return et.ringOf("halo46",et.END_PRISM_ANGLE_DEG)}static ringOf(e,t){const i=et.minimumDeviationDeg(t,et.ICE_INDEX_RED),n=et.minimumDeviationDeg(t,et.ICE_INDEX_BLUE);return{id:e,angleDeg:(i+n)/2,redAngleDeg:i,blueAngleDeg:n}}static strength(e,t,i=90,n=0){const s=Math.max(0,Math.min(1,e)),a=Math.max(0,1-Math.max(0,Math.min(1,t))),o=i>=0?1:n<=0?0:Math.max(0,1+i/n);return s*a*o}static formsAt(e,t=0){if(e<=-t)return[];const i=[et.halo22(),et.halo46()],n=e>0?et.parheliaDistanceDeg(e):void 0;n!==void 0&&i.push({id:"parhelia",angleDeg:n,redAngleDeg:n,blueAngleDeg:et.parheliaDistanceDeg(e,et.ICE_INDEX_BLUE)}),i.push({id:"tangentArc",angleDeg:et.halo22().angleDeg}),e>0&&i.push({id:"parhelicCircle",angleDeg:e});const s=et.circumzenithalAltitudeDeg(e);return s!==void 0&&i.push({id:"circumzenithal",angleDeg:s}),e>et.PLATE_END_FACE_LIMIT_DEG&&i.push({id:"circumhorizontal"}),e<et.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&i.push({id:"pillar"}),i}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class fi{static get WATER_INDEX_RED(){return ai.indexAt(ai.RED_NM)}static get WATER_INDEX_BLUE(){return ai.indexAt(ai.BLUE_NM)}static radiusDeg(e,t){const i=(t*t-1)/(e*e-1);if(i<0||i>1)return Number.NaN;const n=Math.acos(Math.sqrt(i)),s=Math.asin(Math.sin(n)/t),a=2*(n-s)+(e-1)*(Math.PI-2*s),o=2*Math.PI;let l=a%o;return l<0&&(l+=o),l>Math.PI&&(l=o-l),180-l*180/Math.PI}static primary(){return fi.bowOf("primary",2,0)}static secondary(){return fi.bowOf("secondary",3,0)}static bowOf(e,t,i){const n=fi.radiusDeg(t,fi.WATER_INDEX_RED),s=fi.radiusDeg(t,fi.WATER_INDEX_BLUE),a=(n+s)/2;return{id:e,radiusDeg:a,redRadiusDeg:n,violetRadiusDeg:s,topAltitudeDeg:a-i}}static alexandersBandDeg(){return{fromDeg:fi.primary().redRadiusDeg,toDeg:fi.secondary().redRadiusDeg}}static formsAt(e){return e<0?[]:[fi.bowOf("primary",2,e),fi.bowOf("secondary",3,e)].filter(t=>t.topAltitudeDeg>0)}static FULL_MOON_MAGNITUDE=-12.7;static moonlightShare(e){return Math.min(1,10**(-.4*(e-fi.FULL_MOON_MAGNITUDE)))}static strength(e,t,i){if(i<=0)return 0;const n=Math.max(0,Math.min(1,e)),s=Math.max(0,1-Math.max(0,Math.min(1,t)));return n*s}}class qi{constructor(e){this.radius=e;const t=qi.SEGMENTS*qi.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const i=new Tt;i.setAttribute("position",new ht(this.positions,3)),i.setAttribute("color",new ht(this.colors,3)),i.setDrawRange(0,0),this.object=new We(i,new rn({vertexColors:!0,transparent:!0,blending:Zi,depthWrite:!1,fog:!1,side:pn})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=qi.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(qi.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(e,t,i){this.head=e&&oi(e.altitudeDeg,e.azimuthDeg,1),this.tip=t&&oi(t.altitudeDeg,t.azimuthDeg,1),this.brightness=i,this.rebuild()}rebuild(){const e=this.object.geometry,t=this.head,i=this.tip;if(!t||!i||this.brightness<=0){e.setDrawRange(0,0);return}const n=this.angleBetween(t,i);if(n<=0){e.setDrawRange(0,0);return}const s=n*qi.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(t,i,h),this.radius),o=h=>this.radius*(qi.HEAD_HALF_WIDTH_DEG*Math.PI/180+s*h),l=h=>this.brightness*(1-h)**qi.FADE_POWER;let c=0;for(let h=1;h<qi.POINTS;h++){const d=(h-1)/qi.SEGMENTS,u=h/qi.SEGMENTS;c=this.pushBand(c,a(d),a(u),o(d),o(u),l(d),l(u))}e.setDrawRange(0,c),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,i,n,s,a,o){const l=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(i,t))));for(let c=0;c<qi.ACROSS-1;c++){const h=c-1,d=c,u=this.across(t,l,n,h),f=this.across(i,l,s,h),p=this.across(t,l,n,d),v=this.across(i,l,s,d),m=(g,x)=>g===0?x:0;e=this.push(e,u,m(h,a)),e=this.push(e,f,m(h,o)),e=this.push(e,p,m(d,a)),e=this.push(e,f,m(h,o)),e=this.push(e,v,m(d,o)),e=this.push(e,p,m(d,a))}return e}across(e,t,i,n){return{x:e.x+t.x*i*n,y:e.y+t.y*i*n,z:e.z+t.z*i*n}}push(e,t,i){const n=e*3;this.positions[n]=t.x,this.positions[n+1]=t.y,this.positions[n+2]=t.z;const s=Math.max(0,Math.min(1,i));return this.colors[n]=s*.55,this.colors[n+1]=s*.75,this.colors[n+2]=s,e+1}slerp(e,t,i){const n=this.angleBetweenRadians(e,t);if(n<1e-9)return e;const s=Math.sin(n),a=Math.sin((1-i)*n)/s,o=Math.sin(i*n)/s;return{x:e.x*a+t.x*o,y:e.y*a+t.y*o,z:e.z*a+t.z*o}}angleBetween(e,t){return this.angleBetweenRadians(e,t)*180/Math.PI}angleBetweenRadians(e,t){const i=e.x*t.x+e.y*t.y+e.z*t.z;return Math.acos(Math.min(1,Math.max(-1,i)))}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class R_{object=new ci;radius;tiers;drawn=[];constructor(e){this.radius=e,this.object.name="satellites",this.tiers=vf.map(t=>{const i=new hf({vertexColors:!0,size:t.size,sizeAttenuation:!1,fog:!1});Ls.apply(i);const n=new vo(new Tt,i);return n.frustumCulled=!1,this.object.add(n),n})}set(e,t,i){const n=this.tiers.map(()=>[]);this.drawn=[];for(const s of e){const a=i(s.position);if(a<=0)continue;const o=s.magnitude-2.5*Math.log10(a);if(o>t)continue;const l=lo(o,t),c=u1(l),{x:h,y:d,z:u}=oi(s.position.altitudeDeg,s.position.azimuthDeg,this.radius),f=Is(s.position.altitudeDeg),p=co(l);n[c].push({x:h,y:d,z:u,r:p*f[0],g:p*f[1],b:p*f[2]}),this.drawn.push({satellite:s,direction:new P(h,d,u).normalize()})}this.tiers.forEach((s,a)=>{const o=n[a],l=new Float32Array(o.length*3),c=new Float32Array(o.length*3);o.forEach((d,u)=>{l.set([d.x,d.y,d.z],u*3),c.set([d.r,d.g,d.b],u*3)}),s.geometry.dispose();const h=new Tt;h.setAttribute("position",new ht(l,3)),h.setAttribute("color",new ht(c,3)),s.geometry=h})}get count(){return this.drawn.length}nearest(e,t){let i,n=t;for(const s of this.drawn){const a=s.direction.dot(e);a>n&&(n=a,i=s.satellite)}return i}dispose(){for(const e of this.tiers)e.geometry.dispose(),e.material.dispose();this.object.removeFromParent(),this.drawn=[]}}class Hc{constructor(e){this.state=e}next(){this.state=this.state+1831565813|0;let e=this.state;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}between(e,t){return e+this.next()*(t-e)}}class pr{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(e){const{ratePerHour:t,durationMs:i,velocityKmS:n,seed:s}=e;if(t<=0||i<=0)return[];const a=t*i/36e5,o=new Hc(s),l=Math.floor(a),c=l+(o.next()<a-l?1:0),h=[];for(let d=0;d<c;d++){const u=Math.min(1,Math.max(0,(n-20)/52)),f=pr.MAX_DURATION_MS-u*(pr.MAX_DURATION_MS-pr.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+u),brightness:o.next()**3}),h.sort((v,m)=>v.t-m.t)}return h}static aliveAt(e,t){return e.filter(i=>t>=i.t&&t<=i.t+i.durationMs).map(i=>({meteor:i,progress:(t-i.t)/i.durationMs}))}}class ca{object=new ci;radius;core;glow;flashKey;static CORE_WIDTH_DEG=.06;static GLOW_WIDTH_DEG=.5;static SEGMENTS=28;constructor(e){this.radius=e,this.object.name="lightning-bolt",this.core=new rn({color:15659775,transparent:!0,opacity:0,blending:Zi,depthWrite:!1,fog:!1}),this.glow=new rn({color:10466559,transparent:!0,opacity:0,blending:Zi,depthWrite:!1,fog:!1}),this.object.visible=!1,this.object.renderOrder=5.95}set(e,t,i){if(!e||!e.cloudToGround||t<=.01){this.object.visible=!1;return}const n=`${e.channelSeed}:${Math.round(i)}`;n!==this.flashKey&&this.build(e,i,n),this.core.opacity=Math.min(1,t*1.4),this.glow.opacity=t*.35,this.object.visible=!0}build(e,t,i){this.flashKey=i;for(const c of[...this.object.children])c.geometry.dispose(),this.object.remove(c);const n=new Hc(e.channelSeed),s=Math.atan2(t,e.distanceM)*180/Math.PI,a=this.channel(n,e.azimuthDeg,s,0,1),o=[a],l=1+Math.floor(n.next()*2);for(let c=0;c<l;c++){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 c of o)this.object.add(new We(this.ribbon(c,ca.GLOW_WIDTH_DEG),this.glow)),this.object.add(new We(this.ribbon(c,ca.CORE_WIDTH_DEG),this.core))}channel(e,t,i,n,s){const a=[],o=i-n;let l=t;for(let c=0;c<=ca.SEGMENTS;c++){const h=i-o*c/ca.SEGMENTS;a.push({azimuthDeg:l,altitudeDeg:h}),l+=e.between(-1,1)*o*.06*s}return a}ribbon(e,t){const i=new Float32Array(e.length*2*3),n=[],s=this.radius*Math.tan(t*Math.PI/180)/2,a=e.map(l=>{const{x:c,y:h,z:d}=oi(l.altitudeDeg,l.azimuthDeg,this.radius);return new P(c,h,d)});a.forEach((l,c)=>{const h=a[Math.min(c+1,a.length-1)],d=a[Math.max(c-1,0)],f=h.clone().sub(d).normalize().cross(l.clone().normalize()).normalize().multiplyScalar(s);if(i.set([l.x+f.x,l.y+f.y,l.z+f.z],c*6),i.set([l.x-f.x,l.y-f.y,l.z-f.z],c*6+3),c<a.length-1){const p=c*2;n.push(p,p+1,p+2,p+1,p+3,p+2)}});const o=new Tt;return o.setAttribute("position",new ht(i,3)),o.setIndex(n),o}dispose(){for(const e of this.object.children)e.geometry.dispose();this.core.dispose(),this.glow.dispose(),this.object.removeFromParent()}}class Qt{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(e){const t=new Hc(e.seed),i=[],{minS:n,maxS:s}=Qt.intervalFor(e.intensity??.5);let a=t.between(0,s)*1e3;for(;a<e.durationMs;){const o=t.next()<Qt.CLOUD_TO_GROUND_FRACTION,l=Qt.MIN_DISTANCE_M,c=Qt.MAX_DISTANCE_M,h=Math.sqrt(t.between(l*l,c*c)),d=o?1+Math.floor(t.next()*4):1,u=[];let f=0;for(let p=0;p<d;p++)u.push({offsetMs:f,intensity:p===0?1:t.between(.4,.9)}),f+=Qt.INTERSTROKE_MS*t.between(.5,1.6);i.push({t:a,azimuthDeg:t.between(0,360),distanceM:h,cloudToGround:o,strokes:u,channelSeed:Math.floor(t.next()*2**31)}),a+=t.between(n,s)*1e3}return i}static intervalFor(e){const t=Math.min(1,Math.max(0,(e-.5)/.5));return{minS:Qt.MIN_INTERVAL_S-t*(Qt.MIN_INTERVAL_S-Qt.SEVERE_MIN_INTERVAL_S),maxS:Qt.MAX_INTERVAL_S-t*(Qt.MAX_INTERVAL_S-Qt.SEVERE_MAX_INTERVAL_S)}}static brightnessAt(e,t){let i=0;for(const n of e.strokes){const s=t-e.t-n.offsetMs;s<0||s>Qt.STROKE_DECAY_MS*6||(i+=n.intensity*Math.exp(-s/Qt.STROKE_DECAY_MS))}return Math.min(1,i)}static endOf(e){const t=e.strokes[e.strokes.length-1];return e.t+t.offsetMs+Qt.STROKE_DECAY_MS*6}static thunderDelayMs(e){return e.distanceM/Qt.SOUND_SPEED_M_S*1e3}}class Oi{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Oi.ANCHOR_BLUE-Oi.ANCHOR_RED)/(1/(Oi.BLUE_NM*Oi.BLUE_NM)-1/(Oi.RED_NM*Oi.RED_NM));static A=Oi.ANCHOR_RED-Oi.B/(Oi.RED_NM*Oi.RED_NM);static indexAt(e){return Oi.A+Oi.B/(e*e)}}class Lo{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(e,t,i,n,s,a){let o=0,l=0,c=0;Math.abs(i)<.9?(o=-t,l=e,c=0):(o=0,l=-i,c=t);const h=Math.hypot(o,l,c)||1;o/=h,l/=h,c/=h;const d=t*c-i*l,u=i*o-e*c,f=e*l-t*o,p=s/2,v=a/2;for(let m=0;m<6;m++){const g=n+m*Math.PI/3,x=Math.cos(g),M=Math.sin(g);this.normals[m*3]=o*x+d*M,this.normals[m*3+1]=l*x+u*M,this.normals[m*3+2]=c*x+f*M,this.offsets[m]=p}this.normals[18]=e,this.normals[19]=t,this.normals[20]=i,this.offsets[6]=v,this.normals[21]=-e,this.normals[22]=-t,this.normals[23]=-i,this.offsets[7]=v,this.radius=Math.hypot(p,v)}get aimRadius(){return this.radius}trace(e,t,i,n,s,a,o){let l=-t,c=e,h=0,d=Math.hypot(l,c,h);d<1e-6&&(l=1,c=0,h=0,d=1),l/=d,c/=d,h/=d;const u=t*h-i*c,f=i*l-e*h,p=e*c-t*l,v=l*n+u*s-e*this.radius*2,m=c*n+f*s-t*this.radius*2,g=h*n+p*s-i*this.radius*2;let x=-1,M=-1/0,w=1/0;for(let $=0;$<8;$++){const ie=this.normals[$*3],ae=this.normals[$*3+1],Ve=this.normals[$*3+2],je=ie*e+ae*t+Ve*i,He=this.offsets[$]-(ie*v+ae*m+Ve*g);if(je>1e-9){const K=He/je;K<w&&(w=K)}else if(je<-1e-9){const K=He/je;K>M&&(M=K,x=$)}else if(He<0)return 0}if(x<0||M>=w)return 0;let S=0;const _=this.normals[x*3],D=this.normals[x*3+1],y=this.normals[x*3+2],T=-(_*e+D*t+y*i),A=bc.reflectance(T,1,a);o[S].x=e+2*T*_,o[S].y=t+2*T*D,o[S].z=i+2*T*y,o[S].weight=A,S++;const I=1/a,R=Math.sqrt(Math.max(0,1-I*I*(1-T*T)));let k=I*e+(I*T-R)*_,z=I*t+(I*T-R)*D,L=I*i+(I*T-R)*y,B=v+e*M,F=m+t*M,V=g+i*M,j=1-A;for(let $=0;$<Lo.MAX_BOUNCES&&j>Lo.MIN_WEIGHT;$++){let ie=-1,ae=1/0;for(let G=0;G<8;G++){const Ee=this.normals[G*3],Pe=this.normals[G*3+1],Ie=this.normals[G*3+2],be=Ee*k+Pe*z+Ie*L;if(be<=1e-9)continue;const ke=(this.offsets[G]-(Ee*B+Pe*F+Ie*V))/be;ke>1e-9&&ke<ae&&(ae=ke,ie=G)}if(ie<0)break;const Ve=this.normals[ie*3],je=this.normals[ie*3+1],He=this.normals[ie*3+2],K=Ve*k+je*z+He*L,re=a*Math.sqrt(Math.max(0,1-K*K));if(B+=k*ae,F+=z*ae,V+=L*ae,re<1){const G=Math.sqrt(Math.max(0,1-re*re)),Ee=bc.reflectance(K,a,1);if(o[S].x=a*k-(a*K-G)*Ve,o[S].y=a*z-(a*K-G)*je,o[S].z=a*L-(a*K-G)*He,o[S].weight=j*(1-Ee),S++,S>=o.length)return S;j*=Ee}const ne=2*K;k-=ne*Ve,z-=ne*je,L-=ne*He}return S}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Rt{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 Lo;emergent=Array.from({length:Lo.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(Rt.AZIMUTH_BINS*Rt.ALTITUDE_BINS*3);radiance=new Float32Array(Rt.AZIMUTH_BINS*Rt.ALTITUDE_BINS*3);scratch=new Float32Array(Rt.AZIMUTH_BINS*Rt.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(e,t,i=2654435769){this.seed=i>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=e*Math.PI/180,this.alignment=Math.min(1,Math.max(0,t));const n=Rt.WORST_TILT_DEG*(Rt.BEST_TILT_DEG/Rt.WORST_TILT_DEG)**this.alignment;this.tilt=n*Math.PI/180}trace(e){const t=Rt.AZIMUTH_BINS,i=Rt.ALTITUDE_BINS,n=this.tally,s=Rt.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(Rt.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let l=0;l<e;l++){const c=this.pickPopulation();this.orient(c,this.tilt);const h=this.random()*2*Math.PI,d=s*Math.sqrt(this.random()),u=o+d*Math.sin(h),f=d*Math.cos(h)/Math.max(.05,Math.cos(o)),p=-Math.cos(u)*Math.cos(f),v=-Math.cos(u)*Math.sin(f),m=-Math.sin(u),g=this.crystal.aimRadius,x=(this.random()*2-1)*g,M=(this.random()*2-1)*g,w=4*g*g,S=pi.SAMPLES[this.random()*pi.SAMPLES.length|0],_=this.crystal.trace(p,v,m,x,M,Oi.indexAt(S.wavelengthNm),this.emergent);for(let D=0;D<_;D++){const y=this.emergent[D],T=Math.hypot(y.x,y.y,y.z);if(T<1e-9||y.weight<=0)continue;const A=y.x/T,I=y.y/T,R=y.z/T;if(A*p+I*v+R*m>a)continue;const k=Math.asin(Math.max(-1,Math.min(1,-R))),z=Math.abs(Math.atan2(-I,-A)),L=Math.min(t-1,z/Math.PI*t|0),F=(Math.min(i-1,(k+Math.PI/2)/Math.PI*i|0)*t+L)*3,V=y.weight*w*pi.SAMPLES.length;n[F]+=V*S.r,n[F+1]+=V*S.g,n[F+2]+=V*S.b}}this.traced+=e}get tracedRays(){return this.traced}harvest(){const e=Rt.AZIMUTH_BINS,t=Rt.ALTITUDE_BINS;return this.toRadiance(e,t),this.smooth(e,t),{width:e,height:t,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(e,t,i,n){return this.begin(e,t,n),this.trace(i),this.harvest()}toRadiance(e,t){const i=2*Math.PI/e,n=Math.max(1,this.traced),s=4*Rt.REFERENCE_MICRONS*Rt.REFERENCE_MICRONS;for(let a=0;a<t;a++){const o=Math.sin(a/t*Math.PI-Math.PI/2),l=Math.sin((a+1)/t*Math.PI-Math.PI/2),c=1/(i*(l-o)*n*s);for(let h=0;h<e;h++){const d=(a*e+h)*3;this.radiance[d]=this.tally[d]*c,this.radiance[d+1]=this.tally[d+1]*c,this.radiance[d+2]=this.tally[d+2]*c}}}static REFERENCE_MICRONS=50;smooth(e,t){const i=this.scratch,n=this.radiance;i.set(n);for(let a=0;a<t;a++){const o=a*e*3;for(let l=0;l<3;l++){let c=i[o+l];for(let h=0;h<e;h++){const d=o+h*3+l,u=h+1<e?i[d+3]:i[d];n[d]=(c+2*i[d]+u)/4,c=i[d]}}}i.set(n);const s=e*3;for(let a=0;a<t;a++){const o=a>0?-s:0,l=a+1<t?s:0,c=a*s;for(let h=c;h<c+s;h++)n[h]=(i[h+o]+2*i[h]+i[h+l])/4}}pickPopulation(){const e=this.random();let t=0;for(const i of Rt.POPULATIONS)if(t+=i.share,e<=t)return i;return Rt.POPULATIONS[Rt.POPULATIONS.length-1]}orient(e,t){const i=this.random()*2*Math.PI;let n=this.random()*2*Math.PI,s=0,a=0,o=1;switch(e.orientation){case"tumbling":{o=this.random()*2-1;const l=Math.sqrt(Math.max(0,1-o*o));s=l*Math.cos(i),a=l*Math.sin(i);break}case"plate":{o=this.spreadAboutAnAxis(t);const l=Math.sqrt(Math.max(0,1-o*o));s=l*Math.cos(i),a=l*Math.sin(i);break}case"column":case"parry":{o=this.spreadAboutAPlane(t);const l=Math.sqrt(Math.max(0,1-o*o));s=l*Math.cos(i),a=l*Math.sin(i),e.orientation==="parry"&&(n=Math.PI/2+this.gaussian()*t);break}}this.crystal.set(s,a,o,n,e.widthMicrons,e.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let e=this.seed;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}spreadAboutAnAxis(e){const t=1/Math.max(1e-6,e*e),i=Math.max(1e-12,this.random()),n=1+Math.log(i+(1-i)*Math.exp(-2*t))/t;return Math.max(-1,Math.min(1,n))}spreadAboutAPlane(e){for(let t=0;t<8;t++){const i=this.gaussian()*e;if(i>=-1&&i<=1)return i}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const e=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),t=2*Math.PI*this.random();return this.spare=e*Math.sin(t),this.hasSpare=!0,e*Math.cos(t)}}class Cn{static RADIUS=880;static RAYS=9e5;static RAYS_PER_FRAME=4e3;static FIRST_GLIMPSE_RAYS=5e4;static ALTITUDE_STEP_DEG=1;static GAIN=.55;setCloudOffset(e){this.material.uniforms.uFieldOffset.value.copy(e)}object;material;sky=new Rt;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=Cn.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const e=Rt.AZIMUTH_BINS,t=Rt.ALTITUDE_BINS;this.texels=new Uint16Array(e*t*4),this.texture=new Mr(this.texels,e,t,Ti,ui),this.texture.minFilter=vt,this.texture.magFilter=vt,this.texture.wrapS=Ri,this.texture.wrapT=Ri,this.texture.needsUpdate=!0,this.material=new Ot({uniforms:{uSource:{value:new P(0,1,0)},uUp:{value:new P(0,1,0)},uStrength:{value:0},uTint:{value:new P(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uFieldOffset:{value:new P},uMap:{value:this.texture},uGain:{value:Cn.GAIN}},vertexShader:`
7452
+ `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new We(new wn(2,2),this.material))}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height)}setLens(e,t,i,n){const s=this.material.uniforms;s.uApertureMm2.value=e*e/Math.max(.1,t),s.uFocusDistance.value=Math.max(0,i),s.uFocalLengthMm.value=e,s.uPixelsPerMm.value=this.height/Math.max(.1,n)}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}render(e,t,i,n){const s=this.material.uniforms;s.uNear.value=i.near,s.uFar.value=i.far;const a=e.getRenderTarget();e.setRenderTarget(this.target),e.clear(),e.render(t,i),n?.(),e.setRenderTarget(a),e.render(this.quadScene,this.quadCamera)}dispose(){this.target.depthTexture?.dispose(),this.target.dispose(),this.material.dispose()}}class Dt{static MIN_RATIO=1;static STEP=.25;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(e,t){this.maxRatio=Dt.clamp(e),this.ratio=this.maxRatio,this.timer=t?Tc.create(t):void 0}get pixelRatio(){return this.ratio}get timesGpu(){return this.timer!==void 0}set maximum(e){this.maxRatio=Dt.clamp(e),this.ratio>this.maxRatio&&(this.ratio=this.maxRatio)}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(e,t){const i=this.timer?.poll();if(!(this.timer&&i===void 0))return i!==void 0?this.followGpu(e,i):this.followIntervals(e,t)}followGpu(e,t){if(t>Dt.GPU_LATE_MS)return this.lower(e,Dt.LOWER_COOLDOWN_MS);if(t<Dt.GPU_ROOM_MS)return this.raise(e,Dt.RAISE_COOLDOWN_MS)}followIntervals(e,t){if(!(t>0)||t>1e3)return;this.intervalMs=this.intervalMs===void 0?t:this.intervalMs*.9+t*.1;const i=this.intervalMs>Dt.INTERVAL_LATE_MS;if(this.probe){if(i)return this.ratio=this.probe.ratioBefore,this.probe=void 0,this.lastChangeMs=e,this.nextProbeMs=e+Dt.PROBE_BACKOFF_MS,this.ratio;e-this.probe.sinceMs>=Dt.PROBE_WATCH_MS&&(this.probe=void 0,this.nextProbeMs=e+Dt.PROBE_EVERY_MS);return}if(i){const n=this.lower(e,Dt.LOWER_COOLDOWN_MS);return n!==void 0&&(this.nextProbeMs=e+Dt.PROBE_EVERY_MS),n}if(this.ratio<this.maxRatio&&e>=this.nextProbeMs&&e-this.lastChangeMs>=Dt.RAISE_COOLDOWN_MS){const n=this.ratio,s=this.raise(e,0);return s!==void 0&&(this.probe={sinceMs:e,ratioBefore:n}),s}}lower(e,t){if(!(this.ratio<=Dt.MIN_RATIO||e-this.lastChangeMs<t))return this.ratio=Dt.clamp(this.ratio-Dt.STEP),this.lastChangeMs=e,this.ratio}raise(e,t){if(!(this.ratio>=this.maxRatio||e-this.lastChangeMs<t))return this.ratio=Math.min(this.maxRatio,Dt.clamp(this.ratio+Dt.STEP)),this.lastChangeMs=e,this.ratio}static clamp(e){return Number.isFinite(e)?Math.max(Dt.MIN_RATIO,Math.round(e/Dt.STEP)*Dt.STEP):Dt.MIN_RATIO}}class Tc{constructor(e,t){this.gl=e,this.extension=t}static IN_FLIGHT_MAX=8;static create(e){if(!(e instanceof WebGL2RenderingContext))return;const t=e.getExtension("EXT_disjoint_timer_query_webgl2");return t?new Tc(e,t):void 0}pending=[];active;smoothedMs;begin(){if(!(this.active||this.pending.length>=Tc.IN_FLIGHT_MAX))try{const e=this.gl.createQuery();if(!e)return;this.gl.beginQuery(this.extension.TIME_ELAPSED_EXT,e),this.active=e}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 e=this.gl;try{for(let t=0;t<this.pending.length;t++){const i=this.pending[t];if(!e.getQueryParameter(i,e.QUERY_RESULT_AVAILABLE))continue;if(!e.getParameter(this.extension.GPU_DISJOINT_EXT)){const s=e.getQueryParameter(i,e.QUERY_RESULT)/1e6;this.smoothedMs=this.smoothedMs===void 0?s:this.smoothedMs*.8+s*.2}e.deleteQuery(i),this.pending.splice(t,1),t--}}catch{this.pending.length=0}return this.smoothedMs}reset(){this.smoothedMs=void 0}}class et{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 e=et.ICE_INDEX_RED,t=Math.sqrt((4-e*e)/3);return Math.asin(Math.min(1,t))*180/Math.PI}static minimumDeviationDeg(e,t){const i=e*Math.PI/180,n=t*Math.sin(i/2);return n>1?Number.NaN:(2*Math.asin(n)-i)*180/Math.PI}static effectiveIndex(e,t){const i=t*Math.PI/180,n=Math.cos(i);return n<=0?Number.POSITIVE_INFINITY:Math.sqrt(e*e-Math.sin(i)**2)/n}static parheliaAzimuthDeg(e,t=et.ICE_INDEX_RED){const i=et.minimumDeviationDeg(et.SIDE_PRISM_ANGLE_DEG,et.effectiveIndex(t,e));return Number.isFinite(i)?i:void 0}static parheliaDistanceDeg(e,t=et.ICE_INDEX_RED){const i=et.parheliaAzimuthDeg(e,t);if(i===void 0)return;const n=e*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 e=et.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(e*e-1)))*180/Math.PI}static circumzenithalAltitudeDeg(e,t=et.ICE_INDEX_RED){if(e<0||e>90-et.PLATE_END_FACE_LIMIT_DEG)return;const i=Math.cos(e*Math.PI/180),n=Math.sqrt(t*t-i*i);if(!(n>=1))return Math.asin(n)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(e){return Math.acos(6371e3/(6371e3+Math.max(0,e)))*180/Math.PI}static halo22(){return et.ringOf("halo22",et.SIDE_PRISM_ANGLE_DEG)}static halo46(){return et.ringOf("halo46",et.END_PRISM_ANGLE_DEG)}static ringOf(e,t){const i=et.minimumDeviationDeg(t,et.ICE_INDEX_RED),n=et.minimumDeviationDeg(t,et.ICE_INDEX_BLUE);return{id:e,angleDeg:(i+n)/2,redAngleDeg:i,blueAngleDeg:n}}static strength(e,t,i=90,n=0){const s=Math.max(0,Math.min(1,e)),a=Math.max(0,1-Math.max(0,Math.min(1,t))),o=i>=0?1:n<=0?0:Math.max(0,1+i/n);return s*a*o}static formsAt(e,t=0){if(e<=-t)return[];const i=[et.halo22(),et.halo46()],n=e>0?et.parheliaDistanceDeg(e):void 0;n!==void 0&&i.push({id:"parhelia",angleDeg:n,redAngleDeg:n,blueAngleDeg:et.parheliaDistanceDeg(e,et.ICE_INDEX_BLUE)}),i.push({id:"tangentArc",angleDeg:et.halo22().angleDeg}),e>0&&i.push({id:"parhelicCircle",angleDeg:e});const s=et.circumzenithalAltitudeDeg(e);return s!==void 0&&i.push({id:"circumzenithal",angleDeg:s}),e>et.PLATE_END_FACE_LIMIT_DEG&&i.push({id:"circumhorizontal"}),e<et.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&i.push({id:"pillar"}),i}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class fi{static get WATER_INDEX_RED(){return ai.indexAt(ai.RED_NM)}static get WATER_INDEX_BLUE(){return ai.indexAt(ai.BLUE_NM)}static radiusDeg(e,t){const i=(t*t-1)/(e*e-1);if(i<0||i>1)return Number.NaN;const n=Math.acos(Math.sqrt(i)),s=Math.asin(Math.sin(n)/t),a=2*(n-s)+(e-1)*(Math.PI-2*s),o=2*Math.PI;let l=a%o;return l<0&&(l+=o),l>Math.PI&&(l=o-l),180-l*180/Math.PI}static primary(){return fi.bowOf("primary",2,0)}static secondary(){return fi.bowOf("secondary",3,0)}static bowOf(e,t,i){const n=fi.radiusDeg(t,fi.WATER_INDEX_RED),s=fi.radiusDeg(t,fi.WATER_INDEX_BLUE),a=(n+s)/2;return{id:e,radiusDeg:a,redRadiusDeg:n,violetRadiusDeg:s,topAltitudeDeg:a-i}}static alexandersBandDeg(){return{fromDeg:fi.primary().redRadiusDeg,toDeg:fi.secondary().redRadiusDeg}}static formsAt(e){return e<0?[]:[fi.bowOf("primary",2,e),fi.bowOf("secondary",3,e)].filter(t=>t.topAltitudeDeg>0)}static FULL_MOON_MAGNITUDE=-12.7;static moonlightShare(e){return Math.min(1,10**(-.4*(e-fi.FULL_MOON_MAGNITUDE)))}static strength(e,t,i){if(i<=0)return 0;const n=Math.max(0,Math.min(1,e)),s=Math.max(0,1-Math.max(0,Math.min(1,t)));return n*s}}class qi{constructor(e){this.radius=e;const t=qi.SEGMENTS*qi.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const i=new Tt;i.setAttribute("position",new ht(this.positions,3)),i.setAttribute("color",new ht(this.colors,3)),i.setDrawRange(0,0),this.object=new We(i,new rn({vertexColors:!0,transparent:!0,blending:Zi,depthWrite:!1,fog:!1,side:pn})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=qi.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(qi.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(e,t,i){this.head=e&&oi(e.altitudeDeg,e.azimuthDeg,1),this.tip=t&&oi(t.altitudeDeg,t.azimuthDeg,1),this.brightness=i,this.rebuild()}rebuild(){const e=this.object.geometry,t=this.head,i=this.tip;if(!t||!i||this.brightness<=0){e.setDrawRange(0,0);return}const n=this.angleBetween(t,i);if(n<=0){e.setDrawRange(0,0);return}const s=n*qi.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(t,i,h),this.radius),o=h=>this.radius*(qi.HEAD_HALF_WIDTH_DEG*Math.PI/180+s*h),l=h=>this.brightness*(1-h)**qi.FADE_POWER;let c=0;for(let h=1;h<qi.POINTS;h++){const d=(h-1)/qi.SEGMENTS,u=h/qi.SEGMENTS;c=this.pushBand(c,a(d),a(u),o(d),o(u),l(d),l(u))}e.setDrawRange(0,c),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,i,n,s,a,o){const l=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(i,t))));for(let c=0;c<qi.ACROSS-1;c++){const h=c-1,d=c,u=this.across(t,l,n,h),f=this.across(i,l,s,h),p=this.across(t,l,n,d),v=this.across(i,l,s,d),m=(g,x)=>g===0?x:0;e=this.push(e,u,m(h,a)),e=this.push(e,f,m(h,o)),e=this.push(e,p,m(d,a)),e=this.push(e,f,m(h,o)),e=this.push(e,v,m(d,o)),e=this.push(e,p,m(d,a))}return e}across(e,t,i,n){return{x:e.x+t.x*i*n,y:e.y+t.y*i*n,z:e.z+t.z*i*n}}push(e,t,i){const n=e*3;this.positions[n]=t.x,this.positions[n+1]=t.y,this.positions[n+2]=t.z;const s=Math.max(0,Math.min(1,i));return this.colors[n]=s*.55,this.colors[n+1]=s*.75,this.colors[n+2]=s,e+1}slerp(e,t,i){const n=this.angleBetweenRadians(e,t);if(n<1e-9)return e;const s=Math.sin(n),a=Math.sin((1-i)*n)/s,o=Math.sin(i*n)/s;return{x:e.x*a+t.x*o,y:e.y*a+t.y*o,z:e.z*a+t.z*o}}angleBetween(e,t){return this.angleBetweenRadians(e,t)*180/Math.PI}angleBetweenRadians(e,t){const i=e.x*t.x+e.y*t.y+e.z*t.z;return Math.acos(Math.min(1,Math.max(-1,i)))}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class R_{object=new ci;radius;tiers;drawn=[];constructor(e){this.radius=e,this.object.name="satellites",this.tiers=vf.map(t=>{const i=new hf({vertexColors:!0,size:t.size,sizeAttenuation:!1,fog:!1});Ls.apply(i);const n=new vo(new Tt,i);return n.frustumCulled=!1,this.object.add(n),n})}set(e,t,i){const n=this.tiers.map(()=>[]);this.drawn=[];for(const s of e){const a=i(s.position);if(a<=0)continue;const o=s.magnitude-2.5*Math.log10(a);if(o>t)continue;const l=lo(o,t),c=u1(l),{x:h,y:d,z:u}=oi(s.position.altitudeDeg,s.position.azimuthDeg,this.radius),f=Is(s.position.altitudeDeg),p=co(l);n[c].push({x:h,y:d,z:u,r:p*f[0],g:p*f[1],b:p*f[2]}),this.drawn.push({satellite:s,direction:new P(h,d,u).normalize()})}this.tiers.forEach((s,a)=>{const o=n[a],l=new Float32Array(o.length*3),c=new Float32Array(o.length*3);o.forEach((d,u)=>{l.set([d.x,d.y,d.z],u*3),c.set([d.r,d.g,d.b],u*3)}),s.geometry.dispose();const h=new Tt;h.setAttribute("position",new ht(l,3)),h.setAttribute("color",new ht(c,3)),s.geometry=h})}get count(){return this.drawn.length}nearest(e,t){let i,n=t;for(const s of this.drawn){const a=s.direction.dot(e);a>n&&(n=a,i=s.satellite)}return i}dispose(){for(const e of this.tiers)e.geometry.dispose(),e.material.dispose();this.object.removeFromParent(),this.drawn=[]}}class Hc{constructor(e){this.state=e}next(){this.state=this.state+1831565813|0;let e=this.state;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}between(e,t){return e+this.next()*(t-e)}}class pr{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(e){const{ratePerHour:t,durationMs:i,velocityKmS:n,seed:s}=e;if(t<=0||i<=0)return[];const a=t*i/36e5,o=new Hc(s),l=Math.floor(a),c=l+(o.next()<a-l?1:0),h=[];for(let d=0;d<c;d++){const u=Math.min(1,Math.max(0,(n-20)/52)),f=pr.MAX_DURATION_MS-u*(pr.MAX_DURATION_MS-pr.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+u),brightness:o.next()**3}),h.sort((v,m)=>v.t-m.t)}return h}static aliveAt(e,t){return e.filter(i=>t>=i.t&&t<=i.t+i.durationMs).map(i=>({meteor:i,progress:(t-i.t)/i.durationMs}))}}class ca{object=new ci;radius;core;glow;flashKey;static CORE_WIDTH_DEG=.06;static GLOW_WIDTH_DEG=.5;static SEGMENTS=28;constructor(e){this.radius=e,this.object.name="lightning-bolt",this.core=new rn({color:15659775,transparent:!0,opacity:0,blending:Zi,depthWrite:!1,fog:!1}),this.glow=new rn({color:10466559,transparent:!0,opacity:0,blending:Zi,depthWrite:!1,fog:!1}),this.object.visible=!1,this.object.renderOrder=5.95}set(e,t,i){if(!e||!e.cloudToGround||t<=.01){this.object.visible=!1;return}const n=`${e.channelSeed}:${Math.round(i)}`;n!==this.flashKey&&this.build(e,i,n),this.core.opacity=Math.min(1,t*1.4),this.glow.opacity=t*.35,this.object.visible=!0}build(e,t,i){this.flashKey=i;for(const c of[...this.object.children])c.geometry.dispose(),this.object.remove(c);const n=new Hc(e.channelSeed),s=Math.atan2(t,e.distanceM)*180/Math.PI,a=this.channel(n,e.azimuthDeg,s,0,1),o=[a],l=1+Math.floor(n.next()*2);for(let c=0;c<l;c++){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 c of o)this.object.add(new We(this.ribbon(c,ca.GLOW_WIDTH_DEG),this.glow)),this.object.add(new We(this.ribbon(c,ca.CORE_WIDTH_DEG),this.core))}channel(e,t,i,n,s){const a=[],o=i-n;let l=t;for(let c=0;c<=ca.SEGMENTS;c++){const h=i-o*c/ca.SEGMENTS;a.push({azimuthDeg:l,altitudeDeg:h}),l+=e.between(-1,1)*o*.06*s}return a}ribbon(e,t){const i=new Float32Array(e.length*2*3),n=[],s=this.radius*Math.tan(t*Math.PI/180)/2,a=e.map(l=>{const{x:c,y:h,z:d}=oi(l.altitudeDeg,l.azimuthDeg,this.radius);return new P(c,h,d)});a.forEach((l,c)=>{const h=a[Math.min(c+1,a.length-1)],d=a[Math.max(c-1,0)],f=h.clone().sub(d).normalize().cross(l.clone().normalize()).normalize().multiplyScalar(s);if(i.set([l.x+f.x,l.y+f.y,l.z+f.z],c*6),i.set([l.x-f.x,l.y-f.y,l.z-f.z],c*6+3),c<a.length-1){const p=c*2;n.push(p,p+1,p+2,p+1,p+3,p+2)}});const o=new Tt;return o.setAttribute("position",new ht(i,3)),o.setIndex(n),o}dispose(){for(const e of this.object.children)e.geometry.dispose();this.core.dispose(),this.glow.dispose(),this.object.removeFromParent()}}class Qt{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(e){const t=new Hc(e.seed),i=[],{minS:n,maxS:s}=Qt.intervalFor(e.intensity??.5);let a=t.between(0,s)*1e3;for(;a<e.durationMs;){const o=t.next()<Qt.CLOUD_TO_GROUND_FRACTION,l=Qt.MIN_DISTANCE_M,c=Qt.MAX_DISTANCE_M,h=Math.sqrt(t.between(l*l,c*c)),d=o?1+Math.floor(t.next()*4):1,u=[];let f=0;for(let p=0;p<d;p++)u.push({offsetMs:f,intensity:p===0?1:t.between(.4,.9)}),f+=Qt.INTERSTROKE_MS*t.between(.5,1.6);i.push({t:a,azimuthDeg:t.between(0,360),distanceM:h,cloudToGround:o,strokes:u,channelSeed:Math.floor(t.next()*2**31)}),a+=t.between(n,s)*1e3}return i}static intervalFor(e){const t=Math.min(1,Math.max(0,(e-.5)/.5));return{minS:Qt.MIN_INTERVAL_S-t*(Qt.MIN_INTERVAL_S-Qt.SEVERE_MIN_INTERVAL_S),maxS:Qt.MAX_INTERVAL_S-t*(Qt.MAX_INTERVAL_S-Qt.SEVERE_MAX_INTERVAL_S)}}static brightnessAt(e,t){let i=0;for(const n of e.strokes){const s=t-e.t-n.offsetMs;s<0||s>Qt.STROKE_DECAY_MS*6||(i+=n.intensity*Math.exp(-s/Qt.STROKE_DECAY_MS))}return Math.min(1,i)}static endOf(e){const t=e.strokes[e.strokes.length-1];return e.t+t.offsetMs+Qt.STROKE_DECAY_MS*6}static thunderDelayMs(e){return e.distanceM/Qt.SOUND_SPEED_M_S*1e3}}class Oi{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Oi.ANCHOR_BLUE-Oi.ANCHOR_RED)/(1/(Oi.BLUE_NM*Oi.BLUE_NM)-1/(Oi.RED_NM*Oi.RED_NM));static A=Oi.ANCHOR_RED-Oi.B/(Oi.RED_NM*Oi.RED_NM);static indexAt(e){return Oi.A+Oi.B/(e*e)}}class Lo{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(e,t,i,n,s,a){let o=0,l=0,c=0;Math.abs(i)<.9?(o=-t,l=e,c=0):(o=0,l=-i,c=t);const h=Math.hypot(o,l,c)||1;o/=h,l/=h,c/=h;const d=t*c-i*l,u=i*o-e*c,f=e*l-t*o,p=s/2,v=a/2;for(let m=0;m<6;m++){const g=n+m*Math.PI/3,x=Math.cos(g),M=Math.sin(g);this.normals[m*3]=o*x+d*M,this.normals[m*3+1]=l*x+u*M,this.normals[m*3+2]=c*x+f*M,this.offsets[m]=p}this.normals[18]=e,this.normals[19]=t,this.normals[20]=i,this.offsets[6]=v,this.normals[21]=-e,this.normals[22]=-t,this.normals[23]=-i,this.offsets[7]=v,this.radius=Math.hypot(p,v)}get aimRadius(){return this.radius}trace(e,t,i,n,s,a,o){let l=-t,c=e,h=0,d=Math.hypot(l,c,h);d<1e-6&&(l=1,c=0,h=0,d=1),l/=d,c/=d,h/=d;const u=t*h-i*c,f=i*l-e*h,p=e*c-t*l,v=l*n+u*s-e*this.radius*2,m=c*n+f*s-t*this.radius*2,g=h*n+p*s-i*this.radius*2;let x=-1,M=-1/0,w=1/0;for(let $=0;$<8;$++){const ie=this.normals[$*3],ae=this.normals[$*3+1],Ve=this.normals[$*3+2],je=ie*e+ae*t+Ve*i,Ge=this.offsets[$]-(ie*v+ae*m+Ve*g);if(je>1e-9){const K=Ge/je;K<w&&(w=K)}else if(je<-1e-9){const K=Ge/je;K>M&&(M=K,x=$)}else if(Ge<0)return 0}if(x<0||M>=w)return 0;let S=0;const _=this.normals[x*3],D=this.normals[x*3+1],y=this.normals[x*3+2],T=-(_*e+D*t+y*i),A=bc.reflectance(T,1,a);o[S].x=e+2*T*_,o[S].y=t+2*T*D,o[S].z=i+2*T*y,o[S].weight=A,S++;const I=1/a,R=Math.sqrt(Math.max(0,1-I*I*(1-T*T)));let k=I*e+(I*T-R)*_,z=I*t+(I*T-R)*D,L=I*i+(I*T-R)*y,B=v+e*M,F=m+t*M,V=g+i*M,j=1-A;for(let $=0;$<Lo.MAX_BOUNCES&&j>Lo.MIN_WEIGHT;$++){let ie=-1,ae=1/0;for(let G=0;G<8;G++){const Ee=this.normals[G*3],Pe=this.normals[G*3+1],Ie=this.normals[G*3+2],be=Ee*k+Pe*z+Ie*L;if(be<=1e-9)continue;const ke=(this.offsets[G]-(Ee*B+Pe*F+Ie*V))/be;ke>1e-9&&ke<ae&&(ae=ke,ie=G)}if(ie<0)break;const Ve=this.normals[ie*3],je=this.normals[ie*3+1],Ge=this.normals[ie*3+2],K=Ve*k+je*z+Ge*L,re=a*Math.sqrt(Math.max(0,1-K*K));if(B+=k*ae,F+=z*ae,V+=L*ae,re<1){const G=Math.sqrt(Math.max(0,1-re*re)),Ee=bc.reflectance(K,a,1);if(o[S].x=a*k-(a*K-G)*Ve,o[S].y=a*z-(a*K-G)*je,o[S].z=a*L-(a*K-G)*Ge,o[S].weight=j*(1-Ee),S++,S>=o.length)return S;j*=Ee}const ne=2*K;k-=ne*Ve,z-=ne*je,L-=ne*Ge}return S}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Rt{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 Lo;emergent=Array.from({length:Lo.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(Rt.AZIMUTH_BINS*Rt.ALTITUDE_BINS*3);radiance=new Float32Array(Rt.AZIMUTH_BINS*Rt.ALTITUDE_BINS*3);scratch=new Float32Array(Rt.AZIMUTH_BINS*Rt.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(e,t,i=2654435769){this.seed=i>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=e*Math.PI/180,this.alignment=Math.min(1,Math.max(0,t));const n=Rt.WORST_TILT_DEG*(Rt.BEST_TILT_DEG/Rt.WORST_TILT_DEG)**this.alignment;this.tilt=n*Math.PI/180}trace(e){const t=Rt.AZIMUTH_BINS,i=Rt.ALTITUDE_BINS,n=this.tally,s=Rt.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(Rt.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let l=0;l<e;l++){const c=this.pickPopulation();this.orient(c,this.tilt);const h=this.random()*2*Math.PI,d=s*Math.sqrt(this.random()),u=o+d*Math.sin(h),f=d*Math.cos(h)/Math.max(.05,Math.cos(o)),p=-Math.cos(u)*Math.cos(f),v=-Math.cos(u)*Math.sin(f),m=-Math.sin(u),g=this.crystal.aimRadius,x=(this.random()*2-1)*g,M=(this.random()*2-1)*g,w=4*g*g,S=pi.SAMPLES[this.random()*pi.SAMPLES.length|0],_=this.crystal.trace(p,v,m,x,M,Oi.indexAt(S.wavelengthNm),this.emergent);for(let D=0;D<_;D++){const y=this.emergent[D],T=Math.hypot(y.x,y.y,y.z);if(T<1e-9||y.weight<=0)continue;const A=y.x/T,I=y.y/T,R=y.z/T;if(A*p+I*v+R*m>a)continue;const k=Math.asin(Math.max(-1,Math.min(1,-R))),z=Math.abs(Math.atan2(-I,-A)),L=Math.min(t-1,z/Math.PI*t|0),F=(Math.min(i-1,(k+Math.PI/2)/Math.PI*i|0)*t+L)*3,V=y.weight*w*pi.SAMPLES.length;n[F]+=V*S.r,n[F+1]+=V*S.g,n[F+2]+=V*S.b}}this.traced+=e}get tracedRays(){return this.traced}harvest(){const e=Rt.AZIMUTH_BINS,t=Rt.ALTITUDE_BINS;return this.toRadiance(e,t),this.smooth(e,t),{width:e,height:t,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(e,t,i,n){return this.begin(e,t,n),this.trace(i),this.harvest()}toRadiance(e,t){const i=2*Math.PI/e,n=Math.max(1,this.traced),s=4*Rt.REFERENCE_MICRONS*Rt.REFERENCE_MICRONS;for(let a=0;a<t;a++){const o=Math.sin(a/t*Math.PI-Math.PI/2),l=Math.sin((a+1)/t*Math.PI-Math.PI/2),c=1/(i*(l-o)*n*s);for(let h=0;h<e;h++){const d=(a*e+h)*3;this.radiance[d]=this.tally[d]*c,this.radiance[d+1]=this.tally[d+1]*c,this.radiance[d+2]=this.tally[d+2]*c}}}static REFERENCE_MICRONS=50;smooth(e,t){const i=this.scratch,n=this.radiance;i.set(n);for(let a=0;a<t;a++){const o=a*e*3;for(let l=0;l<3;l++){let c=i[o+l];for(let h=0;h<e;h++){const d=o+h*3+l,u=h+1<e?i[d+3]:i[d];n[d]=(c+2*i[d]+u)/4,c=i[d]}}}i.set(n);const s=e*3;for(let a=0;a<t;a++){const o=a>0?-s:0,l=a+1<t?s:0,c=a*s;for(let h=c;h<c+s;h++)n[h]=(i[h+o]+2*i[h]+i[h+l])/4}}pickPopulation(){const e=this.random();let t=0;for(const i of Rt.POPULATIONS)if(t+=i.share,e<=t)return i;return Rt.POPULATIONS[Rt.POPULATIONS.length-1]}orient(e,t){const i=this.random()*2*Math.PI;let n=this.random()*2*Math.PI,s=0,a=0,o=1;switch(e.orientation){case"tumbling":{o=this.random()*2-1;const l=Math.sqrt(Math.max(0,1-o*o));s=l*Math.cos(i),a=l*Math.sin(i);break}case"plate":{o=this.spreadAboutAnAxis(t);const l=Math.sqrt(Math.max(0,1-o*o));s=l*Math.cos(i),a=l*Math.sin(i);break}case"column":case"parry":{o=this.spreadAboutAPlane(t);const l=Math.sqrt(Math.max(0,1-o*o));s=l*Math.cos(i),a=l*Math.sin(i),e.orientation==="parry"&&(n=Math.PI/2+this.gaussian()*t);break}}this.crystal.set(s,a,o,n,e.widthMicrons,e.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let e=this.seed;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}spreadAboutAnAxis(e){const t=1/Math.max(1e-6,e*e),i=Math.max(1e-12,this.random()),n=1+Math.log(i+(1-i)*Math.exp(-2*t))/t;return Math.max(-1,Math.min(1,n))}spreadAboutAPlane(e){for(let t=0;t<8;t++){const i=this.gaussian()*e;if(i>=-1&&i<=1)return i}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const e=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),t=2*Math.PI*this.random();return this.spare=e*Math.sin(t),this.hasSpare=!0,e*Math.cos(t)}}class Cn{static RADIUS=880;static RAYS=9e5;static RAYS_PER_FRAME=4e3;static FIRST_GLIMPSE_RAYS=5e4;static ALTITUDE_STEP_DEG=1;static GAIN=.55;setCloudOffset(e){this.material.uniforms.uFieldOffset.value.copy(e)}object;material;sky=new Rt;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=Cn.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const e=Rt.AZIMUTH_BINS,t=Rt.ALTITUDE_BINS;this.texels=new Uint16Array(e*t*4),this.texture=new Mr(this.texels,e,t,Ti,ui),this.texture.minFilter=vt,this.texture.magFilter=vt,this.texture.wrapS=Ri,this.texture.wrapT=Ri,this.texture.needsUpdate=!0,this.material=new Ot({uniforms:{uSource:{value:new P(0,1,0)},uUp:{value:new P(0,1,0)},uStrength:{value:0},uTint:{value:new P(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uFieldOffset:{value:new P},uMap:{value:this.texture},uGain:{value:Cn.GAIN}},vertexShader:`
7453
7453
  varying vec3 vDirection;
7454
7454
  void main() {
7455
7455
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -7504,7 +7504,7 @@ void main()
7504
7504
  `+n.vertexShader,n.vertexShader=n.vertexShader.replace("#include <project_vertex>",`#include <project_vertex>
7505
7505
  cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let s=`varying vec3 cloudPoint;
7506
7506
  `,a="";t.forEach((o,l)=>{const c=`cloud${l}_`;for(const[h,d]of Object.entries(o.uniforms))n.uniforms[c+h]=d;s+=U3(c),a+=`diffuseColor.a *= ${c}transmissionAt(normalize(cloudPoint), length(cloudPoint));
7507
- `}),n.fragmentShader=s+n.fragmentShader,n.fragmentShader=n.fragmentShader.replace("#include <opaque_fragment>",a+"#include <opaque_fragment>")},e.needsUpdate=!0}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new P;up=new P;lookAt=new Ye;vertex=new P;centre=new P;right=new P;above=new P;set(e,t){this.placed=e,this.frame=t;const i=new Set(e.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 e){let s=this.meshes.get(n.sourceId);s||(s=new We(new wn(1,1,hn.SEGMENTS,hn.SEGMENTS),new rn({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),this.configureCloudMaterial(s.material),s.frustumCulled=!1,s.layers.set(G1),this.scene.add(s),this.meshes.set(n.sourceId,s)),s.renderOrder=Z_+n.renderOrder,s.visible=!n.hidden&&n.shape.transparency<1,s.visible&&this.paint(s,n,t)}}place(e,t,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:l}=s.shape;let c=l.x+l.width/2,h=l.y+l.height/2,d=!0;if(s.aim){const u=i(hn.directionOf(s.aim,this.direction));u&&Math.abs(u.ndcX)<hn.FURTHEST_NDC&&Math.abs(u.ndcY)<hn.FURTHEST_NDC?(c=(u.ndcX+1)/2*n.canvasWidthPx,h=(1-u.ndcY)/2*n.canvasHeightPx):d=!1}d?this.curve(a,e,t,n,o,c,h,s.distanceM):this.flat(a,e,n,o,s.distanceM)}}static FURTHEST_NDC=4;curve(e,t,i,n,s,a,o,l){const c=a-s.width/2,h=o-s.height/2,d=e.geometry.attributes.position,u=hn.SEGMENTS;let f=0;for(let p=0;p<=u;p++){const v=h+p/u*s.height;for(let m=0;m<=u;m++){const g=c+m/u*s.width;i(g/n.canvasWidthPx*2-1,-(v/n.canvasHeightPx*2-1),this.direction),this.vertex.copy(t.position).addScaledVector(this.direction,l),d.setXYZ(f++,this.vertex.x,this.vertex.y,this.vertex.z)}}d.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(it.sizeMAt(l,n.projection.pxToDeg(s.width)),it.sizeMAt(l,n.projection.pxToDeg(s.height)),1)}flat(e,t,i,n,s){const a=e.geometry.attributes.position,o=hn.SEGMENTS,l=it.sizeMAt(s,i.projection.pxToDeg(n.width)),c=it.sizeMAt(s,i.projection.pxToDeg(n.height));this.up.set(0,1,0).applyQuaternion(t.quaternion),this.centre.copy(t.position).addScaledVector(this.direction,s),this.lookAt.lookAt(t.position,this.centre,this.up),this.right.setFromMatrixColumn(this.lookAt,0),this.above.setFromMatrixColumn(this.lookAt,1);let h=0;for(let d=0;d<=o;d++){const u=.5-d/o;for(let f=0;f<=o;f++){const p=f/o-.5;this.vertex.copy(this.centre).addScaledVector(this.right,p*l).addScaledVector(this.above,u*c),a.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}a.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(l,c,1)}static SEGMENTS=16;static directionOf(e,t){const i=e.azimuthDeg*Math.PI/180,n=e.altitudeDeg*Math.PI/180;return t.set(Math.sin(i)*Math.cos(n),Math.sin(n),-Math.cos(i)*Math.cos(n))}get any(){for(const e of this.meshes.values())if(e.visible)return!0;return!1}get furthestM(){return this.placed.reduce((e,t)=>Math.max(e,t.distanceM),0)}paint(e,t,i){const{shape:n}=t,s=To.paintExtent(n);this.extents.set(t.sourceId,s);const a=hn.signatureOf(n,i);if(this.signatures.get(t.sourceId)===a&&e.material.map)return;this.signatures.set(t.sourceId,a);const o=Math.min(i.scale,J_/Math.max(s.width,s.height,1)),l=Math.max(1,Math.ceil(s.width*o)),c=Math.max(1,Math.ceil(s.height*o)),h=e.material.map,d=h?.image??document.createElement("canvas"),u=d.width!==l||d.height!==c;u&&(d.width=l,d.height=c);const f=d.getContext("2d");if(!f)return;f.clearRect(0,0,l,c);const p=new To(f);if(p.setStarPoints(i.starPoints),p.setRoll(i.rollRad),p.paintInto(n,s,o),h&&!u){h.needsUpdate=!0;return}h?.dispose();const v=new Kn(d);v.colorSpace=Bi,v.minFilter=vt,v.generateMipmaps=!1,e.material.map=v,e.material.needsUpdate=!0}static signatureOf(e,t){const{bounds:i}=e;return JSON.stringify([e.kind,Math.round(i.width*10),Math.round(i.height*10),e.color,e.angle,e.transparency,e.haloScale,e.blur??0,e.brightness??0,e.kind==="polygon"?e.points:void 0,t.scale,t.starPoints,t.rollRad])}dispose(e){e.removeFromParent(),e.geometry.dispose(),e.material.map?.dispose(),e.material.dispose()}clear(){for(const e of this.meshes.values())this.dispose(e);this.meshes.clear(),this.signatures.clear(),this.extents.clear(),this.placed=[]}}const V1=3,Ll=800,eo=Math.PI/180;class ar{constructor(e,t,i=ar.fetchImage){this.scene=e,this.onImageLoaded=t,this.loadImage=i}meshes=new Map;signatures=new Map;images=new Map;loading=new Map;failed=new Set;references=[];views=new Map;shown=!0;set(e,t=this.views){this.references=e,this.views=t;const i=new Set(e.map(n=>n.id));for(const[n,s]of this.meshes)i.has(n)||(this.dispose(s),this.meshes.delete(n),this.signatures.delete(n));for(const[n,s]of this.images){const a=e.find(o=>o.id===n);a&&a.src===s.texture.userData.src||(s.texture.dispose(),this.images.delete(n))}for(const n of e){const s=this.images.get(n.id);if(!s){this.load(n);continue}this.build(n,s)}}setShown(e){this.shown=e;for(const t of this.meshes.values())t.visible=e&&this.opacityOf(t.userData.id)>0}setView(e,t){this.views.set(e,t);const i=this.meshes.get(e);i&&this.applyOpacity(i,e)}get any(){for(const e of this.meshes.values())if(e.visible)return!0;return!1}place(e){for(const t of this.meshes.values())t.visible&&(t.position.copy(e.position),t.updateMatrixWorld())}get furthestM(){return this.meshes.size>0?Ll:0}directionOfPixel(e,t,i,n){const s=this.images.get(e.id),a=s?s.width/s.height:1,o=Math.tan(e.registration.fovDeg/2*eo),l=o*a;return n.set((t*2-1)*l,(1-i*2)*o,-1).normalize(),n.applyQuaternion(ar.orientation(e))}aspectOf(e){const t=this.images.get(e);return t?t.width/t.height:void 0}failedToLoad(e){return this.failed.has(e)}load(e){const t=e.src;if(this.loading.has(e.id)||this.failed.has(t))return;const i=this.loadImage(t).then(n=>{this.loading.delete(e.id);const s=this.references.find(a=>a.id===e.id);if(!s||s.src!==t){n.texture.dispose();return}n.texture.userData.src=t,this.images.set(e.id,n),this.build(s,n),this.onImageLoaded()},()=>{this.loading.delete(e.id),this.failed.add(t)});this.loading.set(e.id,i)}static async fetchImage(e){const t=await fetch(e);if(!t.ok)throw new Error(`${e}: ${t.status}`);const i=await createImageBitmap(await t.blob(),{imageOrientation:"flipY"}),n=new di(i);return n.flipY=!1,n.colorSpace=Bi,n.minFilter=vt,n.magFilter=vt,n.generateMipmaps=!1,n.needsUpdate=!0,{texture:n,width:i.width,height:i.height}}build(e,t){const i=ar.signatureOf(e,t);let n=this.meshes.get(e.id);if(n&&this.signatures.get(e.id)===i){this.applyOpacity(n,e.id);return}n&&(this.dispose(n),this.meshes.delete(e.id)),n=new We(ar.geometryOf(e,t),new rn({map:t.texture,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),e.kind==="panorama"&&(n.material.side=Ft),n.frustumCulled=!1,n.layers.set(V1),n.userData.id=e.id,n.quaternion.copy(ar.orientation(e)),this.scene.add(n),this.meshes.set(e.id,n),this.signatures.set(e.id,i),this.applyOpacity(n,e.id)}static geometryOf(e,t){if(e.kind==="panorama"){const a=new yi(Ll,64,32,Math.PI/2,Math.PI*2),o=a.attributes.uv;for(let l=0;l<o.count;l++)o.setX(l,1-o.getX(l));return o.needsUpdate=!0,a}const i=2*Ll*Math.tan(e.registration.fovDeg/2*eo),n=i*(t.width/Math.max(t.height,1)),s=new wn(n,i);return s.translate(0,0,-Ll),s}static orientation(e){const{headingDeg:t,pitchDeg:i,rollDeg:n}=e.registration,s=new _t;return s.rotation.set(i*eo,-t*eo,-(n??0)*eo,"YXZ"),s.quaternion}opacityOf(e){const t=this.references.find(n=>n.id===e);return this.views.get(e)?.opacity??t?.opacity??0}applyOpacity(e,t){const i=this.opacityOf(t);e.material.opacity=i,e.visible=this.shown&&i>0}static signatureOf(e,t){const{headingDeg:i,pitchDeg:n,rollDeg:s,fovDeg:a}=e.registration;return[e.kind,e.src,t.width,t.height,i,n,s??0,a].join("|")}dispose(e){this.scene.remove(e),e.geometry.dispose(),e.material.dispose()}disposeAll(){for(const e of this.meshes.values())this.dispose(e);this.meshes.clear(),this.signatures.clear();for(const e of this.images.values())e.texture.dispose();this.images.clear()}}class Ze{static GROUND_RADIUS_M=636e4;static TOP_RADIUS_M=646e4;static WAVELENGTHS_NM=Array.from({length:15},(e,t)=>410+20*t);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(e={}){const t=Ze.WAVELENGTHS_NM.length,i=e.aerosolOpticalDepth??Ze.DEFAULT_AEROSOL_OPTICAL_DEPTH,n=e.ozoneDobson??Ze.DEFAULT_OZONE_DOBSON;this.rayleighScattering=new Float64Array(t),this.aerosolScattering=new Float64Array(t),this.aerosolExtinction=new Float64Array(t),this.ozoneAbsorption=new Float64Array(t);const s=n*2687e17/Ze.OZONE_HALF_WIDTH_M;for(let a=0;a<t;a++){const o=Ze.WAVELENGTHS_NM[a];this.rayleighScattering[a]=Ze.rayleighAt(o);const l=i/Ze.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosolExtinction[a]=l,this.aerosolScattering[a]=l*Ze.AEROSOL_SINGLE_SCATTERING_ALBEDO,this.ozoneAbsorption[a]=Ze.OZONE_CROSS_SECTION[a]*1e-25*s}}static rayleighAt(e){const t=e/1e3,i=1/(t*t),n=t*t;return(1.0455996-341.29061*i-.9023085*n)/(1+.0027059889*i-85.968563*n)*1e-28*1e-4*2546899e19}static rayleighDensity(e){return Math.exp(-Math.max(e,0)/Ze.RAYLEIGH_SCALE_HEIGHT_M)}static aerosolDensity(e){return Math.exp(-Math.max(e,0)/Ze.AEROSOL_SCALE_HEIGHT_M)}static ozoneDensity(e){return Math.max(0,1-Math.abs(e-Ze.OZONE_PEAK_ALTITUDE_M)/Ze.OZONE_HALF_WIDTH_M)}static rayleighPhase(e){return 3/(16*Math.PI)*(1+e*e)}static aerosolPhase(e,t=Ze.AEROSOL_ASYMMETRY){const i=t*t;return 3/(8*Math.PI)*(1-i)*(1+e*e)/((2+i)*Math.pow(Math.max(1+i-2*t*e,1e-6),1.5))}}class ot{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(e,t){return e*(1/t-1)**(1/ot.RESPONSE_EXPONENT)}static get ADAPTATION_EXPONENT(){const e=ot.anchoredSemiSaturation(ot.DAYLIGHT_ANCHOR_CD_M2,ot.DAYLIGHT_ANCHOR_RESPONSE),t=ot.anchoredSemiSaturation(ot.NIGHT_ANCHOR_CD_M2,ot.NIGHT_ANCHOR_RESPONSE);return Math.log(e/t)/Math.log(ot.DAYLIGHT_ANCHOR_CD_M2/ot.NIGHT_ANCHOR_CD_M2)}static ROD_HALF_LUMINANCE_CD_M2=.04;static SCOTOPIC_TINT=[.853,.995,1.483];static get SEMI_SATURATION_SCALE(){return ot.anchoredSemiSaturation(ot.DAYLIGHT_ANCHOR_CD_M2,ot.DAYLIGHT_ANCHOR_RESPONSE)/ot.DAYLIGHT_ANCHOR_CD_M2**ot.ADAPTATION_EXPONENT}static rodShare(e){return ot.ROD_HALF_LUMINANCE_CD_M2/(ot.ROD_HALF_LUMINANCE_CD_M2+Math.max(e,0))}static semiSaturation(e){return ot.SEMI_SATURATION_SCALE*Math.max(e,1e-9)**ot.ADAPTATION_EXPONENT}static response(e,t){const i=ot.RESPONSE_EXPONENT,n=Math.max(e,0)**i;return n/(n+ot.semiSaturation(t)**i)}static displayOf(e,t,i,n=ot.rodShare(i)){const s=(1-n)*e[1]+n*t,a=ot.response(s,i),[o,l,c]=pi.linearSrgbOf(e),h=Math.max(e[1],1e-12),d=ot.SCOTOPIC_TINT,u=.2126*d[0]+.7152*d[1]+.0722*d[2],f=(p,v)=>Math.max(0,(1-n)*p/h+n*v/u)*a;return[f(o,d[0]),f(l,d[1]),f(c,d[2])]}}class Ge{static TRANSMITTANCE_WIDTH=256;static TRANSMITTANCE_HEIGHT=64;static MULTIPLE_SIZE=64;static MULTIPLE_DIRECTIONS=16;static SKY_VIEW_WIDTH=192;static SKY_VIEW_HEIGHT=108;static STEPS=40;static MULTIPLE_STEPS=20;static GROUND_ALBEDO=.3;supported;renderer;transmittance;multiple;sunView;moonView;scene=new Ca;camera=new Hs(-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(e){this.renderer=e,this.supported=e.capabilities.isWebGL2&&e.extensions.has("EXT_color_buffer_float"),this.transmittance=new vi(Ge.TRANSMITTANCE_WIDTH,Ge.TRANSMITTANCE_HEIGHT,{count:4,type:ui,minFilter:vt,magFilter:vt,depthBuffer:!1}),this.multiple=new vi(Ge.MULTIPLE_SIZE,Ge.MULTIPLE_SIZE,{count:4,type:Pi,minFilter:Nt,magFilter:Nt,depthBuffer:!1});const t=()=>new vi(Ge.SKY_VIEW_WIDTH,Ge.SKY_VIEW_HEIGHT,{type:Pi,minFilter:Nt,magFilter:Nt,depthBuffer:!1});this.sunView=t(),this.moonView=t();const i=Ge.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 $g({glslVersion:uc,uniforms:{...i,...n,...o},vertexShader:Ge.VERTEX,fragmentShader:a,depthTest:!1,depthWrite:!1});this.transmittanceMaterial=s(Ge.TRANSMITTANCE_FRAGMENT),this.multipleMaterial=s(Ge.MULTIPLE_FRAGMENT),this.skyViewMaterial=s(Ge.SKY_VIEW_FRAGMENT,{uObserverRadius:{value:Ze.GROUND_RADIUS_M+2},uSourceMu:{value:1}}),this.quad=new We(new wn(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>=Ge.MULTIPLE_SIZE)}setMedium(e){const t=[e.rayleighScattering,e.aerosolScattering,e.aerosolExtinction,e.ozoneAbsorption].map(n=>Array.from(n,s=>s.toPrecision(6)).join(",")).join("|");if(t===this.mediumKey)return;this.abandonBuilding(),this.releaseAdopted(),this.mediumKey=t;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",e.rayleighScattering),i("uAerosolScattering",e.aerosolScattering),i("uAerosolExtinction",e.aerosolExtinction),i("uOzone",e.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(e){if(!this.supported||!this.mediumKey)return!1;if(this.ready)return!0;const t=Ge.shared.get(this.mediumKey);if(t&&t!=="building")return this.adopt(t),!0;if(t==="building"&&!this.building)return!1;t||(Ge.shared.set(this.mediumKey,"building"),this.building=!0);const i=this.renderer.getRenderTarget();let n=Math.max(1,e);this.transmittanceReady||(this.draw(this.transmittanceMaterial,this.transmittance),this.transmittanceReady=!0,n--);const s=Ge.MULTIPLE_SIZE,a=Ge.MULTIPLE_BLOCK;for(;n>0&&this.multipleRows<s;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(e){this.building=!1;try{const t=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===e?Ge.shared.set(e,{transmittance:t,multiple:i}):Ge.shared.delete(e)}catch{Ge.shared.delete(e)}}async readRaw(e,t,i){const n=new i(e.width*e.height*4);return await this.renderer.readRenderTargetPixelsAsync(e,0,0,e.width,e.height,n,void 0,t),n}adopt(e){const t=(s,a,o,l)=>{const c=new Mr(s,a,o,Ti,l?ui:Pi);return c.minFilter=c.magFilter=l?vt:Nt,c.needsUpdate=!0,c},i=e.transmittance.map(s=>t(s,Ge.TRANSMITTANCE_WIDTH,Ge.TRANSMITTANCE_HEIGHT,!0)),n=e.multiple.map(s=>t(s,Ge.MULTIPLE_SIZE,Ge.MULTIPLE_SIZE,!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 e of this.adopted)e.dispose();this.adopted=void 0;for(let e=0;e<4;e++)this.tableUniforms[`uT${e}`].value=this.transmittance.textures[e],this.tableUniforms[`uM${e}`].value=this.multiple.textures[e]}}abandonBuilding(){this.building&&(this.building=!1,Ge.shared.get(this.mediumKey)==="building"&&Ge.shared.delete(this.mediumKey))}renderSkyViews(e,t,i){if(!this.ready)return;const n=this.renderer.getRenderTarget(),s=this.skyViewMaterial.uniforms;s.uObserverRadius.value=Ze.GROUND_RADIUS_M+Math.max(e,2),s.uSourceMu.value=Math.sin(t*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(e,t,i){const n=Ze.GROUND_RADIUS_M+Math.max(e,2),s=Ze.GROUND_RADIUS_M,a=Math.acos(Math.min(Math.sqrt(Math.max(n*n-s*s,0))/n,1)),o=Math.PI-a,l=t<o?.5*(1-Math.sqrt(Math.max(1-t/o,0))):.5+.5*Math.sqrt(Math.min((t-o)/a,1));return{u:Math.min(Math.max(Math.abs(i)/Math.PI,0),1),v:l}}async readTable(e,t){if(e==="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,t),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,t),Float32Array.from(n,s=>hs.fromHalfFloat(s))}readSkyViewNow(e){const t=e==="sun"?this.sunView:this.moonView,i=new Float32Array(t.width*t.height*4),n=this.renderer.getContext();return n.bindBuffer(n.PIXEL_PACK_BUFFER,null),this.renderer.readRenderTargetPixels(t,0,0,t.width,t.height,i),i}async readSkyView(e){const t=e==="sun"?this.sunView:this.moonView,i=new Float32Array(t.width*t.height*4);return await this.renderer.readRenderTargetPixelsAsync(t,0,0,t.width,t.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(e,t){this.quad.material=e,this.renderer.setRenderTarget(t),this.renderer.render(this.scene,this.camera)}static mediumUniforms(){const e=()=>[new at,new at,new at,new at],t=(i,n)=>{const s=e();return Ze.WAVELENGTHS_NM.forEach((a,o)=>{s[Math.floor(o/4)].setComponent(o%4,i(a)*n*Ze.WAVELENGTH_STEP_NM*Ze.SOLAR_IRRADIANCE[o])}),s};return{uRayleigh:{value:e()},uAerosolScattering:{value:e()},uAerosolExtinction:{value:e()},uOzone:{value:e()},uCieX:{value:t(i=>pi.colourMatching(i)[0],683)},uCieY:{value:t(i=>pi.colourMatching(i)[1],683)},uCieZ:{value:t(i=>pi.colourMatching(i)[2],683)},uScotopic:{value:t(i=>pi.scotopic(i),1700)}}}static VERTEX=`
7507
+ `}),n.fragmentShader=s+n.fragmentShader,n.fragmentShader=n.fragmentShader.replace("#include <opaque_fragment>",a+"#include <opaque_fragment>")},e.needsUpdate=!0}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new P;up=new P;lookAt=new Ye;vertex=new P;centre=new P;right=new P;above=new P;set(e,t){this.placed=e,this.frame=t;const i=new Set(e.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 e){let s=this.meshes.get(n.sourceId);s||(s=new We(new wn(1,1,hn.SEGMENTS,hn.SEGMENTS),new rn({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),this.configureCloudMaterial(s.material),s.frustumCulled=!1,s.layers.set(G1),this.scene.add(s),this.meshes.set(n.sourceId,s)),s.renderOrder=Z_+n.renderOrder,s.visible=!n.hidden&&n.shape.transparency<1,s.visible&&this.paint(s,n,t)}}place(e,t,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:l}=s.shape;let c=l.x+l.width/2,h=l.y+l.height/2,d=!0;if(s.aim){const u=i(hn.directionOf(s.aim,this.direction));u&&Math.abs(u.ndcX)<hn.FURTHEST_NDC&&Math.abs(u.ndcY)<hn.FURTHEST_NDC?(c=(u.ndcX+1)/2*n.canvasWidthPx,h=(1-u.ndcY)/2*n.canvasHeightPx):d=!1}d?this.curve(a,e,t,n,o,c,h,s.distanceM):this.flat(a,e,n,o,s.distanceM)}}static FURTHEST_NDC=4;curve(e,t,i,n,s,a,o,l){const c=a-s.width/2,h=o-s.height/2,d=e.geometry.attributes.position,u=hn.SEGMENTS;let f=0;for(let p=0;p<=u;p++){const v=h+p/u*s.height;for(let m=0;m<=u;m++){const g=c+m/u*s.width;i(g/n.canvasWidthPx*2-1,-(v/n.canvasHeightPx*2-1),this.direction),this.vertex.copy(t.position).addScaledVector(this.direction,l),d.setXYZ(f++,this.vertex.x,this.vertex.y,this.vertex.z)}}d.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(it.sizeMAt(l,n.projection.pxToDeg(s.width)),it.sizeMAt(l,n.projection.pxToDeg(s.height)),1)}flat(e,t,i,n,s){const a=e.geometry.attributes.position,o=hn.SEGMENTS,l=it.sizeMAt(s,i.projection.pxToDeg(n.width)),c=it.sizeMAt(s,i.projection.pxToDeg(n.height));this.up.set(0,1,0).applyQuaternion(t.quaternion),this.centre.copy(t.position).addScaledVector(this.direction,s),this.lookAt.lookAt(t.position,this.centre,this.up),this.right.setFromMatrixColumn(this.lookAt,0),this.above.setFromMatrixColumn(this.lookAt,1);let h=0;for(let d=0;d<=o;d++){const u=.5-d/o;for(let f=0;f<=o;f++){const p=f/o-.5;this.vertex.copy(this.centre).addScaledVector(this.right,p*l).addScaledVector(this.above,u*c),a.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}a.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(l,c,1)}static SEGMENTS=16;static directionOf(e,t){const i=e.azimuthDeg*Math.PI/180,n=e.altitudeDeg*Math.PI/180;return t.set(Math.sin(i)*Math.cos(n),Math.sin(n),-Math.cos(i)*Math.cos(n))}get any(){for(const e of this.meshes.values())if(e.visible)return!0;return!1}get furthestM(){return this.placed.reduce((e,t)=>Math.max(e,t.distanceM),0)}paint(e,t,i){const{shape:n}=t,s=To.paintExtent(n);this.extents.set(t.sourceId,s);const a=hn.signatureOf(n,i);if(this.signatures.get(t.sourceId)===a&&e.material.map)return;this.signatures.set(t.sourceId,a);const o=Math.min(i.scale,J_/Math.max(s.width,s.height,1)),l=Math.max(1,Math.ceil(s.width*o)),c=Math.max(1,Math.ceil(s.height*o)),h=e.material.map,d=h?.image??document.createElement("canvas"),u=d.width!==l||d.height!==c;u&&(d.width=l,d.height=c);const f=d.getContext("2d");if(!f)return;f.clearRect(0,0,l,c);const p=new To(f);if(p.setStarPoints(i.starPoints),p.setRoll(i.rollRad),p.paintInto(n,s,o),h&&!u){h.needsUpdate=!0;return}h?.dispose();const v=new Kn(d);v.colorSpace=Bi,v.minFilter=vt,v.generateMipmaps=!1,e.material.map=v,e.material.needsUpdate=!0}static signatureOf(e,t){const{bounds:i}=e;return JSON.stringify([e.kind,Math.round(i.width*10),Math.round(i.height*10),e.color,e.angle,e.transparency,e.haloScale,e.blur??0,e.brightness??0,e.kind==="polygon"?e.points:void 0,t.scale,t.starPoints,t.rollRad])}dispose(e){e.removeFromParent(),e.geometry.dispose(),e.material.map?.dispose(),e.material.dispose()}clear(){for(const e of this.meshes.values())this.dispose(e);this.meshes.clear(),this.signatures.clear(),this.extents.clear(),this.placed=[]}}const V1=3,Ll=800,eo=Math.PI/180;class ar{constructor(e,t,i=ar.fetchImage){this.scene=e,this.onImageLoaded=t,this.loadImage=i}meshes=new Map;signatures=new Map;images=new Map;loading=new Map;failed=new Set;references=[];views=new Map;shown=!0;set(e,t=this.views){this.references=e,this.views=t;const i=new Set(e.map(n=>n.id));for(const[n,s]of this.meshes)i.has(n)||(this.dispose(s),this.meshes.delete(n),this.signatures.delete(n));for(const[n,s]of this.images){const a=e.find(o=>o.id===n);a&&a.src===s.texture.userData.src||(s.texture.dispose(),this.images.delete(n))}for(const n of e){const s=this.images.get(n.id);if(!s){this.load(n);continue}this.build(n,s)}}setShown(e){this.shown=e;for(const t of this.meshes.values())t.visible=e&&this.opacityOf(t.userData.id)>0}setView(e,t){this.views.set(e,t);const i=this.meshes.get(e);i&&this.applyOpacity(i,e)}get any(){for(const e of this.meshes.values())if(e.visible)return!0;return!1}place(e){for(const t of this.meshes.values())t.visible&&(t.position.copy(e.position),t.updateMatrixWorld())}get furthestM(){return this.meshes.size>0?Ll:0}directionOfPixel(e,t,i,n){const s=this.images.get(e.id),a=s?s.width/s.height:1,o=Math.tan(e.registration.fovDeg/2*eo),l=o*a;return n.set((t*2-1)*l,(1-i*2)*o,-1).normalize(),n.applyQuaternion(ar.orientation(e))}aspectOf(e){const t=this.images.get(e);return t?t.width/t.height:void 0}failedToLoad(e){return this.failed.has(e)}load(e){const t=e.src;if(this.loading.has(e.id)||this.failed.has(t))return;const i=this.loadImage(t).then(n=>{this.loading.delete(e.id);const s=this.references.find(a=>a.id===e.id);if(!s||s.src!==t){n.texture.dispose();return}n.texture.userData.src=t,this.images.set(e.id,n),this.build(s,n),this.onImageLoaded()},()=>{this.loading.delete(e.id),this.failed.add(t)});this.loading.set(e.id,i)}static async fetchImage(e){const t=await fetch(e);if(!t.ok)throw new Error(`${e}: ${t.status}`);const i=await createImageBitmap(await t.blob(),{imageOrientation:"flipY"}),n=new di(i);return n.flipY=!1,n.colorSpace=Bi,n.minFilter=vt,n.magFilter=vt,n.generateMipmaps=!1,n.needsUpdate=!0,{texture:n,width:i.width,height:i.height}}build(e,t){const i=ar.signatureOf(e,t);let n=this.meshes.get(e.id);if(n&&this.signatures.get(e.id)===i){this.applyOpacity(n,e.id);return}n&&(this.dispose(n),this.meshes.delete(e.id)),n=new We(ar.geometryOf(e,t),new rn({map:t.texture,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),e.kind==="panorama"&&(n.material.side=Ft),n.frustumCulled=!1,n.layers.set(V1),n.userData.id=e.id,n.quaternion.copy(ar.orientation(e)),this.scene.add(n),this.meshes.set(e.id,n),this.signatures.set(e.id,i),this.applyOpacity(n,e.id)}static geometryOf(e,t){if(e.kind==="panorama"){const a=new yi(Ll,64,32,Math.PI/2,Math.PI*2),o=a.attributes.uv;for(let l=0;l<o.count;l++)o.setX(l,1-o.getX(l));return o.needsUpdate=!0,a}const i=2*Ll*Math.tan(e.registration.fovDeg/2*eo),n=i*(t.width/Math.max(t.height,1)),s=new wn(n,i);return s.translate(0,0,-Ll),s}static orientation(e){const{headingDeg:t,pitchDeg:i,rollDeg:n}=e.registration,s=new _t;return s.rotation.set(i*eo,-t*eo,-(n??0)*eo,"YXZ"),s.quaternion}opacityOf(e){const t=this.references.find(n=>n.id===e);return this.views.get(e)?.opacity??t?.opacity??0}applyOpacity(e,t){const i=this.opacityOf(t);e.material.opacity=i,e.visible=this.shown&&i>0}static signatureOf(e,t){const{headingDeg:i,pitchDeg:n,rollDeg:s,fovDeg:a}=e.registration;return[e.kind,e.src,t.width,t.height,i,n,s??0,a].join("|")}dispose(e){this.scene.remove(e),e.geometry.dispose(),e.material.dispose()}disposeAll(){for(const e of this.meshes.values())this.dispose(e);this.meshes.clear(),this.signatures.clear();for(const e of this.images.values())e.texture.dispose();this.images.clear()}}class Ze{static GROUND_RADIUS_M=636e4;static TOP_RADIUS_M=646e4;static WAVELENGTHS_NM=Array.from({length:15},(e,t)=>410+20*t);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(e={}){const t=Ze.WAVELENGTHS_NM.length,i=e.aerosolOpticalDepth??Ze.DEFAULT_AEROSOL_OPTICAL_DEPTH,n=e.ozoneDobson??Ze.DEFAULT_OZONE_DOBSON;this.rayleighScattering=new Float64Array(t),this.aerosolScattering=new Float64Array(t),this.aerosolExtinction=new Float64Array(t),this.ozoneAbsorption=new Float64Array(t);const s=n*2687e17/Ze.OZONE_HALF_WIDTH_M;for(let a=0;a<t;a++){const o=Ze.WAVELENGTHS_NM[a];this.rayleighScattering[a]=Ze.rayleighAt(o);const l=i/Ze.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosolExtinction[a]=l,this.aerosolScattering[a]=l*Ze.AEROSOL_SINGLE_SCATTERING_ALBEDO,this.ozoneAbsorption[a]=Ze.OZONE_CROSS_SECTION[a]*1e-25*s}}static rayleighAt(e){const t=e/1e3,i=1/(t*t),n=t*t;return(1.0455996-341.29061*i-.9023085*n)/(1+.0027059889*i-85.968563*n)*1e-28*1e-4*2546899e19}static rayleighDensity(e){return Math.exp(-Math.max(e,0)/Ze.RAYLEIGH_SCALE_HEIGHT_M)}static aerosolDensity(e){return Math.exp(-Math.max(e,0)/Ze.AEROSOL_SCALE_HEIGHT_M)}static ozoneDensity(e){return Math.max(0,1-Math.abs(e-Ze.OZONE_PEAK_ALTITUDE_M)/Ze.OZONE_HALF_WIDTH_M)}static rayleighPhase(e){return 3/(16*Math.PI)*(1+e*e)}static aerosolPhase(e,t=Ze.AEROSOL_ASYMMETRY){const i=t*t;return 3/(8*Math.PI)*(1-i)*(1+e*e)/((2+i)*Math.pow(Math.max(1+i-2*t*e,1e-6),1.5))}}class ot{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(e,t){return e*(1/t-1)**(1/ot.RESPONSE_EXPONENT)}static get ADAPTATION_EXPONENT(){const e=ot.anchoredSemiSaturation(ot.DAYLIGHT_ANCHOR_CD_M2,ot.DAYLIGHT_ANCHOR_RESPONSE),t=ot.anchoredSemiSaturation(ot.NIGHT_ANCHOR_CD_M2,ot.NIGHT_ANCHOR_RESPONSE);return Math.log(e/t)/Math.log(ot.DAYLIGHT_ANCHOR_CD_M2/ot.NIGHT_ANCHOR_CD_M2)}static ROD_HALF_LUMINANCE_CD_M2=.04;static SCOTOPIC_TINT=[.853,.995,1.483];static get SEMI_SATURATION_SCALE(){return ot.anchoredSemiSaturation(ot.DAYLIGHT_ANCHOR_CD_M2,ot.DAYLIGHT_ANCHOR_RESPONSE)/ot.DAYLIGHT_ANCHOR_CD_M2**ot.ADAPTATION_EXPONENT}static rodShare(e){return ot.ROD_HALF_LUMINANCE_CD_M2/(ot.ROD_HALF_LUMINANCE_CD_M2+Math.max(e,0))}static semiSaturation(e){return ot.SEMI_SATURATION_SCALE*Math.max(e,1e-9)**ot.ADAPTATION_EXPONENT}static response(e,t){const i=ot.RESPONSE_EXPONENT,n=Math.max(e,0)**i;return n/(n+ot.semiSaturation(t)**i)}static displayOf(e,t,i,n=ot.rodShare(i)){const s=(1-n)*e[1]+n*t,a=ot.response(s,i),[o,l,c]=pi.linearSrgbOf(e),h=Math.max(e[1],1e-12),d=ot.SCOTOPIC_TINT,u=.2126*d[0]+.7152*d[1]+.0722*d[2],f=(p,v)=>Math.max(0,(1-n)*p/h+n*v/u)*a;return[f(o,d[0]),f(l,d[1]),f(c,d[2])]}}class ze{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 Ca;camera=new Hs(-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(e){this.renderer=e,this.supported=e.capabilities.isWebGL2&&e.extensions.has("EXT_color_buffer_float"),this.transmittance=new vi(ze.TRANSMITTANCE_WIDTH,ze.TRANSMITTANCE_HEIGHT,{count:4,type:ui,minFilter:vt,magFilter:vt,depthBuffer:!1}),this.multiple=new vi(ze.MULTIPLE_SIZE,ze.MULTIPLE_ROWS,{count:4,type:Pi,minFilter:Nt,magFilter:Nt,depthBuffer:!1});const t=()=>new vi(ze.SKY_VIEW_WIDTH,ze.SKY_VIEW_HEIGHT,{type:Pi,minFilter:Nt,magFilter:Nt,depthBuffer:!1});this.sunView=t(),this.moonView=t();const i=ze.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 $g({glslVersion:uc,uniforms:{...i,...n,...o},vertexShader:ze.VERTEX,fragmentShader:a,depthTest:!1,depthWrite:!1});this.transmittanceMaterial=s(ze.TRANSMITTANCE_FRAGMENT),this.multipleMaterial=s(ze.MULTIPLE_FRAGMENT),this.skyViewMaterial=s(ze.SKY_VIEW_FRAGMENT,{uObserverRadius:{value:Ze.GROUND_RADIUS_M+2},uSourceMu:{value:1}}),this.quad=new We(new wn(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>=ze.MULTIPLE_ROWS)}setMedium(e){const t=[e.rayleighScattering,e.aerosolScattering,e.aerosolExtinction,e.ozoneAbsorption].map(n=>Array.from(n,s=>s.toPrecision(6)).join(",")).join("|");if(t===this.mediumKey)return;this.abandonBuilding(),this.releaseAdopted(),this.mediumKey=t;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",e.rayleighScattering),i("uAerosolScattering",e.aerosolScattering),i("uAerosolExtinction",e.aerosolExtinction),i("uOzone",e.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(e){if(!this.supported||!this.mediumKey)return!1;if(this.ready)return!0;const t=ze.shared.get(this.mediumKey);if(t&&t!=="building")return this.adopt(t),!0;if(t==="building"&&!this.building)return!1;t||(ze.shared.set(this.mediumKey,"building"),this.building=!0);const i=this.renderer.getRenderTarget();let n=Math.max(1,e);this.transmittanceReady||(this.draw(this.transmittanceMaterial,this.transmittance),this.transmittanceReady=!0,n--);const s=ze.MULTIPLE_SIZE,a=ze.MULTIPLE_BLOCK;for(;n>0&&this.multipleRows<ze.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(e){this.building=!1;try{const t=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===e?ze.shared.set(e,{transmittance:t,multiple:i}):ze.shared.delete(e)}catch{ze.shared.delete(e)}}async readRaw(e,t,i){const n=new i(e.width*e.height*4);return await this.renderer.readRenderTargetPixelsAsync(e,0,0,e.width,e.height,n,void 0,t),n}adopt(e){const t=(s,a,o,l)=>{const c=new Mr(s,a,o,Ti,l?ui:Pi);return c.minFilter=c.magFilter=l?vt:Nt,c.needsUpdate=!0,c},i=e.transmittance.map(s=>t(s,ze.TRANSMITTANCE_WIDTH,ze.TRANSMITTANCE_HEIGHT,!0)),n=e.multiple.map(s=>t(s,ze.MULTIPLE_SIZE,ze.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 e of this.adopted)e.dispose();this.adopted=void 0;for(let e=0;e<4;e++)this.tableUniforms[`uT${e}`].value=this.transmittance.textures[e],this.tableUniforms[`uM${e}`].value=this.multiple.textures[e]}}abandonBuilding(){this.building&&(this.building=!1,ze.shared.get(this.mediumKey)==="building"&&ze.shared.delete(this.mediumKey))}renderSkyViews(e,t,i){if(!this.ready)return;const n=this.renderer.getRenderTarget(),s=this.skyViewMaterial.uniforms;s.uObserverRadius.value=Ze.GROUND_RADIUS_M+Math.max(e,2),s.uSourceMu.value=Math.sin(t*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(e,t,i){const n=Ze.GROUND_RADIUS_M+Math.max(e,2),s=Ze.GROUND_RADIUS_M,a=Math.acos(Math.min(Math.sqrt(Math.max(n*n-s*s,0))/n,1)),o=Math.PI-a,l=t<o?.5*(1-Math.sqrt(Math.max(1-t/o,0))):.5+.5*Math.sqrt(Math.min((t-o)/a,1));return{u:Math.min(Math.max(Math.abs(i)/Math.PI,0),1),v:l}}async readTable(e,t){if(e==="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,t),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,t),Float32Array.from(n,s=>hs.fromHalfFloat(s))}readSkyViewNow(e){const t=e==="sun"?this.sunView:this.moonView,i=new Float32Array(t.width*t.height*4),n=this.renderer.getContext();return n.bindBuffer(n.PIXEL_PACK_BUFFER,null),this.renderer.readRenderTargetPixels(t,0,0,t.width,t.height,i),i}async readSkyView(e){const t=e==="sun"?this.sunView:this.moonView,i=new Float32Array(t.width*t.height*4);return await this.renderer.readRenderTargetPixelsAsync(t,0,0,t.width,t.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(e,t){this.quad.material=e,this.renderer.setRenderTarget(t),this.renderer.render(this.scene,this.camera)}static mediumUniforms(){const e=()=>[new at,new at,new at,new at],t=(i,n)=>{const s=e();return Ze.WAVELENGTHS_NM.forEach((a,o)=>{s[Math.floor(o/4)].setComponent(o%4,i(a)*n*Ze.WAVELENGTH_STEP_NM*Ze.SOLAR_IRRADIANCE[o])}),s};return{uRayleigh:{value:e()},uAerosolScattering:{value:e()},uAerosolExtinction:{value:e()},uOzone:{value:e()},uCieX:{value:t(i=>pi.colourMatching(i)[0],683)},uCieY:{value:t(i=>pi.colourMatching(i)[1],683)},uCieZ:{value:t(i=>pi.colourMatching(i)[2],683)},uScotopic:{value:t(i=>pi.scotopic(i),1700)}}}static VERTEX=`
7508
7508
  in vec3 position;
7509
7509
  void main() {
7510
7510
  gl_Position = vec4(position.xy, 0.0, 1.0);
@@ -7522,11 +7522,12 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
7522
7522
  const float OZONE_PEAK = ${Ze.OZONE_PEAK_ALTITUDE_M.toFixed(1)};
7523
7523
  const float OZONE_HALF_WIDTH = ${Ze.OZONE_HALF_WIDTH_M.toFixed(1)};
7524
7524
  const float AEROSOL_G = ${Ze.AEROSOL_ASYMMETRY.toFixed(4)};
7525
- const float GROUND_ALBEDO = ${Ge.GROUND_ALBEDO.toFixed(4)};
7526
- const int STEPS = ${Ge.STEPS};
7527
- const int MULTIPLE_STEPS = ${Ge.MULTIPLE_STEPS};
7528
- const vec2 T_SIZE = vec2(${Ge.TRANSMITTANCE_WIDTH}.0, ${Ge.TRANSMITTANCE_HEIGHT}.0);
7529
- const float M_SIZE = ${Ge.MULTIPLE_SIZE}.0;
7525
+ const float GROUND_ALBEDO = ${ze.GROUND_ALBEDO.toFixed(4)};
7526
+ const int STEPS = ${ze.STEPS};
7527
+ const int MULTIPLE_STEPS = ${ze.MULTIPLE_STEPS};
7528
+ const vec2 T_SIZE = vec2(${ze.TRANSMITTANCE_WIDTH}.0, ${ze.TRANSMITTANCE_HEIGHT}.0);
7529
+ const vec2 M_SIZE = vec2(${ze.MULTIPLE_SIZE}.0, ${ze.MULTIPLE_ROWS}.0);
7530
+ const float M_HEIGHT_POWER = ${ze.MULTIPLE_HEIGHT_POWER.toFixed(1)};
7530
7531
 
7531
7532
  uniform vec4 uRayleigh[4];
7532
7533
  uniform vec4 uAerosolScattering[4];
@@ -7602,12 +7603,12 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
7602
7603
  #ifdef BUILDING_MULTIPLE
7603
7604
  for (int k = 0; k < 4; k++) m[k] = vec4(0.0);
7604
7605
  #else
7605
- vec2 uv = vec2((muSun + 1.0) * 0.5, (r - GROUND) / (TOP - GROUND));
7606
- vec2 size = vec2(M_SIZE);
7607
- m[0] = fetchBilinear(uM0, uv, size);
7608
- m[1] = fetchBilinear(uM1, uv, size);
7609
- m[2] = fetchBilinear(uM2, uv, size);
7610
- m[3] = fetchBilinear(uM3, uv, size);
7606
+ float height = max(r - GROUND, 0.0) / (TOP - GROUND);
7607
+ vec2 uv = vec2((muSun + 1.0) * 0.5, pow(height, 1.0 / M_HEIGHT_POWER));
7608
+ m[0] = fetchBilinear(uM0, uv, M_SIZE);
7609
+ m[1] = fetchBilinear(uM1, uv, M_SIZE);
7610
+ m[2] = fetchBilinear(uM2, uv, M_SIZE);
7611
+ m[3] = fetchBilinear(uM3, uv, M_SIZE);
7611
7612
  #endif
7612
7613
  }
7613
7614
 
@@ -7669,7 +7670,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
7669
7670
  }
7670
7671
  }
7671
7672
  `;static TRANSMITTANCE_FRAGMENT=`
7672
- ${Ge.COMMON}
7673
+ ${ze.COMMON}
7673
7674
  layout(location = 0) out vec4 out0;
7674
7675
  layout(location = 1) out vec4 out1;
7675
7676
  layout(location = 2) out vec4 out2;
@@ -7703,16 +7704,16 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
7703
7704
  }
7704
7705
  `;static MULTIPLE_FRAGMENT=`
7705
7706
  #define BUILDING_MULTIPLE
7706
- ${Ge.COMMON}
7707
+ ${ze.COMMON}
7707
7708
  layout(location = 0) out vec4 out0;
7708
7709
  layout(location = 1) out vec4 out1;
7709
7710
  layout(location = 2) out vec4 out2;
7710
7711
  layout(location = 3) out vec4 out3;
7711
- const int DIRECTIONS = ${Ge.MULTIPLE_DIRECTIONS};
7712
+ const int DIRECTIONS = ${ze.MULTIPLE_DIRECTIONS};
7712
7713
 
7713
7714
  void main() {
7714
- vec2 uv = gl_FragCoord.xy / vec2(M_SIZE);
7715
- float r = clamp(GROUND + uv.y * (TOP - GROUND), GROUND + 1.0, TOP - 1.0);
7715
+ vec2 uv = gl_FragCoord.xy / M_SIZE;
7716
+ float r = clamp(GROUND + pow(uv.y, M_HEIGHT_POWER) * (TOP - GROUND), GROUND + 1.0, TOP - 1.0);
7716
7717
  float muSun = uv.x * 2.0 - 1.0;
7717
7718
  vec3 origin = vec3(0.0, r, 0.0);
7718
7719
  vec3 sun = vec3(0.0, muSun, sqrt(max(1.0 - muSun * muSun, 0.0)));
@@ -7745,7 +7746,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
7745
7746
  out3 = result[3];
7746
7747
  }
7747
7748
  `;static SKY_VIEW_FRAGMENT=`
7748
- ${Ge.COMMON}
7749
+ ${ze.COMMON}
7749
7750
  uniform float uObserverRadius;
7750
7751
  uniform float uSourceMu;
7751
7752
  uniform vec4 uCieX[4];
@@ -7755,7 +7756,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
7755
7756
  out vec4 outColor;
7756
7757
 
7757
7758
  void main() {
7758
- vec2 uv = gl_FragCoord.xy / vec2(${Ge.SKY_VIEW_WIDTH}.0, ${Ge.SKY_VIEW_HEIGHT}.0);
7759
+ vec2 uv = gl_FragCoord.xy / vec2(${ze.SKY_VIEW_WIDTH}.0, ${ze.SKY_VIEW_HEIGHT}.0);
7759
7760
  float r = uObserverRadius;
7760
7761
  float beta = acos(clamp(sqrt(max(r * r - GROUND * GROUND, 0.0)) / r, -1.0, 1.0));
7761
7762
  float zenithHorizon = PI - beta;
@@ -7779,7 +7780,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
7779
7780
  }
7780
7781
  outColor = xyzs;
7781
7782
  }
7782
- `}class ri{static AIRGLOW_LAYER_ALTITUDE_M=9e4;static SUN_MAGNITUDE=-26.74;tables;material;onChange;state;drawnKey="";hasViews=!1;adaptingLuminance=1;ambientColours;reading=!1;exposureScale=1;seenByEye=!0;readAgain=!1;constructor(e,t){this.onChange=t,this.tables=new Ge(e),this.tables.setMedium(new Ze),this.material=new Ot({glslVersion:uc,side:Ft,depthWrite:!1,uniforms:{uSunView:{value:this.tables.sunViewTexture},uMoonView:{value:this.tables.moonViewTexture},uSunAzimuth:{value:new Te(0,-1)},uMoonAzimuth:{value:new Te(0,-1)},uMoonScale:{value:0},uObserverRadius:{value:Ze.GROUND_RADIUS_M+2},uAirglow:{value:new at(...ri.airglowXyzs())},uRodShare:{value:0},uSemiSaturationN:{value:1},uExposureScale:{value:1}},vertexShader:`
7783
+ `}class ri{static AIRGLOW_LAYER_ALTITUDE_M=9e4;static SUN_MAGNITUDE=-26.74;tables;material;onChange;state;drawnKey="";hasViews=!1;adaptingLuminance=1;ambientColours;reading=!1;exposureScale=1;seenByEye=!0;readAgain=!1;constructor(e,t){this.onChange=t,this.tables=new ze(e),this.tables.setMedium(new Ze),this.material=new Ot({glslVersion:uc,side:Ft,depthWrite:!1,uniforms:{uSunView:{value:this.tables.sunViewTexture},uMoonView:{value:this.tables.moonViewTexture},uSunAzimuth:{value:new Te(0,-1)},uMoonAzimuth:{value:new Te(0,-1)},uMoonScale:{value:0},uObserverRadius:{value:Ze.GROUND_RADIUS_M+2},uAirglow:{value:new at(...ri.airglowXyzs())},uRodShare:{value:0},uSemiSaturationN:{value:1},uExposureScale:{value:1}},vertexShader:`
7783
7784
  varying vec3 vDirection;
7784
7785
  void main() {
7785
7786
  vDirection = (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition;
@@ -7805,7 +7806,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
7805
7806
  const float GROUND = ${Ze.GROUND_RADIUS_M.toFixed(1)};
7806
7807
  const float AIRGLOW_RATIO = ${(Ze.GROUND_RADIUS_M/(Ze.GROUND_RADIUS_M+ri.AIRGLOW_LAYER_ALTITUDE_M)).toFixed(6)};
7807
7808
  const float EXTINCTION = ${Be.EXTINCTION_PER_AIR_MASS.toFixed(4)};
7808
- const vec2 VIEW_SIZE = vec2(${Ge.SKY_VIEW_WIDTH}.0, ${Ge.SKY_VIEW_HEIGHT}.0);
7809
+ const vec2 VIEW_SIZE = vec2(${ze.SKY_VIEW_WIDTH}.0, ${ze.SKY_VIEW_HEIGHT}.0);
7809
7810
  const float RESPONSE_EXPONENT = ${ot.RESPONSE_EXPONENT.toFixed(4)};
7810
7811
  const vec3 SCOTOPIC_TINT = vec3(${ot.SCOTOPIC_TINT.map(i=>i.toFixed(4)).join(", ")});
7811
7812
 
@@ -7861,7 +7862,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
7861
7862
  gl_FragColor = vec4(displayOf(light.xyz, light.w), 1.0);
7862
7863
  #include <colorspace_fragment>
7863
7864
  }
7864
- `})}get supported(){return this.tables.supported}get ready(){return this.hasViews}get ambient(){return this.ready?this.ambientColours:void 0}setInstrument(e,t){const i=e?10**(.4*t):1;i===this.exposureScale&&this.seenByEye===!e||(this.exposureScale=i,this.seenByEye=!e,this.material.uniforms.uExposureScale.value=i,this.applyAdaptation(this.adaptingLuminance),this.onChange())}setConditions(e){this.tables.setMedium(new Ze(e)),this.tables.ready||(this.drawnKey="")}advance(e){!this.supported||this.tables.ready||this.tables.advance(e)&&this.state&&this.draw(this.state)}invalidate(){this.tables.invalidate(),this.drawnKey="",this.hasViews=!1}update(e){this.state=e,this.tables.ready?this.draw(e):this.hasViews||this.applyAdaptation(ri.predictedZenithLuminance(e))}dispose(){this.tables.dispose(),this.material.dispose()}draw(e){const t=[e.altitudeM.toFixed(0),e.sun.altitudeDeg.toFixed(3),e.moon.altitudeDeg.toFixed(3)].join(":"),i=this.material.uniforms;if(i.uSunAzimuth.value.copy(ri.azimuthVector(e.sun.azimuthDeg)),i.uMoonAzimuth.value.copy(ri.azimuthVector(e.moon.azimuthDeg)),i.uMoonScale.value=10**(-.4*(e.moon.magnitude-ri.SUN_MAGNITUDE)),i.uObserverRadius.value=Ze.GROUND_RADIUS_M+Math.max(e.altitudeM,2),t!==this.drawnKey){this.tables.renderSkyViews(e.altitudeM,e.sun.altitudeDeg,e.moon.altitudeDeg);const n=!this.hasViews;this.hasViews=!0,this.drawnKey=t,n&&!this.ambientColours&&this.adaptFromViews(this.tables.readSkyViewNow("sun"),this.tables.readSkyViewNow("moon"),e),this.readBack()}this.onChange()}async readBack(){if(this.reading){this.readAgain=!0;return}this.reading=!0;try{const[e,t]=await Promise.all([this.tables.readSkyView("sun"),this.tables.readSkyView("moon")]),i=this.state;i&&this.adaptFromViews(e,t,i)}finally{this.reading=!1}this.readAgain&&(this.readAgain=!1,this.readBack())}adaptFromViews(e,t,i){const n=10**(-.4*(i.moon.magnitude-ri.SUN_MAGNITUDE)),s=ri.airglowXyzs(),a=(d,u)=>{const f=(90-d)*Math.PI/180,p=Ge.skyViewUv(i.altitudeM,f,ri.azimuthBetween(u,i.sun.azimuthDeg)),v=Ge.skyViewUv(i.altitudeM,f,ri.azimuthBetween(u,i.moon.azimuthDeg)),m=ri.bilinear(e,p.u,p.v),g=ri.bilinear(t,v.u,v.v),x=d>0?ri.airglowFactor(d):0;return[0,1,2,3].map(M=>m[M]+n*g[M]+s[M]*x)};let o=0,l=0;for(let d=5;d<90;d+=10){const u=Math.cos(d*Math.PI/180);for(let f=0;f<360;f+=30)o+=u*Math.log(Math.max(a(d,f)[1],1e-9)),l+=u}this.applyAdaptation(Math.exp(o/l));const c=(d,u)=>{const f=this.exposureScale,[p,v,m,g]=a(d,u),x=this.adaptingLuminance*f;return ot.displayOf([p*f,v*f,m*f],g*f,x,this.seenByEye?ot.rodShare(x):0)},h=[0,0,0];for(let d=0;d<360;d+=20){const u=c(2,d);for(let f=0;f<3;f++)h[f]+=u[f]/18}this.ambientColours={zenith:c(90,0),horizon:h},this.onChange()}applyAdaptation(e){this.adaptingLuminance=e;const t=e*this.exposureScale;this.material.uniforms.uRodShare.value=this.seenByEye?ot.rodShare(t):0,this.material.uniforms.uSemiSaturationN.value=ot.semiSaturation(t)**ot.RESPONSE_EXPONENT}static predictedZenithLuminance(e){const t=n=>90-n.altitudeDeg,i=Be.magPerArcsec2({altitudeDeg:e.sun.altitudeDeg,separationDeg:t(e.sun)},{phaseAngleDeg:e.moon.phaseAngleDeg,altitudeDeg:e.moon.altitudeDeg,separationDeg:t(e.moon)},90);return Be.toNanolamberts(i)*ri.CANDELAS_PER_NANOLAMBERT}static CANDELAS_PER_NANOLAMBERT=1e-5/Math.PI;static airglowXyzs(){const e=Be.toNanolamberts(Be.AIRGLOW_MAG_PER_ARCSEC2)*ri.CANDELAS_PER_NANOLAMBERT;return[e*.3127/.329,e,e*(1-.3127-.329)/.329,e]}static airglowFactor(e){const t=Math.cos(e*Math.PI/180)**2,i=Ze.GROUND_RADIUS_M/(Ze.GROUND_RADIUS_M+ri.AIRGLOW_LAYER_ALTITUDE_M),n=1/Math.sqrt(Math.max(1-i*i*t,1e-4)),s=1/Math.sqrt(Math.max(1-.96*t,.001));return n*10**(-.4*Be.EXTINCTION_PER_AIR_MASS*(s-1))}static azimuthVector(e){const t=e*Math.PI/180;return new Te(Math.sin(t),-Math.cos(t))}static azimuthBetween(e,t){const i=Math.abs(e-t)%360;return(i>180?360-i:i)*Math.PI/180}static bilinear(e,t,i){const n=Ge.SKY_VIEW_WIDTH,s=Ge.SKY_VIEW_HEIGHT,a=Math.min(Math.max(t*n-.5,0),n-1),o=Math.min(Math.max(i*s-.5,0),s-1),l=Math.floor(a),c=Math.floor(o),h=Math.min(l+1,n-1),d=Math.min(c+1,s-1),u=a-l,f=o-c,p=(v,m,g)=>e[(v*n+m)*4+g];return[0,1,2,3].map(v=>(p(c,l,v)*(1-u)+p(c,h,v)*u)*(1-f)+(p(d,l,v)*(1-u)+p(d,h,v)*u)*f)}}class ur{static DRY_OPTICAL_DEPTH=.08;static GROWTH_EXPONENT=.3;static MAX_RELATIVE_HUMIDITY=.95;static OPTICAL_DEPTH_STEP=.02;static relativeHumidity(e,t){const i=n=>Math.exp(17.625*n/(243.04+n));return Math.min(Math.max(i(t)/i(e),0),1)}static opticalDepth(e){const t=Math.min(Math.max(e,0),ur.MAX_RELATIVE_HUMIDITY);return ur.DRY_OPTICAL_DEPTH*(1-t)**-.3}static steppedOpticalDepth(e){const t=ur.OPTICAL_DEPTH_STEP;return Math.round(ur.opticalDepth(e)/t)*t}}function j_(r,e){return JSON.stringify(r.cloudLayers)===JSON.stringify(e.cloudLayers)&&r.cloudCover===e.cloudCover&&r.cloudDarkness===e.cloudDarkness&&r.cloudBaseM===e.cloudBaseM&&r.highCloudCover===e.highCloudCover&&r.iceCrystalAlignment===e.iceCrystalAlignment&&r.lowerCloudCover===e.lowerCloudCover&&r.relativeHumidity===e.relativeHumidity&&r.precipitationType===e.precipitationType&&r.precipitationIntensity===e.precipitationIntensity&&r.windDirectionDeg===e.windDirectionDeg&&r.windSpeed===e.windSpeed&&r.storm===e.storm}const kl=900,Wh=1,um=.5,fo=900,Q_=6371e3,e5=3e4;function fm(r){const e=Math.sqrt(2*Q_*Math.max(r,0));return Math.max(fo,Math.min(e,e5))}const Xh=.5,qh=850,pm=.03,Zr=850,Yh=4,Kh=1.5,mm=-1,t5=6,Hu=-4,gm=.2,Nl=2600,i5=.97,n5=.38,vm=Hu,s5=3,r5=.15,a5=.6,o5=40,l5=30,c5=[0,45,90,135,180,225,270,315],h5={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},d5=["en","fr"],u5=2,f5=16,ym=2500,bm=880,Ol=40,wm=60,p5=10,m5=1,g5=150,v5=55,y5=.5,b5=2.05,Mm=.265,xm=[[0,0],...Array.from({length:8},(r,e)=>{const t=e*Math.PI/4;return[Math.cos(t)*Mm,Math.sin(t)*Mm]})],$h=700,Zh=250/1e3,w5=12,Sm=5,Jh=6,Zs=[.92,.92,.95],jh=[.15,.15,.19],Em={snow:{fallSpeedMPerS:2,size:.3,color:new oe(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new oe(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},na=0,Qh=0,M5=150,_m=3e3,to=20,x5=15,Tm=na,S5=40,Am=1,E5=9;function Im(r){return Am+(E5-Am)*r}const _5=new oe(.75,.82,.92),T5=10,A5=.5;function I5(r){return wo(r/T5,A5,1)}const Jr=200,Dm=.18,Cm=.32,D5=.35,C5=new oe(.85,.9,.98),Rm=5,Pm=.85,Lm=.01;function ed(r,e){return Math.round(r*(Lm+(1-Lm)*e))}const km=230,Nm=.7,Om=.05,R5=.6,P5=.7,L5=.15,Fm=.35,k5=3,N5=1/12,O5=.5,In=new oe(.82,.86,1),F5=2500,U5=1.6,B5=1.2,z5=2.2,H5={Venus:new oe(1,.96,.85),Mars:new oe(1,.55,.4),Jupiter:new oe(.95,.87,.72),Saturn:new oe(.92,.86,.68)};class tn{renderer;scene=new Ca;phenomena=new hn(this.scene);references=new ar(this.scene,()=>this.render());camera;celestialGroup=new ci;skyMesh;skyGradientMaterial;scatteredSky;lastAstronomy;skyColoursStale=!1;scatteredSkyFrameId=null;skyHoldUntilMs=void 0;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;decorModelProvider=jl[0].create();decorModelToken=0;decorModelCredits=new Map;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;decorReferencePose;decorCurrentPose;decorTime=0;celestialLight=new a0(16777215,0);celestialLightTarget=new _t;skyLight=new yb(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 Th;weather=ag;observerElevationM=0;siteElevationM=0;groundRadius=fo;terrainRadius=fo;cloudRendering="volume";layeredClouds;cloudLayerOffsetsM={};cloudOffsetM=new P;cloudFieldOffset=new P;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new P;rainLastVerticalFacing=-1;rainViewportSize=new Te;lightningArmed=!1;lightningFlashes=[];lightningLevel=0;lightningBolt;lightningLight=new a0(16777215,0);baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new P;sunVisible=!1;lensFlareScratch=new P;sunOcclusionRaycaster=new Th;sunOcclusionDirectionScratch=new P;sunOcclusionRightScratch=new P;sunOcclusionUpScratch=new P;ufoOcclusionRaycaster=new Th;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;static exposureInstantsPerFrame(e){return Math.max(3,Math.round(6e6/Math.max(1,e)))}exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;meteorSystem;cometTail;satelliteField;iceHalos;rainbow;skyGlow;cometKey;novaKeys=new Set;constructor(e,t=v2()){this.renderer=new D3({canvas:e,antialias:!0}),this.resolution=new Dt(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=po,this.camera=new zi(60,e.width/Math.max(e.height,1),.1,kl*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=t,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-120,this.celestialLight.shadow.camera.right=120,this.celestialLight.shadow.camera.top=120,this.celestialLight.shadow.camera.bottom=-120,this.celestialLight.shadow.camera.near=1,this.celestialLight.shadow.camera.far=1e3,this.celestialLight.shadow.bias=-.0015,this.celestialLight.target=this.celestialLightTarget,this.lightningLight.color.copy(In),this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight,this.lightningLight),this.scene.add(this.celestialGroup);const i=new ri(this.renderer,()=>{this.skyColoursStale=!0,this.render()});i.supported?this.scatteredSky=i:i.dispose()}get currentTerrainAttribution(){return this.terrainAttribution}resize(e,t){this.cssSize.width=e,this.cssSize.height=t,this.renderer.setSize(e,t,!1),this.camera.aspect=e/Math.max(t,1),this.camera.updateProjectionMatrix(),this.render()}setCloudRendering(e){e!==this.cloudRendering&&(this.cloudTransmissionMemo.clear(),this.cloudRendering=e,this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.buildClouds(),this.buildCirrus(),this.render())}setCloudOffset(e,t={}){this.cloudOffsetM.set(e.x,0,e.z),this.cloudLayerOffsetsM=t,this.layeredClouds?.setOffsets(e,t),this.cloudFieldOffset.set(e.x*Zh,0,e.z*Zh);for(const i of[this.cloudUniforms,this.cirrusUniforms])i?.fieldOffset.value.copy(this.cloudFieldOffset);this.iceHalos?.setCloudOffset(this.layeredClouds?.cirrusMask?.offset??this.cloudFieldOffset)}setObserverPose(e){const t=((e.rollDeg??0)+this.gaitOffset.rollDeg)*ki,i=(e.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*ki;if(e.headingDeg!==void 0?this.camera.rotation.set(i,-(e.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*ki,t,"YXZ"):this.camera.rotation.set(i,this.camera.rotation.y,t,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(fm(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/fo),this.camera.far=Math.max(kl*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&e.lat!==void 0&&e.lng!==void 0){const n=mi(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=n.x,this.terrainMesh.position.z=n.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+e.elevationM,this.camera.position.y=this.poseCameraY,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==e.fovDeg&&(this.camera.fov=e.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(e){this.terrainProviders=e,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(e,t,i){if(e===void 0||t===void 0)return;const n=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-n)<n*.1){const{x:l,z:c}=mi(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(l*l+c*c)<g5*(n/fo))return}const s=this.terrainOrigin,a=this.terrainRadius;this.terrainOrigin={lat:e,lng:t},this.terrainRadius=n;const o=++this.terrainBuildToken;g_(e,t,this.terrainProviders,n).then(({mesh:l,attribution:c,originElevationM:h})=>{if(o!==this.terrainBuildToken)return;this.setSiteElevation(h??0);const d=this.terrainMesh,u=s?mi(e,t,s.lat,s.lng):void 0;d&&u&&Math.hypot(u.x,u.z)<=a&&(l.position.y=d.position.y+this.groundYOfPatch(d,u.x,u.z)),this.disposeMesh(this.terrainMesh),l.renderOrder=m5,this.terrainMesh=l,this.compileNextFrameOffThread(),this.terrainAttribution=c,this.scene.add(l),this.applyGroundDepthWrite(),this.decorCurrentPose&&(this.setObserverPose(this.decorCurrentPose),this.updateDecorAnchoring(this.decorReferencePose,this.decorCurrentPose,this.decorTime)),this.render(),i?.()}).catch(l=>{console.warn("Terrain build failed, keeping the flat ground fallback:",l),i?.()})}setShowCompass(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}applyLensFlareTint(e){if(!this.lensFlare)return;const t=v5*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(t*e[0],t*e[1],t*e[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const e=this.lastSunPosition?.altitudeDeg??-90,t=oE(e)*this.sunCloudTransmission*this.sunUnhiddenFraction,i=Is(e);this.lensFlare.uniforms.uDazzleColour.value.setRGB(i[0],i[1],i[2]),this.lensFlare.uniforms.uVeilStrength.value=b5**2*Math.max(0,t)}setCompassHovered(e){this.compassHovered!==e&&(this.compassHovered=e,this.updateCompassVisibility())}setCompassForced(e){this.compassForced!==e&&(this.compassForced=e,this.updateCompassVisibility())}updateCompassVisibility(){const e=this.compassHovered||this.compassForced;if(this.compassSprites.some(t=>t.visible!==e)){for(const t of this.compassSprites)t.visible=e;this.developingExposure?this.exposureInstantsDone>0&&this.presentExposure():this.render()}}setWeather(e){this.cloudTransmissionMemo.clear(),!j_(this.weather,e)&&(this.weather=e,this.scatteredSky?.setConditions({aerosolOpticalDepth:e.relativeHumidity===void 0?void 0:ur.steppedOpticalDepth(e.relativeHumidity)}),this.pumpScatteredSky(),this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=e.storm&&e.cloudDarkness>=O5,this.syncAnimationLoop(),this.render())}setDecor(e){if(this.decorObjects!==e){this.decorObjects=e,this.decorModelToken++,this.decorModelCredits.clear();for(const t of this.decorGroups.values())t.removeFromParent(),li.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const i=li.build(t,t.lit??!1);this.scene.add(i),this.decorGroups.set(t.id,i),t.kind==="streetlight"&&this.addStreetlightLight(t.id,i),this.loadDecorModel(t,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0}}setDecorModelProvider(e){this.decorModelProvider=e;const t=this.decorObjects;this.decorObjects=[],this.setDecor(t)}get currentDecorModelCredits(){return[...this.decorModelCredits.values()]}async loadDecorModel(e,t){const i=e.model;if(!(!i||!li.usesModel(e)))try{const n=i.url?void 0:i.id?await this.decorModelProvider.entry(i.id):void 0,s=i.url??n?.url,a=i.credit??n?.credit;if(!s||!a)return;const o=await $_(s);if(t!==this.decorModelToken)return;const l=this.decorGroups.get(e.id);if(!l)return;li.applyModel(l,e,o,{headingOffsetDeg:i.headingOffsetDeg??n?.headingOffsetDeg,depictedSizeM:n?.sizeM}),this.decorModelCredits.set(e.id,a),this.render()}catch(n){console.warn(`Keeping the built-in shape for decor "${e.id}":`,n)}}updateDecorAnchoring(e,t,i=0){this.decorReferencePose=e,this.decorCurrentPose=t,this.decorTime=i;const n=e?.lat!==void 0&&e.lng!==void 0&&t?.lat!==void 0&&t?.lng!==void 0?mi(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},s=this.decorObjects.find(c=>c.witnessSide!==void 0&&ra(c.kind));if(this.terrainMesh&&this.terrainOrigin&&t?.lat!==void 0&&t.lng!==void 0){const c=mi(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=c.x-(s?0:this.gaitOffset.eastM),this.terrainMesh.position.z=c.z+(s?0:this.gaitOffset.northM)}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 c=li.occupantView(s),h=-(s.headingDeg??0)*ki,d=c.x*Math.cos(h)+c.z*Math.sin(h),u=-c.x*Math.sin(h)+c.z*Math.cos(h),f=s.eastM+n.x,p=-s.northM+n.z;a.x=-(f+d),a.z=-(p+u),this.camera.position.y=this.groundYUnder(f,p)+c.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*ki,-(c.headingDeg+this.indoorLookYawDeg)*ki,0,"YXZ")}for(const c of this.decorObjects){const h=this.decorGroups.get(c.id);if(!h)continue;const d=_a(c,i),u=d.eastM+n.x+a.x,f=-d.northM+n.z+a.z,p=this.terrainMesh,v=`${p?.geometry.uuid}:${(u-(p?.position.x??0)).toFixed(3)}:${(f-(p?.position.z??0)).toFixed(3)}:${(p?.position.y??0).toFixed(3)}:${d.headingDeg}:${d.altitudeM}`;if(h.userData.footprintKey!==v&&(h.userData.footprintGroundY=this.groundUnderFootprint(c,u,f,d.headingDeg,d.altitudeM),h.userData.footprintKey=v),h.position.set(u,h.userData.footprintGroundY+d.altitudeM,f),c.kind==="crop"){const m=Math.hypot(u,f);h.visible=m<=M5}if(d.headingDeg!==void 0&&(h.rotation.y=-d.headingDeg*ki),c.kind==="crop"&&h.visible){const m=this.terrainMesh,g=[m?.geometry.uuid,u-(m?.position.x??0),f-(m?.position.z??0),h.position.y-(m?.position.y??0),d.headingDeg,d.altitudeM].map(x=>typeof x=="number"?x.toFixed(4):x).join(":");h.userData.cropGroundKey!==g&&(li.fitCropToGround(h,(x,M)=>this.groundYUnder(x,M)+d.altitudeM),h.userData.cropGroundKey=g)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const l=Math.max(kl*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-l)>1&&(this.camera.far=l,this.camera.updateProjectionMatrix())}groundYUnder(e,t){const i=this.terrainMesh;return i?i.position.y+this.groundYOfPatch(i,e-i.position.x,t-i.position.z):Qh}groundYOfPatch(e,t,i){const n=e.geometry.getAttribute("position"),s=Math.round(Math.sqrt(n.count));if(s<2||s*s!==n.count)return Qh;const a=n.getX(0),o=n.getX(s-1),l=n.getZ(0),c=n.getZ((s-1)*s),h=wo((t-a)/(o-a)*(s-1),0,s-1),d=wo((i-l)/(c-l)*(s-1),0,s-1);if(!Number.isFinite(h)||!Number.isFinite(d))return Qh;const u=Math.min(Math.floor(h),s-2),f=Math.min(Math.floor(d),s-2),p=h-u,v=d-f,m=(S,_)=>n.getY(S*s+_),g=m(f,u),x=m(f,u+1),M=m(f+1,u),w=m(f+1,u+1);return p+v<=1?g+(x-g)*p+(M-g)*v:w+(M-w)*(1-p)+(x-w)*(1-v)}groundUnderFootprint(e,t,i,n,s=0){return li.groundUnderFootprint(e,t,i,n,(a,o)=>this.groundYUnder(a,o),s)}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(e){this.gaitOffset=e}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(e,t){this.lookYawDeg=e,this.lookPitchDeg=t}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(e,t){this.indoorLookYawDeg=e,this.indoorLookPitchDeg=t}updateDecorLitState(e,t=0){for(const i of this.decorObjects){const n=this.decorGroups.get(i.id);if(n&&i.lights?.length&&li.setLights(n,i.lights,e,n.position.distanceTo(this.camera.position),t),i.kind!=="streetlight"&&i.kind!=="vehicle")continue;const s=this.decorGroups.get(i.id);if(!s)continue;const a=sc(i,e);li.setLit(s,i.kind,a);const o=this.streetlightLights.get(i.id);o&&(o.visible=a)}}addStreetlightLight(e,t){const i=li.bodyOf(t),n=i.children.find(a=>a.userData.emissive);if(!n)return;const s=new Mb(16764006,o5,l5);s.position.copy(n.position).multiply(i.scale),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,t.add(s),this.streetlightLights.set(e,s)}setAstronomy(e){this.lastAstronomy=e,this.scatteredSky?.update(this.scatteredSkyState(e)),this.skyHoldUntilMs===void 0&&this.scatteredSky&&!this.scatteredSky.ambient&&(this.skyHoldUntilMs=performance.now()+ym,setTimeout(()=>this.render(),ym+20)),this.pumpScatteredSky(),this.lastSunPosition=e.sun,this.buildSky(e.sun),this.buildGround();const t=hr(e.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(e.stars,t),this.setBodyMesh("sun",e.sun,Yh,new oe(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon,t),this.buildPlanets(e.planets,t),this.buildComet(e.comet,t),this.buildNovae(e.novae??[],t),this.buildIceHalos(e.sun,e.moon),this.buildRainbow(e.sun,e.moon),this.applySkyColours(e),this.syncAnimationLoop(),this.render()}applySkyColours(e){this.skyColoursStale=!1;const t=this.scatteredSky?.ambient??yu(e.sun.altitudeDeg),i=t.horizon;this.baseFogColor=[i[0],i[1],i[2]],this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.scatteredSky?.ready?this.scatteredSky.material:this.skyGradientMaterial),this.updateCloudLighting(e.sun,this.baseFogColor),this.updateCelestialLight(e,t.zenith,i),this.buildSkyGlow(e,t.zenith),this.scene.fog instanceof pc?(this.scene.fog.color.setRGB(...this.baseFogColor),this.scene.fog.near=this.groundRadius*.2,this.scene.fog.far=this.groundRadius):this.scene.fog=new pc(new oe(...this.baseFogColor),this.groundRadius*.2,this.groundRadius)}setSiteElevation(e){Math.abs(e-this.siteElevationM)<1||(this.siteElevationM=e,this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}scatteredSkyState(e){return{altitudeM:this.siteElevationM+this.observerElevationM+1.6,sun:{altitudeDeg:e.sun.altitudeDeg,azimuthDeg:e.sun.azimuthDeg,magnitude:e.sun.magnitude},moon:{altitudeDeg:e.moon.altitudeDeg,azimuthDeg:e.moon.azimuthDeg,magnitude:e.moon.magnitude,phaseAngleDeg:Be.phaseAngleOf(e.moon.phase.illuminatedFraction)}}}pumpScatteredSky(){const e=this.scatteredSky;!e||e.tables.ready||this.scatteredSkyFrameId!==null||this.contextReleased||(this.scatteredSkyFrameId=requestAnimationFrame(()=>{this.scatteredSkyFrameId=null,!this.contextReleased&&(e.advance(this.skyHoldUntilMs?f5:u5),this.pumpScatteredSky())}))}cancelScatteredSkyPump(){this.scatteredSkyFrameId!==null&&(cancelAnimationFrame(this.scatteredSkyFrameId),this.scatteredSkyFrameId=null)}setSatellites(e){if(e.length===0&&!this.satelliteField?.count)return;this.satelliteField||(this.satelliteField=new R_(qh),this.celestialGroup.add(this.satelliteField.object));const t=hr(this.lastSunPosition?.altitudeDeg??-90,this.instrumentMagnitudeGain);this.satelliteField.set(e,t,i=>this.cloudTransmission(i)),this.render()}pickSatelliteAt(e,t){if(!this.satelliteField?.count)return;this.aimAtScreenPoint(this.raycaster,e,t);const i=Math.cos(pm*this.camera.fov*Math.PI/180),n=this.satelliteField.nearest(this.raycaster.ray.direction,i);return n&&this.groundHides(e,t)?void 0:n}updateCelestialLight(e,t,i){this.skyLight.color.setRGB(t[0],t[1],t[2]),this.skyLight.groundColor.setRGB(i[0],i[1],i[2]),this.skyLight.intensity=a5;const n=e.sun.altitudeDeg>=vm,s=!n&&e.moon.altitudeDeg>=vm;if(!n&&!s){this.celestialLight.intensity=0;return}const a=n?e.sun:e.moon,{x:o,y:l,z:c}=oi(a.altitudeDeg,a.azimuthDeg,Zr);this.celestialLight.position.set(o,l,c);const h=Is(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const d=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*ki));this.celestialLight.intensity=(n?s5:r5)*d,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,i){this.meteorSystem||(this.meteorSystem=new si,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(e,t,i)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(e){return this.meteorSystem?.midpointOf(e)}updateMeteors(e){this.meteorSystem?.update(e)}setInstrument(e){this.projectionKind=e.projection;const t=ct.starPointsOf(e),i=ct.flareArtifactsOf(e);t===this.starPoints&&i===this.lensFlareArtifactIntensity||(this.starPoints=t,this.lensFlareArtifactIntensity=i,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=t,this.lensFlare.uniforms.uFlareIntensity.value=i),this.render())}setInstrumentGain(e,t=!1){this.instrumentMagnitudeGain=Number.isFinite(e)?e:0,this.scatteredSky?.setInstrument(t,this.instrumentMagnitudeGain)}render(){this.restatingExposure||(this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()})))}drawIfDirty(){if(!(!this.frameDirty||this.contextReleased)){if(this.skyHoldUntilMs){if(!this.scatteredSky?.ambient&&performance.now()<this.skyHoldUntilMs)return;this.skyHoldUntilMs=null}if(this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy),this.compileBeforeNextDraw){this.compileBeforeNextDraw=!1;const e=this.compileOffThread().then(()=>{this.compiling===e&&(this.compiling=void 0,this.render())});this.compiling=e;return}if(!this.compiling){this.frameDirty=!1,this.resolution.beginDrawing();try{this.renderOnce()}finally{this.resolution.endDrawing()}this.developingExposure&&this.startExposure()}}}compileBeforeNextDraw=!1;compiling;static COMPILE_WAIT_MS=1500;compileOffThread(){const e=this.renderer.compile(this.scene,this.camera);if(!this.renderer.extensions.get("KHR_parallel_shader_compile"))return Promise.resolve();const t=this.renderer.properties,i=performance.now()+tn.COMPILE_WAIT_MS;return new Promise(n=>{const s=()=>{if(this.contextReleased)return n();for(const a of e){const o=t.get(a)?.currentProgram;(!o||o.isReady())&&e.delete(a)}e.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(e){if(this.animationsRunning){const t=this.lastFrameTimeMs===void 0?0:e-this.lastFrameTimeMs;this.lastFrameTimeMs=e,this.hasAnimations()&&this.animate(e,t);const i=this.resolution.update(e,t);i!==void 0&&this.applyPixelRatio(i)}this.drawIfDirty()}animate(e,t){const i=Math.min(t/1e3,N5);this.updateTwinkle(e/1e3),this.updatePrecipitation(e/1e3,i),this.updateRain(i),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=e/1e3),this.developingExposure||(this.frameDirty=!0)}setMaxPixelRatio(e){this.resolution.maximum=e,this.renderer.getPixelRatio()!==this.resolution.pixelRatio&&this.applyPixelRatio(this.resolution.pixelRatio)}applyPixelRatio(e){this.renderer.setPixelRatio(e),this.renderer.setSize(this.cssSize.width,this.cssSize.height,!1),this.frameDirty=!0}setExposure(e,t){const i=t?Math.max(1,Math.round(e)):1;if(i===this.exposureInstants&&(i===1||t===this.exposureInstantAt)){this.exposureInstantAt=t;return}this.exposureInstants=i,this.exposureInstantAt=t,i===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(e){if(this.onMapSubjectBounds){const s=this.mapSubjectBounds();e?this.exposureSubjectBounds.push(...s):this.onMapSubjectBounds(s)}const t=this.usableEquidistantPass();this.phenomena.setCloudLayers(this.layeredClouds?.volumes??[]),this.phenomena.place(this.camera,(s,a,o)=>this.directionAtScreenPoint(s,a,o),s=>this.screenPointOf(s)),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());const n=this.renderer.getRenderTarget();if(!t){this.updateLensFlarePosition();const s=this.usableDepthOfFieldPass();s?.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(e===void 0&&!s),e&&this.renderer.setRenderTarget(e),s?s.render(this.renderer,this.scene,this.camera,()=>this.renderOverlayPasses()):(this.renderer.render(this.scene,this.camera),this.renderOverlayPasses()),e&&this.renderer.setRenderTarget(n);return}t.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(!1),e&&this.renderer.setRenderTarget(e),t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),()=>this.renderOverlayPasses()),e&&this.renderer.setRenderTarget(n)}renderOverlayPasses(){this.renderReferencesPass(),this.renderPhenomenaPass()}renderReferencesPass(){if(!this.references.any)return;const e=this.renderer.autoClear,t=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.camera.layers.set(V1),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=t}setReferences(e){this.references.set(e)}referenceAspect(e){return this.references.aspectOf(e)}directionAt(e,t){return this.directionAtScreenPoint(e,t,new P)}referenceFailedToLoad(e){return this.references.failedToLoad(e)}setReferencesShown(e){this.references.setShown(e),this.render()}setReferenceView(e,t){this.references.setView(e,t),this.render()}renderPhenomenaPass(){if(!this.phenomena.any)return;const e=this.renderer.autoClear,t=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const i of this.decorObjects){const n=this.decorGroups.get(i.id);n&&tn.markDecorDepth(n,i.kind!=="crop")}this.camera.layers.set(Wh),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,this.camera),this.scene.overrideMaterial=null,this.camera.layers.set(G1),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=t}decorDepthMaterial=new rn({colorWrite:!1});static markDecorDepth(e,t){e.traverse(i=>{if(!(i instanceof We))return;const n=Array.isArray(i.material)?i.material[0]:i.material;t&&n.depthWrite!==!1&&n.blending!==Zi?i.layers.enable(Wh):i.layers.disable(Wh)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const e=this.renderer.getDrawingBufferSize(new Te),t=Math.max(1,Math.round(e.x)),i=Math.max(1,Math.round(e.y));this.exposureAccumulation||(this.exposureAccumulation=new B3(t,i)),this.exposureAccumulation.resize(t,i),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const e=this.exposureInstantAt,t=this.exposureAccumulation;if(!e||!t)return;const i=1/this.exposureInstants;this.resolution.beginDrawing();const n=performance.now()+tn.EXPOSURE_BUDGET_MS,s=tn.exposureInstantsPerFrame(t.instantTarget.width*t.instantTarget.height);let a=0;do{this.restateAt(e,this.exposureInstantsDone);const o=this.compassSprites.map(l=>l.visible);for(const l of this.compassSprites)l.visible=!1;try{this.renderOnce(t.instantTarget)}finally{this.compassSprites.forEach((l,c)=>{l.visible=o[c]})}t.add(this.renderer,i),this.exposureInstantsDone++,a++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<n&&a<s);this.restateAt(e,0),this.presentExposure(),this.resolution.endDrawing(),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}presentExposure(){if(this.exposureAccumulation?.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.onMapSubjectBounds?.(this.exposureSubjectBounds),!this.compassSprites.some(s=>s.visible))return;const e=new Ca,t=new Hs(-1,1,1,-1,0,2),i=Ol/(bm*Math.tan(wm*ki/2));for(const s of this.compassSprites){if(!s.visible)continue;const a=s.getWorldPosition(new P).sub(this.camera.position).normalize(),o=this.screenPointOf(a);if(!o)continue;const l=new Gr(s.material);l.position.set(o.ndcX,o.ndcY,-1),l.scale.set(i/this.camera.aspect,i,1),e.add(l)}const n=this.renderer.autoClear;this.renderer.autoClear=!1;try{this.renderer.render(e,t)}finally{this.renderer.autoClear=n}}onMapSubjectBounds;exposureSubjectBounds=[];mapSubjectBounds(){const e=[],t=new bn,i=new P;for(const n of this.decorObjects){if(!n.track?.length&&n.kind!=="aircraft"&&n.kind!=="vehicle")continue;const s=this.decorGroups.get(n.id);if(!s?.visible||(t.setFromObject(s),t.isEmpty()))continue;let a=1/0,o=-1/0,l=1/0,c=-1/0;for(const h of[t.min.x,t.max.x])for(const d of[t.min.y,t.max.y])for(const u of[t.min.z,t.max.z]){i.set(h,d,u).sub(this.camera.position).normalize();const f=this.screenPointOf(i);if(!f)continue;const p=(f.ndcX+1)/2,v=(1-f.ndcY)/2;a=Math.min(a,p),o=Math.max(o,p),l=Math.min(l,v),c=Math.max(c,v)}Number.isFinite(a)&&e.push({x:a,y:l,width:o-a,height:c-l})}return e}restateAt(e,t){this.restatingExposure=!0;try{e(t)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(e){const t=this.lensOptics;this.lensOptics=e,(t===void 0!=(e===void 0)||t&&e&&(t.focalLengthMm!==e.focalLengthMm||t.fNumber!==e.fNumber||t.focusDistance!==e.focusDistance||t.frameHeightMm!==e.frameHeightMm))&&(e&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.render())}usableDepthOfFieldPass(){const e=this.lensOptics;if(!e)return;const t=this.renderer.getDrawingBufferSize(new Te),i=Math.max(1,Math.round(t.x)),n=Math.max(1,Math.round(t.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new bo(i,n)),this.depthOfFieldPass.resize(i,n),this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.depthOfFieldPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const e=this.renderer.getDrawingBufferSize(new Te);if(yo.supports(this.camera.fov,e.x/Math.max(e.y,1)))return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new yo(e.x,e.y),this.equidistantPass}aimAtScreenPoint(e,t,i){const n=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!n){e.setFromCamera(new Te(t,i),this.camera);return}const s=n.directionFor(t,i,this.camera.fov);this.camera.updateMatrixWorld(),e.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),e.ray.direction.set(s.x,s.y,s.z).applyQuaternion(this.camera.quaternion).normalize(),e.camera=this.camera}pickCloudAt(e,t){return this.layeredClouds?.pickInstance(this.cloudDirectionAt(e,t))}cloudDirectionAt(e,t){return this.directionAtScreenPoint(e,t,new P)}directionAtScreenPoint(e,t,i){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),i.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(e){this.camera.updateMatrixWorld();const t=this.screenPointScratch.copy(e).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert());if(t.z>=0)return;const i=this.renderer.getDrawingBufferSize(this.screenPointSize),n=i.x/Math.max(i.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return yo.ndcFor(t,this.camera.fov,n);const s=Math.tan(this.camera.fov/2*ki);return{ndcX:t.x/-t.z/(n*s),ndcY:t.y/-t.z/s}}screenPointScratch=new P;screenPointQuaternion=new qn;screenPointSize=new Te;updateLensFlarePosition(){const e=this.lensFlare;if(!e)return;if(!this.sunVisible){e.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){e.mesh.visible=!1;return}const t=this.sunVisibleFraction();if(t<=0){e.mesh.visible=!1;return}e.mesh.visible=!0,this.sunUnhiddenFraction=t,this.applyDazzleStrength();const i=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);e.uniforms.uLensPosition.value.set(i.x,i.y);const n=this.renderer.domElement.width,s=this.renderer.domElement.height;e.uniforms.uResolution.value.set(n,s),e.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let e=0;for(const t of xm)this.isSunOccluded(t[0],t[1])||e++;return e/xm.length}raycastableDecor(){const e=[];for(const t of this.decorObjects){if(t.kind==="crop")continue;const i=this.decorGroups.get(t.id);i&&e.push(i)}return e}isSunOccluded(e=0,t=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(),e!==0||t!==0){const o=Math.PI/180,l=this.sunOcclusionRightScratch.set(n.z,0,-n.x);l.lengthSq()<1e-9&&l.set(1,0,0),l.normalize();const c=this.sunOcclusionUpScratch.crossVectors(l,n).normalize();n.addScaledVector(l,e*o).addScaledVector(c,t*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(e,t,i,n=0){const s=this.groundMesh;if(s&&t.y<0){const m=(s.position.y-e.y)/t.y;if(m>n&&m<i){const g=e.x+t.x*m-s.position.x,x=e.z+t.z*m-s.position.z;if(Math.hypot(g,x)<=this.groundRadius)return!0}}const a=this.terrainMesh;if(!a)return!1;const o=a.geometry.getAttribute("position"),l=Math.round(Math.sqrt(o.count));if(l<2||l*l!==o.count)return!1;const c=[a.position.x+o.getX(0),a.position.x+o.getX(l-1)],h=[a.position.z+o.getZ(0),a.position.z+o.getZ((l-1)*l)],d=Math.min(Math.abs(c[1]-c[0]),Math.abs(h[1]-h[0]))/(l-1);if(!(d>0))return!1;let u=n,f=i;for(const[m,g,x]of[[e.x,t.x,c],[e.z,t.z,h]]){const M=Math.min(x[0],x[1]),w=Math.max(x[0],x[1]);if(Math.abs(g)<1e-12){if(m<M||m>w)return!1;continue}const S=(M-m)/g,_=(w-m)/g;u=Math.max(u,Math.min(S,_)),f=Math.min(f,Math.max(S,_))}if(!(f>u))return!1;const p=Math.hypot(t.x,t.z),v=Math.min(4096,Math.max(8,Math.ceil((f-u)*p/(d/2))));for(let m=0;m<=v;m++){const g=u+(f-u)*m/v,x=e.x+t.x*g,M=e.y+t.y*g,w=e.z+t.z*g;if(M<=this.groundYUnder(x,w))return!0}return!1}setPhenomena(e,t){this.phenomena.set(e,t)}decorDistancesAt(e,t,i){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=um;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 l=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];l&&(a.occludesSourceIds?.includes(i)?n=n===void 0?l.distance:Math.max(n,l.distance):s=s===void 0?l.distance:Math.min(s,l.distance))}return{behindM:n,inFrontM:s}}pickBodyAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const i=[...this.hitAreas.entries()],n=this.raycaster.intersectObjects(i.map(([,s])=>s))[0];if(n&&!this.groundHides(e,t))return i.find(([,s])=>s===n.object)?.[0]}pickStarAt(e,t){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,e,t);const i=this.raycaster.ray.direction,n=Math.cos(pm*this.camera.fov*Math.PI/180);let s,a=n;for(const o of this.namedStars){const l=o.direction.dot(i);l>a&&(a=l,s={star:o.star,altitudeDeg:o.altitudeDeg})}return s&&this.groundHides(e,t)?void 0:s}groundHides(e,t){if(!this.terrainMesh&&!this.groundMesh)return!1;this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t);const i=this.ufoOcclusionRaycaster.ray;return this.groundBlocks(i.origin,i.direction,1/0,um)}pickDecorAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);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.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.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.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 e of this.bodyMeshes.values())this.disposeMesh(e);this.bodyMeshes.clear(),this.novaKeys.clear();for(const e of[...this.hitAreas.keys()])this.disposeHitArea(e);for(const e of[...this.glareSprites.keys()])this.disposeGlare(e);this.disposeCompassLabels();for(const e of this.decorGroups.values())li.dispose(e);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 e=t=>{this.frame(t),this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e)}setAnimationsRunning(e,t=!1){const i=e&&t;if(e===this.animationsRunning&&i===this.framesDriven)return;const n=this.animationsRunning;this.animationsRunning=e,this.framesDriven=i,e&&!n&&(this.lastFrameTimeMs=void 0,this.resolution.reset()),this.syncAnimationLoop(),(!e||this.frameDirty)&&this.render()}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(e){const t=this.skyMesh?.geometry??new yi(kl,32,16),i=t.attributes.position,n=t.getAttribute("color")??new Ut(new Float32Array(i.count*3),3);for(let a=0;a<i.count;a++){const{altitudeDeg:o,azimuthDeg:l}=G3(i.getX(a),i.getY(a),i.getZ(a)),c=Z3(o,l,e.azimuthDeg,e.altitudeDeg);n.setXYZ(a,c[0],c[1],c[2])}if(n.needsUpdate=!0,this.skyMesh)return;t.setAttribute("color",n);const s=new rn({vertexColors:!0,side:Ft,fog:!1,depthWrite:!1});this.skyGradientMaterial=s,this.skyMesh=new We(t,s),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const e=fm(this.observerElevationM);if(this.groundMesh&&e===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=e;const t=new df(this.groundRadius,48),i=new Oo({color:new oe(Xh,Xh,Xh),fog:!0});this.groundMesh=new We(t,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 e=this.groundMesh?.material;if(!e)return;const t=this.terrainMesh===void 0;e.depthWrite!==t&&(e.depthWrite=t,e.needsUpdate=!0)}cloudTransmission(e){const t=`${e.altitudeDeg.toFixed(1)}:${e.azimuthDeg.toFixed(1)}:${Math.round(this.cloudOffsetM.x/10)}:${Math.round(this.cloudOffsetM.z/10)}:${Math.round(this.observerElevationM)}:`+Object.entries(this.cloudLayerOffsetsM).map(([s,a])=>`${s}=${Math.round(a.x/10)},${Math.round(a.z/10)}`).join(";"),i=this.cloudTransmissionMemo.get(t);if(i!==void 0)return i;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const n=this.computeCloudTransmission(e);return this.cloudTransmissionMemo.set(t,n),n}cloudTransmissionMemo=new Map;computeCloudTransmission(e){const t=oi(e.altitudeDeg,e.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(t);let i=1;const n=this.lowerCloudCover();n>0&&(i*=1-Wt.alphaAt(t,Math.abs(this.cloudLayerOffset()),n,this.cloudFieldOffset)*i5);const s=this.weather.highCloudCover??0;return s>0&&(i*=1-Wt.alphaAt(t,Nl,s)*n5),Math.max(0,Math.min(1,i))}setBodyMesh(e,t,i,n,s){if(t.altitudeDeg<Hu){this.disposeMesh(this.bodyMeshes.get(e)),this.bodyMeshes.delete(e),this.disposeHitArea(e),this.disposeGlare(e),e==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:l}=oi(t.altitudeDeg,t.azimuthDeg,Zr),c=Is(t.altitudeDeg),h=this.cloudTransmission(t),d=new oe(n.r*c[0]*h,n.g*c[1]*h,n.b*c[2]*h);let u=this.bodyMeshes.get(e);u instanceof We?u.material.color.copy(d):(this.disposeMesh(u),u=new We(new yi(1,16,16),new rn({color:d,fog:!1})),this.celestialGroup.add(u),this.bodyMeshes.set(e,u)),u.scale.setScalar(i),u.position.set(a,o,l),this.setHitArea(e,a,o,l,i);const f=s-2.5*Math.log10(Math.max(h,.001));if(e==="sun"&&(this.sunCloudTransmission=h),e!=="sun"&&this.setGlare(e,a,o,l,f,d),e==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*p,o*p+this.celestialGroup.position.y,l*p),this.lensFlare||(this.lensFlare=C_(),this.lensFlare.uniforms.uOpacity.value=y5,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(c)}}setMoonMesh(e,t){const i="moon";if(e.magnitude>t||e.altitudeDeg<Hu){this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i);return}const{x:n,y:s,z:a}=oi(e.altitudeDeg,e.azimuthDeg,Zr),o=Is(e.altitudeDeg),l=new oe(o[0],o[1],o[2]),c=`${e.phase.phaseFraction<.5}:${Math.round(wo(e.phase.illuminatedFraction,0,1)*500)}`;let h=this.bodyMeshes.get(i);if(h instanceof Gr)h.userData.phaseKey!==c&&(h.material.map?.dispose(),h.material.map=Bm(e.phase),h.userData.phaseKey=c),h.material.color.copy(l);else{this.disposeMesh(h),h=new Gr(new ao({map:Bm(e.phase),color:l,fog:!1})),h.userData.phaseKey=c;const d=Yh*2;h.scale.set(d,d,1),this.celestialGroup.add(h),this.bodyMeshes.set(i,h)}h.position.set(n,s,a),this.setHitArea(i,n,s,a,Yh),this.setGlare(i,n,s,a,e.magnitude,l)}setHitArea(e,t,i,n,s){let a=this.hitAreas.get(e);if(!a){const l=new ao({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});a=new Gr(l),this.celestialGroup.add(a),this.hitAreas.set(e,a)}a.position.set(t,i,n);const o=s*t5;a.scale.set(o,o,1)}disposeHitArea(e){const t=this.hitAreas.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.hitAreas.delete(e))}setGlare(e,t,i,n,s,a){const o=Q3(s);if(o<=0){this.disposeGlare(e);return}const l=iE(o),c=this.glareSprites.get(e),h=c??new Gr(new ao({map:Z5(),transparent:!0,blending:Zi,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=rE(o),h.position.set(t,i,n),h.scale.set(l*2,l*2,1),c||(this.celestialGroup.add(h),this.glareSprites.set(e,h))}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.glareSprites.delete(e))}buildComet(e,t){const i=e&&`comet:${e.id}`;if(!e||!i||e.magnitude>t){this.disposeComet();return}this.cometKey&&this.cometKey!==i&&this.disposeComet();const n=lo(e.magnitude,t),s=co(n);this.cometKey=i,this.setBodyMesh(i,e.position,Kh*(.5+.5*n),new oe(s,s,s),e.magnitude),this.cometTail||(this.cometTail=new qi(Zr),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,n)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new Cn,this.iceHalos.setCloudOffset(this.cloudFieldOffset),this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object));const i=this.highCloudCover(),n=this.layeredClouds?.cirrusMask;if(this.iceHalos.setCloudOffset(n?.offset??this.cloudFieldOffset),i===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:Nl},0);return}const s=this.lowerCloudCover(),a=et.deckLitUntilDeg(et.DECK_HEIGHT_M),o=e.altitudeDeg>-a?e:t,l=et.strength(i,s,o.altitudeDeg,a)*(o===e?1:gm),{x:c,y:h,z:d}=oi(o.altitudeDeg,o.azimuthDeg,1),u=Is(o.altitudeDeg);this.iceHalos.update({x:c,y:h,z:d},o.altitudeDeg,l,[u[0],u[1],u[2]],{cover:n?.cover??i,layerHeight:n?.layerHeight??Nl},n?.iceCrystalAlignment??this.weather.iceCrystalAlignment??.65)}buildRainbow(e,t){this.rainbow||(this.rainbow=new cr,this.celestialGroup.add(this.rainbow.object));const i=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,n=e.altitudeDeg>0,s=n?e:t,a=this.lowerCloudCover(),o=gm*fi.moonlightShare(t.magnitude),l=fi.strength(i,a,s.altitudeDeg)*(n?1:o);if(l<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:c,y:h,z:d}=oi(s.altitudeDeg,s.azimuthDeg,1),u=Is(s.altitudeDeg);this.rainbow.update({x:c,y:h,z:d},l,[u[0],u[1],u[2]],n)}buildSkyGlow(e,t){if(!e.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Cs,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:i,observer:n}=e.frame,s=Ki.galactic(i,n),a=tn.directionOf(s.centre),o=tn.directionOf(s.rotation),l=tn.directionOf(s.pole),c=new ze().set(a.x,a.y,a.z,o.x,o.y,o.z,l.x,l.y,l.z),h=tn.directionOf(Ki.eclipticPole(i,n)),d=tn.directionOf(e.sun),u=d.clone().addScaledVector(h,-d.dot(h)).normalize();this.skyGlow.update({galactic:c,eclipticPole:h,sunLongitude:u,sunDirection:d,sunAltitudeDeg:e.sun.altitudeDeg,moon:{direction:tn.directionOf(e.moon),altitudeDeg:e.moon.altitudeDeg,phaseAngleDeg:Be.phaseAngleOf(e.moon.phase.illuminatedFraction)},skyColor:new P(t[0],t[1],t[2])})}static directionOf(e){const{x:t,y:i,z:n}=oi(e.altitudeDeg,e.azimuthDeg,1);return new P(t,i,n).normalize()}buildNovae(e,t){const i=new Set;for(const n of e){if(n.magnitude>t)continue;const s=`nova:${n.id}`;i.add(s);const a=lo(n.magnitude,t),o=co(a);this.setBodyMesh(s,n.position,Kh*(.5+.5*a),new oe(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(e,t){const i=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[],...this.novaKeys]);for(const n of e){if(n.magnitude>t)continue;i.add(n.body);const s=lo(n.magnitude,t),a=co(s),o=H5[n.body]??new oe(1,1,1),l=new oe(o.r*a,o.g*a,o.b*a),c=Kh*(.5+.5*s);this.setBodyMesh(n.body,n.position,c,l,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(e,t){if(this.namedStars=[],!e||e.catalog.count===0){this.disposeStarTiers(),this.syncAnimationLoop();return}const{catalog:i,date:n,observer:s}=e,a=new fn(n,s),o=td(1337),l=[];for(let c=0;c<i.count;c++){const h=i.mag[c];if(h>t)break;const{altitudeDeg:d,azimuthDeg:u}=a.position(i.ra[c],i.dec[c]);if(d<mm)continue;const{x:f,y:p,z:v}=oi(d,u,qh);l.push({x:f,y:p,z:v,brightness:lo(h,t),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const c of h_){if(c.mag>t)continue;const{altitudeDeg:h,azimuthDeg:d}=a.position(c.raHours,c.decDeg);if(h<mm)continue;const{x:u,y:f,z:p}=oi(h,d,qh);this.namedStars.push({star:c,direction:new P(u,f,p).normalize(),altitudeDeg:h})}this.starTiers=vf.map((c,h)=>{const d=l.filter(M=>u1(M.brightness)===h),u=new Float32Array(d.length*3),f=new Float32Array(d.length),p=new Float32Array(d.length),v=new Float32Array(d.length);d.forEach((M,w)=>{u[w*3]=M.x,u[w*3+1]=M.y,u[w*3+2]=M.z,f[w]=M.brightness,p[w]=M.phase,v[w]=M.speedFactor});const m=new Tt;m.setAttribute("position",new ht(u,3));const g=new ht(new Float32Array(d.length*3),3);m.setAttribute("color",g);let x=this.starTiers[h]?.points;if(x)x.geometry.dispose(),x.geometry=m;else{const M=new hf({vertexColors:!0,size:c.size,sizeAttenuation:!1,fog:!1});Ls.apply(M),x=new vo(m,M),this.celestialGroup.add(x)}return{points:x,colorAttribute:g,brightness:f,phase:p,speedFactor:v}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(e){for(const t of this.starTiers){const i=t.colorAttribute.array;for(let n=0;n<t.brightness.length;n++){const s=dE(t.brightness[n],{phase:t.phase[n],speedFactor:t.speedFactor[n]},e),a=co(t.brightness[n])*s;i[n*3]=a,i[n*3+1]=a,i[n*3+2]=a}t.colorAttribute.needsUpdate=!0}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new wc(this.celestialGroup,$h,this.cloudRendering)),this.disposeCirrus(),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 e=this.lowerCloudCover();if(e<=0){this.disposeCloudSystem();return}const t=this.weather.cloudDarkness,i=new oe(Zs[0]+(jh[0]-Zs[0])*t,Zs[1]+(jh[1]-Zs[1])*t,Zs[2]+(jh[2]-Zs[2])*t);if(this.cloudMesh&&this.cloudUniforms){this.cloudUniforms.coverage.value=e,this.cloudUniforms.baseColor.value.copy(i),this.syncCloudLayer(),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}this.disposeCloudSystem();const{material:n,uniforms:s}=fu(i,e,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=pu($h);this.cloudMesh=new We(a,n),this.faceCloudDeck(this.cloudMesh,this.cloudLayerOffset()),this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(e=>e.type!=="cirrus").reduce((e,t)=>e*(1-t.coverage),1):this.weather.lowerCloudCover??this.weather.cloudCover}highCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(e=>e.type==="cirrus").reduce((e,t)=>e*(1-t.coverage),1):this.weather.highCloudCover}buildCirrus(){const e=this.weather.highCloudCover??0;if(this.layeredClouds||e<=0){this.disposeCirrus();return}if(this.cirrusMesh&&this.cirrusUniforms){this.cirrusUniforms.coverage.value=e,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const{material:t,uniforms:i}=fu(new oe(...Zs),e,Nl,1);this.cirrusMaterial=t,this.cirrusUniforms=i,i.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new We(pu($h*1.04),t),this.cirrusMesh.renderOrder=Sm-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 e=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(e)),this.cloudMesh&&this.faceCloudDeck(this.cloudMesh,e)}faceCloudDeck(e,t){const i=t<0;e.scale.y=i?-1:1,e.renderOrder=i?wc.deckOrder(!0,0,1):Sm}cloudLayerOffset(){const t=((this.weather.cloudBaseM??1e3)-this.observerElevationM)*Zh;return Math.sign(t||1)*Math.max(Math.abs(t),w5)}updateCloudLighting(e,t){const i=[this.cloudUniforms,this.cirrusUniforms].filter(d=>d!==void 0);if(i.length===0&&!this.layeredClouds)return;const{x:n,y:s,z:a}=oi(e.altitudeDeg,e.azimuthDeg,1),o=Is(e.altitudeDeg),l=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*ki)),c=this.lightningLevel*B5,h=new oe(t[0]+In.r*c,t[1]+In.g*c,t[2]+In.b*c);this.layeredClouds?.setLighting(new P(n,s,a),new oe(o[0]*l,.96*o[1]*l,.88*o[2]*l),h,h);for(const d of i)d.sunDir.value.set(n,s,a),d.sunColor.value.setRGB(o[0]*l,.96*o[1]*l,.88*o[2]*l),d.ambientColor.value.copy(h)}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}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const e=this.weather.precipitationType;if(e==="none")return;if(e==="rain"){this.buildRain();return}const t=Em[e],i=t.poolSize,n=td(9001),s=new Float32Array(i*3),a=new Float32Array(i),o=new Float32Array(i),l=new Float32Array(i),c=new Float32Array(i),h=new Float32Array(i),d=new Float32Array(i),u=new Float32Array(i),f=new Float32Array(i),p=new Float32Array(i);for(let M=0;M<i;M++){const w=n()*Math.PI*2,S=n()*t.radiusM;s[M*3]=Math.cos(w)*S,s[M*3+1]=na+n()*(t.topYM-na),s[M*3+2]=Math.sin(w)*S,a[M]=n()*Math.PI*2,o[M]=.7+n()*.6,l[M]=.6+n()*.8,c[M]=.4+n()*1.2}const v=new Tt;v.setAttribute("position",new ht(s,3)),v.setDrawRange(0,ed(i,this.weather.precipitationIntensity));const m={uSize:{value:t.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:t.opacity},uColor:{value:t.color},uHazeColor:{value:new oe(...this.baseFogColor)},uTexture:{value:G5(e)},uNearFocusDistance:{value:Rm},uHazeDistance:{value:t.radiusM*Pm}},g=new Ot({uniforms:m,vertexShader:K5,fragmentShader:$5,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const x=new vo(v,g);x.renderOrder=Jh,this.scene.add(x),this.precipitationPoints=x,this.precipitationPositions=s,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=l,this.precipitationWobbleAmpJitter=c,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=d,this.precipitationBounceDuration=u,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=p}updatePrecipitation(e,t){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),t<=0))return;const i=this.weather.precipitationType;if(i==="none"||i==="rain")return;const n=Em[i],s=this.weather.windDirectionDeg*ki,a=Math.sin(s)*this.weather.windSpeed*n.driftSensitivity,o=-Math.cos(s)*this.weather.windSpeed*n.driftSensitivity,l=this.precipitationPositions,c=this.precipitationPhase,h=this.precipitationSpeedJitter,d=this.precipitationWobbleFreqJitter,u=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,p=this.precipitationBounceHeight,v=this.precipitationBounceDuration,m=this.precipitationBounceVelX,g=this.precipitationBounceVelZ,x=i==="snow"&&d&&u,M=i==="hail"&&f&&p&&v&&m&&g;for(let w=0,S=0;w<l.length;w+=3,S++){if(M&&f[S]>0){if(f[S]-=t,f[S]<=0){const y=Math.random()*Math.PI*2,T=Math.sqrt(Math.random())*n.radiusM;l[w]=Math.cos(y)*T,l[w+1]=n.topYM,l[w+2]=Math.sin(y)*T,f[S]=0}else{const y=1-f[S]/v[S];l[w+1]=na+Math.sin(Math.PI*y)*p[S],l[w]=Fl(l[w]+(a+m[S])*t,n.radiusM),l[w+2]=Fl(l[w+2]+(o+g[S])*t,n.radiusM)}continue}let _=0,D=0;if(x){const y=R5*d[S],T=P5*u[S];_=Math.sin(e*y*Math.PI*2+c[S])*T,D=Math.sin(e*y*Math.PI*2+c[S]+Math.PI/2)*T}if(l[w]+=(a+_)*t,l[w+1]-=n.fallSpeedMPerS*h[S]*t,l[w+2]+=(o+D)*t,l[w]=Fl(l[w],n.radiusM),l[w+2]=Fl(l[w+2],n.radiusM),l[w+1]<na){if(M){p[S]=Fm*(.2+Math.random()*1.6),v[S]=L5*(.5+Math.random()),f[S]=v[S];const A=Math.random()*Math.PI*2,I=k5*(p[S]/Fm);m[S]=Math.cos(A)*I,g[S]=Math.sin(A)*I,l[w+1]=na;continue}const y=Math.random()*Math.PI*2,T=Math.sqrt(Math.random())*n.radiusM;l[w]=Math.cos(y)*T,l[w+1]=n.topYM,l[w+2]=Math.sin(y)*T}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=Im(this.weather.precipitationIntensity);this.rainSystem=T_({count:_m,radiusM:to,heightM:x5,bottomYM:Tm,overallSpeed:S5,color:_5,opacity:.85,visibleCount:ed(_m,this.weather.precipitationIntensity),speedStreak:I5(e),pixelSize:km,seed:9001,nearFocusDistanceM:Rm,hazeDistanceM:to*Pm,hazeColor:new oe(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=Jh,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=td(4242),t=new Float32Array(Jr*3),i=new Float32Array(Jr),n=new Float32Array(Jr),s=new Float32Array(Jr);for(let h=0;h<Jr;h++){const d=e()*Math.PI*2,u=Math.sqrt(e())*to;t[h*3]=Math.cos(d)*u,t[h*3+1]=Tm,t[h*3+2]=Math.sin(d)*u,n[h]=Um(Dm,Cm),i[h]=e()*n[h],s[h]=i[h]/n[h]}const a=new Tt;a.setAttribute("position",new ht(t,3));const o=new ht(s,1);a.setAttribute("aLife",o),a.setDrawRange(0,ed(Jr,this.weather.precipitationIntensity));const l=new Ot({uniforms:{uMaxSize:{value:D5},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:C5},uTexture:{value:X5()}},vertexShader:q5,fragmentShader:Y5,transparent:!0,depthWrite:!1}),c=new vo(a,l);c.renderOrder=Jh,this.scene.add(c),this.rainSplashSystem={points:c,positions:t,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 e=this.rainSystem;if(!e)return;const t=this.weather.windDirectionDeg*ki;e.uniforms.uDropVelocity.value.set(Math.sin(t)*this.weather.windSpeed,-Im(this.weather.precipitationIntensity),-Math.cos(t)*this.weather.windSpeed);const i=this.renderer.getSize(this.rainViewportSize);e.uniforms.uAspect.value=i.x/Math.max(i.y,1)}updateRain(e){const t=this.rainSystem;if(!t)return;t.uniforms.uTime.value+=e,t.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const i=this.weather.windDirectionDeg*ki,n=Math.sin(i)*this.weather.windSpeed,s=-Math.cos(i)*this.weather.windSpeed,a=to,o=c=>(c%(a*2)+a*3)%(a*2)-a;t.uniforms.uWindOffset.value.set(o(t.uniforms.uWindOffset.value.x+n*e),o(t.uniforms.uWindOffset.value.y+s*e)),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 c=Nm+(1-Nm)*(1-l),h=Om+(1-Om)*(1-l);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=km*c*(.5+.5*h)}this.updateRainSplashes(e)}updateRainSplashes(e){const t=this.rainSplashSystem;if(!t||e<=0)return;const{positions:i,life:n,duration:s,lifeAttribute:a}=t,o=a.array;for(let l=0,c=0;l<i.length;l+=3,c++){if(n[c]+=e,n[c]>=s[c]){const h=Math.random()*Math.PI*2,d=Math.sqrt(Math.random())*to;i[l]=Math.cos(h)*d,i[l+2]=Math.sin(h)*d,s[c]=Um(Dm,Cm),n[c]=0}o[c]=n[c]/s[c]}t.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}setLightning(e){this.lightningFlashes=e}updateLightning(e){let t,i=0;if(this.lightningArmed)for(const o of this.lightningFlashes){if(o.t>e)break;const l=Qt.brightnessAt(o,e);l>i&&(t=o,i=l)}const n=t?Math.min(1,Math.max(.1,(F5/t.distanceM)**2)):0,s=i*n*(t?.cloudToGround?1:.6);if(s===this.lightningLevel&&!t?.cloudToGround)return;if(this.lightningLevel=s,this.scene.fog){const o=this.scene.fog,l=Math.min(1,s);o.color.setRGB(this.baseFogColor[0]+(In.r-this.baseFogColor[0])*l,this.baseFogColor[1]+(In.g-this.baseFogColor[1])*l,this.baseFogColor[2]+(In.b-this.baseFogColor[2])*l)}if(this.skyMesh){const o=s*U5;this.skyMesh.material.color.setRGB(1+o*In.r,1+o*In.g,1+o*In.b)}if(this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.lightningLight.intensity=s*z5,t){const{x:o,y:l,z:c}=oi(25,t.azimuthDeg,Zr);this.lightningLight.position.set(o,l,c)}this.lightningBolt||(this.lightningBolt=new ca(Zr*.95),this.celestialGroup.add(this.lightningBolt.object));const a=this.weather.cloudBaseM??1500;this.lightningBolt.set(t,i,a),this.render()}buildCompassLabels(){const e=fa(navigator.languages,d5),t=h5[e];this.compassSprites=c5.map((i,n)=>{const s=t[n],a=new ao({map:J5(s),depthTest:!1,fog:!1}),o=new Gr(a),{x:l,y:c,z:h}=oi(0,i,bm);return o.position.set(l,c,h),o.scale.set(Ol,Ol,1),o.renderOrder=p5,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const e=this.camera.fov*Math.PI/360,t=wm*Math.PI/360,i=Ol*Math.tan(e)/Math.tan(t);for(const n of this.compassSprites)n.scale.set(i,i,1)}disposeCompassLabels(){for(const e of this.compassSprites)e.removeFromParent(),e.material.map?.dispose(),e.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const e of this.starTiers)this.disposeMesh(e.points);this.starTiers=[]}disposeMesh(e){if(!e)return;e.removeFromParent(),"geometry"in e&&e.geometry.dispose();const t=e.material;for(const i of Array.isArray(t)?t:[t]){const n=i.map;n&&n.dispose(),i.dispose()}}}const ki=Math.PI/180;function wo(r,e,t){return Math.max(e,Math.min(t,r))}function Um(r,e){return r+Math.random()*(e-r)}function Fl(r,e){return(r%(e*2)+e*3)%(e*2)-e}let Ul,Bl;function G5(r){switch(r){case"snow":return V5();case"hail":return W5()}}function V5(){if(Ul)return Ul;const r=64,e=document.createElement("canvas");e.width=r,e.height=r;const t=e.getContext("2d"),i=t.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)"),t.fillStyle=i,t.fillRect(0,0,r,r),Ul=new Kn(e),Ul}function W5(){if(Bl)return Bl;const r=64,e=document.createElement("canvas");e.width=r,e.height=r;const t=e.getContext("2d"),i=t.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)"),t.fillStyle=i,t.fillRect(0,0,r,r),Bl=new Kn(e),Bl}let zl;function X5(){if(zl)return zl;const r=64,e=document.createElement("canvas");e.width=r,e.height=r;const t=e.getContext("2d"),i=t.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)"),t.fillStyle=i,t.fillRect(0,0,r,r),zl=new Kn(e),zl}const q5=`
7865
+ `})}get supported(){return this.tables.supported}get ready(){return this.hasViews}get ambient(){return this.ready?this.ambientColours:void 0}setInstrument(e,t){const i=e?10**(.4*t):1;i===this.exposureScale&&this.seenByEye===!e||(this.exposureScale=i,this.seenByEye=!e,this.material.uniforms.uExposureScale.value=i,this.applyAdaptation(this.adaptingLuminance),this.onChange())}setConditions(e){this.tables.setMedium(new Ze(e)),this.tables.ready||(this.drawnKey="")}advance(e){!this.supported||this.tables.ready||this.tables.advance(e)&&this.state&&this.draw(this.state)}invalidate(){this.tables.invalidate(),this.drawnKey="",this.hasViews=!1}update(e){this.state=e,this.tables.ready?this.draw(e):this.hasViews||this.applyAdaptation(ri.predictedZenithLuminance(e))}dispose(){this.tables.dispose(),this.material.dispose()}draw(e){const t=[e.altitudeM.toFixed(0),e.sun.altitudeDeg.toFixed(3),e.moon.altitudeDeg.toFixed(3)].join(":"),i=this.material.uniforms;if(i.uSunAzimuth.value.copy(ri.azimuthVector(e.sun.azimuthDeg)),i.uMoonAzimuth.value.copy(ri.azimuthVector(e.moon.azimuthDeg)),i.uMoonScale.value=10**(-.4*(e.moon.magnitude-ri.SUN_MAGNITUDE)),i.uObserverRadius.value=Ze.GROUND_RADIUS_M+Math.max(e.altitudeM,2),t!==this.drawnKey){this.tables.renderSkyViews(e.altitudeM,e.sun.altitudeDeg,e.moon.altitudeDeg);const n=!this.hasViews;this.hasViews=!0,this.drawnKey=t,n&&!this.ambientColours&&this.adaptFromViews(this.tables.readSkyViewNow("sun"),this.tables.readSkyViewNow("moon"),e),this.readBack()}this.onChange()}async readBack(){if(this.reading){this.readAgain=!0;return}this.reading=!0;try{const[e,t]=await Promise.all([this.tables.readSkyView("sun"),this.tables.readSkyView("moon")]),i=this.state;i&&this.adaptFromViews(e,t,i)}finally{this.reading=!1}this.readAgain&&(this.readAgain=!1,this.readBack())}adaptFromViews(e,t,i){const n=10**(-.4*(i.moon.magnitude-ri.SUN_MAGNITUDE)),s=ri.airglowXyzs(),a=(d,u)=>{const f=(90-d)*Math.PI/180,p=ze.skyViewUv(i.altitudeM,f,ri.azimuthBetween(u,i.sun.azimuthDeg)),v=ze.skyViewUv(i.altitudeM,f,ri.azimuthBetween(u,i.moon.azimuthDeg)),m=ri.bilinear(e,p.u,p.v),g=ri.bilinear(t,v.u,v.v),x=d>0?ri.airglowFactor(d):0;return[0,1,2,3].map(M=>m[M]+n*g[M]+s[M]*x)};let o=0,l=0;for(let d=5;d<90;d+=10){const u=Math.cos(d*Math.PI/180);for(let f=0;f<360;f+=30)o+=u*Math.log(Math.max(a(d,f)[1],1e-9)),l+=u}this.applyAdaptation(Math.exp(o/l));const c=(d,u)=>{const f=this.exposureScale,[p,v,m,g]=a(d,u),x=this.adaptingLuminance*f;return ot.displayOf([p*f,v*f,m*f],g*f,x,this.seenByEye?ot.rodShare(x):0)},h=[0,0,0];for(let d=0;d<360;d+=20){const u=c(2,d);for(let f=0;f<3;f++)h[f]+=u[f]/18}this.ambientColours={zenith:c(90,0),horizon:h},this.onChange()}applyAdaptation(e){this.adaptingLuminance=e;const t=e*this.exposureScale;this.material.uniforms.uRodShare.value=this.seenByEye?ot.rodShare(t):0,this.material.uniforms.uSemiSaturationN.value=ot.semiSaturation(t)**ot.RESPONSE_EXPONENT}static predictedZenithLuminance(e){const t=n=>90-n.altitudeDeg,i=Be.magPerArcsec2({altitudeDeg:e.sun.altitudeDeg,separationDeg:t(e.sun)},{phaseAngleDeg:e.moon.phaseAngleDeg,altitudeDeg:e.moon.altitudeDeg,separationDeg:t(e.moon)},90);return Be.toNanolamberts(i)*ri.CANDELAS_PER_NANOLAMBERT}static CANDELAS_PER_NANOLAMBERT=1e-5/Math.PI;static airglowXyzs(){const e=Be.toNanolamberts(Be.AIRGLOW_MAG_PER_ARCSEC2)*ri.CANDELAS_PER_NANOLAMBERT;return[e*.3127/.329,e,e*(1-.3127-.329)/.329,e]}static airglowFactor(e){const t=Math.cos(e*Math.PI/180)**2,i=Ze.GROUND_RADIUS_M/(Ze.GROUND_RADIUS_M+ri.AIRGLOW_LAYER_ALTITUDE_M),n=1/Math.sqrt(Math.max(1-i*i*t,1e-4)),s=1/Math.sqrt(Math.max(1-.96*t,.001));return n*10**(-.4*Be.EXTINCTION_PER_AIR_MASS*(s-1))}static azimuthVector(e){const t=e*Math.PI/180;return new Te(Math.sin(t),-Math.cos(t))}static azimuthBetween(e,t){const i=Math.abs(e-t)%360;return(i>180?360-i:i)*Math.PI/180}static bilinear(e,t,i){const n=ze.SKY_VIEW_WIDTH,s=ze.SKY_VIEW_HEIGHT,a=Math.min(Math.max(t*n-.5,0),n-1),o=Math.min(Math.max(i*s-.5,0),s-1),l=Math.floor(a),c=Math.floor(o),h=Math.min(l+1,n-1),d=Math.min(c+1,s-1),u=a-l,f=o-c,p=(v,m,g)=>e[(v*n+m)*4+g];return[0,1,2,3].map(v=>(p(c,l,v)*(1-u)+p(c,h,v)*u)*(1-f)+(p(d,l,v)*(1-u)+p(d,h,v)*u)*f)}}class ur{static DRY_OPTICAL_DEPTH=.08;static GROWTH_EXPONENT=.3;static MAX_RELATIVE_HUMIDITY=.95;static OPTICAL_DEPTH_STEP=.02;static relativeHumidity(e,t){const i=n=>Math.exp(17.625*n/(243.04+n));return Math.min(Math.max(i(t)/i(e),0),1)}static opticalDepth(e){const t=Math.min(Math.max(e,0),ur.MAX_RELATIVE_HUMIDITY);return ur.DRY_OPTICAL_DEPTH*(1-t)**-.3}static steppedOpticalDepth(e){const t=ur.OPTICAL_DEPTH_STEP;return Math.round(ur.opticalDepth(e)/t)*t}}function j_(r,e){return JSON.stringify(r.cloudLayers)===JSON.stringify(e.cloudLayers)&&r.cloudCover===e.cloudCover&&r.cloudDarkness===e.cloudDarkness&&r.cloudBaseM===e.cloudBaseM&&r.highCloudCover===e.highCloudCover&&r.iceCrystalAlignment===e.iceCrystalAlignment&&r.lowerCloudCover===e.lowerCloudCover&&r.relativeHumidity===e.relativeHumidity&&r.precipitationType===e.precipitationType&&r.precipitationIntensity===e.precipitationIntensity&&r.windDirectionDeg===e.windDirectionDeg&&r.windSpeed===e.windSpeed&&r.storm===e.storm}const kl=900,Wh=1,um=.5,fo=900,Q_=6371e3,e5=3e4;function fm(r){const e=Math.sqrt(2*Q_*Math.max(r,0));return Math.max(fo,Math.min(e,e5))}const Xh=.5,qh=850,pm=.03,Zr=850,Yh=4,Kh=1.5,mm=-1,t5=6,Hu=-4,gm=.2,Nl=2600,i5=.97,n5=.38,vm=Hu,s5=3,r5=.15,a5=.6,o5=40,l5=30,c5=[0,45,90,135,180,225,270,315],h5={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},d5=["en","fr"],u5=2,f5=16,ym=2500,bm=880,Ol=40,wm=60,p5=10,m5=1,g5=150,v5=55,y5=.5,b5=2.05,Mm=.265,xm=[[0,0],...Array.from({length:8},(r,e)=>{const t=e*Math.PI/4;return[Math.cos(t)*Mm,Math.sin(t)*Mm]})],$h=700,Zh=250/1e3,w5=12,Sm=5,Jh=6,Zs=[.92,.92,.95],jh=[.15,.15,.19],Em={snow:{fallSpeedMPerS:2,size:.3,color:new oe(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new oe(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},na=0,Qh=0,M5=150,_m=3e3,to=20,x5=15,Tm=na,S5=40,Am=1,E5=9;function Im(r){return Am+(E5-Am)*r}const _5=new oe(.75,.82,.92),T5=10,A5=.5;function I5(r){return wo(r/T5,A5,1)}const Jr=200,Dm=.18,Cm=.32,D5=.35,C5=new oe(.85,.9,.98),Rm=5,Pm=.85,Lm=.01;function ed(r,e){return Math.round(r*(Lm+(1-Lm)*e))}const km=230,Nm=.7,Om=.05,R5=.6,P5=.7,L5=.15,Fm=.35,k5=3,N5=1/12,O5=.5,In=new oe(.82,.86,1),F5=2500,U5=1.6,B5=1.2,z5=2.2,H5={Venus:new oe(1,.96,.85),Mars:new oe(1,.55,.4),Jupiter:new oe(.95,.87,.72),Saturn:new oe(.92,.86,.68)};class tn{renderer;scene=new Ca;phenomena=new hn(this.scene);references=new ar(this.scene,()=>this.render());camera;celestialGroup=new ci;skyMesh;skyGradientMaterial;scatteredSky;lastAstronomy;skyColoursStale=!1;scatteredSkyFrameId=null;skyHoldUntilMs=void 0;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;decorModelProvider=jl[0].create();decorModelToken=0;decorModelCredits=new Map;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;decorReferencePose;decorCurrentPose;decorTime=0;celestialLight=new a0(16777215,0);celestialLightTarget=new _t;skyLight=new yb(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 Th;weather=ag;observerElevationM=0;siteElevationM=0;groundRadius=fo;terrainRadius=fo;cloudRendering="volume";layeredClouds;cloudLayerOffsetsM={};cloudOffsetM=new P;cloudFieldOffset=new P;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new P;rainLastVerticalFacing=-1;rainViewportSize=new Te;lightningArmed=!1;lightningFlashes=[];lightningLevel=0;lightningBolt;lightningLight=new a0(16777215,0);baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new P;sunVisible=!1;lensFlareScratch=new P;sunOcclusionRaycaster=new Th;sunOcclusionDirectionScratch=new P;sunOcclusionRightScratch=new P;sunOcclusionUpScratch=new P;ufoOcclusionRaycaster=new Th;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;static exposureInstantsPerFrame(e){return Math.max(3,Math.round(6e6/Math.max(1,e)))}exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;meteorSystem;cometTail;satelliteField;iceHalos;rainbow;skyGlow;cometKey;novaKeys=new Set;constructor(e,t=v2()){this.renderer=new D3({canvas:e,antialias:!0}),this.resolution=new Dt(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=po,this.camera=new zi(60,e.width/Math.max(e.height,1),.1,kl*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=t,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-120,this.celestialLight.shadow.camera.right=120,this.celestialLight.shadow.camera.top=120,this.celestialLight.shadow.camera.bottom=-120,this.celestialLight.shadow.camera.near=1,this.celestialLight.shadow.camera.far=1e3,this.celestialLight.shadow.bias=-.0015,this.celestialLight.target=this.celestialLightTarget,this.lightningLight.color.copy(In),this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight,this.lightningLight),this.scene.add(this.celestialGroup);const i=new ri(this.renderer,()=>{this.skyColoursStale=!0,this.render()});i.supported?this.scatteredSky=i:i.dispose()}get currentTerrainAttribution(){return this.terrainAttribution}resize(e,t){this.cssSize.width=e,this.cssSize.height=t,this.renderer.setSize(e,t,!1),this.camera.aspect=e/Math.max(t,1),this.camera.updateProjectionMatrix(),this.render()}setCloudRendering(e){e!==this.cloudRendering&&(this.cloudTransmissionMemo.clear(),this.cloudRendering=e,this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.buildClouds(),this.buildCirrus(),this.render())}setCloudOffset(e,t={}){this.cloudOffsetM.set(e.x,0,e.z),this.cloudLayerOffsetsM=t,this.layeredClouds?.setOffsets(e,t),this.cloudFieldOffset.set(e.x*Zh,0,e.z*Zh);for(const i of[this.cloudUniforms,this.cirrusUniforms])i?.fieldOffset.value.copy(this.cloudFieldOffset);this.iceHalos?.setCloudOffset(this.layeredClouds?.cirrusMask?.offset??this.cloudFieldOffset)}setObserverPose(e){const t=((e.rollDeg??0)+this.gaitOffset.rollDeg)*ki,i=(e.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*ki;if(e.headingDeg!==void 0?this.camera.rotation.set(i,-(e.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*ki,t,"YXZ"):this.camera.rotation.set(i,this.camera.rotation.y,t,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(fm(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/fo),this.camera.far=Math.max(kl*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&e.lat!==void 0&&e.lng!==void 0){const n=mi(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=n.x,this.terrainMesh.position.z=n.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+e.elevationM,this.camera.position.y=this.poseCameraY,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==e.fovDeg&&(this.camera.fov=e.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(e){this.terrainProviders=e,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(e,t,i){if(e===void 0||t===void 0)return;const n=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-n)<n*.1){const{x:l,z:c}=mi(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(l*l+c*c)<g5*(n/fo))return}const s=this.terrainOrigin,a=this.terrainRadius;this.terrainOrigin={lat:e,lng:t},this.terrainRadius=n;const o=++this.terrainBuildToken;g_(e,t,this.terrainProviders,n).then(({mesh:l,attribution:c,originElevationM:h})=>{if(o!==this.terrainBuildToken)return;this.setSiteElevation(h??0);const d=this.terrainMesh,u=s?mi(e,t,s.lat,s.lng):void 0;d&&u&&Math.hypot(u.x,u.z)<=a&&(l.position.y=d.position.y+this.groundYOfPatch(d,u.x,u.z)),this.disposeMesh(this.terrainMesh),l.renderOrder=m5,this.terrainMesh=l,this.compileNextFrameOffThread(),this.terrainAttribution=c,this.scene.add(l),this.applyGroundDepthWrite(),this.decorCurrentPose&&(this.setObserverPose(this.decorCurrentPose),this.updateDecorAnchoring(this.decorReferencePose,this.decorCurrentPose,this.decorTime)),this.render(),i?.()}).catch(l=>{console.warn("Terrain build failed, keeping the flat ground fallback:",l),i?.()})}setShowCompass(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}applyLensFlareTint(e){if(!this.lensFlare)return;const t=v5*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(t*e[0],t*e[1],t*e[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const e=this.lastSunPosition?.altitudeDeg??-90,t=oE(e)*this.sunCloudTransmission*this.sunUnhiddenFraction,i=Is(e);this.lensFlare.uniforms.uDazzleColour.value.setRGB(i[0],i[1],i[2]),this.lensFlare.uniforms.uVeilStrength.value=b5**2*Math.max(0,t)}setCompassHovered(e){this.compassHovered!==e&&(this.compassHovered=e,this.updateCompassVisibility())}setCompassForced(e){this.compassForced!==e&&(this.compassForced=e,this.updateCompassVisibility())}updateCompassVisibility(){const e=this.compassHovered||this.compassForced;if(this.compassSprites.some(t=>t.visible!==e)){for(const t of this.compassSprites)t.visible=e;this.developingExposure?this.exposureInstantsDone>0&&this.presentExposure():this.render()}}setWeather(e){this.cloudTransmissionMemo.clear(),!j_(this.weather,e)&&(this.weather=e,this.scatteredSky?.setConditions({aerosolOpticalDepth:e.relativeHumidity===void 0?void 0:ur.steppedOpticalDepth(e.relativeHumidity)}),this.pumpScatteredSky(),this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=e.storm&&e.cloudDarkness>=O5,this.syncAnimationLoop(),this.render())}setDecor(e){if(this.decorObjects!==e){this.decorObjects=e,this.decorModelToken++,this.decorModelCredits.clear();for(const t of this.decorGroups.values())t.removeFromParent(),li.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const i=li.build(t,t.lit??!1);this.scene.add(i),this.decorGroups.set(t.id,i),t.kind==="streetlight"&&this.addStreetlightLight(t.id,i),this.loadDecorModel(t,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0}}setDecorModelProvider(e){this.decorModelProvider=e;const t=this.decorObjects;this.decorObjects=[],this.setDecor(t)}get currentDecorModelCredits(){return[...this.decorModelCredits.values()]}async loadDecorModel(e,t){const i=e.model;if(!(!i||!li.usesModel(e)))try{const n=i.url?void 0:i.id?await this.decorModelProvider.entry(i.id):void 0,s=i.url??n?.url,a=i.credit??n?.credit;if(!s||!a)return;const o=await $_(s);if(t!==this.decorModelToken)return;const l=this.decorGroups.get(e.id);if(!l)return;li.applyModel(l,e,o,{headingOffsetDeg:i.headingOffsetDeg??n?.headingOffsetDeg,depictedSizeM:n?.sizeM}),this.decorModelCredits.set(e.id,a),this.render()}catch(n){console.warn(`Keeping the built-in shape for decor "${e.id}":`,n)}}updateDecorAnchoring(e,t,i=0){this.decorReferencePose=e,this.decorCurrentPose=t,this.decorTime=i;const n=e?.lat!==void 0&&e.lng!==void 0&&t?.lat!==void 0&&t?.lng!==void 0?mi(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},s=this.decorObjects.find(c=>c.witnessSide!==void 0&&ra(c.kind));if(this.terrainMesh&&this.terrainOrigin&&t?.lat!==void 0&&t.lng!==void 0){const c=mi(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=c.x-(s?0:this.gaitOffset.eastM),this.terrainMesh.position.z=c.z+(s?0:this.gaitOffset.northM)}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 c=li.occupantView(s),h=-(s.headingDeg??0)*ki,d=c.x*Math.cos(h)+c.z*Math.sin(h),u=-c.x*Math.sin(h)+c.z*Math.cos(h),f=s.eastM+n.x,p=-s.northM+n.z;a.x=-(f+d),a.z=-(p+u),this.camera.position.y=this.groundYUnder(f,p)+c.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*ki,-(c.headingDeg+this.indoorLookYawDeg)*ki,0,"YXZ")}for(const c of this.decorObjects){const h=this.decorGroups.get(c.id);if(!h)continue;const d=_a(c,i),u=d.eastM+n.x+a.x,f=-d.northM+n.z+a.z,p=this.terrainMesh,v=`${p?.geometry.uuid}:${(u-(p?.position.x??0)).toFixed(3)}:${(f-(p?.position.z??0)).toFixed(3)}:${(p?.position.y??0).toFixed(3)}:${d.headingDeg}:${d.altitudeM}`;if(h.userData.footprintKey!==v&&(h.userData.footprintGroundY=this.groundUnderFootprint(c,u,f,d.headingDeg,d.altitudeM),h.userData.footprintKey=v),h.position.set(u,h.userData.footprintGroundY+d.altitudeM,f),c.kind==="crop"){const m=Math.hypot(u,f);h.visible=m<=M5}if(d.headingDeg!==void 0&&(h.rotation.y=-d.headingDeg*ki),c.kind==="crop"&&h.visible){const m=this.terrainMesh,g=[m?.geometry.uuid,u-(m?.position.x??0),f-(m?.position.z??0),h.position.y-(m?.position.y??0),d.headingDeg,d.altitudeM].map(x=>typeof x=="number"?x.toFixed(4):x).join(":");h.userData.cropGroundKey!==g&&(li.fitCropToGround(h,(x,M)=>this.groundYUnder(x,M)+d.altitudeM),h.userData.cropGroundKey=g)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const l=Math.max(kl*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-l)>1&&(this.camera.far=l,this.camera.updateProjectionMatrix())}groundYUnder(e,t){const i=this.terrainMesh;return i?i.position.y+this.groundYOfPatch(i,e-i.position.x,t-i.position.z):Qh}groundYOfPatch(e,t,i){const n=e.geometry.getAttribute("position"),s=Math.round(Math.sqrt(n.count));if(s<2||s*s!==n.count)return Qh;const a=n.getX(0),o=n.getX(s-1),l=n.getZ(0),c=n.getZ((s-1)*s),h=wo((t-a)/(o-a)*(s-1),0,s-1),d=wo((i-l)/(c-l)*(s-1),0,s-1);if(!Number.isFinite(h)||!Number.isFinite(d))return Qh;const u=Math.min(Math.floor(h),s-2),f=Math.min(Math.floor(d),s-2),p=h-u,v=d-f,m=(S,_)=>n.getY(S*s+_),g=m(f,u),x=m(f,u+1),M=m(f+1,u),w=m(f+1,u+1);return p+v<=1?g+(x-g)*p+(M-g)*v:w+(M-w)*(1-p)+(x-w)*(1-v)}groundUnderFootprint(e,t,i,n,s=0){return li.groundUnderFootprint(e,t,i,n,(a,o)=>this.groundYUnder(a,o),s)}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(e){this.gaitOffset=e}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(e,t){this.lookYawDeg=e,this.lookPitchDeg=t}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(e,t){this.indoorLookYawDeg=e,this.indoorLookPitchDeg=t}updateDecorLitState(e,t=0){for(const i of this.decorObjects){const n=this.decorGroups.get(i.id);if(n&&i.lights?.length&&li.setLights(n,i.lights,e,n.position.distanceTo(this.camera.position),t),i.kind!=="streetlight"&&i.kind!=="vehicle")continue;const s=this.decorGroups.get(i.id);if(!s)continue;const a=sc(i,e);li.setLit(s,i.kind,a);const o=this.streetlightLights.get(i.id);o&&(o.visible=a)}}addStreetlightLight(e,t){const i=li.bodyOf(t),n=i.children.find(a=>a.userData.emissive);if(!n)return;const s=new Mb(16764006,o5,l5);s.position.copy(n.position).multiply(i.scale),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,t.add(s),this.streetlightLights.set(e,s)}setAstronomy(e){this.lastAstronomy=e,this.scatteredSky?.update(this.scatteredSkyState(e)),this.skyHoldUntilMs===void 0&&this.scatteredSky&&!this.scatteredSky.ambient&&(this.skyHoldUntilMs=performance.now()+ym,setTimeout(()=>this.render(),ym+20)),this.pumpScatteredSky(),this.lastSunPosition=e.sun,this.buildSky(e.sun),this.buildGround();const t=hr(e.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(e.stars,t),this.setBodyMesh("sun",e.sun,Yh,new oe(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon,t),this.buildPlanets(e.planets,t),this.buildComet(e.comet,t),this.buildNovae(e.novae??[],t),this.buildIceHalos(e.sun,e.moon),this.buildRainbow(e.sun,e.moon),this.applySkyColours(e),this.syncAnimationLoop(),this.render()}applySkyColours(e){this.skyColoursStale=!1;const t=this.scatteredSky?.ambient??yu(e.sun.altitudeDeg),i=t.horizon;this.baseFogColor=[i[0],i[1],i[2]],this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.scatteredSky?.ready?this.scatteredSky.material:this.skyGradientMaterial),this.updateCloudLighting(e.sun,this.baseFogColor),this.updateCelestialLight(e,t.zenith,i),this.buildSkyGlow(e,t.zenith),this.scene.fog instanceof pc?(this.scene.fog.color.setRGB(...this.baseFogColor),this.scene.fog.near=this.groundRadius*.2,this.scene.fog.far=this.groundRadius):this.scene.fog=new pc(new oe(...this.baseFogColor),this.groundRadius*.2,this.groundRadius)}setSiteElevation(e){Math.abs(e-this.siteElevationM)<1||(this.siteElevationM=e,this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}scatteredSkyState(e){return{altitudeM:this.siteElevationM+this.observerElevationM+1.6,sun:{altitudeDeg:e.sun.altitudeDeg,azimuthDeg:e.sun.azimuthDeg,magnitude:e.sun.magnitude},moon:{altitudeDeg:e.moon.altitudeDeg,azimuthDeg:e.moon.azimuthDeg,magnitude:e.moon.magnitude,phaseAngleDeg:Be.phaseAngleOf(e.moon.phase.illuminatedFraction)}}}pumpScatteredSky(){const e=this.scatteredSky;!e||e.tables.ready||this.scatteredSkyFrameId!==null||this.contextReleased||(this.scatteredSkyFrameId=requestAnimationFrame(()=>{this.scatteredSkyFrameId=null,!this.contextReleased&&(e.advance(this.skyHoldUntilMs?f5:u5),this.pumpScatteredSky())}))}cancelScatteredSkyPump(){this.scatteredSkyFrameId!==null&&(cancelAnimationFrame(this.scatteredSkyFrameId),this.scatteredSkyFrameId=null)}setSatellites(e){if(e.length===0&&!this.satelliteField?.count)return;this.satelliteField||(this.satelliteField=new R_(qh),this.celestialGroup.add(this.satelliteField.object));const t=hr(this.lastSunPosition?.altitudeDeg??-90,this.instrumentMagnitudeGain);this.satelliteField.set(e,t,i=>this.cloudTransmission(i)),this.render()}pickSatelliteAt(e,t){if(!this.satelliteField?.count)return;this.aimAtScreenPoint(this.raycaster,e,t);const i=Math.cos(pm*this.camera.fov*Math.PI/180),n=this.satelliteField.nearest(this.raycaster.ray.direction,i);return n&&this.groundHides(e,t)?void 0:n}updateCelestialLight(e,t,i){this.skyLight.color.setRGB(t[0],t[1],t[2]),this.skyLight.groundColor.setRGB(i[0],i[1],i[2]),this.skyLight.intensity=a5;const n=e.sun.altitudeDeg>=vm,s=!n&&e.moon.altitudeDeg>=vm;if(!n&&!s){this.celestialLight.intensity=0;return}const a=n?e.sun:e.moon,{x:o,y:l,z:c}=oi(a.altitudeDeg,a.azimuthDeg,Zr);this.celestialLight.position.set(o,l,c);const h=Is(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const d=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*ki));this.celestialLight.intensity=(n?s5:r5)*d,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,i){this.meteorSystem||(this.meteorSystem=new si,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(e,t,i)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(e){return this.meteorSystem?.midpointOf(e)}updateMeteors(e){this.meteorSystem?.update(e)}setInstrument(e){this.projectionKind=e.projection;const t=ct.starPointsOf(e),i=ct.flareArtifactsOf(e);t===this.starPoints&&i===this.lensFlareArtifactIntensity||(this.starPoints=t,this.lensFlareArtifactIntensity=i,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=t,this.lensFlare.uniforms.uFlareIntensity.value=i),this.render())}setInstrumentGain(e,t=!1){this.instrumentMagnitudeGain=Number.isFinite(e)?e:0,this.scatteredSky?.setInstrument(t,this.instrumentMagnitudeGain)}render(){this.restatingExposure||(this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()})))}drawIfDirty(){if(!(!this.frameDirty||this.contextReleased)){if(this.skyHoldUntilMs){if(!this.scatteredSky?.ambient&&performance.now()<this.skyHoldUntilMs)return;this.skyHoldUntilMs=null}if(this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy),this.compileBeforeNextDraw){this.compileBeforeNextDraw=!1;const e=this.compileOffThread().then(()=>{this.compiling===e&&(this.compiling=void 0,this.render())});this.compiling=e;return}if(!this.compiling){this.frameDirty=!1,this.resolution.beginDrawing();try{this.renderOnce()}finally{this.resolution.endDrawing()}this.developingExposure&&this.startExposure()}}}compileBeforeNextDraw=!1;compiling;static COMPILE_WAIT_MS=1500;compileOffThread(){const e=this.renderer.compile(this.scene,this.camera);if(!this.renderer.extensions.get("KHR_parallel_shader_compile"))return Promise.resolve();const t=this.renderer.properties,i=performance.now()+tn.COMPILE_WAIT_MS;return new Promise(n=>{const s=()=>{if(this.contextReleased)return n();for(const a of e){const o=t.get(a)?.currentProgram;(!o||o.isReady())&&e.delete(a)}e.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(e){if(this.animationsRunning){const t=this.lastFrameTimeMs===void 0?0:e-this.lastFrameTimeMs;this.lastFrameTimeMs=e,this.hasAnimations()&&this.animate(e,t);const i=this.resolution.update(e,t);i!==void 0&&this.applyPixelRatio(i)}this.drawIfDirty()}animate(e,t){const i=Math.min(t/1e3,N5);this.updateTwinkle(e/1e3),this.updatePrecipitation(e/1e3,i),this.updateRain(i),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=e/1e3),this.developingExposure||(this.frameDirty=!0)}setMaxPixelRatio(e){this.resolution.maximum=e,this.renderer.getPixelRatio()!==this.resolution.pixelRatio&&this.applyPixelRatio(this.resolution.pixelRatio)}applyPixelRatio(e){this.renderer.setPixelRatio(e),this.renderer.setSize(this.cssSize.width,this.cssSize.height,!1),this.frameDirty=!0}setExposure(e,t){const i=t?Math.max(1,Math.round(e)):1;if(i===this.exposureInstants&&(i===1||t===this.exposureInstantAt)){this.exposureInstantAt=t;return}this.exposureInstants=i,this.exposureInstantAt=t,i===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(e){if(this.onMapSubjectBounds){const s=this.mapSubjectBounds();e?this.exposureSubjectBounds.push(...s):this.onMapSubjectBounds(s)}const t=this.usableEquidistantPass();this.phenomena.setCloudLayers(this.layeredClouds?.volumes??[]),this.phenomena.place(this.camera,(s,a,o)=>this.directionAtScreenPoint(s,a,o),s=>this.screenPointOf(s)),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());const n=this.renderer.getRenderTarget();if(!t){this.updateLensFlarePosition();const s=this.usableDepthOfFieldPass();s?.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(e===void 0&&!s),e&&this.renderer.setRenderTarget(e),s?s.render(this.renderer,this.scene,this.camera,()=>this.renderOverlayPasses()):(this.renderer.render(this.scene,this.camera),this.renderOverlayPasses()),e&&this.renderer.setRenderTarget(n);return}t.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(!1),e&&this.renderer.setRenderTarget(e),t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),()=>this.renderOverlayPasses()),e&&this.renderer.setRenderTarget(n)}renderOverlayPasses(){this.renderReferencesPass(),this.renderPhenomenaPass()}renderReferencesPass(){if(!this.references.any)return;const e=this.renderer.autoClear,t=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.camera.layers.set(V1),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=t}setReferences(e){this.references.set(e)}referenceAspect(e){return this.references.aspectOf(e)}directionAt(e,t){return this.directionAtScreenPoint(e,t,new P)}referenceFailedToLoad(e){return this.references.failedToLoad(e)}setReferencesShown(e){this.references.setShown(e),this.render()}setReferenceView(e,t){this.references.setView(e,t),this.render()}renderPhenomenaPass(){if(!this.phenomena.any)return;const e=this.renderer.autoClear,t=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const i of this.decorObjects){const n=this.decorGroups.get(i.id);n&&tn.markDecorDepth(n,i.kind!=="crop")}this.camera.layers.set(Wh),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,this.camera),this.scene.overrideMaterial=null,this.camera.layers.set(G1),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=t}decorDepthMaterial=new rn({colorWrite:!1});static markDecorDepth(e,t){e.traverse(i=>{if(!(i instanceof We))return;const n=Array.isArray(i.material)?i.material[0]:i.material;t&&n.depthWrite!==!1&&n.blending!==Zi?i.layers.enable(Wh):i.layers.disable(Wh)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const e=this.renderer.getDrawingBufferSize(new Te),t=Math.max(1,Math.round(e.x)),i=Math.max(1,Math.round(e.y));this.exposureAccumulation||(this.exposureAccumulation=new B3(t,i)),this.exposureAccumulation.resize(t,i),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const e=this.exposureInstantAt,t=this.exposureAccumulation;if(!e||!t)return;const i=1/this.exposureInstants;this.resolution.beginDrawing();const n=performance.now()+tn.EXPOSURE_BUDGET_MS,s=tn.exposureInstantsPerFrame(t.instantTarget.width*t.instantTarget.height);let a=0;do{this.restateAt(e,this.exposureInstantsDone);const o=this.compassSprites.map(l=>l.visible);for(const l of this.compassSprites)l.visible=!1;try{this.renderOnce(t.instantTarget)}finally{this.compassSprites.forEach((l,c)=>{l.visible=o[c]})}t.add(this.renderer,i),this.exposureInstantsDone++,a++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<n&&a<s);this.restateAt(e,0),this.presentExposure(),this.resolution.endDrawing(),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}presentExposure(){if(this.exposureAccumulation?.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.onMapSubjectBounds?.(this.exposureSubjectBounds),!this.compassSprites.some(s=>s.visible))return;const e=new Ca,t=new Hs(-1,1,1,-1,0,2),i=Ol/(bm*Math.tan(wm*ki/2));for(const s of this.compassSprites){if(!s.visible)continue;const a=s.getWorldPosition(new P).sub(this.camera.position).normalize(),o=this.screenPointOf(a);if(!o)continue;const l=new Gr(s.material);l.position.set(o.ndcX,o.ndcY,-1),l.scale.set(i/this.camera.aspect,i,1),e.add(l)}const n=this.renderer.autoClear;this.renderer.autoClear=!1;try{this.renderer.render(e,t)}finally{this.renderer.autoClear=n}}onMapSubjectBounds;exposureSubjectBounds=[];mapSubjectBounds(){const e=[],t=new bn,i=new P;for(const n of this.decorObjects){if(!n.track?.length&&n.kind!=="aircraft"&&n.kind!=="vehicle")continue;const s=this.decorGroups.get(n.id);if(!s?.visible||(t.setFromObject(s),t.isEmpty()))continue;let a=1/0,o=-1/0,l=1/0,c=-1/0;for(const h of[t.min.x,t.max.x])for(const d of[t.min.y,t.max.y])for(const u of[t.min.z,t.max.z]){i.set(h,d,u).sub(this.camera.position).normalize();const f=this.screenPointOf(i);if(!f)continue;const p=(f.ndcX+1)/2,v=(1-f.ndcY)/2;a=Math.min(a,p),o=Math.max(o,p),l=Math.min(l,v),c=Math.max(c,v)}Number.isFinite(a)&&e.push({x:a,y:l,width:o-a,height:c-l})}return e}restateAt(e,t){this.restatingExposure=!0;try{e(t)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(e){const t=this.lensOptics;this.lensOptics=e,(t===void 0!=(e===void 0)||t&&e&&(t.focalLengthMm!==e.focalLengthMm||t.fNumber!==e.fNumber||t.focusDistance!==e.focusDistance||t.frameHeightMm!==e.frameHeightMm))&&(e&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.render())}usableDepthOfFieldPass(){const e=this.lensOptics;if(!e)return;const t=this.renderer.getDrawingBufferSize(new Te),i=Math.max(1,Math.round(t.x)),n=Math.max(1,Math.round(t.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new bo(i,n)),this.depthOfFieldPass.resize(i,n),this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.depthOfFieldPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const e=this.renderer.getDrawingBufferSize(new Te);if(yo.supports(this.camera.fov,e.x/Math.max(e.y,1)))return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new yo(e.x,e.y),this.equidistantPass}aimAtScreenPoint(e,t,i){const n=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!n){e.setFromCamera(new Te(t,i),this.camera);return}const s=n.directionFor(t,i,this.camera.fov);this.camera.updateMatrixWorld(),e.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),e.ray.direction.set(s.x,s.y,s.z).applyQuaternion(this.camera.quaternion).normalize(),e.camera=this.camera}pickCloudAt(e,t){return this.layeredClouds?.pickInstance(this.cloudDirectionAt(e,t))}cloudDirectionAt(e,t){return this.directionAtScreenPoint(e,t,new P)}directionAtScreenPoint(e,t,i){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),i.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(e){this.camera.updateMatrixWorld();const t=this.screenPointScratch.copy(e).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert());if(t.z>=0)return;const i=this.renderer.getDrawingBufferSize(this.screenPointSize),n=i.x/Math.max(i.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return yo.ndcFor(t,this.camera.fov,n);const s=Math.tan(this.camera.fov/2*ki);return{ndcX:t.x/-t.z/(n*s),ndcY:t.y/-t.z/s}}screenPointScratch=new P;screenPointQuaternion=new qn;screenPointSize=new Te;updateLensFlarePosition(){const e=this.lensFlare;if(!e)return;if(!this.sunVisible){e.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){e.mesh.visible=!1;return}const t=this.sunVisibleFraction();if(t<=0){e.mesh.visible=!1;return}e.mesh.visible=!0,this.sunUnhiddenFraction=t,this.applyDazzleStrength();const i=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);e.uniforms.uLensPosition.value.set(i.x,i.y);const n=this.renderer.domElement.width,s=this.renderer.domElement.height;e.uniforms.uResolution.value.set(n,s),e.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let e=0;for(const t of xm)this.isSunOccluded(t[0],t[1])||e++;return e/xm.length}raycastableDecor(){const e=[];for(const t of this.decorObjects){if(t.kind==="crop")continue;const i=this.decorGroups.get(t.id);i&&e.push(i)}return e}isSunOccluded(e=0,t=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(),e!==0||t!==0){const o=Math.PI/180,l=this.sunOcclusionRightScratch.set(n.z,0,-n.x);l.lengthSq()<1e-9&&l.set(1,0,0),l.normalize();const c=this.sunOcclusionUpScratch.crossVectors(l,n).normalize();n.addScaledVector(l,e*o).addScaledVector(c,t*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(e,t,i,n=0){const s=this.groundMesh;if(s&&t.y<0){const m=(s.position.y-e.y)/t.y;if(m>n&&m<i){const g=e.x+t.x*m-s.position.x,x=e.z+t.z*m-s.position.z;if(Math.hypot(g,x)<=this.groundRadius)return!0}}const a=this.terrainMesh;if(!a)return!1;const o=a.geometry.getAttribute("position"),l=Math.round(Math.sqrt(o.count));if(l<2||l*l!==o.count)return!1;const c=[a.position.x+o.getX(0),a.position.x+o.getX(l-1)],h=[a.position.z+o.getZ(0),a.position.z+o.getZ((l-1)*l)],d=Math.min(Math.abs(c[1]-c[0]),Math.abs(h[1]-h[0]))/(l-1);if(!(d>0))return!1;let u=n,f=i;for(const[m,g,x]of[[e.x,t.x,c],[e.z,t.z,h]]){const M=Math.min(x[0],x[1]),w=Math.max(x[0],x[1]);if(Math.abs(g)<1e-12){if(m<M||m>w)return!1;continue}const S=(M-m)/g,_=(w-m)/g;u=Math.max(u,Math.min(S,_)),f=Math.min(f,Math.max(S,_))}if(!(f>u))return!1;const p=Math.hypot(t.x,t.z),v=Math.min(4096,Math.max(8,Math.ceil((f-u)*p/(d/2))));for(let m=0;m<=v;m++){const g=u+(f-u)*m/v,x=e.x+t.x*g,M=e.y+t.y*g,w=e.z+t.z*g;if(M<=this.groundYUnder(x,w))return!0}return!1}setPhenomena(e,t){this.phenomena.set(e,t)}decorDistancesAt(e,t,i){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=um;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 l=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];l&&(a.occludesSourceIds?.includes(i)?n=n===void 0?l.distance:Math.max(n,l.distance):s=s===void 0?l.distance:Math.min(s,l.distance))}return{behindM:n,inFrontM:s}}pickBodyAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const i=[...this.hitAreas.entries()],n=this.raycaster.intersectObjects(i.map(([,s])=>s))[0];if(n&&!this.groundHides(e,t))return i.find(([,s])=>s===n.object)?.[0]}pickStarAt(e,t){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,e,t);const i=this.raycaster.ray.direction,n=Math.cos(pm*this.camera.fov*Math.PI/180);let s,a=n;for(const o of this.namedStars){const l=o.direction.dot(i);l>a&&(a=l,s={star:o.star,altitudeDeg:o.altitudeDeg})}return s&&this.groundHides(e,t)?void 0:s}groundHides(e,t){if(!this.terrainMesh&&!this.groundMesh)return!1;this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t);const i=this.ufoOcclusionRaycaster.ray;return this.groundBlocks(i.origin,i.direction,1/0,um)}pickDecorAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);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.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.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.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 e of this.bodyMeshes.values())this.disposeMesh(e);this.bodyMeshes.clear(),this.novaKeys.clear();for(const e of[...this.hitAreas.keys()])this.disposeHitArea(e);for(const e of[...this.glareSprites.keys()])this.disposeGlare(e);this.disposeCompassLabels();for(const e of this.decorGroups.values())li.dispose(e);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 e=t=>{this.frame(t),this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e)}setAnimationsRunning(e,t=!1){const i=e&&t;if(e===this.animationsRunning&&i===this.framesDriven)return;const n=this.animationsRunning;this.animationsRunning=e,this.framesDriven=i,e&&!n&&(this.lastFrameTimeMs=void 0,this.resolution.reset()),this.syncAnimationLoop(),(!e||this.frameDirty)&&this.render()}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(e){const t=this.skyMesh?.geometry??new yi(kl,32,16),i=t.attributes.position,n=t.getAttribute("color")??new Ut(new Float32Array(i.count*3),3);for(let a=0;a<i.count;a++){const{altitudeDeg:o,azimuthDeg:l}=G3(i.getX(a),i.getY(a),i.getZ(a)),c=Z3(o,l,e.azimuthDeg,e.altitudeDeg);n.setXYZ(a,c[0],c[1],c[2])}if(n.needsUpdate=!0,this.skyMesh)return;t.setAttribute("color",n);const s=new rn({vertexColors:!0,side:Ft,fog:!1,depthWrite:!1});this.skyGradientMaterial=s,this.skyMesh=new We(t,s),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const e=fm(this.observerElevationM);if(this.groundMesh&&e===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=e;const t=new df(this.groundRadius,48),i=new Oo({color:new oe(Xh,Xh,Xh),fog:!0});this.groundMesh=new We(t,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 e=this.groundMesh?.material;if(!e)return;const t=this.terrainMesh===void 0;e.depthWrite!==t&&(e.depthWrite=t,e.needsUpdate=!0)}cloudTransmission(e){const t=`${e.altitudeDeg.toFixed(1)}:${e.azimuthDeg.toFixed(1)}:${Math.round(this.cloudOffsetM.x/10)}:${Math.round(this.cloudOffsetM.z/10)}:${Math.round(this.observerElevationM)}:`+Object.entries(this.cloudLayerOffsetsM).map(([s,a])=>`${s}=${Math.round(a.x/10)},${Math.round(a.z/10)}`).join(";"),i=this.cloudTransmissionMemo.get(t);if(i!==void 0)return i;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const n=this.computeCloudTransmission(e);return this.cloudTransmissionMemo.set(t,n),n}cloudTransmissionMemo=new Map;computeCloudTransmission(e){const t=oi(e.altitudeDeg,e.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(t);let i=1;const n=this.lowerCloudCover();n>0&&(i*=1-Wt.alphaAt(t,Math.abs(this.cloudLayerOffset()),n,this.cloudFieldOffset)*i5);const s=this.weather.highCloudCover??0;return s>0&&(i*=1-Wt.alphaAt(t,Nl,s)*n5),Math.max(0,Math.min(1,i))}setBodyMesh(e,t,i,n,s){if(t.altitudeDeg<Hu){this.disposeMesh(this.bodyMeshes.get(e)),this.bodyMeshes.delete(e),this.disposeHitArea(e),this.disposeGlare(e),e==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:l}=oi(t.altitudeDeg,t.azimuthDeg,Zr),c=Is(t.altitudeDeg),h=this.cloudTransmission(t),d=new oe(n.r*c[0]*h,n.g*c[1]*h,n.b*c[2]*h);let u=this.bodyMeshes.get(e);u instanceof We?u.material.color.copy(d):(this.disposeMesh(u),u=new We(new yi(1,16,16),new rn({color:d,fog:!1})),this.celestialGroup.add(u),this.bodyMeshes.set(e,u)),u.scale.setScalar(i),u.position.set(a,o,l),this.setHitArea(e,a,o,l,i);const f=s-2.5*Math.log10(Math.max(h,.001));if(e==="sun"&&(this.sunCloudTransmission=h),e!=="sun"&&this.setGlare(e,a,o,l,f,d),e==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*p,o*p+this.celestialGroup.position.y,l*p),this.lensFlare||(this.lensFlare=C_(),this.lensFlare.uniforms.uOpacity.value=y5,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(c)}}setMoonMesh(e,t){const i="moon";if(e.magnitude>t||e.altitudeDeg<Hu){this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i);return}const{x:n,y:s,z:a}=oi(e.altitudeDeg,e.azimuthDeg,Zr),o=Is(e.altitudeDeg),l=new oe(o[0],o[1],o[2]),c=`${e.phase.phaseFraction<.5}:${Math.round(wo(e.phase.illuminatedFraction,0,1)*500)}`;let h=this.bodyMeshes.get(i);if(h instanceof Gr)h.userData.phaseKey!==c&&(h.material.map?.dispose(),h.material.map=Bm(e.phase),h.userData.phaseKey=c),h.material.color.copy(l);else{this.disposeMesh(h),h=new Gr(new ao({map:Bm(e.phase),color:l,fog:!1})),h.userData.phaseKey=c;const d=Yh*2;h.scale.set(d,d,1),this.celestialGroup.add(h),this.bodyMeshes.set(i,h)}h.position.set(n,s,a),this.setHitArea(i,n,s,a,Yh),this.setGlare(i,n,s,a,e.magnitude,l)}setHitArea(e,t,i,n,s){let a=this.hitAreas.get(e);if(!a){const l=new ao({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});a=new Gr(l),this.celestialGroup.add(a),this.hitAreas.set(e,a)}a.position.set(t,i,n);const o=s*t5;a.scale.set(o,o,1)}disposeHitArea(e){const t=this.hitAreas.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.hitAreas.delete(e))}setGlare(e,t,i,n,s,a){const o=Q3(s);if(o<=0){this.disposeGlare(e);return}const l=iE(o),c=this.glareSprites.get(e),h=c??new Gr(new ao({map:Z5(),transparent:!0,blending:Zi,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=rE(o),h.position.set(t,i,n),h.scale.set(l*2,l*2,1),c||(this.celestialGroup.add(h),this.glareSprites.set(e,h))}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.glareSprites.delete(e))}buildComet(e,t){const i=e&&`comet:${e.id}`;if(!e||!i||e.magnitude>t){this.disposeComet();return}this.cometKey&&this.cometKey!==i&&this.disposeComet();const n=lo(e.magnitude,t),s=co(n);this.cometKey=i,this.setBodyMesh(i,e.position,Kh*(.5+.5*n),new oe(s,s,s),e.magnitude),this.cometTail||(this.cometTail=new qi(Zr),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,n)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new Cn,this.iceHalos.setCloudOffset(this.cloudFieldOffset),this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object));const i=this.highCloudCover(),n=this.layeredClouds?.cirrusMask;if(this.iceHalos.setCloudOffset(n?.offset??this.cloudFieldOffset),i===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:Nl},0);return}const s=this.lowerCloudCover(),a=et.deckLitUntilDeg(et.DECK_HEIGHT_M),o=e.altitudeDeg>-a?e:t,l=et.strength(i,s,o.altitudeDeg,a)*(o===e?1:gm),{x:c,y:h,z:d}=oi(o.altitudeDeg,o.azimuthDeg,1),u=Is(o.altitudeDeg);this.iceHalos.update({x:c,y:h,z:d},o.altitudeDeg,l,[u[0],u[1],u[2]],{cover:n?.cover??i,layerHeight:n?.layerHeight??Nl},n?.iceCrystalAlignment??this.weather.iceCrystalAlignment??.65)}buildRainbow(e,t){this.rainbow||(this.rainbow=new cr,this.celestialGroup.add(this.rainbow.object));const i=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,n=e.altitudeDeg>0,s=n?e:t,a=this.lowerCloudCover(),o=gm*fi.moonlightShare(t.magnitude),l=fi.strength(i,a,s.altitudeDeg)*(n?1:o);if(l<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:c,y:h,z:d}=oi(s.altitudeDeg,s.azimuthDeg,1),u=Is(s.altitudeDeg);this.rainbow.update({x:c,y:h,z:d},l,[u[0],u[1],u[2]],n)}buildSkyGlow(e,t){if(!e.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Cs,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:i,observer:n}=e.frame,s=Ki.galactic(i,n),a=tn.directionOf(s.centre),o=tn.directionOf(s.rotation),l=tn.directionOf(s.pole),c=new He().set(a.x,a.y,a.z,o.x,o.y,o.z,l.x,l.y,l.z),h=tn.directionOf(Ki.eclipticPole(i,n)),d=tn.directionOf(e.sun),u=d.clone().addScaledVector(h,-d.dot(h)).normalize();this.skyGlow.update({galactic:c,eclipticPole:h,sunLongitude:u,sunDirection:d,sunAltitudeDeg:e.sun.altitudeDeg,moon:{direction:tn.directionOf(e.moon),altitudeDeg:e.moon.altitudeDeg,phaseAngleDeg:Be.phaseAngleOf(e.moon.phase.illuminatedFraction)},skyColor:new P(t[0],t[1],t[2])})}static directionOf(e){const{x:t,y:i,z:n}=oi(e.altitudeDeg,e.azimuthDeg,1);return new P(t,i,n).normalize()}buildNovae(e,t){const i=new Set;for(const n of e){if(n.magnitude>t)continue;const s=`nova:${n.id}`;i.add(s);const a=lo(n.magnitude,t),o=co(a);this.setBodyMesh(s,n.position,Kh*(.5+.5*a),new oe(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(e,t){const i=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[],...this.novaKeys]);for(const n of e){if(n.magnitude>t)continue;i.add(n.body);const s=lo(n.magnitude,t),a=co(s),o=H5[n.body]??new oe(1,1,1),l=new oe(o.r*a,o.g*a,o.b*a),c=Kh*(.5+.5*s);this.setBodyMesh(n.body,n.position,c,l,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(e,t){if(this.namedStars=[],!e||e.catalog.count===0){this.disposeStarTiers(),this.syncAnimationLoop();return}const{catalog:i,date:n,observer:s}=e,a=new fn(n,s),o=td(1337),l=[];for(let c=0;c<i.count;c++){const h=i.mag[c];if(h>t)break;const{altitudeDeg:d,azimuthDeg:u}=a.position(i.ra[c],i.dec[c]);if(d<mm)continue;const{x:f,y:p,z:v}=oi(d,u,qh);l.push({x:f,y:p,z:v,brightness:lo(h,t),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const c of h_){if(c.mag>t)continue;const{altitudeDeg:h,azimuthDeg:d}=a.position(c.raHours,c.decDeg);if(h<mm)continue;const{x:u,y:f,z:p}=oi(h,d,qh);this.namedStars.push({star:c,direction:new P(u,f,p).normalize(),altitudeDeg:h})}this.starTiers=vf.map((c,h)=>{const d=l.filter(M=>u1(M.brightness)===h),u=new Float32Array(d.length*3),f=new Float32Array(d.length),p=new Float32Array(d.length),v=new Float32Array(d.length);d.forEach((M,w)=>{u[w*3]=M.x,u[w*3+1]=M.y,u[w*3+2]=M.z,f[w]=M.brightness,p[w]=M.phase,v[w]=M.speedFactor});const m=new Tt;m.setAttribute("position",new ht(u,3));const g=new ht(new Float32Array(d.length*3),3);m.setAttribute("color",g);let x=this.starTiers[h]?.points;if(x)x.geometry.dispose(),x.geometry=m;else{const M=new hf({vertexColors:!0,size:c.size,sizeAttenuation:!1,fog:!1});Ls.apply(M),x=new vo(m,M),this.celestialGroup.add(x)}return{points:x,colorAttribute:g,brightness:f,phase:p,speedFactor:v}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(e){for(const t of this.starTiers){const i=t.colorAttribute.array;for(let n=0;n<t.brightness.length;n++){const s=dE(t.brightness[n],{phase:t.phase[n],speedFactor:t.speedFactor[n]},e),a=co(t.brightness[n])*s;i[n*3]=a,i[n*3+1]=a,i[n*3+2]=a}t.colorAttribute.needsUpdate=!0}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new wc(this.celestialGroup,$h,this.cloudRendering)),this.disposeCirrus(),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 e=this.lowerCloudCover();if(e<=0){this.disposeCloudSystem();return}const t=this.weather.cloudDarkness,i=new oe(Zs[0]+(jh[0]-Zs[0])*t,Zs[1]+(jh[1]-Zs[1])*t,Zs[2]+(jh[2]-Zs[2])*t);if(this.cloudMesh&&this.cloudUniforms){this.cloudUniforms.coverage.value=e,this.cloudUniforms.baseColor.value.copy(i),this.syncCloudLayer(),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}this.disposeCloudSystem();const{material:n,uniforms:s}=fu(i,e,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=pu($h);this.cloudMesh=new We(a,n),this.faceCloudDeck(this.cloudMesh,this.cloudLayerOffset()),this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(e=>e.type!=="cirrus").reduce((e,t)=>e*(1-t.coverage),1):this.weather.lowerCloudCover??this.weather.cloudCover}highCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(e=>e.type==="cirrus").reduce((e,t)=>e*(1-t.coverage),1):this.weather.highCloudCover}buildCirrus(){const e=this.weather.highCloudCover??0;if(this.layeredClouds||e<=0){this.disposeCirrus();return}if(this.cirrusMesh&&this.cirrusUniforms){this.cirrusUniforms.coverage.value=e,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const{material:t,uniforms:i}=fu(new oe(...Zs),e,Nl,1);this.cirrusMaterial=t,this.cirrusUniforms=i,i.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new We(pu($h*1.04),t),this.cirrusMesh.renderOrder=Sm-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 e=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(e)),this.cloudMesh&&this.faceCloudDeck(this.cloudMesh,e)}faceCloudDeck(e,t){const i=t<0;e.scale.y=i?-1:1,e.renderOrder=i?wc.deckOrder(!0,0,1):Sm}cloudLayerOffset(){const t=((this.weather.cloudBaseM??1e3)-this.observerElevationM)*Zh;return Math.sign(t||1)*Math.max(Math.abs(t),w5)}updateCloudLighting(e,t){const i=[this.cloudUniforms,this.cirrusUniforms].filter(d=>d!==void 0);if(i.length===0&&!this.layeredClouds)return;const{x:n,y:s,z:a}=oi(e.altitudeDeg,e.azimuthDeg,1),o=Is(e.altitudeDeg),l=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*ki)),c=this.lightningLevel*B5,h=new oe(t[0]+In.r*c,t[1]+In.g*c,t[2]+In.b*c);this.layeredClouds?.setLighting(new P(n,s,a),new oe(o[0]*l,.96*o[1]*l,.88*o[2]*l),h,h);for(const d of i)d.sunDir.value.set(n,s,a),d.sunColor.value.setRGB(o[0]*l,.96*o[1]*l,.88*o[2]*l),d.ambientColor.value.copy(h)}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}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const e=this.weather.precipitationType;if(e==="none")return;if(e==="rain"){this.buildRain();return}const t=Em[e],i=t.poolSize,n=td(9001),s=new Float32Array(i*3),a=new Float32Array(i),o=new Float32Array(i),l=new Float32Array(i),c=new Float32Array(i),h=new Float32Array(i),d=new Float32Array(i),u=new Float32Array(i),f=new Float32Array(i),p=new Float32Array(i);for(let M=0;M<i;M++){const w=n()*Math.PI*2,S=n()*t.radiusM;s[M*3]=Math.cos(w)*S,s[M*3+1]=na+n()*(t.topYM-na),s[M*3+2]=Math.sin(w)*S,a[M]=n()*Math.PI*2,o[M]=.7+n()*.6,l[M]=.6+n()*.8,c[M]=.4+n()*1.2}const v=new Tt;v.setAttribute("position",new ht(s,3)),v.setDrawRange(0,ed(i,this.weather.precipitationIntensity));const m={uSize:{value:t.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:t.opacity},uColor:{value:t.color},uHazeColor:{value:new oe(...this.baseFogColor)},uTexture:{value:G5(e)},uNearFocusDistance:{value:Rm},uHazeDistance:{value:t.radiusM*Pm}},g=new Ot({uniforms:m,vertexShader:K5,fragmentShader:$5,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const x=new vo(v,g);x.renderOrder=Jh,this.scene.add(x),this.precipitationPoints=x,this.precipitationPositions=s,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=l,this.precipitationWobbleAmpJitter=c,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=d,this.precipitationBounceDuration=u,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=p}updatePrecipitation(e,t){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),t<=0))return;const i=this.weather.precipitationType;if(i==="none"||i==="rain")return;const n=Em[i],s=this.weather.windDirectionDeg*ki,a=Math.sin(s)*this.weather.windSpeed*n.driftSensitivity,o=-Math.cos(s)*this.weather.windSpeed*n.driftSensitivity,l=this.precipitationPositions,c=this.precipitationPhase,h=this.precipitationSpeedJitter,d=this.precipitationWobbleFreqJitter,u=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,p=this.precipitationBounceHeight,v=this.precipitationBounceDuration,m=this.precipitationBounceVelX,g=this.precipitationBounceVelZ,x=i==="snow"&&d&&u,M=i==="hail"&&f&&p&&v&&m&&g;for(let w=0,S=0;w<l.length;w+=3,S++){if(M&&f[S]>0){if(f[S]-=t,f[S]<=0){const y=Math.random()*Math.PI*2,T=Math.sqrt(Math.random())*n.radiusM;l[w]=Math.cos(y)*T,l[w+1]=n.topYM,l[w+2]=Math.sin(y)*T,f[S]=0}else{const y=1-f[S]/v[S];l[w+1]=na+Math.sin(Math.PI*y)*p[S],l[w]=Fl(l[w]+(a+m[S])*t,n.radiusM),l[w+2]=Fl(l[w+2]+(o+g[S])*t,n.radiusM)}continue}let _=0,D=0;if(x){const y=R5*d[S],T=P5*u[S];_=Math.sin(e*y*Math.PI*2+c[S])*T,D=Math.sin(e*y*Math.PI*2+c[S]+Math.PI/2)*T}if(l[w]+=(a+_)*t,l[w+1]-=n.fallSpeedMPerS*h[S]*t,l[w+2]+=(o+D)*t,l[w]=Fl(l[w],n.radiusM),l[w+2]=Fl(l[w+2],n.radiusM),l[w+1]<na){if(M){p[S]=Fm*(.2+Math.random()*1.6),v[S]=L5*(.5+Math.random()),f[S]=v[S];const A=Math.random()*Math.PI*2,I=k5*(p[S]/Fm);m[S]=Math.cos(A)*I,g[S]=Math.sin(A)*I,l[w+1]=na;continue}const y=Math.random()*Math.PI*2,T=Math.sqrt(Math.random())*n.radiusM;l[w]=Math.cos(y)*T,l[w+1]=n.topYM,l[w+2]=Math.sin(y)*T}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=Im(this.weather.precipitationIntensity);this.rainSystem=T_({count:_m,radiusM:to,heightM:x5,bottomYM:Tm,overallSpeed:S5,color:_5,opacity:.85,visibleCount:ed(_m,this.weather.precipitationIntensity),speedStreak:I5(e),pixelSize:km,seed:9001,nearFocusDistanceM:Rm,hazeDistanceM:to*Pm,hazeColor:new oe(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=Jh,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=td(4242),t=new Float32Array(Jr*3),i=new Float32Array(Jr),n=new Float32Array(Jr),s=new Float32Array(Jr);for(let h=0;h<Jr;h++){const d=e()*Math.PI*2,u=Math.sqrt(e())*to;t[h*3]=Math.cos(d)*u,t[h*3+1]=Tm,t[h*3+2]=Math.sin(d)*u,n[h]=Um(Dm,Cm),i[h]=e()*n[h],s[h]=i[h]/n[h]}const a=new Tt;a.setAttribute("position",new ht(t,3));const o=new ht(s,1);a.setAttribute("aLife",o),a.setDrawRange(0,ed(Jr,this.weather.precipitationIntensity));const l=new Ot({uniforms:{uMaxSize:{value:D5},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:C5},uTexture:{value:X5()}},vertexShader:q5,fragmentShader:Y5,transparent:!0,depthWrite:!1}),c=new vo(a,l);c.renderOrder=Jh,this.scene.add(c),this.rainSplashSystem={points:c,positions:t,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 e=this.rainSystem;if(!e)return;const t=this.weather.windDirectionDeg*ki;e.uniforms.uDropVelocity.value.set(Math.sin(t)*this.weather.windSpeed,-Im(this.weather.precipitationIntensity),-Math.cos(t)*this.weather.windSpeed);const i=this.renderer.getSize(this.rainViewportSize);e.uniforms.uAspect.value=i.x/Math.max(i.y,1)}updateRain(e){const t=this.rainSystem;if(!t)return;t.uniforms.uTime.value+=e,t.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const i=this.weather.windDirectionDeg*ki,n=Math.sin(i)*this.weather.windSpeed,s=-Math.cos(i)*this.weather.windSpeed,a=to,o=c=>(c%(a*2)+a*3)%(a*2)-a;t.uniforms.uWindOffset.value.set(o(t.uniforms.uWindOffset.value.x+n*e),o(t.uniforms.uWindOffset.value.y+s*e)),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 c=Nm+(1-Nm)*(1-l),h=Om+(1-Om)*(1-l);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=km*c*(.5+.5*h)}this.updateRainSplashes(e)}updateRainSplashes(e){const t=this.rainSplashSystem;if(!t||e<=0)return;const{positions:i,life:n,duration:s,lifeAttribute:a}=t,o=a.array;for(let l=0,c=0;l<i.length;l+=3,c++){if(n[c]+=e,n[c]>=s[c]){const h=Math.random()*Math.PI*2,d=Math.sqrt(Math.random())*to;i[l]=Math.cos(h)*d,i[l+2]=Math.sin(h)*d,s[c]=Um(Dm,Cm),n[c]=0}o[c]=n[c]/s[c]}t.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}setLightning(e){this.lightningFlashes=e}updateLightning(e){let t,i=0;if(this.lightningArmed)for(const o of this.lightningFlashes){if(o.t>e)break;const l=Qt.brightnessAt(o,e);l>i&&(t=o,i=l)}const n=t?Math.min(1,Math.max(.1,(F5/t.distanceM)**2)):0,s=i*n*(t?.cloudToGround?1:.6);if(s===this.lightningLevel&&!t?.cloudToGround)return;if(this.lightningLevel=s,this.scene.fog){const o=this.scene.fog,l=Math.min(1,s);o.color.setRGB(this.baseFogColor[0]+(In.r-this.baseFogColor[0])*l,this.baseFogColor[1]+(In.g-this.baseFogColor[1])*l,this.baseFogColor[2]+(In.b-this.baseFogColor[2])*l)}if(this.skyMesh){const o=s*U5;this.skyMesh.material.color.setRGB(1+o*In.r,1+o*In.g,1+o*In.b)}if(this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.lightningLight.intensity=s*z5,t){const{x:o,y:l,z:c}=oi(25,t.azimuthDeg,Zr);this.lightningLight.position.set(o,l,c)}this.lightningBolt||(this.lightningBolt=new ca(Zr*.95),this.celestialGroup.add(this.lightningBolt.object));const a=this.weather.cloudBaseM??1500;this.lightningBolt.set(t,i,a),this.render()}buildCompassLabels(){const e=fa(navigator.languages,d5),t=h5[e];this.compassSprites=c5.map((i,n)=>{const s=t[n],a=new ao({map:J5(s),depthTest:!1,fog:!1}),o=new Gr(a),{x:l,y:c,z:h}=oi(0,i,bm);return o.position.set(l,c,h),o.scale.set(Ol,Ol,1),o.renderOrder=p5,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const e=this.camera.fov*Math.PI/360,t=wm*Math.PI/360,i=Ol*Math.tan(e)/Math.tan(t);for(const n of this.compassSprites)n.scale.set(i,i,1)}disposeCompassLabels(){for(const e of this.compassSprites)e.removeFromParent(),e.material.map?.dispose(),e.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const e of this.starTiers)this.disposeMesh(e.points);this.starTiers=[]}disposeMesh(e){if(!e)return;e.removeFromParent(),"geometry"in e&&e.geometry.dispose();const t=e.material;for(const i of Array.isArray(t)?t:[t]){const n=i.map;n&&n.dispose(),i.dispose()}}}const ki=Math.PI/180;function wo(r,e,t){return Math.max(e,Math.min(t,r))}function Um(r,e){return r+Math.random()*(e-r)}function Fl(r,e){return(r%(e*2)+e*3)%(e*2)-e}let Ul,Bl;function G5(r){switch(r){case"snow":return V5();case"hail":return W5()}}function V5(){if(Ul)return Ul;const r=64,e=document.createElement("canvas");e.width=r,e.height=r;const t=e.getContext("2d"),i=t.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)"),t.fillStyle=i,t.fillRect(0,0,r,r),Ul=new Kn(e),Ul}function W5(){if(Bl)return Bl;const r=64,e=document.createElement("canvas");e.width=r,e.height=r;const t=e.getContext("2d"),i=t.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)"),t.fillStyle=i,t.fillRect(0,0,r,r),Bl=new Kn(e),Bl}let zl;function X5(){if(zl)return zl;const r=64,e=document.createElement("canvas");e.width=r,e.height=r;const t=e.getContext("2d"),i=t.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)"),t.fillStyle=i,t.fillRect(0,0,r,r),zl=new Kn(e),zl}const q5=`
7865
7866
  uniform float uMaxSize;
7866
7867
  uniform float uScale;
7867
7868
  attribute float aLife;
@@ -7927,4 +7928,4 @@ void main() {
7927
7928
  gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
7928
7929
  }
7929
7930
  `;let Hl;function Z5(){if(Hl)return Hl;const r=128,e=document.createElement("canvas");e.width=r,e.height=r;const t=e.getContext("2d"),i=t.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(.4,"rgba(255,255,255,0.35)"),i.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=i,t.fillRect(0,0,r,r),Hl=new Kn(e),Hl}function Bm(r){const t=document.createElement("canvas");t.width=128,t.height=128;const i=t.getContext("2d"),n=128/2-2,s=128/2,a=128/2,o="#2e2b26",l="#f4f1e2";i.fillStyle=o,i.beginPath(),i.arc(s,a,n,0,Math.PI*2),i.fill();const c=wo(r.illuminatedFraction,0,1),h=r.phaseFraction<.5,d=n*Math.abs(1-2*c),u=c<.5;return i.save(),i.beginPath(),i.arc(s,a,n,0,Math.PI*2),i.clip(),i.fillStyle=l,i.beginPath(),h?(i.arc(s,a,n,-Math.PI/2,Math.PI/2,!1),i.ellipse(s,a,d,n,0,Math.PI/2,-Math.PI/2,u)):(i.arc(s,a,n,Math.PI/2,-Math.PI/2,!1),i.ellipse(s,a,d,n,0,-Math.PI/2,Math.PI/2,u)),i.fill(),i.restore(),new Kn(t)}function J5(r){const e=document.createElement("canvas");e.width=128,e.height=128;const t=e.getContext("2d");return t.fillStyle="rgba(0, 0, 0, 0.55)",t.beginPath(),t.arc(64,64,60,0,Math.PI*2),t.fill(),t.fillStyle="#ffffff",t.font="bold 52px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(r,64,68),new Kn(e)}function td(r){let e=r;return function(){e|=0,e=e+1831565813|0;let i=Math.imul(e^e>>>15,1|e);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}const id=7.5,Mo=9;class Rn{static cache=new Map;static load(e){let t=Rn.cache.get(e);return t||(t=fetch(e).then(i=>i.arrayBuffer()).then(i=>Rn.parse(i)),Rn.cache.set(e,t)),t}static upTo(e,t){const i=e.filter((a,o)=>o===0||e[o-1].magnitudeLimit<t);if(i.length<=1)return Rn.load(e[0].url);const n=i.map(a=>a.url).join(`
7930
- `);let s=Rn.cache.get(n);return s||(s=Promise.all(i.map(a=>Rn.load(a.url))).then(a=>a.reduce((o,l)=>Rn.concat(o,l))),Rn.cache.set(n,s)),s}static parse(e){const t=e.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),i=t*Float32Array.BYTES_PER_ELEMENT;return{count:t,ra:new Float32Array(e,0*i,t),dec:new Float32Array(e,1*i,t),mag:new Float32Array(e,2*i,t),ci:new Float32Array(e,3*i,t)}}static concat(e,t){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:e.count+t.count,ra:i(e.ra,t.ra),dec:i(e.dec,t.dec),mag:i(e.mag,t.mag),ci:i(e.ci,t.ci)}}}const j5=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,Q5=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,eT=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,tT=20,iT=1;class nT{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};resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(e){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",e);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(e,t,i){if(this.requested={type:e,intensity:t,windSpeed:i},!this.context)return;this.paused&&(e="none",t=0,i=0);const n=e==="rain"||e==="hail"?e:"none";if(this.ambientVolume=n==="hail"?Math.min(1,t*1.3+.2):n==="rain"?t: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(j5,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,l=>{this.ambientSource=l?.source,this.ambientGain=l?.gain,l&&(l.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(i/tT,1);const s=i>iT;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(Q5,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,l=>{this.windSource=l?.source,this.windGain=l?.gain,l&&(l.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:i,windSpeed:n}=this.requested;this.setAmbient(t,i,n)}playThunder(){!this.context||this.paused||this.playOneShot(eT,.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.buffers.clear()}applyIfCurrent(e,t,i,n){if(t!==i()){e?.source.stop();return}n(e)}async startLoop(e,t){const i=this.context;if(i)try{const n=await this.getBuffer(e),s=i.createBufferSource();s.buffer=n,s.loop=!0;const a=i.createGain();return a.gain.value=t,s.connect(a).connect(i.destination),s.start(),{source:s,gain:a}}catch(n){console.warn("Weather ambient sound failed to load, staying silent:",n);return}}async playOneShot(e,t){const i=this.context;if(i)try{const n=await this.getBuffer(e),s=i.createBufferSource();s.buffer=n;const a=i.createGain();a.gain.value=t,s.connect(a).connect(i.destination),s.start()}catch(n){console.warn("Thunder sound failed to load:",n)}}async getBuffer(e){const t=this.context;if(!t)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(e);return i||(i=fetch(e).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${e}`);return n.arrayBuffer()}).then(n=>t.decodeAudioData(n)),this.buffers.set(e,i)),i}stopSource(e,t){try{e?.stop()}catch{}e?.disconnect(),t?.disconnect()}}class ss{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:i}=e,[n,s]=this.perifocalAxes(),a=Math.sqrt(ss.SUN_GM_AU3_PER_DAY2*(1+t)/i);this.perihelionPosition=this.scale(n,i),this.perihelionVelocity=this.scale(s,a),this.inverseSemiMajorAxis=(1-t)/i}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(e){const t=e-this.elements.perihelionJd,i=this.universalAnomaly(t),n=this.inverseSemiMajorAxis*i*i,s=this.elements.perihelionAu,a=1-i*i/s*ss.stumpffC(n),o=t-i*i*i/Math.sqrt(ss.SUN_GM_AU3_PER_DAY2)*ss.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(e){const t=this.positionAt(e);return Math.hypot(t.x,t.y,t.z)}universalAnomaly(e){if(e===0)return 0;const t=Math.sign(e),i=Math.sqrt(ss.SUN_GM_AU3_PER_DAY2)*Math.abs(e),n=o=>{const l=this.inverseSemiMajorAxis*o*o,c=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*c)*o*o*o*ss.stumpffS(l)+c*o};let s=Math.max(1,i/this.elements.perihelionAu);for(;n(s)<i;)s*=2;let a=0;for(let o=0;o<ss.MAX_ITERATIONS&&s-a>1e-13*Math.max(1,s);o++){const l=(a+s)/2;n(l)<i?a=l:s=l}return t*(a+s)/2}perifocalAxes(){const e=this.elements.ascendingNodeDeg*Math.PI/180,t=this.elements.argumentOfPerihelionDeg*Math.PI/180,i=this.elements.inclinationDeg*Math.PI/180,n=Math.cos(e),s=Math.sin(e),a=Math.cos(t),o=Math.sin(t),l=Math.cos(i),c=Math.sin(i);return[{x:n*a-s*o*l,y:s*a+n*o*l,z:o*c},{x:-n*o-s*a*l,y:-s*o+n*a*l,z:a*c}]}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}static stumpffC(e){if(Math.abs(e)<1e-6)return 1/2-e/24+e*e/720;if(e>0)return(1-Math.cos(Math.sqrt(e)))/e;const t=Math.sqrt(-e);return(Math.cosh(t)-1)/-e}static stumpffS(e){if(Math.abs(e)<1e-6)return 1/6-e/120+e*e/5040;if(e>0){const i=Math.sqrt(e);return(i-Math.sin(i))/(i*i*i)}const t=Math.sqrt(-e);return(Math.sinh(t)-t)/(t*t*t)}}const W1=[{id:"halley-1910",designation:"1P/Halley",name:{en:"Halley's Comet",fr:"comète de Halley"},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:{en:"Comet Brooks",fr:"comète 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:{en:"Comet Skjellerup-Maristany",fr:"comète 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:{en:"Comet de Kock-Paraskevopoulos",fr:"comète 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:{en:"the Southern Comet",fr:"comète australe"},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:{en:"the Eclipse Comet",fr:"comète de l'éclipse"},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:{en:"Comet Arend-Roland",fr:"comète 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:{en:"Comet Mrkos",fr:"comète 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:{en:"Comet Seki-Lines",fr:"comète 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:{en:"Comet Ikeya-Seki",fr:"comète 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:{en:"Comet Bennett",fr:"comète 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:{en:"Comet White-Ortiz-Bolelli",fr:"comète 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:{en:"Comet Kohoutek",fr:"comète 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:{en:"Comet West",fr:"comète 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:{en:"Comet IRAS-Araki-Alcock",fr:"comète 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:{en:"Halley's Comet",fr:"comète de Halley"},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:{en:"Comet Hyakutake",fr:"comète 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:{en:"Comet Hale-Bopp",fr:"comète 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:{en:"Comet McNaught",fr:"comète 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:{en:"Comet Lovejoy",fr:"comète 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:{en:"Comet PANSTARRS",fr:"comète 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:{en:"Comet NEOWISE",fr:"comète 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:{en:"Comet Tsuchinshan-ATLAS",fr:"comète 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 Ql{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(e){const t=this.julianDayOf(e);return W1.filter(i=>Math.abs(t-i.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(e,t){return this.aroundDate(e).map(i=>this.appearanceOf(i,e,t)).sort((i,n)=>i.magnitude-n.magnitude)[0]}static appearanceOf(e,t,i){const n=Bt(t),s=this.earthPositionAt(n),a=this.apparentPositionOf(e,2451545+n.tt,s),o=this.subtract(a,s),l=this.length(a),c=this.length(o),h=this.tailEndAt(e,a,s,l,n,t,i),d=this.horizontalOf(o,n,t,i);return{apparition:e,position:d,...h,heliocentricDistanceAu:l,earthDistanceAu:c,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},s)),magnitude:this.magnitudeAt(e,l,c)}}static magnitudeAt(e,t,i){const n=e.absoluteMagnitude+5*Math.log10(i)+2.5*e.activityExponent*Math.log10(t);return Math.max(n,e.peakMagnitude)}static tailEndAt(e,t,i,n,s,a,o){if(e.tailLengthAu===void 0)return{};const l=1+e.tailLengthAu/n,c=this.subtract({x:t.x*l,y:t.y*l,z:t.z*l},i),h=this.subtract(t,i);return{tailEnd:this.horizontalOf(c,s,a,o),tailLengthDeg:this.angleBetween(h,c)}}static apparentPositionOf(e,t,i){const n=this.orbitOf(e);let s=n.positionAt(t);for(let a=0;a<2;a++){const o=this.length(this.subtract(s,i))/this.LIGHT_SPEED_AU_PER_DAY;s=n.positionAt(t-o)}return s}static horizontalOf(e,t,i,n){const s=xa(n_(),new Et(e.x,e.y,e.z,t)),a=xa(C1(t),s),o=OE(t,new _f(n.lat,n.lng,n.elevationM)),l=new Et(a.x-o.x,a.y-o.y,a.z-o.z,t),c=Af(l);return If(c.ra,c.dec,i,n)}static earthPositionAt(e){return xa(i_(),Us(xe.Earth,e))}static julianDayOf(e){return 2451545+Bt(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const i=new ss(e.orbit);return this.orbits.set(e.id,i),i}static subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}static length(e){return Math.hypot(e.x,e.y,e.z)}static angleBetween(e,t){const i=(e.x*t.x+e.y*t.y+e.z*t.z)/(this.length(e)*this.length(t)||1);return Math.acos(Math.min(1,Math.max(-1,i)))*180/Math.PI}}const nd=[{id:"sn-1006",kind:"supernova",designation:"SN 1006",name:{en:"Supernova of 1006",fr:"supernova de 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:{en:"Supernova of 1054",fr:"supernova de 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:{en:"Supernova of 1181",fr:"supernova de 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:{en:"Tycho's Supernova",fr:"supernova de Tycho"},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:{en:"Kepler's Supernova",fr:"supernova de Kepler"},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:{en:"Nova Coronae Borealis 1866",fr:"nova de la Couronne boréale 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:{en:"Nova Aurigae 1891",fr:"nova du Cocher 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:{en:"Nova Persei 1901",fr:"nova de Persée 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:{en:"Nova Geminorum 1912",fr:"nova des Gémeaux 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:{en:"Nova Aquilae 1918",fr:"nova de l'Aigle 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:{en:"Nova Cygni 1920",fr:"nova du Cygne 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:{en:"Nova Pictoris 1925",fr:"nova du Peintre 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:{en:"Nova Herculis 1934",fr:"nova d'Hercule 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:{en:"Nova Lacertae 1936",fr:"nova du Lézard 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:{en:"Nova Puppis 1942",fr:"nova de la Poupe 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:{en:"Nova Coronae Borealis 1946",fr:"nova de la Couronne boréale 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:{en:"Nova Herculis 1960",fr:"nova d'Hercule 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:{en:"Nova Herculis 1963",fr:"nova d'Hercule 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:{en:"Nova Delphini 1967",fr:"nova du Dauphin 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:{en:"Nova Vulpeculae 1968",fr:"nova du Petit Renard 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:{en:"Nova Serpentis 1970",fr:"nova du Serpent 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:{en:"Nova Cygni 1975",fr:"nova du Cygne 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:{en:"Nova Centauri 1986",fr:"nova du Centaure 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:{en:"Supernova 1987A",fr:"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:{en:"Nova Cygni 1992",fr:"nova du Cygne 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:{en:"Nova Velorum 1999",fr:"nova des Voiles 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:{en:"Nova Aquilae 1999",fr:"nova de l'Aigle 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:{en:"Nova Sagittarii 2002",fr:"nova du Sagittaire 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:{en:"Nova Ophiuchi 2006",fr:"nova d'Ophiuchus 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:{en:"Nova Scorpii 2007",fr:"nova du Scorpion 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:{en:"Nova Delphini 2013",fr:"nova du Dauphin 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:{en:"Nova Centauri 2013",fr:"nova du Centaure 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:{en:"Nova Ophiuchi 2021",fr:"nova d'Ophiuchus 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 Ac{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(e){const t=this.julianDayOf(e);return nd.filter(i=>this.magnitudeAt(i,t)!==void 0)}static appearancesAt(e,t){const i=this.julianDayOf(e),n=[];for(const s of nd){const a=this.magnitudeAt(s,i);a!==void 0&&n.push({outburst:s,position:fn.ofJ2000(s.raHours,s.decDeg,e,t),magnitude:a})}return n.sort((s,a)=>s.magnitude-a.magnitude)}static brightestAt(e,t){return this.appearancesAt(e,t)[0]}static byId(e){return nd.find(t=>t.id===e)}static magnitudeAt(e,t){const i=e.lightCurve,n=t-e.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],[l,c]=i[s]??i[0];if(l===a)return o;const h=Math.min(1,Math.max(0,(n-a)/(l-a)));return o+h*(c-o)}static julianDayOf(e){return e.getTime()/864e5+this.UNIX_EPOCH_JD}}const sT=[{id:"quadrantids",code:"QUA",name:{en:"Quadrantids",fr:"Quadrantides"},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:{en:"April Lyrids",fr:"Lyrides d'avril"},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:{en:"eta Aquariids",fr:"Êta Aquarides"},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:{en:"alpha Capricornids",fr:"Alpha Capricornides"},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:{en:"Southern delta Aquariids",fr:"Delta Aquarides du Sud"},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:{en:"Perseids",fr:"Perséides"},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:{en:"Southern Taurids",fr:"Taurides du Sud"},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:{en:"October Draconids",fr:"Draconides d'octobre"},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:{en:"Orionids",fr:"Orionides"},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:{en:"Northern Taurids",fr:"Taurides du Nord"},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:{en:"Leonids",fr:"Léonides"},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:{en:"Geminids",fr:"Géminides"},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:{en:"Ursids",fr:"Ursides"},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}],La=6.5;class Sa{static activeAt(e){return sT.flatMap(t=>{const i=this.nearness(t,e);return i<=0?[]:[{shower:t,zhr:t.peakZhr*i,nearness:i}]})}static nearness(e,t){const i=this.dayOfYear(t),n=this.dayOfYear(this.asDate(e.start)),s=this.dayOfYear(this.asDate(e.peak)),a=this.dayOfYear(this.asDate(e.end)),o=this.wrappedDelta(i,s),l=this.wrappedDelta(s,n),c=this.wrappedDelta(a,s);return o<0?o<-l?0:1+o/l:o>0?o>c?0:1-o/c:1}static observedRatePerHour(e,t,i,n=La){if(t<=0)return 0;const s=La-n;return e*Math.sin(t*Math.PI/180)/Math.pow(i,s)}static radiantPosition(e,t,i){return fn.ofJ2000(e.radiantRaHours,e.radiantDecDeg,t,i)}static dayOfYear(e){const t=Date.UTC(e.getUTCFullYear(),0,1);return Math.floor((Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())-t)/864e5)+1}static asDate(e){return new Date(Date.UTC(2001,e.month-1,e.day))}static wrappedDelta(e,t){const i=e-t;return i>182?i-365:i<-182?i+365:i}}class Lt{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const i=Bt(e),n=new Uc(0,kE(e).elon-90,1),s=xa(r_(i),Tf(n,i)),a=Af(s);return If(a.ra,a.dec,e,t)}static observedRatePerHour(e,t=La){const i=Lt.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),n=La-t;return(Lt.QUIET_RATE_PER_HOUR+i)/Math.pow(Lt.POPULATION_INDEX,n)}static schedule(e){const t=new Hc(e.seed^1542469173);return pr.schedule(e).map(i=>{const n=Lt.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),s=i.fromRadiantDeg*Math.PI/180,a=Lt.turnAround(n,t.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:Lt.toHorizontal(o),bearingDeg:Lt.bearingFrom(o,n)}})}static turnAround(e,t){const[i,n]=Lt.basisAround(e),s=t*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(e,t){const[i,n]=Lt.basisAround(e),s=e.x*t.x+e.y*t.y+e.z*t.z,a=Lt.normalise({x:t.x-e.x*s,y:t.y-e.y*s,z:t.z-e.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(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=Lt.normalise(Lt.cross(e,t));return[i,Lt.normalise(Lt.cross(e,i))]}static toHorizontal(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,e.y/t)))*180/Math.PI,azimuthDeg:(Math.atan2(e.x,-e.z)*180/Math.PI%360+360)%360}}static appearanceOf(e){const t=Lt.toCartesian(e.radiant??{altitudeDeg:90,azimuthDeg:0}),i=Lt.turnAround(t,e.bearingDeg),n=e.fromRadiantDeg*Math.PI/180;return Lt.toHorizontal({x:t.x*Math.cos(n)+i.x*Math.sin(n),y:t.y*Math.cos(n)+i.y*Math.sin(n),z:t.z*Math.cos(n)+i.z*Math.sin(n)})}static toCartesian(e){const t=e.altitudeDeg*Math.PI/180,i=e.azimuthDeg*Math.PI/180,n=Math.cos(t);return{x:n*Math.sin(i),y:Math.sin(t),z:-n*Math.cos(i)}}static cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}static normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}static TYPICAL_VELOCITY_KM_S=40}const zm="https://ufoathome.org/tle/index.json";class Si{static MAX_ELEMENT_AGE_DAYS=7;static DAY_MS=864e5;fetchImpl;indexUrls;index;files=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??Si.defaultIndexUrls()}static defaultIndexUrls(){const e=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&e.push(new URL("/tle/index.json",location.href).href),e.includes(zm)||e.push(zm),e}static FIRST_SNAPSHOT="2021-02-22";async covers(e){const t=Date.parse(`${Si.FIRST_SNAPSHOT}T00:00:00Z`)-Si.MAX_ELEMENT_AGE_DAYS*Si.DAY_MS;if(e.getTime()<t)return!1;const i=await this.loadIndex();return i?Object.values(i.index.kinds).some(n=>e.getTime()>=Date.parse(n.from)-Si.MAX_ELEMENT_AGE_DAYS*Si.DAY_MS&&e.getTime()<=Date.parse(n.to)+Si.MAX_ELEMENT_AGE_DAYS*Si.DAY_MS):!1}async at(e){const t=await this.loadIndex();if(!t)return;const{index:i,base:n}=t,s=[],a=[];for(const o of Object.keys(i.kinds)){const l=await this.kindAt(o,e,i,n);s.push(...l),a.push(this.coverageOf(o,e,i,l.length>0))}return{objects:s,coverage:a,credit:i.credit,creditUrl:i.source}}async kindAt(e,t,i,n){const s=t.getTime(),a=i.binDays*Si.DAY_MS,o=Math.floor(s/a),l=s-o*a<a/2?o-1:o+1,c=new Set(i.kinds[e].bins),h=[o,l].map(v=>new Date(v*a).toISOString().slice(0,10)).filter(v=>c.has(v));if(h.length===0)return[];const[d,...u]=await Promise.all([this.json(new URL(`objects-${e}.json`,n).href),...h.map(v=>this.binary(new URL(`${e}/${v}.bin`,n).href))]),f=new Map;for(const v of u)for(const m of Si.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)/Si.DAY_MS;if(m>Si.MAX_ELEMENT_AGE_DAYS)continue;const g=d[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:e,launch:g.launch,stdMag:g.stdMag,elements:v,ageDays:m})}return p}coverageOf(e,t,i,n){const{from:s,to:a}=i.kinds[e],o=t.getTime(),l=Si.MAX_ELEMENT_AGE_DAYS*Si.DAY_MS,c=n?"covered":o<Date.parse(s)-l?"before":o>Date.parse(a)+l?"after":"gap";return{kind:e,status:c,from:s,to:a}}static decode(e,t){const i=new DataView(e),n=[];for(let s=0;s+t<=e.byteLength;s+=t)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 e of this.indexUrls)try{const t=await this.fetchImpl(e);if(!t.ok)continue;return{index:await t.json(),base:e}}catch{}})(),this.index}json(e){return this.cached(e,async t=>t.json())}binary(e){return this.cached(e,async t=>t.arrayBuffer())}cached(e,t){let i=this.files.get(e);return i||(i=this.fetchImpl(e).then(n=>{if(!n.ok)throw new Error(`${e}: ${n.status}`);return t(n)}),i.catch(()=>this.files.delete(e)),this.files.set(e,i)),i}}class rT{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const i=it.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(t.inFrontM!==void 0){const i=it.sizeMAt(t.inFrontM,e);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(e){return e<=0?{}:{minM:this.lowerM===void 0?void 0:it.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:it.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class mr{static DEG_PER_SECOND=360/86164.0905;static degOver(e){return Math.max(0,e)*mr.DEG_PER_SECOND}static instants(e,t){if(!(t>0))return 1;const i=mr.degOver(e)/t;return i<1?1:Math.min(mr.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class Ei{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 mr.DEG_PER_SECOND*3600}static graspOf(e,t={}){const i=t.exposureSeconds??e.exposureSeconds,n=t.fNumber??e.fNumber;if(i===void 0||n===void 0||!(i>0)||!(n>0))return Ei.EYE;const s=t.focalLengthMm??e.frame?.focalLengthMm??Ei.UNKNOWN_CAMERA_FOCAL_MM,a=s/n,o=Ei.resolutionArcsec(e,s,a);return{apertureMm:a,exposureSeconds:Math.min(i,Ei.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(e,t,i){const s=(e.detailUm??Ei.UNKNOWN_CAMERA_DETAIL_UM)/1e3/t*Ei.ARCSEC_PER_RADIAN,a=1.22*Ei.WAVELENGTH_M/(i/1e3)*Ei.ARCSEC_PER_RADIAN;return Math.max(s,a)}static trailLimitedSeconds(e){return e/Ei.skyDriftArcsecPerSecond}static gainOverEye(e,t={}){const i=Ei.graspOf(e,t),n=Ei.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(e,t){const i=t.fieldOfViewDeg===void 0?void 0:ct.focalLengthMmFor(e,t.fieldOfViewDeg);return Ei.gainOverEye(e,{fNumber:t.fNumber,focalLengthMm:i,exposureSeconds:t.exposureSeconds})}}const Hm=111320,io=Math.PI/180,aT=1.02,oT=1;class xo{static of(e,t){const i=xo.sightings(e,t);if(i.length<2)return;const n=xo.baseline(i);if(!n)return;const{near:s,far:a,closedM:o}=n,l=Math.tan(a.widthDeg/2*io)===0?0:Math.tan(s.widthDeg/2*io)/Math.tan(a.widthDeg/2*io);if(l<aT)return;const c=o/(l-1),h=it.sizeMAt(c,s.widthDeg),d=i.map(u=>({t:u.t,m:it.distanceMAt(h,u.widthDeg)}));return{widthM:h,distanceM:d,nearestM:Math.min(...d.map(u=>u.m)),fromT:a.t,toT:s.t,closedM:o}}static sightings(e,t){return e.timeline.allKeyframes.flatMap(i=>{const n=i.shapes.find(o=>o.sourceId===t)?.shape,s=n?.angular?.widthDeg,a=nt(e,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(e){let t;for(const i of e)for(const n of e){if(i.t>=n.t)continue;const s=xo.closedAlongSight(i,n),[a,o,l]=s>=0?[n,i,s]:[i,n,-s];l<oT||a.widthDeg<=o.widthDeg||(!t||l>t.closedM)&&(t={near:a,far:o,closedM:l})}return t}static closedAlongSight(e,t){const i=(t.lat-e.lat)*Hm,n=(t.lng-e.lng)*Hm*Math.cos(e.lat*io),s=(e.sightAzimuthDeg??0)*io;return i*Math.cos(s)+n*Math.sin(s)}}class Di{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(e){if(e.statedM!==void 0&&e.statedM>0)return{distanceM:Di.atLeastNearest(e.statedM),basis:"stated"};if(e.hypothesisM!==void 0&&e.hypothesisM>0)return{distanceM:Di.atLeastNearest(e.hypothesisM),basis:"hypothesis"};if(e.derivedM!==void 0&&e.derivedM>0)return{distanceM:Di.atLeastNearest(e.derivedM),basis:"derived"};const t=Di.largest(e.range?.minM,e.crossing?.behindM),i=Di.smallest(e.range?.maxM,e.crossing?.inFrontM),n=t===void 0?void 0:t*Di.MARGIN,s=i===void 0?void 0:i/Di.MARGIN;return n!==void 0&&s!==void 0?{distanceM:Di.atLeastNearest(n<=s?Math.sqrt(n*s):n),basis:"bounded"}:n!==void 0?{distanceM:Di.atLeastNearest(n),basis:"bounded"}:s!==void 0&&s<Di.CONVENTIONAL_M?{distanceM:Di.atLeastNearest(s),basis:"bounded"}:{distanceM:Di.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(e){return Math.max(Di.NEAREST_M,e)}static largest(...e){const t=e.filter(i=>i!==void 0&&i>0);return t.length===0?void 0:Math.max(...t)}static smallest(...e){const t=e.filter(i=>i!==void 0&&i>0);return t.length===0?void 0:Math.min(...t)}}Cc();const lT={sun:{en:"Sun",fr:"Soleil"},moon:{en:"Moon",fr:"Lune"},Venus:{en:"Venus",fr:"Vénus"},Mars:{en:"Mars",fr:"Mars"},Jupiter:{en:"Jupiter",fr:"Jupiter"},Saturn:{en:"Saturn",fr:"Saturne"}},cT=["en","fr"],hT={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},dT={en:"{name} — satellite, mag {mag}, {height} km up",fr:"{name} — satellite, mag {mag}, à {height} km d'altitude"},X1="satellites-change",uT={en:"{name} — mag {mag}, {alt}° below the horizontal",fr:"{name} — mag {mag}, {alt}° sous l'horizontale"},Gm="comet:",Vm="nova:",fT={building:{en:"Building",fr:"Bâtiment"},tree:{en:"Tree",fr:"Arbre"},crop:{en:"Crop row",fr:"Rang de culture"},mound:{en:"Stone heap",fr:"Tas de pierres"},streetlight:{en:"Streetlight",fr:"Lampadaire"},vehicle:{en:"Vehicle",fr:"Véhicule"},witness:{en:"Witness",fr:"Témoin"},aircraft:{en:"Aircraft",fr:"Aéronef"},entity:{en:"Being",fr:"Être"}},pT=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,mT=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,gT=-18,vT={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},sd={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class Df extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",fr,pa]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;distanceHypotheses=new Map;depths=new Map;directionScratch=new P;meteorScheduleFor;lightningScheduleFor;lightningFlashes=[];lastLightningT;lastTimeMs=0;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new Si;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;starCatalogDepth=0;weatherAudio=new nT;animateWhilePausedValue=!1;set animateWhilePaused(e){e!==this.animateWhilePausedValue&&(this.animateWhilePausedValue=e,this.syncAnimationsToPlayback())}get animateWhilePaused(){return this.animateWhilePausedValue}thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=e=>{this.sceneRenderer.setCompassHovered(!0);const t=this.ufoElement.canvasElement,i=t.getBoundingClientRect();if(i.width===0||i.height===0)return;const n=(e.clientX-i.left)/i.width*t.width,s=(e.clientY-i.top)/i.height*t.height;if(this.ufoElement.hasVisibleShapeAt(n,s)){this.hoverTooltip.hidden=!0;return}const a=(e.clientX-i.left)/i.width*2-1,o=-((e.clientY-i.top)/i.height*2-1),l=fa(Ns.preferencesFor(this),cT),c=this.sceneRenderer.pickBodyAt(a,o);if(c){this.showHoverTooltip(e,this.bodyName(c,l));return}const h=this.sceneRenderer.pickDecorAt(a,o),d=h?this.ufoElement.sighting.decor.find(p=>p.id===h):void 0;if(d){this.showHoverTooltip(e,this.said.read(d.title)||fT[d.kind][l]);return}const u=this.sceneRenderer.pickSatelliteAt(a,o);if(u){this.showHoverTooltip(e,dT[l].replace("{name}",u.name).replace("{mag}",u.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(u.heightKm).toLocaleString()));return}const f=this.sceneRenderer.pickStarAt(a,o);if(f){const p=f.star.mag,v=f.altitudeDeg,m=(v<0?uT:hT)[l];this.showHoverTooltip(e,m.replace("{name}",f.star.name[l]).replace("{mag}",p.toLocaleString(void 0,{maximumFractionDigits:Math.abs(p)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(v)))));return}this.hoverTooltip.hidden=!0};bodyName(e,t){const i=e.startsWith(Gm)?e.slice(Gm.length):void 0,n=i?W1.find(a=>a.id===i):void 0,s=e.startsWith(Vm)?Ac.byId(e.slice(Vm.length)):void 0;return n?.name[t]??s?.name[t]??lT[e]?.[t]??e}showHoverTooltip(e,t){this.hoverTooltip.textContent=t,this.hoverTooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${e.clientX-i.left+12}px`,this.hoverTooltip.style.top=`${e.clientY-i.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash(e){clearTimeout(this.thunderTimeoutId),this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),Qt.thunderDelayMs(e))}handleFirstInteraction=()=>{this.removeEventListener("pointerdown",this.handleFirstInteraction,!0),this.removeEventListener("keydown",this.handleFirstInteraction,!0),this.weatherAudio.resume(),this.setWeather(kt(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=e=>{this.lastTimeMs=e.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"&&this.sceneRenderer.frame(performance.now())};syncAnimationsToPlayback(){const e=this.ufoElement.playbackState==="playing",t=e||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(t,e),this.weatherAudio.setPaused(!t),t||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${w2}</style>${b2}`,this.shadow.appendChild(e.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 tn(this.sceneCanvas),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(wd),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",t=>this.lookToward(t.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.sceneRenderer.onMapSubjectBounds=t=>this.ufoElement.setMapSubjectBounds(t),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.addEventListener("referenceview",t=>this.applyReferenceView(t.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 rs(Ns.preferencesFor(this))}saidTexts;connectedCallback(){this.saidTexts=void 0,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 e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose(),queueMicrotask(()=>{this.isConnected||this.sceneRenderer.releaseContext()})}attributeChangedCallback(e,t,i){if(e==="src"&&i&&i!==t&&this.isConnected&&this.loadFromSrc(i),(e==="star-catalog-src"||e==="deep-star-catalog-src")&&i!==t&&this.isConnected&&this.loadStars(),e==="show-compass"&&i!==t&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),e==="max-pixel-ratio"&&i!==t){const n=Number(i);this.sceneRenderer.setMaxPixelRatio(Number.isFinite(n)&&n>0?n:Math.min(window.devicePixelRatio||1,2))}(e===fr||e===pa)&&i!==t&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const e of[fr,pa])this.ufoElement.toggleAttribute(e,this.hasAttribute(e))}setCompassForced(e){this.sceneRenderer.setCompassForced(e)}lookToward(e){const t=nt(this.ufoElement.sighting,this.lastTimeMs);if(e.kind==="witness"||t?.lat===void 0||t.lng===void 0||t.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:i,z:n}=mi(e.lat,e.lng,t.lat,t.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-t.headingDeg)%360+540)%360-180,-t.pitchDeg)}setLookOffset(e,t){this.sceneRenderer.setLookOffset(e,t),this.ufoElement.setLookOffset(e,t),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(e,t){this.sceneRenderer.setIndoorLook(e,t)}setCloudRendering(e){this.sceneRenderer.setCloudRendering(e)}setWeather(e){this.sceneRenderer.setWeather(e),this.weatherAudio.setAmbient(e.precipitationType,e.precipitationIntensity,e.windSpeed)}pickCloudAt(e,t){return this.sceneRenderer.pickCloudAt(e,t)}cloudDirectionAt(e,t){return this.sceneRenderer.cloudDirectionAt(e,t)}pickDecorAt(e,t){return this.sceneRenderer.pickDecorAt(e,t)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(e){this.sightingData=await Xu.json(e)}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.ufoElement.sightingData=e,this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}referenceAspect(e){return this.sceneRenderer.referenceAspect(e)}screenPointOf(e){return this.sceneRenderer.screenPointOf(e)}directionAt(e,t){return this.sceneRenderer.directionAt(e,t)}referenceFailedToLoad(e){return this.sceneRenderer.referenceFailedToLoad(e)}applyReferenceView(e){this.sceneRenderer.setReferencesShown(e.shown);for(const t of this.ufoElement.sighting.references)this.sceneRenderer.setReferenceView(t.id,{opacity:e.opacity})}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}setTerrainProviders(e){this.sceneRenderer.setTerrainProviders(e)}setDecorModelProvider(e){this.sceneRenderer.setDecorModelProvider(e)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const e=this.ufoElement.sighting.instrument,t=it.CANVAS_HEIGHT_PX,i=ct.frameWidthPx(e,t);this.frameElement.style.setProperty("--frame-aspect",`${i} / ${t}`)}resizeToStage(){const e=this.frameElement.getBoundingClientRect(),t=Math.max(1,Math.round(e.width)),i=Math.max(1,Math.round(e.height));this.sceneCanvas.width=t,this.sceneCanvas.height=i,this.sceneRenderer.resize(t,i)}async loadStars(){const e=[{magnitudeLimit:id,url:this.getAttribute("star-catalog-src")??pT},{magnitudeLimit:Mo,url:this.getAttribute("deep-star-catalog-src")??mT}],t=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=t>id?Mo:id;const n=await Rn.upTo(e,t);i===this.starCatalogRequest&&(this.starCatalog=n,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=Mo||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const e=this.ufoElement.sighting,t=Ei.gainFor(e.instrument,{fNumber:nt(e,0)?.fNumber,fieldOfViewDeg:gi.fovOf(e,0),exposureSeconds:e.exposure});return hr(gT,t)}updateAstronomy(e){this.ensureStarsDeepEnough(),this.applySceneAt(e);const t=un.windowEndingAt(e,this.exposureSeconds()),i=t.seconds,n=this.degreesPerPixelAt(e),s=mr.instants(i,n),a=Math.max(s,this.ufoElement.exposureTimes(e).length,un.instants(this.ufoElement.sighting.decor,nt(this.ufoElement.sighting,e)?.elevationM??0,t.fromMs,i,n));if(a<=1){this.sceneRenderer.setExposure(1);return}this.sceneRenderer.setExposure(a,o=>this.applySceneAt(t.fromMs+t.ms*o/(a-1),{sky:Math.floor(o*s/a)!==Math.floor((o-1)*s/a),stepMs:t.ms/a}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(e){const t=this.sceneCanvas.height;return t<=0?0:gi.fovOf(this.ufoElement.sighting,e)/t}applySceneAt(e,t){const i=this.ufoElement.sighting;this.setWeather(kt(i,e)),this.sceneRenderer.setInstrument(i.instrument),this.updateMeteorShower(i,e),this.updateLightning(i,e,t!==void 0),this.sceneRenderer.setDecor(i.decor),this.sceneRenderer.setReferences(i.references);const n=nt(i,e),s=nt(i,0),a=kt(i,0),o=Object.fromEntries(Bn(kt(i,e)).map(M=>[M.id,tc(e,i.weatherTrack,a,s,n,M.id)]));this.sceneRenderer.setCloudOffset(tc(e,i.weatherTrack,a,s,n),o),this.sceneRenderer.setObserverPose(n??sd),this.sceneRenderer.setLensOptics(this.lensOpticsAt(e)),this.sceneRenderer.setInstrumentGain(Ei.gainFor(i.instrument,{fNumber:n?.fNumber,fieldOfViewDeg:gi.fovOf(i,e),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0),this.sceneRenderer.setGait(jt.of(i)?.offsetAt(e)??jt.STILL),this.sceneRenderer.updateDecorAnchoring(nt(i,0),n,e),this.sceneRenderer.updateDecorLitState(e,t?.stepMs??0),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng),this.pushPhenomenaAt(e);const l=n?.lat??sd.lat,c=n?.lng??sd.lng,h=zn(i.event.time??{},c,i.event.utcOffsetHours),d={lat:l,lng:c,elevationM:n?.elevationM??0};if(this.pushSatellitesAt(h,e,d),t&&!t.sky)return;if(!h){this.sceneRenderer.setAstronomy(vT);return}const u=new Date(h.getTime()+e),f=Math.max(1,Math.round(.25*this.degreesPerPixelAt(e)/mr.DEG_PER_SECOND*1e3)),p=Math.max(1e-8,this.degreesPerPixelAt(e)*.1),v=`${Math.floor(u.getTime()/f)}|${Math.round(l/p)}|${Math.round(c/p)}|${Math.round(d.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(v===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=v;const m={...Ui("Sun",u,d),magnitude:Fh("Sun",u)},g={...Ui("Moon",u,d),phase:_c(u),magnitude:Fh("Moon",u)},x=a_.map(M=>({body:M,position:Ui(M,u,d),magnitude:Fh(M,u)}));this.sceneRenderer.setAstronomy({sun:m,moon:g,planets:x,comet:this.cometAt(u,d),novae:Ac.appearancesAt(u,d).map(({outburst:M,position:w,magnitude:S})=>({id:M.id,position:w,magnitude:S})),stars:this.starCatalog?{catalog:this.starCatalog,date:u,observer:d}:void 0,frame:{date:u,observer:d}}),this.ufoElement.setSunAltitude(m.altitudeDeg)}pushSatellitesAt(e,t,i){if(this.ensureSatellites(e),!e||!this.satellites){this.sceneRenderer.setSatellites([]);return}const n=new Date(e.getTime()+t),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(e){const t=e?String(e.getTime()):"";if(t===this.satellitesFor)return;this.satellitesFor=t,this.satellites=void 0,this.satellitePassesMemo=void 0;const i=++this.satelliteRequest;if(!e){this.satelliteStatus="none";return}this.satelliteStatus="loading";const n=a=>{i===this.satelliteRequest&&(this.satelliteStatus=a,this.dispatchEvent(new CustomEvent(X1)))},s=Df.tleArchive;(async()=>{if(!await s.covers(e))return n("outside");const[a,o]=await Promise.all([s.at(e),sn(()=>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.updateAstronomy(this.lastTimeMs)}})().catch(()=>n("unavailable"))}get satelliteState(){const e=this.satellites?.snapshot;return{status:this.satelliteStatus,coverage:e?.coverage,credit:e?.credit,creditUrl:e?.creditUrl}}satellitePassesDuring(e){const t=this.satellites,i=this.ufoElement.sighting,n=nt(i,0),s=i.event.place?.[0],a=n?.lat??s?.lat,o=n?.lng??s?.lng;if(!t||a===void 0||o===void 0)return[];const l=zn(i.event.time??{},o,i.event.utcOffsetHours);if(!l)return[];const c=Math.min(Math.max(e,0),4*36e5),h={lat:a,lng:o,elevationM:n?.elevationM??0},d=JSON.stringify([this.satellitesFor,l.getTime(),a,o,h.elevationM,c]);if(this.satellitePassesMemo?.key===d)return this.satellitePassesMemo.passes;const u=Math.max(10,Math.ceil(c/1e3/600)),f=t.passes.passesDuring(l,new Date(l.getTime()+c),h,u);return this.satellitePassesMemo={key:d,passes:f},f}cometAt(e,t){const i=Ql.brightestAt(e,t);if(i)return{id:i.apparition.id,position:i.position,tailEnd:i.tailEnd,magnitude:i.magnitude}}pushPhenomenaAt(e){const t=this.ufoElement.sighting;t!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=t);const i=t.timeline,n=this.ufoElement.canvasElement,s=this.ufoElement.frameShiftPx,a=this.projectionAt(e),o=new Map,l=new Map,c=new Set;for(const p of i.sourceIds){const v=i.getInterpolatedShapeAt(e,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(hn.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)},x=g!==void 0&&Math.abs(g.ndcX)<=1&&Math.abs(g.ndcY)<=1,M=x?this.sceneRenderer.decorDistancesAt(g.ndcX,g.ndcY,p):{};c.add(p),(x||v.aim)&&c.delete(p);const w=v.angular?.widthDeg??a.pxToDeg(v.bounds.width),S=this.sizeEstimateOf(p);S.add(w,M);const _=xo.of(t,p);l.set(p,Di.resolve({hypothesisM:this.distanceHypotheses.get(p),derivedM:_&&w>0?it.distanceMAt(_.widthM,w):void 0,range:S.distanceRangeAt(w),crossing:M}))}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 M=l.get(m);M&&l.set(p,{distanceM:M.distanceM*.999,basis:M.basis});break}this.depths=l;const h=i.sourceIds,d=[];for(const[p,v]of o)d.push({sourceId:p,shape:v,distanceM:l.get(p).distanceM,renderOrder:h.indexOf(p),aim:v.aim,hidden:c.has(p)});const f=(nt(t,e)?.rollDeg??0)+(jt.of(t)?.offsetAt(e)??jt.STILL).rollDeg;this.sceneRenderer.setPhenomena(d,{projection:a,canvasWidthPx:n.width,canvasHeightPx:n.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,n.height)),starPoints:ct.starPointsOf(t.instrument),rollRad:f*Math.PI/180})}setDistanceHypothesis(e,t){t===void 0||!(t>0)?this.distanceHypotheses.delete(e):this.distanceHypotheses.set(e,t),this.updateAstronomy(this.lastTimeMs)}depthOf(e){return this.depths.get(e)}sizeRangeOf(e){return this.sizeEstimateOf(e).sizeRange}distanceRangeAt(e,t){const i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,e);if(!i)return{};const n=i.angular?.widthDeg??this.projectionAt(t).pxToDeg(i.bounds.width);return this.sizeEstimateOf(e).distanceRangeAt(n)}sizeContradictory(e){return this.sizeEstimateOf(e).contradictory}updateMeteorShower(e,t){this.ensureMeteorSchedule(e),this.sceneRenderer.updateMeteors(t)}updateLightning(e,t,i){if(this.ensureLightningSchedule(e),this.sceneRenderer.updateLightning(t),i)return;const n=this.lastLightningT;if(this.lastLightningT=t,n===void 0||t<n||this.ufoElement.playbackState!=="playing")return;const s=this.lightningFlashes.filter(a=>a.t>n&&a.t<=t).pop();s&&kt(e,s.t).storm&&this.handleLightningFlash(s)}ensureLightningSchedule(e){const t=kt(e,0).precipitationIntensity,i=`${this.meteorInputsOf(e)}|${t}`;if(i===this.lightningScheduleFor)return;this.lightningScheduleFor=i;const n=e.event.time,s=e.event.place?.[0],a=n?.year!==void 0?zn(n,s?.lng??0,e.event.utcOffsetHours):void 0,o=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,l=Math.round((a?.getTime()??0)/1e3)+Math.round((s?.lat??0)*1e3)+7;this.lightningFlashes=Qt.schedule({durationMs:o,seed:l,intensity:t}),this.sceneRenderer.setLightning(this.lightningFlashes)}ensureMeteorSchedule(e){const t=this.meteorInputsOf(e);t!==this.meteorScheduleFor&&(this.meteorScheduleFor=t,this.scheduleMeteors(e))}meteorInputsOf(e){const t=e.event.place?.[0],i=e.event.time;return JSON.stringify([t?.lat,t?.lng,i?.year,i?.month,i?.day,i?.hour,i?.minute,i?.second,e.event.utcOffsetHours,e.event.durationSeconds,e.timeline.duration])}scheduleMeteors(e){const t=e.event.place?.[0],i=e.event.time,n=t?.lat!==void 0&&t.lng!==void 0&&i?.year!==void 0?zn(i,t.lng,e.event.utcOffsetHours):void 0;if(!n||t?.lat===void 0||t.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const s={lat:t.lat,lng:t.lng,elevationM:0},a=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,o=Math.round(n.getTime()/1e3)+Math.round(t.lat*1e3),l=Lt.schedule({ratePerHour:Lt.observedRatePerHour(Lt.apexPosition(n,s).altitudeDeg),durationMs:a,velocityKmS:Lt.TYPICAL_VELOCITY_KM_S,seed:o}),c=Sa.activeAt(n).map(d=>{const u=Sa.radiantPosition(d.shower,n,s);return{entry:d,position:u,rate:Sa.observedRatePerHour(d.zhr,u.altitudeDeg,d.shower.populationIndex)}}).sort((d,u)=>u.rate-d.rate)[0];if(!c||c.rate<=0){this.sceneRenderer.setMeteorShower(l,0,0);return}const h=pr.schedule({ratePerHour:c.rate,durationMs:a,velocityKmS:c.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...l],c.position.altitudeDeg,c.position.azimuthDeg)}meteorByRank(e){this.ensureMeteorSchedule(this.ufoElement.sighting);const t=[...this.sceneRenderer.meteorSchedule].filter(s=>s.t+s.durationMs<=this.ufoElement.seekableDuration).sort((s,a)=>a.brightness-s.brightness);if(t.length===0)return;const i=t[e%t.length],n=this.sceneRenderer.meteorMidpoint(i);if(n)return{t:Math.round(i.t+i.durationMs*.45),...n}}lensOpticsAt(e){const t=this.ufoElement.sighting,i=t.instrument,n=i.frame,s=nt(t,e),a=s?.fNumber??i.fNumber;if(!n||a===void 0)return;const o=ct.focalLengthMmFor(i,gi.fovOf(t,e));if(o!==void 0)return{focalLengthMm:o,fNumber:a,focusDistance:s?.focusDistanceM??0,frameHeightMm:n.heightMm}}projectionAt(e){const t=this.ufoElement.sighting;return gn.of(t.instrument,it.CANVAS_HEIGHT_PX,gi.fovOf(t,e))}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new rT,this.sizeEstimates.set(e,t)),t}}const Gu="rr0-scene";function yT(){Cc(),customElements.get(Gu)||customElements.define(Gu,Df)}class bT{constructor(e,t){this.timeline=e,this.clock=t}currentPointer=null;shapePrototype=null;sourceId="";start(e,t){this.sourceId=e,this.shapePrototype=t,this.currentPointer=null,this.clock.start(i=>this.recordSample(i))}onPointerMove(e,t){this.currentPointer={x:e,y:t}}stop(){this.clock.stop()}recordSample(e){if(!this.currentPointer||!this.shapePrototype)return;const t=cg(this.shapePrototype,this.currentPointer.x,this.currentPointer.y);this.timeline.addKeyframe(e,[{sourceId:this.sourceId,shape:t}])}}class wT{constructor(e){this.intervalMs=e}rafId=null;startTime=0;lastTick=0;start(e){this.startTime=performance.now(),this.lastTick=0;const t=()=>{const i=performance.now()-this.startTime;i-this.lastTick>=this.intervalMs&&(this.lastTick=i,e(i)),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}stop(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}}const MT=[{id:"echo",name:{en:"the Echo balloons",fr:"les ballons Echo"},from:"1960-08-12",to:"1969-06-07",peakMagnitude:-1,note:"Echo 1 and 2 were 30- and 40-metre reflective balloons, as bright as the brightest stars and moving slowly enough to be watched — deliberately visible, widely announced in newspapers, and the first objects most people ever saw crossing the night sky. They fall squarely inside the sighting waves this project reconstructs."},{id:"iridium-flares",name:{en:"the Iridium flares",fr:"les flashes d'Iridium"},from:"1997-05-05",to:"2019-12-27",peakMagnitude:-8,note:"The original Iridium satellites carried flat, mirror-finish antennas that threw a sunbeam a few kilometres wide across the ground: a still point of sky flaring to magnitude -8 over five seconds and vanishing again. Nothing else in the sky does that."},{id:"iss",name:{en:"the International Space Station",fr:"la Station spatiale internationale"},from:"1998-11-20",peakMagnitude:-5.9,note:"Since its first module, and much brighter as it grew: at its best it outshines everything in the sky but the Sun and the Moon, crossing in a straight silent line in about four minutes."},{id:"starlink-trains",name:{en:"the Starlink trains",fr:"les trains de Starlink"},from:"2019-05-24",peakMagnitude:1,note:"In the days after a launch, satellites still bunched in their deployment string cross as an evenly spaced line of lights — the most reported 'formation of UFOs' of the era. They spread out within weeks, so a train is a fact about the days after a launch rather than about the year."}],xT=23493,Wm=[2,3,2,1,2,5,4,6,5,6,6,6,6,6,6,6,9,9,9,9,9,9,14,14,15,16,16,16,16,16,18,22,25,24,29,28,29,33,34,35,40,40,42,42,43,46,48,48,49,53,53,54,58,61,70,70,74,78,79,83,92,92,99,97,101,102,109,115,126,125,123,125,127,130,139,153,157,156,161,156,165,174,193,193,201,203,212,215,224,244,255,263,262,281,293,307,312,327,339,336,343,353,359,369,386,396,405,410,421,419,424,434,443,450,460,480,492,504,509,516,519,524,527,530,527,535,543,549,564,571,573,576,582,584,600,600,608,618,625,632,637,642,648,654,661,667,669,667,671,671,697,692,703,697,710,714,724,731,747,755,764,770,782,802,801,815,819,837,846,856,878,881,877,900,906,907,917,932,932,936,954,973,989,986,991,990,1002,1009,1021,1024,1040,1038,1058,1078,1098,1092,1094,1099,1122,1132,1140,1151,1154,1161,1176,1185,1202,1206,1227,1228,1243,1265,1281,1288,1296,1325,1328,1336,1354,1373,1375,1393,1398,1411,1432,1457,1462,1476,1487,1485,1506,1509,1521,1524,1537,1543,1563,1586,1598,1614,1621,1620,1640,1658,1660,1673,1670,1686,1708,1715,1726,1726,1745,1749,1767,1774,1790,1798,1803,1805,1815,1818,1819,1820,1833,1822,1821,1819,1838,1835,1845,1841,1851,1869,1865,1868,1871,1870,1879,1882,1886,1900,1899,1908,1921,1928,1954,1966,1976,1986,1999,2007,2015,2030,2036,2057,2067,2072,2077,2088,2101,2106,2112,2119,2127,2142,2171,2176,2203,2226,2242,2241,2244,2254,2263,2284,2300,2320,2327,2345,2364,2367,2402,2423,2425,2434,2443,2461,2476,2495,2505,2520,2531,2535,2556,2567,2599,2608,2625,2639,2660,2663,2668,2681,2695,2702,2709,2719,2720,2738,2746,2763,2778,2788,2796,2807,2822,2831,2831,2853,2863,2866,2883,2892,2895,2921,2919,2937,2941,2947,2964,2987,2992,2987,2995,3002,3021,3025,3026,3036,3052,3049,3059,3077,3075,3083,3086,3107,3123,3124,3146,3155,3168,3179,3204,3205,3211,3233,3252,3253,3276,3287,3294,3293,3297,3314,3326,3335,3338,3355,3362,3358,3365,3364,3376,3375,3382,3418,3429,3432,3455,3463,3483,3490,3502,3509,3521,3532,3542,3544,3553,3571,3580,3588,3596,3603,3633,3639,3649,3655,3660,3670,3699,3699,3707,3723,3747,3752,3754,3766,3772,3778,3781,3798,3815,3814,3824,3832,3853,3859,3879,3885,3899,3912,3910,3924,3937,3951,3951,3961,3963,3961,3976,3977,3988,4004,4018,4025,4047,4074,4086,4108,4133,4136,4159,4168,4182,4192,4200,4215,4230,4239,4257,4678,4698,4694,4713,4719,4739,4750,4756,4764,4771,4788,4792,4790,4809,4821,4829,4834,4836,4843,4853,4863,4872,4881,4890,4898,4901,4897,4895,4884,4886,4886,4894,4897,4905,4905,4909,4907,4925,4918,4920,4929,4925,4928,4936,4943,4944,4951,4955,4952,4974,4976,4975,4981,4994,4997,5022,5023,5032,5043,5048,5051,5066,5062,5068,5075,5082,5082,5098,5102,5110,5113,5119,5123,5138,5138,5145,5149,5157,5165,5166,5169,5178,5183,5190,5192,5203,5204,5207,5214,5228,5234,5245,5249,5256,5262,5275,5278,5305,5303,5315,5321,5348,5358,5369,5369,5372,5385,5402,5409,5427,5429,5429,5439,5456,5464,5481,5485,5494,5509,5520,5526,5543,5555,5568,5575,5585,5596,5602,5620,5627,5644,5647,5660,5678,5680,5684,5692,5700,5711,5727,5733,5736,5756,5776,5797,5805,5804,5807,5800,5808,5814,5822,5839,5856,5869,5889,5902,5919,5921,5936,5937,5936,5957,5961,5975,5981,6002,6015,6027,6035,6042,6059,6062,6080,6081,6092,6097,6106,6127,6129,6198,6227,6231,6243,6249,6262,6255,6279,6304,6315,6326,6330,6334,6361,6358,6359,6379,6381,6389,6388,6404,6404,6443,6465,6473,6497,6500,6513,6524,6532,6538,6578,6572,6576,6584,6582,6608,6639,6656,6761,6764,6768,6772,6836,6905,6916,6925,6951,6984,7009,7072,7092,7110,7122,7140,7148,7170,7168,7180,7194,7247,7374,7391,7393,7382,7425,7485,7530,7568,7587,7602,7602,7715,7771,7900,8004,8103,8153,8162,8296,8319,8437,8566,8746,8860,8913,9128,9275,9585,9739,10014,10123,10167,10203,10288,10323,10398,10544,10721,10883,11044,11157,11442,11515,11787,12070,12269,12468,12484,12619,12883,13008,13264,13317,13549,13859,14049,14175,14360,14498,14687,14843,14984,15093,15279,15431,15623,15741,15788,15966,16025,16132,16419,16568,16791,16892,17060,17269,17598,17959,18194,18482,18804,19136,19564,19990,20249,20509,20943,21248,21539,21845,22196,22412];class Pn{static FIRST_ORBIT="1957-10-04";static EARTH_RADIUS_KM=6371;static LOW_ORBIT_KM=500;static shadowHeightKm(e){if(e>=0)return 0;const t=-e*Math.PI/180;return Pn.EARTH_RADIUS_KM*(1/Math.cos(t)-1)}static isLitOverhead(e,t){return e>Pn.shadowHeightKm(t)}static classesAt(e){const t=e.getTime();return MT.filter(i=>{const n=Date.parse(`${i.from}T00:00:00Z`),s=i.to===void 0?1/0:Date.parse(`${i.to}T23:59:59Z`);return t>=n&&t<=s})}static trackedInOrbitAt(e){const t=e.getUTCFullYear()*12+e.getUTCMonth()-xT;if(!(t<0))return Wm[Math.min(t,Wm.length-1)]}static visibilityAt(e,t){const i=Ui("Sun",e,t).altitudeDeg;return{sunAltitudeDeg:i,shadowHeightKm:Pn.shadowHeightKm(i),lowOrbitLit:Pn.isLitOverhead(Pn.LOW_ORBIT_KM,i),classes:Pn.classesAt(e),trackedObjects:Pn.trackedInOrbitAt(e),anythingInOrbit:e.getTime()>=Date.parse(`${Pn.FIRST_ORBIT}T00:00:00Z`)}}}class rt{static COARSE_STEP_DEG=10;static FINE_STEP_DEG=2;static FINE_SPAN_DEG=10;static LOWEST_DEG=5;static THRESHOLD_CONTRAST=.5;static CONE_SEPARATION_DEG=60;galaxy=new Qe;dust=new Pt;assess(e,t){const i=Ui("Sun",e,t),n=Ui("Moon",e,t),s={altitudeDeg:n.altitudeDeg,phaseAngleDeg:Be.phaseAngleOf(_c(e).illuminatedFraction)},a=Ki.galactic(e,t),o=rt.unit(a.centre),l=rt.unit(a.rotation),c=rt.unit(a.pole),h=rt.unit(Ki.eclipticPole(e,t)),d=rt.unit(i),u=rt.unit(n),f=rt.normalize(rt.reject(d,h));let p,v,m=0;const g=(x,M)=>{const w=rt.unit({altitudeDeg:x,azimuthDeg:M}),S=rt.between(w,d),_=Be.magPerArcsec2({altitudeDeg:i.altitudeDeg,separationDeg:S},{...s,separationDeg:rt.between(w,u)},x);_>m&&(m=_);const D=us.fromMagPerArcsec2(_),y=10**(-.4*Be.EXTINCTION_PER_AIR_MASS*(Be.airMass(x)-1)),T=this.galaxy.surfaceBrightnessS10(Math.atan2(rt.dot(w,l),rt.dot(w,o))*180/Math.PI,Math.asin(Math.max(-1,Math.min(1,rt.dot(w,c))))*180/Math.PI)*y;p=rt.better(p,T,D,_,x,M,S);const A=Math.max(-1,Math.min(1,rt.dot(w,h))),I=rt.normalize(rt.reject(w,h)),R=this.dust.surfaceBrightnessS10(rt.between(I,f),Math.asin(A)*180/Math.PI)*y;v=rt.better(v,R,D,_,x,M,S)};for(let x=rt.LOWEST_DEG;x<=90;x+=rt.COARSE_STEP_DEG)for(let M=0;M<360;M+=rt.COARSE_STEP_DEG)g(x,M);for(const x of[p,v]){if(!x)continue;const M=rt.FINE_SPAN_DEG,w=rt.FINE_STEP_DEG;for(let S=x.altitudeDeg-M;S<=x.altitudeDeg+M;S+=w)if(!(S<rt.LOWEST_DEG||S>90))for(let _=x.azimuthDeg-M;_<=x.azimuthDeg+M;_+=w)g(S,(_+360)%360)}return{milkyWay:p&&p.contrast>=rt.THRESHOLD_CONTRAST?p:void 0,zodiacal:v&&v.contrast>=rt.THRESHOLD_CONTRAST?v:void 0,darkestSkyMagPerArcsec2:m}}static better(e,t,i,n,s,a,o){const l=t/i;return e&&e.contrast>=l?e:{contrast:l,altitudeDeg:s,azimuthDeg:a,magPerArcsec2:us.toMagPerArcsec2(t),skyMagPerArcsec2:n,sunSeparationDeg:o}}static unit(e){const t=e.altitudeDeg*Math.PI/180,i=e.azimuthDeg*Math.PI/180,n=Math.cos(t);return[n*Math.sin(i),Math.sin(t),-n*Math.cos(i)]}static dot(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}static between(e,t){return Math.acos(Math.max(-1,Math.min(1,rt.dot(e,t))))*180/Math.PI}static reject(e,t){const i=rt.dot(e,t);return[e[0]-i*t[0],e[1]-i*t[1],e[2]-i*t[2]]}static normalize(e){const t=Math.hypot(...e)||1;return[e[0]/t,e[1]/t,e[2]/t]}}const ST=.5,Gl=40,ET=4e5,Js=Math.PI/180,jr=180/Math.PI;class Ni{static localDirection(e,t,i,n=new P){const s=Math.tan(t/2*Js);return n.set((e.u*2-1)*s*i,(1-e.v*2)*s,-1).normalize()}static picturePoint(e,t,i){if(e.z>=0)return;const n=Math.tan(t/2*Js),s=e.x/-e.z/(n*i),a=e.y/-e.z/n;return{u:(s+1)/2,v:(1-a)/2}}static worldDirection(e,t=new P){const i=e.azimuthDeg*Js,n=e.altitudeDeg*Js;return t.set(Math.sin(i)*Math.cos(n),Math.sin(n),-Math.cos(i)*Math.cos(n))}static aimOf(e){const t=Math.hypot(e.x,e.z);return{azimuthDeg:(Math.atan2(e.x,-e.z)*jr+360)%360,altitudeDeg:Math.atan2(e.y,t)*jr}}static rotationOf(e){const t=new _t;return t.rotation.set(e.pitchDeg*Js,-e.headingDeg*Js,-(e.rollDeg??0)*Js,"YXZ"),t.quaternion.clone()}static anglesOf(e){const t=new Yn().setFromQuaternion(e,"YXZ"),i=(-t.y*jr%360+360)%360,n=-t.z*jr;return{headingDeg:i,pitchDeg:t.x*jr,rollDeg:Math.abs(n)<1e-9?0:n}}static worldDirectionOf(e,t,i,n=new P){return this.localDirection(e,t.fovDeg,i,n).applyQuaternion(this.rotationOf(t))}static picturePointOf(e,t,i){const n=e.clone().applyQuaternion(this.rotationOf(t).invert()),s=this.picturePoint(n,t.fovDeg,i);if(!(!s||s.u<0||s.u>1||s.v<0||s.v>1))return s}static solve(e,t,i,n=e.length>=3){if(e.length<2)return;if(!n)return this.solveAtField(e,t,i);let s=1,a=179;const o=(Math.sqrt(5)-1)/2;let l=a-o*(a-s),c=s+o*(a-s),h=this.solveAtField(e,t,l),d=this.solveAtField(e,t,c);for(let f=0;f<60&&a-s>1e-4;f++){if(!h||!d)return;h.residualDeg<d.residualDeg?(a=c,c=l,d=h,l=a-o*(a-s),h=this.solveAtField(e,t,l)):(s=l,l=c,h=d,c=s+o*(a-s),d=this.solveAtField(e,t,c))}return h&&d?h.residualDeg<d.residualDeg?h:d:h??d}static solveAtField(e,t,i){const n=e.map(c=>this.localDirection(c.picture,i,t)),s=e.map(c=>this.worldDirection(c.scene)),a=this.triad(n,s);if(!a)return;const o=this.refine(a,n,s);return{registration:{...this.anglesOf(o),fovDeg:i},residualDeg:this.residualDeg(o,n,s)}}static triad(e,t){let i=0,n=1,s=-1;for(let h=0;h<e.length;h++)for(let d=h+1;d<e.length;d++){const u=e[h].clone().cross(e[d]).lengthSq();u>s&&(s=u,i=h,n=d)}if(s<1e-12)return;const a=(h,d)=>{const u=h.clone().normalize(),f=h.clone().cross(d).normalize(),p=f.clone().cross(u);return new ze().set(u.x,p.x,f.x,u.y,p.y,f.y,u.z,p.z,f.z)},o=a(e[i],e[n]),c=a(t[i],t[n]).multiply(o.transpose());return new qn().setFromRotationMatrix(new Ye().setFromMatrix3(c))}static refine(e,t,i){const n=e.clone(),s=new P;for(let a=0;a<20;a++){const o=new ze().set(0,0,0,0,0,0,0,0,0),l=o.elements,c=new P;for(let f=0;f<t.length;f++){s.copy(t[f]).applyQuaternion(n);const p=s,v=[[0,p.z,-p.y],[-p.z,0,p.x],[p.y,-p.x,0]],m=[i[f].x-p.x,i[f].y-p.y,i[f].z-p.z];for(let g=0;g<3;g++){for(let x=0;x<3;x++)for(let M=0;M<3;M++)l[x*3+g]+=v[M][g]*v[M][x];c.setComponent(g,c.getComponent(g)+v[0][g]*m[0]+v[1][g]*m[1]+v[2][g]*m[2])}}for(let f=0;f<3;f++)l[f*3+f]+=1e-9;const h=c.applyMatrix3(o.invert()),d=h.length();if(d<1e-12)break;const u=new qn().setFromAxisAngle(h.normalize(),d);if(n.premultiply(u).normalize(),d<1e-10)break}return n}static residualDeg(e,t,i){let n=0;const s=new P;for(let a=0;a<t.length;a++){s.copy(t[a]).applyQuaternion(e);const o=s.angleTo(i[a])*jr;n+=o*o}return Math.sqrt(n/t.length)}}const Xm=6371e3,no=Math.PI/180;class da{constructor(e=t=>fetch(t).then(i=>{if(!i.ok)throw new Error(`${t}: HTTP ${i.status}`);return i.json()})){this.fetchJson=e}static API="https://api.panoramax.xyz/api";static CREDIT="Panoramax";static CREDIT_URL="https://panoramax.fr/";async nearby(e,t,i=300,n=50){const s=i/111320,a=i/(111320*Math.cos(e*no)),o=[t-a,e-s,t+a,e+s].map(h=>h.toFixed(6)).join(",");return((await this.fetchJson(`${da.API}/search?bbox=${o}&limit=${n}`)).features??[]).map(h=>this.picture(h,e,t)).filter(h=>h!==void 0&&h.distanceM<=i).sort((h,d)=>h.distanceM-d.distanceM)}picture(e,t,i){const[n,s]=e.geometry.coordinates,a=e.assets.sd?.href??e.assets.hd?.href;if(!a)return;const{distanceM:o,bearingDeg:l}=da.offset(t,i,s,n),c=e.properties,h=c["pers:interior_orientation"]?.field_of_view,d=(c.providers??[]).map(f=>f.name).filter(f=>!!f),u=c.license??"CC-BY-SA-4.0";return{id:e.id,lat:s,lng:n,distanceM:o,bearingDeg:l,azimuthDeg:c["view:azimuth"],panorama:h!==void 0&&h>=360,takenAt:c.datetime??"",src:a,srcFull:e.assets.hd?.href,credit:`${da.CREDIT}${d.length?` — ${d.join(", ")}`:""} (${u})`,creditUrl:`${da.API.replace(/\/api$/,"")}/#focus=pic&pic=${e.id}`}}static offset(e,t,i,n){const s=(i-e)*no*Xm,a=(n-t)*no*Xm*Math.cos((e+i)/2*no);return{distanceM:Math.hypot(a,s),bearingDeg:(Math.atan2(a,s)/no+360)%360}}}const Vl=36e5,qm=25;class rd{constructor(e){this.provider=e}async infer(e){const t=this.questionOf(e);if(!t)return{status:"incomplete"};const{origin:i,start:n}=t,s=Ea(e.event)??0,a=this.sampleTimings(e,n,s);let o;try{o=await this.provider.getWeather({points:a.map(l=>this.pointAt(e,l,i))})}catch{return{status:"failed",at:n}}return o?{status:"inferred",at:n,source:o.source,keyframes:o.samples.map((l,c)=>({t:a[c].t,weather:l.weather}))}:{status:"unavailable",at:n}}applyTo(e,t){if(!(t.status!=="inferred"||!t.keyframes||!t.source)){e.weatherTrack.clear();for(const i of t.keyframes)e.weatherTrack.addKeyframe(i.t,i.weather);e.weatherSource=t.source}}sampleTimes(e,t){const i=[e],n=e.getTime()+t;let s=Math.floor(e.getTime()/Vl)*Vl+Vl;for(;s<=n&&i.length<qm;)i.push(new Date(s)),s+=Vl;return t>0&&i[i.length-1].getTime()!==n&&i.length<qm&&i.push(new Date(n)),i}sampleTimings(e,t,i){const n=e.timeline.duration>0?e.timeline.duration:i;return i<=0||n<=0?[{time:t,t:0}]:this.sampleTimes(t,i).map(s=>{const a=(s.getTime()-t.getTime())/i;return{time:s,t:Math.round(n*Math.max(0,Math.min(1,a)))}})}canInfer(e){return this.questionOf(e)!==void 0}questionOf(e){const t=this.originOf(e);if(!t)return;const i=e.event.time;if(i?.year===void 0||i.month===void 0||i.day===void 0)return;const n=zn(i,t.lng,e.event.utcOffsetHours);return n?{origin:t,start:n}:void 0}originOf(e){const t=nt(e,0),i=e.event.place?.[0],n=t?.lat??i?.lat,s=t?.lng??i?.lng;return n===void 0||s===void 0?void 0:{lat:n,lng:s}}pointAt(e,t,i){const n=nt(e,t.t);return{lat:n?.lat??i.lat,lng:n?.lng??i.lng,time:t.time}}}const _T=Date.UTC(1940,0,1),Ym=36e5,Km=.25,TT=.7,AT=.45,IT=.1,DT=2,CT=.3,RT=.2,PT=8,ad=.125,LT=.05,$m=125,Zm=100,Jm=2500,od=3500,ld=8e3,kT=95,NT=99,OT=[96,99],FT=["cloud_cover","cloud_cover_low","cloud_cover_mid","cloud_cover_high","precipitation","snowfall","weather_code","wind_speed_10m","wind_direction_10m","temperature_2m","dew_point_2m"];class q1{fetchImpl;baseUrl;cache=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.baseUrl=e.baseUrl??"https://archive-api.open-meteo.com/v1/archive"}async getWeather(e){if(e.points.length===0)return;const t=e.points.map(f=>f.time.getTime()),i=Math.min(...t);if(i<_T)return;const n=new Map;for(const f of e.points){const p=this.cellKey(f);n.has(p)||n.set(p,{lat:f.lat,lng:f.lng,index:n.size})}const s=this.requestUrl([...n.values()],new Date(i),new Date(Math.max(...t))),a=this.cache.get(s);if(a)return a;const o=await this.fetchImpl(s);if(!o.ok)throw new Error(`Open-Meteo HTTP ${o.status}`);const l=await o.json(),c=Array.isArray(l)?l:[l];if(c.length<n.size||c.some(f=>f.error||!f.hourly))return;const h={id:"era5",name:"ERA5 (Open-Meteo)",url:s},d=e.points.map(f=>this.sampleAt(c[n.get(this.cellKey(f)).index].hourly,f.time));if(d.some(f=>f===void 0))return;const u={samples:d,source:h};return this.cache.set(s,u),u}cellKey(e){return`${Math.round(e.lat/Km)},${Math.round(e.lng/Km)}`}requestUrl(e,t,i){const n=new URLSearchParams({latitude:e.map(s=>s.lat).join(","),longitude:e.map(s=>s.lng).join(","),start_date:this.isoDate(t),end_date:this.isoDate(i),hourly:FT.join(","),wind_speed_unit:"ms",timezone:"UTC"});return`${this.baseUrl}?${n}`}isoDate(e){return e.toISOString().slice(0,10)}sampleAt(e,t){const i=this.recordAt(e,t);return i&&{time:t,weather:this.toWeather(i)}}recordAt(e,t){const i=e.time.map(o=>Date.parse(`${o}Z`)),n=t.getTime();if(i.length===0||n<i[0]-Ym||n>i[i.length-1]+Ym)return;if(n<=i[0])return this.recordFrom(e,0);if(n>=i[i.length-1])return this.recordFrom(e,i.length-1);let s=0;for(;s+1<i.length&&i[s+1]<=n;)s++;const a=i[s+1]-i[s];return this.blendRecords(this.recordFrom(e,s),this.recordFrom(e,s+1),a>0?(n-i[s])/a:0)}recordFrom(e,t){const i={cloudCover:e.cloud_cover[t]/100,cloudCoverLow:e.cloud_cover_low[t]/100,cloudCoverMid:e.cloud_cover_mid[t]/100,cloudCoverHigh:e.cloud_cover_high[t]/100,precipitationMm:e.precipitation[t],snowfallCm:e.snowfall[t],weatherCode:e.weather_code[t],windSpeedMs:e.wind_speed_10m[t],windFromDeg:e.wind_direction_10m[t],temperatureC:e.temperature_2m[t],dewPointC:e.dew_point_2m[t]};return Object.values(i).some(n=>n===void 0||Number.isNaN(n))?void 0:i}blendRecords(e,t,i){if(!e||!t)return e??t;const n=(a,o)=>a+(o-a)*i,s=((t.windFromDeg-e.windFromDeg)%360+540)%360-180;return{cloudCover:n(e.cloudCover,t.cloudCover),cloudCoverLow:n(e.cloudCoverLow,t.cloudCoverLow),cloudCoverMid:n(e.cloudCoverMid,t.cloudCoverMid),cloudCoverHigh:n(e.cloudCoverHigh,t.cloudCoverHigh),precipitationMm:n(e.precipitationMm,t.precipitationMm),snowfallCm:n(e.snowfallCm,t.snowfallCm),weatherCode:i<.5?e.weatherCode:t.weatherCode,windSpeedMs:n(e.windSpeedMs,t.windSpeedMs),windFromDeg:((e.windFromDeg+s*i)%360+360)%360,temperatureC:n(e.temperatureC,t.temperatureC),dewPointC:n(e.dewPointC,t.dewPointC)}}cloudLayersFrom(e){return[{id:"record-low",type:"unknown",baseM:Math.round(this.clamp($m*(e.temperatureC-e.dewPointC),Zm,Jm)),thicknessM:650,coverage:this.clamp(e.cloudCoverLow,0,1),sizeM:1400,density:1},{id:"record-mid",type:"unknown",baseM:od,thicknessM:800,coverage:this.clamp(e.cloudCoverMid,0,1),sizeM:2500,density:1},{id:"record-high",type:"cirrus",baseM:ld,thicknessM:400,coverage:this.clamp(e.cloudCoverHigh,0,1),sizeM:2200,density:.35}]}toWeather(e){const t=e.weatherCode>=kT&&e.weatherCode<=NT,i=this.precipitationTypeFrom(e);return{cloudLayers:this.cloudLayersFrom(e),cloudCover:this.clamp(e.cloudCover,0,1),cloudDarkness:this.cloudDarknessFrom(e,t),cloudBaseM:this.cloudBaseFrom(e),highCloudCover:e.cloudCoverHigh,lowerCloudCover:Math.max(e.cloudCoverLow,e.cloudCoverMid),relativeHumidity:Math.round(ur.relativeHumidity(e.temperatureC,e.dewPointC)*100)/100,precipitationType:i,precipitationIntensity:i==="none"?0:this.clamp(Math.sqrt(e.precipitationMm/PT),0,1),windDirectionDeg:(e.windFromDeg+180)%360,windSpeed:e.windSpeedMs,storm:t}}precipitationTypeFrom(e){return e.snowfallCm>0?"snow":OT.includes(e.weatherCode)?"hail":e.precipitationMm>0?"rain":"none"}cloudDarknessFrom(e,t){const i=e.cloudCoverLow+e.cloudCoverMid+e.cloudCoverHigh;if(i<=0)return 0;const n=(TT*e.cloudCoverLow+AT*e.cloudCoverMid+IT*e.cloudCoverHigh)/i,s=Math.min(1,e.precipitationMm/DT);return this.clamp(n+CT*s+(t?RT:0),0,1)}cloudBaseFrom(e){if(e.cloudCover<LT)return;const t=this.clamp($m*(e.temperatureC-e.dewPointC),Zm,Jm);if(e.cloudCoverLow>=ad)return Math.round(t);if(e.cloudCoverMid>=ad)return od;if(e.cloudCoverHigh>=ad)return ld;const i=Math.max(e.cloudCoverLow,e.cloudCoverMid,e.cloudCoverHigh);if(!(i<=0))return i===e.cloudCoverLow?Math.round(t):i===e.cloudCoverMid?od:ld}clamp(e,t,i){return Math.max(t,Math.min(i,e))}}function UT(){return new q1}const BT=5;class Y1{attribution={text:"© OpenStreetMap",url:"https://osm.org/copyright"};fetchImpl;baseUrl;reverseUrl;cache=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.baseUrl=e.baseUrl??"https://nominatim.openstreetmap.org/search",this.reverseUrl=e.reverseUrl??"https://nominatim.openstreetmap.org/reverse"}async reverse(e,t,i={}){const n=new URLSearchParams({lat:String(e),lon:String(t),format:"jsonv2"});i.language&&n.set("accept-language",i.language);const s=`${this.reverseUrl}?${n}`,a=this.cache.get(s);if(a)return a[0];const o=await this.fetchImpl(s,{signal:i.signal});if(!o.ok)throw new Error(`Nominatim HTTP ${o.status}`);const l=await o.json(),c=l.error?void 0:this.toMatch(l);return this.cache.set(s,c?[c]:[]),c}async search(e,t={}){const i=e.trim();if(i==="")return[];const n=this.requestUrl(i,t),s=this.cache.get(n);if(s)return s;const a=await this.fetchImpl(n,{signal:t.signal});if(!a.ok)throw new Error(`Nominatim HTTP ${a.status}`);const o=await a.json(),l=(Array.isArray(o)?o:[]).map(c=>this.toMatch(c)).filter(c=>c!==void 0);return this.cache.set(n,l),l}requestUrl(e,t){const i=new URLSearchParams({q:e,format:"jsonv2",limit:String(t.limit??BT)});return t.language&&i.set("accept-language",t.language),`${this.baseUrl}?${i}`}toMatch(e){const t=e.display_name??e.name,i=this.coordinate(e.lat),n=this.coordinate(e.lon);return t&&i!==void 0&&n!==void 0?{name:t,lat:i,lng:n}:void 0}coordinate(e){if(e===void 0||e.trim()==="")return;const t=Number(e);return Number.isFinite(t)?t:void 0}}function zT(){return new Y1}const HT=[{id:"nominatim",name:"Nominatim",credit:"© OpenStreetMap",creditUrl:"https://osm.org/copyright",create:()=>new Y1}],GT=[{id:"era5",name:"ERA5 (Open-Meteo)",credit:"© Copernicus/ECMWF",creditUrl:"https://open-meteo.com/en/docs/historical-weather-api",create:()=>new q1}];class VT{attribution;fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis);const t=e.year??2024;this.tileUrlTemplate=`https://tiles.maps.eox.at/wmts/1.0.0/s2cloudless-${t}_3857/default/g/{z}/{y}/{x}.jpg`,this.attribution=`EOxCloudless https://cloudless.eox.at by EOX IT Services GmbH (Contains modified Copernicus Sentinel data ${t})`}async getImageryTexture(e,t){return Mg(e,t,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}const cd=[{id:"aws-terrarium",name:"AWS Terrain Tiles",credit:"© AWS Open Data (SRTM, ETOPO1)",creditUrl:"https://registry.opendata.aws/terrain-tiles/",create:()=>new wg}],jm=[{id:"esri-world",name:"Esri World Imagery",credit:"Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community",creditUrl:"https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9",create:()=>new xg},{id:"eox-s2cloudless",name:"EOX Sentinel-2 cloudless",credit:"EOxCloudless by EOX IT Services GmbH (contains modified Copernicus Sentinel data)",creditUrl:"https://cloudless.eox.at",create:()=>new VT}];class Cf{constructor(e){this.provider=e}static SPAN_DEG=.002;async at(e,t){const i=Cf.SPAN_DEG;try{const s=(await this.provider.getElevationGrid({south:e-i,north:e+i,west:t-i,east:t+i},{width:2,height:2})).heights[0];return Number.isFinite(s)?s:void 0}catch{return}}}class WT{available(){const e=Intl.supportedValuesOf;return e?[...e.call(Intl,"timeZone")].sort():[]}offsetHoursAt(e,t){if(t.year===void 0)return;const i=Date.UTC(t.year,(t.month??1)-1,t.day??1,t.hour??12,t.minute??0,t.second??0),n=this.zoneOffsetHours(e,new Date(i));if(n!==void 0)return this.zoneOffsetHours(e,new Date(i-n*36e5))??n}zoneOffsetHours(e,t){let i;try{i=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).formatToParts(t).find(s=>s.type==="timeZoneName")?.value??""}catch{return}const n=/^GMT(?:([+-])(\d{2}):(\d{2}))?$/.exec(i);if(n)return n[1]?(n[1]==="-"?-1:1)*(Number(n[2])+Number(n[3])/60):0}}function Qr(r,e){return r.find(t=>t.id===e)??r[0]}class XT{constructor(e="https://api.open-meteo.com/v1/forecast"){this.endpoint=e}async zoneAt(e,t){const i=new URL(this.endpoint);i.searchParams.set("latitude",String(e)),i.searchParams.set("longitude",String(t)),i.searchParams.set("timezone","auto"),i.searchParams.set("forecast_days","1");try{const n=await fetch(i.toString());if(!n.ok)return;const s=await n.json();return s.timezone&&s.timezone!=="GMT"?s.timezone:void 0}catch{return}}}const qT=[{id:"open-meteo",name:"Open-Meteo",credit:"© Open-Meteo",creditUrl:"https://open-meteo.com/en/docs",create:()=>new XT}],YT={color:"Color",transparency:"Transparency",halo:"Halo",blur:"Blur",brightness:"Brilliance",shapeTitle:"Name",utcOffset:"Time zone",cloudBase:"Cloud base",elevation:"Altitude",heightAboveGround:"Height above ground",duration:"Duration",placeName:"Place",latitude:"Latitude",longitude:"Longitude",heading:"Heading",pitch:"Tilt",roll:"Roll",observationTime:"Observation start",observationEndTime:"Observation end",assessmentGroup:"Assessment",assessmentNames:{coverage:"Witness info"},assessmentVerdicts:{"hynek.nl":"NL — nocturnal light","hynek.dd":"DD — daylight disc","hynek.rv":"RV — radar-visual","hynek.ce1":"CE1 — close encounter","hynek.ce2":"CE2 — with a physical trace","hynek.ce3":"CE3 — with entities"},witnessGroup:"Witness",witnessId:"ID",witnessTitle:"Title",witnessLastName:"Last name",witnessFirstNames:"First names",caseId:"Case ID",tags:"Tags",cloudCover:"Cloud cover",highCloudCover:"Ice cloud (cirrus)",focalLength:"Focal length",fieldOfView:"Field of view",aperture:"Aperture",exposure:"Exposure",focusDistance:"Focused at",iceCrystalAlignment:"Crystal alignment",cloudDarkness:"Cloud darkness",precipitationType:"Precipitation",precipitationNone:"None",precipitationRain:"Rain",precipitationSnow:"Snow",precipitationHail:"Hail",precipitationIntensity:"Intensity",windDirection:"Wind direction",windSpeed:"Wind speed",storm:"Storm",cloudsGroup:"Clouds",precipitationGroup:"Precipitation",windGroup:"Wind",soundKind:"Sound",soundNone:"None (silent)",soundHum:"Hum",soundWhistle:"Whistle",soundRumble:"Rumble",soundCrackle:"Crackle",soundVolume:"Loudness",soundPitch:"Pitch",soundSrc:"Recording",instrument:"Observed through",decorAircraft:"Aircraft",decorEntity:"Being",decorAltitude:"Altitude",decorLights:"Lights",decorLightsNone:"none",decor:"Environment",decorBuilding:"Building",decorTree:"Tree",decorCrop:"Crop row",decorMound:"Stone heap",decorStreetlight:"Streetlight",decorVehicle:"Vehicle",decorWitness:"Other witness",decorEast:"Distance east",decorNorth:"Distance north",decorHeading:"Heading",decorColor:"Colour",decorLit:"Lit",decorTitle:"Name",milestones:"Moments",milestoneLabel:"Label",milestoneNote:"What happens",addMilestone:"Name this moment",deleteMilestone:"Delete moment",confirmAccept:"Delete",confirmDecline:"Cancel",decorWidth:"Width",decorLength:"Length",decorHeight:"Height",decorModel:"3D model",decorModelNone:"Built-in shape",decorModelAdvanced:"Model from an address",decorModelUrl:"glTF/GLB address",decorModelTitle:"Model name",decorModelAuthor:"Author",decorModelLicense:"Licence",decorModelSource:"Where it came from",decorFloors:"Floors",decorOccupiedFloor:"Occupied floor",decorWitnessSide:"Witness location",decorWitnessSideNone:"Not present",decorWindows:"Windows",decorSideFront:"Front",decorSideBehind:"Behind",decorSideLeft:"Left",decorSideRight:"Right",decorSideFrontLeft:"Front-left",decorSideFrontRight:"Front-right",decorSideBehindLeft:"Behind-left",decorSideBehindRight:"Behind-right"},K1={...YT,oval:"Oval",polygon:"Polygon",addVertex:"Add vertex",deleteVertex:"Delete vertex",notAPolygon:"Select a single polygon shape",tooFewVertices:"A shape needs at least 3 points",shape:"Shape",apparentWidth:"Apparent width",realWidth:"Real width",distance:"Distance",sizeLock:"Hold",lockNone:"nothing",lockApparent:"the apparent width",lockReal:"the real width",lockDistance:"the distance",apparentSize:"{moons}× the Moon",utcOffsetPlaceholder:"from longitude",realSizeBetween:"The scene bounds that width: between {min} and {max} m, from what it crosses",realSizeAtLeast:"The scene bounds that width: at least {min} m, from what it passes behind",realSizeAtMost:"The scene bounds that width: at most {max} m, from what it passes in front of",realSizeUnknown:"Nothing in the scene bounds that width: it is only what the distance implies",realSizeOutside:" — the width above is outside that",blurBound:"Blurred through this lens: nearer than {max} m",blurBoundNoInstrument:"Blur through the naked eye bounds no distance — an eye has no aperture to be out of focus with",blurBoundNotAtInfinity:"Blur bounds a distance only for a lens focused at infinity: this one is focused at {focus} m, which blurs on both sides of it",realSizeContradiction:"Contradiction: the declared crossings cannot all be true",realDistanceHere:" — i.e. between {min} and {max} m here",clearDistanceHypothesis:"Withdraw the distance hypothesis",clearDistanceHypothesisTitle:"Back to what the recording establishes",depthStated:"Drawn at {m} m, as the recording states",depthHypothesis:"Drawn at {m} m: your hypothesis — what the decor hides of it is what a thing that far would lose",depthDerived:"Drawn at {m} m, from the witness's own walk",depthBounded:"Drawn at {m} m, from what it passes behind and in front of",depthConventional:"Drawn at {m} m by convention: nothing in the recording establishes a distance",addShape:"Add shape",deleteShape:"Delete shape",play:"Play",pause:"Pause",noDuration:"No observation duration",group:"Group",ungroup:"Ungroup",bringToFront:"Bring to front",sendToBack:"Send to back",contextMenuDelete:"Delete",confirmDeleteShape:"Delete {name}? This can't be undone.",confirmDeleteShapes:"Delete {count} shapes? This can't be undone.",confirmDeleteMilestone:"Stop naming moment {name}? The recording itself is unchanged.",onlyOneShape:"There is only one shape",alreadyAtFront:"This shape is already at the front",alreadyAtBack:"This shape is already at the back",needTwoShapesToGroup:"Select at least two shapes to group them",notGrouped:"This shape isn't part of a group",multipleShapesSelected:"Multiple shapes selected — select just one to edit this",samplingRate:"Sampling rate",currentPosition:"Current position",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",durationPlaceholder:"observation length",durationImprecise:"These dates don't precisely enough determine a duration — enter it manually.",export:"Export",importFile:"Load JSON file",importUrl:"Or load from URL",importUrlPlaceholder:"https://…/sighting.json",importButton:"Load",importError:"Couldn't load that recording — check the file or URL and try again.",importErrorCors:'That address answers, but the browser is not allowed to read it from this page. The file itself is fine — its server needs to send the header "Access-Control-Allow-Origin: *" with it. If it is not your server, that is what to ask its administrator for.',importErrorMixedContent:"A secure page cannot load an address starting with http://. Use https:// if that server offers it.",importErrorUnreachable:"Nothing answered at that address. Check the spelling, and that you are online.",importErrorStatus:"That server answered with an error ({status}). The address is probably wrong, or the file has moved.",importErrorMalformed:"That address answered, but what came back is not a recording.",record:"Record",stop:"Stop",according:"according to",sourceElevation:"Relief",sourceImagery:"Imagery",placeNamePlaceholder:"Valensole, France",searchPlace:"Locate",placeMatch:"Matches",placeSearching:"Looking up the place…",placeMatchFound:"place found",placeMatchesFound:"places found",placeNotFound:"No place by that name",placeSearchFailed:"Place search temporarily unavailable",utcOffsetImplausible:"This time zone doesn't match the longitude entered, whose own solar time is UTC{solar} — yet the scene and the weather record both obey what is declared here. Clear the field to derive it from the longitude.",timeZoneManual:"offset entered",altitudeAboveSeaLevel:"The witness's altitude above sea level — the ground at the location entered sets its floor: a witness in the Alps is not at 0 m.",groundAt:"ground at {m} m",headingPlaceholder:"unknown",edtfInvalid:"Not a valid EDTF date/time (e.g. 1965-07-01T05:00, 2025-06?, 2025~).",edtfPlaceholder:"YYYY-MM-DDThh:mm[?~%] or hh:mm",observationTimeHint:"EDTF — e.g. 1965-07-01T05:00, 2025-06? (uncertain), 2025~ (approximate), or just 05:00 if the date isn't known",observationEndTimeHint:"EDTF — e.g. 1965-07-01T05:10, 2025-06? (uncertain), 2025~ (approximate), or just 05:10 if the date isn't known",presetsGroupLabel:"UFO shape",witnessDirName:"Dir name",description:"Description",tagsPlaceholder:"comma-separated",weather:"Weather",shapeGroup:"Phenomenon",soundGroup:"Sound",temporalGroup:"Moment",timeQualifierExact:"Exact",timeQualifierApproximate:"Approximate",timeQualifierUncertain:"Uncertain",timeQualifierBoth:"Uncertain and approximate",edtfModeTitle:"Type an imprecise date instead: a year alone, a month, a time with no date",locationGroup:"Location",observationGroup:"Observation",weatherWhilePlaying:"Pause the recording to state the weather — while it plays, the instant these would be written at is moving",weatherInferred:"From weather records",weatherInferredTitle:"Weather isn't testimony: it's a measurable fact, on record for the observation's own date, time and place. Uncheck to state the conditions the witness reported, which then override the record.",weatherLookingUp:"Looking up the record…",weatherNeedsDateAndPlace:"A full date and a place are needed to look up the record",weatherNoRecord:"No record for this date and place",weatherLookupFailed:"Weather records temporarily unreachable",instrumentOutOfPeriod:"{name} — not of this date",unitMillimetres:"mm",unitDegrees:"°",soundSrcPlaceholder:"URL of a real recording",referenceGroup:"Pictures",reference:"Picture",referenceTitle:"Name",referenceSrc:"Address",referenceSrcPlaceholder:"https://…/photo.jpg",referenceKind:"Kind",referencePhoto:"Photo",referencePanorama:"Panorama (360°)",referenceCredit:"Credit",referenceCreditUrl:"Credit link",referenceT:"Taken at",referenceDrawing:"Drawn on",referenceOpacity:"Opacity",referenceHeading:"Heading",referencePitch:"Pitch",referenceRoll:"Roll",referenceFov:"Vertical field",referenceUsePose:"Use the witness's pose",addReferenceUrl:"Add from an address",addReferenceFile:"Add a file",deleteReference:"Delete picture",referenceEmbedded:"{kb} kB embedded in the recording — an address would keep it light",referenceUnreachable:"The picture could not be loaded: check the address, and that its site allows other sites to read it",referenceRegisterHint:"Drag to turn the picture, wheel to change its field; “Add a landmark” to point at a detail on the picture, then at the same one in the render",referenceLandmarkPicture:"Landmark {n}: click the point on the picture",referenceLandmarkScene:"Landmark {n}: click the same point in the render",referenceLandmarkOffPicture:"That click is not on the picture",referenceNotLoaded:"The picture has not arrived yet",referenceLandmarksFit:"{n} landmarks — {deg}° off on average",referenceLandmarks:"Landmarks",addReferenceLandmark:"Add a landmark",deleteReferenceLandmark:"Delete landmark",referenceLandmarkLabel:"Name",referenceLandmarkLabelPlaceholder:"Masking tree, fence…",referenceAdoptPose:"Adopt as the witness's pose",referenceAdoptRationale:"Measured on the picture “{title}”: {n} landmarks lined up, {deg}° of residual",referenceStreetSearch:"Street-level pictures nearby",referenceStreetSearching:"Looking for pictures taken nearby…",referenceStreetNone:"No street-level picture within {m} m (Panoramax)",referenceStreetFailed:"Panoramax could not be reached",referenceStreetAdd:"Add",referenceStreetItem:"{distance} m at {bearing}°, {date}{panorama}",referenceStreetPanorama:" — 360°",referenceStreetTitle:"Street-level picture {distance} m away at {bearing}°, {date}",skyLine:"Sky: {parts}",skyStarsEye:"stars down to magnitude {limit}, which is as faint as an eye went under this sky",skyStarsDeeper:"stars down to magnitude {limit} through a {device} — {gain} magnitudes past the {eye} the witness's own eyes reached",skyStarsShallower:"stars down to magnitude {limit} through a {device} — {gain} magnitudes short of the {eye} the witness's own eyes reached",skyStarsCatalogue:", drawn to {catalogue}, where this project's catalogue stops",skyStarsNone:"no star could be picked out of a sky this bright",skyDetails:"Show the records in full",skyDetailsHide:"Hide the records",skyShowerActive:"{name} — radiant {altitude}° above the horizon, {bearing} — about {rate}/h under this sky, over a sporadic background of {sporadic}/h",skyShowerBelowHorizon:"{name} is active, but its radiant is below the horizon — it can have produced nothing",skyNothingActive:"no meteor shower active on this date — a sporadic background of about {sporadic}/h",showMeteor:"Show me one",skyComet:"{name}, magnitude {magnitude}, {altitude}° above the horizon {bearing}, tail {tail}° long",skyCometNoTail:"{name}, magnitude {magnitude}, {altitude}° above the horizon {bearing}",skyCometBelowHorizon:"{name} was there at magnitude {magnitude}, but below the horizon — nobody here saw it",skyCometInDaylight:"{name}, magnitude {magnitude}, {altitude}° above the horizon {bearing} — but only {elongation}° from the Sun",showComet:"Show me the comet",skyNova:"{name}, a new star of magnitude {magnitude}, {altitude}° above the horizon {bearing}",skyNovaBelowHorizon:"{name} was shining at magnitude {magnitude}, but below the horizon: nobody here saw it",showNova:"Show me the new star",skySatellitePasses:"{count} satellites crossed this sky bright enough to be seen, the brightest {name}, magnitude {magnitude}, {altitude}° above the horizon {bearing} at {time}",skySatellitePassesOne:"one satellite crossed this sky bright enough to be seen: {name}, magnitude {magnitude}, {altitude}° above the horizon {bearing} at {time}",skySatelliteTrain:"among them a train of {count} Starlinks launched on {date}",skySatellitePassesNone:"by the orbital elements archived for that date, no lit satellite crossed this sky brightly enough to be seen",skySatelliteElementsGap:"no orbital elements archived near that date",showSatellite:"Show me a satellite",skyOpticsPossible:"ice cloud enough, around the {source}, for {forms}",skyOpticsAlignment:" — everything but the rings needs crystals falling level, stated here at {alignment}% since no record holds it",skyOpticsHalo22:"a {angle}° ring",skyOpticsHalo46:"a {angle}° ring",skyOpticsParhelia:"sundogs {angle}° to either side",skyOpticsTangentArc:"an arc tangent on top of it",skyOpticsParhelicCircle:"a white circle right round the sky at its own height",skyOpticsCircumzenithal:"a circumzenithal arc {angle}° up",skyOpticsCircumhorizontal:"a circumhorizontal arc far below it",skyOpticsPillar:"a pillar standing over it",skyOpticsNoIce:"no ice cloud: no halo and no sundogs",skyOpticsHidden:"ice cloud above, but a lower deck between it and the witness",skyOpticsSun:"Sun",skyOpticsMoon:"Moon",skyBowPossible:"rain and sunlight enough for {forms}",skyBowMoon:"rain under a Moon {lit}% lit, enough for {forms} — a moonbow, which the eye sees as a white arc",skyGlowBand:"the Milky Way {contrast}× the sky behind it, {altitude}° up {bearing}",skyGlowCone:"the zodiacal light {contrast}× the sky behind it, {altitude}° up {bearing}, {elongation}° from the Sun — a faint tilted cone of light with blurred edges, gone within the hour",skyGlowZodiacalBand:"the zodiacal band {contrast}× the sky behind it, {altitude}° up {bearing} — the whole ecliptic faintly alight, which is not the sight people report",skyGlowMoon:"no Milky Way and no zodiacal light: a Moon {lit}% lit held the sky at {sky} magnitudes a square arcsecond, where they need 22",skyGlowTwilight:"no Milky Way and no zodiacal light: twilight still held the sky at {sky} magnitudes a square arcsecond, where they need 22",skyGlowNothingUp:"sky dark enough ({sky} magnitudes a square arcsecond) but neither the galactic plane nor the ecliptic stood high enough in it",skyBowPrimary:"a bow {radius}° across, its top {top}° up",skyBowSecondary:"a second, fainter one at {radius}° with its colours reversed",skyBowSourceTooHigh:"rain, but with the source {altitude}° up no bow could clear the horizon: they stand {radius}° from the point opposite it",skyBowHidden:"rain, but an unbroken deck between it and the light: no bow",skyBowNoSource:"rain, and nothing lit to make a bow of it",skySatellitesLit:"the Earth's shadow stood {height} km above the witness, so low orbit was still in sunlight — {count} tracked objects were in orbit that month",skySatellitesLitWith:"the Earth's shadow stood {height} km above the witness, so low orbit was still in sunlight — {count} tracked objects were in orbit that month, among them {eras}",skySatellitesShadowed:"the Earth's shadow stood {height} km above the witness: of the {count} tracked objects in orbit that month, nothing in low orbit was lit",skySatellitesNotYet:"nothing had been put in orbit yet",skySatellitesDaylight:"everything in orbit was sunlit, as it always is by day, and {eras} could outshine even this sky",skySatellitesDaylightOne:"everything in orbit was sunlit, as it always is by day, and {eras} could outshine even this sky",skyUnknown:"cannot be worked out without a date and a place",lookAtDecor:"Look at it",addDecor:"Add",deleteDecor:"Delete decor",decorSightingUrl:"Their own recording URL",viewTestimony:"View testimony",noWitnessRecording:"No recording URL set for this witness",masks:"Masks",addWitness:"Add witness",narrativePlaceholder:"What the witness reported, in their own words",narrativeKey:"{source} API key",narrativeNeedsKey:"Enter your own {source} API key to generate a reconstruction from the account",narrativeKeyUnlikely:"This does not look like a Claude API key: they begin with sk-ant-",narrativeWorkspace:"Workspace ID",narrativeWorkspacePlaceholder:"only if your key spans several",narrativeWorkspaceHint:"Only for a key whose scope is the whole organisation. Simpler: leave this empty and create a key scoped to one workspace instead.",narrativeNeedsAsk:"Nothing to send yet",narrativeRemember:"Remember on this device",narrativeDraft:"Generate reconstruction",narrativeStop:"Stop",narrativeWorking:"Reading the account…",narrativeApplied:"{count} fields written into the editor",narrativeUnchanged:"The account states nothing the recording can hold yet",narrativeStated:"What the witness said",narrativeDerived:"Worked out from the account",narrativeAssumed:"Guessed, so the reconstruction runs — check these",narrativeGaps:"What nothing could settle",narrativeErrorCredential:"No key, or one that was refused — check it at console.anthropic.com",narrativeErrorRateLimited:"Too many requests on your account: wait a moment and ask again",narrativeErrorRefused:"The account was not answered. Rephrasing may help; asking again will not",narrativeErrorMalformed:"The answer was not a usable draft — worth asking once more",narrativeErrorUnreachable:"Nothing answered: check the connection",narrativeErrorRejected:"Refused: {detail}",witnessAge:"Age then",witnessOccupation:"Occupation",testimonySource:"Account obtained",testimonySourceUnknown:"unknown",testimonySourceOnSite:"on-site investigation",testimonySourceInterview:"interview in person",testimonySourceTelephone:"by telephone",testimonySourceQuestionnaire:"questionnaire",testimonySourceLetter:"the witness wrote it",testimonySourcePress:"press or broadcast",testimonyFollowedUp:"Followed up",testimonyUnknown:"unknown",testimonyYes:"yes",testimonyNo:"no",questionUnanswered:"Nothing in this recording answers one of the questions a reconstruction needs settled",durationRequired:"The observation needs a length to be replayed at all — state one, or an end time, which may be approximate",questionsUnanswered:"{count} of the questions a full reconstruction answers are unanswered here"},KT=Object.freeze(Object.defineProperty({__proto__:null,sightingEditorMessages_en:K1},Symbol.toStringTag,{value:"Module"})),Qm=new Set;Cc();yT();const ea={width:48,height:28},$T=2500,ZT=600,eg=900,ta=2e-4,JT=900,jT=-1.46,QT=3,tg=.2,eA=.01,tA=1.6,hd=2e3,iA=250,ig=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),As=4,Wl="ufo-1",ng=["oval","polygon"],nA={presetId:"oval",color:"#39ff14",transparency:0,haloScale:1.5,blur:0,brightness:0};function sA(r){return r.kind==="oval"?"oval":"polygon"}const rA=-6,aA=21;class Ct extends HTMLElement{shadow;sceneElement;ufoElement;recordButton;samplingRateInput;presetButtons;presetsGroup;colorInput;transparencyInput;haloScaleInput;blurInput;brightnessInput;blurBoundOutput;sourceSelect;shapeTitleInput;utcOffsetInput;timeZoneSelect;timeZoneProvider=qT[0].create();timeZoneLookupTimer;timeZoneLookedUpAt;autoFilledTimeZone;timeZones=new WT;apparentWidthInput;realWidthInput;objectDistanceInput;sizeLockSelect;apparentSizeOutput;realSizeOutput;clearDistanceHypothesisButton;depthBasisOutput;addShapeButton;deleteShapeButton;contextMenu;contextGroupButton;contextUngroupButton;contextBringToFrontButton;contextSendToBackButton;contextDeleteButton;contextAddVertexButton;contextDeleteVertexButton;decorContextMenu;contextViewTestimonyButton;contextMasksSubmenu;labelContextMasks;playPauseButton;seekInput;timeStartLabel;timeEndLabel;durationInput;exportButton;importFileInput;importUrlInput;importUrlButton;narrativeKeyInput;narrativeWorkspaceInput;narrativeRememberInput;narrativeDraftButton;narrativeStopButton;narrativeCreditLink;narrativeStatus;narrativeReport;placeNameInput;searchPlaceButton;placeMatchRow;placeMatchSelect;placeStatusText;placeProvider=zT();placeMatches=[];placeSearchToken=0;placeReverseTimer;namedCoordinates;latInput;lngInput;headingInput;headingUnit;pitchInput;rollInput;elevationInput;groundElevationOutput;weatherFromRecords=!0;groundElevationM;groundElevationFor;groundElevationTimer;groundElevationToken=0;obsTimeInput;obsTimeNativeInput;obsEndTimeNativeInput;obsTimeQualifier;obsEndTimeQualifier;edtfModeButton;edtfMode=!1;obsEndTimeInput;witnessIdInput;witnessDirNameInput;witnessTitleInput;witnessLastNameInput;witnessFirstNamesInput;witnessAgeInput;witnessOccupationInput;testimonySourceSelect;testimonyFollowedUpSelect;caseIdInput;descriptionInput;tagsInput;cloudEditor;cloudCoverInput;cloudDarknessInput;cloudBaseInput;precipitationTypeSelect;precipitationIntensityInput;windDirectionInput;windSpeedInput;stormInput;weatherInferredInput;weatherSourceText;skyCandidatesOutput;showMeteorButton;showCometButton;showNovaButton;showSatelliteButton;weatherSourceLink;weatherFields;weatherInference=new rd(UT());weatherLookupTimer;weatherLookupToken=0;weatherLookupPending=!1;weatherLookupResult;weatherTrackSpan;soundKindSelect;soundVolumeInput;soundPitchInput;soundPitchValue;soundSrcInput;soundFields;soundKindOptions=new Map;soundPreviewTimer;instrumentSelect;focalLengthInput;labelFocalLength;unitFocalLength;labelFNumber;labelExposure;labelFocusDistance;fNumberInput;exposureInput;focusDistanceInput;labelColor;labelTransparency;labelHalo;labelBlur;labelBrightness;labelShape;labelShapeTitle;labelUtcOffset;labelApparentWidth;labelRealWidth;labelObjectDistance;labelSizeLock;labelSamplingRate;labelDuration;placeSourceRow;weatherSourceRow;terrainSourceRows;chosenSourceId=new Map;labelPlaceName;labelPlaceMatch;labelLatitude;labelLongitude;labelHeading;labelPitch;labelRoll;labelElevation;labelObservationTime;labelObservationEndTime;labelWitnessId;labelWitnessDirName;labelWitnessTitle;labelWitnessLastName;labelWitnessFirstNames;labelWitnessAge;labelWitnessOccupation;labelTestimonySource;labelTestimonyFollowedUp;labelCaseId;labelDescription;labelTags;labelImportFile;labelImportUrl;labelNarrativeKey;labelNarrativeWorkspace;labelNarrativeRemember;groupTabs;groupPanels;paramSummary;paramSummaryBuilder;paramSummarySignature="";labelShapeGroup;labelTemporalGroup;labelLocationGroup;labelObservationGroup;labelWitnessGroup;skyDetailsButton;clampedLines;labelWeatherGroup;labelCloudCover;labelHighCloud;labelIceAlignment;highCloudCoverInput;iceCrystalAlignmentInput;labelCloudDarkness;labelCloudBase;labelPrecipitationType;labelPrecipitationIntensity;labelWindDirection;labelWindSpeed;labelStorm;labelCloudsGroup;labelPrecipitationGroup;labelWindGroup;subgroupTabs;labelWeatherInferred;labelSoundGroup;labelSoundKind;labelSoundVolume;labelSoundPitch;labelSoundSrc;labelInstrument;optionPrecipitationNone;optionPrecipitationRain;optionPrecipitationSnow;optionPrecipitationHail;decorKindSelect;addDecorWitnessButton;addDecorBuildingButton;deleteDecorButton;decorSelect;decorTitleInput;decorEastInput;decorNorthInput;decorHeadingInput;decorColorInput;decorLitInput;decorLightRigSelect;lookAtDecorButton;decorAltitudeInput;labelDecorAltitude;decorSightingUrlInput;decorModelProvider=jl[0].create();confirmOverlay;confirmMessage;confirmAcceptButton;confirmDeclineButton;confirmAnswer;milestoneSelect;milestoneLabelInput;milestoneNoteInput;addMilestoneButton;deleteMilestoneButton;currentMilestoneT;decorWidthInput;decorLengthInput;decorHeightInput;decorModelSelect;decorModelAdvanced;decorModelUrlInput;decorModelTitleInput;decorModelAuthorInput;decorModelLicenseInput;decorModelSourceInput;decorFloorsInput;decorOccupiedFloorInput;decorWitnessSideSelect;decorWindowInputs;labelDecorSide;optionWitnessSide;labelDecor;labelDecorGroup;labelDecorTitle;labelDecorEast;labelDecorNorth;labelDecorHeading;labelDecorColor;labelDecorLit;labelDecorSightingUrl;labelMilestones;labelMilestoneLabel;labelMilestoneNote;labelDecorWidth;labelDecorLength;labelDecorHeight;labelDecorModel;labelDecorModelAdvanced;labelDecorModelUrl;labelDecorModelTitle;labelDecorModelAuthor;labelDecorModelLicense;labelDecorModelSource;labelDecorFloors;labelDecorOccupiedFloor;labelDecorWitnessSide;labelDecorWindows;optionWitnessSideNone;optionDecorBuilding;optionDecorTree;optionDecorCrop;optionDecorMound;optionDecorStreetlight;optionDecorVehicle;optionDecorAircraft;optionDecorEntity;labelDecorLights;optionDecorWitness;recorder;isRecording=!1;messages=K1;currentAppearance={...nA};currentSourceId=Wl;selectedSourceIds=new Set([Wl]);currentDecorId;currentReferenceId;referenceSelect;deleteReferenceButton;referenceTitleInput;referenceSrcInput;referenceKindSelect;referenceCreditInput;referenceCreditUrlInput;referenceTInput;referenceDrawingInput;referenceOpacityInput;referenceHeadingInput;referencePitchInput;referenceRollInput;referenceFovInput;referenceUsePoseButton;referenceStatus;addReferenceUrlButton;addReferenceFileInput;referenceLandmarksSelect;addReferenceLandmarkButton;deleteReferenceLandmarkButton;referenceLandmarkLabelInput;labelReferenceLandmarks;labelReferenceLandmarkLabel;referenceAdoptPoseButton;referenceStreetSearchButton;referenceStreetSelect;referenceStreetAddButton;lastCanvasMode="shape";referenceDragState;armingLandmark=!1;pendingLandmark;currentLandmarkId;referenceFit;streetPictures=[];streetPictures$=new da;referenceFields;labelReferenceGroup;labelReference;labelReferenceTitle;labelReferenceSrc;labelReferenceKind;labelReferenceCredit;labelReferenceCreditUrl;labelReferenceT;labelReferenceDrawing;labelReferenceOpacity;labelReferenceHeading;labelReferencePitch;labelReferenceRoll;labelReferenceFov;labelAddReferenceFile;contextMenuDecorId;contextMenuPoint;dragState;cameraDragState;hoverCursor;indoorLookYawDeg=0;indoorLookPitchDeg=0;lastInhabitedKey;handleKeyDown=e=>{if(e.key==="Escape"&&(this.isRecording&&this.toggleRecording(),this.confirmOverlay.hidden||this.answerConfirm(!1),(this.armingLandmark||this.pendingLandmark)&&this.disarmLandmark(),this.contextMenu.hidden||this.hideContextMenu(),this.decorContextMenu.hidden||this.hideDecorContextMenu()),ig.has(e.key)||e.key==="Delete"||e.key==="Backspace"){const t=e.composedPath()[0];if(t instanceof HTMLInputElement||t instanceof HTMLSelectElement||t instanceof HTMLTextAreaElement)return;ig.has(e.key)?this.moveOrResizeSelectedShapes(e):this.deleteShape()}};handleDragPointerMove=e=>this.onDragPointerMove(e);handleDragPointerUp=()=>this.endDrag();constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${Wv}</style>${Vv}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.sceneElement=document.createElement(Gu),this.sceneElement.setAttribute("show-compass",""),this.sceneElement.setAttribute(fr,""),this.sceneElement.animateWhilePaused=!0,this.ufoElement=this.sceneElement.ufoElement,this.ufoElement.enableClickToPlay=!1,this.ufoElement.showToolbar=!1,this.shadow.getElementById("ufo-slot").replaceWith(this.sceneElement),this.ufoElement.hostControls(this.shadow.getElementById("scene-controls")),this.recordButton=this.shadow.getElementById("record"),this.samplingRateInput=this.shadow.getElementById("samplingRate"),this.presetsGroup=this.shadow.getElementById("presets-group"),this.presetButtons={oval:this.shadow.getElementById("preset-oval"),polygon:this.shadow.getElementById("preset-polygon")},this.colorInput=this.shadow.getElementById("color"),this.transparencyInput=this.shadow.getElementById("transparency"),this.haloScaleInput=this.shadow.getElementById("haloScale"),this.blurInput=this.shadow.getElementById("blur"),this.brightnessInput=this.shadow.getElementById("brightness"),this.blurBoundOutput=this.shadow.getElementById("blur-bound"),this.sourceSelect=this.shadow.getElementById("source"),this.shapeTitleInput=this.shadow.getElementById("shapeTitle"),this.utcOffsetInput=this.shadow.getElementById("utcOffsetHours"),this.timeZoneSelect=this.shadow.getElementById("timeZone"),this.apparentWidthInput=this.shadow.getElementById("apparentWidth"),this.realWidthInput=this.shadow.getElementById("realWidth"),this.objectDistanceInput=this.shadow.getElementById("objectDistance"),this.sizeLockSelect=this.shadow.getElementById("sizeLock"),this.apparentSizeOutput=this.shadow.getElementById("apparent-size"),this.realSizeOutput=this.shadow.getElementById("real-size"),this.clearDistanceHypothesisButton=this.shadow.getElementById("clear-distance-hypothesis"),this.depthBasisOutput=this.shadow.getElementById("depth-basis"),this.addShapeButton=this.shadow.getElementById("add-shape"),this.deleteShapeButton=this.shadow.getElementById("delete-shape"),this.contextMenu=this.shadow.getElementById("context-menu"),this.contextGroupButton=this.shadow.getElementById("context-group"),this.contextUngroupButton=this.shadow.getElementById("context-ungroup"),this.contextBringToFrontButton=this.shadow.getElementById("context-bring-to-front"),this.contextSendToBackButton=this.shadow.getElementById("context-send-to-back"),this.contextDeleteButton=this.shadow.getElementById("context-delete"),this.contextAddVertexButton=this.shadow.getElementById("context-add-vertex"),this.contextDeleteVertexButton=this.shadow.getElementById("context-delete-vertex"),this.decorContextMenu=this.shadow.getElementById("decor-context-menu"),this.contextViewTestimonyButton=this.shadow.getElementById("context-view-testimony"),this.contextMasksSubmenu=this.shadow.getElementById("context-masks-submenu"),this.labelContextMasks=this.shadow.getElementById("label-context-masks"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.seekInput=this.shadow.getElementById("seek"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end");for(const t of[this.timeStartLabel,this.timeEndLabel])t.addEventListener("click",()=>this.switchTimeDisplay()),t.addEventListener("keydown",i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),this.switchTimeDisplay())});this.durationInput=this.shadow.getElementById("durationSeconds"),this.exportButton=this.shadow.getElementById("export"),this.importFileInput=this.shadow.getElementById("import-file"),this.importUrlInput=this.shadow.getElementById("import-url"),this.importUrlButton=this.shadow.getElementById("import-url-button"),this.narrativeKeyInput=this.shadow.getElementById("narrativeKey"),this.narrativeWorkspaceInput=this.shadow.getElementById("narrativeWorkspace"),this.narrativeRememberInput=this.shadow.getElementById("narrativeRemember"),this.narrativeDraftButton=this.shadow.getElementById("narrative-draft"),this.narrativeStopButton=this.shadow.getElementById("narrative-stop"),this.narrativeCreditLink=this.shadow.getElementById("narrative-credit"),this.narrativeStatus=this.shadow.getElementById("narrative-status"),this.narrativeReport=this.shadow.getElementById("narrative-report"),this.placeNameInput=this.shadow.getElementById("placeName"),this.searchPlaceButton=this.shadow.getElementById("search-place"),this.placeMatchRow=this.shadow.getElementById("place-match-row"),this.placeMatchSelect=this.shadow.getElementById("placeMatch"),this.placeStatusText=this.shadow.getElementById("place-status-text"),this.latInput=this.shadow.getElementById("lat"),this.lngInput=this.shadow.getElementById("lng"),this.headingInput=this.shadow.getElementById("heading"),this.headingUnit=this.shadow.getElementById("heading-unit"),this.pitchInput=this.shadow.getElementById("pitch"),this.rollInput=this.shadow.getElementById("roll"),this.elevationInput=this.shadow.getElementById("elevation"),this.groundElevationOutput=this.shadow.getElementById("ground-elevation"),this.obsTimeInput=this.shadow.getElementById("obs-time"),this.obsEndTimeInput=this.shadow.getElementById("obs-end-time"),this.obsTimeNativeInput=this.shadow.getElementById("obs-time-native"),this.obsEndTimeNativeInput=this.shadow.getElementById("obs-end-time-native"),this.obsTimeQualifier=this.shadow.getElementById("obs-time-qualifier"),this.obsEndTimeQualifier=this.shadow.getElementById("obs-end-time-qualifier"),this.edtfModeButton=this.shadow.getElementById("edtf-mode"),this.witnessIdInput=this.shadow.getElementById("witnessId"),this.witnessDirNameInput=this.shadow.getElementById("witnessDirName"),this.witnessTitleInput=this.shadow.getElementById("witnessTitle"),this.witnessLastNameInput=this.shadow.getElementById("witnessLastName"),this.witnessFirstNamesInput=this.shadow.getElementById("witnessFirstNames"),this.witnessAgeInput=this.shadow.getElementById("witnessAge"),this.witnessOccupationInput=this.shadow.getElementById("witnessOccupation"),this.testimonySourceSelect=this.shadow.getElementById("testimonySource"),this.testimonyFollowedUpSelect=this.shadow.getElementById("testimonyFollowedUp"),this.caseIdInput=this.shadow.getElementById("caseId"),this.descriptionInput=this.shadow.getElementById("description"),this.tagsInput=this.shadow.getElementById("tags"),this.cloudCoverInput=this.shadow.getElementById("cloudCover"),this.highCloudCoverInput=this.shadow.getElementById("highCloudCover"),this.iceCrystalAlignmentInput=this.shadow.getElementById("iceCrystalAlignment"),this.cloudDarknessInput=this.shadow.getElementById("cloudDarkness"),this.cloudBaseInput=this.shadow.getElementById("cloudBase"),this.precipitationTypeSelect=this.shadow.getElementById("precipitationType"),this.precipitationIntensityInput=this.shadow.getElementById("precipitationIntensity"),this.windDirectionInput=this.shadow.getElementById("windDirection"),this.windSpeedInput=this.shadow.getElementById("windSpeed"),this.stormInput=this.shadow.getElementById("storm"),this.weatherInferredInput=this.shadow.getElementById("weatherInferred"),this.weatherSourceText=this.shadow.getElementById("weather-source-text"),this.skyCandidatesOutput=this.shadow.getElementById("sky-candidates"),this.showMeteorButton=this.shadow.getElementById("show-meteor"),this.showCometButton=this.shadow.getElementById("show-comet"),this.showNovaButton=this.shadow.getElementById("show-nova"),this.showSatelliteButton=this.shadow.getElementById("show-satellite"),this.weatherSourceLink=this.shadow.getElementById("weather-source-link"),this.weatherFields=[this.cloudCoverInput,this.highCloudCoverInput,this.iceCrystalAlignmentInput,this.cloudDarknessInput,this.cloudBaseInput,this.precipitationTypeSelect,this.precipitationIntensityInput,this.windDirectionInput,this.windSpeedInput,this.stormInput],this.soundKindSelect=this.shadow.getElementById("soundKind"),this.soundVolumeInput=this.shadow.getElementById("soundVolume"),this.soundPitchInput=this.shadow.getElementById("soundPitch"),this.soundPitchValue=this.shadow.getElementById("sound-pitch-value"),this.soundSrcInput=this.shadow.getElementById("soundSrc"),this.soundFields=[this.soundKindSelect,this.soundVolumeInput,this.soundPitchInput,this.soundSrcInput],this.buildSoundKindOptions(),this.instrumentSelect=this.shadow.getElementById("instrument"),this.focalLengthInput=this.shadow.getElementById("focalLength"),this.labelFocalLength=this.shadow.getElementById("label-focal-length"),this.unitFocalLength=this.shadow.getElementById("unit-focal-length"),this.labelFNumber=this.shadow.getElementById("label-f-number"),this.labelExposure=this.shadow.getElementById("label-exposure"),this.fNumberInput=this.shadow.getElementById("fNumber"),this.exposureInput=this.shadow.getElementById("exposureSeconds"),this.focusDistanceInput=this.shadow.getElementById("focusDistance"),this.labelFocusDistance=this.shadow.getElementById("label-focus-distance"),this.refreshInstrumentOptions(),this.labelColor=this.shadow.getElementById("label-color"),this.labelTransparency=this.shadow.getElementById("label-transparency"),this.labelHalo=this.shadow.getElementById("label-halo"),this.labelBlur=this.shadow.getElementById("label-blur"),this.labelBrightness=this.shadow.getElementById("label-brightness"),this.labelShape=this.shadow.getElementById("label-shape"),this.labelShapeTitle=this.shadow.getElementById("label-shape-title"),this.labelUtcOffset=this.shadow.getElementById("label-utc-offset"),this.labelApparentWidth=this.shadow.getElementById("label-apparent-width"),this.labelRealWidth=this.shadow.getElementById("label-real-width"),this.labelObjectDistance=this.shadow.getElementById("label-object-distance"),this.labelSizeLock=this.shadow.getElementById("label-size-lock"),this.labelSamplingRate=this.shadow.getElementById("label-sampling-rate"),this.labelSoundGroup=this.shadow.getElementById("label-sound-group"),this.labelSoundKind=this.shadow.getElementById("label-sound-kind"),this.labelSoundVolume=this.shadow.getElementById("label-sound-volume"),this.labelSoundPitch=this.shadow.getElementById("label-sound-pitch"),this.labelSoundSrc=this.shadow.getElementById("label-sound-src"),this.labelReferenceGroup=this.shadow.getElementById("label-reference-group"),this.labelReference=this.shadow.getElementById("label-reference"),this.labelReferenceTitle=this.shadow.getElementById("label-reference-title"),this.labelReferenceSrc=this.shadow.getElementById("label-reference-src"),this.labelReferenceKind=this.shadow.getElementById("label-reference-kind"),this.labelReferenceCredit=this.shadow.getElementById("label-reference-credit"),this.labelReferenceCreditUrl=this.shadow.getElementById("label-reference-credit-url"),this.labelReferenceT=this.shadow.getElementById("label-reference-t"),this.labelReferenceDrawing=this.shadow.getElementById("label-reference-drawing"),this.labelReferenceOpacity=this.shadow.getElementById("label-reference-opacity"),this.labelReferenceHeading=this.shadow.getElementById("label-reference-heading"),this.labelReferencePitch=this.shadow.getElementById("label-reference-pitch"),this.labelReferenceRoll=this.shadow.getElementById("label-reference-roll"),this.labelReferenceFov=this.shadow.getElementById("label-reference-fov"),this.labelAddReferenceFile=this.shadow.getElementById("label-add-reference-file"),this.labelDuration=this.shadow.getElementById("label-duration"),this.placeSourceRow=this.shadow.getElementById("place-source-row"),this.weatherSourceRow=this.shadow.getElementById("weather-source-row"),this.terrainSourceRows=this.shadow.getElementById("terrain-source-rows"),this.labelPlaceName=this.shadow.getElementById("label-place-name"),this.labelPlaceMatch=this.shadow.getElementById("label-place-match"),this.labelLatitude=this.shadow.getElementById("label-lat"),this.labelLongitude=this.shadow.getElementById("label-lng"),this.labelHeading=this.shadow.getElementById("label-heading"),this.labelPitch=this.shadow.getElementById("label-pitch"),this.labelRoll=this.shadow.getElementById("label-roll"),this.labelElevation=this.shadow.getElementById("label-elevation"),this.labelObservationTime=this.shadow.getElementById("label-observation-time"),this.labelObservationEndTime=this.shadow.getElementById("label-observation-end-time"),this.labelWitnessId=this.shadow.getElementById("label-witness-id"),this.labelWitnessDirName=this.shadow.getElementById("label-witness-dir-name"),this.labelWitnessTitle=this.shadow.getElementById("label-witness-title"),this.labelWitnessLastName=this.shadow.getElementById("label-witness-last-name"),this.labelWitnessFirstNames=this.shadow.getElementById("label-witness-first-names"),this.labelWitnessAge=this.shadow.getElementById("label-witness-age"),this.labelWitnessOccupation=this.shadow.getElementById("label-witness-occupation"),this.labelTestimonySource=this.shadow.getElementById("label-testimony-source"),this.labelTestimonyFollowedUp=this.shadow.getElementById("label-testimony-followed-up"),this.labelCaseId=this.shadow.getElementById("label-case-id"),this.labelDescription=this.shadow.getElementById("label-description"),this.labelTags=this.shadow.getElementById("label-tags"),this.labelImportFile=this.shadow.getElementById("label-import-file"),this.labelImportUrl=this.shadow.getElementById("label-import-url"),this.labelNarrativeKey=this.shadow.getElementById("label-narrative-key"),this.labelNarrativeWorkspace=this.shadow.getElementById("label-narrative-workspace"),this.labelNarrativeRemember=this.shadow.getElementById("label-narrative-remember"),this.labelShapeGroup=this.shadow.getElementById("label-shape-group"),this.labelTemporalGroup=this.shadow.getElementById("label-temporal-group"),this.labelLocationGroup=this.shadow.getElementById("label-location-group"),this.labelObservationGroup=this.shadow.getElementById("label-observation-group"),this.labelWitnessGroup=this.shadow.getElementById("label-witness-group"),this.labelWeatherGroup=this.shadow.getElementById("label-weather-group"),this.labelCloudCover=this.shadow.getElementById("label-cloud-cover"),this.labelHighCloud=this.shadow.getElementById("label-high-cloud"),this.labelIceAlignment=this.shadow.getElementById("label-ice-alignment"),this.labelCloudDarkness=this.shadow.getElementById("label-cloud-darkness"),this.labelCloudBase=this.shadow.getElementById("label-cloud-base"),this.labelPrecipitationType=this.shadow.getElementById("label-precipitation-type"),this.labelPrecipitationIntensity=this.shadow.getElementById("label-precipitation-intensity"),this.labelWindDirection=this.shadow.getElementById("label-wind-direction"),this.labelWindSpeed=this.shadow.getElementById("label-wind-speed"),this.labelStorm=this.shadow.getElementById("label-storm"),this.labelCloudsGroup=this.shadow.getElementById("label-clouds-group"),this.labelPrecipitationGroup=this.shadow.getElementById("label-precipitation-group"),this.labelWindGroup=this.shadow.getElementById("label-wind-group"),this.labelWeatherInferred=this.shadow.getElementById("label-weather-inferred"),this.labelInstrument=this.shadow.getElementById("label-instrument"),this.optionPrecipitationNone=this.shadow.getElementById("option-precipitation-none"),this.optionPrecipitationRain=this.shadow.getElementById("option-precipitation-rain"),this.optionPrecipitationSnow=this.shadow.getElementById("option-precipitation-snow"),this.optionPrecipitationHail=this.shadow.getElementById("option-precipitation-hail"),this.decorKindSelect=this.shadow.getElementById("decorKind"),this.addDecorWitnessButton=this.shadow.getElementById("add-decor-witness"),this.addDecorBuildingButton=this.shadow.getElementById("add-decor-building"),this.deleteDecorButton=this.shadow.getElementById("delete-decor"),this.decorSelect=this.shadow.getElementById("decor"),this.referenceSelect=this.shadow.getElementById("reference"),this.deleteReferenceButton=this.shadow.getElementById("delete-reference"),this.referenceTitleInput=this.shadow.getElementById("referenceTitle"),this.referenceSrcInput=this.shadow.getElementById("referenceSrc"),this.referenceKindSelect=this.shadow.getElementById("referenceKind"),this.referenceCreditInput=this.shadow.getElementById("referenceCredit"),this.referenceCreditUrlInput=this.shadow.getElementById("referenceCreditUrl"),this.referenceTInput=this.shadow.getElementById("referenceT"),this.referenceDrawingInput=this.shadow.getElementById("referenceDrawing"),this.referenceOpacityInput=this.shadow.getElementById("referenceOpacity"),this.referenceHeadingInput=this.shadow.getElementById("referenceHeading"),this.referencePitchInput=this.shadow.getElementById("referencePitch"),this.referenceRollInput=this.shadow.getElementById("referenceRoll"),this.referenceFovInput=this.shadow.getElementById("referenceFov"),this.referenceUsePoseButton=this.shadow.getElementById("reference-use-pose"),this.referenceStatus=this.shadow.getElementById("reference-status"),this.addReferenceUrlButton=this.shadow.getElementById("add-reference-url"),this.addReferenceFileInput=this.shadow.getElementById("add-reference-file"),this.referenceLandmarksSelect=this.shadow.getElementById("reference-landmarks"),this.addReferenceLandmarkButton=this.shadow.getElementById("add-reference-landmark"),this.deleteReferenceLandmarkButton=this.shadow.getElementById("delete-reference-landmark"),this.referenceLandmarkLabelInput=this.shadow.getElementById("referenceLandmarkLabel"),this.labelReferenceLandmarks=this.shadow.getElementById("label-reference-landmarks"),this.labelReferenceLandmarkLabel=this.shadow.getElementById("label-reference-landmark-label"),this.referenceAdoptPoseButton=this.shadow.getElementById("reference-adopt-pose"),this.referenceStreetSearchButton=this.shadow.getElementById("reference-street-search"),this.referenceStreetSelect=this.shadow.getElementById("reference-street"),this.referenceStreetAddButton=this.shadow.getElementById("reference-street-add"),this.referenceFields=[this.referenceTitleInput,this.referenceSrcInput,this.referenceKindSelect,this.referenceCreditInput,this.referenceCreditUrlInput,this.referenceTInput,this.referenceDrawingInput,this.referenceOpacityInput,this.referenceHeadingInput,this.referencePitchInput,this.referenceRollInput,this.referenceFovInput],this.decorTitleInput=this.shadow.getElementById("decorTitle"),this.decorEastInput=this.shadow.getElementById("decorEast"),this.decorNorthInput=this.shadow.getElementById("decorNorth"),this.decorHeadingInput=this.shadow.getElementById("decorHeading"),this.decorColorInput=this.shadow.getElementById("decorColor"),this.decorLitInput=this.shadow.getElementById("decorLit"),this.decorLightRigSelect=this.shadow.getElementById("decorLightRig"),this.lookAtDecorButton=this.shadow.getElementById("look-at-decor"),this.decorAltitudeInput=this.shadow.getElementById("decorAltitude"),this.labelDecorAltitude=this.shadow.getElementById("label-decor-altitude"),this.decorSightingUrlInput=this.shadow.getElementById("decorSightingUrl"),this.confirmOverlay=this.shadow.getElementById("confirm-overlay"),this.confirmMessage=this.shadow.getElementById("confirm-message"),this.confirmAcceptButton=this.shadow.getElementById("confirm-ok"),this.confirmDeclineButton=this.shadow.getElementById("confirm-cancel"),this.milestoneSelect=this.shadow.getElementById("milestone"),this.milestoneLabelInput=this.shadow.getElementById("milestoneLabel"),this.milestoneNoteInput=this.shadow.getElementById("milestoneNote"),this.addMilestoneButton=this.shadow.getElementById("add-milestone"),this.deleteMilestoneButton=this.shadow.getElementById("delete-milestone"),this.decorWidthInput=this.shadow.getElementById("decorWidth"),this.decorLengthInput=this.shadow.getElementById("decorLength"),this.decorHeightInput=this.shadow.getElementById("decorHeight"),this.decorModelSelect=this.shadow.getElementById("decorModel"),this.decorModelAdvanced=this.shadow.getElementById("decor-model-advanced"),this.decorModelUrlInput=this.shadow.getElementById("decorModelUrl"),this.decorModelTitleInput=this.shadow.getElementById("decorModelTitle"),this.decorModelAuthorInput=this.shadow.getElementById("decorModelAuthor"),this.decorModelLicenseInput=this.shadow.getElementById("decorModelLicense"),this.decorModelSourceInput=this.shadow.getElementById("decorModelSource"),this.decorFloorsInput=this.shadow.getElementById("decorFloors"),this.decorOccupiedFloorInput=this.shadow.getElementById("decorOccupiedFloor"),this.decorWitnessSideSelect=this.shadow.getElementById("decorWitnessSide"),this.decorWindowInputs={front:this.shadow.getElementById("decorWindowFront"),behind:this.shadow.getElementById("decorWindowBehind"),left:this.shadow.getElementById("decorWindowLeft"),right:this.shadow.getElementById("decorWindowRight"),"front-left":this.shadow.getElementById("decorWindowFrontLeft"),"front-right":this.shadow.getElementById("decorWindowFrontRight"),"behind-left":this.shadow.getElementById("decorWindowBehindLeft"),"behind-right":this.shadow.getElementById("decorWindowBehindRight")},this.labelDecorSide={front:this.shadow.getElementById("label-decor-window-front"),behind:this.shadow.getElementById("label-decor-window-behind"),left:this.shadow.getElementById("label-decor-window-left"),right:this.shadow.getElementById("label-decor-window-right"),"front-left":this.shadow.getElementById("label-decor-window-front-left"),"front-right":this.shadow.getElementById("label-decor-window-front-right"),"behind-left":this.shadow.getElementById("label-decor-window-behind-left"),"behind-right":this.shadow.getElementById("label-decor-window-behind-right")},this.optionWitnessSide={front:this.shadow.getElementById("option-witness-side-front"),behind:this.shadow.getElementById("option-witness-side-behind"),left:this.shadow.getElementById("option-witness-side-left"),right:this.shadow.getElementById("option-witness-side-right"),"front-left":this.shadow.getElementById("option-witness-side-front-left"),"front-right":this.shadow.getElementById("option-witness-side-front-right"),"behind-left":this.shadow.getElementById("option-witness-side-behind-left"),"behind-right":this.shadow.getElementById("option-witness-side-behind-right")},this.optionWitnessSideNone=this.shadow.getElementById("option-witness-side-none"),this.labelDecor=this.shadow.getElementById("label-decor"),this.labelDecorGroup=this.shadow.getElementById("label-decor-group"),this.labelDecorTitle=this.shadow.getElementById("label-decor-title"),this.labelDecorEast=this.shadow.getElementById("label-decor-east"),this.labelDecorNorth=this.shadow.getElementById("label-decor-north"),this.labelDecorHeading=this.shadow.getElementById("label-decor-heading"),this.labelDecorColor=this.shadow.getElementById("label-decor-color"),this.labelDecorLit=this.shadow.getElementById("label-decor-lit"),this.labelDecorSightingUrl=this.shadow.getElementById("label-decor-sighting-url"),this.labelMilestones=this.shadow.getElementById("label-milestones"),this.labelMilestoneLabel=this.shadow.getElementById("label-milestone-label"),this.labelMilestoneNote=this.shadow.getElementById("label-milestone-note"),this.labelDecorWidth=this.shadow.getElementById("label-decor-width"),this.labelDecorLength=this.shadow.getElementById("label-decor-length"),this.labelDecorHeight=this.shadow.getElementById("label-decor-height"),this.labelDecorModel=this.shadow.getElementById("label-decor-model"),this.labelDecorModelAdvanced=this.shadow.getElementById("label-decor-model-advanced"),this.labelDecorModelUrl=this.shadow.getElementById("label-decor-model-url"),this.labelDecorModelTitle=this.shadow.getElementById("label-decor-model-title"),this.labelDecorModelAuthor=this.shadow.getElementById("label-decor-model-author"),this.labelDecorModelLicense=this.shadow.getElementById("label-decor-model-license"),this.labelDecorModelSource=this.shadow.getElementById("label-decor-model-source"),this.labelDecorFloors=this.shadow.getElementById("label-decor-floors"),this.labelDecorOccupiedFloor=this.shadow.getElementById("label-decor-occupied-floor"),this.labelDecorWitnessSide=this.shadow.getElementById("label-decor-witness-side"),this.labelDecorWindows=this.shadow.getElementById("label-decor-windows"),this.optionDecorBuilding=this.shadow.getElementById("option-decor-building"),this.optionDecorTree=this.shadow.getElementById("option-decor-tree"),this.optionDecorCrop=this.shadow.getElementById("option-decor-crop"),this.optionDecorMound=this.shadow.getElementById("option-decor-mound"),this.optionDecorStreetlight=this.shadow.getElementById("option-decor-streetlight"),this.optionDecorVehicle=this.shadow.getElementById("option-decor-vehicle"),this.optionDecorAircraft=this.shadow.getElementById("option-decor-aircraft"),this.optionDecorEntity=this.shadow.getElementById("option-decor-entity"),this.labelDecorLights=this.shadow.getElementById("label-decor-lights"),this.optionDecorWitness=this.shadow.getElementById("option-decor-witness"),this.ufoElement.canvasElement.addEventListener("pointerdown",t=>{this.focus({preventScroll:!0}),this.onPointerDown(t)}),this.ufoElement.canvasElement.addEventListener("pointermove",t=>this.onPointerMove(t)),this.ufoElement.canvasElement.addEventListener("contextmenu",t=>this.onContextMenu(t)),this.contextGroupButton.addEventListener("click",()=>this.groupSelected()),this.contextUngroupButton.addEventListener("click",()=>this.ungroupSelected()),this.contextBringToFrontButton.addEventListener("click",()=>this.bringSelectedToFront()),this.contextSendToBackButton.addEventListener("click",()=>this.sendSelectedToBack()),this.contextDeleteButton.addEventListener("click",()=>{this.hideContextMenu(),this.deleteShape()}),this.contextAddVertexButton.addEventListener("click",()=>this.addVertexAtContextMenu()),this.contextDeleteVertexButton.addEventListener("click",()=>this.deleteVertexAtContextMenu()),this.contextViewTestimonyButton.addEventListener("click",()=>this.viewWitnessTestimony()),this.playPauseButton.addEventListener("click",()=>{this.ufoElement.togglePlayPause(),this.syncPlaybackControls()}),this.seekInput.addEventListener("input",()=>this.ufoElement.currentTime=Number(this.seekInput.value)),this.recordButton.addEventListener("click",()=>this.toggleRecording()),this.addShapeButton.addEventListener("click",()=>this.addShape()),this.deleteShapeButton.addEventListener("click",()=>this.deleteShape()),this.exportButton.addEventListener("click",()=>this.exportJson()),this.importFileInput.addEventListener("change",()=>this.importFromFile()),this.importUrlButton.addEventListener("click",()=>this.importFromUrl()),this.testimonySourceSelect.addEventListener("change",()=>this.updateWitnessMetadata()),this.testimonyFollowedUpSelect.addEventListener("change",()=>this.updateWitnessMetadata()),this.narrativeDraftButton.addEventListener("click",()=>this.draftFromDescription()),this.narrativeStopButton.addEventListener("click",()=>this.narrativeAbort?.abort()),this.narrativeRememberInput.addEventListener("change",()=>this.rememberNarrativeKey()),this.narrativeWorkspaceInput.addEventListener("input",()=>this.rememberNarrativeKey()),this.narrativeKeyInput.addEventListener("input",()=>{this.rememberNarrativeKey(),this.syncNarrativeEnabled()}),this.narrativeCreditLink.textContent=`${Vs[0].name} — ${Vs[0].credit}`,this.narrativeCreditLink.href=Vs[0].creditUrl,this.labelNarrativeKey.textContent=this.messages.narrativeKey.replace("{source}",Vs[0].name),this.narrativeWorkspaceInput.title=this.messages.narrativeWorkspaceHint,this.restoreNarrativeKey(),this.syncNarrativeEnabled(),this.durationInput.addEventListener("input",()=>{this.ufoElement.durationSeconds=this.durationInput.value===""?void 0:Number(this.durationInput.value),this.ufoElement.refresh(),this.updateDurationValidity(),this.scheduleWeatherLookup()}),this.sourceSelect.addEventListener("change",()=>this.selectUnit(this.sourceSelect.value)),this.shapeTitleInput.addEventListener("input",()=>this.updateShapeTitle()),this.apparentWidthInput.addEventListener("input",()=>this.typing(this.apparentWidthInput,()=>this.onApparentWidthInput())),this.realWidthInput.addEventListener("input",()=>this.typing(this.realWidthInput,()=>this.onRealWidthInput())),this.objectDistanceInput.addEventListener("input",()=>this.typing(this.objectDistanceInput,()=>this.onDistanceInput())),this.sizeLockSelect.addEventListener("change",()=>this.applySizeLock()),this.clearDistanceHypothesisButton.addEventListener("click",()=>this.clearDistanceHypothesis()),this.addDecorWitnessButton.addEventListener("click",()=>this.addDecor("witness")),this.addDecorBuildingButton.addEventListener("click",()=>this.addDecor()),this.deleteDecorButton.addEventListener("click",()=>this.deleteDecor()),this.decorSelect.addEventListener("change",()=>this.selectDecor(this.decorSelect.value)),this.referenceSelect.addEventListener("change",()=>this.selectReference(this.referenceSelect.value)),this.deleteReferenceButton.addEventListener("click",()=>this.deleteReference());for(const t of this.referenceFields)t.addEventListener("input",()=>this.updateReference());this.referenceUsePoseButton.addEventListener("click",()=>this.useWitnessPoseForReference()),this.addReferenceUrlButton.addEventListener("click",()=>this.addReferenceFromAddress()),this.addReferenceFileInput.addEventListener("change",()=>void this.addReferenceFromFile()),this.addReferenceLandmarkButton.addEventListener("click",()=>this.armLandmark()),this.deleteReferenceLandmarkButton.addEventListener("click",()=>this.deleteLandmark()),this.referenceLandmarksSelect.addEventListener("change",()=>this.selectLandmark(this.referenceLandmarksSelect.value)),this.referenceLandmarkLabelInput.addEventListener("input",()=>this.updateLandmarkLabel()),this.referenceAdoptPoseButton.addEventListener("click",()=>this.adoptReferencePose()),this.referenceStreetSearchButton.addEventListener("click",()=>void this.searchStreetPictures()),this.referenceStreetAddButton.addEventListener("click",()=>this.addStreetPicture()),this.ufoElement.canvasElement.addEventListener("wheel",t=>this.onReferenceWheel(t),{passive:!1});for(const t of[this.decorTitleInput,this.decorEastInput,this.decorNorthInput,this.decorAltitudeInput,this.decorHeadingInput,this.decorColorInput,this.decorSightingUrlInput,this.decorWidthInput,this.decorLengthInput,this.decorHeightInput,this.decorModelUrlInput,this.decorModelTitleInput,this.decorModelAuthorInput,this.decorModelLicenseInput,this.decorModelSourceInput,this.decorFloorsInput,this.decorOccupiedFloorInput])t.addEventListener("input",()=>this.updateDecor());this.decorWitnessSideSelect.addEventListener("change",()=>this.updateDecor()),this.decorModelSelect.addEventListener("change",()=>this.updateDecorModelChoice()),this.addMilestoneButton.addEventListener("click",()=>this.addMilestone()),this.deleteMilestoneButton.addEventListener("click",()=>this.deleteMilestone()),this.milestoneSelect.addEventListener("change",()=>this.selectMilestone(Number(this.milestoneSelect.value)));for(const t of[this.milestoneLabelInput,this.milestoneNoteInput])t.addEventListener("input",()=>this.updateMilestone());this.confirmAcceptButton.addEventListener("click",()=>this.answerConfirm(!0)),this.confirmDeclineButton.addEventListener("click",()=>this.answerConfirm(!1)),this.confirmOverlay.addEventListener("click",t=>{t.target===this.confirmOverlay&&this.answerConfirm(!1)});for(const t of _r)this.decorWindowInputs[t].addEventListener("input",()=>this.updateDecorWindows());this.decorLitInput.addEventListener("input",()=>this.updateDecorLit()),this.decorLightRigSelect.addEventListener("change",()=>this.updateDecorLightRig()),this.lookAtDecorButton.addEventListener("click",()=>this.lookAtDecor()),this.showMeteorButton.addEventListener("click",()=>this.showNextMeteor()),this.showCometButton.addEventListener("click",()=>this.lookAtComet()),this.showNovaButton.addEventListener("click",()=>this.lookAtNova()),this.showSatelliteButton.addEventListener("click",()=>this.showNextSatellite()),this.sceneElement.addEventListener(X1,()=>{this.skyCandidatesKey=void 0,this.refreshSkyCandidates()}),this.ufoElement.addEventListener("timeupdate",()=>{this.onSelectionOrTimeChanged(),this.syncPlaybackControls(),this.dispatchEvent(new CustomEvent("sightingchange"))}),this.addEventListener("keydown",this.handleKeyDown);for(const t of ng)this.presetButtons[t].addEventListener("click",()=>this.setAppearance({presetId:t}));this.colorInput.addEventListener("input",()=>this.setAppearance({color:this.colorInput.value})),this.transparencyInput.addEventListener("input",()=>this.setAppearance({transparency:Number(this.transparencyInput.value)})),this.brightnessInput.addEventListener("input",()=>this.setAppearance({brightness:Number(this.brightnessInput.value)})),this.blurInput.addEventListener("input",()=>{this.setAppearance({blur:Number(this.blurInput.value)}),this.refreshBlurDistanceBound()}),this.haloScaleInput.addEventListener("input",()=>this.setAppearance({haloScale:Number(this.haloScaleInput.value)}));for(const t of[this.latInput,this.lngInput,this.headingInput,this.pitchInput,this.rollInput,this.elevationInput])t.addEventListener("input",()=>this.updateObserver());for(const t of[this.focalLengthInput,this.fNumberInput,this.exposureInput,this.focusDistanceInput])t.addEventListener("input",()=>this.updateObserver());this.searchPlaceButton.addEventListener("click",()=>void this.searchPlace()),this.placeNameInput.addEventListener("keydown",t=>{t.key==="Enter"&&(t.preventDefault(),this.searchPlace())}),this.placeMatchSelect.addEventListener("change",()=>this.applyPlaceMatch(this.placeMatchSelect.selectedIndex)),this.placeNameInput.addEventListener("input",()=>this.updatePlaceName()),this.headingInput.addEventListener("focus",()=>this.sceneElement.setCompassForced(!0)),this.headingInput.addEventListener("input",()=>this.refreshHeadingPoint()),this.headingInput.addEventListener("blur",()=>this.sceneElement.setCompassForced(!1)),this.instrumentSelect.addEventListener("change",()=>{const t=this.ufoElement.sighting.instrument;this.ufoElement.sighting.instrumentId=this.instrumentSelect.value;const i=new Map(this.ufoElement.sighting.timeline.allKeyframes.map(n=>[n.t,gi.fovOf(this.ufoElement.sighting,n.t)]));this.retuneFieldOfView(t),this.retuneExposure(t),gi.reproject(this.ufoElement.sighting,t,i),this.sceneElement.applyFrameFormat(),this.syncOpticsFromInstrument(),this.ufoElement.refresh(),this.dispatchEvent(new CustomEvent("sightingchange"))}),this.utcOffsetInput.addEventListener("input",()=>this.updateUtcOffset()),this.timeZoneSelect.addEventListener("change",()=>{this.autoFilledTimeZone=void 0,this.updateTimeZone()}),this.obsTimeInput.addEventListener("input",()=>this.updateObservationTime()),this.obsEndTimeInput.addEventListener("input",()=>this.updateObservationEndTime()),this.obsTimeNativeInput.addEventListener("change",()=>this.writeFromPicker(this.obsTimeNativeInput,this.obsTimeQualifier,this.obsTimeInput,()=>this.updateObservationTime())),this.obsEndTimeNativeInput.addEventListener("change",()=>this.writeFromPicker(this.obsEndTimeNativeInput,this.obsEndTimeQualifier,this.obsEndTimeInput,()=>this.updateObservationEndTime())),this.obsTimeQualifier.addEventListener("change",()=>this.writeFromPicker(this.obsTimeNativeInput,this.obsTimeQualifier,this.obsTimeInput,()=>this.updateObservationTime())),this.obsEndTimeQualifier.addEventListener("change",()=>this.writeFromPicker(this.obsEndTimeNativeInput,this.obsEndTimeQualifier,this.obsEndTimeInput,()=>this.updateObservationEndTime())),this.edtfModeButton.addEventListener("click",()=>this.setEdtfMode(!this.edtfMode)),this.obsTimeInput.addEventListener("blur",()=>this.validateEdtfTimeInput(this.obsTimeInput)),this.obsEndTimeInput.addEventListener("blur",()=>this.validateEdtfTimeInput(this.obsEndTimeInput));for(const t of[this.witnessIdInput,this.witnessDirNameInput,this.witnessTitleInput,this.witnessLastNameInput,this.witnessFirstNamesInput,this.witnessAgeInput,this.witnessOccupationInput,this.caseIdInput])t.addEventListener("input",()=>this.updateWitnessMetadata());this.descriptionInput.addEventListener("input",()=>{this.updateDescription(),this.syncNarrativeEnabled()}),this.tagsInput.addEventListener("input",()=>this.updateTags());for(const t of this.weatherFields){if(t===this.iceCrystalAlignmentInput){t.addEventListener("input",()=>this.applyIceAlignmentAtPlayhead());continue}t.addEventListener("input",()=>this.applyWeatherAtPlayhead())}for(const t of this.soundFields)t.addEventListener("input",()=>this.applySoundAtPlayhead());this.weatherInferredInput.addEventListener("change",()=>this.onWeatherInferredToggled()),this.skyDetailsButton=this.shadow.getElementById("sky-details"),this.clampedLines=[this.shadow.getElementById("weather-source"),this.shadow.getElementById("sky-candidates")],this.skyDetailsButton.addEventListener("click",()=>this.toggleSkyDetails()),this.groupTabs=[...this.shadow.querySelectorAll(".group-tab")],this.groupPanels=this.groupTabs.map(t=>this.shadow.getElementById(t.getAttribute("aria-controls")));for(const t of this.groupTabs)t.addEventListener("click",()=>this.toggleGroup(t,!this.isGroupOpen(t)));this.subgroupTabs=[...this.shadow.querySelectorAll(".subgroup-tab")];for(const t of this.subgroupTabs)t.addEventListener("click",()=>this.openSubgroup(t));this.paramSummary=this.shadow.getElementById("param-summary"),this.paramSummaryBuilder=new tp(this.messages,this.showerLanguage(),this.said,this.tagNames),this.paramSummary.addEventListener("click",t=>this.onParamSummaryClick(t)),this.toggleGroup(this.groupTabs[this.groupTabs.length-1],!0),this.updatePresetButtons(),this.setRecordButtonLabel(!1),this.applyAppearanceAtPlayhead(),this.shapeTitleInput.value=this.shapeLabel(this.currentSourceId),this.updateShapeTitle(),this.currentDecorId=this.ufoElement.sighting.decor[0]?.id,this.refreshDecorList(),this.currentReferenceId=this.ufoElement.sighting.references[0]?.id,this.refreshReferenceList(),this.sceneElement.setCloudRendering("volume"),this.cloudEditor=Cv(this.shadow.getElementById("cloud-editor"),this.sceneElement,(t=!0)=>{t&&(this.weatherFromRecords=!1,this.cancelWeatherLookup(),this.ufoElement.sighting.weatherSource=void 0,this.syncWeatherSourceState())},(t,i)=>{this.headingInput.value=String(this.rounded(t)),this.pitchInput.value=String(this.rounded(i)),this.updateObserver()},fa(Ns.preferencesFor(this),bd)),this.currentMilestoneT=this.ufoElement.sighting.milestones[0]?.t,this.refreshMilestoneList(),this.onSelectionOrTimeChanged(),this.syncDurationField(),this.syncPlaybackControls(),this.refreshSourceRows(),this.refreshTimeQualifierOptions(),this.refreshTimeZoneOptions(),this.syncWeatherSourceState(),this.loadLocaleMessages()}static get observedAttributes(){return["src"]}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=-1);const e=this.getAttribute("src");e&&this.importFromUrl(e)}attributeChangedCallback(e,t,i){e==="src"&&i&&i!==t&&this.isConnected&&this.importFromUrl(i)}disconnectedCallback(){this.cloudEditor.stopManipulation(),document.removeEventListener("click",this.handleOutsideContextMenuClick),this.endDrag()}setCloudRendering(e){this.sceneElement.setCloudRendering(e)}showWeatherEditor(){const e=this.groupPanels.findIndex(t=>t.id==="group-weather");e>=0&&this.toggleGroup(this.groupTabs[e],!0)}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.endDrag(),this.ufoElement.sightingData=e,this.cloudEditor.reset(),this.currentSourceId=this.ufoElement.sighting.timeline.sourceIds[0]??Wl,this.selectedSourceIds=new Set([this.currentSourceId]),this.refreshSourceList(),this.currentDecorId=this.ufoElement.sighting.decor[0]?.id,this.refreshDecorList(),this.currentReferenceId=this.ufoElement.sighting.references[0]?.id,this.refreshReferenceList(),this.currentMilestoneT=this.ufoElement.sighting.milestones[0]?.t,this.refreshMilestoneList(),this.onSelectionOrTimeChanged(),this.syncDurationField(),this.syncObservationTimeFields(),this.syncObservationEndTimeFields(),this.chooseTimeInputMode(),this.syncWitnessMetadataFields(),this.refreshTimeZoneOptions(),this.utcOffsetInput.readOnly=this.ufoElement.sighting.event.timeZone!==void 0,this.syncUtcOffsetField(),this.syncPlaceNameField(),this.syncGroundElevationField(),this.syncWeatherOwnership()}exportJson(){const e=this.sightingData,t=`${e.witness?.id??"sighting"}-sighting.json`,i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),s=document.createElement("a");s.href=n,s.download=t,s.click(),URL.revokeObjectURL(n)}async importFromFile(){const e=this.importFileInput.files?.[0];if(e)try{const t=await new Promise((i,n)=>{const s=new FileReader;s.onload=()=>i(s.result),s.onerror=()=>n(s.error),s.readAsText(e)});this.sightingData=JSON.parse(t),this.importUrlInput.value=""}catch{window.alert(this.messages.importError)}finally{this.importFileInput.value=""}}async importFromUrl(e=this.importUrlInput.value.trim()){if(e)try{this.sightingData=await Xu.json(e),this.importUrlInput.value=new URL(e,location.href).href}catch(t){window.alert(this.importErrorFor(t))}}importErrorFor(e){if(!(e instanceof js))return this.messages.importError;switch(e.kind){case"cors":return this.messages.importErrorCors;case"mixed-content":return this.messages.importErrorMixedContent;case"unreachable":return this.messages.importErrorUnreachable;case"status":return this.messages.importErrorStatus.replace("{status}",String(e.status??""));case"malformed":return this.messages.importErrorMalformed;default:return this.messages.importError}}static NARRATIVE_KEY_STORAGE="rr0-sighting-editor.narrative-key";static NARRATIVE_SCOPE_STORAGE="rr0-sighting-editor.narrative-workspace";narrativeProvider=Vs[0].create();narrativeAbort;async draftFromDescription(){const e=this.descriptionInput.value.trim();if(e===""||this.narrativeAbort)return;const t=this.narrativeAbort=new AbortController;this.setNarrativeBusy(!0);try{const i=await this.narrativeProvider.draft({ask:e,current:this.sightingData,language:this.showerLanguage()==="fr"?"French":"English",credential:this.narrativeKeyInput.value.trim()||void 0,credentialScope:this.narrativeWorkspaceInput.value.trim()||void 0},t.signal);this.applyNarrativeDraft(i)}catch(i){const n=i instanceof Wi&&i.kind==="cancelled";this.narrativeStatus.textContent=n?"":this.narrativeErrorFor(i),this.narrativeStatus.classList.toggle("error",!n)}finally{this.narrativeAbort=void 0,this.setNarrativeBusy(!1)}}applyNarrativeDraft(e){const{description:t,...i}=e.recording,{utcOffsetHours:n,...s}=i,a=i.timeZone?s:i,o=Ln.stated(a);if(o.length>0){const l=this.ufoElement.sighting.provenance,c=yd(this.ufoElement.sighting);this.sightingData=Ln.apply(c,rc.loadable(a),o),this.ufoElement.sighting.provenance=l,this.recordNarrativeProvenance(e,o),this.ufoElement.sighting.event.timeZone&&this.applyTimeZoneOffset()}this.narrativeStatus.textContent=o.length>0?this.messages.narrativeApplied.replace("{count}",String(o.length)):this.messages.narrativeUnchanged,this.narrativeStatus.classList.remove("error"),this.showNarrativeReport(e),this.syncNarrativeEnabled()}recordNarrativeProvenance(e,t){const i=this.ufoElement.sighting,n=new Set(t);for(const s of e.claims)!n.has(s.path)&&!t.some(a=>s.path.startsWith(`${a}.`))||i.provenance.set(s.path,{basis:s.basis,rationale:s.rationale,of:Ct.valueAt(yd(this.ufoElement.sighting),s.path)})}static valueAt(e,t){let i=e;for(const n of t.split(".")){if(typeof i!="object"||i===null)return;i=i[n]}return i}showNarrativeReport(e){this.narrativeReport.replaceChildren();for(const t of["assumed","derived","stated"]){const i=e.claims.filter(n=>n.basis===t);if(i.length!==0){this.narrativeReport.append(this.narrativeHeading(this.messages[oA[t]]));for(const n of i){const s=document.createElement("div");s.className=`claim ${t}`;const a=document.createElement("code");a.textContent=n.path;const o=document.createElement(t==="stated"?"q":"span");o.textContent=n.rationale,s.append(a,o),this.narrativeReport.append(s)}}}if(e.gaps.length>0){this.narrativeReport.append(this.narrativeHeading(this.messages.narrativeGaps));const t=document.createElement("ul");t.className="gaps";for(const i of e.gaps){const n=document.createElement("li");n.textContent=i,t.append(n)}this.narrativeReport.append(t)}this.narrativeReport.hidden=this.narrativeReport.childElementCount===0}narrativeHeading(e){const t=document.createElement("h4");return t.textContent=e,t}setNarrativeBusy(e){this.descriptionInput.disabled=e,this.narrativeStopButton.hidden=!e,e&&(this.narrativeStatus.textContent=this.messages.narrativeWorking,this.narrativeStatus.classList.remove("error")),this.syncNarrativeEnabled()}syncNarrativeEnabled(){const e=Vs[0].name,t=this.narrativeProvider.needsCredential&&this.narrativeKeyInput.value.trim()==="",i=this.descriptionInput.value.trim()==="";this.narrativeDraftButton.disabled=!!this.narrativeAbort||t||i,this.narrativeDraftButton.title=t?this.messages.narrativeNeedsKey.replace("{source}",e):i?this.messages.narrativeNeedsAsk:"",this.narrativeKeyInput.parentElement.hidden=!this.narrativeProvider.needsCredential,this.narrativeRememberInput.parentElement.hidden=!this.narrativeProvider.needsCredential,this.narrativeWorkspaceInput.parentElement.hidden=!this.narrativeProvider.acceptsCredentialScope;const n=this.narrativeKeyInput.value.trim(),s=n!==""&&!n.startsWith("sk-ant-");this.narrativeKeyInput.classList.toggle("invalid",s),this.narrativeKeyInput.title=s?this.messages.narrativeKeyUnlikely:""}narrativeErrorFor(e){if(!(e instanceof Wi))return this.messages.narrativeErrorMalformed;switch(e.kind){case"rejected":return this.messages.narrativeErrorRejected.replace("{detail}",e.detail??"");case"credential":return this.messages.narrativeErrorCredential;case"rate-limited":return this.messages.narrativeErrorRateLimited;case"refused":return this.messages.narrativeErrorRefused;case"unreachable":return this.messages.narrativeErrorUnreachable;default:return this.messages.narrativeErrorMalformed}}rememberNarrativeKey(){try{this.narrativeRememberInput.checked?(localStorage.setItem(Ct.NARRATIVE_KEY_STORAGE,this.narrativeKeyInput.value),localStorage.setItem(Ct.NARRATIVE_SCOPE_STORAGE,this.narrativeWorkspaceInput.value)):(localStorage.removeItem(Ct.NARRATIVE_KEY_STORAGE),localStorage.removeItem(Ct.NARRATIVE_SCOPE_STORAGE))}catch{}}restoreNarrativeKey(){let e=null;try{e=localStorage.getItem(Ct.NARRATIVE_KEY_STORAGE)}catch{return}e!==null&&(this.narrativeKeyInput.value=e,this.narrativeWorkspaceInput.value=localStorage.getItem(Ct.NARRATIVE_SCOPE_STORAGE)??"",this.narrativeRememberInput.checked=!0)}numberOrUndefined(e){return e===""?void 0:Number(e)}stringOrUndefined(e){return e===""?void 0:e}wrapDegrees(e,t){if(e===void 0)return;const i=(e%360+360)%360;return String(i)!==t.value&&(t.value=String(i)),i}refreshSourceRows(){this.placeSourceRow.replaceChildren(document.createTextNode(`${this.messages.according} `),this.sourcePicker("place",HT,e=>{this.placeProvider=e.create()})),this.weatherSourceRow.replaceChildren(this.sourcePicker("weather",GT,e=>{this.weatherInference=new rd(e.create()),this.scheduleWeatherLookup()})),this.terrainSourceRows.replaceChildren(this.labelledPicker("elevation",this.messages.sourceElevation,cd,()=>this.applyTerrainSources()),this.labelledPicker("imagery",this.messages.sourceImagery,jm,()=>this.applyTerrainSources()),this.labelledPicker("decor-model",this.messages.decorModel,jl,()=>this.applyDecorModelSource()))}sourcePicker(e,t,i){const n=document.createDocumentFragment(),s=document.createElement("select");s.id=`${e}Source`;for(const l of t){const c=document.createElement("option");c.value=l.id,c.textContent=l.name,c.title=l.credit,s.appendChild(c)}s.value=this.chosenSourceId.get(e)??t[0].id;const a=document.createElement("a");a.className="source-credit",a.target="_blank",a.rel="noopener noreferrer";const o=()=>{const l=Qr(t,s.value);s.title=l.credit,a.href=l.creditUrl,a.textContent=l.credit};return o(),s.addEventListener("change",()=>{this.chosenSourceId.set(e,s.value),o(),i(Qr(t,s.value))}),n.append(s,document.createTextNode(" "),a),n}labelledPicker(e,t,i,n){const s=document.createElement("label"),a=document.createElement("span");return a.textContent=t,s.append(a,this.sourcePicker(e,i,n)),s}applyTerrainSources(){this.sceneElement.setTerrainProviders({elevation:Qr(cd,this.chosenSourceId.get("elevation")).create(),imagery:Qr(jm,this.chosenSourceId.get("imagery")).create()}),this.ufoElement.refresh()}applyDecorModelSource(){this.decorModelProvider=Qr(jl,this.chosenSourceId.get("decor-model")).create(),this.sceneElement.setDecorModelProvider(this.decorModelProvider),this.refreshDecorModelOptions(),this.ufoElement.refresh()}get placeSearchLanguage(){return navigator.languages?.[0]}set placeSearchProvider(e){this.placeProvider=e}async searchPlace(){const e=this.placeNameInput.value.trim();if(e==="")return;const t=++this.placeSearchToken;this.placeStatusText.textContent=this.messages.placeSearching;let i;try{i=await this.placeProvider.search(e,{language:this.placeSearchLanguage})}catch{if(t!==this.placeSearchToken)return;this.placeStatusText.textContent=this.messages.placeSearchFailed;return}t===this.placeSearchToken&&(this.placeMatches=i,this.refreshPlaceMatches(),i.length>0&&this.applyPlaceMatch(0))}refreshPlaceMatches(){this.placeMatchSelect.replaceChildren(...this.placeMatches.map(t=>{const i=document.createElement("option");return i.textContent=t.name,i.title=t.name,i})),this.placeMatchRow.hidden=this.placeMatches.length===0;const e=this.placeMatches.length===1?this.messages.placeMatchFound:this.messages.placeMatchesFound;this.placeStatusText.textContent=this.placeMatches.length===0?this.messages.placeNotFound:`${this.placeMatches.length} ${e} `,this.placeSourceRow.hidden=this.placeMatches.length===0}applyPlaceMatch(e){const t=this.placeMatches[e];t&&(this.placeMatchSelect.selectedIndex=e,this.placeNameInput.value=t.name,this.placeNameInput.title=t.name,this.latInput.value=String(t.lat),this.lngInput.value=String(t.lng),this.namedCoordinates={lat:t.lat,lng:t.lng},this.updateObserver())}updatePlaceName(){this.placeMatches=[],this.placeMatchRow.hidden=!0,this.placeStatusText.textContent="",this.placeSourceRow.hidden=!0,this.placeNameInput.title=this.placeNameInput.value,this.namedCoordinates=void 0,this.updateObserver()}schedulePlaceReverse(){if(!this.namedCoordinates)return;const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value);e===void 0||t===void 0||Math.abs(e-this.namedCoordinates.lat)<ta&&Math.abs(t-this.namedCoordinates.lng)<ta||(clearTimeout(this.placeReverseTimer),this.placeReverseTimer=setTimeout(()=>void this.reversePlace(e,t),eg))}scheduleTimeZoneLookup(){const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value);if(e===void 0||t===void 0)return;const i=this.ufoElement.sighting.event.timeZone;if(i&&i!==this.autoFilledTimeZone)return;const n=this.timeZoneLookedUpAt;n&&Math.abs(e-n.lat)<ta&&Math.abs(t-n.lng)<ta||(clearTimeout(this.timeZoneLookupTimer),this.timeZoneLookupTimer=setTimeout(()=>void this.lookUpTimeZone(e,t),eg))}async lookUpTimeZone(e,t){this.timeZoneLookedUpAt={lat:e,lng:t};const i=await this.timeZoneProvider.zoneAt(e,t),n=this.ufoElement.sighting.event.timeZone;!i||n&&n!==this.autoFilledTimeZone||this.timeZones.available().includes(i)&&(this.autoFilledTimeZone=i,this.timeZoneSelect.value=i,this.updateTimeZone(),this.dispatchEvent(new CustomEvent("sightingchange")))}async reversePlace(e,t){const i=++this.placeSearchToken;let n;try{n=await this.placeProvider.reverse(e,t,{language:this.placeSearchLanguage})}catch{return}i===this.placeSearchToken&&(this.namedCoordinates={lat:e,lng:t},this.placeNameInput.value=n?.name??"",this.placeNameInput.title=n?.name??"",this.placeMatches=[],this.placeMatchRow.hidden=!0,this.placeStatusText.textContent=n?"":this.messages.placeNotFound,this.placeSourceRow.hidden=!n,this.updateObserver())}updateObserver(){if(this.refreshHeadingPoint(),this.ufoElement.playbackState==="playing")return;const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value),i=this.wrapDegrees(this.numberOrUndefined(this.headingInput.value),this.headingInput),n=this.numberOrUndefined(this.pitchInput.value)??0,s=this.numberOrUndefined(this.rollInput.value)??0,a=this.numberOrUndefined(this.elevationInput.value)??this.groundElevationM??0,o=Math.max(0,a-(this.groundElevationM??0)),l=this.ufoElement.sighting.event,c=this.ufoElement.sighting.witnessTrack,h=this.ufoElement.currentTime,d=this.stringOrUndefined(this.placeNameInput.value.trim());l.place=e!==void 0&&t!==void 0?[{lat:e,lng:t,name:d}]:void 0;const u=this.ufoElement.sighting.instrument,f=this.numberOrUndefined(this.focalLengthInput.value),p=(u.frame&&f!==void 0?ct.fieldOfViewDegAt(u,f):f)??this.currentFovDeg(),v=this.numberOrUndefined(this.fNumberInput.value),m=this.statedExposureSeconds(u);this.ufoElement.sighting.exposureSeconds=m===u.exposureSeconds?void 0:m;const g=this.numberOrUndefined(this.focusDistanceInput.value),x=Math.abs(p-ct.fieldOfViewDeg(u))>.01||v!==u.fNumber||g!==void 0;e===void 0&&t===void 0&&i===void 0&&n===0&&s===0&&o===0&&!x?c.removeKeyframeAt(h):c.addKeyframe(h,{lat:e,lng:t,elevationM:o,headingDeg:i,pitchDeg:n,rollDeg:s===0?void 0:s,fovDeg:p,fNumber:v,focusDistanceM:g}),this.ufoElement.refresh(),this.scheduleWeatherLookup(),this.schedulePlaceReverse(),this.scheduleTimeZoneLookup(),this.scheduleGroundElevation(),this.updateUtcOffsetValidity()}applyEdtfTimeInput(e,t){const i=e.value.trim();if(i==="")t(void 0);else{const n=Gf(i);if(!n)return;t(n)}e.setCustomValidity(""),e.classList.remove("invalid"),this.dropDurationOutrankedByDates(),this.ufoElement.sighting.event.timeZone&&this.applyTimeZoneOffset(),this.ufoElement.refresh(),this.syncDurationField(),this.scheduleWeatherLookup()}dropDurationOutrankedByDates(){const e=this.ufoElement.sighting.event;e.durationSeconds!==void 0&&Ea({...e,durationSeconds:void 0})!==void 0&&(this.ufoElement.durationSeconds=void 0)}validateEdtfTimeInput(e){const t=e.value.trim();t===""||Gf(t)||(e.setCustomValidity(this.messages.edtfInvalid),e.classList.add("invalid"))}refreshTimeZoneOptions(){const e=document.createElement("option");e.value="",e.textContent=this.messages.timeZoneManual,this.timeZoneSelect.replaceChildren(e,...this.timeZones.available().map(t=>{const i=document.createElement("option");return i.value=t,i.textContent=t,i})),this.timeZoneSelect.value=this.ufoElement.sighting.event.timeZone??""}updateTimeZone(){const e=this.stringOrUndefined(this.timeZoneSelect.value);this.ufoElement.sighting.event.timeZone=e,this.applyTimeZoneOffset()}applyTimeZoneOffset(){const e=this.ufoElement.sighting.event,t=e.timeZone&&e.time?this.timeZones.offsetHoursAt(e.timeZone,e.time):void 0;t!==void 0&&(e.utcOffsetHours=t),this.utcOffsetInput.readOnly=e.timeZone!==void 0,this.syncUtcOffsetField(),this.ufoElement.refresh(),this.scheduleWeatherLookup()}updateUtcOffset(){this.ufoElement.sighting.event.utcOffsetHours=this.numberOrUndefined(this.utcOffsetInput.value),this.updateUtcOffsetValidity(),this.ufoElement.refresh(),this.scheduleWeatherLookup()}updateObservationTime(){this.applyEdtfTimeInput(this.obsTimeInput,e=>{this.ufoElement.sighting.event.time=e})}updateObservationEndTime(){this.applyEdtfTimeInput(this.obsEndTimeInput,e=>{this.ufoElement.sighting.event.endTime=e})}updateWitnessMetadata(){const e=this.ufoElement.sighting,t=this.witnessFirstNamesInput.value.split(",").map(n=>n.trim()).filter(n=>n.length>0),i={id:this.stringOrUndefined(this.witnessIdInput.value),dirName:this.stringOrUndefined(this.witnessDirNameInput.value),title:this.stringOrUndefined(this.witnessTitleInput.value),lastName:this.stringOrUndefined(this.witnessLastNameInput.value),firstNames:t.length>0?t:void 0};e.witness=Object.values(i).some(n=>n!==void 0)?i:void 0,e.caseId=this.stringOrUndefined(this.caseIdInput.value),this.updateTestimony(),this.ufoElement.refresh()}updateTestimony(){const e=this.ufoElement.sighting,t=this.testimonyFollowedUpSelect.value,i={witnessAgeYears:this.numberOrUndefined(this.witnessAgeInput.value),witnessOccupation:this.witnessOccupationInput.value.trim()===""?void 0:this.said.write(e.testimony?.witnessOccupation,this.witnessOccupationInput.value,this.writingLanguage),source:this.stringOrUndefined(this.testimonySourceSelect.value),followedUp:t===""?void 0:t==="yes"};e.testimony=Object.values(i).some(n=>n!==void 0)?i:void 0}updateDescription(){this.ufoElement.sighting.event.description=this.said.write(this.ufoElement.sighting.event.description,this.descriptionInput.value,this.writingLanguage),this.ufoElement.refresh()}updateTags(){const e=this.tagsInput.value.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>this.tagNames.stored(t));this.ufoElement.sighting.event.tags=e.length>0?e:void 0,this.ufoElement.refresh()}applyWeatherAtPlayhead(){if(this.ufoElement.playbackState==="playing")return;this.sceneElement.resumeWeatherAudio(),this.weatherFromRecords&&(this.weatherFromRecords=!1,this.cancelWeatherLookup(),this.ufoElement.sighting.weatherSource=void 0,this.syncWeatherSourceState());const e={...kt(this.ufoElement.sighting,this.ufoElement.currentTime),cloudCover:Number(this.cloudCoverInput.value),highCloudCover:Number(this.highCloudCoverInput.value),lowerCloudCover:Number(this.cloudCoverInput.value),cloudDarkness:Number(this.cloudDarknessInput.value),cloudBaseM:this.numberOrUndefined(this.cloudBaseInput.value),precipitationType:this.precipitationTypeSelect.value,precipitationIntensity:Number(this.precipitationIntensityInput.value),windDirectionDeg:this.wrapDegrees(this.numberOrUndefined(this.windDirectionInput.value),this.windDirectionInput)??0,windSpeed:Number(this.windSpeedInput.value),storm:this.stormInput.checked};this.ufoElement.sighting.weatherTrack.addKeyframe(this.ufoElement.currentTime,e),this.ufoElement.refresh()}applyIceAlignmentAtPlayhead(){if(this.ufoElement.playbackState==="playing")return;this.sceneElement.resumeWeatherAudio();const e={...kt(this.ufoElement.sighting,this.ufoElement.currentTime),iceCrystalAlignment:Number(this.iceCrystalAlignmentInput.value)};this.ufoElement.sighting.weatherTrack.addKeyframe(this.ufoElement.currentTime,e),this.ufoElement.refresh()}referenceLabel(e){return this.said.read(e.title)||e.src.replace(/^data:.*$/,"…")||e.id}refreshReferenceList(){const e=this.ufoElement.sighting.references;this.referenceSelect.innerHTML="";for(const t of e){const i=document.createElement("option");i.value=t.id,i.textContent=this.referenceLabel(t),this.referenceSelect.appendChild(i)}this.currentReferenceId!==void 0&&(this.referenceSelect.value=this.currentReferenceId),this.syncReferenceFields()}selectReference(e){this.currentReferenceId=e,this.referenceSelect.value=e,this.disarmLandmark(),this.currentLandmarkId=void 0,this.referenceFit=void 0,this.syncReferenceFields()}syncReferenceFields(){const e=this.ufoElement.sighting.references.find(n=>n.id===this.currentReferenceId),t=e!==void 0;this.deleteReferenceButton.disabled=!t,this.referenceUsePoseButton.disabled=!t;for(const n of[this.referenceSelect,...this.referenceFields])n.disabled=!t,this.setRowVisible(n,t);this.setRowVisible(this.referenceUsePoseButton,t);for(const n of[this.referenceLandmarksSelect,this.addReferenceLandmarkButton,this.deleteReferenceLandmarkButton,this.referenceLandmarkLabelInput])this.setRowVisible(n,t);if(this.refreshLandmarkList(),this.setRowVisible(this.referenceAdoptPoseButton,t),this.syncCanvasMode(),!e){this.referenceStatus.textContent="";return}this.referenceTitleInput.value=this.said.read(e.title)??"";const i=e.src.startsWith("data:");this.referenceSrcInput.value=i?"":e.src,this.referenceSrcInput.disabled=i,this.referenceKindSelect.value=e.kind,this.referenceCreditInput.value=e.credit??"",this.referenceCreditUrlInput.value=e.creditUrl??"",this.referenceTInput.value=e.t===void 0?"":String(e.t/1e3),this.referenceDrawingInput.checked=e.drawing===!0,this.referenceOpacityInput.value=String(e.opacity),this.referenceHeadingInput.value=String(e.registration.headingDeg),this.referencePitchInput.value=String(e.registration.pitchDeg),this.referenceRollInput.value=String(e.registration.rollDeg??0),this.referenceFovInput.value=String(e.registration.fovDeg),this.syncReferenceStatus(e)}syncReferenceStatus(e){if(this.canvasMode()==="picture"){this.syncRegisterStatus();return}if(e.src.startsWith("data:")){const t=Math.round(e.src.length*3/4/1024);this.referenceStatus.textContent=e.src.length>ET?this.messages.referenceEmbedded.replace("{kb}",String(t)):"";return}this.referenceStatus.textContent=this.sceneElement.referenceFailedToLoad(e.src)?this.messages.referenceUnreachable:""}updateReference(){if(this.currentReferenceId===void 0)return;const e=this.ufoElement.sighting,t=this.wrapDegrees(Number(this.referenceHeadingInput.value),this.referenceHeadingInput)??0,i=this.referenceTInput.value.trim()===""?void 0:Number(this.referenceTInput.value);e.references=e.references.map(s=>{if(s.id!==this.currentReferenceId)return s;const a=s.src.startsWith("data:")?s.src:this.referenceSrcInput.value.trim();return{...s,kind:this.referenceKindSelect.value,src:a,title:this.said.write(s.title,this.referenceTitleInput.value,this.writingLanguage),credit:this.stringOrUndefined(this.referenceCreditInput.value),creditUrl:this.stringOrUndefined(this.referenceCreditUrlInput.value),t:i===void 0||Number.isNaN(i)?void 0:Math.round(i*1e3),drawing:this.referenceDrawingInput.checked||void 0,opacity:Number(this.referenceOpacityInput.value),registration:{headingDeg:t,pitchDeg:Number(this.referencePitchInput.value)||0,rollDeg:Number(this.referenceRollInput.value)||void 0,fovDeg:Math.min(179,Math.max(1,Number(this.referenceFovInput.value)||Gl))}}});const n=e.references.find(s=>s.id===this.currentReferenceId);this.referenceSelect.options[this.referenceSelect.selectedIndex].textContent=this.referenceLabel(n),this.syncReferenceStatus(n),this.ufoElement.refresh()}useWitnessPoseForReference(){const e=nt(this.ufoElement.sighting,this.ufoElement.currentTime);e&&(this.referenceHeadingInput.value=String(this.rounded(e.headingDeg??0)),this.referencePitchInput.value=String(this.rounded(e.pitchDeg)),this.referenceRollInput.value=String(this.rounded(e.rollDeg??0)),this.referenceFovInput.value=String(this.rounded(e.fovDeg)),this.updateReference())}addReference(e,t,i={}){const n=this.ufoElement.sighting,s=nt(this.ufoElement.sighting,this.ufoElement.currentTime),a=`picture-${n.references.length+1}`,o={id:a,kind:"photo",src:e,title:t?this.said.write(void 0,t,this.writingLanguage):void 0,opacity:ST,registration:{headingDeg:s?.headingDeg??0,pitchDeg:s?.pitchDeg??0,fovDeg:Gl},...i};n.references=[...n.references,o],this.currentReferenceId=a,this.refreshReferenceList(),this.ufoElement.refresh()}addReferenceFromAddress(){this.addReference(""),this.referenceSrcInput.focus()}async addReferenceFromFile(){const e=this.addReferenceFileInput.files?.[0];if(!e)return;const t=await new Promise((i,n)=>{const s=new FileReader;s.onload=()=>i(s.result),s.onerror=()=>n(s.error),s.readAsDataURL(e)});this.addReferenceFileInput.value="",this.addReference(t,e.name.replace(/\.[^.]+$/,""))}currentReference(){return this.ufoElement.sighting.references.find(e=>e.id===this.currentReferenceId)}currentLandmarks(){return this.currentReference()?.landmarks??[]}writeLandmarks(e){const t=this.ufoElement.sighting;t.references=t.references.map(i=>i.id===this.currentReferenceId?{...i,landmarks:e.length>0?e:void 0}:i)}beginReferenceDrag(e){const t=this.currentReference();if(!t)return;if(this.armingLandmark||this.pendingLandmark){this.nameLandmarkAt(e);return}const i=this.landmarkEndAt(e);if(i){this.selectLandmark(i.landmarkId),this.referenceDragState={kind:"anchor",...i},this.setCanvasCursor("landmark"),this.startDragListening();return}const n=this.sceneElement.referenceAspect(t.id);if(!(n!==void 0&&Ni.picturePointOf(this.directionAtCanvasPoint(e),t.registration,n)!==void 0)){this.beginCameraDrag(e);return}this.referenceDragState={kind:"picture",startPointer:e,startHeadingDeg:t.registration.headingDeg,startPitchDeg:t.registration.pitchDeg,moved:!1},this.setCanvasCursor("panning"),this.startDragListening()}landmarkEndAt(e){const t=this.currentReference(),i=t?this.sceneElement.referenceAspect(t.id):void 0;if(!t||i===void 0)return;const n=8;for(const s of this.currentLandmarks()){const a=this.canvasPointOfDirection(Ni.worldDirectionOf(s.picture,t.registration,i));if(a&&Math.hypot(a.x-e.x,a.y-e.y)<=n)return{landmarkId:s.id,end:"picture"};const o=this.canvasPointOfDirection(Ni.worldDirection(s.scene));if(o&&Math.hypot(o.x-e.x,o.y-e.y)<=n)return{landmarkId:s.id,end:"scene"}}}onReferenceDragPointerMove(e){const t=this.referenceDragState,i=this.canvasPointFromEvent(e);if(!t||!i)return;if(t.kind==="anchor"){this.moveLandmarkEnd(t.landmarkId,t.end,i);return}const n=i.x-t.startPointer.x,s=i.y-t.startPointer.y;if(!t.moved&&Math.hypot(n,s)<3)return;t.moved=!0;const a=this.currentFovDeg()/this.ufoElement.canvasElement.height;this.referenceHeadingInput.value=String(this.rounded(t.startHeadingDeg+n*a)),this.referencePitchInput.value=String(this.rounded(Math.max(-90,Math.min(90,t.startPitchDeg-s*a)))),this.updateReference()}moveLandmarkEnd(e,t,i){const n=this.currentReference(),s=n?this.sceneElement.referenceAspect(n.id):void 0;if(!n||s===void 0)return;const a=this.directionAtCanvasPoint(i);this.writeLandmarks(this.currentLandmarks().map(o=>{if(o.id!==e)return o;if(t==="scene")return{...o,scene:Ni.aimOf(a)};const l=Ni.picturePointOf(a,n.registration,s);return l?{...o,picture:l}:o})),this.ufoElement.refresh()}endReferenceDrag(){const e=this.referenceDragState;this.referenceDragState=void 0,this.setCanvasCursor(this.canvasMode()==="picture"?"pan":this.hoverCursor),document.removeEventListener("pointermove",this.handleDragPointerMove),document.removeEventListener("pointerup",this.handleDragPointerUp),e?.kind==="anchor"&&this.fitReferenceToLandmarks()}onReferenceWheel(e){if(this.canvasMode()!=="picture")return;e.preventDefault();const t=Number(this.referenceFovInput.value)||Gl,i=Math.min(179,Math.max(1,t*Math.exp(Math.sign(e.deltaY)*.05)));this.referenceFovInput.value=String(this.rounded(i)),this.updateReference()}directionAtCanvasPoint(e){const t=this.ufoElement.canvasElement;return this.sceneElement.directionAt(e.x/t.width*2-1,-(e.y/t.height*2-1))}armLandmark(){this.currentReference()&&(this.armingLandmark=!0,this.pendingLandmark=void 0,this.setCanvasCursor("landmark"),this.syncRegisterStatus(),this.ufoElement.refresh())}disarmLandmark(){this.armingLandmark=!1,this.pendingLandmark=void 0,this.canvasMode()==="picture"&&(this.setCanvasCursor("pan"),this.syncRegisterStatus()),this.ufoElement.refresh()}nameLandmarkAt(e){const t=this.currentReference();if(!t)return;const i=this.directionAtCanvasPoint(e);if(!this.pendingLandmark){const a=this.sceneElement.referenceAspect(t.id);if(a===void 0){this.referenceStatus.textContent=this.messages.referenceNotLoaded;return}const o=Ni.picturePointOf(i,t.registration,a);if(!o){this.referenceStatus.textContent=this.messages.referenceLandmarkOffPicture;return}this.pendingLandmark=o,this.syncRegisterStatus(),this.ufoElement.refresh();return}const n=this.currentLandmarks(),s=this.nextLandmarkId(n);this.writeLandmarks([...n,{id:s,picture:this.pendingLandmark,scene:Ni.aimOf(i)}]),this.armingLandmark=!1,this.pendingLandmark=void 0,this.currentLandmarkId=s,this.setCanvasCursor("pan"),this.fitReferenceToLandmarks()}nextLandmarkId(e){let t=e.length+1;for(;e.some(i=>i.id===`landmark-${t}`);)t++;return`landmark-${t}`}fitReferenceToLandmarks(){const e=this.currentReference(),t=e?this.sceneElement.referenceAspect(e.id):void 0;if(!e||t===void 0)return;const i=this.currentLandmarks(),n=Ni.solve(i,t,e.registration.fovDeg);n?(this.referenceFit={n:i.length,residualDeg:n.residualDeg},this.referenceHeadingInput.value=String(this.rounded(n.registration.headingDeg)),this.referencePitchInput.value=String(this.rounded(n.registration.pitchDeg)),this.referenceRollInput.value=String(this.rounded(n.registration.rollDeg??0)),this.referenceFovInput.value=String(this.rounded(n.registration.fovDeg)),this.updateReference()):this.referenceFit=void 0,this.refreshLandmarkList(),this.syncRegisterStatus(),this.ufoElement.refresh()}landmarkResidualDeg(e,t,i){return Ni.worldDirectionOf(e.picture,t.registration,i).angleTo(Ni.worldDirection(e.scene))*180/Math.PI}landmarkLabel(e,t){const i=this.said.read(e.label);return i?`${t+1} · ${i}`:String(t+1)}refreshLandmarkList(){const e=this.currentReference(),t=this.currentLandmarks(),i=e?this.sceneElement.referenceAspect(e.id):void 0;this.referenceLandmarksSelect.innerHTML="";for(const[s,a]of t.entries()){const o=document.createElement("option");o.value=a.id;const l=e&&i!==void 0?` · ${this.landmarkResidualDeg(a,e,i).toFixed(1)}°`:"";o.textContent=this.landmarkLabel(a,s)+l,this.referenceLandmarksSelect.appendChild(o)}this.currentLandmarkId!==void 0&&!t.some(s=>s.id===this.currentLandmarkId)&&(this.currentLandmarkId=void 0),this.currentLandmarkId!==void 0&&(this.referenceLandmarksSelect.value=this.currentLandmarkId);const n=t.find(s=>s.id===this.currentLandmarkId);this.referenceLandmarksSelect.disabled=t.length===0,this.deleteReferenceLandmarkButton.disabled=n===void 0,this.referenceLandmarkLabelInput.disabled=n===void 0,this.shadow.activeElement!==this.referenceLandmarkLabelInput&&(this.referenceLandmarkLabelInput.value=this.said.read(n?.label)??"")}selectLandmark(e){this.currentLandmarkId=e,this.refreshLandmarkList(),this.ufoElement.refresh()}updateLandmarkLabel(){const e=this.currentLandmarkId;if(e===void 0)return;this.writeLandmarks(this.currentLandmarks().map(o=>o.id===e?{...o,label:this.said.write(o.label,this.referenceLandmarkLabelInput.value,this.writingLanguage)}:o));const t=this.referenceLandmarksSelect.options[this.referenceLandmarksSelect.selectedIndex],i=this.currentLandmarks(),n=i.findIndex(o=>o.id===e),s=this.currentReference(),a=s?this.sceneElement.referenceAspect(s.id):void 0;if(t&&n>=0){const o=s&&a!==void 0?` · ${this.landmarkResidualDeg(i[n],s,a).toFixed(1)}°`:"";t.textContent=this.landmarkLabel(i[n],n)+o}this.ufoElement.refresh()}deleteLandmark(){const e=this.currentLandmarkId;if(e===void 0)return;const t=this.currentLandmarks().filter(i=>i.id!==e);this.writeLandmarks(t),this.currentLandmarkId=t[t.length-1]?.id,this.fitReferenceToLandmarks()}landmarkHint(){const e=this.currentLandmarks().length+1;if(this.pendingLandmark)return this.messages.referenceLandmarkScene.replace("{n}",String(e));if(this.armingLandmark)return this.messages.referenceLandmarkPicture.replace("{n}",String(e))}syncRegisterStatus(){const e=this.landmarkHint();e?this.referenceStatus.textContent=e:this.referenceFit?this.referenceStatus.textContent=this.messages.referenceLandmarksFit.replace("{n}",String(this.referenceFit.n)).replace("{deg}",this.referenceFit.residualDeg.toFixed(1)):this.referenceStatus.textContent=this.messages.referenceRegisterHint}canvasPointOfDirection(e){const t=this.sceneElement.screenPointOf(e);if(!t)return;const i=this.ufoElement.canvasElement;return{x:(t.ndcX+1)/2*i.width,y:(1-t.ndcY)/2*i.height}}paintPictureOverlay=e=>{const t=this.currentReference();if(!t)return;const i=this.sceneElement.referenceAspect(t.id);if(i===void 0)return;const{registration:n}=t,s=[{u:0,v:0},{u:1,v:0},{u:1,v:1},{u:0,v:1}].map(o=>this.canvasPointOfDirection(Ni.worldDirectionOf(o,n,i))),a=this.currentLandmarks().map((o,l)=>({picture:this.canvasPointOfDirection(Ni.worldDirectionOf(o.picture,n,i)),scene:this.canvasPointOfDirection(Ni.worldDirection(o.scene)),label:this.landmarkLabel(o,l),selected:o.id===this.currentLandmarkId,residualDeg:this.landmarkResidualDeg(o,t,i)}));this.pendingLandmark&&a.push({picture:this.canvasPointOfDirection(Ni.worldDirectionOf(this.pendingLandmark,n,i)),scene:void 0,label:String(this.currentLandmarks().length+1),selected:!0,residualDeg:void 0}),e.paintPictureFrame(s.every(o=>o!==void 0)?s:void 0,a.filter(o=>o.picture!==void 0),this.landmarkHint())};adoptReferencePose(){const e=this.currentReference();if(!e)return;const{headingDeg:t,pitchDeg:i,rollDeg:n}=e.registration;this.headingInput.value=String(this.rounded(t)),this.pitchInput.value=String(this.rounded(i)),this.rollInput.value=String(this.rounded(n??0)),this.updateObserver();const s=this.ufoElement.currentTime,a=this.ufoElement.sighting.witnessTrack.toJSON().keyframes.findIndex(c=>c.t===s);if(a<0)return;const o=this.messages.referenceAdoptRationale.replace("{title}",this.referenceLabel(e)).replace("{n}",String(this.currentLandmarks().length)).replace("{deg}",(this.referenceFit?.residualDeg??0).toFixed(1)),l=[["headingDeg",t],["pitchDeg",i],["rollDeg",n??0]];for(const[c,h]of l)this.ufoElement.sighting.provenance.set(`witnessTrack.keyframes.${a}.pose.${c}`,{basis:"derived",rationale:o,of:this.rounded(h)})}syncStreetSearchAvailability(){const e=this.numberOrUndefined(this.latInput.value)!==void 0&&this.numberOrUndefined(this.lngInput.value)!==void 0;this.referenceStreetSearchButton.disabled=!e}async searchStreetPictures(){const e=nt(this.ufoElement.sighting,0),t=e?.lat??this.numberOrUndefined(this.latInput.value),i=e?.lng??this.numberOrUndefined(this.lngInput.value);if(t===void 0||i===void 0)return;const n=300;this.referenceStatus.textContent=this.messages.referenceStreetSearching,this.referenceStreetSearchButton.disabled=!0;try{this.streetPictures=await this.streetPictures$.nearby(t,i,n)}catch{this.streetPictures=[],this.referenceStatus.textContent=this.messages.referenceStreetFailed,this.referenceStreetSearchButton.disabled=!1;return}this.referenceStreetSearchButton.disabled=!1,this.referenceStreetSelect.innerHTML="";for(const[a,o]of this.streetPictures.entries()){const l=document.createElement("option");l.value=String(a),l.textContent=this.streetPictureLabel(o,this.messages.referenceStreetItem),this.referenceStreetSelect.appendChild(l)}const s=this.streetPictures.length>0;this.referenceStreetSelect.hidden=!s,this.referenceStreetAddButton.hidden=!s,this.referenceStatus.textContent=s?"":this.messages.referenceStreetNone.replace("{m}",String(n))}streetPictureLabel(e,t){return t.replace("{distance}",String(Math.round(e.distanceM))).replace("{bearing}",String(Math.round(e.bearingDeg))).replace("{date}",e.takenAt.slice(0,10)).replace("{panorama}",e.panorama?this.messages.referenceStreetPanorama:"")}addStreetPicture(){const e=this.streetPictures[Number(this.referenceStreetSelect.value)];e&&this.addReference(e.src,this.streetPictureLabel(e,this.messages.referenceStreetTitle),{kind:e.panorama?"panorama":"photo",credit:e.credit,creditUrl:e.creditUrl,registration:{headingDeg:e.azimuthDeg??0,pitchDeg:0,fovDeg:Gl}})}deleteReference(){if(this.currentReferenceId===void 0)return;const e=this.ufoElement.sighting;e.references=e.references.filter(t=>t.id!==this.currentReferenceId),this.currentReferenceId=e.references[0]?.id,this.refreshReferenceList(),this.ufoElement.refresh()}buildSoundKindOptions(){for(const e of bv){const t=document.createElement("option");t.value=e,t.textContent=this.soundKindLabel(e,this.messages),this.soundKindOptions.set(e,t),this.soundKindSelect.appendChild(t)}}soundKindLabel(e,t){switch(e){case"hum":return t.soundHum;case"whistle":return t.soundWhistle;case"rumble":return t.soundRumble;case"crackle":return t.soundCrackle;default:return t.soundNone}}applySoundAtPlayhead(){if(this.ufoElement.playbackState==="playing")return;const e=this.readSound();this.ufoElement.sighting.soundTrack.addKeyframe(this.ufoElement.currentTime,e),this.updateSoundPitchReadout(e.pitchHz),this.updateSoundFieldsDisabledState(e),this.ufoElement.refresh(),this.previewSound(e)}previewSound(e){clearTimeout(this.soundPreviewTimer),this.ufoElement.previewSound(e),this.soundPreviewTimer=setTimeout(()=>this.ufoElement.stopSoundPreview(),$T)}readSound(){return{kind:this.soundKindSelect.value,volume:Number(this.soundVolumeInput.value),pitchHz:Number(this.soundPitchInput.value),src:this.soundSrcInput.value.trim()||void 0}}syncSoundFromTimeline(){if(this.ufoElement.playbackState==="playing")return;const e=Wu(this.ufoElement.sighting,this.ufoElement.currentTime),t=this.shadow.activeElement;t!==this.soundKindSelect&&(this.soundKindSelect.value=e.kind),t!==this.soundVolumeInput&&(this.soundVolumeInput.value=String(e.volume)),t!==this.soundPitchInput&&(this.soundPitchInput.value=String(e.pitchHz)),t!==this.soundSrcInput&&(this.soundSrcInput.value=e.src??""),this.updateSoundPitchReadout(e.pitchHz),this.updateSoundFieldsDisabledState(e)}updateSoundPitchReadout(e){this.soundPitchValue.textContent=`${Math.round(e)} Hz`}updateSoundFieldsDisabledState(e){const t=e.kind==="none"&&!e.src;this.soundVolumeInput.disabled=t,this.soundSrcInput.disabled=t,this.soundPitchInput.disabled=t||e.src!==void 0}set weatherProvider(e){this.weatherInference=new rd(e),this.scheduleWeatherLookup()}onWeatherInferredToggled(){this.weatherFromRecords=this.weatherInferredInput.checked,this.weatherFromRecords?this.scheduleWeatherLookup():(this.cancelWeatherLookup(),this.ufoElement.sighting.weatherSource=void 0,this.syncWeatherSourceState())}scheduleWeatherLookup(){this.weatherFromRecords&&(clearTimeout(this.weatherLookupTimer),this.weatherLookupTimer=setTimeout(()=>void this.inferWeather(),ZT))}cancelWeatherLookup(){clearTimeout(this.weatherLookupTimer),this.weatherLookupToken++,this.weatherLookupPending=!1}async inferWeather(){if(!this.weatherFromRecords)return;const e=++this.weatherLookupToken;this.weatherLookupPending=!0,this.syncWeatherSourceState();const t=await this.weatherInference.infer(this.ufoElement.sighting);e!==this.weatherLookupToken||!this.weatherFromRecords||(this.weatherLookupPending=!1,this.weatherLookupResult=t,t.status==="inferred"?(this.weatherInference.applyTo(this.ufoElement.sighting,t),this.weatherTrackSpan=this.ufoElement.seekableDuration,this.ufoElement.refresh(),this.syncWeatherFromTimeline()):this.ufoElement.sighting.weatherSource=void 0,this.syncWeatherSourceState())}ensureWeatherTrackSpan(){if(!this.weatherFromRecords||this.ufoElement.sighting.weatherSource===void 0)return;const e=this.ufoElement.seekableDuration;this.weatherTrackSpan===void 0||e===this.weatherTrackSpan||(this.weatherTrackSpan=e,this.scheduleWeatherLookup())}syncWeatherSourceState(){const e=this.ufoElement.sighting.weatherSource,t=this.weatherFromRecords;for(const o of this.weatherFields)o.disabled=t&&e!==void 0&&o!==this.iceCrystalAlignmentInput||this.ufoElement.playbackState==="playing",this.ufoElement.playbackState==="playing"?o.title=this.messages.weatherWhilePlaying:o.title===this.messages.weatherWhilePlaying&&(o.title="");const i=this.weatherInference.canInfer(this.ufoElement.sighting);this.weatherInferredInput.disabled=!i,this.weatherInferredInput.checked=i&&this.weatherFromRecords;const n=i?this.messages.weatherInferredTitle:this.messages.weatherNeedsDateAndPlace;this.weatherInferredInput.title=n,this.labelWeatherInferred.title=n;const s=t&&e!==void 0;if(this.weatherSourceLink.hidden=!s,s){this.weatherSourceRow.hidden=!1,this.weatherSourceText.textContent="",this.weatherSourceLink.href=e.url,this.weatherSourceLink.textContent=this.observationInstantLabel();return}const a=t?this.weatherStatusMessage():"";this.weatherSourceText.textContent=a===""?"":`${a} `,this.weatherSourceRow.hidden=a===""}weatherStatusMessage(){if(this.weatherLookupPending)return this.messages.weatherLookingUp;switch(this.weatherLookupResult?.status){case"unavailable":return this.messages.weatherNoRecord;case"failed":return this.messages.weatherLookupFailed;default:return""}}observationInstantLabel(){const e=this.ufoElement.sighting.event,t=e.time&&zn(e.time,e.place?.[0]?.lng??0,e.utcOffsetHours);return t?`, ${t.toISOString().slice(0,16).replace("T"," ")} UTC`:""}syncWeatherOwnership(){const e=this.ufoElement.sighting;this.cancelWeatherLookup(),this.weatherLookupResult=void 0,this.weatherFromRecords=e.weatherSource!==void 0||e.weatherTrack.allKeyframes.length===0,this.syncWeatherSourceState(),this.weatherFromRecords&&e.weatherSource===void 0&&this.scheduleWeatherLookup()}syncDurationField(){if(this.shadow.activeElement!==this.durationInput){const e=Ea(this.ufoElement.sighting.event);this.durationInput.value=e!==void 0?String(e/1e3):""}this.updateDurationValidity()}updateDurationValidity(){const e=this.durationInput.value==="";this.durationInput.classList.toggle("missing-required",e),this.markUnansweredQuestions(),this.durationInput.setAttribute("aria-invalid",String(e));const t=_v(this.ufoElement.sighting.event);this.durationInput.title=t==="imprecise"?this.messages.durationImprecise:""}syncPlaybackControls(){this.ensureWeatherTrackSpan();const e=this.ufoElement.playbackState==="playing",t=this.ufoElement.seekableDuration>0;this.playPauseButton.textContent=e?"⏸":"▶",this.playPauseButton.disabled=!t;const i=t?e?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=i,this.playPauseButton.setAttribute("aria-label",i),this.seekInput.max=String(this.ufoElement.seekableDuration),this.shadow.activeElement!==this.seekInput&&(this.seekInput.value=String(this.ufoElement.currentTime)),this.timeStartLabel.textContent=this.ufoElement.positionLabel,this.timeEndLabel.textContent=this.ufoElement.durationLabel,this.syncTimeDisplaySwitch()}switchTimeDisplay(){this.ufoElement.toggleTimeDisplay(),this.timeStartLabel.textContent=this.ufoElement.positionLabel,this.timeEndLabel.textContent=this.ufoElement.durationLabel,this.syncTimeDisplaySwitch()}syncTimeDisplaySwitch(){const e=this.ufoElement.canSwitchTimeDisplay,t=this.ufoElement.showingClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime;for(const[i,n]of[[this.timeStartLabel,this.messages.currentPosition],[this.timeEndLabel,this.messages.duration]])i.title=e?`${n} — ${t}`:n,i.classList.toggle("switchable",e),e?(i.setAttribute("role","button"),i.setAttribute("tabindex","0")):(i.removeAttribute("role"),i.removeAttribute("tabindex"))}static TIME_QUALIFIERS=[{value:"",key:"timeQualifierExact"},{value:"~",key:"timeQualifierApproximate"},{value:"?",key:"timeQualifierUncertain"},{value:"%",key:"timeQualifierBoth"}];refreshTimeQualifierOptions(){for(const e of[this.obsTimeQualifier,this.obsEndTimeQualifier]){const t=e.value;e.replaceChildren(...Ct.TIME_QUALIFIERS.map(i=>{const n=document.createElement("option");return n.value=i.value,n.textContent=this.messages[i.key],n})),e.value=t}}qualifierOf(e){const t=e.trim().slice(-1);return"?~%".includes(t)?t:""}isPickable(e){return e?e.year!==void 0&&e.month!==void 0&&e.day!==void 0&&e.hour!==void 0&&e.minute!==void 0&&(e.second===void 0||e.second===0):!1}pickerValueOf(e){if(!this.isPickable(e))return"";const t=(i,n=2)=>String(i).padStart(n,"0");return`${t(e.year,4)}-${t(e.month)}-${t(e.day)}T${t(e.hour)}:${t(e.minute)}`}writeFromPicker(e,t,i,n){e.value===""&&e.validity.badInput||(i.value=e.value===""?"":`${e.value}${t.value}`,n())}chooseTimeInputMode(){const e=this.ufoElement.sighting.event,t=i=>i===void 0||this.isPickable(i);this.setEdtfMode(!(t(e.time)&&t(e.endTime)))}setEdtfMode(e){this.edtfMode=e,this.edtfModeButton.setAttribute("aria-pressed",String(e));for(const[t,i,n]of[[this.obsTimeInput,this.obsTimeNativeInput,this.obsTimeQualifier],[this.obsEndTimeInput,this.obsEndTimeNativeInput,this.obsEndTimeQualifier]])t.hidden=!e,i.hidden=e,n.hidden=e}syncObservationTimeFields(){const e=this.ufoElement.sighting.event.time;this.obsTimeInput.value=e?ic(e):"",this.obsTimeNativeInput.value=this.pickerValueOf(e),this.obsTimeQualifier.value=this.qualifierOf(this.obsTimeInput.value),this.obsTimeInput.setCustomValidity(""),this.obsTimeInput.classList.remove("invalid")}syncObservationEndTimeFields(){const e=this.ufoElement.sighting.event.endTime;this.obsEndTimeInput.value=e?ic(e):"",this.obsEndTimeNativeInput.value=this.pickerValueOf(e),this.obsEndTimeQualifier.value=this.qualifierOf(this.obsEndTimeInput.value),this.obsEndTimeInput.setCustomValidity(""),this.obsEndTimeInput.classList.remove("invalid")}syncUtcOffsetField(){const e=this.ufoElement.sighting.event.utcOffsetHours;this.utcOffsetInput.value=e===void 0?"":String(e),this.updateUtcOffsetValidity()}updateUtcOffsetValidity(){const e=this.ufoElement.sighting.event.utcOffsetHours,t=this.ufoElement.sighting.event.place?.[0]?.lng,i=t===void 0?void 0:Math.round(t/15),n=e!==void 0&&i!==void 0&&Math.abs(e-i)>QT;this.utcOffsetInput.classList.toggle("invalid",n),this.utcOffsetInput.title=n?this.messages.utcOffsetImplausible.replace("{solar}",i>=0?`+${i}`:String(i)):""}scheduleGroundElevation(){const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value);e===void 0||t===void 0||this.groundElevationFor&&this.isSamePlace(this.groundElevationFor,e,t)||(clearTimeout(this.groundElevationTimer),this.groundElevationTimer=setTimeout(()=>void this.applyGroundElevation(e,t),JT))}isSamePlace(e,t,i){return Math.abs(e.lat-t)<ta&&Math.abs(e.lng-i)<ta}async applyGroundElevation(e,t){const i=++this.groundElevationToken,n=Qr(cd,this.chosenSourceId.get("elevation")),s=await new Cf(n.create()).at(e,t);if(i!==this.groundElevationToken||s===void 0)return;this.groundElevationFor={lat:e,lng:t};const a=Math.max(0,(this.numberOrUndefined(this.elevationInput.value)??0)-(this.groundElevationM??0));this.groundElevationM=Math.round(s),this.syncElevationField(a),this.updateObserver()}syncElevationField(e){const t=this.groundElevationM;this.elevationInput.value=String(Math.round((t??0)+e)),this.elevationInput.min=t===void 0?"":String(t),this.elevationInput.title=t===void 0?"":this.messages.altitudeAboveSeaLevel,this.groundElevationOutput.textContent=t===void 0?"":this.messages.groundAt.replace("{m}",String(t))}syncGroundElevationField(){this.groundElevationToken++,clearTimeout(this.groundElevationTimer),this.groundElevationM=void 0,this.groundElevationFor=void 0,this.syncElevationField(nt(this.ufoElement.sighting,0)?.elevationM??0),this.scheduleGroundElevation()}syncPlaceNameField(){const e=this.ufoElement.sighting.event.place?.[0],t=e?.name??"";this.placeNameInput.value=t,this.placeNameInput.title=t,this.namedCoordinates=e&&t?{lat:e.lat,lng:e.lng}:void 0,this.placeMatches=[],this.placeMatchRow.hidden=!0,this.placeStatusText.textContent=""}syncWitnessMetadataFields(){const e=this.ufoElement.sighting;this.witnessIdInput.value=e.witness?.id??"",this.witnessDirNameInput.value=e.witness?.dirName??"",this.witnessTitleInput.value=e.witness?.title??"",this.witnessLastNameInput.value=e.witness?.lastName??"",this.witnessFirstNamesInput.value=e.witness?.firstNames?.join(", ")??"",this.caseIdInput.value=e.caseId??"",this.witnessAgeInput.value=e.testimony?.witnessAgeYears?.toString()??"",this.witnessOccupationInput.value=this.said.read(e.testimony?.witnessOccupation)??"",this.testimonySourceSelect.value=e.testimony?.source??"",this.testimonyFollowedUpSelect.value=e.testimony?.followedUp===void 0?"":e.testimony.followedUp?"yes":"no",this.descriptionInput.value=this.said.read(e.event.description)??"",this.showTags(),this.instrumentSelect.value=e.instrument.id}syncWeatherFromTimeline(){if(this.cloudEditor?.sync(),this.ufoElement.playbackState==="playing")return;const e=kt(this.ufoElement.sighting,this.ufoElement.currentTime),t=this.shadow.activeElement;t!==this.cloudCoverInput&&(this.cloudCoverInput.value=String(e.cloudCover)),t!==this.highCloudCoverInput&&(this.highCloudCoverInput.value=String(e.highCloudCover??0)),t!==this.iceCrystalAlignmentInput&&(this.iceCrystalAlignmentInput.value=String(e.iceCrystalAlignment??.65)),t!==this.cloudDarknessInput&&(this.cloudDarknessInput.value=String(e.cloudDarkness)),t!==this.cloudBaseInput&&(this.cloudBaseInput.value=e.cloudBaseM===void 0?"":String(e.cloudBaseM)),t!==this.precipitationTypeSelect&&(this.precipitationTypeSelect.value=e.precipitationType),t!==this.precipitationIntensityInput&&(this.precipitationIntensityInput.value=String(e.precipitationIntensity)),t!==this.windDirectionInput&&(this.windDirectionInput.value=String(Math.round(e.windDirectionDeg))),t!==this.windSpeedInput&&(this.windSpeedInput.value=String(Math.round(e.windSpeed*2)/2)),t!==this.stormInput&&(this.stormInput.checked=e.storm)}syncObserverFromTimeline(){if(this.ufoElement.playbackState==="playing")return;this.syncStreetSearchAvailability();const e=this.ufoElement.sighting,t=e.witnessTrack.getInterpolatedPoseAt(this.ufoElement.currentTime),i=e.event.place?.[0],n=this.shadow.activeElement;n!==this.latInput&&(this.latInput.value=t?.lat!==void 0?String(t.lat):i?String(i.lat):""),n!==this.lngInput&&(this.lngInput.value=t?.lng!==void 0?String(t.lng):i?String(i.lng):""),n!==this.headingInput&&(this.headingInput.value=t?.headingDeg!==void 0?String(this.rounded(t.headingDeg)):""),this.refreshHeadingPoint(),n!==this.pitchInput&&(this.pitchInput.value=String(this.rounded(t?.pitchDeg??0)),this.rollInput.value=String(this.rounded(t?.rollDeg??0))),n!==this.elevationInput&&this.syncElevationField(t?.elevationM??0)}get appearance(){return{...this.currentAppearance}}set appearance(e){this.setAppearance(e)}setAppearance(e){const t="presetId"in e;this.currentAppearance={...this.currentAppearance,...e},this.updatePresetButtons(),!(this.isRecording||this.ufoElement.playbackState==="playing")&&this.applyAppearanceAtPlayhead(void 0,t)}applyAppearanceAtPlayhead(e,t=!0){const i=this.ufoElement.sighting.timeline,n=this.ufoElement.currentTime,s=i.getInterpolatedShapeAt(n,this.currentSourceId),a=this.buildAppearanceShape(e??s?.bounds??this.defaultBounds(),s,t);this.commitShapes(n,[{sourceId:this.currentSourceId,shape:a}]),this.ufoElement.refresh()}buildAppearanceShape(e,t,i=!0){if(t&&!i)return{...t,color:this.currentAppearance.color,transparency:this.currentAppearance.transparency,haloScale:this.currentAppearance.haloScale,blur:this.currentAppearance.blur,brightness:this.currentAppearance.brightness};const n=zf(e,this.currentAppearance);return t?{...n,angle:t.angle,title:t.title,selected:t.selected}:n}toggleSkyDetails(){const e=this.skyDetailsButton.getAttribute("aria-expanded")!=="true";this.skyDetailsButton.setAttribute("aria-expanded",String(e)),this.skyDetailsButton.textContent=e?"▴":"▾",this.skyDetailsButton.title=e?this.messages.skyDetailsHide:this.messages.skyDetails,this.skyDetailsButton.setAttribute("aria-label",this.skyDetailsButton.title);for(const t of this.clampedLines)t.classList.toggle("clamped",!e)}isGroupOpen(e){return e.getAttribute("aria-expanded")==="true"}toggleGroup(e,t){this.cloudEditor?.stopManipulation();for(const[i,n]of this.groupTabs.entries()){const s=n===e&&t;n.setAttribute("aria-expanded",String(s)),this.groupPanels[i].hidden=!s}this.syncCanvasMode()}isGroupIdOpen(e){const t=this.groupTabs.find(i=>i.getAttribute("aria-controls")===e);return t!==void 0&&this.isGroupOpen(t)}canvasMode(){return this.isGroupIdOpen("group-reference")&&this.currentReferenceId!==void 0?"picture":this.isGroupIdOpen("group-shape")?"shape":"scene"}syncCanvasMode(){const e=this.canvasMode(),t=e==="picture",i=this.lastCanvasMode==="picture",n=e!==this.lastCanvasMode;this.lastCanvasMode=e,this.ufoElement.selectionShown=e==="shape",this.ufoElement.overlayPainter=t?this.paintPictureOverlay:void 0,n&&this.ufoElement.refresh(),t!==i&&this.setCanvasCursor(t?"pan":this.hoverCursor),!t&&(this.armingLandmark||this.pendingLandmark)&&this.disarmLandmark();const s=this.currentReference();s&&this.syncReferenceStatus(s),this.syncStreetSearchAvailability()}openSubgroup(e){this.cloudEditor?.stopManipulation();const t=e.parentElement;for(const i of this.subgroupTabs){if(i.parentElement!==t)continue;const n=i===e;i.setAttribute("aria-expanded",String(n)),this.shadow.getElementById(i.getAttribute("aria-controls")).hidden=!n}}revealSubgroupOf(e){const t=e.closest(".subgroup-panel"),i=t&&this.subgroupTabs.find(n=>n.getAttribute("aria-controls")===t.id);i&&this.openSubgroup(i)}static SUMMARY_GROUPS=["observation","witness","location","decor","temporal","weather","sound"];static PANEL_ORDER=["observation","witness","location","decor","temporal","weather","sound","shape"];refreshParamSummary(){const t=this.paramSummaryBuilder.entriesFor(this.ufoElement.sighting,this.ufoElement.currentTime,{decorId:this.currentDecorId,decorPicker:!0,groundElevationM:this.groundElevationM??0}).map(n=>({...n,panel:Ct.SUMMARY_GROUPS.indexOf(n.group)})),i=t.map(n=>`${n.field}=${n.label}=${n.value}${n.unit}${n.fromSource?"*":""}`).join("|");i!==this.paramSummarySignature&&(this.paramSummarySignature=i,this.paramChips=t,this.renderParamSummary(),this.runAssessments())}paramChips=[];renderParamSummary(){const e=Ct.NESTED_GROUPS,t=[];let i;for(const n of[...this.paramChips,...this.assessmentChips]){if(i&&i.group!==n.group&&(i=void 0),e.includes(n.group)&&!i){const a=document.createElement("span");a.className="param-nest",a.dataset.group=n.group;const o=document.createElement("span");o.className="param-nest-label",o.textContent=n.group==="assessment"?this.messages.assessmentGroup:Ct.tabLabel(this.groupTabs[Ct.SUMMARY_GROUPS.indexOf(n.group)]),a.append(o),i={group:n.group,element:a},t.push(a)}const s=this.paramChip(n);i?i.element.append(s):t.push(s)}this.paramSummary.replaceChildren(...t)}static NESTED_GROUPS=["witness","decor","assessment"];static QUESTION_FIELDS={when:{panel:"temporal",fields:["obs-time","obs-time-native"]},where:{panel:"location",fields:["lat","lng"]},facing:{panel:"location",fields:["heading"]},"apparent-size":{panel:"shape",fields:[]},"sky-position":{panel:"shape",fields:[]},"how-long":{panel:"temporal",fields:["durationSeconds","obs-end-time","obs-end-time-native"]},appearance:{panel:"shape",fields:["shapeTitle","color"]},movement:{panel:"shape",fields:[]},sound:{panel:"sound",fields:["soundKind"]},conditions:{panel:"weather",fields:["cloudCover"]}};assessmentChips=[];assessmentToken=0;async runAssessments(){const e=++this.assessmentToken,t=await new Uv(this.messages).read(this.ufoElement.sighting);e===this.assessmentToken&&(this.assessmentChips=t.entries.map(i=>({...i,panel:Ct.PANEL_ORDER.indexOf(i.about??"")})),this.markUnansweredQuestions(t.unanswered),this.renderParamSummary())}static tabLabel(e){return(e.querySelector("span:not(.tab-badge)")??e).textContent.trim()}static badgeOn(e){const t=e.querySelector(".tab-badge");if(t)return t;const i=document.createElement("span");return i.className="tab-badge",i.hidden=!0,e.append(i),i}unansweredQuestions=new Set;markUnansweredQuestions(e=this.unansweredQuestions){this.unansweredQuestions=e;const t=new Set;for(const s of e){const a=Ct.QUESTION_FIELDS[s];if(a&&!a.fields.some(o=>this.shadow.getElementById(o)?.classList.contains("missing-required")))for(const o of a.fields){const l=this.shadow.getElementById(o);l&&!l.hidden&&l.value===""&&t.add(o)}}for(const[s,a]of Object.entries(Ct.QUESTION_FIELDS))for(const o of Ct.QUESTION_FIELDS[s].fields){const l=this.shadow.getElementById(o);if(!l)continue;const c=t.has(o)&&!l.classList.contains("missing-required");l.classList.toggle("wanted",c),(c||l.title===this.messages.questionUnanswered)&&(l.title=c?this.messages.questionUnanswered:"")}const i=new Map;let n;for(const[s,a]of Object.entries(Ct.QUESTION_FIELDS))for(const o of a.fields){const l=this.shadow.getElementById(o);if(!l)continue;const c=l.classList.contains("missing-required");!c&&!l.classList.contains("wanted")||(c&&(n=a.panel),i.set(a.panel,(i.get(a.panel)??0)+1))}for(const[s,a]of this.groupTabs.entries()){const o=Ct.PANEL_ORDER[s],l=i.get(o)??0,c=o===n,h=Ct.badgeOn(a);h.hidden=l===0,h.textContent=String(l),h.classList.toggle("optional",!c),a.title=l===0?"":c?this.messages.durationRequired:this.messages.questionsUnanswered.replace("{count}",String(l))}}paramChip(e){const t=document.createElement("button");t.type="button",t.className=e.fromSource?"param-chip from-source":"param-chip",t.dataset.panel=String(e.panel),t.dataset.field=e.field;const i=document.createElement("span");if(i.className="param-chip-label",i.textContent=`${e.label} `,t.append(i),e.color!==void 0){const s=document.createElement("span");s.className="param-chip-swatch",s.style.background=e.color,t.append(s)}const n=document.createElement("span");return n.className="param-chip-value",n.textContent=e.unit===""?e.value:`${e.value} ${e.unit}`,t.append(n),t}onParamSummaryClick(e){const t=e.target.closest(".param-chip");if(t==null)return;const i=Number(t.dataset.panel);if(i<0)return;const n=this.groupPanels[i];this.toggleGroup(this.groupTabs[i],!0);const s=t.dataset.field;if(s.startsWith("decor:")){this.currentDecorId=s.slice(6),this.refreshDecorList(),this.decorSelect.focus();return}const a=this.shadow.getElementById(s);a===null||!n.contains(a)||(this.revealSubgroupOf(a),a.focus(),a instanceof HTMLInputElement&&a.type!=="checkbox"&&a.type!=="color"&&a.type!=="range"&&a.select(),a.scrollIntoView?.({block:"center"}))}onSelectionOrTimeChanged(){this.syncAppearanceFromTimeline(),this.syncObserverFromTimeline(),this.syncWeatherFromTimeline(),this.syncWeatherSourceState(),this.syncSoundFromTimeline(),this.syncDecorLitFromTimeline(),this.syncDecorPlacementFromTimeline(),this.syncIndoorLookReset(),this.updateAppearanceFieldsDisabledState(),this.updateShapeTitleValidity(),this.refreshRealSize(),this.refreshBlurDistanceBound(),this.refreshSkyCandidates(),this.refreshInstrumentOptions(),this.syncOpticsFromInstrument(),this.ufoElement.selectedSourceIds=this.selectedSourceIds;const e=this.ufoElement.sighting.timeline.sourceIds,t=e.filter(i=>this.selectedSourceIds.has(i)).length;this.deleteShapeButton.disabled=this.isRecording||this.ufoElement.playbackState==="playing"||t===0||e.length-t<1,this.refreshParamSummary()}updateAppearanceFieldsDisabledState(){const e=this.selectedSourceIds.size>1,t=e?this.messages.multipleShapesSelected:"";for(const i of[this.shapeTitleInput,this.colorInput,this.transparencyInput,this.haloScaleInput,this.blurInput,this.brightnessInput,this.apparentWidthInput,this.realWidthInput,this.objectDistanceInput,this.sizeLockSelect,this.clearDistanceHypothesisButton,this.sourceSelect,...Object.values(this.presetButtons)])i.disabled=e,i.title=t}syncAppearanceFromTimeline(){if(this.ufoElement.playbackState==="playing"||this.selectedSourceIds.size>1)return;const e=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId);e&&(this.currentAppearance={presetId:sA(e),color:e.color,transparency:e.transparency,haloScale:e.haloScale,blur:e.blur??0,brightness:e.brightness??0},this.updatePresetButtons(),this.colorInput.value=this.currentAppearance.color,this.transparencyInput.value=String(this.currentAppearance.transparency),this.haloScaleInput.value=String(this.currentAppearance.haloScale),this.blurInput.value=String(this.currentAppearance.blur),this.brightnessInput.value=String(this.currentAppearance.brightness),this.shadow.activeElement!==this.shapeTitleInput&&(this.shapeTitleInput.value=this.said.read(e.title)??""),this.refreshApparentSize())}updateShapeTitle(){const e=this.ufoElement.sighting.timeline,t=this.ufoElement.currentTime,i=e.getInterpolatedShapeAt(t,this.currentSourceId);i&&(this.commitShapes(t,[{sourceId:this.currentSourceId,shape:{...i,title:this.said.write(i.title,this.shapeTitleInput.value,this.writingLanguage)}}]),this.ufoElement.refresh(),this.refreshSourceList(),this.updateShapeTitleValidity())}sizeLock="none";onApparentWidthInput(){const e=this.numberOrUndefined(this.apparentWidthInput.value);if(!(e===void 0||e<=0||this.selectedSourceIds.size!==1)){if(this.sizeLock==="real"){const t=this.numberOrUndefined(this.realWidthInput.value);t!==void 0&&t>0&&this.sceneElement.setDistanceHypothesis(this.currentSourceId,it.distanceMAt(t,e))}this.applyApparentWidth(e)}}onRealWidthInput(){const e=this.numberOrUndefined(this.realWidthInput.value);if(e===void 0||e<=0||this.selectedSourceIds.size!==1)return;if(this.sizeLock==="apparent"){const i=this.currentApparentWidthDeg();i!==void 0&&i>0&&(this.sceneElement.setDistanceHypothesis(this.currentSourceId,it.distanceMAt(e,i)),this.refreshDepth());return}const t=this.currentDistanceM();t!==void 0&&t>0&&this.applyApparentWidth(it.angularWidthDeg({sizeM:e,distanceM:t}))}onDistanceInput(){const e=this.numberOrUndefined(this.objectDistanceInput.value);e===void 0||e<=0||this.applyDistance(e)}applyDistance(e){if(this.selectedSourceIds.size===1){if(this.sizeLock!=="apparent"){const t=this.numberOrUndefined(this.realWidthInput.value);t!==void 0&&t>0&&this.applyApparentWidth(it.angularWidthDeg({sizeM:t,distanceM:e}))}this.sceneElement.setDistanceHypothesis(this.currentSourceId,e),this.refreshDepth()}}applySizeLock(){this.sizeLock=this.sizeLockSelect.value,this.apparentWidthInput.readOnly=this.sizeLock==="apparent",this.realWidthInput.readOnly=this.sizeLock==="real",this.objectDistanceInput.readOnly=this.sizeLock==="distance"}currentApparentWidthDeg(){const e=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId);if(e)return e.angular?.widthDeg??this.currentProjection().pxToDeg(e.bounds.width)}currentDistanceM(){return this.sceneElement.depthOf(this.currentSourceId)?.distanceM}applyApparentWidth(e){const t=this.ufoElement.sighting.timeline,i=this.ufoElement.currentTime,n=t.getInterpolatedShapeAt(i,this.currentSourceId);if(!n)return;const s=this.currentProjection(),a=s.degToPx(e),o=n.bounds.height*(n.bounds.width===0?1:a/n.bounds.width),l={x:n.bounds.x+(n.bounds.width-a)/2,y:n.bounds.y+(n.bounds.height-o)/2,width:a,height:o},c=s.ofBounds(l),h=n.kind==="oval"?{...n,bounds:l,angular:c}:{...n,bounds:l,angular:c,points:this.scalePoints(n,l)};this.commitShapes(i,[{sourceId:this.currentSourceId,shape:h}]),this.ufoElement.refresh(),this.refreshApparentSize()}scalePoints(e,t){const i=e.bounds.width===0?1:t.width/e.bounds.width,n=e.bounds.height===0?1:t.height/e.bounds.height;return e.points.map(s=>({x:s.x*i,y:s.y*n}))}refreshInstrumentOptions(){const e=this.ufoElement.sighting,t=e.event.time?.year,i=ct.availableAt(t),n=e.instrument,s=i.includes(n)?i:[...i,n],a=this.instrumentSelect.value||n.id;this.instrumentSelect.replaceChildren();for(const o of s){const l=document.createElement("option");l.value=o.id;const c=o.name[this.showerLanguage()];l.textContent=i.includes(o)?c:this.messages.instrumentOutOfPeriod.replace("{name}",c),this.instrumentSelect.appendChild(l)}this.instrumentSelect.value=s.some(o=>o.id===a)?a:n.id}static exposureText(e){return e>=1?String(Math.round(e*100)/100):`1/${Math.round(1/e)}`}statedExposureSeconds(e){const t=Ct.exposureSeconds(this.exposureInput.value),i=e.exposureRangeSeconds;if(!i)return e.exposureSeconds??t;if(t!==void 0)return Math.min(i.max,Math.max(i.min,t))}static exposureSeconds(e){const t=e.trim();if(!t)return;const i=/^(\d*\.?\d+)\s*\/\s*(\d*\.?\d+)$/.exec(t);if(i){const s=Number(i[1]),a=Number(i[2]);return a>0?s/a:void 0}const n=Number(t);return Number.isFinite(n)&&n>0?n:void 0}syncOpticsFromInstrument(){const e=this.ufoElement.sighting,t=e.instrument,i=nt(e,this.ufoElement.currentTime),n=t.frame,s=i?.fovDeg??ct.fieldOfViewDeg(t),a=n?ct.focalLengthMmFor(t,s):s;this.focalLengthInput!==this.shadow.activeElement&&(this.focalLengthInput.value=a===void 0?"":String(Math.round(a*10)/10)),this.unitFocalLength.textContent=n?this.messages.unitMillimetres:this.messages.unitDegrees,this.labelFocalLength.textContent=n?this.messages.focalLength:this.messages.fieldOfView,this.focalLengthInput.disabled=n!==void 0&&n.focalRangeMm===void 0,this.focalLengthInput.min=String(n?.focalRangeMm?.minMm??1),this.focalLengthInput.max=String(n?.focalRangeMm?.maxMm??2e3);const o=i?.fNumber??t.fNumber;this.fNumberInput!==this.shadow.activeElement&&(this.fNumberInput.value=o===void 0?"":String(o)),this.setRowVisible(this.fNumberInput,t.fNumber!==void 0),this.fNumberInput.disabled=t.fNumberRange===void 0,this.fNumberInput.min=String(t.fNumberRange?.min??.7),this.fNumberInput.max=String(t.fNumberRange?.max??64);const l=e.exposure;this.exposureInput!==this.shadow.activeElement&&(this.exposureInput.value=l===void 0?"":Ct.exposureText(l)),this.setRowVisible(this.exposureInput,t.exposureSeconds!==void 0),this.exposureInput.disabled=t.exposureRangeSeconds===void 0,this.focusDistanceInput!==this.shadow.activeElement&&(this.focusDistanceInput.value=i?.focusDistanceM===void 0?"":String(i.focusDistanceM)),this.setRowVisible(this.focusDistanceInput,n!==void 0&&t.fNumber!==void 0)}retuneFieldOfView(e){const t=this.ufoElement.sighting,i=ct.fieldOfViewDeg(e),n=ct.fieldOfViewDeg(t.instrument);for(const s of[...t.witnessTrack.allKeyframes])Math.abs(s.pose.fovDeg-i)>eA||t.witnessTrack.addKeyframe(s.t,{...s.pose,fovDeg:n})}retuneExposure(e){const t=this.ufoElement.sighting,i=t.exposureSeconds,n=t.instrument.exposureRangeSeconds;if(i===void 0||i===e.exposureSeconds||!n){t.exposureSeconds=void 0;return}t.exposureSeconds=Math.min(n.max,Math.max(n.min,i))}currentFovDeg(){const e=this.ufoElement.sighting;return nt(e,this.ufoElement.currentTime)?.fovDeg??ct.fieldOfViewDeg(e.instrument)}currentProjection(){return gn.of(this.ufoElement.sighting.instrument,this.ufoElement.canvasElement.height,this.currentFovDeg())}refreshApparentSize(){const e=this.selectedSourceIds.size===1?this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId):void 0;if(!e){this.apparentSizeOutput.textContent="",this.hasFocus(this.apparentWidthInput)||(this.apparentWidthInput.value=""),this.refreshRealSize();return}const t=e.angular?.widthDeg??this.currentProjection().pxToDeg(e.bounds.width),i=it.inMoons(t);this.hasFocus(this.apparentWidthInput)||(this.apparentWidthInput.value=this.plain(t,t<1?2:1)),this.apparentSizeOutput.textContent=this.messages.apparentSize.replace("{moons}",i.toLocaleString(void 0,{maximumFractionDigits:i<10?1:0})),this.refreshRealSize()}hasFocus(e){return this.typingIn===e}typingIn;typing(e,t){this.typingIn=e;try{t()}finally{this.typingIn=void 0}}plain(e,t){return String(Number(e.toFixed(t)))}refreshBlurDistanceBound(){const e=this.currentAppearance.blur;if(e<=0||this.selectedSourceIds.size!==1){this.blurBoundOutput.textContent="";return}const t=this.ufoElement.sighting.instrument,i=t.frame;if(!i){this.blurBoundOutput.textContent=this.messages.blurBoundNoInstrument;return}const n=nt(this.ufoElement.sighting,this.ufoElement.currentTime),s=n?.focusDistanceM;if(s!==void 0){this.blurBoundOutput.textContent=this.messages.blurBoundNotAtInfinity.replace("{focus}",this.meters(s));return}const a=(n?ct.focalLengthMmFor(t,n.fovDeg):void 0)??i.focalLengthMm,o=n?.fNumber??t.fNumber;if(o===void 0||a<=0){this.blurBoundOutput.textContent="";return}const l=this.ufoElement.canvasElement.height;if(l<=0)return;const c=2*fd*e/l*i.heightMm,h=a*a/(o*c)/1e3;this.blurBoundOutput.textContent=this.messages.blurBound.replace("{max}",this.meters(h))}refreshRealSize(){if(this.refreshDepth(),this.selectedSourceIds.size!==1){this.realSizeOutput.textContent="";return}const e=this.currentSourceId;if(this.sceneElement.sizeContradictory(e)){this.realSizeOutput.textContent=this.messages.realSizeContradiction;return}const{minM:t,maxM:i}=this.sceneElement.sizeRangeOf(e);if(t===void 0&&i===void 0){this.realSizeOutput.textContent=this.messages.realSizeUnknown;return}const n=this.numberOrUndefined(this.realWidthInput.value),s=n!==void 0&&(t!==void 0&&n<t||i!==void 0&&n>i)?this.messages.realSizeOutside:"";if(t!==void 0&&i!==void 0){const a=this.sceneElement.distanceRangeAt(e,this.ufoElement.currentTime),o=a.minM===void 0||a.maxM===void 0?"":this.messages.realDistanceHere.replace("{min}",this.meters(a.minM)).replace("{max}",this.meters(a.maxM));this.realSizeOutput.textContent=this.messages.realSizeBetween.replace("{min}",this.meters(t)).replace("{max}",this.meters(i))+o+s;return}this.realSizeOutput.textContent=(t!==void 0?this.messages.realSizeAtLeast.replace("{min}",this.meters(t)):this.messages.realSizeAtMost.replace("{max}",this.meters(i)))+s}decimal(e,t){return e.toLocaleString(void 0,{minimumFractionDigits:t,maximumFractionDigits:t})}clearDistanceHypothesis(){this.selectedSourceIds.size===1&&(this.sceneElement.setDistanceHypothesis(this.currentSourceId,void 0),this.refreshDepth())}refreshDepth(){const e=this.selectedSourceIds.size===1?this.sceneElement.depthOf(this.currentSourceId):void 0;if(!e){this.depthBasisOutput.textContent="",this.hasFocus(this.objectDistanceInput)||(this.objectDistanceInput.value=""),this.hasFocus(this.realWidthInput)||(this.realWidthInput.value="");return}const t=this.meters(e.distanceM);this.hasFocus(this.objectDistanceInput)||(this.objectDistanceInput.value=this.plain(e.distanceM,e.distanceM<10?1:0));const i=this.currentApparentWidthDeg();if(!this.hasFocus(this.realWidthInput)){const s=i===void 0||i<=0?void 0:it.sizeMAt(e.distanceM,i);this.realWidthInput.value=s===void 0?"":this.plain(s,s<1?2:s<10?1:0)}this.clearDistanceHypothesisButton.hidden=e.basis!=="hypothesis";const n={stated:this.messages.depthStated,hypothesis:this.messages.depthHypothesis,derived:this.messages.depthDerived,bounded:this.messages.depthBounded,conventional:this.messages.depthConventional}[e.basis];this.depthBasisOutput.textContent=n.replace("{m}",t)}commitShapes(e,t){const i=this.ufoElement.sighting,n=gn.of(i.instrument,it.CANVAS_HEIGHT_PX,gi.fovOf(i,e));i.timeline.addKeyframe(e,t.map(s=>{const a=gi.aimOf(i,e,s.shape.bounds),o=n.ofBounds(s.shape.bounds);return{...s,shape:a?{...s.shape,aim:a,angular:o}:{...s.shape,angular:o}}}))}meters(e){const t=e<1?2:e<10?1:0;return e.toLocaleString(void 0,{maximumFractionDigits:t})}updateShapeTitleValidity(){const e=this.selectedSourceIds.size===1&&this.shapeTitleInput.value==="";this.shapeTitleInput.classList.toggle("invalid",e),this.shapeTitleInput.setAttribute("aria-invalid",String(e))}shapeLabel(e){const t=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,e),i=this.said.read(t?.title);if(i)return i;const n=/^ufo-(\d+)$/.exec(e);return n?`${this.messages.shape} ${n[1]}`:e}addShape(){if(this.isRecording)return;const e=this.ufoElement.sighting.timeline,t=new Set([...e.sourceIds,this.currentSourceId]);let i=t.size+1;for(;t.has(`ufo-${i}`);)i++;this.currentSourceId=`ufo-${i}`,this.selectedSourceIds=new Set([this.currentSourceId]),this.applyAppearanceAtPlayhead(this.offsetDefaultBounds(e.sourceIds.length)),this.shapeTitleInput.value=this.shapeLabel(this.currentSourceId),this.updateShapeTitle()}deleteShape(){if(this.isRecording||this.ufoElement.playbackState==="playing")return;const e=this.ufoElement.sighting.timeline,t=e.sourceIds.filter(n=>this.selectedSourceIds.has(n));if(t.length===0||e.sourceIds.length-t.length<1)return;const i=t.length===1?this.messages.confirmDeleteShape.replace("{name}",this.shapeLabel(t[0])):this.messages.confirmDeleteShapes.replace("{count}",String(t.length));this.askConfirm(i,()=>this.removeShapes(t))}removeShapes(e){const t=this.ufoElement.sighting.timeline;for(const i of e)t.removeSource(i);this.currentSourceId=t.sourceIds[0],this.selectedSourceIds=new Set([this.currentSourceId]),this.refreshSourceList(),this.ufoElement.refresh()}askConfirm(e,t){this.answerConfirm(!1),this.confirmMessage.textContent=e,this.confirmOverlay.hidden=!1,this.confirmAcceptButton.focus(),this.confirmAnswer=t}answerConfirm(e){const t=this.confirmAnswer;this.confirmAnswer=void 0,this.confirmOverlay.hidden=!0,e&&t?.()}offsetDefaultBounds(e){const t=this.defaultBounds(),i=24;return{...t,x:t.x+e*i,y:t.y+e*i}}refreshSourceList(){const e=this.ufoElement.sighting.timeline,t=[...new Set([...e.sourceIds,this.currentSourceId])];this.sourceSelect.innerHTML="";for(const i of t){const n=document.createElement("option");n.value=i,n.textContent=this.shapeLabel(i),this.sourceSelect.appendChild(n)}this.sourceSelect.value=this.currentSourceId}decorLabel(e){const t=this.said.read(e.title);if(t)return t;const n=this.ufoElement.sighting.decor.filter(a=>a.kind===e.kind).indexOf(e)+1;return`${this.decorKindSelect.querySelector(`option[value="${e.kind}"]`)?.textContent??e.kind} ${n}`}addDecor(e=this.decorKindSelect.value){const t=this.ufoElement.sighting,n={id:`decor-${t.decor.length+1}`,kind:e,title:this.nextDecorLabel(e),eastM:8*t.decor.length,northM:15,headingDeg:0,lit:!1,...e==="aircraft"?this.defaultAircraft():{},...e==="building"?{floors:ua}:{},windows:ug(e)};t.decor=[...t.decor,n],this.currentDecorId=n.id,this.refreshDecorList(),this.ufoElement.refresh()}defaultAircraft(){const e=2*hd,t=Math.round(e/iA*1e3);return{lights:Xc.byId("airliner")?.create(),track:[{t:0,eastM:-hd,northM:1e3,altitudeM:1500,headingDeg:90},{t,eastM:hd,northM:1e3,altitudeM:1500,headingDeg:90}]}}nextDecorLabel(e){const t=this.ufoElement.sighting.decor.filter(n=>n.kind===e).length;return`${this.decorKindSelect.querySelector(`option[value="${e}"]`)?.textContent??e} ${t+1}`}deleteDecor(){if(this.currentDecorId===void 0)return;const e=this.ufoElement.sighting;e.decor=e.decor.filter(t=>t.id!==this.currentDecorId),this.currentDecorId=e.decor[0]?.id,this.refreshDecorList(),this.ufoElement.refresh()}selectDecor(e){this.currentDecorId=e,this.decorSelect.value=e,this.syncDecorFields()}updateDecor(){if(this.currentDecorId===void 0)return;const e=this.ufoElement.sighting,t=this.wrapDegrees(Number(this.decorHeadingInput.value),this.decorHeadingInput)??0,i=this.decorWitnessSideSelect.value;e.decor=e.decor.map(n=>{if(n.id!==this.currentDecorId)return n;const s=ra(n.kind)&&i!==""?i:void 0,a=Number(this.decorEastInput.value),o=Number(this.decorNorthInput.value),l=Number(this.decorAltitudeInput.value),c=n.track??(l!==0?[]:void 0);if(c){const h=this.ufoElement.currentTime,d={t:h,eastM:a,northM:o,altitudeM:l,headingDeg:t},u=c.filter(f=>f.t!==h);return{...n,title:this.said.write(n.title,this.decorTitleInput.value,this.writingLanguage),color:this.statedDecorColor(n),track:[...u,d].sort((f,p)=>f.t-p.t),sightingUrl:this.stringOrUndefined(this.decorSightingUrlInput.value),witnessSide:s,sizeM:this.statedDecorSize(),model:this.statedDecorModel(),floors:n.kind==="building"?Number(this.decorFloorsInput.value):void 0,occupiedFloor:n.kind==="building"?Number(this.decorOccupiedFloorInput.value):void 0}}return{...n,title:this.said.write(void 0,this.decorTitleInput.value,this.writingLanguage),color:this.statedDecorColor(n),eastM:a,northM:o,headingDeg:t,sightingUrl:this.stringOrUndefined(this.decorSightingUrlInput.value),witnessSide:s,sizeM:this.statedDecorSize(),model:this.statedDecorModel(),floors:n.kind==="building"?Number(this.decorFloorsInput.value):void 0,occupiedFloor:n.kind==="building"?Number(this.decorOccupiedFloorInput.value):void 0}}),this.decorSelect.options[this.decorSelect.selectedIndex].textContent=this.decorLabel(e.decor.find(n=>n.id===this.currentDecorId)),this.syncDecorVisibility(),this.updateDecorTitleValidity(),this.ufoElement.refresh()}syncDecorSizeFields(e){const t=e?li.naturalSize(e.kind,e.floors):void 0,i=[[this.decorWidthInput,e?.sizeM?.widthM,t?.widthM],[this.decorLengthInput,e?.sizeM?.lengthM,t?.lengthM],[this.decorHeightInput,e?.sizeM?.heightM,t?.heightM]];for(const[n,s,a]of i)n.value=s===void 0?"":String(this.roundedMeters(s)),n.placeholder=a===void 0?"":String(this.roundedMeters(a))}syncDecorModelFields(e){this.refreshDecorModelOptions(e),this.decorModelSelect.value=e?.model?.id??"",this.decorModelUrlInput.value=e?.model?.url??"",this.decorModelTitleInput.value=e?.model?.credit?.title??"",this.decorModelAuthorInput.value=e?.model?.credit?.author??"",this.decorModelLicenseInput.value=e?.model?.credit?.license??"",this.decorModelSourceInput.value=e?.model?.credit?.sourceUrl??"",this.decorModelAdvanced.open=e?.model?.url!==void 0}async refreshDecorModelOptions(e){const t=e??this.ufoElement.sighting.decor.find(a=>a.id===this.currentDecorId),i=t?await this.decorModelProvider.entries(t.kind).catch(()=>[]):[],n=t?.model?.id??"",s=document.createElement("option");s.value="",s.textContent=this.messages.decorModelNone,this.decorModelSelect.replaceChildren(s,...i.map(a=>{const o=document.createElement("option");return o.value=a.id,o.textContent=a.name,o.title=`${a.credit.title}${a.credit.author?` — ${a.credit.author}`:""} (${a.credit.license})`,o})),this.decorModelSelect.value=n}updateDecorModelChoice(){const e=this.decorModelSelect.value;(async()=>{const t=e?await this.decorModelProvider.entry(e).catch(()=>{}):void 0,i=this.ufoElement.sighting.decor.find(n=>n.id===this.currentDecorId);if(t?.sizeM&&i&&!i.sizeM){const n=[[this.decorWidthInput,t.sizeM.widthM],[this.decorLengthInput,t.sizeM.lengthM],[this.decorHeightInput,t.sizeM.heightM]];for(const[s,a]of n)a!==void 0&&(s.value=String(this.roundedMeters(a)))}this.updateDecor()})()}roundedMeters(e){return Math.round(e*100)/100}positiveMeters(e){const t=Number(e);return e.trim()===""||!Number.isFinite(t)||t<=0?void 0:t}statedDecorColor(e){const t=this.decorColorInput.value;return t==="#808080"&&e.color===void 0?void 0:t}statedDecorSize(){const e=this.positiveMeters(this.decorWidthInput.value),t=this.positiveMeters(this.decorLengthInput.value),i=this.positiveMeters(this.decorHeightInput.value);return e===void 0&&t===void 0&&i===void 0?void 0:{widthM:e,lengthM:t,heightM:i}}statedDecorModel(){const e=this.stringOrUndefined(this.decorModelUrlInput.value);if(e){const i=this.stringOrUndefined(this.decorModelTitleInput.value),n=this.stringOrUndefined(this.decorModelLicenseInput.value);return{url:e,credit:i!==void 0&&n!==void 0?{title:i,license:n,author:this.stringOrUndefined(this.decorModelAuthorInput.value),sourceUrl:this.stringOrUndefined(this.decorModelSourceInput.value)}:void 0}}const t=this.stringOrUndefined(this.decorModelSelect.value);return t===void 0?void 0:{id:t}}addMilestone(){const e=Math.round(this.ufoElement.currentTime),t=this.ufoElement.sighting;t.milestones.find(n=>n.t===e)||(t.milestones=Ta([...t.milestones,{t:e,label:this.nextMilestoneLabel()}])),this.currentMilestoneT=e,this.refreshMilestoneList(),this.ufoElement.refresh()}nextMilestoneLabel(){const e=new Set(this.ufoElement.sighting.milestones.map(t=>t.label));for(let t=0;t<26;t++){const i=String.fromCharCode(65+t);if(!e.has(i))return i}return String(this.ufoElement.sighting.milestones.length+1)}deleteMilestone(){const e=this.currentMilestoneT;if(e===void 0)return;const t=this.ufoElement.sighting,i=t.milestones.find(n=>n.t===e);i&&this.askConfirm(this.messages.confirmDeleteMilestone.replace("{name}",this.said.read(i.label)??""),()=>{t.milestones=t.milestones.filter(n=>n.t!==e),this.currentMilestoneT=t.milestones[0]?.t,this.refreshMilestoneList(),this.ufoElement.refresh()})}selectMilestone(e){this.currentMilestoneT=e,this.syncMilestoneFields(),this.ufoElement.currentTime=e}updateMilestone(){const e=this.currentMilestoneT;if(e===void 0)return;const t=this.ufoElement.sighting;t.milestones=t.milestones.map(i=>i.t===e?{...i,label:this.said.write(i.label,this.milestoneLabelInput.value,this.writingLanguage)??"",note:this.said.write(i.note,this.milestoneNoteInput.value,this.writingLanguage)}:i),this.refreshMilestoneList(),this.ufoElement.refresh()}refreshMilestoneList(){const e=Ta(this.ufoElement.sighting.milestones);e.some(t=>t.t===this.currentMilestoneT)||(this.currentMilestoneT=e[0]?.t),this.milestoneSelect.replaceChildren(...e.map(t=>{const i=document.createElement("option");return i.value=String(t.t),i.textContent=`${this.said.read(t.label)??""} — ${this.formatSeconds(t.t)}`,i.title=this.said.read(t.note)??"",i})),this.currentMilestoneT!==void 0&&(this.milestoneSelect.value=String(this.currentMilestoneT)),this.syncMilestoneFields()}formatSeconds(e){return`${(e/1e3).toFixed(1)} s`}syncMilestoneFields(){const e=this.ufoElement.sighting.milestones.find(i=>i.t===this.currentMilestoneT),t=e!==void 0;for(const i of[this.milestoneSelect,this.milestoneLabelInput,this.milestoneNoteInput,this.deleteMilestoneButton])i.disabled=!t,this.setRowVisible(i,t);this.milestoneLabelInput.value=this.said.read(e?.label)??"",this.milestoneNoteInput.value=this.said.read(e?.note)??""}updateDecorTitleValidity(){const e=this.currentDecorId!==void 0&&this.decorTitleInput.value==="";this.decorTitleInput.classList.toggle("invalid",e),this.decorTitleInput.setAttribute("aria-invalid",String(e))}updateDecorWindows(){if(this.currentDecorId===void 0)return;const e=this.ufoElement.sighting;e.decor=e.decor.map(t=>{if(t.id!==this.currentDecorId)return t;const i={};for(const n of _r){const s=this.decorWindowInputs[n];if(s.value==="")continue;const a=md(t.kind,n)?0:pd,o=Math.max(a,Math.min(100,Number(s.value)));i[n]=o,String(o)!==s.value&&(s.value=String(o))}return{...t,windows:i}}),this.ufoElement.refresh()}updateDecorLit(){if(this.currentDecorId===void 0||this.ufoElement.playbackState==="playing")return;const e=this.ufoElement.sighting,t=this.ufoElement.currentTime,i=this.decorLitInput.checked;e.decor=e.decor.map(n=>{if(n.id!==this.currentDecorId)return n;const s=[...(n.litKeyframes??[]).filter(a=>a.t!==t),{t,lit:i}].sort((a,o)=>a.t-o.t);return{...n,litKeyframes:s}}),this.ufoElement.refresh()}refreshDecorList(){const e=this.ufoElement.sighting.decor;this.decorSelect.innerHTML="";for(const t of e){const i=document.createElement("option");i.value=t.id,i.textContent=this.decorLabel(t),this.decorSelect.appendChild(i)}this.currentDecorId!==void 0&&(this.decorSelect.value=this.currentDecorId),this.syncDecorFields()}syncDecorFields(){const e=this.ufoElement.sighting.decor.find(i=>i.id===this.currentDecorId),t=e!==void 0;this.deleteDecorButton.disabled=!t;for(const i of[this.decorSelect,this.decorTitleInput,this.decorEastInput,this.decorNorthInput,this.decorHeadingInput,this.decorLitInput,this.decorSightingUrlInput,this.decorWidthInput,this.decorLengthInput,this.decorHeightInput,this.decorModelSelect,this.decorModelUrlInput,this.decorModelTitleInput,this.decorModelAuthorInput,this.decorModelLicenseInput,this.decorModelSourceInput,this.decorFloorsInput,this.decorOccupiedFloorInput,this.decorWitnessSideSelect,this.decorLightRigSelect,this.decorAltitudeInput,this.lookAtDecorButton])i.disabled=!t;this.decorTitleInput.value=this.said.read(e?.title)??"",this.decorColorInput.value=e?.color??"#808080",this.showDecorPlacement(e),this.decorLitInput.checked=e?sc(e,this.ufoElement.currentTime):!1,this.refreshDecorLightRigOptions(e),this.decorSightingUrlInput.value=e?.sightingUrl??"",this.syncDecorSizeFields(e),this.syncDecorModelFields(e),this.decorFloorsInput.value=String(e?.floors??ua),this.decorOccupiedFloorInput.value=String(e?.occupiedFloor??0),this.decorWitnessSideSelect.value=e?.witnessSide??"";for(const i of _r){const n=e?.windows?.[i];this.decorWindowInputs[i].value=n===void 0?"":String(n)}this.syncDecorVisibility(),this.updateDecorTitleValidity()}setRowVisible(e,t){const i=e.closest("label")??e;i.hidden=!t}syncDecorVisibility(){const e=this.ufoElement.sighting.decor.find(c=>c.id===this.currentDecorId),t=e!==void 0,i=e?.kind;this.setRowVisible(this.decorSelect,t),this.setRowVisible(this.deleteDecorButton,t),this.setRowVisible(this.decorTitleInput,t),this.setRowVisible(this.decorEastInput,t),this.setRowVisible(this.decorNorthInput,t),this.setRowVisible(this.decorAltitudeInput,t),this.setRowVisible(this.decorHeadingInput,t),this.setRowVisible(this.decorWidthInput,t),this.setRowVisible(this.decorLengthInput,t),this.setRowVisible(this.decorHeightInput,t),this.setRowVisible(this.decorModelSelect,t),this.decorModelAdvanced.hidden=!t,this.setRowVisible(this.decorLitInput,t&&e?.kind!=="aircraft");const n=t&&i!==void 0&&Yu(i);this.setRowVisible(this.labelDecorWindows,n);const s=i!==void 0?qu(i):[];for(const c of _r)this.decorWindowInputs[c].disabled=!t,this.decorWindowInputs[c].min=String(i!==void 0&&md(i,c)?0:pd),this.setRowVisible(this.decorWindowInputs[c],n&&s.includes(c));const a=t&&i!==void 0&&ra(i);this.setRowVisible(this.decorWitnessSideSelect,a);const o=i!==void 0?Bv(i):[];for(const c of _r)this.optionWitnessSide[c].hidden=!o.includes(c);const l=t&&i==="building";this.setRowVisible(this.decorFloorsInput,l),this.setRowVisible(this.decorOccupiedFloorInput,l),this.decorOccupiedFloorInput.max=String(e?.floors??ua)}showDecorPlacement(e){const t=e?_a(e,this.ufoElement.currentTime):void 0,i=[[this.decorEastInput,t?.eastM??0],[this.decorNorthInput,t?.northM??0],[this.decorAltitudeInput,t?.altitudeM??0],[this.decorHeadingInput,t?.headingDeg??0]];for(const[n,s]of i)this.shadow.activeElement!==n&&(n.value=String(this.rounded(s)))}syncDecorPlacementFromTimeline(){this.ufoElement.playbackState!=="playing"&&this.showDecorPlacement(this.ufoElement.sighting.decor.find(e=>e.id===this.currentDecorId))}showNextMeteor(){const e=this.sceneElement.meteorByRank(this.meteorRank++);e&&(this.ufoElement.playbackState==="playing"&&this.ufoElement.togglePlayPause(),this.ufoElement.currentTime=e.t,this.headingInput.value=String(Math.round(e.azimuthDeg*10)/10),this.pitchInput.value=String(Math.round(e.altitudeDeg*10)/10),this.updateObserver())}resetMeteorRankIfSkyChanged(){const e=this.sceneElement.meteorByRank(0),t=e?`${e.t}`:"";t!==this.meteorRankFor&&(this.meteorRankFor=t,this.meteorRank=0)}meteorRankFor;skyCandidatesKey;meteorRank=0;showerLanguage(){return fa(Ns.preferencesFor(this),["en","fr"])}get said(){return this.saidTexts??=new rs(Ns.preferencesFor(this))}saidTexts;tagNames=new vd({});get writingLanguage(){return this.showerLanguage()}refreshSkyCandidates(){this.resetMeteorRankIfSkyChanged();const e=this.ufoElement.sighting,t=e.event.place?.[0],i=e.event.time,n=t&&t.lat!==void 0&&t.lng!==void 0&&i?.year!==void 0?zn(i,t.lng,e.event.utcOffsetHours):void 0,s=JSON.stringify([n?.getTime(),t?.lat,t?.lng,this.groundElevationM,e.instrumentId,e.exposureSeconds,kt(e,0),this.messages.skyLine,this.meteorRankFor,this.sceneElement.satelliteState.status,this.satelliteSpanMs()]);if(s===this.skyCandidatesKey)return;if(this.skyCandidatesKey=s,!n||!t||t.lat===void 0||t.lng===void 0){this.showMeteorButton.hidden=!0,this.showCometButton.hidden=!0,this.showNovaButton.hidden=!0,this.showSatelliteButton.hidden=!0,this.skyCandidatesOutput.textContent=this.messages.skyLine.replace("{parts}",this.messages.skyUnknown);return}const a={lat:t.lat,lng:t.lng,elevationM:this.groundElevationM??0},o=[this.starsClause(n,a),this.showerClause(n,a),this.cometClause(n,a),this.novaClause(n,a),this.satelliteClause(n,a),this.opticsClause(n,a),this.rainbowClause(n,a),this.glowClause(n,a)].filter(l=>l!==void 0);this.skyCandidatesOutput.textContent=this.messages.skyLine.replace("{parts}",o.join(" · "))}instrumentGain(){const e=this.ufoElement.sighting;return Ei.gainFor(e.instrument,{fNumber:nt(e,0)?.fNumber,fieldOfViewDeg:gi.fovOf(e,0),exposureSeconds:e.exposure})}starsClause(e,t){const i=Ui("Sun",e,t).altitudeDeg,n=this.instrumentGain(),s=hr(i,n),a=c=>c.toLocaleString(void 0,{maximumFractionDigits:1});if(s<jT)return this.messages.skyStarsNone;const o=this.ufoElement.sighting.instrument,l=Math.abs(n)<.1?this.messages.skyStarsEye.replace("{limit}",a(s)):(n>0?this.messages.skyStarsDeeper:this.messages.skyStarsShallower).replace("{limit}",a(s)).replace("{device}",o.name[this.showerLanguage()]).replace("{gain}",a(Math.abs(n))).replace("{eye}",a(hr(i)));return s<=Mo?l:l+this.messages.skyStarsCatalogue.replace("{catalogue}",a(Mo))}showerClause(e,t){const i=Lt.observedRatePerHour(Lt.apexPosition(e,t).altitudeDeg).toLocaleString(void 0,{maximumFractionDigits:1}),n=Sa.activeAt(e);if(n.length===0)return this.showMeteorButton.hidden=!this.sceneElement.meteorByRank(0),this.messages.skyNothingActive.replace("{sporadic}",i);const s=n.map(a=>{const o=Sa.radiantPosition(a.shower,e,t);return{entry:a,position:o,rate:Sa.observedRatePerHour(a.zhr,o.altitudeDeg,a.shower.populationIndex)}}).sort((a,o)=>o.rate-a.rate)[0];return s.rate<=0?(this.showMeteorButton.hidden=!this.sceneElement.meteorByRank(0),this.messages.skyShowerBelowHorizon.replace("{name}",s.entry.shower.name[this.showerLanguage()])):(this.showMeteorButton.hidden=!this.sceneElement.meteorByRank(0),this.messages.skyShowerActive.replace("{name}",s.entry.shower.name[this.showerLanguage()]).replace("{altitude}",String(Math.round(s.position.altitudeDeg))).replace("{bearing}",dn.towards(s.position.azimuthDeg,this.showerLanguage())).replace("{rate}",s.rate.toLocaleString(void 0,{maximumFractionDigits:s.rate<10?1:0})).replace("{sporadic}",i))}cometClause(e,t){const i=Ql.brightestAt(e,t);if(!i||i.magnitude>La){this.showCometButton.hidden=!0;return}return this.showCometButton.hidden=i.position.altitudeDeg<=0,this.cometText(i)}novaClause(e,t){const i=Ac.brightestAt(e,t);if(!i||i.magnitude>La){this.showNovaButton.hidden=!0;return}return this.showNovaButton.hidden=i.position.altitudeDeg<=0,this.novaText(i)}novaText(e){return(e.position.altitudeDeg<=0?this.messages.skyNovaBelowHorizon:this.messages.skyNova).replace("{name}",e.outburst.name[this.showerLanguage()]).replace("{magnitude}",e.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{altitude}",String(Math.round(e.position.altitudeDeg))).replace("{bearing}",dn.towards(e.position.azimuthDeg,this.showerLanguage()))}satelliteClause(e,t){const i=Pn.visibilityAt(e,t),n=this.realSatelliteClause(i.lowOrbitLit||i.sunAltitudeDeg>=0);if(n!==void 0)return n;if(this.showSatelliteButton.hidden=!0,!i.anythingInOrbit)return i.sunAltitudeDeg<0?this.messages.skySatellitesNotYet:void 0;const s=hr(i.sunAltitudeDeg,this.instrumentGain()),a=i.classes.filter(d=>d.peakMagnitude<=s),o=this.listed(a.map(d=>d.name[this.showerLanguage()]));if(i.sunAltitudeDeg>=0)return a.length===0?void 0:(a.length===1?this.messages.skySatellitesDaylightOne:this.messages.skySatellitesDaylight).replace("{eras}",o);const l=Math.round(i.shadowHeightKm).toLocaleString(),c=(i.trackedObjects??0).toLocaleString(),h=d=>d.replace("{height}",l).replace("{count}",c);return i.lowOrbitLit?a.length===0?h(this.messages.skySatellitesLit):h(this.messages.skySatellitesLitWith).replace("{eras}",o):h(this.messages.skySatellitesShadowed)}realSatelliteClause(e){const t=this.sceneElement.satelliteState;if(t.status!=="ready")return;if(t.coverage?.every(h=>h.status!=="covered"))return this.showSatelliteButton.hidden=!0,t.coverage.some(h=>h.status==="gap")?this.messages.skySatelliteElementsGap:void 0;const i=this.visibleSatellitePasses(),n=i.filter(h=>this.passTimelineMs(h)<=this.ufoElement.seekableDuration);if(this.showSatelliteButton.hidden=n.length===0,i.length===0)return e?this.messages.skySatellitePassesNone:void 0;const a=i[0].peak,l=(i.length===1?this.messages.skySatellitePassesOne:this.messages.skySatellitePasses).replace("{count}",String(i.length)).replace("{name}",a.object.name).replace("{magnitude}",a.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{altitude}",String(Math.round(a.altitudeDeg))).replace("{bearing}",dn.towards(a.azimuthDeg,this.showerLanguage())).replace("{time}",this.witnessClock(a.date)),c=this.starlinkTrain(i);return c?`${l}, ${c}`:l}visibleSatellitePasses(){const e=this.instrumentGain(),t=this.observerAtStart();return this.sceneElement.satellitePassesDuring(this.satelliteSpanMs()).filter(i=>{const n=i.peak.magnitude;if(n===void 0)return!1;const s=Ui("Sun",i.peak.date,t);return n<=hr(s.altitudeDeg,e)}).sort((i,n)=>i.peak.magnitude-n.peak.magnitude)}starlinkTrain(e){const t=new Map;for(const a of e){const{kind:o,launch:l}=a.peak.object;o!=="starlink"||!l||(a.peak.date.getTime()-Date.parse(`${l}T00:00:00Z`))/864e5>60||t.set(l,(t.get(l)??0)+1)}const[i,n]=[...t.entries()].sort((a,o)=>o[1]-a[1])[0]??[];if(!i||!n||n<3)return;const s=new Date(`${i}T00:00:00Z`).toLocaleDateString(this.showerLanguage(),{day:"numeric",month:"long",year:"numeric",timeZone:"UTC"});return this.messages.skySatelliteTrain.replace("{count}",String(n)).replace("{date}",s)}satelliteSpanMs(){const e=(this.ufoElement.sighting.event.durationSeconds??0)*1e3;return Math.max(e,this.ufoElement.seekableDuration)}observerAtStart(){const e=this.ufoElement.sighting.event.place?.[0],t=nt(this.ufoElement.sighting,0);return{lat:t?.lat??e?.lat??0,lng:t?.lng??e?.lng??0,elevationM:this.groundElevationM??0}}passTimelineMs(e){const t=this.ufoElement.sighting,i=zn(t.event.time??{},this.observerAtStart().lng,t.event.utcOffsetHours);return i?e.peak.date.getTime()-i.getTime():1/0}witnessClock(e){const i=this.ufoElement.sighting.event.utcOffsetHours??Math.round(this.observerAtStart().lng/15);return new Date(e.getTime()+i*36e5).toLocaleTimeString(this.showerLanguage(),{hour:"2-digit",minute:"2-digit",second:"2-digit",timeZone:"UTC"})}showNextSatellite(){const e=this.visibleSatellitePasses().filter(n=>this.passTimelineMs(n)<=this.ufoElement.seekableDuration);if(e.length===0)return;const t=e.map(n=>`${n.object.norad}@${n.peak.date.getTime()}`).join();t!==this.satelliteRankFor&&(this.satelliteRankFor=t,this.satelliteRank=0);const i=e[this.satelliteRank++%e.length];this.ufoElement.playbackState==="playing"&&this.ufoElement.togglePlayPause(),this.ufoElement.currentTime=this.passTimelineMs(i),this.headingInput.value=String(Math.round(i.peak.azimuthDeg*10)/10),this.pitchInput.value=String(Math.round(i.peak.altitudeDeg*10)/10),this.updateObserver()}satelliteRankFor;satelliteRank=0;opticsClause(e,t){const i=kt(this.ufoElement.sighting,0),n=Ui("Sun",e,t),s=Ui("Moon",e,t),a=et.deckLitUntilDeg(et.DECK_HEIGHT_M),o=n.altitudeDeg>-a,l=o?n:s;if(l.altitudeDeg<=-a)return;const c=i.highCloudCover;if(c===void 0||c<=0)return this.messages.skyOpticsNoIce;if(et.strength(c,i.lowerCloudCover??i.cloudCover,l.altitudeDeg,a)<=0)return this.messages.skyOpticsHidden;const h=o?this.messages.skyOpticsSun:this.messages.skyOpticsMoon,d=this.listed(et.formsAt(l.altitudeDeg,a).map(f=>this.opticsFormName(f))),u=i.iceCrystalAlignment??.65;return this.messages.skyOpticsPossible.replace("{forms}",d).replace("{source}",h)+this.messages.skyOpticsAlignment.replace("{alignment}",String(Math.round(u*100)))}rainbowClause(e,t){const i=kt(this.ufoElement.sighting,0);if(i.precipitationType!=="rain"||i.precipitationIntensity<=0)return;const n=Ui("Sun",e,t),s=Ui("Moon",e,t),a=n.altitudeDeg>0,o=a?n:s;if(o.altitudeDeg<=0)return this.messages.skyBowNoSource;const l=i.lowerCloudCover??i.cloudCover;if(fi.strength(i.precipitationIntensity,l,o.altitudeDeg)<=0)return this.messages.skyBowHidden;const c=fi.formsAt(o.altitudeDeg);if(c.length===0)return this.messages.skyBowSourceTooHigh.replace("{altitude}",String(Math.round(o.altitudeDeg))).replace("{radius}",String(Math.round(fi.primary().radiusDeg)));const h=this.listed(c.map(u=>this.bowFormName(u)));if(a)return this.messages.skyBowPossible.replace("{forms}",h);const d=Math.round(_c(e).illuminatedFraction*100);return this.messages.skyBowMoon.replace("{forms}",h).replace("{lit}",String(d))}glowClause(e,t){if(Ui("Sun",e,t).altitudeDeg>rA)return;const n=this.glows.assess(e,t),s=this.showerLanguage(),a=[];if(n.milkyWay&&a.push(this.messages.skyGlowBand.replace("{contrast}",this.decimal(n.milkyWay.contrast,1)).replace("{altitude}",String(Math.round(n.milkyWay.altitudeDeg))).replace("{bearing}",dn.towards(n.milkyWay.azimuthDeg,s))),n.zodiacal){const h=n.zodiacal.sunSeparationDeg<=rt.CONE_SEPARATION_DEG;a.push((h?this.messages.skyGlowCone:this.messages.skyGlowZodiacalBand).replace("{contrast}",this.decimal(n.zodiacal.contrast,1)).replace("{altitude}",String(Math.round(n.zodiacal.altitudeDeg))).replace("{bearing}",dn.towards(n.zodiacal.azimuthDeg,s)).replace("{elongation}",String(Math.round(n.zodiacal.sunSeparationDeg))))}if(a.length>0)return this.listed(a);const o=this.decimal(n.darkestSkyMagPerArcsec2,1),l=Ui("Moon",e,t),c=n.darkestSkyMagPerArcsec2<aA;if(c&&l.altitudeDeg>0){const h=Math.round(_c(e).illuminatedFraction*100);return this.messages.skyGlowMoon.replace("{lit}",String(h)).replace("{sky}",o)}return c?this.messages.skyGlowTwilight.replace("{sky}",o):this.messages.skyGlowNothingUp.replace("{sky}",o)}glows=new rt;bowFormName(e){return(e.id==="primary"?this.messages.skyBowPrimary:this.messages.skyBowSecondary).replace("{radius}",String(Math.round(e.radiusDeg))).replace("{top}",String(Math.round(e.topAltitudeDeg)))}opticsFormName(e){const t=i=>String(Math.round(i??0));switch(e.id){case"halo22":return this.messages.skyOpticsHalo22.replace("{angle}",t(e.angleDeg));case"halo46":return this.messages.skyOpticsHalo46.replace("{angle}",t(e.angleDeg));case"parhelia":return this.messages.skyOpticsParhelia.replace("{angle}",t(e.angleDeg));case"tangentArc":return this.messages.skyOpticsTangentArc;case"parhelicCircle":return this.messages.skyOpticsParhelicCircle;case"circumzenithal":return this.messages.skyOpticsCircumzenithal.replace("{angle}",t(e.angleDeg));case"circumhorizontal":return this.messages.skyOpticsCircumhorizontal;case"pillar":return this.messages.skyOpticsPillar}}listed(e){return new Intl.ListFormat(this.showerLanguage(),{style:"long",type:"conjunction"}).format(e)}cometText(e){const t=e.apparition.name[this.showerLanguage()],i=e.magnitude.toLocaleString(void 0,{maximumFractionDigits:1});return e.position.altitudeDeg<=0?this.messages.skyCometBelowHorizon.replace("{name}",t).replace("{magnitude}",i):(e.elongationDeg<Ql.TWILIGHT_ELONGATION_DEG?this.messages.skyCometInDaylight:e.tailLengthDeg===void 0?this.messages.skyCometNoTail:this.messages.skyComet).replace("{name}",t).replace("{magnitude}",i).replace("{altitude}",String(Math.round(e.position.altitudeDeg))).replace("{bearing}",dn.towards(e.position.azimuthDeg,this.showerLanguage())).replace("{tail}",String(Math.round(e.tailLengthDeg??0))).replace("{elongation}",String(Math.round(e.elongationDeg)))}lookAtComet(){const e=this.ufoElement.sighting,t=e.event.place?.[0],i=e.event.time;if(!t||t.lat===void 0||t.lng===void 0||i?.year===void 0)return;const n=zn(i,t.lng,e.event.utcOffsetHours);if(!n)return;const s=Ql.brightestAt(n,{lat:t.lat,lng:t.lng,elevationM:this.groundElevationM??0});s&&(this.headingInput.value=String(this.rounded(s.position.azimuthDeg)),this.pitchInput.value=String(this.rounded(s.position.altitudeDeg)),this.updateObserver())}lookAtNova(){const e=this.ufoElement.sighting,t=e.event.place?.[0],i=e.event.time;if(!t||t.lat===void 0||t.lng===void 0||i?.year===void 0)return;const n=zn(i,t.lng,e.event.utcOffsetHours);if(!n)return;const s=Ac.brightestAt(n,{lat:t.lat,lng:t.lng,elevationM:this.groundElevationM??0});s&&(this.headingInput.value=String(this.rounded(s.position.azimuthDeg)),this.pitchInput.value=String(this.rounded(s.position.altitudeDeg)),this.updateObserver())}refreshHeadingPoint(){const e=this.numberOrUndefined(this.headingInput.value);this.headingUnit.textContent=e===void 0?"°":`° (${dn.point(e,this.showerLanguage())})`}rounded(e){return Math.round(e*10)/10}lookAtDecor(){const e=this.ufoElement.sighting.decor.find(l=>l.id===this.currentDecorId);if(!e)return;const{eastM:t,northM:i,altitudeM:n}=_a(e,this.ufoElement.currentTime),s=Math.hypot(t,i);if(s===0&&n===0)return;const a=Math.atan2(t,i)*180/Math.PI,o=Math.atan2(n-tA,s)*180/Math.PI;this.headingInput.value=String(Math.round(a*10)/10),this.pitchInput.value=String(Math.round(o*10)/10),this.updateObserver()}refreshDecorLightRigOptions(e){const t=e?Xc.forKind(e.kind):[],i=document.createElement("option");i.value="",i.textContent=this.messages.decorLightsNone,this.decorLightRigSelect.replaceChildren(i,...t.map(s=>{const a=document.createElement("option");return a.value=s.id,a.textContent=s.name,a}));const n=e?.lights?.map(s=>s.id).join()??"";this.decorLightRigSelect.value=t.find(s=>s.create().map(a=>a.id).join()===n)?.id??""}updateDecorLightRig(){const e=this.ufoElement.sighting,t=e.decor.find(n=>n.id===this.currentDecorId);if(!t)return;const i=Xc.byId(this.decorLightRigSelect.value);e.decor=e.decor.map(n=>n.id===t.id?{...n,lights:i?i.create():void 0}:n),this.ufoElement.refresh(),this.dispatchEvent(new CustomEvent("sightingchange"))}syncDecorLitFromTimeline(){if(this.ufoElement.playbackState==="playing"||this.shadow.activeElement===this.decorLitInput)return;const e=this.ufoElement.sighting.decor.find(t=>t.id===this.currentDecorId);e&&(this.decorLitInput.checked=sc(e,this.ufoElement.currentTime))}updatePresetButtons(){for(const e of ng)this.presetButtons[e]?.setAttribute("aria-pressed",String(e===this.currentAppearance.presetId))}get samplingRate(){return Number(this.samplingRateInput.value)}buildPrototype(e=this.defaultBounds()){return zf(e,this.currentAppearance)}defaultBounds(){const e=this.ufoElement.canvasElement;return{x:e.width/2-ea.width/2,y:e.height/2-ea.height/2,width:ea.width,height:ea.height}}toggleRecording(){this.endDrag();const e=this.ufoElement.canvasElement;this.isRecording?(this.recorder?.stop(),this.isRecording=!1,this.setRecordButtonLabel(!1),this.setCanvasCursor(void 0),e.style.touchAction="",this.sourceSelect.disabled=!1,this.addShapeButton.disabled=!1,this.ufoElement.refresh(),this.refreshSourceList()):(this.recorder=new bT(this.ufoElement.sighting.timeline,new wT(this.samplingRate)),this.recorder.start(this.currentSourceId,this.buildPrototype()),this.isRecording=!0,this.setRecordButtonLabel(!0),this.setCanvasCursor("record"),e.style.touchAction="none",this.sourceSelect.disabled=!0,this.addShapeButton.disabled=!0,this.deleteShapeButton.disabled=!0)}setRecordButtonLabel(e){this.recordButton.textContent=e?"⏹":"⏺";const t=e?this.messages.stop:this.messages.record;this.recordButton.title=t,this.recordButton.setAttribute("aria-label",t)}async loadLocaleMessages(){const e=fa(Ns.preferencesFor(this),bd);e!=="en"&&(this.tagNames=new vd(await o2(e)),this.showTags(),this.applyMessages(await a2(e)))}showTags(){this.tagsInput.value=this.ufoElement.sighting.event.tags?.map(e=>this.tagNames.name(e)).join(", ")??""}applyMessages(e){this.currentSourceId===Wl&&this.shapeTitleInput.value===`${this.messages.shape} 1`?(this.messages=e,this.shapeTitleInput.value=`${this.messages.shape} 1`,this.updateShapeTitle()):this.messages=e,this.presetButtons.oval.textContent=e.oval,this.presetButtons.polygon.textContent=e.polygon,this.contextAddVertexButton.textContent=e.addVertex,this.contextDeleteVertexButton.textContent=e.deleteVertex,this.labelColor.textContent=e.color,this.labelTransparency.textContent=e.transparency,this.labelHalo.textContent=e.halo,this.labelBlur.textContent=e.blur,this.labelBrightness.textContent=e.brightness,this.labelShape.textContent=e.shape,this.labelShapeTitle.textContent=e.shapeTitle,this.labelUtcOffset.textContent=e.utcOffset,this.utcOffsetInput.placeholder=e.utcOffsetPlaceholder,this.labelApparentWidth.textContent=e.apparentWidth,this.labelRealWidth.textContent=e.realWidth,this.labelObjectDistance.textContent=e.distance,this.labelSizeLock.textContent=e.sizeLock;for(const[n,s]of[["option-lock-none",e.lockNone],["option-lock-apparent",e.lockApparent],["option-lock-real",e.lockReal],["option-lock-distance",e.lockDistance]])this.shadow.getElementById(n).textContent=s;this.clearDistanceHypothesisButton.textContent=e.clearDistanceHypothesis,this.clearDistanceHypothesisButton.title=e.clearDistanceHypothesisTitle,this.refreshApparentSize(),this.labelSamplingRate.textContent=e.samplingRate,this.labelDuration.textContent=e.duration,this.durationInput.placeholder=e.durationPlaceholder,this.addShapeButton.title=e.addShape,this.addShapeButton.setAttribute("aria-label",e.addShape),this.deleteShapeButton.title=e.deleteShape,this.deleteShapeButton.setAttribute("aria-label",e.deleteShape),this.contextGroupButton.textContent=e.group,this.contextUngroupButton.textContent=e.ungroup,this.contextBringToFrontButton.textContent=e.bringToFront,this.contextSendToBackButton.textContent=e.sendToBack,this.contextDeleteButton.textContent=e.contextMenuDelete,this.exportButton.textContent=e.export,this.labelImportFile.textContent=e.importFile,this.labelImportUrl.textContent=e.importUrl,this.importUrlInput.placeholder=e.importUrlPlaceholder,this.importUrlButton.textContent=e.importButton,this.labelWitnessAge.textContent=e.witnessAge,this.labelWitnessOccupation.textContent=e.witnessOccupation,this.labelTestimonySource.textContent=e.testimonySource,this.labelTestimonyFollowedUp.textContent=e.testimonyFollowedUp;for(const[n,s]of[["option-source-unknown",e.testimonySourceUnknown],["option-source-on-site",e.testimonySourceOnSite],["option-source-interview",e.testimonySourceInterview],["option-source-telephone",e.testimonySourceTelephone],["option-source-questionnaire",e.testimonySourceQuestionnaire],["option-source-letter",e.testimonySourceLetter],["option-source-press",e.testimonySourcePress],["option-followed-unknown",e.testimonyUnknown],["option-followed-yes",e.testimonyYes],["option-followed-no",e.testimonyNo]]){const a=this.shadow.getElementById(n);a&&(a.textContent=s)}this.labelNarrativeKey.textContent=e.narrativeKey.replace("{source}",Vs[0].name),this.labelNarrativeWorkspace.textContent=e.narrativeWorkspace,this.narrativeWorkspaceInput.placeholder=e.narrativeWorkspacePlaceholder,this.narrativeWorkspaceInput.title=e.narrativeWorkspaceHint,this.labelNarrativeRemember.textContent=e.narrativeRemember,this.narrativeStopButton.textContent=e.narrativeStop,this.narrativeDraftButton.textContent=e.narrativeDraft,this.descriptionInput.placeholder=e.narrativePlaceholder,this.syncNarrativeEnabled(),this.refreshSourceRows(),this.refreshTimeZoneOptions(),this.labelPlaceName.textContent=e.placeName,this.placeNameInput.placeholder=e.placeNamePlaceholder,this.searchPlaceButton.textContent=e.searchPlace,this.labelPlaceMatch.textContent=e.placeMatch,this.labelLatitude.textContent=e.latitude,this.labelLongitude.textContent=e.longitude,this.labelHeading.textContent=e.heading,this.headingInput.placeholder=e.headingPlaceholder,this.labelPitch.textContent=e.pitch,this.labelRoll.textContent=e.roll,this.labelElevation.textContent=e.elevation,this.labelObservationTime.textContent=e.observationTime,this.labelObservationEndTime.textContent=e.observationEndTime,this.obsTimeInput.placeholder=e.edtfPlaceholder,this.obsTimeInput.title=e.observationTimeHint,this.obsEndTimeInput.placeholder=e.edtfPlaceholder,this.obsEndTimeInput.title=e.observationEndTimeHint,this.presetsGroup.setAttribute("aria-label",e.presetsGroupLabel),this.labelDecor.textContent=e.decor,this.labelDecorGroup.textContent=e.decor,this.optionDecorBuilding.textContent=e.decorBuilding,this.optionDecorTree.textContent=e.decorTree,this.optionDecorCrop.textContent=e.decorCrop,this.optionDecorMound.textContent=e.decorMound,this.optionDecorStreetlight.textContent=e.decorStreetlight,this.optionDecorVehicle.textContent=e.decorVehicle,this.optionDecorAircraft.textContent=e.decorAircraft,this.optionDecorEntity.textContent=e.decorEntity,this.labelDecorLights.textContent=e.decorLights,this.labelDecorAltitude.textContent=e.decorAltitude,this.showMeteorButton.title=e.showMeteor,this.showMeteorButton.setAttribute("aria-label",e.showMeteor),this.showCometButton.title=e.showComet,this.showCometButton.setAttribute("aria-label",e.showComet),this.showNovaButton.title=e.showNova,this.showNovaButton.setAttribute("aria-label",e.showNova),this.showSatelliteButton.title=e.showSatellite,this.showSatelliteButton.setAttribute("aria-label",e.showSatellite),this.lookAtDecorButton.title=e.lookAtDecor,this.lookAtDecorButton.setAttribute("aria-label",e.lookAtDecor),this.optionDecorWitness.textContent=e.decorWitness,this.deleteDecorButton.title=e.deleteDecor,this.deleteDecorButton.setAttribute("aria-label",e.deleteDecor),this.labelDecorTitle.textContent=e.decorTitle,this.labelDecorEast.textContent=e.decorEast,this.labelDecorNorth.textContent=e.decorNorth,this.labelDecorHeading.textContent=e.decorHeading,this.labelDecorColor.textContent=e.decorColor,this.labelDecorLit.textContent=e.decorLit,this.labelDecorSightingUrl.textContent=e.decorSightingUrl,this.contextViewTestimonyButton.textContent=e.viewTestimony,this.labelContextMasks.textContent=`${e.masks} ▸`,this.addDecorWitnessButton.textContent=e.addWitness,this.addDecorBuildingButton.title=e.addDecor,this.addDecorBuildingButton.setAttribute("aria-label",e.addDecor),this.confirmAcceptButton.textContent=e.confirmAccept,this.confirmDeclineButton.textContent=e.confirmDecline,this.labelMilestones.textContent=e.milestones,this.labelMilestoneLabel.textContent=e.milestoneLabel,this.labelMilestoneNote.textContent=e.milestoneNote;for(const[n,s]of[[this.addMilestoneButton,e.addMilestone],[this.deleteMilestoneButton,e.deleteMilestone]])n.title=s,n.setAttribute("aria-label",s);this.labelDecorWidth.textContent=e.decorWidth,this.labelDecorLength.textContent=e.decorLength,this.labelDecorHeight.textContent=e.decorHeight,this.labelDecorModel.textContent=e.decorModel,this.labelDecorModelAdvanced.textContent=e.decorModelAdvanced,this.labelDecorModelUrl.textContent=e.decorModelUrl,this.labelDecorModelTitle.textContent=e.decorModelTitle,this.labelDecorModelAuthor.textContent=e.decorModelAuthor,this.labelDecorModelLicense.textContent=e.decorModelLicense,this.labelDecorModelSource.textContent=e.decorModelSource,this.labelDecorFloors.textContent=e.decorFloors,this.labelDecorOccupiedFloor.textContent=e.decorOccupiedFloor,this.labelDecorWitnessSide.textContent=e.decorWitnessSide,this.labelDecorWindows.textContent=e.decorWindows,this.optionWitnessSideNone.textContent=e.decorWitnessSideNone;const t={front:e.decorSideFront,behind:e.decorSideBehind,left:e.decorSideLeft,right:e.decorSideRight,"front-left":e.decorSideFrontLeft,"front-right":e.decorSideFrontRight,"behind-left":e.decorSideBehindLeft,"behind-right":e.decorSideBehindRight};for(const n of _r)this.labelDecorSide[n].textContent=t[n],this.optionWitnessSide[n].textContent=t[n];this.refreshDecorList(),this.labelWitnessId.textContent=e.witnessId,this.labelWitnessDirName.textContent=e.witnessDirName,this.labelWitnessTitle.textContent=e.witnessTitle,this.labelWitnessLastName.textContent=e.witnessLastName,this.labelWitnessFirstNames.textContent=e.witnessFirstNames,this.witnessFirstNamesInput.placeholder=e.tagsPlaceholder,this.labelCaseId.textContent=e.caseId,this.labelDescription.textContent=e.description,this.labelTags.textContent=e.tags,this.tagsInput.placeholder=e.tagsPlaceholder,this.labelShapeGroup.textContent=e.shapeGroup,this.labelTemporalGroup.textContent=e.temporalGroup,this.labelLocationGroup.textContent=e.locationGroup,this.labelObservationGroup.textContent=e.observationGroup,this.labelWitnessGroup.textContent=e.witnessGroup,this.labelWeatherGroup.textContent=e.weather,this.refreshTimeQualifierOptions(),this.edtfModeButton.title=e.edtfModeTitle,this.edtfModeButton.setAttribute("aria-label",e.edtfModeTitle),this.paramSummaryBuilder=new tp(e,this.showerLanguage(),this.said,this.tagNames),this.refreshParamSummary();const i=this.skyDetailsButton.getAttribute("aria-expanded")==="true";this.skyDetailsButton.title=i?e.skyDetailsHide:e.skyDetails,this.skyDetailsButton.setAttribute("aria-label",this.skyDetailsButton.title),this.labelCloudCover.textContent=e.cloudCover,this.labelHighCloud.textContent=e.highCloudCover,this.labelIceAlignment.textContent=e.iceCrystalAlignment,this.labelFNumber.textContent=e.aperture,this.labelExposure.textContent=e.exposure,this.labelFocusDistance.textContent=e.focusDistance,this.syncOpticsFromInstrument(),this.labelCloudDarkness.textContent=e.cloudDarkness,this.labelCloudBase.textContent=e.cloudBase,this.labelPrecipitationType.textContent=e.precipitationType,this.optionPrecipitationNone.textContent=e.precipitationNone,this.optionPrecipitationRain.textContent=e.precipitationRain,this.optionPrecipitationSnow.textContent=e.precipitationSnow,this.optionPrecipitationHail.textContent=e.precipitationHail,this.labelPrecipitationIntensity.textContent=e.precipitationIntensity,this.labelWindDirection.textContent=e.windDirection,this.labelWindSpeed.textContent=e.windSpeed,this.labelStorm.textContent=e.storm,this.labelCloudsGroup.textContent=e.cloudsGroup,this.labelPrecipitationGroup.textContent=e.precipitationGroup,this.labelWindGroup.textContent=e.windGroup,this.labelWeatherInferred.textContent=e.weatherInferred,this.syncWeatherSourceState(),this.labelSoundGroup.textContent=e.soundGroup,this.labelSoundKind.textContent=e.soundKind,this.labelSoundVolume.textContent=e.soundVolume,this.labelSoundPitch.textContent=e.soundPitch,this.labelSoundSrc.textContent=e.soundSrc,this.soundSrcInput.placeholder=e.soundSrcPlaceholder,this.labelReferenceGroup.textContent=e.referenceGroup,this.labelReference.textContent=e.reference,this.labelReferenceTitle.textContent=e.referenceTitle,this.labelReferenceSrc.textContent=e.referenceSrc,this.referenceSrcInput.placeholder=e.referenceSrcPlaceholder,this.labelReferenceKind.textContent=e.referenceKind,this.referenceKindSelect.querySelector("#reference-kind-photo").textContent=e.referencePhoto,this.referenceKindSelect.querySelector("#reference-kind-panorama").textContent=e.referencePanorama,this.labelReferenceCredit.textContent=e.referenceCredit,this.labelReferenceCreditUrl.textContent=e.referenceCreditUrl,this.labelReferenceT.textContent=e.referenceT,this.labelReferenceDrawing.textContent=e.referenceDrawing,this.labelReferenceOpacity.textContent=e.referenceOpacity,this.labelReferenceHeading.textContent=e.referenceHeading,this.labelReferencePitch.textContent=e.referencePitch,this.labelReferenceRoll.textContent=e.referenceRoll,this.labelReferenceFov.textContent=e.referenceFov,this.referenceUsePoseButton.textContent=e.referenceUsePose,this.addReferenceUrlButton.textContent=e.addReferenceUrl,this.labelAddReferenceFile.textContent=e.addReferenceFile,this.deleteReferenceButton.title=e.deleteReference,this.deleteReferenceButton.setAttribute("aria-label",e.deleteReference),this.labelReferenceLandmarks.textContent=e.referenceLandmarks,this.addReferenceLandmarkButton.textContent=e.addReferenceLandmark,this.deleteReferenceLandmarkButton.title=e.deleteReferenceLandmark,this.deleteReferenceLandmarkButton.setAttribute("aria-label",e.deleteReferenceLandmark),this.labelReferenceLandmarkLabel.textContent=e.referenceLandmarkLabel,this.referenceLandmarkLabelInput.placeholder=e.referenceLandmarkLabelPlaceholder,this.referenceAdoptPoseButton.textContent=e.referenceAdoptPose,this.referenceStreetSearchButton.textContent=e.referenceStreetSearch,this.referenceStreetAddButton.textContent=e.referenceStreetAdd;for(const[n,s]of this.soundKindOptions)s.textContent=this.soundKindLabel(n,e);this.labelInstrument.textContent=e.instrument,this.setRecordButtonLabel(this.isRecording),this.syncPlaybackControls()}onPointerDown(e){if(this.isRecording){this.onPointerMove(e);return}const t=this.canvasPointFromEvent(e);if(!t)return;const i=this.canvasMode();if(i==="picture"){this.ufoElement.playbackState!=="playing"&&this.beginReferenceDrag(t);return}const n=this.ufoElement.sighting.timeline,s=this.ufoElement.currentTime,a=this.ufoElement.playbackState==="playing",o=i==="shape";if(o)if(this.selectedSourceIds.size>1){const h=new Wc(this.selectedMembers()),d=lt.hitTestHandle({bounds:h.bounds(),angle:0},t);if(d==="rotate"){if(a)return;this.dragState={kind:"group-rotate",group:h,startPointer:t},this.startDragListening();return}if(d){if(a)return;this.dragState={kind:"group-resize",group:h,handle:d},this.startDragListening();return}}else{const h=n.getInterpolatedShapeAt(s,this.currentSourceId),d=h?.kind==="polygon"?lt.hitTestVertex(h,t):void 0;if(h?.kind==="polygon"&&d!==void 0){if(a)return;this.dragState={kind:"vertex",sourceId:this.currentSourceId,original:h,vertexIndex:d},this.startDragListening();return}const u=h&&lt.hitTestHandle(h,t);if(h&&u){if(a)return;this.beginDrag(u==="rotate"?"rotate":"resize",this.currentSourceId,h,t,u);return}}const l=this.ufoElement.shapeAt(t.x,t.y,Qm);if(!l){const h=this.pickDecorAt(e);if(h!==void 0){this.selectDecor(h);return}a||this.beginCameraDrag(t);return}if(this.revealShapePanel(),e.shiftKey?this.toggleUnitSelection(l.sourceId):this.selectedSourceIds.has(l.sourceId)||this.selectUnit(l.sourceId),a||!o)return;const c=[...this.selectedSourceIds].map(h=>({sourceId:h,original:h===l.sourceId?l.shape:n.getInterpolatedShapeAt(s,h)??l.shape}));this.dragState={kind:"move",sources:c,startPointer:t},this.startDragListening()}revealShapePanel(){const e=this.groupTabs.find(t=>t.getAttribute("aria-controls")==="group-shape");e&&this.toggleGroup(e,!0)}selectedMembers(){const e=this.ufoElement.sighting.timeline,t=this.ufoElement.currentTime;return[...this.selectedSourceIds].map(i=>({sourceId:i,shape:e.getInterpolatedShapeAt(t,i)})).filter(i=>!!i.shape)}selectUnit(e){const t=this.ufoElement.sighting.timeline.groupMembers(e)??[e];t.length===this.selectedSourceIds.size&&t.every(i=>this.selectedSourceIds.has(i))&&e===this.currentSourceId||(this.selectedSourceIds=new Set(t),this.currentSourceId=e,this.refreshSourceList(),this.onSelectionOrTimeChanged())}toggleUnitSelection(e){const t=this.ufoElement.sighting.timeline,i=t.groupMembers(e)??[e];if(i.every(s=>this.selectedSourceIds.has(s))){if(i.length>=this.selectedSourceIds.size)return;for(const s of i)this.selectedSourceIds.delete(s);if(!this.selectedSourceIds.has(this.currentSourceId)){const s=t.sourceIds;this.currentSourceId=[...this.selectedSourceIds].sort((a,o)=>s.indexOf(a)-s.indexOf(o)).pop()}}else{for(const s of i)this.selectedSourceIds.add(s);this.currentSourceId=e}this.refreshSourceList(),this.onSelectionOrTimeChanged()}onContextMenu(e){if(e.preventDefault(),this.isRecording||this.ufoElement.playbackState==="playing")return;this.hideContextMenu(),this.hideDecorContextMenu();const t=this.canvasPointFromEvent(e);if(!t)return;const i=this.ufoElement.sighting.timeline,n=this.ufoElement.currentTime,s=this.selectedSourceIds.size===1?i.getInterpolatedShapeAt(n,this.currentSourceId):void 0,o=s?.kind==="polygon"&&lt.hitTestVertex(s,t)!==void 0?{sourceId:this.currentSourceId}:this.ufoElement.shapeAt(t.x,t.y,Qm);if(o){this.selectedSourceIds.has(o.sourceId)||this.selectUnit(o.sourceId),this.currentSourceId=o.sourceId,this.contextMenuPoint=t,this.showContextMenu(e.clientX,e.clientY);return}const l=this.pickDecorAt(e),c=l?this.ufoElement.sighting.decor.find(h=>h.id===l):void 0;c&&this.showDecorContextMenu(e.clientX,e.clientY,c)}pickDecorAt(e){const i=this.ufoElement.canvasElement.getBoundingClientRect();if(i.width===0||i.height===0)return;const n=(e.clientX-i.left)/i.width*2-1,s=-((e.clientY-i.top)/i.height*2-1);return this.sceneElement.pickDecorAt(n,s)}showContextMenu(e,t){this.contextMenu.style.left=`${e}px`,this.contextMenu.style.top=`${t}px`,this.contextMenu.hidden=!1;const i=this.ufoElement.sighting.timeline.sourceIds,n=i.filter(f=>this.selectedSourceIds.has(f)),s=i.length<=n.length,a=n.length>0&&i.slice(i.length-n.length).every(f=>this.selectedSourceIds.has(f)),o=n.length>0&&i.slice(0,n.length).every(f=>this.selectedSourceIds.has(f));this.contextBringToFrontButton.disabled=s||a,this.contextSendToBackButton.disabled=s||o,this.contextBringToFrontButton.title=s?this.messages.onlyOneShape:a?this.messages.alreadyAtFront:"",this.contextSendToBackButton.title=s?this.messages.onlyOneShape:o?this.messages.alreadyAtBack:"",this.contextGroupButton.disabled=this.selectedSourceIds.size<2,this.contextGroupButton.title=this.contextGroupButton.disabled?this.messages.needTwoShapesToGroup:"";const l=this.ufoElement.sighting.timeline.groupMembers(this.currentSourceId)!==void 0;this.contextUngroupButton.disabled=!l,this.contextUngroupButton.title=l?"":this.messages.notGrouped,this.contextDeleteButton.disabled=this.deleteShapeButton.disabled,this.contextDeleteButton.title=this.contextDeleteButton.disabled?this.messages.onlyOneShape:"";const c=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId),h=this.selectedSourceIds.size===1&&c?.kind==="polygon";this.contextAddVertexButton.disabled=!h,this.contextAddVertexButton.title=h?"":this.messages.notAPolygon;const d=h&&this.contextMenuPoint?lt.hitTestVertex(c,this.contextMenuPoint):void 0,u=h&&c.points.length<=dg;this.contextDeleteVertexButton.disabled=!h||d===void 0||u,this.contextDeleteVertexButton.title=h?u?this.messages.tooFewVertices:"":this.messages.notAPolygon,document.addEventListener("click",this.handleOutsideContextMenuClick)}hideContextMenu(){this.contextMenu.hidden=!0,this.contextMenuPoint=void 0,document.removeEventListener("click",this.handleOutsideContextMenuClick)}handleOutsideContextMenuClick=e=>{e.composedPath().includes(this.contextMenu)||e.composedPath().includes(this.decorContextMenu)||(this.hideContextMenu(),this.hideDecorContextMenu())};showDecorContextMenu(e,t,i){this.contextMenuDecorId=i.id,this.decorContextMenu.style.left=`${e}px`,this.decorContextMenu.style.top=`${t}px`,this.decorContextMenu.hidden=!1,this.contextViewTestimonyButton.disabled=!i.sightingUrl,this.contextViewTestimonyButton.title=i.sightingUrl?"":this.messages.noWitnessRecording,this.refreshContextMasksSubmenu(i),document.addEventListener("click",this.handleOutsideContextMenuClick)}hideDecorContextMenu(){this.decorContextMenu.hidden=!0,this.contextMenuDecorId=void 0,document.removeEventListener("click",this.handleOutsideContextMenuClick)}refreshContextMasksSubmenu(e){this.contextMasksSubmenu.innerHTML="";for(const t of this.ufoElement.sighting.timeline.sourceIds){const i=document.createElement("label"),n=document.createElement("input");n.type="checkbox",n.checked=e.occludesSourceIds?.includes(t)??!1,n.addEventListener("change",()=>this.updateDecorOccludesShape(e.id,t,n.checked)),i.appendChild(n),i.appendChild(document.createTextNode(this.shapeLabel(t))),this.contextMasksSubmenu.appendChild(i)}}updateDecorOccludesShape(e,t,i){const n=this.ufoElement.sighting;n.decor=n.decor.map(s=>{if(s.id!==e)return s;const a=i?[...new Set([...s.occludesSourceIds??[],t])]:(s.occludesSourceIds??[]).filter(o=>o!==t);return{...s,occludesSourceIds:a.length>0?a:void 0}}),this.ufoElement.refresh()}viewWitnessTestimony(){const e=this.ufoElement.sighting.decor.find(t=>t.id===this.contextMenuDecorId);this.hideDecorContextMenu(),e?.sightingUrl&&this.importFromUrl(e.sightingUrl)}addVertexAtContextMenu(){const e=this.contextMenuPoint;if(this.hideContextMenu(),!e)return;const t=this.ufoElement.currentTime,i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,this.currentSourceId);if(i?.kind!=="polygon")return;const n=lt.insertVertexNear(i,e);this.commitShapes(t,[{sourceId:this.currentSourceId,shape:n}]),this.ufoElement.refresh()}deleteVertexAtContextMenu(){const e=this.contextMenuPoint;if(this.hideContextMenu(),!e)return;const t=this.ufoElement.currentTime,i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,this.currentSourceId);if(i?.kind!=="polygon")return;const n=lt.hitTestVertex(i,e);if(n===void 0)return;const s=lt.deleteVertex(i,n);this.commitShapes(t,[{sourceId:this.currentSourceId,shape:s}]),this.ufoElement.refresh()}bringSelectedToFront(){const e=this.ufoElement.sighting.timeline;for(const t of e.sourceIds.filter(i=>this.selectedSourceIds.has(i)))e.bringToFront(t);this.hideContextMenu(),this.ufoElement.refresh()}sendSelectedToBack(){const e=this.ufoElement.sighting.timeline;for(const t of e.sourceIds.filter(i=>this.selectedSourceIds.has(i)).reverse())e.sendToBack(t);this.hideContextMenu(),this.ufoElement.refresh()}groupSelected(){this.selectedSourceIds.size<2||(this.ufoElement.sighting.timeline.group([...this.selectedSourceIds]),this.hideContextMenu(),this.ufoElement.refresh())}ungroupSelected(){this.ufoElement.sighting.timeline.ungroup(this.currentSourceId),this.selectedSourceIds=new Set([this.currentSourceId]),this.hideContextMenu(),this.ufoElement.refresh()}beginDrag(e,t,i,n,s){this.dragState={kind:e,sourceId:t,original:i,handle:s,startPointer:n},this.startDragListening()}beginCameraDrag(e){const t=this.isWitnessInsideDecor();this.cameraDragState={startPointer:e,startHeadingDeg:t?this.indoorLookYawDeg:this.numberOrUndefined(this.headingInput.value)??0,startPitchDeg:t?this.indoorLookPitchDeg:this.numberOrUndefined(this.pitchInput.value)??0,insideDecor:t},t||this.sceneElement.setCompassForced(!0),this.setCanvasCursor("panning"),this.startDragListening()}isWitnessInsideDecor(){return this.ufoElement.sighting.decor.some(e=>e.witnessSide!==void 0&&ra(e.kind))}syncIndoorLookReset(){const e=this.ufoElement.sighting.decor.find(i=>i.witnessSide!==void 0&&ra(i.kind)),t=e?`${e.id}:${e.witnessSide}`:void 0;t!==this.lastInhabitedKey&&(this.lastInhabitedKey=t,this.indoorLookYawDeg=0,this.indoorLookPitchDeg=0,this.sceneElement.setIndoorLook(0,0))}startDragListening(){document.addEventListener("pointermove",this.handleDragPointerMove),document.addEventListener("pointerup",this.handleDragPointerUp)}onDragPointerMove(e){if(this.referenceDragState){this.onReferenceDragPointerMove(e);return}if(this.cameraDragState){this.onCameraDragPointerMove(e);return}if(!this.dragState)return;const t=this.canvasPointFromEvent(e);if(!t)return;const i=this.ufoElement.currentTime;if(this.dragState.kind==="move"){const{sources:n,startPointer:s}=this.dragState,a=t.x-s.x,o=t.y-s.y,l=n.map(({sourceId:c,original:h})=>({sourceId:c,shape:{...h,bounds:{...h.bounds,x:h.bounds.x+a,y:h.bounds.y+o}}}));this.commitShapes(i,l)}else if(this.dragState.kind==="group-resize"){const{group:n,handle:s}=this.dragState;this.commitShapes(i,n.resize(s,t))}else if(this.dragState.kind==="group-rotate"){const{group:n,startPointer:s}=this.dragState;this.commitShapes(i,n.rotate(t,s))}else if(this.dragState.kind==="vertex"){const{sourceId:n,original:s,vertexIndex:a}=this.dragState,o=lt.moveVertex(s,a,t);this.commitShapes(i,[{sourceId:n,shape:o}])}else{const{kind:n,sourceId:s,original:a,handle:o}=this.dragState,l=n==="resize"?lt.resizeShape(a,o,t):lt.rotateShape(a,t);this.commitShapes(i,[{sourceId:s,shape:l}])}this.ufoElement.refresh()}onCameraDragPointerMove(e){if(!this.cameraDragState)return;const t=this.canvasPointFromEvent(e);if(!t)return;const{startPointer:i,startHeadingDeg:n,startPitchDeg:s,insideDecor:a}=this.cameraDragState,o=n+(t.x-i.x)*tg,l=Math.max(-90,Math.min(90,s-(t.y-i.y)*tg));if(a){this.indoorLookYawDeg=o,this.indoorLookPitchDeg=l,this.sceneElement.setIndoorLook(o,l),this.ufoElement.refresh();return}this.headingInput.value=String(this.rounded(o)),this.pitchInput.value=String(this.rounded(l)),this.updateObserver()}endDrag(){if(this.referenceDragState){this.endReferenceDrag();return}!this.dragState&&!this.cameraDragState||(this.cameraDragState&&!this.cameraDragState.insideDecor&&this.sceneElement.setCompassForced(!1),this.dragState=void 0,this.cameraDragState=void 0,this.setCanvasCursor(this.hoverCursor),document.removeEventListener("pointermove",this.handleDragPointerMove),document.removeEventListener("pointerup",this.handleDragPointerUp))}nudgeBounds(e,t){const i={...e};if(t.shiftKey){switch(t.key){case"ArrowLeft":i.width=Math.max(ks,i.width-As);break;case"ArrowRight":i.width+=As;break;case"ArrowUp":i.height=Math.max(ks,i.height-As);break;case"ArrowDown":i.height+=As;break}i.x-=(i.width-e.width)/2,i.y-=(i.height-e.height)/2}else switch(t.key){case"ArrowLeft":i.x-=As;break;case"ArrowRight":i.x+=As;break;case"ArrowUp":i.y-=As;break;case"ArrowDown":i.y+=As;break}return i}moveOrResizeSelectedShapes(e){if(this.isRecording||this.ufoElement.playbackState==="playing")return;const t=this.ufoElement.currentTime,i=this.selectedMembers();if(i.length!==0){if(e.preventDefault(),i.length===1){const{sourceId:n,shape:s}=i[0];this.commitShapes(t,[{sourceId:n,shape:{...s,bounds:this.nudgeBounds(s.bounds,e)}}])}else{const n=new Wc(i),s=this.nudgeBounds(n.bounds(),e);this.commitShapes(t,n.scaleTo(s))}this.ufoElement.refresh()}}updateHoverCursor(e){this.isRecording||this.dragState||this.cameraDragState||(this.hoverCursor=this.hoverCursorAt(e),this.setCanvasCursor(this.hoverCursor))}hoverCursorAt(e){const t=this.canvasPointFromEvent(e);if(!t)return;const i=this.canvasMode(),n=this.ufoElement.sighting.timeline,s=this.ufoElement.currentTime,a=this.ufoElement.playbackState!=="playing";if(i==="picture")return a?"pan":void 0;const o=i==="shape";if(a&&o)if(this.selectedSourceIds.size>1){const l=lt.hitTestHandle({bounds:new Wc(this.selectedMembers()).bounds(),angle:0},t);if(l)return this.cursorForHandle(l,0)}else{const l=n.getInterpolatedShapeAt(s,this.currentSourceId);if(l?.kind==="polygon"&&lt.hitTestVertex(l,t)!==void 0)return"vertex";const c=l&&lt.hitTestHandle(l,t);if(l&&c)return this.cursorForHandle(c,l.angle)}return n.hitTest(s,t.x,t.y)?a&&o?"move":"select":this.pickDecorAt(e)!==void 0?"select":a?"pan":void 0}cursorForHandle(e,t){return e==="rotate"?"rotate":`resize-${lt.resizeAxisFor(e,t)}`}setCanvasCursor(e){const t=this.ufoElement.canvasElement;e?t.dataset.cursor=e:delete t.dataset.cursor}onPointerMove(e){if(!this.isRecording){this.updateHoverCursor(e);return}const t=this.ufoElement.canvasElement,i=t.getBoundingClientRect(),n=e.clientX-i.left,s=e.clientY-i.top;this.recorder?.onPointerMove(n,s),this.ufoElement.renderer.clear(t.width,t.height),this.ufoElement.renderer.paintShape(cg(this.buildPrototype({x:0,y:0,width:ea.width,height:ea.height}),n,s))}canvasPointFromEvent(e){const t=this.ufoElement.canvasElement,i=t.getBoundingClientRect();if(!(i.width===0||i.height===0))return{x:(e.clientX-i.left)/i.width*t.width,y:(e.clientY-i.top)/i.height*t.height}}}const oA={stated:"narrativeStated",derived:"narrativeDerived",assumed:"narrativeAssumed"},sg="rr0-sighting-editor",rg="rr0-ufo-recorder";class lA extends Ct{}function cA(){Cc(),customElements.get(sg)||customElements.define(sg,Ct),customElements.get(rg)||customElements.define(rg,lA)}cA();export{zi as $,pn as A,ht as B,oe as C,a0 as D,rn as E,wA as F,bt as G,Tt as H,mA as I,pA as J,We as K,Uo as L,yA as M,Ko as N,_t as O,Mb as P,qn as Q,Io as R,xo as S,hA as T,gA as U,Te as V,Xg as W,vA as X,vo as Y,ci as Z,sn as _,uA as a,fA as a0,Hs as a1,Wg as a2,bA as a3,Wy as a4,lc as a5,ou as a6,mc as a7,di as a8,Jg as a9,uf as aa,ff as ab,tt as ac,Bs as ad,Fo as ae,bn as af,fs as ag,dA as b,Ui as c,SA as d,hc as e,Bi as f,xA as g,Ye as h,P as i,Wp as j,MA as k,EA as l,zy as m,or as n,Zc as o,yd as p,X2 as q,vt as r,zn as s,Nt as t,Cd as u,Ri as v,hf as w,ps as x,Zy as y,ib as z};
7931
+ `);let s=Rn.cache.get(n);return s||(s=Promise.all(i.map(a=>Rn.load(a.url))).then(a=>a.reduce((o,l)=>Rn.concat(o,l))),Rn.cache.set(n,s)),s}static parse(e){const t=e.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),i=t*Float32Array.BYTES_PER_ELEMENT;return{count:t,ra:new Float32Array(e,0*i,t),dec:new Float32Array(e,1*i,t),mag:new Float32Array(e,2*i,t),ci:new Float32Array(e,3*i,t)}}static concat(e,t){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:e.count+t.count,ra:i(e.ra,t.ra),dec:i(e.dec,t.dec),mag:i(e.mag,t.mag),ci:i(e.ci,t.ci)}}}const j5=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,Q5=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,eT=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,tT=20,iT=1;class nT{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};resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(e){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",e);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(e,t,i){if(this.requested={type:e,intensity:t,windSpeed:i},!this.context)return;this.paused&&(e="none",t=0,i=0);const n=e==="rain"||e==="hail"?e:"none";if(this.ambientVolume=n==="hail"?Math.min(1,t*1.3+.2):n==="rain"?t: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(j5,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,l=>{this.ambientSource=l?.source,this.ambientGain=l?.gain,l&&(l.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(i/tT,1);const s=i>iT;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(Q5,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,l=>{this.windSource=l?.source,this.windGain=l?.gain,l&&(l.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:i,windSpeed:n}=this.requested;this.setAmbient(t,i,n)}playThunder(){!this.context||this.paused||this.playOneShot(eT,.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.buffers.clear()}applyIfCurrent(e,t,i,n){if(t!==i()){e?.source.stop();return}n(e)}async startLoop(e,t){const i=this.context;if(i)try{const n=await this.getBuffer(e),s=i.createBufferSource();s.buffer=n,s.loop=!0;const a=i.createGain();return a.gain.value=t,s.connect(a).connect(i.destination),s.start(),{source:s,gain:a}}catch(n){console.warn("Weather ambient sound failed to load, staying silent:",n);return}}async playOneShot(e,t){const i=this.context;if(i)try{const n=await this.getBuffer(e),s=i.createBufferSource();s.buffer=n;const a=i.createGain();a.gain.value=t,s.connect(a).connect(i.destination),s.start()}catch(n){console.warn("Thunder sound failed to load:",n)}}async getBuffer(e){const t=this.context;if(!t)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(e);return i||(i=fetch(e).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${e}`);return n.arrayBuffer()}).then(n=>t.decodeAudioData(n)),this.buffers.set(e,i)),i}stopSource(e,t){try{e?.stop()}catch{}e?.disconnect(),t?.disconnect()}}class ss{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:i}=e,[n,s]=this.perifocalAxes(),a=Math.sqrt(ss.SUN_GM_AU3_PER_DAY2*(1+t)/i);this.perihelionPosition=this.scale(n,i),this.perihelionVelocity=this.scale(s,a),this.inverseSemiMajorAxis=(1-t)/i}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(e){const t=e-this.elements.perihelionJd,i=this.universalAnomaly(t),n=this.inverseSemiMajorAxis*i*i,s=this.elements.perihelionAu,a=1-i*i/s*ss.stumpffC(n),o=t-i*i*i/Math.sqrt(ss.SUN_GM_AU3_PER_DAY2)*ss.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(e){const t=this.positionAt(e);return Math.hypot(t.x,t.y,t.z)}universalAnomaly(e){if(e===0)return 0;const t=Math.sign(e),i=Math.sqrt(ss.SUN_GM_AU3_PER_DAY2)*Math.abs(e),n=o=>{const l=this.inverseSemiMajorAxis*o*o,c=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*c)*o*o*o*ss.stumpffS(l)+c*o};let s=Math.max(1,i/this.elements.perihelionAu);for(;n(s)<i;)s*=2;let a=0;for(let o=0;o<ss.MAX_ITERATIONS&&s-a>1e-13*Math.max(1,s);o++){const l=(a+s)/2;n(l)<i?a=l:s=l}return t*(a+s)/2}perifocalAxes(){const e=this.elements.ascendingNodeDeg*Math.PI/180,t=this.elements.argumentOfPerihelionDeg*Math.PI/180,i=this.elements.inclinationDeg*Math.PI/180,n=Math.cos(e),s=Math.sin(e),a=Math.cos(t),o=Math.sin(t),l=Math.cos(i),c=Math.sin(i);return[{x:n*a-s*o*l,y:s*a+n*o*l,z:o*c},{x:-n*o-s*a*l,y:-s*o+n*a*l,z:a*c}]}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}static stumpffC(e){if(Math.abs(e)<1e-6)return 1/2-e/24+e*e/720;if(e>0)return(1-Math.cos(Math.sqrt(e)))/e;const t=Math.sqrt(-e);return(Math.cosh(t)-1)/-e}static stumpffS(e){if(Math.abs(e)<1e-6)return 1/6-e/120+e*e/5040;if(e>0){const i=Math.sqrt(e);return(i-Math.sin(i))/(i*i*i)}const t=Math.sqrt(-e);return(Math.sinh(t)-t)/(t*t*t)}}const W1=[{id:"halley-1910",designation:"1P/Halley",name:{en:"Halley's Comet",fr:"comète de Halley"},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:{en:"Comet Brooks",fr:"comète 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:{en:"Comet Skjellerup-Maristany",fr:"comète 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:{en:"Comet de Kock-Paraskevopoulos",fr:"comète 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:{en:"the Southern Comet",fr:"comète australe"},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:{en:"the Eclipse Comet",fr:"comète de l'éclipse"},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:{en:"Comet Arend-Roland",fr:"comète 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:{en:"Comet Mrkos",fr:"comète 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:{en:"Comet Seki-Lines",fr:"comète 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:{en:"Comet Ikeya-Seki",fr:"comète 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:{en:"Comet Bennett",fr:"comète 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:{en:"Comet White-Ortiz-Bolelli",fr:"comète 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:{en:"Comet Kohoutek",fr:"comète 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:{en:"Comet West",fr:"comète 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:{en:"Comet IRAS-Araki-Alcock",fr:"comète 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:{en:"Halley's Comet",fr:"comète de Halley"},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:{en:"Comet Hyakutake",fr:"comète 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:{en:"Comet Hale-Bopp",fr:"comète 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:{en:"Comet McNaught",fr:"comète 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:{en:"Comet Lovejoy",fr:"comète 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:{en:"Comet PANSTARRS",fr:"comète 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:{en:"Comet NEOWISE",fr:"comète 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:{en:"Comet Tsuchinshan-ATLAS",fr:"comète 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 Ql{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(e){const t=this.julianDayOf(e);return W1.filter(i=>Math.abs(t-i.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(e,t){return this.aroundDate(e).map(i=>this.appearanceOf(i,e,t)).sort((i,n)=>i.magnitude-n.magnitude)[0]}static appearanceOf(e,t,i){const n=Bt(t),s=this.earthPositionAt(n),a=this.apparentPositionOf(e,2451545+n.tt,s),o=this.subtract(a,s),l=this.length(a),c=this.length(o),h=this.tailEndAt(e,a,s,l,n,t,i),d=this.horizontalOf(o,n,t,i);return{apparition:e,position:d,...h,heliocentricDistanceAu:l,earthDistanceAu:c,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},s)),magnitude:this.magnitudeAt(e,l,c)}}static magnitudeAt(e,t,i){const n=e.absoluteMagnitude+5*Math.log10(i)+2.5*e.activityExponent*Math.log10(t);return Math.max(n,e.peakMagnitude)}static tailEndAt(e,t,i,n,s,a,o){if(e.tailLengthAu===void 0)return{};const l=1+e.tailLengthAu/n,c=this.subtract({x:t.x*l,y:t.y*l,z:t.z*l},i),h=this.subtract(t,i);return{tailEnd:this.horizontalOf(c,s,a,o),tailLengthDeg:this.angleBetween(h,c)}}static apparentPositionOf(e,t,i){const n=this.orbitOf(e);let s=n.positionAt(t);for(let a=0;a<2;a++){const o=this.length(this.subtract(s,i))/this.LIGHT_SPEED_AU_PER_DAY;s=n.positionAt(t-o)}return s}static horizontalOf(e,t,i,n){const s=xa(n_(),new Et(e.x,e.y,e.z,t)),a=xa(C1(t),s),o=OE(t,new _f(n.lat,n.lng,n.elevationM)),l=new Et(a.x-o.x,a.y-o.y,a.z-o.z,t),c=Af(l);return If(c.ra,c.dec,i,n)}static earthPositionAt(e){return xa(i_(),Us(xe.Earth,e))}static julianDayOf(e){return 2451545+Bt(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const i=new ss(e.orbit);return this.orbits.set(e.id,i),i}static subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}static length(e){return Math.hypot(e.x,e.y,e.z)}static angleBetween(e,t){const i=(e.x*t.x+e.y*t.y+e.z*t.z)/(this.length(e)*this.length(t)||1);return Math.acos(Math.min(1,Math.max(-1,i)))*180/Math.PI}}const nd=[{id:"sn-1006",kind:"supernova",designation:"SN 1006",name:{en:"Supernova of 1006",fr:"supernova de 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:{en:"Supernova of 1054",fr:"supernova de 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:{en:"Supernova of 1181",fr:"supernova de 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:{en:"Tycho's Supernova",fr:"supernova de Tycho"},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:{en:"Kepler's Supernova",fr:"supernova de Kepler"},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:{en:"Nova Coronae Borealis 1866",fr:"nova de la Couronne boréale 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:{en:"Nova Aurigae 1891",fr:"nova du Cocher 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:{en:"Nova Persei 1901",fr:"nova de Persée 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:{en:"Nova Geminorum 1912",fr:"nova des Gémeaux 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:{en:"Nova Aquilae 1918",fr:"nova de l'Aigle 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:{en:"Nova Cygni 1920",fr:"nova du Cygne 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:{en:"Nova Pictoris 1925",fr:"nova du Peintre 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:{en:"Nova Herculis 1934",fr:"nova d'Hercule 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:{en:"Nova Lacertae 1936",fr:"nova du Lézard 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:{en:"Nova Puppis 1942",fr:"nova de la Poupe 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:{en:"Nova Coronae Borealis 1946",fr:"nova de la Couronne boréale 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:{en:"Nova Herculis 1960",fr:"nova d'Hercule 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:{en:"Nova Herculis 1963",fr:"nova d'Hercule 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:{en:"Nova Delphini 1967",fr:"nova du Dauphin 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:{en:"Nova Vulpeculae 1968",fr:"nova du Petit Renard 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:{en:"Nova Serpentis 1970",fr:"nova du Serpent 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:{en:"Nova Cygni 1975",fr:"nova du Cygne 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:{en:"Nova Centauri 1986",fr:"nova du Centaure 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:{en:"Supernova 1987A",fr:"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:{en:"Nova Cygni 1992",fr:"nova du Cygne 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:{en:"Nova Velorum 1999",fr:"nova des Voiles 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:{en:"Nova Aquilae 1999",fr:"nova de l'Aigle 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:{en:"Nova Sagittarii 2002",fr:"nova du Sagittaire 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:{en:"Nova Ophiuchi 2006",fr:"nova d'Ophiuchus 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:{en:"Nova Scorpii 2007",fr:"nova du Scorpion 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:{en:"Nova Delphini 2013",fr:"nova du Dauphin 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:{en:"Nova Centauri 2013",fr:"nova du Centaure 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:{en:"Nova Ophiuchi 2021",fr:"nova d'Ophiuchus 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 Ac{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(e){const t=this.julianDayOf(e);return nd.filter(i=>this.magnitudeAt(i,t)!==void 0)}static appearancesAt(e,t){const i=this.julianDayOf(e),n=[];for(const s of nd){const a=this.magnitudeAt(s,i);a!==void 0&&n.push({outburst:s,position:fn.ofJ2000(s.raHours,s.decDeg,e,t),magnitude:a})}return n.sort((s,a)=>s.magnitude-a.magnitude)}static brightestAt(e,t){return this.appearancesAt(e,t)[0]}static byId(e){return nd.find(t=>t.id===e)}static magnitudeAt(e,t){const i=e.lightCurve,n=t-e.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],[l,c]=i[s]??i[0];if(l===a)return o;const h=Math.min(1,Math.max(0,(n-a)/(l-a)));return o+h*(c-o)}static julianDayOf(e){return e.getTime()/864e5+this.UNIX_EPOCH_JD}}const sT=[{id:"quadrantids",code:"QUA",name:{en:"Quadrantids",fr:"Quadrantides"},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:{en:"April Lyrids",fr:"Lyrides d'avril"},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:{en:"eta Aquariids",fr:"Êta Aquarides"},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:{en:"alpha Capricornids",fr:"Alpha Capricornides"},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:{en:"Southern delta Aquariids",fr:"Delta Aquarides du Sud"},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:{en:"Perseids",fr:"Perséides"},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:{en:"Southern Taurids",fr:"Taurides du Sud"},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:{en:"October Draconids",fr:"Draconides d'octobre"},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:{en:"Orionids",fr:"Orionides"},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:{en:"Northern Taurids",fr:"Taurides du Nord"},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:{en:"Leonids",fr:"Léonides"},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:{en:"Geminids",fr:"Géminides"},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:{en:"Ursids",fr:"Ursides"},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}],La=6.5;class Sa{static activeAt(e){return sT.flatMap(t=>{const i=this.nearness(t,e);return i<=0?[]:[{shower:t,zhr:t.peakZhr*i,nearness:i}]})}static nearness(e,t){const i=this.dayOfYear(t),n=this.dayOfYear(this.asDate(e.start)),s=this.dayOfYear(this.asDate(e.peak)),a=this.dayOfYear(this.asDate(e.end)),o=this.wrappedDelta(i,s),l=this.wrappedDelta(s,n),c=this.wrappedDelta(a,s);return o<0?o<-l?0:1+o/l:o>0?o>c?0:1-o/c:1}static observedRatePerHour(e,t,i,n=La){if(t<=0)return 0;const s=La-n;return e*Math.sin(t*Math.PI/180)/Math.pow(i,s)}static radiantPosition(e,t,i){return fn.ofJ2000(e.radiantRaHours,e.radiantDecDeg,t,i)}static dayOfYear(e){const t=Date.UTC(e.getUTCFullYear(),0,1);return Math.floor((Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())-t)/864e5)+1}static asDate(e){return new Date(Date.UTC(2001,e.month-1,e.day))}static wrappedDelta(e,t){const i=e-t;return i>182?i-365:i<-182?i+365:i}}class Lt{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const i=Bt(e),n=new Uc(0,kE(e).elon-90,1),s=xa(r_(i),Tf(n,i)),a=Af(s);return If(a.ra,a.dec,e,t)}static observedRatePerHour(e,t=La){const i=Lt.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),n=La-t;return(Lt.QUIET_RATE_PER_HOUR+i)/Math.pow(Lt.POPULATION_INDEX,n)}static schedule(e){const t=new Hc(e.seed^1542469173);return pr.schedule(e).map(i=>{const n=Lt.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),s=i.fromRadiantDeg*Math.PI/180,a=Lt.turnAround(n,t.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:Lt.toHorizontal(o),bearingDeg:Lt.bearingFrom(o,n)}})}static turnAround(e,t){const[i,n]=Lt.basisAround(e),s=t*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(e,t){const[i,n]=Lt.basisAround(e),s=e.x*t.x+e.y*t.y+e.z*t.z,a=Lt.normalise({x:t.x-e.x*s,y:t.y-e.y*s,z:t.z-e.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(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=Lt.normalise(Lt.cross(e,t));return[i,Lt.normalise(Lt.cross(e,i))]}static toHorizontal(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,e.y/t)))*180/Math.PI,azimuthDeg:(Math.atan2(e.x,-e.z)*180/Math.PI%360+360)%360}}static appearanceOf(e){const t=Lt.toCartesian(e.radiant??{altitudeDeg:90,azimuthDeg:0}),i=Lt.turnAround(t,e.bearingDeg),n=e.fromRadiantDeg*Math.PI/180;return Lt.toHorizontal({x:t.x*Math.cos(n)+i.x*Math.sin(n),y:t.y*Math.cos(n)+i.y*Math.sin(n),z:t.z*Math.cos(n)+i.z*Math.sin(n)})}static toCartesian(e){const t=e.altitudeDeg*Math.PI/180,i=e.azimuthDeg*Math.PI/180,n=Math.cos(t);return{x:n*Math.sin(i),y:Math.sin(t),z:-n*Math.cos(i)}}static cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}static normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}static TYPICAL_VELOCITY_KM_S=40}const zm="https://ufoathome.org/tle/index.json";class Si{static MAX_ELEMENT_AGE_DAYS=7;static DAY_MS=864e5;fetchImpl;indexUrls;index;files=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??Si.defaultIndexUrls()}static defaultIndexUrls(){const e=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&e.push(new URL("/tle/index.json",location.href).href),e.includes(zm)||e.push(zm),e}static FIRST_SNAPSHOT="2021-02-22";async covers(e){const t=Date.parse(`${Si.FIRST_SNAPSHOT}T00:00:00Z`)-Si.MAX_ELEMENT_AGE_DAYS*Si.DAY_MS;if(e.getTime()<t)return!1;const i=await this.loadIndex();return i?Object.values(i.index.kinds).some(n=>e.getTime()>=Date.parse(n.from)-Si.MAX_ELEMENT_AGE_DAYS*Si.DAY_MS&&e.getTime()<=Date.parse(n.to)+Si.MAX_ELEMENT_AGE_DAYS*Si.DAY_MS):!1}async at(e){const t=await this.loadIndex();if(!t)return;const{index:i,base:n}=t,s=[],a=[];for(const o of Object.keys(i.kinds)){const l=await this.kindAt(o,e,i,n);s.push(...l),a.push(this.coverageOf(o,e,i,l.length>0))}return{objects:s,coverage:a,credit:i.credit,creditUrl:i.source}}async kindAt(e,t,i,n){const s=t.getTime(),a=i.binDays*Si.DAY_MS,o=Math.floor(s/a),l=s-o*a<a/2?o-1:o+1,c=new Set(i.kinds[e].bins),h=[o,l].map(v=>new Date(v*a).toISOString().slice(0,10)).filter(v=>c.has(v));if(h.length===0)return[];const[d,...u]=await Promise.all([this.json(new URL(`objects-${e}.json`,n).href),...h.map(v=>this.binary(new URL(`${e}/${v}.bin`,n).href))]),f=new Map;for(const v of u)for(const m of Si.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)/Si.DAY_MS;if(m>Si.MAX_ELEMENT_AGE_DAYS)continue;const g=d[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:e,launch:g.launch,stdMag:g.stdMag,elements:v,ageDays:m})}return p}coverageOf(e,t,i,n){const{from:s,to:a}=i.kinds[e],o=t.getTime(),l=Si.MAX_ELEMENT_AGE_DAYS*Si.DAY_MS,c=n?"covered":o<Date.parse(s)-l?"before":o>Date.parse(a)+l?"after":"gap";return{kind:e,status:c,from:s,to:a}}static decode(e,t){const i=new DataView(e),n=[];for(let s=0;s+t<=e.byteLength;s+=t)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 e of this.indexUrls)try{const t=await this.fetchImpl(e);if(!t.ok)continue;return{index:await t.json(),base:e}}catch{}})(),this.index}json(e){return this.cached(e,async t=>t.json())}binary(e){return this.cached(e,async t=>t.arrayBuffer())}cached(e,t){let i=this.files.get(e);return i||(i=this.fetchImpl(e).then(n=>{if(!n.ok)throw new Error(`${e}: ${n.status}`);return t(n)}),i.catch(()=>this.files.delete(e)),this.files.set(e,i)),i}}class rT{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const i=it.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(t.inFrontM!==void 0){const i=it.sizeMAt(t.inFrontM,e);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(e){return e<=0?{}:{minM:this.lowerM===void 0?void 0:it.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:it.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class mr{static DEG_PER_SECOND=360/86164.0905;static degOver(e){return Math.max(0,e)*mr.DEG_PER_SECOND}static instants(e,t){if(!(t>0))return 1;const i=mr.degOver(e)/t;return i<1?1:Math.min(mr.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class Ei{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 mr.DEG_PER_SECOND*3600}static graspOf(e,t={}){const i=t.exposureSeconds??e.exposureSeconds,n=t.fNumber??e.fNumber;if(i===void 0||n===void 0||!(i>0)||!(n>0))return Ei.EYE;const s=t.focalLengthMm??e.frame?.focalLengthMm??Ei.UNKNOWN_CAMERA_FOCAL_MM,a=s/n,o=Ei.resolutionArcsec(e,s,a);return{apertureMm:a,exposureSeconds:Math.min(i,Ei.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(e,t,i){const s=(e.detailUm??Ei.UNKNOWN_CAMERA_DETAIL_UM)/1e3/t*Ei.ARCSEC_PER_RADIAN,a=1.22*Ei.WAVELENGTH_M/(i/1e3)*Ei.ARCSEC_PER_RADIAN;return Math.max(s,a)}static trailLimitedSeconds(e){return e/Ei.skyDriftArcsecPerSecond}static gainOverEye(e,t={}){const i=Ei.graspOf(e,t),n=Ei.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(e,t){const i=t.fieldOfViewDeg===void 0?void 0:ct.focalLengthMmFor(e,t.fieldOfViewDeg);return Ei.gainOverEye(e,{fNumber:t.fNumber,focalLengthMm:i,exposureSeconds:t.exposureSeconds})}}const Hm=111320,io=Math.PI/180,aT=1.02,oT=1;class xo{static of(e,t){const i=xo.sightings(e,t);if(i.length<2)return;const n=xo.baseline(i);if(!n)return;const{near:s,far:a,closedM:o}=n,l=Math.tan(a.widthDeg/2*io)===0?0:Math.tan(s.widthDeg/2*io)/Math.tan(a.widthDeg/2*io);if(l<aT)return;const c=o/(l-1),h=it.sizeMAt(c,s.widthDeg),d=i.map(u=>({t:u.t,m:it.distanceMAt(h,u.widthDeg)}));return{widthM:h,distanceM:d,nearestM:Math.min(...d.map(u=>u.m)),fromT:a.t,toT:s.t,closedM:o}}static sightings(e,t){return e.timeline.allKeyframes.flatMap(i=>{const n=i.shapes.find(o=>o.sourceId===t)?.shape,s=n?.angular?.widthDeg,a=nt(e,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(e){let t;for(const i of e)for(const n of e){if(i.t>=n.t)continue;const s=xo.closedAlongSight(i,n),[a,o,l]=s>=0?[n,i,s]:[i,n,-s];l<oT||a.widthDeg<=o.widthDeg||(!t||l>t.closedM)&&(t={near:a,far:o,closedM:l})}return t}static closedAlongSight(e,t){const i=(t.lat-e.lat)*Hm,n=(t.lng-e.lng)*Hm*Math.cos(e.lat*io),s=(e.sightAzimuthDeg??0)*io;return i*Math.cos(s)+n*Math.sin(s)}}class Di{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(e){if(e.statedM!==void 0&&e.statedM>0)return{distanceM:Di.atLeastNearest(e.statedM),basis:"stated"};if(e.hypothesisM!==void 0&&e.hypothesisM>0)return{distanceM:Di.atLeastNearest(e.hypothesisM),basis:"hypothesis"};if(e.derivedM!==void 0&&e.derivedM>0)return{distanceM:Di.atLeastNearest(e.derivedM),basis:"derived"};const t=Di.largest(e.range?.minM,e.crossing?.behindM),i=Di.smallest(e.range?.maxM,e.crossing?.inFrontM),n=t===void 0?void 0:t*Di.MARGIN,s=i===void 0?void 0:i/Di.MARGIN;return n!==void 0&&s!==void 0?{distanceM:Di.atLeastNearest(n<=s?Math.sqrt(n*s):n),basis:"bounded"}:n!==void 0?{distanceM:Di.atLeastNearest(n),basis:"bounded"}:s!==void 0&&s<Di.CONVENTIONAL_M?{distanceM:Di.atLeastNearest(s),basis:"bounded"}:{distanceM:Di.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(e){return Math.max(Di.NEAREST_M,e)}static largest(...e){const t=e.filter(i=>i!==void 0&&i>0);return t.length===0?void 0:Math.max(...t)}static smallest(...e){const t=e.filter(i=>i!==void 0&&i>0);return t.length===0?void 0:Math.min(...t)}}Cc();const lT={sun:{en:"Sun",fr:"Soleil"},moon:{en:"Moon",fr:"Lune"},Venus:{en:"Venus",fr:"Vénus"},Mars:{en:"Mars",fr:"Mars"},Jupiter:{en:"Jupiter",fr:"Jupiter"},Saturn:{en:"Saturn",fr:"Saturne"}},cT=["en","fr"],hT={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},dT={en:"{name} — satellite, mag {mag}, {height} km up",fr:"{name} — satellite, mag {mag}, à {height} km d'altitude"},X1="satellites-change",uT={en:"{name} — mag {mag}, {alt}° below the horizontal",fr:"{name} — mag {mag}, {alt}° sous l'horizontale"},Gm="comet:",Vm="nova:",fT={building:{en:"Building",fr:"Bâtiment"},tree:{en:"Tree",fr:"Arbre"},crop:{en:"Crop row",fr:"Rang de culture"},mound:{en:"Stone heap",fr:"Tas de pierres"},streetlight:{en:"Streetlight",fr:"Lampadaire"},vehicle:{en:"Vehicle",fr:"Véhicule"},witness:{en:"Witness",fr:"Témoin"},aircraft:{en:"Aircraft",fr:"Aéronef"},entity:{en:"Being",fr:"Être"}},pT=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,mT=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,gT=-18,vT={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},sd={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class Df extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",fr,pa]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;distanceHypotheses=new Map;depths=new Map;directionScratch=new P;meteorScheduleFor;lightningScheduleFor;lightningFlashes=[];lastLightningT;lastTimeMs=0;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new Si;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;starCatalogDepth=0;weatherAudio=new nT;animateWhilePausedValue=!1;set animateWhilePaused(e){e!==this.animateWhilePausedValue&&(this.animateWhilePausedValue=e,this.syncAnimationsToPlayback())}get animateWhilePaused(){return this.animateWhilePausedValue}thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=e=>{this.sceneRenderer.setCompassHovered(!0);const t=this.ufoElement.canvasElement,i=t.getBoundingClientRect();if(i.width===0||i.height===0)return;const n=(e.clientX-i.left)/i.width*t.width,s=(e.clientY-i.top)/i.height*t.height;if(this.ufoElement.hasVisibleShapeAt(n,s)){this.hoverTooltip.hidden=!0;return}const a=(e.clientX-i.left)/i.width*2-1,o=-((e.clientY-i.top)/i.height*2-1),l=fa(Ns.preferencesFor(this),cT),c=this.sceneRenderer.pickBodyAt(a,o);if(c){this.showHoverTooltip(e,this.bodyName(c,l));return}const h=this.sceneRenderer.pickDecorAt(a,o),d=h?this.ufoElement.sighting.decor.find(p=>p.id===h):void 0;if(d){this.showHoverTooltip(e,this.said.read(d.title)||fT[d.kind][l]);return}const u=this.sceneRenderer.pickSatelliteAt(a,o);if(u){this.showHoverTooltip(e,dT[l].replace("{name}",u.name).replace("{mag}",u.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(u.heightKm).toLocaleString()));return}const f=this.sceneRenderer.pickStarAt(a,o);if(f){const p=f.star.mag,v=f.altitudeDeg,m=(v<0?uT:hT)[l];this.showHoverTooltip(e,m.replace("{name}",f.star.name[l]).replace("{mag}",p.toLocaleString(void 0,{maximumFractionDigits:Math.abs(p)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(v)))));return}this.hoverTooltip.hidden=!0};bodyName(e,t){const i=e.startsWith(Gm)?e.slice(Gm.length):void 0,n=i?W1.find(a=>a.id===i):void 0,s=e.startsWith(Vm)?Ac.byId(e.slice(Vm.length)):void 0;return n?.name[t]??s?.name[t]??lT[e]?.[t]??e}showHoverTooltip(e,t){this.hoverTooltip.textContent=t,this.hoverTooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${e.clientX-i.left+12}px`,this.hoverTooltip.style.top=`${e.clientY-i.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash(e){clearTimeout(this.thunderTimeoutId),this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),Qt.thunderDelayMs(e))}handleFirstInteraction=()=>{this.removeEventListener("pointerdown",this.handleFirstInteraction,!0),this.removeEventListener("keydown",this.handleFirstInteraction,!0),this.weatherAudio.resume(),this.setWeather(kt(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=e=>{this.lastTimeMs=e.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"&&this.sceneRenderer.frame(performance.now())};syncAnimationsToPlayback(){const e=this.ufoElement.playbackState==="playing",t=e||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(t,e),this.weatherAudio.setPaused(!t),t||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${w2}</style>${b2}`,this.shadow.appendChild(e.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 tn(this.sceneCanvas),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(wd),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",t=>this.lookToward(t.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.sceneRenderer.onMapSubjectBounds=t=>this.ufoElement.setMapSubjectBounds(t),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.addEventListener("referenceview",t=>this.applyReferenceView(t.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 rs(Ns.preferencesFor(this))}saidTexts;connectedCallback(){this.saidTexts=void 0,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 e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose(),queueMicrotask(()=>{this.isConnected||this.sceneRenderer.releaseContext()})}attributeChangedCallback(e,t,i){if(e==="src"&&i&&i!==t&&this.isConnected&&this.loadFromSrc(i),(e==="star-catalog-src"||e==="deep-star-catalog-src")&&i!==t&&this.isConnected&&this.loadStars(),e==="show-compass"&&i!==t&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),e==="max-pixel-ratio"&&i!==t){const n=Number(i);this.sceneRenderer.setMaxPixelRatio(Number.isFinite(n)&&n>0?n:Math.min(window.devicePixelRatio||1,2))}(e===fr||e===pa)&&i!==t&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const e of[fr,pa])this.ufoElement.toggleAttribute(e,this.hasAttribute(e))}setCompassForced(e){this.sceneRenderer.setCompassForced(e)}lookToward(e){const t=nt(this.ufoElement.sighting,this.lastTimeMs);if(e.kind==="witness"||t?.lat===void 0||t.lng===void 0||t.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:i,z:n}=mi(e.lat,e.lng,t.lat,t.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-t.headingDeg)%360+540)%360-180,-t.pitchDeg)}setLookOffset(e,t){this.sceneRenderer.setLookOffset(e,t),this.ufoElement.setLookOffset(e,t),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(e,t){this.sceneRenderer.setIndoorLook(e,t)}setCloudRendering(e){this.sceneRenderer.setCloudRendering(e)}setWeather(e){this.sceneRenderer.setWeather(e),this.weatherAudio.setAmbient(e.precipitationType,e.precipitationIntensity,e.windSpeed)}pickCloudAt(e,t){return this.sceneRenderer.pickCloudAt(e,t)}cloudDirectionAt(e,t){return this.sceneRenderer.cloudDirectionAt(e,t)}pickDecorAt(e,t){return this.sceneRenderer.pickDecorAt(e,t)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(e){this.sightingData=await Xu.json(e)}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.ufoElement.sightingData=e,this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}referenceAspect(e){return this.sceneRenderer.referenceAspect(e)}screenPointOf(e){return this.sceneRenderer.screenPointOf(e)}directionAt(e,t){return this.sceneRenderer.directionAt(e,t)}referenceFailedToLoad(e){return this.sceneRenderer.referenceFailedToLoad(e)}applyReferenceView(e){this.sceneRenderer.setReferencesShown(e.shown);for(const t of this.ufoElement.sighting.references)this.sceneRenderer.setReferenceView(t.id,{opacity:e.opacity})}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}setTerrainProviders(e){this.sceneRenderer.setTerrainProviders(e)}setDecorModelProvider(e){this.sceneRenderer.setDecorModelProvider(e)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const e=this.ufoElement.sighting.instrument,t=it.CANVAS_HEIGHT_PX,i=ct.frameWidthPx(e,t);this.frameElement.style.setProperty("--frame-aspect",`${i} / ${t}`)}resizeToStage(){const e=this.frameElement.getBoundingClientRect(),t=Math.max(1,Math.round(e.width)),i=Math.max(1,Math.round(e.height));this.sceneCanvas.width=t,this.sceneCanvas.height=i,this.sceneRenderer.resize(t,i)}async loadStars(){const e=[{magnitudeLimit:id,url:this.getAttribute("star-catalog-src")??pT},{magnitudeLimit:Mo,url:this.getAttribute("deep-star-catalog-src")??mT}],t=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=t>id?Mo:id;const n=await Rn.upTo(e,t);i===this.starCatalogRequest&&(this.starCatalog=n,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=Mo||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const e=this.ufoElement.sighting,t=Ei.gainFor(e.instrument,{fNumber:nt(e,0)?.fNumber,fieldOfViewDeg:gi.fovOf(e,0),exposureSeconds:e.exposure});return hr(gT,t)}updateAstronomy(e){this.ensureStarsDeepEnough(),this.applySceneAt(e);const t=un.windowEndingAt(e,this.exposureSeconds()),i=t.seconds,n=this.degreesPerPixelAt(e),s=mr.instants(i,n),a=Math.max(s,this.ufoElement.exposureTimes(e).length,un.instants(this.ufoElement.sighting.decor,nt(this.ufoElement.sighting,e)?.elevationM??0,t.fromMs,i,n));if(a<=1){this.sceneRenderer.setExposure(1);return}this.sceneRenderer.setExposure(a,o=>this.applySceneAt(t.fromMs+t.ms*o/(a-1),{sky:Math.floor(o*s/a)!==Math.floor((o-1)*s/a),stepMs:t.ms/a}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(e){const t=this.sceneCanvas.height;return t<=0?0:gi.fovOf(this.ufoElement.sighting,e)/t}applySceneAt(e,t){const i=this.ufoElement.sighting;this.setWeather(kt(i,e)),this.sceneRenderer.setInstrument(i.instrument),this.updateMeteorShower(i,e),this.updateLightning(i,e,t!==void 0),this.sceneRenderer.setDecor(i.decor),this.sceneRenderer.setReferences(i.references);const n=nt(i,e),s=nt(i,0),a=kt(i,0),o=Object.fromEntries(Bn(kt(i,e)).map(M=>[M.id,tc(e,i.weatherTrack,a,s,n,M.id)]));this.sceneRenderer.setCloudOffset(tc(e,i.weatherTrack,a,s,n),o),this.sceneRenderer.setObserverPose(n??sd),this.sceneRenderer.setLensOptics(this.lensOpticsAt(e)),this.sceneRenderer.setInstrumentGain(Ei.gainFor(i.instrument,{fNumber:n?.fNumber,fieldOfViewDeg:gi.fovOf(i,e),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0),this.sceneRenderer.setGait(jt.of(i)?.offsetAt(e)??jt.STILL),this.sceneRenderer.updateDecorAnchoring(nt(i,0),n,e),this.sceneRenderer.updateDecorLitState(e,t?.stepMs??0),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng),this.pushPhenomenaAt(e);const l=n?.lat??sd.lat,c=n?.lng??sd.lng,h=zn(i.event.time??{},c,i.event.utcOffsetHours),d={lat:l,lng:c,elevationM:n?.elevationM??0};if(this.pushSatellitesAt(h,e,d),t&&!t.sky)return;if(!h){this.sceneRenderer.setAstronomy(vT);return}const u=new Date(h.getTime()+e),f=Math.max(1,Math.round(.25*this.degreesPerPixelAt(e)/mr.DEG_PER_SECOND*1e3)),p=Math.max(1e-8,this.degreesPerPixelAt(e)*.1),v=`${Math.floor(u.getTime()/f)}|${Math.round(l/p)}|${Math.round(c/p)}|${Math.round(d.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(v===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=v;const m={...Ui("Sun",u,d),magnitude:Fh("Sun",u)},g={...Ui("Moon",u,d),phase:_c(u),magnitude:Fh("Moon",u)},x=a_.map(M=>({body:M,position:Ui(M,u,d),magnitude:Fh(M,u)}));this.sceneRenderer.setAstronomy({sun:m,moon:g,planets:x,comet:this.cometAt(u,d),novae:Ac.appearancesAt(u,d).map(({outburst:M,position:w,magnitude:S})=>({id:M.id,position:w,magnitude:S})),stars:this.starCatalog?{catalog:this.starCatalog,date:u,observer:d}:void 0,frame:{date:u,observer:d}}),this.ufoElement.setSunAltitude(m.altitudeDeg)}pushSatellitesAt(e,t,i){if(this.ensureSatellites(e),!e||!this.satellites){this.sceneRenderer.setSatellites([]);return}const n=new Date(e.getTime()+t),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(e){const t=e?String(e.getTime()):"";if(t===this.satellitesFor)return;this.satellitesFor=t,this.satellites=void 0,this.satellitePassesMemo=void 0;const i=++this.satelliteRequest;if(!e){this.satelliteStatus="none";return}this.satelliteStatus="loading";const n=a=>{i===this.satelliteRequest&&(this.satelliteStatus=a,this.dispatchEvent(new CustomEvent(X1)))},s=Df.tleArchive;(async()=>{if(!await s.covers(e))return n("outside");const[a,o]=await Promise.all([s.at(e),sn(()=>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.updateAstronomy(this.lastTimeMs)}})().catch(()=>n("unavailable"))}get satelliteState(){const e=this.satellites?.snapshot;return{status:this.satelliteStatus,coverage:e?.coverage,credit:e?.credit,creditUrl:e?.creditUrl}}satellitePassesDuring(e){const t=this.satellites,i=this.ufoElement.sighting,n=nt(i,0),s=i.event.place?.[0],a=n?.lat??s?.lat,o=n?.lng??s?.lng;if(!t||a===void 0||o===void 0)return[];const l=zn(i.event.time??{},o,i.event.utcOffsetHours);if(!l)return[];const c=Math.min(Math.max(e,0),4*36e5),h={lat:a,lng:o,elevationM:n?.elevationM??0},d=JSON.stringify([this.satellitesFor,l.getTime(),a,o,h.elevationM,c]);if(this.satellitePassesMemo?.key===d)return this.satellitePassesMemo.passes;const u=Math.max(10,Math.ceil(c/1e3/600)),f=t.passes.passesDuring(l,new Date(l.getTime()+c),h,u);return this.satellitePassesMemo={key:d,passes:f},f}cometAt(e,t){const i=Ql.brightestAt(e,t);if(i)return{id:i.apparition.id,position:i.position,tailEnd:i.tailEnd,magnitude:i.magnitude}}pushPhenomenaAt(e){const t=this.ufoElement.sighting;t!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=t);const i=t.timeline,n=this.ufoElement.canvasElement,s=this.ufoElement.frameShiftPx,a=this.projectionAt(e),o=new Map,l=new Map,c=new Set;for(const p of i.sourceIds){const v=i.getInterpolatedShapeAt(e,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(hn.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)},x=g!==void 0&&Math.abs(g.ndcX)<=1&&Math.abs(g.ndcY)<=1,M=x?this.sceneRenderer.decorDistancesAt(g.ndcX,g.ndcY,p):{};c.add(p),(x||v.aim)&&c.delete(p);const w=v.angular?.widthDeg??a.pxToDeg(v.bounds.width),S=this.sizeEstimateOf(p);S.add(w,M);const _=xo.of(t,p);l.set(p,Di.resolve({hypothesisM:this.distanceHypotheses.get(p),derivedM:_&&w>0?it.distanceMAt(_.widthM,w):void 0,range:S.distanceRangeAt(w),crossing:M}))}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 M=l.get(m);M&&l.set(p,{distanceM:M.distanceM*.999,basis:M.basis});break}this.depths=l;const h=i.sourceIds,d=[];for(const[p,v]of o)d.push({sourceId:p,shape:v,distanceM:l.get(p).distanceM,renderOrder:h.indexOf(p),aim:v.aim,hidden:c.has(p)});const f=(nt(t,e)?.rollDeg??0)+(jt.of(t)?.offsetAt(e)??jt.STILL).rollDeg;this.sceneRenderer.setPhenomena(d,{projection:a,canvasWidthPx:n.width,canvasHeightPx:n.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,n.height)),starPoints:ct.starPointsOf(t.instrument),rollRad:f*Math.PI/180})}setDistanceHypothesis(e,t){t===void 0||!(t>0)?this.distanceHypotheses.delete(e):this.distanceHypotheses.set(e,t),this.updateAstronomy(this.lastTimeMs)}depthOf(e){return this.depths.get(e)}sizeRangeOf(e){return this.sizeEstimateOf(e).sizeRange}distanceRangeAt(e,t){const i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,e);if(!i)return{};const n=i.angular?.widthDeg??this.projectionAt(t).pxToDeg(i.bounds.width);return this.sizeEstimateOf(e).distanceRangeAt(n)}sizeContradictory(e){return this.sizeEstimateOf(e).contradictory}updateMeteorShower(e,t){this.ensureMeteorSchedule(e),this.sceneRenderer.updateMeteors(t)}updateLightning(e,t,i){if(this.ensureLightningSchedule(e),this.sceneRenderer.updateLightning(t),i)return;const n=this.lastLightningT;if(this.lastLightningT=t,n===void 0||t<n||this.ufoElement.playbackState!=="playing")return;const s=this.lightningFlashes.filter(a=>a.t>n&&a.t<=t).pop();s&&kt(e,s.t).storm&&this.handleLightningFlash(s)}ensureLightningSchedule(e){const t=kt(e,0).precipitationIntensity,i=`${this.meteorInputsOf(e)}|${t}`;if(i===this.lightningScheduleFor)return;this.lightningScheduleFor=i;const n=e.event.time,s=e.event.place?.[0],a=n?.year!==void 0?zn(n,s?.lng??0,e.event.utcOffsetHours):void 0,o=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,l=Math.round((a?.getTime()??0)/1e3)+Math.round((s?.lat??0)*1e3)+7;this.lightningFlashes=Qt.schedule({durationMs:o,seed:l,intensity:t}),this.sceneRenderer.setLightning(this.lightningFlashes)}ensureMeteorSchedule(e){const t=this.meteorInputsOf(e);t!==this.meteorScheduleFor&&(this.meteorScheduleFor=t,this.scheduleMeteors(e))}meteorInputsOf(e){const t=e.event.place?.[0],i=e.event.time;return JSON.stringify([t?.lat,t?.lng,i?.year,i?.month,i?.day,i?.hour,i?.minute,i?.second,e.event.utcOffsetHours,e.event.durationSeconds,e.timeline.duration])}scheduleMeteors(e){const t=e.event.place?.[0],i=e.event.time,n=t?.lat!==void 0&&t.lng!==void 0&&i?.year!==void 0?zn(i,t.lng,e.event.utcOffsetHours):void 0;if(!n||t?.lat===void 0||t.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const s={lat:t.lat,lng:t.lng,elevationM:0},a=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,o=Math.round(n.getTime()/1e3)+Math.round(t.lat*1e3),l=Lt.schedule({ratePerHour:Lt.observedRatePerHour(Lt.apexPosition(n,s).altitudeDeg),durationMs:a,velocityKmS:Lt.TYPICAL_VELOCITY_KM_S,seed:o}),c=Sa.activeAt(n).map(d=>{const u=Sa.radiantPosition(d.shower,n,s);return{entry:d,position:u,rate:Sa.observedRatePerHour(d.zhr,u.altitudeDeg,d.shower.populationIndex)}}).sort((d,u)=>u.rate-d.rate)[0];if(!c||c.rate<=0){this.sceneRenderer.setMeteorShower(l,0,0);return}const h=pr.schedule({ratePerHour:c.rate,durationMs:a,velocityKmS:c.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...l],c.position.altitudeDeg,c.position.azimuthDeg)}meteorByRank(e){this.ensureMeteorSchedule(this.ufoElement.sighting);const t=[...this.sceneRenderer.meteorSchedule].filter(s=>s.t+s.durationMs<=this.ufoElement.seekableDuration).sort((s,a)=>a.brightness-s.brightness);if(t.length===0)return;const i=t[e%t.length],n=this.sceneRenderer.meteorMidpoint(i);if(n)return{t:Math.round(i.t+i.durationMs*.45),...n}}lensOpticsAt(e){const t=this.ufoElement.sighting,i=t.instrument,n=i.frame,s=nt(t,e),a=s?.fNumber??i.fNumber;if(!n||a===void 0)return;const o=ct.focalLengthMmFor(i,gi.fovOf(t,e));if(o!==void 0)return{focalLengthMm:o,fNumber:a,focusDistance:s?.focusDistanceM??0,frameHeightMm:n.heightMm}}projectionAt(e){const t=this.ufoElement.sighting;return gn.of(t.instrument,it.CANVAS_HEIGHT_PX,gi.fovOf(t,e))}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new rT,this.sizeEstimates.set(e,t)),t}}const Gu="rr0-scene";function yT(){Cc(),customElements.get(Gu)||customElements.define(Gu,Df)}class bT{constructor(e,t){this.timeline=e,this.clock=t}currentPointer=null;shapePrototype=null;sourceId="";start(e,t){this.sourceId=e,this.shapePrototype=t,this.currentPointer=null,this.clock.start(i=>this.recordSample(i))}onPointerMove(e,t){this.currentPointer={x:e,y:t}}stop(){this.clock.stop()}recordSample(e){if(!this.currentPointer||!this.shapePrototype)return;const t=cg(this.shapePrototype,this.currentPointer.x,this.currentPointer.y);this.timeline.addKeyframe(e,[{sourceId:this.sourceId,shape:t}])}}class wT{constructor(e){this.intervalMs=e}rafId=null;startTime=0;lastTick=0;start(e){this.startTime=performance.now(),this.lastTick=0;const t=()=>{const i=performance.now()-this.startTime;i-this.lastTick>=this.intervalMs&&(this.lastTick=i,e(i)),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}stop(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}}const MT=[{id:"echo",name:{en:"the Echo balloons",fr:"les ballons Echo"},from:"1960-08-12",to:"1969-06-07",peakMagnitude:-1,note:"Echo 1 and 2 were 30- and 40-metre reflective balloons, as bright as the brightest stars and moving slowly enough to be watched — deliberately visible, widely announced in newspapers, and the first objects most people ever saw crossing the night sky. They fall squarely inside the sighting waves this project reconstructs."},{id:"iridium-flares",name:{en:"the Iridium flares",fr:"les flashes d'Iridium"},from:"1997-05-05",to:"2019-12-27",peakMagnitude:-8,note:"The original Iridium satellites carried flat, mirror-finish antennas that threw a sunbeam a few kilometres wide across the ground: a still point of sky flaring to magnitude -8 over five seconds and vanishing again. Nothing else in the sky does that."},{id:"iss",name:{en:"the International Space Station",fr:"la Station spatiale internationale"},from:"1998-11-20",peakMagnitude:-5.9,note:"Since its first module, and much brighter as it grew: at its best it outshines everything in the sky but the Sun and the Moon, crossing in a straight silent line in about four minutes."},{id:"starlink-trains",name:{en:"the Starlink trains",fr:"les trains de Starlink"},from:"2019-05-24",peakMagnitude:1,note:"In the days after a launch, satellites still bunched in their deployment string cross as an evenly spaced line of lights — the most reported 'formation of UFOs' of the era. They spread out within weeks, so a train is a fact about the days after a launch rather than about the year."}],xT=23493,Wm=[2,3,2,1,2,5,4,6,5,6,6,6,6,6,6,6,9,9,9,9,9,9,14,14,15,16,16,16,16,16,18,22,25,24,29,28,29,33,34,35,40,40,42,42,43,46,48,48,49,53,53,54,58,61,70,70,74,78,79,83,92,92,99,97,101,102,109,115,126,125,123,125,127,130,139,153,157,156,161,156,165,174,193,193,201,203,212,215,224,244,255,263,262,281,293,307,312,327,339,336,343,353,359,369,386,396,405,410,421,419,424,434,443,450,460,480,492,504,509,516,519,524,527,530,527,535,543,549,564,571,573,576,582,584,600,600,608,618,625,632,637,642,648,654,661,667,669,667,671,671,697,692,703,697,710,714,724,731,747,755,764,770,782,802,801,815,819,837,846,856,878,881,877,900,906,907,917,932,932,936,954,973,989,986,991,990,1002,1009,1021,1024,1040,1038,1058,1078,1098,1092,1094,1099,1122,1132,1140,1151,1154,1161,1176,1185,1202,1206,1227,1228,1243,1265,1281,1288,1296,1325,1328,1336,1354,1373,1375,1393,1398,1411,1432,1457,1462,1476,1487,1485,1506,1509,1521,1524,1537,1543,1563,1586,1598,1614,1621,1620,1640,1658,1660,1673,1670,1686,1708,1715,1726,1726,1745,1749,1767,1774,1790,1798,1803,1805,1815,1818,1819,1820,1833,1822,1821,1819,1838,1835,1845,1841,1851,1869,1865,1868,1871,1870,1879,1882,1886,1900,1899,1908,1921,1928,1954,1966,1976,1986,1999,2007,2015,2030,2036,2057,2067,2072,2077,2088,2101,2106,2112,2119,2127,2142,2171,2176,2203,2226,2242,2241,2244,2254,2263,2284,2300,2320,2327,2345,2364,2367,2402,2423,2425,2434,2443,2461,2476,2495,2505,2520,2531,2535,2556,2567,2599,2608,2625,2639,2660,2663,2668,2681,2695,2702,2709,2719,2720,2738,2746,2763,2778,2788,2796,2807,2822,2831,2831,2853,2863,2866,2883,2892,2895,2921,2919,2937,2941,2947,2964,2987,2992,2987,2995,3002,3021,3025,3026,3036,3052,3049,3059,3077,3075,3083,3086,3107,3123,3124,3146,3155,3168,3179,3204,3205,3211,3233,3252,3253,3276,3287,3294,3293,3297,3314,3326,3335,3338,3355,3362,3358,3365,3364,3376,3375,3382,3418,3429,3432,3455,3463,3483,3490,3502,3509,3521,3532,3542,3544,3553,3571,3580,3588,3596,3603,3633,3639,3649,3655,3660,3670,3699,3699,3707,3723,3747,3752,3754,3766,3772,3778,3781,3798,3815,3814,3824,3832,3853,3859,3879,3885,3899,3912,3910,3924,3937,3951,3951,3961,3963,3961,3976,3977,3988,4004,4018,4025,4047,4074,4086,4108,4133,4136,4159,4168,4182,4192,4200,4215,4230,4239,4257,4678,4698,4694,4713,4719,4739,4750,4756,4764,4771,4788,4792,4790,4809,4821,4829,4834,4836,4843,4853,4863,4872,4881,4890,4898,4901,4897,4895,4884,4886,4886,4894,4897,4905,4905,4909,4907,4925,4918,4920,4929,4925,4928,4936,4943,4944,4951,4955,4952,4974,4976,4975,4981,4994,4997,5022,5023,5032,5043,5048,5051,5066,5062,5068,5075,5082,5082,5098,5102,5110,5113,5119,5123,5138,5138,5145,5149,5157,5165,5166,5169,5178,5183,5190,5192,5203,5204,5207,5214,5228,5234,5245,5249,5256,5262,5275,5278,5305,5303,5315,5321,5348,5358,5369,5369,5372,5385,5402,5409,5427,5429,5429,5439,5456,5464,5481,5485,5494,5509,5520,5526,5543,5555,5568,5575,5585,5596,5602,5620,5627,5644,5647,5660,5678,5680,5684,5692,5700,5711,5727,5733,5736,5756,5776,5797,5805,5804,5807,5800,5808,5814,5822,5839,5856,5869,5889,5902,5919,5921,5936,5937,5936,5957,5961,5975,5981,6002,6015,6027,6035,6042,6059,6062,6080,6081,6092,6097,6106,6127,6129,6198,6227,6231,6243,6249,6262,6255,6279,6304,6315,6326,6330,6334,6361,6358,6359,6379,6381,6389,6388,6404,6404,6443,6465,6473,6497,6500,6513,6524,6532,6538,6578,6572,6576,6584,6582,6608,6639,6656,6761,6764,6768,6772,6836,6905,6916,6925,6951,6984,7009,7072,7092,7110,7122,7140,7148,7170,7168,7180,7194,7247,7374,7391,7393,7382,7425,7485,7530,7568,7587,7602,7602,7715,7771,7900,8004,8103,8153,8162,8296,8319,8437,8566,8746,8860,8913,9128,9275,9585,9739,10014,10123,10167,10203,10288,10323,10398,10544,10721,10883,11044,11157,11442,11515,11787,12070,12269,12468,12484,12619,12883,13008,13264,13317,13549,13859,14049,14175,14360,14498,14687,14843,14984,15093,15279,15431,15623,15741,15788,15966,16025,16132,16419,16568,16791,16892,17060,17269,17598,17959,18194,18482,18804,19136,19564,19990,20249,20509,20943,21248,21539,21845,22196,22412];class Pn{static FIRST_ORBIT="1957-10-04";static EARTH_RADIUS_KM=6371;static LOW_ORBIT_KM=500;static shadowHeightKm(e){if(e>=0)return 0;const t=-e*Math.PI/180;return Pn.EARTH_RADIUS_KM*(1/Math.cos(t)-1)}static isLitOverhead(e,t){return e>Pn.shadowHeightKm(t)}static classesAt(e){const t=e.getTime();return MT.filter(i=>{const n=Date.parse(`${i.from}T00:00:00Z`),s=i.to===void 0?1/0:Date.parse(`${i.to}T23:59:59Z`);return t>=n&&t<=s})}static trackedInOrbitAt(e){const t=e.getUTCFullYear()*12+e.getUTCMonth()-xT;if(!(t<0))return Wm[Math.min(t,Wm.length-1)]}static visibilityAt(e,t){const i=Ui("Sun",e,t).altitudeDeg;return{sunAltitudeDeg:i,shadowHeightKm:Pn.shadowHeightKm(i),lowOrbitLit:Pn.isLitOverhead(Pn.LOW_ORBIT_KM,i),classes:Pn.classesAt(e),trackedObjects:Pn.trackedInOrbitAt(e),anythingInOrbit:e.getTime()>=Date.parse(`${Pn.FIRST_ORBIT}T00:00:00Z`)}}}class rt{static COARSE_STEP_DEG=10;static FINE_STEP_DEG=2;static FINE_SPAN_DEG=10;static LOWEST_DEG=5;static THRESHOLD_CONTRAST=.5;static CONE_SEPARATION_DEG=60;galaxy=new Qe;dust=new Pt;assess(e,t){const i=Ui("Sun",e,t),n=Ui("Moon",e,t),s={altitudeDeg:n.altitudeDeg,phaseAngleDeg:Be.phaseAngleOf(_c(e).illuminatedFraction)},a=Ki.galactic(e,t),o=rt.unit(a.centre),l=rt.unit(a.rotation),c=rt.unit(a.pole),h=rt.unit(Ki.eclipticPole(e,t)),d=rt.unit(i),u=rt.unit(n),f=rt.normalize(rt.reject(d,h));let p,v,m=0;const g=(x,M)=>{const w=rt.unit({altitudeDeg:x,azimuthDeg:M}),S=rt.between(w,d),_=Be.magPerArcsec2({altitudeDeg:i.altitudeDeg,separationDeg:S},{...s,separationDeg:rt.between(w,u)},x);_>m&&(m=_);const D=us.fromMagPerArcsec2(_),y=10**(-.4*Be.EXTINCTION_PER_AIR_MASS*(Be.airMass(x)-1)),T=this.galaxy.surfaceBrightnessS10(Math.atan2(rt.dot(w,l),rt.dot(w,o))*180/Math.PI,Math.asin(Math.max(-1,Math.min(1,rt.dot(w,c))))*180/Math.PI)*y;p=rt.better(p,T,D,_,x,M,S);const A=Math.max(-1,Math.min(1,rt.dot(w,h))),I=rt.normalize(rt.reject(w,h)),R=this.dust.surfaceBrightnessS10(rt.between(I,f),Math.asin(A)*180/Math.PI)*y;v=rt.better(v,R,D,_,x,M,S)};for(let x=rt.LOWEST_DEG;x<=90;x+=rt.COARSE_STEP_DEG)for(let M=0;M<360;M+=rt.COARSE_STEP_DEG)g(x,M);for(const x of[p,v]){if(!x)continue;const M=rt.FINE_SPAN_DEG,w=rt.FINE_STEP_DEG;for(let S=x.altitudeDeg-M;S<=x.altitudeDeg+M;S+=w)if(!(S<rt.LOWEST_DEG||S>90))for(let _=x.azimuthDeg-M;_<=x.azimuthDeg+M;_+=w)g(S,(_+360)%360)}return{milkyWay:p&&p.contrast>=rt.THRESHOLD_CONTRAST?p:void 0,zodiacal:v&&v.contrast>=rt.THRESHOLD_CONTRAST?v:void 0,darkestSkyMagPerArcsec2:m}}static better(e,t,i,n,s,a,o){const l=t/i;return e&&e.contrast>=l?e:{contrast:l,altitudeDeg:s,azimuthDeg:a,magPerArcsec2:us.toMagPerArcsec2(t),skyMagPerArcsec2:n,sunSeparationDeg:o}}static unit(e){const t=e.altitudeDeg*Math.PI/180,i=e.azimuthDeg*Math.PI/180,n=Math.cos(t);return[n*Math.sin(i),Math.sin(t),-n*Math.cos(i)]}static dot(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}static between(e,t){return Math.acos(Math.max(-1,Math.min(1,rt.dot(e,t))))*180/Math.PI}static reject(e,t){const i=rt.dot(e,t);return[e[0]-i*t[0],e[1]-i*t[1],e[2]-i*t[2]]}static normalize(e){const t=Math.hypot(...e)||1;return[e[0]/t,e[1]/t,e[2]/t]}}const ST=.5,Gl=40,ET=4e5,Js=Math.PI/180,jr=180/Math.PI;class Ni{static localDirection(e,t,i,n=new P){const s=Math.tan(t/2*Js);return n.set((e.u*2-1)*s*i,(1-e.v*2)*s,-1).normalize()}static picturePoint(e,t,i){if(e.z>=0)return;const n=Math.tan(t/2*Js),s=e.x/-e.z/(n*i),a=e.y/-e.z/n;return{u:(s+1)/2,v:(1-a)/2}}static worldDirection(e,t=new P){const i=e.azimuthDeg*Js,n=e.altitudeDeg*Js;return t.set(Math.sin(i)*Math.cos(n),Math.sin(n),-Math.cos(i)*Math.cos(n))}static aimOf(e){const t=Math.hypot(e.x,e.z);return{azimuthDeg:(Math.atan2(e.x,-e.z)*jr+360)%360,altitudeDeg:Math.atan2(e.y,t)*jr}}static rotationOf(e){const t=new _t;return t.rotation.set(e.pitchDeg*Js,-e.headingDeg*Js,-(e.rollDeg??0)*Js,"YXZ"),t.quaternion.clone()}static anglesOf(e){const t=new Yn().setFromQuaternion(e,"YXZ"),i=(-t.y*jr%360+360)%360,n=-t.z*jr;return{headingDeg:i,pitchDeg:t.x*jr,rollDeg:Math.abs(n)<1e-9?0:n}}static worldDirectionOf(e,t,i,n=new P){return this.localDirection(e,t.fovDeg,i,n).applyQuaternion(this.rotationOf(t))}static picturePointOf(e,t,i){const n=e.clone().applyQuaternion(this.rotationOf(t).invert()),s=this.picturePoint(n,t.fovDeg,i);if(!(!s||s.u<0||s.u>1||s.v<0||s.v>1))return s}static solve(e,t,i,n=e.length>=3){if(e.length<2)return;if(!n)return this.solveAtField(e,t,i);let s=1,a=179;const o=(Math.sqrt(5)-1)/2;let l=a-o*(a-s),c=s+o*(a-s),h=this.solveAtField(e,t,l),d=this.solveAtField(e,t,c);for(let f=0;f<60&&a-s>1e-4;f++){if(!h||!d)return;h.residualDeg<d.residualDeg?(a=c,c=l,d=h,l=a-o*(a-s),h=this.solveAtField(e,t,l)):(s=l,l=c,h=d,c=s+o*(a-s),d=this.solveAtField(e,t,c))}return h&&d?h.residualDeg<d.residualDeg?h:d:h??d}static solveAtField(e,t,i){const n=e.map(c=>this.localDirection(c.picture,i,t)),s=e.map(c=>this.worldDirection(c.scene)),a=this.triad(n,s);if(!a)return;const o=this.refine(a,n,s);return{registration:{...this.anglesOf(o),fovDeg:i},residualDeg:this.residualDeg(o,n,s)}}static triad(e,t){let i=0,n=1,s=-1;for(let h=0;h<e.length;h++)for(let d=h+1;d<e.length;d++){const u=e[h].clone().cross(e[d]).lengthSq();u>s&&(s=u,i=h,n=d)}if(s<1e-12)return;const a=(h,d)=>{const u=h.clone().normalize(),f=h.clone().cross(d).normalize(),p=f.clone().cross(u);return new He().set(u.x,p.x,f.x,u.y,p.y,f.y,u.z,p.z,f.z)},o=a(e[i],e[n]),c=a(t[i],t[n]).multiply(o.transpose());return new qn().setFromRotationMatrix(new Ye().setFromMatrix3(c))}static refine(e,t,i){const n=e.clone(),s=new P;for(let a=0;a<20;a++){const o=new He().set(0,0,0,0,0,0,0,0,0),l=o.elements,c=new P;for(let f=0;f<t.length;f++){s.copy(t[f]).applyQuaternion(n);const p=s,v=[[0,p.z,-p.y],[-p.z,0,p.x],[p.y,-p.x,0]],m=[i[f].x-p.x,i[f].y-p.y,i[f].z-p.z];for(let g=0;g<3;g++){for(let x=0;x<3;x++)for(let M=0;M<3;M++)l[x*3+g]+=v[M][g]*v[M][x];c.setComponent(g,c.getComponent(g)+v[0][g]*m[0]+v[1][g]*m[1]+v[2][g]*m[2])}}for(let f=0;f<3;f++)l[f*3+f]+=1e-9;const h=c.applyMatrix3(o.invert()),d=h.length();if(d<1e-12)break;const u=new qn().setFromAxisAngle(h.normalize(),d);if(n.premultiply(u).normalize(),d<1e-10)break}return n}static residualDeg(e,t,i){let n=0;const s=new P;for(let a=0;a<t.length;a++){s.copy(t[a]).applyQuaternion(e);const o=s.angleTo(i[a])*jr;n+=o*o}return Math.sqrt(n/t.length)}}const Xm=6371e3,no=Math.PI/180;class da{constructor(e=t=>fetch(t).then(i=>{if(!i.ok)throw new Error(`${t}: HTTP ${i.status}`);return i.json()})){this.fetchJson=e}static API="https://api.panoramax.xyz/api";static CREDIT="Panoramax";static CREDIT_URL="https://panoramax.fr/";async nearby(e,t,i=300,n=50){const s=i/111320,a=i/(111320*Math.cos(e*no)),o=[t-a,e-s,t+a,e+s].map(h=>h.toFixed(6)).join(",");return((await this.fetchJson(`${da.API}/search?bbox=${o}&limit=${n}`)).features??[]).map(h=>this.picture(h,e,t)).filter(h=>h!==void 0&&h.distanceM<=i).sort((h,d)=>h.distanceM-d.distanceM)}picture(e,t,i){const[n,s]=e.geometry.coordinates,a=e.assets.sd?.href??e.assets.hd?.href;if(!a)return;const{distanceM:o,bearingDeg:l}=da.offset(t,i,s,n),c=e.properties,h=c["pers:interior_orientation"]?.field_of_view,d=(c.providers??[]).map(f=>f.name).filter(f=>!!f),u=c.license??"CC-BY-SA-4.0";return{id:e.id,lat:s,lng:n,distanceM:o,bearingDeg:l,azimuthDeg:c["view:azimuth"],panorama:h!==void 0&&h>=360,takenAt:c.datetime??"",src:a,srcFull:e.assets.hd?.href,credit:`${da.CREDIT}${d.length?` — ${d.join(", ")}`:""} (${u})`,creditUrl:`${da.API.replace(/\/api$/,"")}/#focus=pic&pic=${e.id}`}}static offset(e,t,i,n){const s=(i-e)*no*Xm,a=(n-t)*no*Xm*Math.cos((e+i)/2*no);return{distanceM:Math.hypot(a,s),bearingDeg:(Math.atan2(a,s)/no+360)%360}}}const Vl=36e5,qm=25;class rd{constructor(e){this.provider=e}async infer(e){const t=this.questionOf(e);if(!t)return{status:"incomplete"};const{origin:i,start:n}=t,s=Ea(e.event)??0,a=this.sampleTimings(e,n,s);let o;try{o=await this.provider.getWeather({points:a.map(l=>this.pointAt(e,l,i))})}catch{return{status:"failed",at:n}}return o?{status:"inferred",at:n,source:o.source,keyframes:o.samples.map((l,c)=>({t:a[c].t,weather:l.weather}))}:{status:"unavailable",at:n}}applyTo(e,t){if(!(t.status!=="inferred"||!t.keyframes||!t.source)){e.weatherTrack.clear();for(const i of t.keyframes)e.weatherTrack.addKeyframe(i.t,i.weather);e.weatherSource=t.source}}sampleTimes(e,t){const i=[e],n=e.getTime()+t;let s=Math.floor(e.getTime()/Vl)*Vl+Vl;for(;s<=n&&i.length<qm;)i.push(new Date(s)),s+=Vl;return t>0&&i[i.length-1].getTime()!==n&&i.length<qm&&i.push(new Date(n)),i}sampleTimings(e,t,i){const n=e.timeline.duration>0?e.timeline.duration:i;return i<=0||n<=0?[{time:t,t:0}]:this.sampleTimes(t,i).map(s=>{const a=(s.getTime()-t.getTime())/i;return{time:s,t:Math.round(n*Math.max(0,Math.min(1,a)))}})}canInfer(e){return this.questionOf(e)!==void 0}questionOf(e){const t=this.originOf(e);if(!t)return;const i=e.event.time;if(i?.year===void 0||i.month===void 0||i.day===void 0)return;const n=zn(i,t.lng,e.event.utcOffsetHours);return n?{origin:t,start:n}:void 0}originOf(e){const t=nt(e,0),i=e.event.place?.[0],n=t?.lat??i?.lat,s=t?.lng??i?.lng;return n===void 0||s===void 0?void 0:{lat:n,lng:s}}pointAt(e,t,i){const n=nt(e,t.t);return{lat:n?.lat??i.lat,lng:n?.lng??i.lng,time:t.time}}}const _T=Date.UTC(1940,0,1),Ym=36e5,Km=.25,TT=.7,AT=.45,IT=.1,DT=2,CT=.3,RT=.2,PT=8,ad=.125,LT=.05,$m=125,Zm=100,Jm=2500,od=3500,ld=8e3,kT=95,NT=99,OT=[96,99],FT=["cloud_cover","cloud_cover_low","cloud_cover_mid","cloud_cover_high","precipitation","snowfall","weather_code","wind_speed_10m","wind_direction_10m","temperature_2m","dew_point_2m"];class q1{fetchImpl;baseUrl;cache=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.baseUrl=e.baseUrl??"https://archive-api.open-meteo.com/v1/archive"}async getWeather(e){if(e.points.length===0)return;const t=e.points.map(f=>f.time.getTime()),i=Math.min(...t);if(i<_T)return;const n=new Map;for(const f of e.points){const p=this.cellKey(f);n.has(p)||n.set(p,{lat:f.lat,lng:f.lng,index:n.size})}const s=this.requestUrl([...n.values()],new Date(i),new Date(Math.max(...t))),a=this.cache.get(s);if(a)return a;const o=await this.fetchImpl(s);if(!o.ok)throw new Error(`Open-Meteo HTTP ${o.status}`);const l=await o.json(),c=Array.isArray(l)?l:[l];if(c.length<n.size||c.some(f=>f.error||!f.hourly))return;const h={id:"era5",name:"ERA5 (Open-Meteo)",url:s},d=e.points.map(f=>this.sampleAt(c[n.get(this.cellKey(f)).index].hourly,f.time));if(d.some(f=>f===void 0))return;const u={samples:d,source:h};return this.cache.set(s,u),u}cellKey(e){return`${Math.round(e.lat/Km)},${Math.round(e.lng/Km)}`}requestUrl(e,t,i){const n=new URLSearchParams({latitude:e.map(s=>s.lat).join(","),longitude:e.map(s=>s.lng).join(","),start_date:this.isoDate(t),end_date:this.isoDate(i),hourly:FT.join(","),wind_speed_unit:"ms",timezone:"UTC"});return`${this.baseUrl}?${n}`}isoDate(e){return e.toISOString().slice(0,10)}sampleAt(e,t){const i=this.recordAt(e,t);return i&&{time:t,weather:this.toWeather(i)}}recordAt(e,t){const i=e.time.map(o=>Date.parse(`${o}Z`)),n=t.getTime();if(i.length===0||n<i[0]-Ym||n>i[i.length-1]+Ym)return;if(n<=i[0])return this.recordFrom(e,0);if(n>=i[i.length-1])return this.recordFrom(e,i.length-1);let s=0;for(;s+1<i.length&&i[s+1]<=n;)s++;const a=i[s+1]-i[s];return this.blendRecords(this.recordFrom(e,s),this.recordFrom(e,s+1),a>0?(n-i[s])/a:0)}recordFrom(e,t){const i={cloudCover:e.cloud_cover[t]/100,cloudCoverLow:e.cloud_cover_low[t]/100,cloudCoverMid:e.cloud_cover_mid[t]/100,cloudCoverHigh:e.cloud_cover_high[t]/100,precipitationMm:e.precipitation[t],snowfallCm:e.snowfall[t],weatherCode:e.weather_code[t],windSpeedMs:e.wind_speed_10m[t],windFromDeg:e.wind_direction_10m[t],temperatureC:e.temperature_2m[t],dewPointC:e.dew_point_2m[t]};return Object.values(i).some(n=>n===void 0||Number.isNaN(n))?void 0:i}blendRecords(e,t,i){if(!e||!t)return e??t;const n=(a,o)=>a+(o-a)*i,s=((t.windFromDeg-e.windFromDeg)%360+540)%360-180;return{cloudCover:n(e.cloudCover,t.cloudCover),cloudCoverLow:n(e.cloudCoverLow,t.cloudCoverLow),cloudCoverMid:n(e.cloudCoverMid,t.cloudCoverMid),cloudCoverHigh:n(e.cloudCoverHigh,t.cloudCoverHigh),precipitationMm:n(e.precipitationMm,t.precipitationMm),snowfallCm:n(e.snowfallCm,t.snowfallCm),weatherCode:i<.5?e.weatherCode:t.weatherCode,windSpeedMs:n(e.windSpeedMs,t.windSpeedMs),windFromDeg:((e.windFromDeg+s*i)%360+360)%360,temperatureC:n(e.temperatureC,t.temperatureC),dewPointC:n(e.dewPointC,t.dewPointC)}}cloudLayersFrom(e){return[{id:"record-low",type:"unknown",baseM:Math.round(this.clamp($m*(e.temperatureC-e.dewPointC),Zm,Jm)),thicknessM:650,coverage:this.clamp(e.cloudCoverLow,0,1),sizeM:1400,density:1},{id:"record-mid",type:"unknown",baseM:od,thicknessM:800,coverage:this.clamp(e.cloudCoverMid,0,1),sizeM:2500,density:1},{id:"record-high",type:"cirrus",baseM:ld,thicknessM:400,coverage:this.clamp(e.cloudCoverHigh,0,1),sizeM:2200,density:.35}]}toWeather(e){const t=e.weatherCode>=kT&&e.weatherCode<=NT,i=this.precipitationTypeFrom(e);return{cloudLayers:this.cloudLayersFrom(e),cloudCover:this.clamp(e.cloudCover,0,1),cloudDarkness:this.cloudDarknessFrom(e,t),cloudBaseM:this.cloudBaseFrom(e),highCloudCover:e.cloudCoverHigh,lowerCloudCover:Math.max(e.cloudCoverLow,e.cloudCoverMid),relativeHumidity:Math.round(ur.relativeHumidity(e.temperatureC,e.dewPointC)*100)/100,precipitationType:i,precipitationIntensity:i==="none"?0:this.clamp(Math.sqrt(e.precipitationMm/PT),0,1),windDirectionDeg:(e.windFromDeg+180)%360,windSpeed:e.windSpeedMs,storm:t}}precipitationTypeFrom(e){return e.snowfallCm>0?"snow":OT.includes(e.weatherCode)?"hail":e.precipitationMm>0?"rain":"none"}cloudDarknessFrom(e,t){const i=e.cloudCoverLow+e.cloudCoverMid+e.cloudCoverHigh;if(i<=0)return 0;const n=(TT*e.cloudCoverLow+AT*e.cloudCoverMid+IT*e.cloudCoverHigh)/i,s=Math.min(1,e.precipitationMm/DT);return this.clamp(n+CT*s+(t?RT:0),0,1)}cloudBaseFrom(e){if(e.cloudCover<LT)return;const t=this.clamp($m*(e.temperatureC-e.dewPointC),Zm,Jm);if(e.cloudCoverLow>=ad)return Math.round(t);if(e.cloudCoverMid>=ad)return od;if(e.cloudCoverHigh>=ad)return ld;const i=Math.max(e.cloudCoverLow,e.cloudCoverMid,e.cloudCoverHigh);if(!(i<=0))return i===e.cloudCoverLow?Math.round(t):i===e.cloudCoverMid?od:ld}clamp(e,t,i){return Math.max(t,Math.min(i,e))}}function UT(){return new q1}const BT=5;class Y1{attribution={text:"© OpenStreetMap",url:"https://osm.org/copyright"};fetchImpl;baseUrl;reverseUrl;cache=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.baseUrl=e.baseUrl??"https://nominatim.openstreetmap.org/search",this.reverseUrl=e.reverseUrl??"https://nominatim.openstreetmap.org/reverse"}async reverse(e,t,i={}){const n=new URLSearchParams({lat:String(e),lon:String(t),format:"jsonv2"});i.language&&n.set("accept-language",i.language);const s=`${this.reverseUrl}?${n}`,a=this.cache.get(s);if(a)return a[0];const o=await this.fetchImpl(s,{signal:i.signal});if(!o.ok)throw new Error(`Nominatim HTTP ${o.status}`);const l=await o.json(),c=l.error?void 0:this.toMatch(l);return this.cache.set(s,c?[c]:[]),c}async search(e,t={}){const i=e.trim();if(i==="")return[];const n=this.requestUrl(i,t),s=this.cache.get(n);if(s)return s;const a=await this.fetchImpl(n,{signal:t.signal});if(!a.ok)throw new Error(`Nominatim HTTP ${a.status}`);const o=await a.json(),l=(Array.isArray(o)?o:[]).map(c=>this.toMatch(c)).filter(c=>c!==void 0);return this.cache.set(n,l),l}requestUrl(e,t){const i=new URLSearchParams({q:e,format:"jsonv2",limit:String(t.limit??BT)});return t.language&&i.set("accept-language",t.language),`${this.baseUrl}?${i}`}toMatch(e){const t=e.display_name??e.name,i=this.coordinate(e.lat),n=this.coordinate(e.lon);return t&&i!==void 0&&n!==void 0?{name:t,lat:i,lng:n}:void 0}coordinate(e){if(e===void 0||e.trim()==="")return;const t=Number(e);return Number.isFinite(t)?t:void 0}}function zT(){return new Y1}const HT=[{id:"nominatim",name:"Nominatim",credit:"© OpenStreetMap",creditUrl:"https://osm.org/copyright",create:()=>new Y1}],GT=[{id:"era5",name:"ERA5 (Open-Meteo)",credit:"© Copernicus/ECMWF",creditUrl:"https://open-meteo.com/en/docs/historical-weather-api",create:()=>new q1}];class VT{attribution;fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis);const t=e.year??2024;this.tileUrlTemplate=`https://tiles.maps.eox.at/wmts/1.0.0/s2cloudless-${t}_3857/default/g/{z}/{y}/{x}.jpg`,this.attribution=`EOxCloudless https://cloudless.eox.at by EOX IT Services GmbH (Contains modified Copernicus Sentinel data ${t})`}async getImageryTexture(e,t){return Mg(e,t,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}const cd=[{id:"aws-terrarium",name:"AWS Terrain Tiles",credit:"© AWS Open Data (SRTM, ETOPO1)",creditUrl:"https://registry.opendata.aws/terrain-tiles/",create:()=>new wg}],jm=[{id:"esri-world",name:"Esri World Imagery",credit:"Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community",creditUrl:"https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9",create:()=>new xg},{id:"eox-s2cloudless",name:"EOX Sentinel-2 cloudless",credit:"EOxCloudless by EOX IT Services GmbH (contains modified Copernicus Sentinel data)",creditUrl:"https://cloudless.eox.at",create:()=>new VT}];class Cf{constructor(e){this.provider=e}static SPAN_DEG=.002;async at(e,t){const i=Cf.SPAN_DEG;try{const s=(await this.provider.getElevationGrid({south:e-i,north:e+i,west:t-i,east:t+i},{width:2,height:2})).heights[0];return Number.isFinite(s)?s:void 0}catch{return}}}class WT{available(){const e=Intl.supportedValuesOf;return e?[...e.call(Intl,"timeZone")].sort():[]}offsetHoursAt(e,t){if(t.year===void 0)return;const i=Date.UTC(t.year,(t.month??1)-1,t.day??1,t.hour??12,t.minute??0,t.second??0),n=this.zoneOffsetHours(e,new Date(i));if(n!==void 0)return this.zoneOffsetHours(e,new Date(i-n*36e5))??n}zoneOffsetHours(e,t){let i;try{i=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).formatToParts(t).find(s=>s.type==="timeZoneName")?.value??""}catch{return}const n=/^GMT(?:([+-])(\d{2}):(\d{2}))?$/.exec(i);if(n)return n[1]?(n[1]==="-"?-1:1)*(Number(n[2])+Number(n[3])/60):0}}function Qr(r,e){return r.find(t=>t.id===e)??r[0]}class XT{constructor(e="https://api.open-meteo.com/v1/forecast"){this.endpoint=e}async zoneAt(e,t){const i=new URL(this.endpoint);i.searchParams.set("latitude",String(e)),i.searchParams.set("longitude",String(t)),i.searchParams.set("timezone","auto"),i.searchParams.set("forecast_days","1");try{const n=await fetch(i.toString());if(!n.ok)return;const s=await n.json();return s.timezone&&s.timezone!=="GMT"?s.timezone:void 0}catch{return}}}const qT=[{id:"open-meteo",name:"Open-Meteo",credit:"© Open-Meteo",creditUrl:"https://open-meteo.com/en/docs",create:()=>new XT}],YT={color:"Color",transparency:"Transparency",halo:"Halo",blur:"Blur",brightness:"Brilliance",shapeTitle:"Name",utcOffset:"Time zone",cloudBase:"Cloud base",elevation:"Altitude",heightAboveGround:"Height above ground",duration:"Duration",placeName:"Place",latitude:"Latitude",longitude:"Longitude",heading:"Heading",pitch:"Tilt",roll:"Roll",observationTime:"Observation start",observationEndTime:"Observation end",assessmentGroup:"Assessment",assessmentNames:{coverage:"Witness info"},assessmentVerdicts:{"hynek.nl":"NL — nocturnal light","hynek.dd":"DD — daylight disc","hynek.rv":"RV — radar-visual","hynek.ce1":"CE1 — close encounter","hynek.ce2":"CE2 — with a physical trace","hynek.ce3":"CE3 — with entities"},witnessGroup:"Witness",witnessId:"ID",witnessTitle:"Title",witnessLastName:"Last name",witnessFirstNames:"First names",caseId:"Case ID",tags:"Tags",cloudCover:"Cloud cover",highCloudCover:"Ice cloud (cirrus)",focalLength:"Focal length",fieldOfView:"Field of view",aperture:"Aperture",exposure:"Exposure",focusDistance:"Focused at",iceCrystalAlignment:"Crystal alignment",cloudDarkness:"Cloud darkness",precipitationType:"Precipitation",precipitationNone:"None",precipitationRain:"Rain",precipitationSnow:"Snow",precipitationHail:"Hail",precipitationIntensity:"Intensity",windDirection:"Wind direction",windSpeed:"Wind speed",storm:"Storm",cloudsGroup:"Clouds",precipitationGroup:"Precipitation",windGroup:"Wind",soundKind:"Sound",soundNone:"None (silent)",soundHum:"Hum",soundWhistle:"Whistle",soundRumble:"Rumble",soundCrackle:"Crackle",soundVolume:"Loudness",soundPitch:"Pitch",soundSrc:"Recording",instrument:"Observed through",decorAircraft:"Aircraft",decorEntity:"Being",decorAltitude:"Altitude",decorLights:"Lights",decorLightsNone:"none",decor:"Environment",decorBuilding:"Building",decorTree:"Tree",decorCrop:"Crop row",decorMound:"Stone heap",decorStreetlight:"Streetlight",decorVehicle:"Vehicle",decorWitness:"Other witness",decorEast:"Distance east",decorNorth:"Distance north",decorHeading:"Heading",decorColor:"Colour",decorLit:"Lit",decorTitle:"Name",milestones:"Moments",milestoneLabel:"Label",milestoneNote:"What happens",addMilestone:"Name this moment",deleteMilestone:"Delete moment",confirmAccept:"Delete",confirmDecline:"Cancel",decorWidth:"Width",decorLength:"Length",decorHeight:"Height",decorModel:"3D model",decorModelNone:"Built-in shape",decorModelAdvanced:"Model from an address",decorModelUrl:"glTF/GLB address",decorModelTitle:"Model name",decorModelAuthor:"Author",decorModelLicense:"Licence",decorModelSource:"Where it came from",decorFloors:"Floors",decorOccupiedFloor:"Occupied floor",decorWitnessSide:"Witness location",decorWitnessSideNone:"Not present",decorWindows:"Windows",decorSideFront:"Front",decorSideBehind:"Behind",decorSideLeft:"Left",decorSideRight:"Right",decorSideFrontLeft:"Front-left",decorSideFrontRight:"Front-right",decorSideBehindLeft:"Behind-left",decorSideBehindRight:"Behind-right"},K1={...YT,oval:"Oval",polygon:"Polygon",addVertex:"Add vertex",deleteVertex:"Delete vertex",notAPolygon:"Select a single polygon shape",tooFewVertices:"A shape needs at least 3 points",shape:"Shape",apparentWidth:"Apparent width",realWidth:"Real width",distance:"Distance",sizeLock:"Hold",lockNone:"nothing",lockApparent:"the apparent width",lockReal:"the real width",lockDistance:"the distance",apparentSize:"{moons}× the Moon",utcOffsetPlaceholder:"from longitude",realSizeBetween:"The scene bounds that width: between {min} and {max} m, from what it crosses",realSizeAtLeast:"The scene bounds that width: at least {min} m, from what it passes behind",realSizeAtMost:"The scene bounds that width: at most {max} m, from what it passes in front of",realSizeUnknown:"Nothing in the scene bounds that width: it is only what the distance implies",realSizeOutside:" — the width above is outside that",blurBound:"Blurred through this lens: nearer than {max} m",blurBoundNoInstrument:"Blur through the naked eye bounds no distance — an eye has no aperture to be out of focus with",blurBoundNotAtInfinity:"Blur bounds a distance only for a lens focused at infinity: this one is focused at {focus} m, which blurs on both sides of it",realSizeContradiction:"Contradiction: the declared crossings cannot all be true",realDistanceHere:" — i.e. between {min} and {max} m here",clearDistanceHypothesis:"Withdraw the distance hypothesis",clearDistanceHypothesisTitle:"Back to what the recording establishes",depthStated:"Drawn at {m} m, as the recording states",depthHypothesis:"Drawn at {m} m: your hypothesis — what the decor hides of it is what a thing that far would lose",depthDerived:"Drawn at {m} m, from the witness's own walk",depthBounded:"Drawn at {m} m, from what it passes behind and in front of",depthConventional:"Drawn at {m} m by convention: nothing in the recording establishes a distance",addShape:"Add shape",deleteShape:"Delete shape",play:"Play",pause:"Pause",noDuration:"No observation duration",group:"Group",ungroup:"Ungroup",bringToFront:"Bring to front",sendToBack:"Send to back",contextMenuDelete:"Delete",confirmDeleteShape:"Delete {name}? This can't be undone.",confirmDeleteShapes:"Delete {count} shapes? This can't be undone.",confirmDeleteMilestone:"Stop naming moment {name}? The recording itself is unchanged.",onlyOneShape:"There is only one shape",alreadyAtFront:"This shape is already at the front",alreadyAtBack:"This shape is already at the back",needTwoShapesToGroup:"Select at least two shapes to group them",notGrouped:"This shape isn't part of a group",multipleShapesSelected:"Multiple shapes selected — select just one to edit this",samplingRate:"Sampling rate",currentPosition:"Current position",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",durationPlaceholder:"observation length",durationImprecise:"These dates don't precisely enough determine a duration — enter it manually.",export:"Export",importFile:"Load JSON file",importUrl:"Or load from URL",importUrlPlaceholder:"https://…/sighting.json",importButton:"Load",importError:"Couldn't load that recording — check the file or URL and try again.",importErrorCors:'That address answers, but the browser is not allowed to read it from this page. The file itself is fine — its server needs to send the header "Access-Control-Allow-Origin: *" with it. If it is not your server, that is what to ask its administrator for.',importErrorMixedContent:"A secure page cannot load an address starting with http://. Use https:// if that server offers it.",importErrorUnreachable:"Nothing answered at that address. Check the spelling, and that you are online.",importErrorStatus:"That server answered with an error ({status}). The address is probably wrong, or the file has moved.",importErrorMalformed:"That address answered, but what came back is not a recording.",record:"Record",stop:"Stop",according:"according to",sourceElevation:"Relief",sourceImagery:"Imagery",placeNamePlaceholder:"Valensole, France",searchPlace:"Locate",placeMatch:"Matches",placeSearching:"Looking up the place…",placeMatchFound:"place found",placeMatchesFound:"places found",placeNotFound:"No place by that name",placeSearchFailed:"Place search temporarily unavailable",utcOffsetImplausible:"This time zone doesn't match the longitude entered, whose own solar time is UTC{solar} — yet the scene and the weather record both obey what is declared here. Clear the field to derive it from the longitude.",timeZoneManual:"offset entered",altitudeAboveSeaLevel:"The witness's altitude above sea level — the ground at the location entered sets its floor: a witness in the Alps is not at 0 m.",groundAt:"ground at {m} m",headingPlaceholder:"unknown",edtfInvalid:"Not a valid EDTF date/time (e.g. 1965-07-01T05:00, 2025-06?, 2025~).",edtfPlaceholder:"YYYY-MM-DDThh:mm[?~%] or hh:mm",observationTimeHint:"EDTF — e.g. 1965-07-01T05:00, 2025-06? (uncertain), 2025~ (approximate), or just 05:00 if the date isn't known",observationEndTimeHint:"EDTF — e.g. 1965-07-01T05:10, 2025-06? (uncertain), 2025~ (approximate), or just 05:10 if the date isn't known",presetsGroupLabel:"UFO shape",witnessDirName:"Dir name",description:"Description",tagsPlaceholder:"comma-separated",weather:"Weather",shapeGroup:"Phenomenon",soundGroup:"Sound",temporalGroup:"Moment",timeQualifierExact:"Exact",timeQualifierApproximate:"Approximate",timeQualifierUncertain:"Uncertain",timeQualifierBoth:"Uncertain and approximate",edtfModeTitle:"Type an imprecise date instead: a year alone, a month, a time with no date",locationGroup:"Location",observationGroup:"Observation",weatherWhilePlaying:"Pause the recording to state the weather — while it plays, the instant these would be written at is moving",weatherInferred:"From weather records",weatherInferredTitle:"Weather isn't testimony: it's a measurable fact, on record for the observation's own date, time and place. Uncheck to state the conditions the witness reported, which then override the record.",weatherLookingUp:"Looking up the record…",weatherNeedsDateAndPlace:"A full date and a place are needed to look up the record",weatherNoRecord:"No record for this date and place",weatherLookupFailed:"Weather records temporarily unreachable",instrumentOutOfPeriod:"{name} — not of this date",unitMillimetres:"mm",unitDegrees:"°",soundSrcPlaceholder:"URL of a real recording",referenceGroup:"Pictures",reference:"Picture",referenceTitle:"Name",referenceSrc:"Address",referenceSrcPlaceholder:"https://…/photo.jpg",referenceKind:"Kind",referencePhoto:"Photo",referencePanorama:"Panorama (360°)",referenceCredit:"Credit",referenceCreditUrl:"Credit link",referenceT:"Taken at",referenceDrawing:"Drawn on",referenceOpacity:"Opacity",referenceHeading:"Heading",referencePitch:"Pitch",referenceRoll:"Roll",referenceFov:"Vertical field",referenceUsePose:"Use the witness's pose",addReferenceUrl:"Add from an address",addReferenceFile:"Add a file",deleteReference:"Delete picture",referenceEmbedded:"{kb} kB embedded in the recording — an address would keep it light",referenceUnreachable:"The picture could not be loaded: check the address, and that its site allows other sites to read it",referenceRegisterHint:"Drag to turn the picture, wheel to change its field; “Add a landmark” to point at a detail on the picture, then at the same one in the render",referenceLandmarkPicture:"Landmark {n}: click the point on the picture",referenceLandmarkScene:"Landmark {n}: click the same point in the render",referenceLandmarkOffPicture:"That click is not on the picture",referenceNotLoaded:"The picture has not arrived yet",referenceLandmarksFit:"{n} landmarks — {deg}° off on average",referenceLandmarks:"Landmarks",addReferenceLandmark:"Add a landmark",deleteReferenceLandmark:"Delete landmark",referenceLandmarkLabel:"Name",referenceLandmarkLabelPlaceholder:"Masking tree, fence…",referenceAdoptPose:"Adopt as the witness's pose",referenceAdoptRationale:"Measured on the picture “{title}”: {n} landmarks lined up, {deg}° of residual",referenceStreetSearch:"Street-level pictures nearby",referenceStreetSearching:"Looking for pictures taken nearby…",referenceStreetNone:"No street-level picture within {m} m (Panoramax)",referenceStreetFailed:"Panoramax could not be reached",referenceStreetAdd:"Add",referenceStreetItem:"{distance} m at {bearing}°, {date}{panorama}",referenceStreetPanorama:" — 360°",referenceStreetTitle:"Street-level picture {distance} m away at {bearing}°, {date}",skyLine:"Sky: {parts}",skyStarsEye:"stars down to magnitude {limit}, which is as faint as an eye went under this sky",skyStarsDeeper:"stars down to magnitude {limit} through a {device} — {gain} magnitudes past the {eye} the witness's own eyes reached",skyStarsShallower:"stars down to magnitude {limit} through a {device} — {gain} magnitudes short of the {eye} the witness's own eyes reached",skyStarsCatalogue:", drawn to {catalogue}, where this project's catalogue stops",skyStarsNone:"no star could be picked out of a sky this bright",skyDetails:"Show the records in full",skyDetailsHide:"Hide the records",skyShowerActive:"{name} — radiant {altitude}° above the horizon, {bearing} — about {rate}/h under this sky, over a sporadic background of {sporadic}/h",skyShowerBelowHorizon:"{name} is active, but its radiant is below the horizon — it can have produced nothing",skyNothingActive:"no meteor shower active on this date — a sporadic background of about {sporadic}/h",showMeteor:"Show me one",skyComet:"{name}, magnitude {magnitude}, {altitude}° above the horizon {bearing}, tail {tail}° long",skyCometNoTail:"{name}, magnitude {magnitude}, {altitude}° above the horizon {bearing}",skyCometBelowHorizon:"{name} was there at magnitude {magnitude}, but below the horizon — nobody here saw it",skyCometInDaylight:"{name}, magnitude {magnitude}, {altitude}° above the horizon {bearing} — but only {elongation}° from the Sun",showComet:"Show me the comet",skyNova:"{name}, a new star of magnitude {magnitude}, {altitude}° above the horizon {bearing}",skyNovaBelowHorizon:"{name} was shining at magnitude {magnitude}, but below the horizon: nobody here saw it",showNova:"Show me the new star",skySatellitePasses:"{count} satellites crossed this sky bright enough to be seen, the brightest {name}, magnitude {magnitude}, {altitude}° above the horizon {bearing} at {time}",skySatellitePassesOne:"one satellite crossed this sky bright enough to be seen: {name}, magnitude {magnitude}, {altitude}° above the horizon {bearing} at {time}",skySatelliteTrain:"among them a train of {count} Starlinks launched on {date}",skySatellitePassesNone:"by the orbital elements archived for that date, no lit satellite crossed this sky brightly enough to be seen",skySatelliteElementsGap:"no orbital elements archived near that date",showSatellite:"Show me a satellite",skyOpticsPossible:"ice cloud enough, around the {source}, for {forms}",skyOpticsAlignment:" — everything but the rings needs crystals falling level, stated here at {alignment}% since no record holds it",skyOpticsHalo22:"a {angle}° ring",skyOpticsHalo46:"a {angle}° ring",skyOpticsParhelia:"sundogs {angle}° to either side",skyOpticsTangentArc:"an arc tangent on top of it",skyOpticsParhelicCircle:"a white circle right round the sky at its own height",skyOpticsCircumzenithal:"a circumzenithal arc {angle}° up",skyOpticsCircumhorizontal:"a circumhorizontal arc far below it",skyOpticsPillar:"a pillar standing over it",skyOpticsNoIce:"no ice cloud: no halo and no sundogs",skyOpticsHidden:"ice cloud above, but a lower deck between it and the witness",skyOpticsSun:"Sun",skyOpticsMoon:"Moon",skyBowPossible:"rain and sunlight enough for {forms}",skyBowMoon:"rain under a Moon {lit}% lit, enough for {forms} — a moonbow, which the eye sees as a white arc",skyGlowBand:"the Milky Way {contrast}× the sky behind it, {altitude}° up {bearing}",skyGlowCone:"the zodiacal light {contrast}× the sky behind it, {altitude}° up {bearing}, {elongation}° from the Sun — a faint tilted cone of light with blurred edges, gone within the hour",skyGlowZodiacalBand:"the zodiacal band {contrast}× the sky behind it, {altitude}° up {bearing} — the whole ecliptic faintly alight, which is not the sight people report",skyGlowMoon:"no Milky Way and no zodiacal light: a Moon {lit}% lit held the sky at {sky} magnitudes a square arcsecond, where they need 22",skyGlowTwilight:"no Milky Way and no zodiacal light: twilight still held the sky at {sky} magnitudes a square arcsecond, where they need 22",skyGlowNothingUp:"sky dark enough ({sky} magnitudes a square arcsecond) but neither the galactic plane nor the ecliptic stood high enough in it",skyBowPrimary:"a bow {radius}° across, its top {top}° up",skyBowSecondary:"a second, fainter one at {radius}° with its colours reversed",skyBowSourceTooHigh:"rain, but with the source {altitude}° up no bow could clear the horizon: they stand {radius}° from the point opposite it",skyBowHidden:"rain, but an unbroken deck between it and the light: no bow",skyBowNoSource:"rain, and nothing lit to make a bow of it",skySatellitesLit:"the Earth's shadow stood {height} km above the witness, so low orbit was still in sunlight — {count} tracked objects were in orbit that month",skySatellitesLitWith:"the Earth's shadow stood {height} km above the witness, so low orbit was still in sunlight — {count} tracked objects were in orbit that month, among them {eras}",skySatellitesShadowed:"the Earth's shadow stood {height} km above the witness: of the {count} tracked objects in orbit that month, nothing in low orbit was lit",skySatellitesNotYet:"nothing had been put in orbit yet",skySatellitesDaylight:"everything in orbit was sunlit, as it always is by day, and {eras} could outshine even this sky",skySatellitesDaylightOne:"everything in orbit was sunlit, as it always is by day, and {eras} could outshine even this sky",skyUnknown:"cannot be worked out without a date and a place",lookAtDecor:"Look at it",addDecor:"Add",deleteDecor:"Delete decor",decorSightingUrl:"Their own recording URL",viewTestimony:"View testimony",noWitnessRecording:"No recording URL set for this witness",masks:"Masks",addWitness:"Add witness",narrativePlaceholder:"What the witness reported, in their own words",narrativeKey:"{source} API key",narrativeNeedsKey:"Enter your own {source} API key to generate a reconstruction from the account",narrativeKeyUnlikely:"This does not look like a Claude API key: they begin with sk-ant-",narrativeWorkspace:"Workspace ID",narrativeWorkspacePlaceholder:"only if your key spans several",narrativeWorkspaceHint:"Only for a key whose scope is the whole organisation. Simpler: leave this empty and create a key scoped to one workspace instead.",narrativeNeedsAsk:"Nothing to send yet",narrativeRemember:"Remember on this device",narrativeDraft:"Generate reconstruction",narrativeStop:"Stop",narrativeWorking:"Reading the account…",narrativeApplied:"{count} fields written into the editor",narrativeUnchanged:"The account states nothing the recording can hold yet",narrativeStated:"What the witness said",narrativeDerived:"Worked out from the account",narrativeAssumed:"Guessed, so the reconstruction runs — check these",narrativeGaps:"What nothing could settle",narrativeErrorCredential:"No key, or one that was refused — check it at console.anthropic.com",narrativeErrorRateLimited:"Too many requests on your account: wait a moment and ask again",narrativeErrorRefused:"The account was not answered. Rephrasing may help; asking again will not",narrativeErrorMalformed:"The answer was not a usable draft — worth asking once more",narrativeErrorUnreachable:"Nothing answered: check the connection",narrativeErrorRejected:"Refused: {detail}",witnessAge:"Age then",witnessOccupation:"Occupation",testimonySource:"Account obtained",testimonySourceUnknown:"unknown",testimonySourceOnSite:"on-site investigation",testimonySourceInterview:"interview in person",testimonySourceTelephone:"by telephone",testimonySourceQuestionnaire:"questionnaire",testimonySourceLetter:"the witness wrote it",testimonySourcePress:"press or broadcast",testimonyFollowedUp:"Followed up",testimonyUnknown:"unknown",testimonyYes:"yes",testimonyNo:"no",questionUnanswered:"Nothing in this recording answers one of the questions a reconstruction needs settled",durationRequired:"The observation needs a length to be replayed at all — state one, or an end time, which may be approximate",questionsUnanswered:"{count} of the questions a full reconstruction answers are unanswered here"},KT=Object.freeze(Object.defineProperty({__proto__:null,sightingEditorMessages_en:K1},Symbol.toStringTag,{value:"Module"})),Qm=new Set;Cc();yT();const ea={width:48,height:28},$T=2500,ZT=600,eg=900,ta=2e-4,JT=900,jT=-1.46,QT=3,tg=.2,eA=.01,tA=1.6,hd=2e3,iA=250,ig=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),As=4,Wl="ufo-1",ng=["oval","polygon"],nA={presetId:"oval",color:"#39ff14",transparency:0,haloScale:1.5,blur:0,brightness:0};function sA(r){return r.kind==="oval"?"oval":"polygon"}const rA=-6,aA=21;class Ct extends HTMLElement{shadow;sceneElement;ufoElement;recordButton;samplingRateInput;presetButtons;presetsGroup;colorInput;transparencyInput;haloScaleInput;blurInput;brightnessInput;blurBoundOutput;sourceSelect;shapeTitleInput;utcOffsetInput;timeZoneSelect;timeZoneProvider=qT[0].create();timeZoneLookupTimer;timeZoneLookedUpAt;autoFilledTimeZone;timeZones=new WT;apparentWidthInput;realWidthInput;objectDistanceInput;sizeLockSelect;apparentSizeOutput;realSizeOutput;clearDistanceHypothesisButton;depthBasisOutput;addShapeButton;deleteShapeButton;contextMenu;contextGroupButton;contextUngroupButton;contextBringToFrontButton;contextSendToBackButton;contextDeleteButton;contextAddVertexButton;contextDeleteVertexButton;decorContextMenu;contextViewTestimonyButton;contextMasksSubmenu;labelContextMasks;playPauseButton;seekInput;timeStartLabel;timeEndLabel;durationInput;exportButton;importFileInput;importUrlInput;importUrlButton;narrativeKeyInput;narrativeWorkspaceInput;narrativeRememberInput;narrativeDraftButton;narrativeStopButton;narrativeCreditLink;narrativeStatus;narrativeReport;placeNameInput;searchPlaceButton;placeMatchRow;placeMatchSelect;placeStatusText;placeProvider=zT();placeMatches=[];placeSearchToken=0;placeReverseTimer;namedCoordinates;latInput;lngInput;headingInput;headingUnit;pitchInput;rollInput;elevationInput;groundElevationOutput;weatherFromRecords=!0;groundElevationM;groundElevationFor;groundElevationTimer;groundElevationToken=0;obsTimeInput;obsTimeNativeInput;obsEndTimeNativeInput;obsTimeQualifier;obsEndTimeQualifier;edtfModeButton;edtfMode=!1;obsEndTimeInput;witnessIdInput;witnessDirNameInput;witnessTitleInput;witnessLastNameInput;witnessFirstNamesInput;witnessAgeInput;witnessOccupationInput;testimonySourceSelect;testimonyFollowedUpSelect;caseIdInput;descriptionInput;tagsInput;cloudEditor;cloudCoverInput;cloudDarknessInput;cloudBaseInput;precipitationTypeSelect;precipitationIntensityInput;windDirectionInput;windSpeedInput;stormInput;weatherInferredInput;weatherSourceText;skyCandidatesOutput;showMeteorButton;showCometButton;showNovaButton;showSatelliteButton;weatherSourceLink;weatherFields;weatherInference=new rd(UT());weatherLookupTimer;weatherLookupToken=0;weatherLookupPending=!1;weatherLookupResult;weatherTrackSpan;soundKindSelect;soundVolumeInput;soundPitchInput;soundPitchValue;soundSrcInput;soundFields;soundKindOptions=new Map;soundPreviewTimer;instrumentSelect;focalLengthInput;labelFocalLength;unitFocalLength;labelFNumber;labelExposure;labelFocusDistance;fNumberInput;exposureInput;focusDistanceInput;labelColor;labelTransparency;labelHalo;labelBlur;labelBrightness;labelShape;labelShapeTitle;labelUtcOffset;labelApparentWidth;labelRealWidth;labelObjectDistance;labelSizeLock;labelSamplingRate;labelDuration;placeSourceRow;weatherSourceRow;terrainSourceRows;chosenSourceId=new Map;labelPlaceName;labelPlaceMatch;labelLatitude;labelLongitude;labelHeading;labelPitch;labelRoll;labelElevation;labelObservationTime;labelObservationEndTime;labelWitnessId;labelWitnessDirName;labelWitnessTitle;labelWitnessLastName;labelWitnessFirstNames;labelWitnessAge;labelWitnessOccupation;labelTestimonySource;labelTestimonyFollowedUp;labelCaseId;labelDescription;labelTags;labelImportFile;labelImportUrl;labelNarrativeKey;labelNarrativeWorkspace;labelNarrativeRemember;groupTabs;groupPanels;paramSummary;paramSummaryBuilder;paramSummarySignature="";labelShapeGroup;labelTemporalGroup;labelLocationGroup;labelObservationGroup;labelWitnessGroup;skyDetailsButton;clampedLines;labelWeatherGroup;labelCloudCover;labelHighCloud;labelIceAlignment;highCloudCoverInput;iceCrystalAlignmentInput;labelCloudDarkness;labelCloudBase;labelPrecipitationType;labelPrecipitationIntensity;labelWindDirection;labelWindSpeed;labelStorm;labelCloudsGroup;labelPrecipitationGroup;labelWindGroup;subgroupTabs;labelWeatherInferred;labelSoundGroup;labelSoundKind;labelSoundVolume;labelSoundPitch;labelSoundSrc;labelInstrument;optionPrecipitationNone;optionPrecipitationRain;optionPrecipitationSnow;optionPrecipitationHail;decorKindSelect;addDecorWitnessButton;addDecorBuildingButton;deleteDecorButton;decorSelect;decorTitleInput;decorEastInput;decorNorthInput;decorHeadingInput;decorColorInput;decorLitInput;decorLightRigSelect;lookAtDecorButton;decorAltitudeInput;labelDecorAltitude;decorSightingUrlInput;decorModelProvider=jl[0].create();confirmOverlay;confirmMessage;confirmAcceptButton;confirmDeclineButton;confirmAnswer;milestoneSelect;milestoneLabelInput;milestoneNoteInput;addMilestoneButton;deleteMilestoneButton;currentMilestoneT;decorWidthInput;decorLengthInput;decorHeightInput;decorModelSelect;decorModelAdvanced;decorModelUrlInput;decorModelTitleInput;decorModelAuthorInput;decorModelLicenseInput;decorModelSourceInput;decorFloorsInput;decorOccupiedFloorInput;decorWitnessSideSelect;decorWindowInputs;labelDecorSide;optionWitnessSide;labelDecor;labelDecorGroup;labelDecorTitle;labelDecorEast;labelDecorNorth;labelDecorHeading;labelDecorColor;labelDecorLit;labelDecorSightingUrl;labelMilestones;labelMilestoneLabel;labelMilestoneNote;labelDecorWidth;labelDecorLength;labelDecorHeight;labelDecorModel;labelDecorModelAdvanced;labelDecorModelUrl;labelDecorModelTitle;labelDecorModelAuthor;labelDecorModelLicense;labelDecorModelSource;labelDecorFloors;labelDecorOccupiedFloor;labelDecorWitnessSide;labelDecorWindows;optionWitnessSideNone;optionDecorBuilding;optionDecorTree;optionDecorCrop;optionDecorMound;optionDecorStreetlight;optionDecorVehicle;optionDecorAircraft;optionDecorEntity;labelDecorLights;optionDecorWitness;recorder;isRecording=!1;messages=K1;currentAppearance={...nA};currentSourceId=Wl;selectedSourceIds=new Set([Wl]);currentDecorId;currentReferenceId;referenceSelect;deleteReferenceButton;referenceTitleInput;referenceSrcInput;referenceKindSelect;referenceCreditInput;referenceCreditUrlInput;referenceTInput;referenceDrawingInput;referenceOpacityInput;referenceHeadingInput;referencePitchInput;referenceRollInput;referenceFovInput;referenceUsePoseButton;referenceStatus;addReferenceUrlButton;addReferenceFileInput;referenceLandmarksSelect;addReferenceLandmarkButton;deleteReferenceLandmarkButton;referenceLandmarkLabelInput;labelReferenceLandmarks;labelReferenceLandmarkLabel;referenceAdoptPoseButton;referenceStreetSearchButton;referenceStreetSelect;referenceStreetAddButton;lastCanvasMode="shape";referenceDragState;armingLandmark=!1;pendingLandmark;currentLandmarkId;referenceFit;streetPictures=[];streetPictures$=new da;referenceFields;labelReferenceGroup;labelReference;labelReferenceTitle;labelReferenceSrc;labelReferenceKind;labelReferenceCredit;labelReferenceCreditUrl;labelReferenceT;labelReferenceDrawing;labelReferenceOpacity;labelReferenceHeading;labelReferencePitch;labelReferenceRoll;labelReferenceFov;labelAddReferenceFile;contextMenuDecorId;contextMenuPoint;dragState;cameraDragState;hoverCursor;indoorLookYawDeg=0;indoorLookPitchDeg=0;lastInhabitedKey;handleKeyDown=e=>{if(e.key==="Escape"&&(this.isRecording&&this.toggleRecording(),this.confirmOverlay.hidden||this.answerConfirm(!1),(this.armingLandmark||this.pendingLandmark)&&this.disarmLandmark(),this.contextMenu.hidden||this.hideContextMenu(),this.decorContextMenu.hidden||this.hideDecorContextMenu()),ig.has(e.key)||e.key==="Delete"||e.key==="Backspace"){const t=e.composedPath()[0];if(t instanceof HTMLInputElement||t instanceof HTMLSelectElement||t instanceof HTMLTextAreaElement)return;ig.has(e.key)?this.moveOrResizeSelectedShapes(e):this.deleteShape()}};handleDragPointerMove=e=>this.onDragPointerMove(e);handleDragPointerUp=()=>this.endDrag();constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${Wv}</style>${Vv}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.sceneElement=document.createElement(Gu),this.sceneElement.setAttribute("show-compass",""),this.sceneElement.setAttribute(fr,""),this.sceneElement.animateWhilePaused=!0,this.ufoElement=this.sceneElement.ufoElement,this.ufoElement.enableClickToPlay=!1,this.ufoElement.showToolbar=!1,this.shadow.getElementById("ufo-slot").replaceWith(this.sceneElement),this.ufoElement.hostControls(this.shadow.getElementById("scene-controls")),this.recordButton=this.shadow.getElementById("record"),this.samplingRateInput=this.shadow.getElementById("samplingRate"),this.presetsGroup=this.shadow.getElementById("presets-group"),this.presetButtons={oval:this.shadow.getElementById("preset-oval"),polygon:this.shadow.getElementById("preset-polygon")},this.colorInput=this.shadow.getElementById("color"),this.transparencyInput=this.shadow.getElementById("transparency"),this.haloScaleInput=this.shadow.getElementById("haloScale"),this.blurInput=this.shadow.getElementById("blur"),this.brightnessInput=this.shadow.getElementById("brightness"),this.blurBoundOutput=this.shadow.getElementById("blur-bound"),this.sourceSelect=this.shadow.getElementById("source"),this.shapeTitleInput=this.shadow.getElementById("shapeTitle"),this.utcOffsetInput=this.shadow.getElementById("utcOffsetHours"),this.timeZoneSelect=this.shadow.getElementById("timeZone"),this.apparentWidthInput=this.shadow.getElementById("apparentWidth"),this.realWidthInput=this.shadow.getElementById("realWidth"),this.objectDistanceInput=this.shadow.getElementById("objectDistance"),this.sizeLockSelect=this.shadow.getElementById("sizeLock"),this.apparentSizeOutput=this.shadow.getElementById("apparent-size"),this.realSizeOutput=this.shadow.getElementById("real-size"),this.clearDistanceHypothesisButton=this.shadow.getElementById("clear-distance-hypothesis"),this.depthBasisOutput=this.shadow.getElementById("depth-basis"),this.addShapeButton=this.shadow.getElementById("add-shape"),this.deleteShapeButton=this.shadow.getElementById("delete-shape"),this.contextMenu=this.shadow.getElementById("context-menu"),this.contextGroupButton=this.shadow.getElementById("context-group"),this.contextUngroupButton=this.shadow.getElementById("context-ungroup"),this.contextBringToFrontButton=this.shadow.getElementById("context-bring-to-front"),this.contextSendToBackButton=this.shadow.getElementById("context-send-to-back"),this.contextDeleteButton=this.shadow.getElementById("context-delete"),this.contextAddVertexButton=this.shadow.getElementById("context-add-vertex"),this.contextDeleteVertexButton=this.shadow.getElementById("context-delete-vertex"),this.decorContextMenu=this.shadow.getElementById("decor-context-menu"),this.contextViewTestimonyButton=this.shadow.getElementById("context-view-testimony"),this.contextMasksSubmenu=this.shadow.getElementById("context-masks-submenu"),this.labelContextMasks=this.shadow.getElementById("label-context-masks"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.seekInput=this.shadow.getElementById("seek"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end");for(const t of[this.timeStartLabel,this.timeEndLabel])t.addEventListener("click",()=>this.switchTimeDisplay()),t.addEventListener("keydown",i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),this.switchTimeDisplay())});this.durationInput=this.shadow.getElementById("durationSeconds"),this.exportButton=this.shadow.getElementById("export"),this.importFileInput=this.shadow.getElementById("import-file"),this.importUrlInput=this.shadow.getElementById("import-url"),this.importUrlButton=this.shadow.getElementById("import-url-button"),this.narrativeKeyInput=this.shadow.getElementById("narrativeKey"),this.narrativeWorkspaceInput=this.shadow.getElementById("narrativeWorkspace"),this.narrativeRememberInput=this.shadow.getElementById("narrativeRemember"),this.narrativeDraftButton=this.shadow.getElementById("narrative-draft"),this.narrativeStopButton=this.shadow.getElementById("narrative-stop"),this.narrativeCreditLink=this.shadow.getElementById("narrative-credit"),this.narrativeStatus=this.shadow.getElementById("narrative-status"),this.narrativeReport=this.shadow.getElementById("narrative-report"),this.placeNameInput=this.shadow.getElementById("placeName"),this.searchPlaceButton=this.shadow.getElementById("search-place"),this.placeMatchRow=this.shadow.getElementById("place-match-row"),this.placeMatchSelect=this.shadow.getElementById("placeMatch"),this.placeStatusText=this.shadow.getElementById("place-status-text"),this.latInput=this.shadow.getElementById("lat"),this.lngInput=this.shadow.getElementById("lng"),this.headingInput=this.shadow.getElementById("heading"),this.headingUnit=this.shadow.getElementById("heading-unit"),this.pitchInput=this.shadow.getElementById("pitch"),this.rollInput=this.shadow.getElementById("roll"),this.elevationInput=this.shadow.getElementById("elevation"),this.groundElevationOutput=this.shadow.getElementById("ground-elevation"),this.obsTimeInput=this.shadow.getElementById("obs-time"),this.obsEndTimeInput=this.shadow.getElementById("obs-end-time"),this.obsTimeNativeInput=this.shadow.getElementById("obs-time-native"),this.obsEndTimeNativeInput=this.shadow.getElementById("obs-end-time-native"),this.obsTimeQualifier=this.shadow.getElementById("obs-time-qualifier"),this.obsEndTimeQualifier=this.shadow.getElementById("obs-end-time-qualifier"),this.edtfModeButton=this.shadow.getElementById("edtf-mode"),this.witnessIdInput=this.shadow.getElementById("witnessId"),this.witnessDirNameInput=this.shadow.getElementById("witnessDirName"),this.witnessTitleInput=this.shadow.getElementById("witnessTitle"),this.witnessLastNameInput=this.shadow.getElementById("witnessLastName"),this.witnessFirstNamesInput=this.shadow.getElementById("witnessFirstNames"),this.witnessAgeInput=this.shadow.getElementById("witnessAge"),this.witnessOccupationInput=this.shadow.getElementById("witnessOccupation"),this.testimonySourceSelect=this.shadow.getElementById("testimonySource"),this.testimonyFollowedUpSelect=this.shadow.getElementById("testimonyFollowedUp"),this.caseIdInput=this.shadow.getElementById("caseId"),this.descriptionInput=this.shadow.getElementById("description"),this.tagsInput=this.shadow.getElementById("tags"),this.cloudCoverInput=this.shadow.getElementById("cloudCover"),this.highCloudCoverInput=this.shadow.getElementById("highCloudCover"),this.iceCrystalAlignmentInput=this.shadow.getElementById("iceCrystalAlignment"),this.cloudDarknessInput=this.shadow.getElementById("cloudDarkness"),this.cloudBaseInput=this.shadow.getElementById("cloudBase"),this.precipitationTypeSelect=this.shadow.getElementById("precipitationType"),this.precipitationIntensityInput=this.shadow.getElementById("precipitationIntensity"),this.windDirectionInput=this.shadow.getElementById("windDirection"),this.windSpeedInput=this.shadow.getElementById("windSpeed"),this.stormInput=this.shadow.getElementById("storm"),this.weatherInferredInput=this.shadow.getElementById("weatherInferred"),this.weatherSourceText=this.shadow.getElementById("weather-source-text"),this.skyCandidatesOutput=this.shadow.getElementById("sky-candidates"),this.showMeteorButton=this.shadow.getElementById("show-meteor"),this.showCometButton=this.shadow.getElementById("show-comet"),this.showNovaButton=this.shadow.getElementById("show-nova"),this.showSatelliteButton=this.shadow.getElementById("show-satellite"),this.weatherSourceLink=this.shadow.getElementById("weather-source-link"),this.weatherFields=[this.cloudCoverInput,this.highCloudCoverInput,this.iceCrystalAlignmentInput,this.cloudDarknessInput,this.cloudBaseInput,this.precipitationTypeSelect,this.precipitationIntensityInput,this.windDirectionInput,this.windSpeedInput,this.stormInput],this.soundKindSelect=this.shadow.getElementById("soundKind"),this.soundVolumeInput=this.shadow.getElementById("soundVolume"),this.soundPitchInput=this.shadow.getElementById("soundPitch"),this.soundPitchValue=this.shadow.getElementById("sound-pitch-value"),this.soundSrcInput=this.shadow.getElementById("soundSrc"),this.soundFields=[this.soundKindSelect,this.soundVolumeInput,this.soundPitchInput,this.soundSrcInput],this.buildSoundKindOptions(),this.instrumentSelect=this.shadow.getElementById("instrument"),this.focalLengthInput=this.shadow.getElementById("focalLength"),this.labelFocalLength=this.shadow.getElementById("label-focal-length"),this.unitFocalLength=this.shadow.getElementById("unit-focal-length"),this.labelFNumber=this.shadow.getElementById("label-f-number"),this.labelExposure=this.shadow.getElementById("label-exposure"),this.fNumberInput=this.shadow.getElementById("fNumber"),this.exposureInput=this.shadow.getElementById("exposureSeconds"),this.focusDistanceInput=this.shadow.getElementById("focusDistance"),this.labelFocusDistance=this.shadow.getElementById("label-focus-distance"),this.refreshInstrumentOptions(),this.labelColor=this.shadow.getElementById("label-color"),this.labelTransparency=this.shadow.getElementById("label-transparency"),this.labelHalo=this.shadow.getElementById("label-halo"),this.labelBlur=this.shadow.getElementById("label-blur"),this.labelBrightness=this.shadow.getElementById("label-brightness"),this.labelShape=this.shadow.getElementById("label-shape"),this.labelShapeTitle=this.shadow.getElementById("label-shape-title"),this.labelUtcOffset=this.shadow.getElementById("label-utc-offset"),this.labelApparentWidth=this.shadow.getElementById("label-apparent-width"),this.labelRealWidth=this.shadow.getElementById("label-real-width"),this.labelObjectDistance=this.shadow.getElementById("label-object-distance"),this.labelSizeLock=this.shadow.getElementById("label-size-lock"),this.labelSamplingRate=this.shadow.getElementById("label-sampling-rate"),this.labelSoundGroup=this.shadow.getElementById("label-sound-group"),this.labelSoundKind=this.shadow.getElementById("label-sound-kind"),this.labelSoundVolume=this.shadow.getElementById("label-sound-volume"),this.labelSoundPitch=this.shadow.getElementById("label-sound-pitch"),this.labelSoundSrc=this.shadow.getElementById("label-sound-src"),this.labelReferenceGroup=this.shadow.getElementById("label-reference-group"),this.labelReference=this.shadow.getElementById("label-reference"),this.labelReferenceTitle=this.shadow.getElementById("label-reference-title"),this.labelReferenceSrc=this.shadow.getElementById("label-reference-src"),this.labelReferenceKind=this.shadow.getElementById("label-reference-kind"),this.labelReferenceCredit=this.shadow.getElementById("label-reference-credit"),this.labelReferenceCreditUrl=this.shadow.getElementById("label-reference-credit-url"),this.labelReferenceT=this.shadow.getElementById("label-reference-t"),this.labelReferenceDrawing=this.shadow.getElementById("label-reference-drawing"),this.labelReferenceOpacity=this.shadow.getElementById("label-reference-opacity"),this.labelReferenceHeading=this.shadow.getElementById("label-reference-heading"),this.labelReferencePitch=this.shadow.getElementById("label-reference-pitch"),this.labelReferenceRoll=this.shadow.getElementById("label-reference-roll"),this.labelReferenceFov=this.shadow.getElementById("label-reference-fov"),this.labelAddReferenceFile=this.shadow.getElementById("label-add-reference-file"),this.labelDuration=this.shadow.getElementById("label-duration"),this.placeSourceRow=this.shadow.getElementById("place-source-row"),this.weatherSourceRow=this.shadow.getElementById("weather-source-row"),this.terrainSourceRows=this.shadow.getElementById("terrain-source-rows"),this.labelPlaceName=this.shadow.getElementById("label-place-name"),this.labelPlaceMatch=this.shadow.getElementById("label-place-match"),this.labelLatitude=this.shadow.getElementById("label-lat"),this.labelLongitude=this.shadow.getElementById("label-lng"),this.labelHeading=this.shadow.getElementById("label-heading"),this.labelPitch=this.shadow.getElementById("label-pitch"),this.labelRoll=this.shadow.getElementById("label-roll"),this.labelElevation=this.shadow.getElementById("label-elevation"),this.labelObservationTime=this.shadow.getElementById("label-observation-time"),this.labelObservationEndTime=this.shadow.getElementById("label-observation-end-time"),this.labelWitnessId=this.shadow.getElementById("label-witness-id"),this.labelWitnessDirName=this.shadow.getElementById("label-witness-dir-name"),this.labelWitnessTitle=this.shadow.getElementById("label-witness-title"),this.labelWitnessLastName=this.shadow.getElementById("label-witness-last-name"),this.labelWitnessFirstNames=this.shadow.getElementById("label-witness-first-names"),this.labelWitnessAge=this.shadow.getElementById("label-witness-age"),this.labelWitnessOccupation=this.shadow.getElementById("label-witness-occupation"),this.labelTestimonySource=this.shadow.getElementById("label-testimony-source"),this.labelTestimonyFollowedUp=this.shadow.getElementById("label-testimony-followed-up"),this.labelCaseId=this.shadow.getElementById("label-case-id"),this.labelDescription=this.shadow.getElementById("label-description"),this.labelTags=this.shadow.getElementById("label-tags"),this.labelImportFile=this.shadow.getElementById("label-import-file"),this.labelImportUrl=this.shadow.getElementById("label-import-url"),this.labelNarrativeKey=this.shadow.getElementById("label-narrative-key"),this.labelNarrativeWorkspace=this.shadow.getElementById("label-narrative-workspace"),this.labelNarrativeRemember=this.shadow.getElementById("label-narrative-remember"),this.labelShapeGroup=this.shadow.getElementById("label-shape-group"),this.labelTemporalGroup=this.shadow.getElementById("label-temporal-group"),this.labelLocationGroup=this.shadow.getElementById("label-location-group"),this.labelObservationGroup=this.shadow.getElementById("label-observation-group"),this.labelWitnessGroup=this.shadow.getElementById("label-witness-group"),this.labelWeatherGroup=this.shadow.getElementById("label-weather-group"),this.labelCloudCover=this.shadow.getElementById("label-cloud-cover"),this.labelHighCloud=this.shadow.getElementById("label-high-cloud"),this.labelIceAlignment=this.shadow.getElementById("label-ice-alignment"),this.labelCloudDarkness=this.shadow.getElementById("label-cloud-darkness"),this.labelCloudBase=this.shadow.getElementById("label-cloud-base"),this.labelPrecipitationType=this.shadow.getElementById("label-precipitation-type"),this.labelPrecipitationIntensity=this.shadow.getElementById("label-precipitation-intensity"),this.labelWindDirection=this.shadow.getElementById("label-wind-direction"),this.labelWindSpeed=this.shadow.getElementById("label-wind-speed"),this.labelStorm=this.shadow.getElementById("label-storm"),this.labelCloudsGroup=this.shadow.getElementById("label-clouds-group"),this.labelPrecipitationGroup=this.shadow.getElementById("label-precipitation-group"),this.labelWindGroup=this.shadow.getElementById("label-wind-group"),this.labelWeatherInferred=this.shadow.getElementById("label-weather-inferred"),this.labelInstrument=this.shadow.getElementById("label-instrument"),this.optionPrecipitationNone=this.shadow.getElementById("option-precipitation-none"),this.optionPrecipitationRain=this.shadow.getElementById("option-precipitation-rain"),this.optionPrecipitationSnow=this.shadow.getElementById("option-precipitation-snow"),this.optionPrecipitationHail=this.shadow.getElementById("option-precipitation-hail"),this.decorKindSelect=this.shadow.getElementById("decorKind"),this.addDecorWitnessButton=this.shadow.getElementById("add-decor-witness"),this.addDecorBuildingButton=this.shadow.getElementById("add-decor-building"),this.deleteDecorButton=this.shadow.getElementById("delete-decor"),this.decorSelect=this.shadow.getElementById("decor"),this.referenceSelect=this.shadow.getElementById("reference"),this.deleteReferenceButton=this.shadow.getElementById("delete-reference"),this.referenceTitleInput=this.shadow.getElementById("referenceTitle"),this.referenceSrcInput=this.shadow.getElementById("referenceSrc"),this.referenceKindSelect=this.shadow.getElementById("referenceKind"),this.referenceCreditInput=this.shadow.getElementById("referenceCredit"),this.referenceCreditUrlInput=this.shadow.getElementById("referenceCreditUrl"),this.referenceTInput=this.shadow.getElementById("referenceT"),this.referenceDrawingInput=this.shadow.getElementById("referenceDrawing"),this.referenceOpacityInput=this.shadow.getElementById("referenceOpacity"),this.referenceHeadingInput=this.shadow.getElementById("referenceHeading"),this.referencePitchInput=this.shadow.getElementById("referencePitch"),this.referenceRollInput=this.shadow.getElementById("referenceRoll"),this.referenceFovInput=this.shadow.getElementById("referenceFov"),this.referenceUsePoseButton=this.shadow.getElementById("reference-use-pose"),this.referenceStatus=this.shadow.getElementById("reference-status"),this.addReferenceUrlButton=this.shadow.getElementById("add-reference-url"),this.addReferenceFileInput=this.shadow.getElementById("add-reference-file"),this.referenceLandmarksSelect=this.shadow.getElementById("reference-landmarks"),this.addReferenceLandmarkButton=this.shadow.getElementById("add-reference-landmark"),this.deleteReferenceLandmarkButton=this.shadow.getElementById("delete-reference-landmark"),this.referenceLandmarkLabelInput=this.shadow.getElementById("referenceLandmarkLabel"),this.labelReferenceLandmarks=this.shadow.getElementById("label-reference-landmarks"),this.labelReferenceLandmarkLabel=this.shadow.getElementById("label-reference-landmark-label"),this.referenceAdoptPoseButton=this.shadow.getElementById("reference-adopt-pose"),this.referenceStreetSearchButton=this.shadow.getElementById("reference-street-search"),this.referenceStreetSelect=this.shadow.getElementById("reference-street"),this.referenceStreetAddButton=this.shadow.getElementById("reference-street-add"),this.referenceFields=[this.referenceTitleInput,this.referenceSrcInput,this.referenceKindSelect,this.referenceCreditInput,this.referenceCreditUrlInput,this.referenceTInput,this.referenceDrawingInput,this.referenceOpacityInput,this.referenceHeadingInput,this.referencePitchInput,this.referenceRollInput,this.referenceFovInput],this.decorTitleInput=this.shadow.getElementById("decorTitle"),this.decorEastInput=this.shadow.getElementById("decorEast"),this.decorNorthInput=this.shadow.getElementById("decorNorth"),this.decorHeadingInput=this.shadow.getElementById("decorHeading"),this.decorColorInput=this.shadow.getElementById("decorColor"),this.decorLitInput=this.shadow.getElementById("decorLit"),this.decorLightRigSelect=this.shadow.getElementById("decorLightRig"),this.lookAtDecorButton=this.shadow.getElementById("look-at-decor"),this.decorAltitudeInput=this.shadow.getElementById("decorAltitude"),this.labelDecorAltitude=this.shadow.getElementById("label-decor-altitude"),this.decorSightingUrlInput=this.shadow.getElementById("decorSightingUrl"),this.confirmOverlay=this.shadow.getElementById("confirm-overlay"),this.confirmMessage=this.shadow.getElementById("confirm-message"),this.confirmAcceptButton=this.shadow.getElementById("confirm-ok"),this.confirmDeclineButton=this.shadow.getElementById("confirm-cancel"),this.milestoneSelect=this.shadow.getElementById("milestone"),this.milestoneLabelInput=this.shadow.getElementById("milestoneLabel"),this.milestoneNoteInput=this.shadow.getElementById("milestoneNote"),this.addMilestoneButton=this.shadow.getElementById("add-milestone"),this.deleteMilestoneButton=this.shadow.getElementById("delete-milestone"),this.decorWidthInput=this.shadow.getElementById("decorWidth"),this.decorLengthInput=this.shadow.getElementById("decorLength"),this.decorHeightInput=this.shadow.getElementById("decorHeight"),this.decorModelSelect=this.shadow.getElementById("decorModel"),this.decorModelAdvanced=this.shadow.getElementById("decor-model-advanced"),this.decorModelUrlInput=this.shadow.getElementById("decorModelUrl"),this.decorModelTitleInput=this.shadow.getElementById("decorModelTitle"),this.decorModelAuthorInput=this.shadow.getElementById("decorModelAuthor"),this.decorModelLicenseInput=this.shadow.getElementById("decorModelLicense"),this.decorModelSourceInput=this.shadow.getElementById("decorModelSource"),this.decorFloorsInput=this.shadow.getElementById("decorFloors"),this.decorOccupiedFloorInput=this.shadow.getElementById("decorOccupiedFloor"),this.decorWitnessSideSelect=this.shadow.getElementById("decorWitnessSide"),this.decorWindowInputs={front:this.shadow.getElementById("decorWindowFront"),behind:this.shadow.getElementById("decorWindowBehind"),left:this.shadow.getElementById("decorWindowLeft"),right:this.shadow.getElementById("decorWindowRight"),"front-left":this.shadow.getElementById("decorWindowFrontLeft"),"front-right":this.shadow.getElementById("decorWindowFrontRight"),"behind-left":this.shadow.getElementById("decorWindowBehindLeft"),"behind-right":this.shadow.getElementById("decorWindowBehindRight")},this.labelDecorSide={front:this.shadow.getElementById("label-decor-window-front"),behind:this.shadow.getElementById("label-decor-window-behind"),left:this.shadow.getElementById("label-decor-window-left"),right:this.shadow.getElementById("label-decor-window-right"),"front-left":this.shadow.getElementById("label-decor-window-front-left"),"front-right":this.shadow.getElementById("label-decor-window-front-right"),"behind-left":this.shadow.getElementById("label-decor-window-behind-left"),"behind-right":this.shadow.getElementById("label-decor-window-behind-right")},this.optionWitnessSide={front:this.shadow.getElementById("option-witness-side-front"),behind:this.shadow.getElementById("option-witness-side-behind"),left:this.shadow.getElementById("option-witness-side-left"),right:this.shadow.getElementById("option-witness-side-right"),"front-left":this.shadow.getElementById("option-witness-side-front-left"),"front-right":this.shadow.getElementById("option-witness-side-front-right"),"behind-left":this.shadow.getElementById("option-witness-side-behind-left"),"behind-right":this.shadow.getElementById("option-witness-side-behind-right")},this.optionWitnessSideNone=this.shadow.getElementById("option-witness-side-none"),this.labelDecor=this.shadow.getElementById("label-decor"),this.labelDecorGroup=this.shadow.getElementById("label-decor-group"),this.labelDecorTitle=this.shadow.getElementById("label-decor-title"),this.labelDecorEast=this.shadow.getElementById("label-decor-east"),this.labelDecorNorth=this.shadow.getElementById("label-decor-north"),this.labelDecorHeading=this.shadow.getElementById("label-decor-heading"),this.labelDecorColor=this.shadow.getElementById("label-decor-color"),this.labelDecorLit=this.shadow.getElementById("label-decor-lit"),this.labelDecorSightingUrl=this.shadow.getElementById("label-decor-sighting-url"),this.labelMilestones=this.shadow.getElementById("label-milestones"),this.labelMilestoneLabel=this.shadow.getElementById("label-milestone-label"),this.labelMilestoneNote=this.shadow.getElementById("label-milestone-note"),this.labelDecorWidth=this.shadow.getElementById("label-decor-width"),this.labelDecorLength=this.shadow.getElementById("label-decor-length"),this.labelDecorHeight=this.shadow.getElementById("label-decor-height"),this.labelDecorModel=this.shadow.getElementById("label-decor-model"),this.labelDecorModelAdvanced=this.shadow.getElementById("label-decor-model-advanced"),this.labelDecorModelUrl=this.shadow.getElementById("label-decor-model-url"),this.labelDecorModelTitle=this.shadow.getElementById("label-decor-model-title"),this.labelDecorModelAuthor=this.shadow.getElementById("label-decor-model-author"),this.labelDecorModelLicense=this.shadow.getElementById("label-decor-model-license"),this.labelDecorModelSource=this.shadow.getElementById("label-decor-model-source"),this.labelDecorFloors=this.shadow.getElementById("label-decor-floors"),this.labelDecorOccupiedFloor=this.shadow.getElementById("label-decor-occupied-floor"),this.labelDecorWitnessSide=this.shadow.getElementById("label-decor-witness-side"),this.labelDecorWindows=this.shadow.getElementById("label-decor-windows"),this.optionDecorBuilding=this.shadow.getElementById("option-decor-building"),this.optionDecorTree=this.shadow.getElementById("option-decor-tree"),this.optionDecorCrop=this.shadow.getElementById("option-decor-crop"),this.optionDecorMound=this.shadow.getElementById("option-decor-mound"),this.optionDecorStreetlight=this.shadow.getElementById("option-decor-streetlight"),this.optionDecorVehicle=this.shadow.getElementById("option-decor-vehicle"),this.optionDecorAircraft=this.shadow.getElementById("option-decor-aircraft"),this.optionDecorEntity=this.shadow.getElementById("option-decor-entity"),this.labelDecorLights=this.shadow.getElementById("label-decor-lights"),this.optionDecorWitness=this.shadow.getElementById("option-decor-witness"),this.ufoElement.canvasElement.addEventListener("pointerdown",t=>{this.focus({preventScroll:!0}),this.onPointerDown(t)}),this.ufoElement.canvasElement.addEventListener("pointermove",t=>this.onPointerMove(t)),this.ufoElement.canvasElement.addEventListener("contextmenu",t=>this.onContextMenu(t)),this.contextGroupButton.addEventListener("click",()=>this.groupSelected()),this.contextUngroupButton.addEventListener("click",()=>this.ungroupSelected()),this.contextBringToFrontButton.addEventListener("click",()=>this.bringSelectedToFront()),this.contextSendToBackButton.addEventListener("click",()=>this.sendSelectedToBack()),this.contextDeleteButton.addEventListener("click",()=>{this.hideContextMenu(),this.deleteShape()}),this.contextAddVertexButton.addEventListener("click",()=>this.addVertexAtContextMenu()),this.contextDeleteVertexButton.addEventListener("click",()=>this.deleteVertexAtContextMenu()),this.contextViewTestimonyButton.addEventListener("click",()=>this.viewWitnessTestimony()),this.playPauseButton.addEventListener("click",()=>{this.ufoElement.togglePlayPause(),this.syncPlaybackControls()}),this.seekInput.addEventListener("input",()=>this.ufoElement.currentTime=Number(this.seekInput.value)),this.recordButton.addEventListener("click",()=>this.toggleRecording()),this.addShapeButton.addEventListener("click",()=>this.addShape()),this.deleteShapeButton.addEventListener("click",()=>this.deleteShape()),this.exportButton.addEventListener("click",()=>this.exportJson()),this.importFileInput.addEventListener("change",()=>this.importFromFile()),this.importUrlButton.addEventListener("click",()=>this.importFromUrl()),this.testimonySourceSelect.addEventListener("change",()=>this.updateWitnessMetadata()),this.testimonyFollowedUpSelect.addEventListener("change",()=>this.updateWitnessMetadata()),this.narrativeDraftButton.addEventListener("click",()=>this.draftFromDescription()),this.narrativeStopButton.addEventListener("click",()=>this.narrativeAbort?.abort()),this.narrativeRememberInput.addEventListener("change",()=>this.rememberNarrativeKey()),this.narrativeWorkspaceInput.addEventListener("input",()=>this.rememberNarrativeKey()),this.narrativeKeyInput.addEventListener("input",()=>{this.rememberNarrativeKey(),this.syncNarrativeEnabled()}),this.narrativeCreditLink.textContent=`${Vs[0].name} — ${Vs[0].credit}`,this.narrativeCreditLink.href=Vs[0].creditUrl,this.labelNarrativeKey.textContent=this.messages.narrativeKey.replace("{source}",Vs[0].name),this.narrativeWorkspaceInput.title=this.messages.narrativeWorkspaceHint,this.restoreNarrativeKey(),this.syncNarrativeEnabled(),this.durationInput.addEventListener("input",()=>{this.ufoElement.durationSeconds=this.durationInput.value===""?void 0:Number(this.durationInput.value),this.ufoElement.refresh(),this.updateDurationValidity(),this.scheduleWeatherLookup()}),this.sourceSelect.addEventListener("change",()=>this.selectUnit(this.sourceSelect.value)),this.shapeTitleInput.addEventListener("input",()=>this.updateShapeTitle()),this.apparentWidthInput.addEventListener("input",()=>this.typing(this.apparentWidthInput,()=>this.onApparentWidthInput())),this.realWidthInput.addEventListener("input",()=>this.typing(this.realWidthInput,()=>this.onRealWidthInput())),this.objectDistanceInput.addEventListener("input",()=>this.typing(this.objectDistanceInput,()=>this.onDistanceInput())),this.sizeLockSelect.addEventListener("change",()=>this.applySizeLock()),this.clearDistanceHypothesisButton.addEventListener("click",()=>this.clearDistanceHypothesis()),this.addDecorWitnessButton.addEventListener("click",()=>this.addDecor("witness")),this.addDecorBuildingButton.addEventListener("click",()=>this.addDecor()),this.deleteDecorButton.addEventListener("click",()=>this.deleteDecor()),this.decorSelect.addEventListener("change",()=>this.selectDecor(this.decorSelect.value)),this.referenceSelect.addEventListener("change",()=>this.selectReference(this.referenceSelect.value)),this.deleteReferenceButton.addEventListener("click",()=>this.deleteReference());for(const t of this.referenceFields)t.addEventListener("input",()=>this.updateReference());this.referenceUsePoseButton.addEventListener("click",()=>this.useWitnessPoseForReference()),this.addReferenceUrlButton.addEventListener("click",()=>this.addReferenceFromAddress()),this.addReferenceFileInput.addEventListener("change",()=>void this.addReferenceFromFile()),this.addReferenceLandmarkButton.addEventListener("click",()=>this.armLandmark()),this.deleteReferenceLandmarkButton.addEventListener("click",()=>this.deleteLandmark()),this.referenceLandmarksSelect.addEventListener("change",()=>this.selectLandmark(this.referenceLandmarksSelect.value)),this.referenceLandmarkLabelInput.addEventListener("input",()=>this.updateLandmarkLabel()),this.referenceAdoptPoseButton.addEventListener("click",()=>this.adoptReferencePose()),this.referenceStreetSearchButton.addEventListener("click",()=>void this.searchStreetPictures()),this.referenceStreetAddButton.addEventListener("click",()=>this.addStreetPicture()),this.ufoElement.canvasElement.addEventListener("wheel",t=>this.onReferenceWheel(t),{passive:!1});for(const t of[this.decorTitleInput,this.decorEastInput,this.decorNorthInput,this.decorAltitudeInput,this.decorHeadingInput,this.decorColorInput,this.decorSightingUrlInput,this.decorWidthInput,this.decorLengthInput,this.decorHeightInput,this.decorModelUrlInput,this.decorModelTitleInput,this.decorModelAuthorInput,this.decorModelLicenseInput,this.decorModelSourceInput,this.decorFloorsInput,this.decorOccupiedFloorInput])t.addEventListener("input",()=>this.updateDecor());this.decorWitnessSideSelect.addEventListener("change",()=>this.updateDecor()),this.decorModelSelect.addEventListener("change",()=>this.updateDecorModelChoice()),this.addMilestoneButton.addEventListener("click",()=>this.addMilestone()),this.deleteMilestoneButton.addEventListener("click",()=>this.deleteMilestone()),this.milestoneSelect.addEventListener("change",()=>this.selectMilestone(Number(this.milestoneSelect.value)));for(const t of[this.milestoneLabelInput,this.milestoneNoteInput])t.addEventListener("input",()=>this.updateMilestone());this.confirmAcceptButton.addEventListener("click",()=>this.answerConfirm(!0)),this.confirmDeclineButton.addEventListener("click",()=>this.answerConfirm(!1)),this.confirmOverlay.addEventListener("click",t=>{t.target===this.confirmOverlay&&this.answerConfirm(!1)});for(const t of _r)this.decorWindowInputs[t].addEventListener("input",()=>this.updateDecorWindows());this.decorLitInput.addEventListener("input",()=>this.updateDecorLit()),this.decorLightRigSelect.addEventListener("change",()=>this.updateDecorLightRig()),this.lookAtDecorButton.addEventListener("click",()=>this.lookAtDecor()),this.showMeteorButton.addEventListener("click",()=>this.showNextMeteor()),this.showCometButton.addEventListener("click",()=>this.lookAtComet()),this.showNovaButton.addEventListener("click",()=>this.lookAtNova()),this.showSatelliteButton.addEventListener("click",()=>this.showNextSatellite()),this.sceneElement.addEventListener(X1,()=>{this.skyCandidatesKey=void 0,this.refreshSkyCandidates()}),this.ufoElement.addEventListener("timeupdate",()=>{this.onSelectionOrTimeChanged(),this.syncPlaybackControls(),this.dispatchEvent(new CustomEvent("sightingchange"))}),this.addEventListener("keydown",this.handleKeyDown);for(const t of ng)this.presetButtons[t].addEventListener("click",()=>this.setAppearance({presetId:t}));this.colorInput.addEventListener("input",()=>this.setAppearance({color:this.colorInput.value})),this.transparencyInput.addEventListener("input",()=>this.setAppearance({transparency:Number(this.transparencyInput.value)})),this.brightnessInput.addEventListener("input",()=>this.setAppearance({brightness:Number(this.brightnessInput.value)})),this.blurInput.addEventListener("input",()=>{this.setAppearance({blur:Number(this.blurInput.value)}),this.refreshBlurDistanceBound()}),this.haloScaleInput.addEventListener("input",()=>this.setAppearance({haloScale:Number(this.haloScaleInput.value)}));for(const t of[this.latInput,this.lngInput,this.headingInput,this.pitchInput,this.rollInput,this.elevationInput])t.addEventListener("input",()=>this.updateObserver());for(const t of[this.focalLengthInput,this.fNumberInput,this.exposureInput,this.focusDistanceInput])t.addEventListener("input",()=>this.updateObserver());this.searchPlaceButton.addEventListener("click",()=>void this.searchPlace()),this.placeNameInput.addEventListener("keydown",t=>{t.key==="Enter"&&(t.preventDefault(),this.searchPlace())}),this.placeMatchSelect.addEventListener("change",()=>this.applyPlaceMatch(this.placeMatchSelect.selectedIndex)),this.placeNameInput.addEventListener("input",()=>this.updatePlaceName()),this.headingInput.addEventListener("focus",()=>this.sceneElement.setCompassForced(!0)),this.headingInput.addEventListener("input",()=>this.refreshHeadingPoint()),this.headingInput.addEventListener("blur",()=>this.sceneElement.setCompassForced(!1)),this.instrumentSelect.addEventListener("change",()=>{const t=this.ufoElement.sighting.instrument;this.ufoElement.sighting.instrumentId=this.instrumentSelect.value;const i=new Map(this.ufoElement.sighting.timeline.allKeyframes.map(n=>[n.t,gi.fovOf(this.ufoElement.sighting,n.t)]));this.retuneFieldOfView(t),this.retuneExposure(t),gi.reproject(this.ufoElement.sighting,t,i),this.sceneElement.applyFrameFormat(),this.syncOpticsFromInstrument(),this.ufoElement.refresh(),this.dispatchEvent(new CustomEvent("sightingchange"))}),this.utcOffsetInput.addEventListener("input",()=>this.updateUtcOffset()),this.timeZoneSelect.addEventListener("change",()=>{this.autoFilledTimeZone=void 0,this.updateTimeZone()}),this.obsTimeInput.addEventListener("input",()=>this.updateObservationTime()),this.obsEndTimeInput.addEventListener("input",()=>this.updateObservationEndTime()),this.obsTimeNativeInput.addEventListener("change",()=>this.writeFromPicker(this.obsTimeNativeInput,this.obsTimeQualifier,this.obsTimeInput,()=>this.updateObservationTime())),this.obsEndTimeNativeInput.addEventListener("change",()=>this.writeFromPicker(this.obsEndTimeNativeInput,this.obsEndTimeQualifier,this.obsEndTimeInput,()=>this.updateObservationEndTime())),this.obsTimeQualifier.addEventListener("change",()=>this.writeFromPicker(this.obsTimeNativeInput,this.obsTimeQualifier,this.obsTimeInput,()=>this.updateObservationTime())),this.obsEndTimeQualifier.addEventListener("change",()=>this.writeFromPicker(this.obsEndTimeNativeInput,this.obsEndTimeQualifier,this.obsEndTimeInput,()=>this.updateObservationEndTime())),this.edtfModeButton.addEventListener("click",()=>this.setEdtfMode(!this.edtfMode)),this.obsTimeInput.addEventListener("blur",()=>this.validateEdtfTimeInput(this.obsTimeInput)),this.obsEndTimeInput.addEventListener("blur",()=>this.validateEdtfTimeInput(this.obsEndTimeInput));for(const t of[this.witnessIdInput,this.witnessDirNameInput,this.witnessTitleInput,this.witnessLastNameInput,this.witnessFirstNamesInput,this.witnessAgeInput,this.witnessOccupationInput,this.caseIdInput])t.addEventListener("input",()=>this.updateWitnessMetadata());this.descriptionInput.addEventListener("input",()=>{this.updateDescription(),this.syncNarrativeEnabled()}),this.tagsInput.addEventListener("input",()=>this.updateTags());for(const t of this.weatherFields){if(t===this.iceCrystalAlignmentInput){t.addEventListener("input",()=>this.applyIceAlignmentAtPlayhead());continue}t.addEventListener("input",()=>this.applyWeatherAtPlayhead())}for(const t of this.soundFields)t.addEventListener("input",()=>this.applySoundAtPlayhead());this.weatherInferredInput.addEventListener("change",()=>this.onWeatherInferredToggled()),this.skyDetailsButton=this.shadow.getElementById("sky-details"),this.clampedLines=[this.shadow.getElementById("weather-source"),this.shadow.getElementById("sky-candidates")],this.skyDetailsButton.addEventListener("click",()=>this.toggleSkyDetails()),this.groupTabs=[...this.shadow.querySelectorAll(".group-tab")],this.groupPanels=this.groupTabs.map(t=>this.shadow.getElementById(t.getAttribute("aria-controls")));for(const t of this.groupTabs)t.addEventListener("click",()=>this.toggleGroup(t,!this.isGroupOpen(t)));this.subgroupTabs=[...this.shadow.querySelectorAll(".subgroup-tab")];for(const t of this.subgroupTabs)t.addEventListener("click",()=>this.openSubgroup(t));this.paramSummary=this.shadow.getElementById("param-summary"),this.paramSummaryBuilder=new tp(this.messages,this.showerLanguage(),this.said,this.tagNames),this.paramSummary.addEventListener("click",t=>this.onParamSummaryClick(t)),this.toggleGroup(this.groupTabs[this.groupTabs.length-1],!0),this.updatePresetButtons(),this.setRecordButtonLabel(!1),this.applyAppearanceAtPlayhead(),this.shapeTitleInput.value=this.shapeLabel(this.currentSourceId),this.updateShapeTitle(),this.currentDecorId=this.ufoElement.sighting.decor[0]?.id,this.refreshDecorList(),this.currentReferenceId=this.ufoElement.sighting.references[0]?.id,this.refreshReferenceList(),this.sceneElement.setCloudRendering("volume"),this.cloudEditor=Cv(this.shadow.getElementById("cloud-editor"),this.sceneElement,(t=!0)=>{t&&(this.weatherFromRecords=!1,this.cancelWeatherLookup(),this.ufoElement.sighting.weatherSource=void 0,this.syncWeatherSourceState())},(t,i)=>{this.headingInput.value=String(this.rounded(t)),this.pitchInput.value=String(this.rounded(i)),this.updateObserver()},fa(Ns.preferencesFor(this),bd)),this.currentMilestoneT=this.ufoElement.sighting.milestones[0]?.t,this.refreshMilestoneList(),this.onSelectionOrTimeChanged(),this.syncDurationField(),this.syncPlaybackControls(),this.refreshSourceRows(),this.refreshTimeQualifierOptions(),this.refreshTimeZoneOptions(),this.syncWeatherSourceState(),this.loadLocaleMessages()}static get observedAttributes(){return["src"]}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=-1);const e=this.getAttribute("src");e&&this.importFromUrl(e)}attributeChangedCallback(e,t,i){e==="src"&&i&&i!==t&&this.isConnected&&this.importFromUrl(i)}disconnectedCallback(){this.cloudEditor.stopManipulation(),document.removeEventListener("click",this.handleOutsideContextMenuClick),this.endDrag()}setCloudRendering(e){this.sceneElement.setCloudRendering(e)}showWeatherEditor(){const e=this.groupPanels.findIndex(t=>t.id==="group-weather");e>=0&&this.toggleGroup(this.groupTabs[e],!0)}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.endDrag(),this.ufoElement.sightingData=e,this.cloudEditor.reset(),this.currentSourceId=this.ufoElement.sighting.timeline.sourceIds[0]??Wl,this.selectedSourceIds=new Set([this.currentSourceId]),this.refreshSourceList(),this.currentDecorId=this.ufoElement.sighting.decor[0]?.id,this.refreshDecorList(),this.currentReferenceId=this.ufoElement.sighting.references[0]?.id,this.refreshReferenceList(),this.currentMilestoneT=this.ufoElement.sighting.milestones[0]?.t,this.refreshMilestoneList(),this.onSelectionOrTimeChanged(),this.syncDurationField(),this.syncObservationTimeFields(),this.syncObservationEndTimeFields(),this.chooseTimeInputMode(),this.syncWitnessMetadataFields(),this.refreshTimeZoneOptions(),this.utcOffsetInput.readOnly=this.ufoElement.sighting.event.timeZone!==void 0,this.syncUtcOffsetField(),this.syncPlaceNameField(),this.syncGroundElevationField(),this.syncWeatherOwnership()}exportJson(){const e=this.sightingData,t=`${e.witness?.id??"sighting"}-sighting.json`,i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),s=document.createElement("a");s.href=n,s.download=t,s.click(),URL.revokeObjectURL(n)}async importFromFile(){const e=this.importFileInput.files?.[0];if(e)try{const t=await new Promise((i,n)=>{const s=new FileReader;s.onload=()=>i(s.result),s.onerror=()=>n(s.error),s.readAsText(e)});this.sightingData=JSON.parse(t),this.importUrlInput.value=""}catch{window.alert(this.messages.importError)}finally{this.importFileInput.value=""}}async importFromUrl(e=this.importUrlInput.value.trim()){if(e)try{this.sightingData=await Xu.json(e),this.importUrlInput.value=new URL(e,location.href).href}catch(t){window.alert(this.importErrorFor(t))}}importErrorFor(e){if(!(e instanceof js))return this.messages.importError;switch(e.kind){case"cors":return this.messages.importErrorCors;case"mixed-content":return this.messages.importErrorMixedContent;case"unreachable":return this.messages.importErrorUnreachable;case"status":return this.messages.importErrorStatus.replace("{status}",String(e.status??""));case"malformed":return this.messages.importErrorMalformed;default:return this.messages.importError}}static NARRATIVE_KEY_STORAGE="rr0-sighting-editor.narrative-key";static NARRATIVE_SCOPE_STORAGE="rr0-sighting-editor.narrative-workspace";narrativeProvider=Vs[0].create();narrativeAbort;async draftFromDescription(){const e=this.descriptionInput.value.trim();if(e===""||this.narrativeAbort)return;const t=this.narrativeAbort=new AbortController;this.setNarrativeBusy(!0);try{const i=await this.narrativeProvider.draft({ask:e,current:this.sightingData,language:this.showerLanguage()==="fr"?"French":"English",credential:this.narrativeKeyInput.value.trim()||void 0,credentialScope:this.narrativeWorkspaceInput.value.trim()||void 0},t.signal);this.applyNarrativeDraft(i)}catch(i){const n=i instanceof Wi&&i.kind==="cancelled";this.narrativeStatus.textContent=n?"":this.narrativeErrorFor(i),this.narrativeStatus.classList.toggle("error",!n)}finally{this.narrativeAbort=void 0,this.setNarrativeBusy(!1)}}applyNarrativeDraft(e){const{description:t,...i}=e.recording,{utcOffsetHours:n,...s}=i,a=i.timeZone?s:i,o=Ln.stated(a);if(o.length>0){const l=this.ufoElement.sighting.provenance,c=yd(this.ufoElement.sighting);this.sightingData=Ln.apply(c,rc.loadable(a),o),this.ufoElement.sighting.provenance=l,this.recordNarrativeProvenance(e,o),this.ufoElement.sighting.event.timeZone&&this.applyTimeZoneOffset()}this.narrativeStatus.textContent=o.length>0?this.messages.narrativeApplied.replace("{count}",String(o.length)):this.messages.narrativeUnchanged,this.narrativeStatus.classList.remove("error"),this.showNarrativeReport(e),this.syncNarrativeEnabled()}recordNarrativeProvenance(e,t){const i=this.ufoElement.sighting,n=new Set(t);for(const s of e.claims)!n.has(s.path)&&!t.some(a=>s.path.startsWith(`${a}.`))||i.provenance.set(s.path,{basis:s.basis,rationale:s.rationale,of:Ct.valueAt(yd(this.ufoElement.sighting),s.path)})}static valueAt(e,t){let i=e;for(const n of t.split(".")){if(typeof i!="object"||i===null)return;i=i[n]}return i}showNarrativeReport(e){this.narrativeReport.replaceChildren();for(const t of["assumed","derived","stated"]){const i=e.claims.filter(n=>n.basis===t);if(i.length!==0){this.narrativeReport.append(this.narrativeHeading(this.messages[oA[t]]));for(const n of i){const s=document.createElement("div");s.className=`claim ${t}`;const a=document.createElement("code");a.textContent=n.path;const o=document.createElement(t==="stated"?"q":"span");o.textContent=n.rationale,s.append(a,o),this.narrativeReport.append(s)}}}if(e.gaps.length>0){this.narrativeReport.append(this.narrativeHeading(this.messages.narrativeGaps));const t=document.createElement("ul");t.className="gaps";for(const i of e.gaps){const n=document.createElement("li");n.textContent=i,t.append(n)}this.narrativeReport.append(t)}this.narrativeReport.hidden=this.narrativeReport.childElementCount===0}narrativeHeading(e){const t=document.createElement("h4");return t.textContent=e,t}setNarrativeBusy(e){this.descriptionInput.disabled=e,this.narrativeStopButton.hidden=!e,e&&(this.narrativeStatus.textContent=this.messages.narrativeWorking,this.narrativeStatus.classList.remove("error")),this.syncNarrativeEnabled()}syncNarrativeEnabled(){const e=Vs[0].name,t=this.narrativeProvider.needsCredential&&this.narrativeKeyInput.value.trim()==="",i=this.descriptionInput.value.trim()==="";this.narrativeDraftButton.disabled=!!this.narrativeAbort||t||i,this.narrativeDraftButton.title=t?this.messages.narrativeNeedsKey.replace("{source}",e):i?this.messages.narrativeNeedsAsk:"",this.narrativeKeyInput.parentElement.hidden=!this.narrativeProvider.needsCredential,this.narrativeRememberInput.parentElement.hidden=!this.narrativeProvider.needsCredential,this.narrativeWorkspaceInput.parentElement.hidden=!this.narrativeProvider.acceptsCredentialScope;const n=this.narrativeKeyInput.value.trim(),s=n!==""&&!n.startsWith("sk-ant-");this.narrativeKeyInput.classList.toggle("invalid",s),this.narrativeKeyInput.title=s?this.messages.narrativeKeyUnlikely:""}narrativeErrorFor(e){if(!(e instanceof Wi))return this.messages.narrativeErrorMalformed;switch(e.kind){case"rejected":return this.messages.narrativeErrorRejected.replace("{detail}",e.detail??"");case"credential":return this.messages.narrativeErrorCredential;case"rate-limited":return this.messages.narrativeErrorRateLimited;case"refused":return this.messages.narrativeErrorRefused;case"unreachable":return this.messages.narrativeErrorUnreachable;default:return this.messages.narrativeErrorMalformed}}rememberNarrativeKey(){try{this.narrativeRememberInput.checked?(localStorage.setItem(Ct.NARRATIVE_KEY_STORAGE,this.narrativeKeyInput.value),localStorage.setItem(Ct.NARRATIVE_SCOPE_STORAGE,this.narrativeWorkspaceInput.value)):(localStorage.removeItem(Ct.NARRATIVE_KEY_STORAGE),localStorage.removeItem(Ct.NARRATIVE_SCOPE_STORAGE))}catch{}}restoreNarrativeKey(){let e=null;try{e=localStorage.getItem(Ct.NARRATIVE_KEY_STORAGE)}catch{return}e!==null&&(this.narrativeKeyInput.value=e,this.narrativeWorkspaceInput.value=localStorage.getItem(Ct.NARRATIVE_SCOPE_STORAGE)??"",this.narrativeRememberInput.checked=!0)}numberOrUndefined(e){return e===""?void 0:Number(e)}stringOrUndefined(e){return e===""?void 0:e}wrapDegrees(e,t){if(e===void 0)return;const i=(e%360+360)%360;return String(i)!==t.value&&(t.value=String(i)),i}refreshSourceRows(){this.placeSourceRow.replaceChildren(document.createTextNode(`${this.messages.according} `),this.sourcePicker("place",HT,e=>{this.placeProvider=e.create()})),this.weatherSourceRow.replaceChildren(this.sourcePicker("weather",GT,e=>{this.weatherInference=new rd(e.create()),this.scheduleWeatherLookup()})),this.terrainSourceRows.replaceChildren(this.labelledPicker("elevation",this.messages.sourceElevation,cd,()=>this.applyTerrainSources()),this.labelledPicker("imagery",this.messages.sourceImagery,jm,()=>this.applyTerrainSources()),this.labelledPicker("decor-model",this.messages.decorModel,jl,()=>this.applyDecorModelSource()))}sourcePicker(e,t,i){const n=document.createDocumentFragment(),s=document.createElement("select");s.id=`${e}Source`;for(const l of t){const c=document.createElement("option");c.value=l.id,c.textContent=l.name,c.title=l.credit,s.appendChild(c)}s.value=this.chosenSourceId.get(e)??t[0].id;const a=document.createElement("a");a.className="source-credit",a.target="_blank",a.rel="noopener noreferrer";const o=()=>{const l=Qr(t,s.value);s.title=l.credit,a.href=l.creditUrl,a.textContent=l.credit};return o(),s.addEventListener("change",()=>{this.chosenSourceId.set(e,s.value),o(),i(Qr(t,s.value))}),n.append(s,document.createTextNode(" "),a),n}labelledPicker(e,t,i,n){const s=document.createElement("label"),a=document.createElement("span");return a.textContent=t,s.append(a,this.sourcePicker(e,i,n)),s}applyTerrainSources(){this.sceneElement.setTerrainProviders({elevation:Qr(cd,this.chosenSourceId.get("elevation")).create(),imagery:Qr(jm,this.chosenSourceId.get("imagery")).create()}),this.ufoElement.refresh()}applyDecorModelSource(){this.decorModelProvider=Qr(jl,this.chosenSourceId.get("decor-model")).create(),this.sceneElement.setDecorModelProvider(this.decorModelProvider),this.refreshDecorModelOptions(),this.ufoElement.refresh()}get placeSearchLanguage(){return navigator.languages?.[0]}set placeSearchProvider(e){this.placeProvider=e}async searchPlace(){const e=this.placeNameInput.value.trim();if(e==="")return;const t=++this.placeSearchToken;this.placeStatusText.textContent=this.messages.placeSearching;let i;try{i=await this.placeProvider.search(e,{language:this.placeSearchLanguage})}catch{if(t!==this.placeSearchToken)return;this.placeStatusText.textContent=this.messages.placeSearchFailed;return}t===this.placeSearchToken&&(this.placeMatches=i,this.refreshPlaceMatches(),i.length>0&&this.applyPlaceMatch(0))}refreshPlaceMatches(){this.placeMatchSelect.replaceChildren(...this.placeMatches.map(t=>{const i=document.createElement("option");return i.textContent=t.name,i.title=t.name,i})),this.placeMatchRow.hidden=this.placeMatches.length===0;const e=this.placeMatches.length===1?this.messages.placeMatchFound:this.messages.placeMatchesFound;this.placeStatusText.textContent=this.placeMatches.length===0?this.messages.placeNotFound:`${this.placeMatches.length} ${e} `,this.placeSourceRow.hidden=this.placeMatches.length===0}applyPlaceMatch(e){const t=this.placeMatches[e];t&&(this.placeMatchSelect.selectedIndex=e,this.placeNameInput.value=t.name,this.placeNameInput.title=t.name,this.latInput.value=String(t.lat),this.lngInput.value=String(t.lng),this.namedCoordinates={lat:t.lat,lng:t.lng},this.updateObserver())}updatePlaceName(){this.placeMatches=[],this.placeMatchRow.hidden=!0,this.placeStatusText.textContent="",this.placeSourceRow.hidden=!0,this.placeNameInput.title=this.placeNameInput.value,this.namedCoordinates=void 0,this.updateObserver()}schedulePlaceReverse(){if(!this.namedCoordinates)return;const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value);e===void 0||t===void 0||Math.abs(e-this.namedCoordinates.lat)<ta&&Math.abs(t-this.namedCoordinates.lng)<ta||(clearTimeout(this.placeReverseTimer),this.placeReverseTimer=setTimeout(()=>void this.reversePlace(e,t),eg))}scheduleTimeZoneLookup(){const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value);if(e===void 0||t===void 0)return;const i=this.ufoElement.sighting.event.timeZone;if(i&&i!==this.autoFilledTimeZone)return;const n=this.timeZoneLookedUpAt;n&&Math.abs(e-n.lat)<ta&&Math.abs(t-n.lng)<ta||(clearTimeout(this.timeZoneLookupTimer),this.timeZoneLookupTimer=setTimeout(()=>void this.lookUpTimeZone(e,t),eg))}async lookUpTimeZone(e,t){this.timeZoneLookedUpAt={lat:e,lng:t};const i=await this.timeZoneProvider.zoneAt(e,t),n=this.ufoElement.sighting.event.timeZone;!i||n&&n!==this.autoFilledTimeZone||this.timeZones.available().includes(i)&&(this.autoFilledTimeZone=i,this.timeZoneSelect.value=i,this.updateTimeZone(),this.dispatchEvent(new CustomEvent("sightingchange")))}async reversePlace(e,t){const i=++this.placeSearchToken;let n;try{n=await this.placeProvider.reverse(e,t,{language:this.placeSearchLanguage})}catch{return}i===this.placeSearchToken&&(this.namedCoordinates={lat:e,lng:t},this.placeNameInput.value=n?.name??"",this.placeNameInput.title=n?.name??"",this.placeMatches=[],this.placeMatchRow.hidden=!0,this.placeStatusText.textContent=n?"":this.messages.placeNotFound,this.placeSourceRow.hidden=!n,this.updateObserver())}updateObserver(){if(this.refreshHeadingPoint(),this.ufoElement.playbackState==="playing")return;const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value),i=this.wrapDegrees(this.numberOrUndefined(this.headingInput.value),this.headingInput),n=this.numberOrUndefined(this.pitchInput.value)??0,s=this.numberOrUndefined(this.rollInput.value)??0,a=this.numberOrUndefined(this.elevationInput.value)??this.groundElevationM??0,o=Math.max(0,a-(this.groundElevationM??0)),l=this.ufoElement.sighting.event,c=this.ufoElement.sighting.witnessTrack,h=this.ufoElement.currentTime,d=this.stringOrUndefined(this.placeNameInput.value.trim());l.place=e!==void 0&&t!==void 0?[{lat:e,lng:t,name:d}]:void 0;const u=this.ufoElement.sighting.instrument,f=this.numberOrUndefined(this.focalLengthInput.value),p=(u.frame&&f!==void 0?ct.fieldOfViewDegAt(u,f):f)??this.currentFovDeg(),v=this.numberOrUndefined(this.fNumberInput.value),m=this.statedExposureSeconds(u);this.ufoElement.sighting.exposureSeconds=m===u.exposureSeconds?void 0:m;const g=this.numberOrUndefined(this.focusDistanceInput.value),x=Math.abs(p-ct.fieldOfViewDeg(u))>.01||v!==u.fNumber||g!==void 0;e===void 0&&t===void 0&&i===void 0&&n===0&&s===0&&o===0&&!x?c.removeKeyframeAt(h):c.addKeyframe(h,{lat:e,lng:t,elevationM:o,headingDeg:i,pitchDeg:n,rollDeg:s===0?void 0:s,fovDeg:p,fNumber:v,focusDistanceM:g}),this.ufoElement.refresh(),this.scheduleWeatherLookup(),this.schedulePlaceReverse(),this.scheduleTimeZoneLookup(),this.scheduleGroundElevation(),this.updateUtcOffsetValidity()}applyEdtfTimeInput(e,t){const i=e.value.trim();if(i==="")t(void 0);else{const n=Gf(i);if(!n)return;t(n)}e.setCustomValidity(""),e.classList.remove("invalid"),this.dropDurationOutrankedByDates(),this.ufoElement.sighting.event.timeZone&&this.applyTimeZoneOffset(),this.ufoElement.refresh(),this.syncDurationField(),this.scheduleWeatherLookup()}dropDurationOutrankedByDates(){const e=this.ufoElement.sighting.event;e.durationSeconds!==void 0&&Ea({...e,durationSeconds:void 0})!==void 0&&(this.ufoElement.durationSeconds=void 0)}validateEdtfTimeInput(e){const t=e.value.trim();t===""||Gf(t)||(e.setCustomValidity(this.messages.edtfInvalid),e.classList.add("invalid"))}refreshTimeZoneOptions(){const e=document.createElement("option");e.value="",e.textContent=this.messages.timeZoneManual,this.timeZoneSelect.replaceChildren(e,...this.timeZones.available().map(t=>{const i=document.createElement("option");return i.value=t,i.textContent=t,i})),this.timeZoneSelect.value=this.ufoElement.sighting.event.timeZone??""}updateTimeZone(){const e=this.stringOrUndefined(this.timeZoneSelect.value);this.ufoElement.sighting.event.timeZone=e,this.applyTimeZoneOffset()}applyTimeZoneOffset(){const e=this.ufoElement.sighting.event,t=e.timeZone&&e.time?this.timeZones.offsetHoursAt(e.timeZone,e.time):void 0;t!==void 0&&(e.utcOffsetHours=t),this.utcOffsetInput.readOnly=e.timeZone!==void 0,this.syncUtcOffsetField(),this.ufoElement.refresh(),this.scheduleWeatherLookup()}updateUtcOffset(){this.ufoElement.sighting.event.utcOffsetHours=this.numberOrUndefined(this.utcOffsetInput.value),this.updateUtcOffsetValidity(),this.ufoElement.refresh(),this.scheduleWeatherLookup()}updateObservationTime(){this.applyEdtfTimeInput(this.obsTimeInput,e=>{this.ufoElement.sighting.event.time=e})}updateObservationEndTime(){this.applyEdtfTimeInput(this.obsEndTimeInput,e=>{this.ufoElement.sighting.event.endTime=e})}updateWitnessMetadata(){const e=this.ufoElement.sighting,t=this.witnessFirstNamesInput.value.split(",").map(n=>n.trim()).filter(n=>n.length>0),i={id:this.stringOrUndefined(this.witnessIdInput.value),dirName:this.stringOrUndefined(this.witnessDirNameInput.value),title:this.stringOrUndefined(this.witnessTitleInput.value),lastName:this.stringOrUndefined(this.witnessLastNameInput.value),firstNames:t.length>0?t:void 0};e.witness=Object.values(i).some(n=>n!==void 0)?i:void 0,e.caseId=this.stringOrUndefined(this.caseIdInput.value),this.updateTestimony(),this.ufoElement.refresh()}updateTestimony(){const e=this.ufoElement.sighting,t=this.testimonyFollowedUpSelect.value,i={witnessAgeYears:this.numberOrUndefined(this.witnessAgeInput.value),witnessOccupation:this.witnessOccupationInput.value.trim()===""?void 0:this.said.write(e.testimony?.witnessOccupation,this.witnessOccupationInput.value,this.writingLanguage),source:this.stringOrUndefined(this.testimonySourceSelect.value),followedUp:t===""?void 0:t==="yes"};e.testimony=Object.values(i).some(n=>n!==void 0)?i:void 0}updateDescription(){this.ufoElement.sighting.event.description=this.said.write(this.ufoElement.sighting.event.description,this.descriptionInput.value,this.writingLanguage),this.ufoElement.refresh()}updateTags(){const e=this.tagsInput.value.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>this.tagNames.stored(t));this.ufoElement.sighting.event.tags=e.length>0?e:void 0,this.ufoElement.refresh()}applyWeatherAtPlayhead(){if(this.ufoElement.playbackState==="playing")return;this.sceneElement.resumeWeatherAudio(),this.weatherFromRecords&&(this.weatherFromRecords=!1,this.cancelWeatherLookup(),this.ufoElement.sighting.weatherSource=void 0,this.syncWeatherSourceState());const e={...kt(this.ufoElement.sighting,this.ufoElement.currentTime),cloudCover:Number(this.cloudCoverInput.value),highCloudCover:Number(this.highCloudCoverInput.value),lowerCloudCover:Number(this.cloudCoverInput.value),cloudDarkness:Number(this.cloudDarknessInput.value),cloudBaseM:this.numberOrUndefined(this.cloudBaseInput.value),precipitationType:this.precipitationTypeSelect.value,precipitationIntensity:Number(this.precipitationIntensityInput.value),windDirectionDeg:this.wrapDegrees(this.numberOrUndefined(this.windDirectionInput.value),this.windDirectionInput)??0,windSpeed:Number(this.windSpeedInput.value),storm:this.stormInput.checked};this.ufoElement.sighting.weatherTrack.addKeyframe(this.ufoElement.currentTime,e),this.ufoElement.refresh()}applyIceAlignmentAtPlayhead(){if(this.ufoElement.playbackState==="playing")return;this.sceneElement.resumeWeatherAudio();const e={...kt(this.ufoElement.sighting,this.ufoElement.currentTime),iceCrystalAlignment:Number(this.iceCrystalAlignmentInput.value)};this.ufoElement.sighting.weatherTrack.addKeyframe(this.ufoElement.currentTime,e),this.ufoElement.refresh()}referenceLabel(e){return this.said.read(e.title)||e.src.replace(/^data:.*$/,"…")||e.id}refreshReferenceList(){const e=this.ufoElement.sighting.references;this.referenceSelect.innerHTML="";for(const t of e){const i=document.createElement("option");i.value=t.id,i.textContent=this.referenceLabel(t),this.referenceSelect.appendChild(i)}this.currentReferenceId!==void 0&&(this.referenceSelect.value=this.currentReferenceId),this.syncReferenceFields()}selectReference(e){this.currentReferenceId=e,this.referenceSelect.value=e,this.disarmLandmark(),this.currentLandmarkId=void 0,this.referenceFit=void 0,this.syncReferenceFields()}syncReferenceFields(){const e=this.ufoElement.sighting.references.find(n=>n.id===this.currentReferenceId),t=e!==void 0;this.deleteReferenceButton.disabled=!t,this.referenceUsePoseButton.disabled=!t;for(const n of[this.referenceSelect,...this.referenceFields])n.disabled=!t,this.setRowVisible(n,t);this.setRowVisible(this.referenceUsePoseButton,t);for(const n of[this.referenceLandmarksSelect,this.addReferenceLandmarkButton,this.deleteReferenceLandmarkButton,this.referenceLandmarkLabelInput])this.setRowVisible(n,t);if(this.refreshLandmarkList(),this.setRowVisible(this.referenceAdoptPoseButton,t),this.syncCanvasMode(),!e){this.referenceStatus.textContent="";return}this.referenceTitleInput.value=this.said.read(e.title)??"";const i=e.src.startsWith("data:");this.referenceSrcInput.value=i?"":e.src,this.referenceSrcInput.disabled=i,this.referenceKindSelect.value=e.kind,this.referenceCreditInput.value=e.credit??"",this.referenceCreditUrlInput.value=e.creditUrl??"",this.referenceTInput.value=e.t===void 0?"":String(e.t/1e3),this.referenceDrawingInput.checked=e.drawing===!0,this.referenceOpacityInput.value=String(e.opacity),this.referenceHeadingInput.value=String(e.registration.headingDeg),this.referencePitchInput.value=String(e.registration.pitchDeg),this.referenceRollInput.value=String(e.registration.rollDeg??0),this.referenceFovInput.value=String(e.registration.fovDeg),this.syncReferenceStatus(e)}syncReferenceStatus(e){if(this.canvasMode()==="picture"){this.syncRegisterStatus();return}if(e.src.startsWith("data:")){const t=Math.round(e.src.length*3/4/1024);this.referenceStatus.textContent=e.src.length>ET?this.messages.referenceEmbedded.replace("{kb}",String(t)):"";return}this.referenceStatus.textContent=this.sceneElement.referenceFailedToLoad(e.src)?this.messages.referenceUnreachable:""}updateReference(){if(this.currentReferenceId===void 0)return;const e=this.ufoElement.sighting,t=this.wrapDegrees(Number(this.referenceHeadingInput.value),this.referenceHeadingInput)??0,i=this.referenceTInput.value.trim()===""?void 0:Number(this.referenceTInput.value);e.references=e.references.map(s=>{if(s.id!==this.currentReferenceId)return s;const a=s.src.startsWith("data:")?s.src:this.referenceSrcInput.value.trim();return{...s,kind:this.referenceKindSelect.value,src:a,title:this.said.write(s.title,this.referenceTitleInput.value,this.writingLanguage),credit:this.stringOrUndefined(this.referenceCreditInput.value),creditUrl:this.stringOrUndefined(this.referenceCreditUrlInput.value),t:i===void 0||Number.isNaN(i)?void 0:Math.round(i*1e3),drawing:this.referenceDrawingInput.checked||void 0,opacity:Number(this.referenceOpacityInput.value),registration:{headingDeg:t,pitchDeg:Number(this.referencePitchInput.value)||0,rollDeg:Number(this.referenceRollInput.value)||void 0,fovDeg:Math.min(179,Math.max(1,Number(this.referenceFovInput.value)||Gl))}}});const n=e.references.find(s=>s.id===this.currentReferenceId);this.referenceSelect.options[this.referenceSelect.selectedIndex].textContent=this.referenceLabel(n),this.syncReferenceStatus(n),this.ufoElement.refresh()}useWitnessPoseForReference(){const e=nt(this.ufoElement.sighting,this.ufoElement.currentTime);e&&(this.referenceHeadingInput.value=String(this.rounded(e.headingDeg??0)),this.referencePitchInput.value=String(this.rounded(e.pitchDeg)),this.referenceRollInput.value=String(this.rounded(e.rollDeg??0)),this.referenceFovInput.value=String(this.rounded(e.fovDeg)),this.updateReference())}addReference(e,t,i={}){const n=this.ufoElement.sighting,s=nt(this.ufoElement.sighting,this.ufoElement.currentTime),a=`picture-${n.references.length+1}`,o={id:a,kind:"photo",src:e,title:t?this.said.write(void 0,t,this.writingLanguage):void 0,opacity:ST,registration:{headingDeg:s?.headingDeg??0,pitchDeg:s?.pitchDeg??0,fovDeg:Gl},...i};n.references=[...n.references,o],this.currentReferenceId=a,this.refreshReferenceList(),this.ufoElement.refresh()}addReferenceFromAddress(){this.addReference(""),this.referenceSrcInput.focus()}async addReferenceFromFile(){const e=this.addReferenceFileInput.files?.[0];if(!e)return;const t=await new Promise((i,n)=>{const s=new FileReader;s.onload=()=>i(s.result),s.onerror=()=>n(s.error),s.readAsDataURL(e)});this.addReferenceFileInput.value="",this.addReference(t,e.name.replace(/\.[^.]+$/,""))}currentReference(){return this.ufoElement.sighting.references.find(e=>e.id===this.currentReferenceId)}currentLandmarks(){return this.currentReference()?.landmarks??[]}writeLandmarks(e){const t=this.ufoElement.sighting;t.references=t.references.map(i=>i.id===this.currentReferenceId?{...i,landmarks:e.length>0?e:void 0}:i)}beginReferenceDrag(e){const t=this.currentReference();if(!t)return;if(this.armingLandmark||this.pendingLandmark){this.nameLandmarkAt(e);return}const i=this.landmarkEndAt(e);if(i){this.selectLandmark(i.landmarkId),this.referenceDragState={kind:"anchor",...i},this.setCanvasCursor("landmark"),this.startDragListening();return}const n=this.sceneElement.referenceAspect(t.id);if(!(n!==void 0&&Ni.picturePointOf(this.directionAtCanvasPoint(e),t.registration,n)!==void 0)){this.beginCameraDrag(e);return}this.referenceDragState={kind:"picture",startPointer:e,startHeadingDeg:t.registration.headingDeg,startPitchDeg:t.registration.pitchDeg,moved:!1},this.setCanvasCursor("panning"),this.startDragListening()}landmarkEndAt(e){const t=this.currentReference(),i=t?this.sceneElement.referenceAspect(t.id):void 0;if(!t||i===void 0)return;const n=8;for(const s of this.currentLandmarks()){const a=this.canvasPointOfDirection(Ni.worldDirectionOf(s.picture,t.registration,i));if(a&&Math.hypot(a.x-e.x,a.y-e.y)<=n)return{landmarkId:s.id,end:"picture"};const o=this.canvasPointOfDirection(Ni.worldDirection(s.scene));if(o&&Math.hypot(o.x-e.x,o.y-e.y)<=n)return{landmarkId:s.id,end:"scene"}}}onReferenceDragPointerMove(e){const t=this.referenceDragState,i=this.canvasPointFromEvent(e);if(!t||!i)return;if(t.kind==="anchor"){this.moveLandmarkEnd(t.landmarkId,t.end,i);return}const n=i.x-t.startPointer.x,s=i.y-t.startPointer.y;if(!t.moved&&Math.hypot(n,s)<3)return;t.moved=!0;const a=this.currentFovDeg()/this.ufoElement.canvasElement.height;this.referenceHeadingInput.value=String(this.rounded(t.startHeadingDeg+n*a)),this.referencePitchInput.value=String(this.rounded(Math.max(-90,Math.min(90,t.startPitchDeg-s*a)))),this.updateReference()}moveLandmarkEnd(e,t,i){const n=this.currentReference(),s=n?this.sceneElement.referenceAspect(n.id):void 0;if(!n||s===void 0)return;const a=this.directionAtCanvasPoint(i);this.writeLandmarks(this.currentLandmarks().map(o=>{if(o.id!==e)return o;if(t==="scene")return{...o,scene:Ni.aimOf(a)};const l=Ni.picturePointOf(a,n.registration,s);return l?{...o,picture:l}:o})),this.ufoElement.refresh()}endReferenceDrag(){const e=this.referenceDragState;this.referenceDragState=void 0,this.setCanvasCursor(this.canvasMode()==="picture"?"pan":this.hoverCursor),document.removeEventListener("pointermove",this.handleDragPointerMove),document.removeEventListener("pointerup",this.handleDragPointerUp),e?.kind==="anchor"&&this.fitReferenceToLandmarks()}onReferenceWheel(e){if(this.canvasMode()!=="picture")return;e.preventDefault();const t=Number(this.referenceFovInput.value)||Gl,i=Math.min(179,Math.max(1,t*Math.exp(Math.sign(e.deltaY)*.05)));this.referenceFovInput.value=String(this.rounded(i)),this.updateReference()}directionAtCanvasPoint(e){const t=this.ufoElement.canvasElement;return this.sceneElement.directionAt(e.x/t.width*2-1,-(e.y/t.height*2-1))}armLandmark(){this.currentReference()&&(this.armingLandmark=!0,this.pendingLandmark=void 0,this.setCanvasCursor("landmark"),this.syncRegisterStatus(),this.ufoElement.refresh())}disarmLandmark(){this.armingLandmark=!1,this.pendingLandmark=void 0,this.canvasMode()==="picture"&&(this.setCanvasCursor("pan"),this.syncRegisterStatus()),this.ufoElement.refresh()}nameLandmarkAt(e){const t=this.currentReference();if(!t)return;const i=this.directionAtCanvasPoint(e);if(!this.pendingLandmark){const a=this.sceneElement.referenceAspect(t.id);if(a===void 0){this.referenceStatus.textContent=this.messages.referenceNotLoaded;return}const o=Ni.picturePointOf(i,t.registration,a);if(!o){this.referenceStatus.textContent=this.messages.referenceLandmarkOffPicture;return}this.pendingLandmark=o,this.syncRegisterStatus(),this.ufoElement.refresh();return}const n=this.currentLandmarks(),s=this.nextLandmarkId(n);this.writeLandmarks([...n,{id:s,picture:this.pendingLandmark,scene:Ni.aimOf(i)}]),this.armingLandmark=!1,this.pendingLandmark=void 0,this.currentLandmarkId=s,this.setCanvasCursor("pan"),this.fitReferenceToLandmarks()}nextLandmarkId(e){let t=e.length+1;for(;e.some(i=>i.id===`landmark-${t}`);)t++;return`landmark-${t}`}fitReferenceToLandmarks(){const e=this.currentReference(),t=e?this.sceneElement.referenceAspect(e.id):void 0;if(!e||t===void 0)return;const i=this.currentLandmarks(),n=Ni.solve(i,t,e.registration.fovDeg);n?(this.referenceFit={n:i.length,residualDeg:n.residualDeg},this.referenceHeadingInput.value=String(this.rounded(n.registration.headingDeg)),this.referencePitchInput.value=String(this.rounded(n.registration.pitchDeg)),this.referenceRollInput.value=String(this.rounded(n.registration.rollDeg??0)),this.referenceFovInput.value=String(this.rounded(n.registration.fovDeg)),this.updateReference()):this.referenceFit=void 0,this.refreshLandmarkList(),this.syncRegisterStatus(),this.ufoElement.refresh()}landmarkResidualDeg(e,t,i){return Ni.worldDirectionOf(e.picture,t.registration,i).angleTo(Ni.worldDirection(e.scene))*180/Math.PI}landmarkLabel(e,t){const i=this.said.read(e.label);return i?`${t+1} · ${i}`:String(t+1)}refreshLandmarkList(){const e=this.currentReference(),t=this.currentLandmarks(),i=e?this.sceneElement.referenceAspect(e.id):void 0;this.referenceLandmarksSelect.innerHTML="";for(const[s,a]of t.entries()){const o=document.createElement("option");o.value=a.id;const l=e&&i!==void 0?` · ${this.landmarkResidualDeg(a,e,i).toFixed(1)}°`:"";o.textContent=this.landmarkLabel(a,s)+l,this.referenceLandmarksSelect.appendChild(o)}this.currentLandmarkId!==void 0&&!t.some(s=>s.id===this.currentLandmarkId)&&(this.currentLandmarkId=void 0),this.currentLandmarkId!==void 0&&(this.referenceLandmarksSelect.value=this.currentLandmarkId);const n=t.find(s=>s.id===this.currentLandmarkId);this.referenceLandmarksSelect.disabled=t.length===0,this.deleteReferenceLandmarkButton.disabled=n===void 0,this.referenceLandmarkLabelInput.disabled=n===void 0,this.shadow.activeElement!==this.referenceLandmarkLabelInput&&(this.referenceLandmarkLabelInput.value=this.said.read(n?.label)??"")}selectLandmark(e){this.currentLandmarkId=e,this.refreshLandmarkList(),this.ufoElement.refresh()}updateLandmarkLabel(){const e=this.currentLandmarkId;if(e===void 0)return;this.writeLandmarks(this.currentLandmarks().map(o=>o.id===e?{...o,label:this.said.write(o.label,this.referenceLandmarkLabelInput.value,this.writingLanguage)}:o));const t=this.referenceLandmarksSelect.options[this.referenceLandmarksSelect.selectedIndex],i=this.currentLandmarks(),n=i.findIndex(o=>o.id===e),s=this.currentReference(),a=s?this.sceneElement.referenceAspect(s.id):void 0;if(t&&n>=0){const o=s&&a!==void 0?` · ${this.landmarkResidualDeg(i[n],s,a).toFixed(1)}°`:"";t.textContent=this.landmarkLabel(i[n],n)+o}this.ufoElement.refresh()}deleteLandmark(){const e=this.currentLandmarkId;if(e===void 0)return;const t=this.currentLandmarks().filter(i=>i.id!==e);this.writeLandmarks(t),this.currentLandmarkId=t[t.length-1]?.id,this.fitReferenceToLandmarks()}landmarkHint(){const e=this.currentLandmarks().length+1;if(this.pendingLandmark)return this.messages.referenceLandmarkScene.replace("{n}",String(e));if(this.armingLandmark)return this.messages.referenceLandmarkPicture.replace("{n}",String(e))}syncRegisterStatus(){const e=this.landmarkHint();e?this.referenceStatus.textContent=e:this.referenceFit?this.referenceStatus.textContent=this.messages.referenceLandmarksFit.replace("{n}",String(this.referenceFit.n)).replace("{deg}",this.referenceFit.residualDeg.toFixed(1)):this.referenceStatus.textContent=this.messages.referenceRegisterHint}canvasPointOfDirection(e){const t=this.sceneElement.screenPointOf(e);if(!t)return;const i=this.ufoElement.canvasElement;return{x:(t.ndcX+1)/2*i.width,y:(1-t.ndcY)/2*i.height}}paintPictureOverlay=e=>{const t=this.currentReference();if(!t)return;const i=this.sceneElement.referenceAspect(t.id);if(i===void 0)return;const{registration:n}=t,s=[{u:0,v:0},{u:1,v:0},{u:1,v:1},{u:0,v:1}].map(o=>this.canvasPointOfDirection(Ni.worldDirectionOf(o,n,i))),a=this.currentLandmarks().map((o,l)=>({picture:this.canvasPointOfDirection(Ni.worldDirectionOf(o.picture,n,i)),scene:this.canvasPointOfDirection(Ni.worldDirection(o.scene)),label:this.landmarkLabel(o,l),selected:o.id===this.currentLandmarkId,residualDeg:this.landmarkResidualDeg(o,t,i)}));this.pendingLandmark&&a.push({picture:this.canvasPointOfDirection(Ni.worldDirectionOf(this.pendingLandmark,n,i)),scene:void 0,label:String(this.currentLandmarks().length+1),selected:!0,residualDeg:void 0}),e.paintPictureFrame(s.every(o=>o!==void 0)?s:void 0,a.filter(o=>o.picture!==void 0),this.landmarkHint())};adoptReferencePose(){const e=this.currentReference();if(!e)return;const{headingDeg:t,pitchDeg:i,rollDeg:n}=e.registration;this.headingInput.value=String(this.rounded(t)),this.pitchInput.value=String(this.rounded(i)),this.rollInput.value=String(this.rounded(n??0)),this.updateObserver();const s=this.ufoElement.currentTime,a=this.ufoElement.sighting.witnessTrack.toJSON().keyframes.findIndex(c=>c.t===s);if(a<0)return;const o=this.messages.referenceAdoptRationale.replace("{title}",this.referenceLabel(e)).replace("{n}",String(this.currentLandmarks().length)).replace("{deg}",(this.referenceFit?.residualDeg??0).toFixed(1)),l=[["headingDeg",t],["pitchDeg",i],["rollDeg",n??0]];for(const[c,h]of l)this.ufoElement.sighting.provenance.set(`witnessTrack.keyframes.${a}.pose.${c}`,{basis:"derived",rationale:o,of:this.rounded(h)})}syncStreetSearchAvailability(){const e=this.numberOrUndefined(this.latInput.value)!==void 0&&this.numberOrUndefined(this.lngInput.value)!==void 0;this.referenceStreetSearchButton.disabled=!e}async searchStreetPictures(){const e=nt(this.ufoElement.sighting,0),t=e?.lat??this.numberOrUndefined(this.latInput.value),i=e?.lng??this.numberOrUndefined(this.lngInput.value);if(t===void 0||i===void 0)return;const n=300;this.referenceStatus.textContent=this.messages.referenceStreetSearching,this.referenceStreetSearchButton.disabled=!0;try{this.streetPictures=await this.streetPictures$.nearby(t,i,n)}catch{this.streetPictures=[],this.referenceStatus.textContent=this.messages.referenceStreetFailed,this.referenceStreetSearchButton.disabled=!1;return}this.referenceStreetSearchButton.disabled=!1,this.referenceStreetSelect.innerHTML="";for(const[a,o]of this.streetPictures.entries()){const l=document.createElement("option");l.value=String(a),l.textContent=this.streetPictureLabel(o,this.messages.referenceStreetItem),this.referenceStreetSelect.appendChild(l)}const s=this.streetPictures.length>0;this.referenceStreetSelect.hidden=!s,this.referenceStreetAddButton.hidden=!s,this.referenceStatus.textContent=s?"":this.messages.referenceStreetNone.replace("{m}",String(n))}streetPictureLabel(e,t){return t.replace("{distance}",String(Math.round(e.distanceM))).replace("{bearing}",String(Math.round(e.bearingDeg))).replace("{date}",e.takenAt.slice(0,10)).replace("{panorama}",e.panorama?this.messages.referenceStreetPanorama:"")}addStreetPicture(){const e=this.streetPictures[Number(this.referenceStreetSelect.value)];e&&this.addReference(e.src,this.streetPictureLabel(e,this.messages.referenceStreetTitle),{kind:e.panorama?"panorama":"photo",credit:e.credit,creditUrl:e.creditUrl,registration:{headingDeg:e.azimuthDeg??0,pitchDeg:0,fovDeg:Gl}})}deleteReference(){if(this.currentReferenceId===void 0)return;const e=this.ufoElement.sighting;e.references=e.references.filter(t=>t.id!==this.currentReferenceId),this.currentReferenceId=e.references[0]?.id,this.refreshReferenceList(),this.ufoElement.refresh()}buildSoundKindOptions(){for(const e of bv){const t=document.createElement("option");t.value=e,t.textContent=this.soundKindLabel(e,this.messages),this.soundKindOptions.set(e,t),this.soundKindSelect.appendChild(t)}}soundKindLabel(e,t){switch(e){case"hum":return t.soundHum;case"whistle":return t.soundWhistle;case"rumble":return t.soundRumble;case"crackle":return t.soundCrackle;default:return t.soundNone}}applySoundAtPlayhead(){if(this.ufoElement.playbackState==="playing")return;const e=this.readSound();this.ufoElement.sighting.soundTrack.addKeyframe(this.ufoElement.currentTime,e),this.updateSoundPitchReadout(e.pitchHz),this.updateSoundFieldsDisabledState(e),this.ufoElement.refresh(),this.previewSound(e)}previewSound(e){clearTimeout(this.soundPreviewTimer),this.ufoElement.previewSound(e),this.soundPreviewTimer=setTimeout(()=>this.ufoElement.stopSoundPreview(),$T)}readSound(){return{kind:this.soundKindSelect.value,volume:Number(this.soundVolumeInput.value),pitchHz:Number(this.soundPitchInput.value),src:this.soundSrcInput.value.trim()||void 0}}syncSoundFromTimeline(){if(this.ufoElement.playbackState==="playing")return;const e=Wu(this.ufoElement.sighting,this.ufoElement.currentTime),t=this.shadow.activeElement;t!==this.soundKindSelect&&(this.soundKindSelect.value=e.kind),t!==this.soundVolumeInput&&(this.soundVolumeInput.value=String(e.volume)),t!==this.soundPitchInput&&(this.soundPitchInput.value=String(e.pitchHz)),t!==this.soundSrcInput&&(this.soundSrcInput.value=e.src??""),this.updateSoundPitchReadout(e.pitchHz),this.updateSoundFieldsDisabledState(e)}updateSoundPitchReadout(e){this.soundPitchValue.textContent=`${Math.round(e)} Hz`}updateSoundFieldsDisabledState(e){const t=e.kind==="none"&&!e.src;this.soundVolumeInput.disabled=t,this.soundSrcInput.disabled=t,this.soundPitchInput.disabled=t||e.src!==void 0}set weatherProvider(e){this.weatherInference=new rd(e),this.scheduleWeatherLookup()}onWeatherInferredToggled(){this.weatherFromRecords=this.weatherInferredInput.checked,this.weatherFromRecords?this.scheduleWeatherLookup():(this.cancelWeatherLookup(),this.ufoElement.sighting.weatherSource=void 0,this.syncWeatherSourceState())}scheduleWeatherLookup(){this.weatherFromRecords&&(clearTimeout(this.weatherLookupTimer),this.weatherLookupTimer=setTimeout(()=>void this.inferWeather(),ZT))}cancelWeatherLookup(){clearTimeout(this.weatherLookupTimer),this.weatherLookupToken++,this.weatherLookupPending=!1}async inferWeather(){if(!this.weatherFromRecords)return;const e=++this.weatherLookupToken;this.weatherLookupPending=!0,this.syncWeatherSourceState();const t=await this.weatherInference.infer(this.ufoElement.sighting);e!==this.weatherLookupToken||!this.weatherFromRecords||(this.weatherLookupPending=!1,this.weatherLookupResult=t,t.status==="inferred"?(this.weatherInference.applyTo(this.ufoElement.sighting,t),this.weatherTrackSpan=this.ufoElement.seekableDuration,this.ufoElement.refresh(),this.syncWeatherFromTimeline()):this.ufoElement.sighting.weatherSource=void 0,this.syncWeatherSourceState())}ensureWeatherTrackSpan(){if(!this.weatherFromRecords||this.ufoElement.sighting.weatherSource===void 0)return;const e=this.ufoElement.seekableDuration;this.weatherTrackSpan===void 0||e===this.weatherTrackSpan||(this.weatherTrackSpan=e,this.scheduleWeatherLookup())}syncWeatherSourceState(){const e=this.ufoElement.sighting.weatherSource,t=this.weatherFromRecords;for(const o of this.weatherFields)o.disabled=t&&e!==void 0&&o!==this.iceCrystalAlignmentInput||this.ufoElement.playbackState==="playing",this.ufoElement.playbackState==="playing"?o.title=this.messages.weatherWhilePlaying:o.title===this.messages.weatherWhilePlaying&&(o.title="");const i=this.weatherInference.canInfer(this.ufoElement.sighting);this.weatherInferredInput.disabled=!i,this.weatherInferredInput.checked=i&&this.weatherFromRecords;const n=i?this.messages.weatherInferredTitle:this.messages.weatherNeedsDateAndPlace;this.weatherInferredInput.title=n,this.labelWeatherInferred.title=n;const s=t&&e!==void 0;if(this.weatherSourceLink.hidden=!s,s){this.weatherSourceRow.hidden=!1,this.weatherSourceText.textContent="",this.weatherSourceLink.href=e.url,this.weatherSourceLink.textContent=this.observationInstantLabel();return}const a=t?this.weatherStatusMessage():"";this.weatherSourceText.textContent=a===""?"":`${a} `,this.weatherSourceRow.hidden=a===""}weatherStatusMessage(){if(this.weatherLookupPending)return this.messages.weatherLookingUp;switch(this.weatherLookupResult?.status){case"unavailable":return this.messages.weatherNoRecord;case"failed":return this.messages.weatherLookupFailed;default:return""}}observationInstantLabel(){const e=this.ufoElement.sighting.event,t=e.time&&zn(e.time,e.place?.[0]?.lng??0,e.utcOffsetHours);return t?`, ${t.toISOString().slice(0,16).replace("T"," ")} UTC`:""}syncWeatherOwnership(){const e=this.ufoElement.sighting;this.cancelWeatherLookup(),this.weatherLookupResult=void 0,this.weatherFromRecords=e.weatherSource!==void 0||e.weatherTrack.allKeyframes.length===0,this.syncWeatherSourceState(),this.weatherFromRecords&&e.weatherSource===void 0&&this.scheduleWeatherLookup()}syncDurationField(){if(this.shadow.activeElement!==this.durationInput){const e=Ea(this.ufoElement.sighting.event);this.durationInput.value=e!==void 0?String(e/1e3):""}this.updateDurationValidity()}updateDurationValidity(){const e=this.durationInput.value==="";this.durationInput.classList.toggle("missing-required",e),this.markUnansweredQuestions(),this.durationInput.setAttribute("aria-invalid",String(e));const t=_v(this.ufoElement.sighting.event);this.durationInput.title=t==="imprecise"?this.messages.durationImprecise:""}syncPlaybackControls(){this.ensureWeatherTrackSpan();const e=this.ufoElement.playbackState==="playing",t=this.ufoElement.seekableDuration>0;this.playPauseButton.textContent=e?"⏸":"▶",this.playPauseButton.disabled=!t;const i=t?e?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=i,this.playPauseButton.setAttribute("aria-label",i),this.seekInput.max=String(this.ufoElement.seekableDuration),this.shadow.activeElement!==this.seekInput&&(this.seekInput.value=String(this.ufoElement.currentTime)),this.timeStartLabel.textContent=this.ufoElement.positionLabel,this.timeEndLabel.textContent=this.ufoElement.durationLabel,this.syncTimeDisplaySwitch()}switchTimeDisplay(){this.ufoElement.toggleTimeDisplay(),this.timeStartLabel.textContent=this.ufoElement.positionLabel,this.timeEndLabel.textContent=this.ufoElement.durationLabel,this.syncTimeDisplaySwitch()}syncTimeDisplaySwitch(){const e=this.ufoElement.canSwitchTimeDisplay,t=this.ufoElement.showingClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime;for(const[i,n]of[[this.timeStartLabel,this.messages.currentPosition],[this.timeEndLabel,this.messages.duration]])i.title=e?`${n} — ${t}`:n,i.classList.toggle("switchable",e),e?(i.setAttribute("role","button"),i.setAttribute("tabindex","0")):(i.removeAttribute("role"),i.removeAttribute("tabindex"))}static TIME_QUALIFIERS=[{value:"",key:"timeQualifierExact"},{value:"~",key:"timeQualifierApproximate"},{value:"?",key:"timeQualifierUncertain"},{value:"%",key:"timeQualifierBoth"}];refreshTimeQualifierOptions(){for(const e of[this.obsTimeQualifier,this.obsEndTimeQualifier]){const t=e.value;e.replaceChildren(...Ct.TIME_QUALIFIERS.map(i=>{const n=document.createElement("option");return n.value=i.value,n.textContent=this.messages[i.key],n})),e.value=t}}qualifierOf(e){const t=e.trim().slice(-1);return"?~%".includes(t)?t:""}isPickable(e){return e?e.year!==void 0&&e.month!==void 0&&e.day!==void 0&&e.hour!==void 0&&e.minute!==void 0&&(e.second===void 0||e.second===0):!1}pickerValueOf(e){if(!this.isPickable(e))return"";const t=(i,n=2)=>String(i).padStart(n,"0");return`${t(e.year,4)}-${t(e.month)}-${t(e.day)}T${t(e.hour)}:${t(e.minute)}`}writeFromPicker(e,t,i,n){e.value===""&&e.validity.badInput||(i.value=e.value===""?"":`${e.value}${t.value}`,n())}chooseTimeInputMode(){const e=this.ufoElement.sighting.event,t=i=>i===void 0||this.isPickable(i);this.setEdtfMode(!(t(e.time)&&t(e.endTime)))}setEdtfMode(e){this.edtfMode=e,this.edtfModeButton.setAttribute("aria-pressed",String(e));for(const[t,i,n]of[[this.obsTimeInput,this.obsTimeNativeInput,this.obsTimeQualifier],[this.obsEndTimeInput,this.obsEndTimeNativeInput,this.obsEndTimeQualifier]])t.hidden=!e,i.hidden=e,n.hidden=e}syncObservationTimeFields(){const e=this.ufoElement.sighting.event.time;this.obsTimeInput.value=e?ic(e):"",this.obsTimeNativeInput.value=this.pickerValueOf(e),this.obsTimeQualifier.value=this.qualifierOf(this.obsTimeInput.value),this.obsTimeInput.setCustomValidity(""),this.obsTimeInput.classList.remove("invalid")}syncObservationEndTimeFields(){const e=this.ufoElement.sighting.event.endTime;this.obsEndTimeInput.value=e?ic(e):"",this.obsEndTimeNativeInput.value=this.pickerValueOf(e),this.obsEndTimeQualifier.value=this.qualifierOf(this.obsEndTimeInput.value),this.obsEndTimeInput.setCustomValidity(""),this.obsEndTimeInput.classList.remove("invalid")}syncUtcOffsetField(){const e=this.ufoElement.sighting.event.utcOffsetHours;this.utcOffsetInput.value=e===void 0?"":String(e),this.updateUtcOffsetValidity()}updateUtcOffsetValidity(){const e=this.ufoElement.sighting.event.utcOffsetHours,t=this.ufoElement.sighting.event.place?.[0]?.lng,i=t===void 0?void 0:Math.round(t/15),n=e!==void 0&&i!==void 0&&Math.abs(e-i)>QT;this.utcOffsetInput.classList.toggle("invalid",n),this.utcOffsetInput.title=n?this.messages.utcOffsetImplausible.replace("{solar}",i>=0?`+${i}`:String(i)):""}scheduleGroundElevation(){const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value);e===void 0||t===void 0||this.groundElevationFor&&this.isSamePlace(this.groundElevationFor,e,t)||(clearTimeout(this.groundElevationTimer),this.groundElevationTimer=setTimeout(()=>void this.applyGroundElevation(e,t),JT))}isSamePlace(e,t,i){return Math.abs(e.lat-t)<ta&&Math.abs(e.lng-i)<ta}async applyGroundElevation(e,t){const i=++this.groundElevationToken,n=Qr(cd,this.chosenSourceId.get("elevation")),s=await new Cf(n.create()).at(e,t);if(i!==this.groundElevationToken||s===void 0)return;this.groundElevationFor={lat:e,lng:t};const a=Math.max(0,(this.numberOrUndefined(this.elevationInput.value)??0)-(this.groundElevationM??0));this.groundElevationM=Math.round(s),this.syncElevationField(a),this.updateObserver()}syncElevationField(e){const t=this.groundElevationM;this.elevationInput.value=String(Math.round((t??0)+e)),this.elevationInput.min=t===void 0?"":String(t),this.elevationInput.title=t===void 0?"":this.messages.altitudeAboveSeaLevel,this.groundElevationOutput.textContent=t===void 0?"":this.messages.groundAt.replace("{m}",String(t))}syncGroundElevationField(){this.groundElevationToken++,clearTimeout(this.groundElevationTimer),this.groundElevationM=void 0,this.groundElevationFor=void 0,this.syncElevationField(nt(this.ufoElement.sighting,0)?.elevationM??0),this.scheduleGroundElevation()}syncPlaceNameField(){const e=this.ufoElement.sighting.event.place?.[0],t=e?.name??"";this.placeNameInput.value=t,this.placeNameInput.title=t,this.namedCoordinates=e&&t?{lat:e.lat,lng:e.lng}:void 0,this.placeMatches=[],this.placeMatchRow.hidden=!0,this.placeStatusText.textContent=""}syncWitnessMetadataFields(){const e=this.ufoElement.sighting;this.witnessIdInput.value=e.witness?.id??"",this.witnessDirNameInput.value=e.witness?.dirName??"",this.witnessTitleInput.value=e.witness?.title??"",this.witnessLastNameInput.value=e.witness?.lastName??"",this.witnessFirstNamesInput.value=e.witness?.firstNames?.join(", ")??"",this.caseIdInput.value=e.caseId??"",this.witnessAgeInput.value=e.testimony?.witnessAgeYears?.toString()??"",this.witnessOccupationInput.value=this.said.read(e.testimony?.witnessOccupation)??"",this.testimonySourceSelect.value=e.testimony?.source??"",this.testimonyFollowedUpSelect.value=e.testimony?.followedUp===void 0?"":e.testimony.followedUp?"yes":"no",this.descriptionInput.value=this.said.read(e.event.description)??"",this.showTags(),this.instrumentSelect.value=e.instrument.id}syncWeatherFromTimeline(){if(this.cloudEditor?.sync(),this.ufoElement.playbackState==="playing")return;const e=kt(this.ufoElement.sighting,this.ufoElement.currentTime),t=this.shadow.activeElement;t!==this.cloudCoverInput&&(this.cloudCoverInput.value=String(e.cloudCover)),t!==this.highCloudCoverInput&&(this.highCloudCoverInput.value=String(e.highCloudCover??0)),t!==this.iceCrystalAlignmentInput&&(this.iceCrystalAlignmentInput.value=String(e.iceCrystalAlignment??.65)),t!==this.cloudDarknessInput&&(this.cloudDarknessInput.value=String(e.cloudDarkness)),t!==this.cloudBaseInput&&(this.cloudBaseInput.value=e.cloudBaseM===void 0?"":String(e.cloudBaseM)),t!==this.precipitationTypeSelect&&(this.precipitationTypeSelect.value=e.precipitationType),t!==this.precipitationIntensityInput&&(this.precipitationIntensityInput.value=String(e.precipitationIntensity)),t!==this.windDirectionInput&&(this.windDirectionInput.value=String(Math.round(e.windDirectionDeg))),t!==this.windSpeedInput&&(this.windSpeedInput.value=String(Math.round(e.windSpeed*2)/2)),t!==this.stormInput&&(this.stormInput.checked=e.storm)}syncObserverFromTimeline(){if(this.ufoElement.playbackState==="playing")return;this.syncStreetSearchAvailability();const e=this.ufoElement.sighting,t=e.witnessTrack.getInterpolatedPoseAt(this.ufoElement.currentTime),i=e.event.place?.[0],n=this.shadow.activeElement;n!==this.latInput&&(this.latInput.value=t?.lat!==void 0?String(t.lat):i?String(i.lat):""),n!==this.lngInput&&(this.lngInput.value=t?.lng!==void 0?String(t.lng):i?String(i.lng):""),n!==this.headingInput&&(this.headingInput.value=t?.headingDeg!==void 0?String(this.rounded(t.headingDeg)):""),this.refreshHeadingPoint(),n!==this.pitchInput&&(this.pitchInput.value=String(this.rounded(t?.pitchDeg??0)),this.rollInput.value=String(this.rounded(t?.rollDeg??0))),n!==this.elevationInput&&this.syncElevationField(t?.elevationM??0)}get appearance(){return{...this.currentAppearance}}set appearance(e){this.setAppearance(e)}setAppearance(e){const t="presetId"in e;this.currentAppearance={...this.currentAppearance,...e},this.updatePresetButtons(),!(this.isRecording||this.ufoElement.playbackState==="playing")&&this.applyAppearanceAtPlayhead(void 0,t)}applyAppearanceAtPlayhead(e,t=!0){const i=this.ufoElement.sighting.timeline,n=this.ufoElement.currentTime,s=i.getInterpolatedShapeAt(n,this.currentSourceId),a=this.buildAppearanceShape(e??s?.bounds??this.defaultBounds(),s,t);this.commitShapes(n,[{sourceId:this.currentSourceId,shape:a}]),this.ufoElement.refresh()}buildAppearanceShape(e,t,i=!0){if(t&&!i)return{...t,color:this.currentAppearance.color,transparency:this.currentAppearance.transparency,haloScale:this.currentAppearance.haloScale,blur:this.currentAppearance.blur,brightness:this.currentAppearance.brightness};const n=zf(e,this.currentAppearance);return t?{...n,angle:t.angle,title:t.title,selected:t.selected}:n}toggleSkyDetails(){const e=this.skyDetailsButton.getAttribute("aria-expanded")!=="true";this.skyDetailsButton.setAttribute("aria-expanded",String(e)),this.skyDetailsButton.textContent=e?"▴":"▾",this.skyDetailsButton.title=e?this.messages.skyDetailsHide:this.messages.skyDetails,this.skyDetailsButton.setAttribute("aria-label",this.skyDetailsButton.title);for(const t of this.clampedLines)t.classList.toggle("clamped",!e)}isGroupOpen(e){return e.getAttribute("aria-expanded")==="true"}toggleGroup(e,t){this.cloudEditor?.stopManipulation();for(const[i,n]of this.groupTabs.entries()){const s=n===e&&t;n.setAttribute("aria-expanded",String(s)),this.groupPanels[i].hidden=!s}this.syncCanvasMode()}isGroupIdOpen(e){const t=this.groupTabs.find(i=>i.getAttribute("aria-controls")===e);return t!==void 0&&this.isGroupOpen(t)}canvasMode(){return this.isGroupIdOpen("group-reference")&&this.currentReferenceId!==void 0?"picture":this.isGroupIdOpen("group-shape")?"shape":"scene"}syncCanvasMode(){const e=this.canvasMode(),t=e==="picture",i=this.lastCanvasMode==="picture",n=e!==this.lastCanvasMode;this.lastCanvasMode=e,this.ufoElement.selectionShown=e==="shape",this.ufoElement.overlayPainter=t?this.paintPictureOverlay:void 0,n&&this.ufoElement.refresh(),t!==i&&this.setCanvasCursor(t?"pan":this.hoverCursor),!t&&(this.armingLandmark||this.pendingLandmark)&&this.disarmLandmark();const s=this.currentReference();s&&this.syncReferenceStatus(s),this.syncStreetSearchAvailability()}openSubgroup(e){this.cloudEditor?.stopManipulation();const t=e.parentElement;for(const i of this.subgroupTabs){if(i.parentElement!==t)continue;const n=i===e;i.setAttribute("aria-expanded",String(n)),this.shadow.getElementById(i.getAttribute("aria-controls")).hidden=!n}}revealSubgroupOf(e){const t=e.closest(".subgroup-panel"),i=t&&this.subgroupTabs.find(n=>n.getAttribute("aria-controls")===t.id);i&&this.openSubgroup(i)}static SUMMARY_GROUPS=["observation","witness","location","decor","temporal","weather","sound"];static PANEL_ORDER=["observation","witness","location","decor","temporal","weather","sound","shape"];refreshParamSummary(){const t=this.paramSummaryBuilder.entriesFor(this.ufoElement.sighting,this.ufoElement.currentTime,{decorId:this.currentDecorId,decorPicker:!0,groundElevationM:this.groundElevationM??0}).map(n=>({...n,panel:Ct.SUMMARY_GROUPS.indexOf(n.group)})),i=t.map(n=>`${n.field}=${n.label}=${n.value}${n.unit}${n.fromSource?"*":""}`).join("|");i!==this.paramSummarySignature&&(this.paramSummarySignature=i,this.paramChips=t,this.renderParamSummary(),this.runAssessments())}paramChips=[];renderParamSummary(){const e=Ct.NESTED_GROUPS,t=[];let i;for(const n of[...this.paramChips,...this.assessmentChips]){if(i&&i.group!==n.group&&(i=void 0),e.includes(n.group)&&!i){const a=document.createElement("span");a.className="param-nest",a.dataset.group=n.group;const o=document.createElement("span");o.className="param-nest-label",o.textContent=n.group==="assessment"?this.messages.assessmentGroup:Ct.tabLabel(this.groupTabs[Ct.SUMMARY_GROUPS.indexOf(n.group)]),a.append(o),i={group:n.group,element:a},t.push(a)}const s=this.paramChip(n);i?i.element.append(s):t.push(s)}this.paramSummary.replaceChildren(...t)}static NESTED_GROUPS=["witness","decor","assessment"];static QUESTION_FIELDS={when:{panel:"temporal",fields:["obs-time","obs-time-native"]},where:{panel:"location",fields:["lat","lng"]},facing:{panel:"location",fields:["heading"]},"apparent-size":{panel:"shape",fields:[]},"sky-position":{panel:"shape",fields:[]},"how-long":{panel:"temporal",fields:["durationSeconds","obs-end-time","obs-end-time-native"]},appearance:{panel:"shape",fields:["shapeTitle","color"]},movement:{panel:"shape",fields:[]},sound:{panel:"sound",fields:["soundKind"]},conditions:{panel:"weather",fields:["cloudCover"]}};assessmentChips=[];assessmentToken=0;async runAssessments(){const e=++this.assessmentToken,t=await new Uv(this.messages).read(this.ufoElement.sighting);e===this.assessmentToken&&(this.assessmentChips=t.entries.map(i=>({...i,panel:Ct.PANEL_ORDER.indexOf(i.about??"")})),this.markUnansweredQuestions(t.unanswered),this.renderParamSummary())}static tabLabel(e){return(e.querySelector("span:not(.tab-badge)")??e).textContent.trim()}static badgeOn(e){const t=e.querySelector(".tab-badge");if(t)return t;const i=document.createElement("span");return i.className="tab-badge",i.hidden=!0,e.append(i),i}unansweredQuestions=new Set;markUnansweredQuestions(e=this.unansweredQuestions){this.unansweredQuestions=e;const t=new Set;for(const s of e){const a=Ct.QUESTION_FIELDS[s];if(a&&!a.fields.some(o=>this.shadow.getElementById(o)?.classList.contains("missing-required")))for(const o of a.fields){const l=this.shadow.getElementById(o);l&&!l.hidden&&l.value===""&&t.add(o)}}for(const[s,a]of Object.entries(Ct.QUESTION_FIELDS))for(const o of Ct.QUESTION_FIELDS[s].fields){const l=this.shadow.getElementById(o);if(!l)continue;const c=t.has(o)&&!l.classList.contains("missing-required");l.classList.toggle("wanted",c),(c||l.title===this.messages.questionUnanswered)&&(l.title=c?this.messages.questionUnanswered:"")}const i=new Map;let n;for(const[s,a]of Object.entries(Ct.QUESTION_FIELDS))for(const o of a.fields){const l=this.shadow.getElementById(o);if(!l)continue;const c=l.classList.contains("missing-required");!c&&!l.classList.contains("wanted")||(c&&(n=a.panel),i.set(a.panel,(i.get(a.panel)??0)+1))}for(const[s,a]of this.groupTabs.entries()){const o=Ct.PANEL_ORDER[s],l=i.get(o)??0,c=o===n,h=Ct.badgeOn(a);h.hidden=l===0,h.textContent=String(l),h.classList.toggle("optional",!c),a.title=l===0?"":c?this.messages.durationRequired:this.messages.questionsUnanswered.replace("{count}",String(l))}}paramChip(e){const t=document.createElement("button");t.type="button",t.className=e.fromSource?"param-chip from-source":"param-chip",t.dataset.panel=String(e.panel),t.dataset.field=e.field;const i=document.createElement("span");if(i.className="param-chip-label",i.textContent=`${e.label} `,t.append(i),e.color!==void 0){const s=document.createElement("span");s.className="param-chip-swatch",s.style.background=e.color,t.append(s)}const n=document.createElement("span");return n.className="param-chip-value",n.textContent=e.unit===""?e.value:`${e.value} ${e.unit}`,t.append(n),t}onParamSummaryClick(e){const t=e.target.closest(".param-chip");if(t==null)return;const i=Number(t.dataset.panel);if(i<0)return;const n=this.groupPanels[i];this.toggleGroup(this.groupTabs[i],!0);const s=t.dataset.field;if(s.startsWith("decor:")){this.currentDecorId=s.slice(6),this.refreshDecorList(),this.decorSelect.focus();return}const a=this.shadow.getElementById(s);a===null||!n.contains(a)||(this.revealSubgroupOf(a),a.focus(),a instanceof HTMLInputElement&&a.type!=="checkbox"&&a.type!=="color"&&a.type!=="range"&&a.select(),a.scrollIntoView?.({block:"center"}))}onSelectionOrTimeChanged(){this.syncAppearanceFromTimeline(),this.syncObserverFromTimeline(),this.syncWeatherFromTimeline(),this.syncWeatherSourceState(),this.syncSoundFromTimeline(),this.syncDecorLitFromTimeline(),this.syncDecorPlacementFromTimeline(),this.syncIndoorLookReset(),this.updateAppearanceFieldsDisabledState(),this.updateShapeTitleValidity(),this.refreshRealSize(),this.refreshBlurDistanceBound(),this.refreshSkyCandidates(),this.refreshInstrumentOptions(),this.syncOpticsFromInstrument(),this.ufoElement.selectedSourceIds=this.selectedSourceIds;const e=this.ufoElement.sighting.timeline.sourceIds,t=e.filter(i=>this.selectedSourceIds.has(i)).length;this.deleteShapeButton.disabled=this.isRecording||this.ufoElement.playbackState==="playing"||t===0||e.length-t<1,this.refreshParamSummary()}updateAppearanceFieldsDisabledState(){const e=this.selectedSourceIds.size>1,t=e?this.messages.multipleShapesSelected:"";for(const i of[this.shapeTitleInput,this.colorInput,this.transparencyInput,this.haloScaleInput,this.blurInput,this.brightnessInput,this.apparentWidthInput,this.realWidthInput,this.objectDistanceInput,this.sizeLockSelect,this.clearDistanceHypothesisButton,this.sourceSelect,...Object.values(this.presetButtons)])i.disabled=e,i.title=t}syncAppearanceFromTimeline(){if(this.ufoElement.playbackState==="playing"||this.selectedSourceIds.size>1)return;const e=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId);e&&(this.currentAppearance={presetId:sA(e),color:e.color,transparency:e.transparency,haloScale:e.haloScale,blur:e.blur??0,brightness:e.brightness??0},this.updatePresetButtons(),this.colorInput.value=this.currentAppearance.color,this.transparencyInput.value=String(this.currentAppearance.transparency),this.haloScaleInput.value=String(this.currentAppearance.haloScale),this.blurInput.value=String(this.currentAppearance.blur),this.brightnessInput.value=String(this.currentAppearance.brightness),this.shadow.activeElement!==this.shapeTitleInput&&(this.shapeTitleInput.value=this.said.read(e.title)??""),this.refreshApparentSize())}updateShapeTitle(){const e=this.ufoElement.sighting.timeline,t=this.ufoElement.currentTime,i=e.getInterpolatedShapeAt(t,this.currentSourceId);i&&(this.commitShapes(t,[{sourceId:this.currentSourceId,shape:{...i,title:this.said.write(i.title,this.shapeTitleInput.value,this.writingLanguage)}}]),this.ufoElement.refresh(),this.refreshSourceList(),this.updateShapeTitleValidity())}sizeLock="none";onApparentWidthInput(){const e=this.numberOrUndefined(this.apparentWidthInput.value);if(!(e===void 0||e<=0||this.selectedSourceIds.size!==1)){if(this.sizeLock==="real"){const t=this.numberOrUndefined(this.realWidthInput.value);t!==void 0&&t>0&&this.sceneElement.setDistanceHypothesis(this.currentSourceId,it.distanceMAt(t,e))}this.applyApparentWidth(e)}}onRealWidthInput(){const e=this.numberOrUndefined(this.realWidthInput.value);if(e===void 0||e<=0||this.selectedSourceIds.size!==1)return;if(this.sizeLock==="apparent"){const i=this.currentApparentWidthDeg();i!==void 0&&i>0&&(this.sceneElement.setDistanceHypothesis(this.currentSourceId,it.distanceMAt(e,i)),this.refreshDepth());return}const t=this.currentDistanceM();t!==void 0&&t>0&&this.applyApparentWidth(it.angularWidthDeg({sizeM:e,distanceM:t}))}onDistanceInput(){const e=this.numberOrUndefined(this.objectDistanceInput.value);e===void 0||e<=0||this.applyDistance(e)}applyDistance(e){if(this.selectedSourceIds.size===1){if(this.sizeLock!=="apparent"){const t=this.numberOrUndefined(this.realWidthInput.value);t!==void 0&&t>0&&this.applyApparentWidth(it.angularWidthDeg({sizeM:t,distanceM:e}))}this.sceneElement.setDistanceHypothesis(this.currentSourceId,e),this.refreshDepth()}}applySizeLock(){this.sizeLock=this.sizeLockSelect.value,this.apparentWidthInput.readOnly=this.sizeLock==="apparent",this.realWidthInput.readOnly=this.sizeLock==="real",this.objectDistanceInput.readOnly=this.sizeLock==="distance"}currentApparentWidthDeg(){const e=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId);if(e)return e.angular?.widthDeg??this.currentProjection().pxToDeg(e.bounds.width)}currentDistanceM(){return this.sceneElement.depthOf(this.currentSourceId)?.distanceM}applyApparentWidth(e){const t=this.ufoElement.sighting.timeline,i=this.ufoElement.currentTime,n=t.getInterpolatedShapeAt(i,this.currentSourceId);if(!n)return;const s=this.currentProjection(),a=s.degToPx(e),o=n.bounds.height*(n.bounds.width===0?1:a/n.bounds.width),l={x:n.bounds.x+(n.bounds.width-a)/2,y:n.bounds.y+(n.bounds.height-o)/2,width:a,height:o},c=s.ofBounds(l),h=n.kind==="oval"?{...n,bounds:l,angular:c}:{...n,bounds:l,angular:c,points:this.scalePoints(n,l)};this.commitShapes(i,[{sourceId:this.currentSourceId,shape:h}]),this.ufoElement.refresh(),this.refreshApparentSize()}scalePoints(e,t){const i=e.bounds.width===0?1:t.width/e.bounds.width,n=e.bounds.height===0?1:t.height/e.bounds.height;return e.points.map(s=>({x:s.x*i,y:s.y*n}))}refreshInstrumentOptions(){const e=this.ufoElement.sighting,t=e.event.time?.year,i=ct.availableAt(t),n=e.instrument,s=i.includes(n)?i:[...i,n],a=this.instrumentSelect.value||n.id;this.instrumentSelect.replaceChildren();for(const o of s){const l=document.createElement("option");l.value=o.id;const c=o.name[this.showerLanguage()];l.textContent=i.includes(o)?c:this.messages.instrumentOutOfPeriod.replace("{name}",c),this.instrumentSelect.appendChild(l)}this.instrumentSelect.value=s.some(o=>o.id===a)?a:n.id}static exposureText(e){return e>=1?String(Math.round(e*100)/100):`1/${Math.round(1/e)}`}statedExposureSeconds(e){const t=Ct.exposureSeconds(this.exposureInput.value),i=e.exposureRangeSeconds;if(!i)return e.exposureSeconds??t;if(t!==void 0)return Math.min(i.max,Math.max(i.min,t))}static exposureSeconds(e){const t=e.trim();if(!t)return;const i=/^(\d*\.?\d+)\s*\/\s*(\d*\.?\d+)$/.exec(t);if(i){const s=Number(i[1]),a=Number(i[2]);return a>0?s/a:void 0}const n=Number(t);return Number.isFinite(n)&&n>0?n:void 0}syncOpticsFromInstrument(){const e=this.ufoElement.sighting,t=e.instrument,i=nt(e,this.ufoElement.currentTime),n=t.frame,s=i?.fovDeg??ct.fieldOfViewDeg(t),a=n?ct.focalLengthMmFor(t,s):s;this.focalLengthInput!==this.shadow.activeElement&&(this.focalLengthInput.value=a===void 0?"":String(Math.round(a*10)/10)),this.unitFocalLength.textContent=n?this.messages.unitMillimetres:this.messages.unitDegrees,this.labelFocalLength.textContent=n?this.messages.focalLength:this.messages.fieldOfView,this.focalLengthInput.disabled=n!==void 0&&n.focalRangeMm===void 0,this.focalLengthInput.min=String(n?.focalRangeMm?.minMm??1),this.focalLengthInput.max=String(n?.focalRangeMm?.maxMm??2e3);const o=i?.fNumber??t.fNumber;this.fNumberInput!==this.shadow.activeElement&&(this.fNumberInput.value=o===void 0?"":String(o)),this.setRowVisible(this.fNumberInput,t.fNumber!==void 0),this.fNumberInput.disabled=t.fNumberRange===void 0,this.fNumberInput.min=String(t.fNumberRange?.min??.7),this.fNumberInput.max=String(t.fNumberRange?.max??64);const l=e.exposure;this.exposureInput!==this.shadow.activeElement&&(this.exposureInput.value=l===void 0?"":Ct.exposureText(l)),this.setRowVisible(this.exposureInput,t.exposureSeconds!==void 0),this.exposureInput.disabled=t.exposureRangeSeconds===void 0,this.focusDistanceInput!==this.shadow.activeElement&&(this.focusDistanceInput.value=i?.focusDistanceM===void 0?"":String(i.focusDistanceM)),this.setRowVisible(this.focusDistanceInput,n!==void 0&&t.fNumber!==void 0)}retuneFieldOfView(e){const t=this.ufoElement.sighting,i=ct.fieldOfViewDeg(e),n=ct.fieldOfViewDeg(t.instrument);for(const s of[...t.witnessTrack.allKeyframes])Math.abs(s.pose.fovDeg-i)>eA||t.witnessTrack.addKeyframe(s.t,{...s.pose,fovDeg:n})}retuneExposure(e){const t=this.ufoElement.sighting,i=t.exposureSeconds,n=t.instrument.exposureRangeSeconds;if(i===void 0||i===e.exposureSeconds||!n){t.exposureSeconds=void 0;return}t.exposureSeconds=Math.min(n.max,Math.max(n.min,i))}currentFovDeg(){const e=this.ufoElement.sighting;return nt(e,this.ufoElement.currentTime)?.fovDeg??ct.fieldOfViewDeg(e.instrument)}currentProjection(){return gn.of(this.ufoElement.sighting.instrument,this.ufoElement.canvasElement.height,this.currentFovDeg())}refreshApparentSize(){const e=this.selectedSourceIds.size===1?this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId):void 0;if(!e){this.apparentSizeOutput.textContent="",this.hasFocus(this.apparentWidthInput)||(this.apparentWidthInput.value=""),this.refreshRealSize();return}const t=e.angular?.widthDeg??this.currentProjection().pxToDeg(e.bounds.width),i=it.inMoons(t);this.hasFocus(this.apparentWidthInput)||(this.apparentWidthInput.value=this.plain(t,t<1?2:1)),this.apparentSizeOutput.textContent=this.messages.apparentSize.replace("{moons}",i.toLocaleString(void 0,{maximumFractionDigits:i<10?1:0})),this.refreshRealSize()}hasFocus(e){return this.typingIn===e}typingIn;typing(e,t){this.typingIn=e;try{t()}finally{this.typingIn=void 0}}plain(e,t){return String(Number(e.toFixed(t)))}refreshBlurDistanceBound(){const e=this.currentAppearance.blur;if(e<=0||this.selectedSourceIds.size!==1){this.blurBoundOutput.textContent="";return}const t=this.ufoElement.sighting.instrument,i=t.frame;if(!i){this.blurBoundOutput.textContent=this.messages.blurBoundNoInstrument;return}const n=nt(this.ufoElement.sighting,this.ufoElement.currentTime),s=n?.focusDistanceM;if(s!==void 0){this.blurBoundOutput.textContent=this.messages.blurBoundNotAtInfinity.replace("{focus}",this.meters(s));return}const a=(n?ct.focalLengthMmFor(t,n.fovDeg):void 0)??i.focalLengthMm,o=n?.fNumber??t.fNumber;if(o===void 0||a<=0){this.blurBoundOutput.textContent="";return}const l=this.ufoElement.canvasElement.height;if(l<=0)return;const c=2*fd*e/l*i.heightMm,h=a*a/(o*c)/1e3;this.blurBoundOutput.textContent=this.messages.blurBound.replace("{max}",this.meters(h))}refreshRealSize(){if(this.refreshDepth(),this.selectedSourceIds.size!==1){this.realSizeOutput.textContent="";return}const e=this.currentSourceId;if(this.sceneElement.sizeContradictory(e)){this.realSizeOutput.textContent=this.messages.realSizeContradiction;return}const{minM:t,maxM:i}=this.sceneElement.sizeRangeOf(e);if(t===void 0&&i===void 0){this.realSizeOutput.textContent=this.messages.realSizeUnknown;return}const n=this.numberOrUndefined(this.realWidthInput.value),s=n!==void 0&&(t!==void 0&&n<t||i!==void 0&&n>i)?this.messages.realSizeOutside:"";if(t!==void 0&&i!==void 0){const a=this.sceneElement.distanceRangeAt(e,this.ufoElement.currentTime),o=a.minM===void 0||a.maxM===void 0?"":this.messages.realDistanceHere.replace("{min}",this.meters(a.minM)).replace("{max}",this.meters(a.maxM));this.realSizeOutput.textContent=this.messages.realSizeBetween.replace("{min}",this.meters(t)).replace("{max}",this.meters(i))+o+s;return}this.realSizeOutput.textContent=(t!==void 0?this.messages.realSizeAtLeast.replace("{min}",this.meters(t)):this.messages.realSizeAtMost.replace("{max}",this.meters(i)))+s}decimal(e,t){return e.toLocaleString(void 0,{minimumFractionDigits:t,maximumFractionDigits:t})}clearDistanceHypothesis(){this.selectedSourceIds.size===1&&(this.sceneElement.setDistanceHypothesis(this.currentSourceId,void 0),this.refreshDepth())}refreshDepth(){const e=this.selectedSourceIds.size===1?this.sceneElement.depthOf(this.currentSourceId):void 0;if(!e){this.depthBasisOutput.textContent="",this.hasFocus(this.objectDistanceInput)||(this.objectDistanceInput.value=""),this.hasFocus(this.realWidthInput)||(this.realWidthInput.value="");return}const t=this.meters(e.distanceM);this.hasFocus(this.objectDistanceInput)||(this.objectDistanceInput.value=this.plain(e.distanceM,e.distanceM<10?1:0));const i=this.currentApparentWidthDeg();if(!this.hasFocus(this.realWidthInput)){const s=i===void 0||i<=0?void 0:it.sizeMAt(e.distanceM,i);this.realWidthInput.value=s===void 0?"":this.plain(s,s<1?2:s<10?1:0)}this.clearDistanceHypothesisButton.hidden=e.basis!=="hypothesis";const n={stated:this.messages.depthStated,hypothesis:this.messages.depthHypothesis,derived:this.messages.depthDerived,bounded:this.messages.depthBounded,conventional:this.messages.depthConventional}[e.basis];this.depthBasisOutput.textContent=n.replace("{m}",t)}commitShapes(e,t){const i=this.ufoElement.sighting,n=gn.of(i.instrument,it.CANVAS_HEIGHT_PX,gi.fovOf(i,e));i.timeline.addKeyframe(e,t.map(s=>{const a=gi.aimOf(i,e,s.shape.bounds),o=n.ofBounds(s.shape.bounds);return{...s,shape:a?{...s.shape,aim:a,angular:o}:{...s.shape,angular:o}}}))}meters(e){const t=e<1?2:e<10?1:0;return e.toLocaleString(void 0,{maximumFractionDigits:t})}updateShapeTitleValidity(){const e=this.selectedSourceIds.size===1&&this.shapeTitleInput.value==="";this.shapeTitleInput.classList.toggle("invalid",e),this.shapeTitleInput.setAttribute("aria-invalid",String(e))}shapeLabel(e){const t=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,e),i=this.said.read(t?.title);if(i)return i;const n=/^ufo-(\d+)$/.exec(e);return n?`${this.messages.shape} ${n[1]}`:e}addShape(){if(this.isRecording)return;const e=this.ufoElement.sighting.timeline,t=new Set([...e.sourceIds,this.currentSourceId]);let i=t.size+1;for(;t.has(`ufo-${i}`);)i++;this.currentSourceId=`ufo-${i}`,this.selectedSourceIds=new Set([this.currentSourceId]),this.applyAppearanceAtPlayhead(this.offsetDefaultBounds(e.sourceIds.length)),this.shapeTitleInput.value=this.shapeLabel(this.currentSourceId),this.updateShapeTitle()}deleteShape(){if(this.isRecording||this.ufoElement.playbackState==="playing")return;const e=this.ufoElement.sighting.timeline,t=e.sourceIds.filter(n=>this.selectedSourceIds.has(n));if(t.length===0||e.sourceIds.length-t.length<1)return;const i=t.length===1?this.messages.confirmDeleteShape.replace("{name}",this.shapeLabel(t[0])):this.messages.confirmDeleteShapes.replace("{count}",String(t.length));this.askConfirm(i,()=>this.removeShapes(t))}removeShapes(e){const t=this.ufoElement.sighting.timeline;for(const i of e)t.removeSource(i);this.currentSourceId=t.sourceIds[0],this.selectedSourceIds=new Set([this.currentSourceId]),this.refreshSourceList(),this.ufoElement.refresh()}askConfirm(e,t){this.answerConfirm(!1),this.confirmMessage.textContent=e,this.confirmOverlay.hidden=!1,this.confirmAcceptButton.focus(),this.confirmAnswer=t}answerConfirm(e){const t=this.confirmAnswer;this.confirmAnswer=void 0,this.confirmOverlay.hidden=!0,e&&t?.()}offsetDefaultBounds(e){const t=this.defaultBounds(),i=24;return{...t,x:t.x+e*i,y:t.y+e*i}}refreshSourceList(){const e=this.ufoElement.sighting.timeline,t=[...new Set([...e.sourceIds,this.currentSourceId])];this.sourceSelect.innerHTML="";for(const i of t){const n=document.createElement("option");n.value=i,n.textContent=this.shapeLabel(i),this.sourceSelect.appendChild(n)}this.sourceSelect.value=this.currentSourceId}decorLabel(e){const t=this.said.read(e.title);if(t)return t;const n=this.ufoElement.sighting.decor.filter(a=>a.kind===e.kind).indexOf(e)+1;return`${this.decorKindSelect.querySelector(`option[value="${e.kind}"]`)?.textContent??e.kind} ${n}`}addDecor(e=this.decorKindSelect.value){const t=this.ufoElement.sighting,n={id:`decor-${t.decor.length+1}`,kind:e,title:this.nextDecorLabel(e),eastM:8*t.decor.length,northM:15,headingDeg:0,lit:!1,...e==="aircraft"?this.defaultAircraft():{},...e==="building"?{floors:ua}:{},windows:ug(e)};t.decor=[...t.decor,n],this.currentDecorId=n.id,this.refreshDecorList(),this.ufoElement.refresh()}defaultAircraft(){const e=2*hd,t=Math.round(e/iA*1e3);return{lights:Xc.byId("airliner")?.create(),track:[{t:0,eastM:-hd,northM:1e3,altitudeM:1500,headingDeg:90},{t,eastM:hd,northM:1e3,altitudeM:1500,headingDeg:90}]}}nextDecorLabel(e){const t=this.ufoElement.sighting.decor.filter(n=>n.kind===e).length;return`${this.decorKindSelect.querySelector(`option[value="${e}"]`)?.textContent??e} ${t+1}`}deleteDecor(){if(this.currentDecorId===void 0)return;const e=this.ufoElement.sighting;e.decor=e.decor.filter(t=>t.id!==this.currentDecorId),this.currentDecorId=e.decor[0]?.id,this.refreshDecorList(),this.ufoElement.refresh()}selectDecor(e){this.currentDecorId=e,this.decorSelect.value=e,this.syncDecorFields()}updateDecor(){if(this.currentDecorId===void 0)return;const e=this.ufoElement.sighting,t=this.wrapDegrees(Number(this.decorHeadingInput.value),this.decorHeadingInput)??0,i=this.decorWitnessSideSelect.value;e.decor=e.decor.map(n=>{if(n.id!==this.currentDecorId)return n;const s=ra(n.kind)&&i!==""?i:void 0,a=Number(this.decorEastInput.value),o=Number(this.decorNorthInput.value),l=Number(this.decorAltitudeInput.value),c=n.track??(l!==0?[]:void 0);if(c){const h=this.ufoElement.currentTime,d={t:h,eastM:a,northM:o,altitudeM:l,headingDeg:t},u=c.filter(f=>f.t!==h);return{...n,title:this.said.write(n.title,this.decorTitleInput.value,this.writingLanguage),color:this.statedDecorColor(n),track:[...u,d].sort((f,p)=>f.t-p.t),sightingUrl:this.stringOrUndefined(this.decorSightingUrlInput.value),witnessSide:s,sizeM:this.statedDecorSize(),model:this.statedDecorModel(),floors:n.kind==="building"?Number(this.decorFloorsInput.value):void 0,occupiedFloor:n.kind==="building"?Number(this.decorOccupiedFloorInput.value):void 0}}return{...n,title:this.said.write(void 0,this.decorTitleInput.value,this.writingLanguage),color:this.statedDecorColor(n),eastM:a,northM:o,headingDeg:t,sightingUrl:this.stringOrUndefined(this.decorSightingUrlInput.value),witnessSide:s,sizeM:this.statedDecorSize(),model:this.statedDecorModel(),floors:n.kind==="building"?Number(this.decorFloorsInput.value):void 0,occupiedFloor:n.kind==="building"?Number(this.decorOccupiedFloorInput.value):void 0}}),this.decorSelect.options[this.decorSelect.selectedIndex].textContent=this.decorLabel(e.decor.find(n=>n.id===this.currentDecorId)),this.syncDecorVisibility(),this.updateDecorTitleValidity(),this.ufoElement.refresh()}syncDecorSizeFields(e){const t=e?li.naturalSize(e.kind,e.floors):void 0,i=[[this.decorWidthInput,e?.sizeM?.widthM,t?.widthM],[this.decorLengthInput,e?.sizeM?.lengthM,t?.lengthM],[this.decorHeightInput,e?.sizeM?.heightM,t?.heightM]];for(const[n,s,a]of i)n.value=s===void 0?"":String(this.roundedMeters(s)),n.placeholder=a===void 0?"":String(this.roundedMeters(a))}syncDecorModelFields(e){this.refreshDecorModelOptions(e),this.decorModelSelect.value=e?.model?.id??"",this.decorModelUrlInput.value=e?.model?.url??"",this.decorModelTitleInput.value=e?.model?.credit?.title??"",this.decorModelAuthorInput.value=e?.model?.credit?.author??"",this.decorModelLicenseInput.value=e?.model?.credit?.license??"",this.decorModelSourceInput.value=e?.model?.credit?.sourceUrl??"",this.decorModelAdvanced.open=e?.model?.url!==void 0}async refreshDecorModelOptions(e){const t=e??this.ufoElement.sighting.decor.find(a=>a.id===this.currentDecorId),i=t?await this.decorModelProvider.entries(t.kind).catch(()=>[]):[],n=t?.model?.id??"",s=document.createElement("option");s.value="",s.textContent=this.messages.decorModelNone,this.decorModelSelect.replaceChildren(s,...i.map(a=>{const o=document.createElement("option");return o.value=a.id,o.textContent=a.name,o.title=`${a.credit.title}${a.credit.author?` — ${a.credit.author}`:""} (${a.credit.license})`,o})),this.decorModelSelect.value=n}updateDecorModelChoice(){const e=this.decorModelSelect.value;(async()=>{const t=e?await this.decorModelProvider.entry(e).catch(()=>{}):void 0,i=this.ufoElement.sighting.decor.find(n=>n.id===this.currentDecorId);if(t?.sizeM&&i&&!i.sizeM){const n=[[this.decorWidthInput,t.sizeM.widthM],[this.decorLengthInput,t.sizeM.lengthM],[this.decorHeightInput,t.sizeM.heightM]];for(const[s,a]of n)a!==void 0&&(s.value=String(this.roundedMeters(a)))}this.updateDecor()})()}roundedMeters(e){return Math.round(e*100)/100}positiveMeters(e){const t=Number(e);return e.trim()===""||!Number.isFinite(t)||t<=0?void 0:t}statedDecorColor(e){const t=this.decorColorInput.value;return t==="#808080"&&e.color===void 0?void 0:t}statedDecorSize(){const e=this.positiveMeters(this.decorWidthInput.value),t=this.positiveMeters(this.decorLengthInput.value),i=this.positiveMeters(this.decorHeightInput.value);return e===void 0&&t===void 0&&i===void 0?void 0:{widthM:e,lengthM:t,heightM:i}}statedDecorModel(){const e=this.stringOrUndefined(this.decorModelUrlInput.value);if(e){const i=this.stringOrUndefined(this.decorModelTitleInput.value),n=this.stringOrUndefined(this.decorModelLicenseInput.value);return{url:e,credit:i!==void 0&&n!==void 0?{title:i,license:n,author:this.stringOrUndefined(this.decorModelAuthorInput.value),sourceUrl:this.stringOrUndefined(this.decorModelSourceInput.value)}:void 0}}const t=this.stringOrUndefined(this.decorModelSelect.value);return t===void 0?void 0:{id:t}}addMilestone(){const e=Math.round(this.ufoElement.currentTime),t=this.ufoElement.sighting;t.milestones.find(n=>n.t===e)||(t.milestones=Ta([...t.milestones,{t:e,label:this.nextMilestoneLabel()}])),this.currentMilestoneT=e,this.refreshMilestoneList(),this.ufoElement.refresh()}nextMilestoneLabel(){const e=new Set(this.ufoElement.sighting.milestones.map(t=>t.label));for(let t=0;t<26;t++){const i=String.fromCharCode(65+t);if(!e.has(i))return i}return String(this.ufoElement.sighting.milestones.length+1)}deleteMilestone(){const e=this.currentMilestoneT;if(e===void 0)return;const t=this.ufoElement.sighting,i=t.milestones.find(n=>n.t===e);i&&this.askConfirm(this.messages.confirmDeleteMilestone.replace("{name}",this.said.read(i.label)??""),()=>{t.milestones=t.milestones.filter(n=>n.t!==e),this.currentMilestoneT=t.milestones[0]?.t,this.refreshMilestoneList(),this.ufoElement.refresh()})}selectMilestone(e){this.currentMilestoneT=e,this.syncMilestoneFields(),this.ufoElement.currentTime=e}updateMilestone(){const e=this.currentMilestoneT;if(e===void 0)return;const t=this.ufoElement.sighting;t.milestones=t.milestones.map(i=>i.t===e?{...i,label:this.said.write(i.label,this.milestoneLabelInput.value,this.writingLanguage)??"",note:this.said.write(i.note,this.milestoneNoteInput.value,this.writingLanguage)}:i),this.refreshMilestoneList(),this.ufoElement.refresh()}refreshMilestoneList(){const e=Ta(this.ufoElement.sighting.milestones);e.some(t=>t.t===this.currentMilestoneT)||(this.currentMilestoneT=e[0]?.t),this.milestoneSelect.replaceChildren(...e.map(t=>{const i=document.createElement("option");return i.value=String(t.t),i.textContent=`${this.said.read(t.label)??""} — ${this.formatSeconds(t.t)}`,i.title=this.said.read(t.note)??"",i})),this.currentMilestoneT!==void 0&&(this.milestoneSelect.value=String(this.currentMilestoneT)),this.syncMilestoneFields()}formatSeconds(e){return`${(e/1e3).toFixed(1)} s`}syncMilestoneFields(){const e=this.ufoElement.sighting.milestones.find(i=>i.t===this.currentMilestoneT),t=e!==void 0;for(const i of[this.milestoneSelect,this.milestoneLabelInput,this.milestoneNoteInput,this.deleteMilestoneButton])i.disabled=!t,this.setRowVisible(i,t);this.milestoneLabelInput.value=this.said.read(e?.label)??"",this.milestoneNoteInput.value=this.said.read(e?.note)??""}updateDecorTitleValidity(){const e=this.currentDecorId!==void 0&&this.decorTitleInput.value==="";this.decorTitleInput.classList.toggle("invalid",e),this.decorTitleInput.setAttribute("aria-invalid",String(e))}updateDecorWindows(){if(this.currentDecorId===void 0)return;const e=this.ufoElement.sighting;e.decor=e.decor.map(t=>{if(t.id!==this.currentDecorId)return t;const i={};for(const n of _r){const s=this.decorWindowInputs[n];if(s.value==="")continue;const a=md(t.kind,n)?0:pd,o=Math.max(a,Math.min(100,Number(s.value)));i[n]=o,String(o)!==s.value&&(s.value=String(o))}return{...t,windows:i}}),this.ufoElement.refresh()}updateDecorLit(){if(this.currentDecorId===void 0||this.ufoElement.playbackState==="playing")return;const e=this.ufoElement.sighting,t=this.ufoElement.currentTime,i=this.decorLitInput.checked;e.decor=e.decor.map(n=>{if(n.id!==this.currentDecorId)return n;const s=[...(n.litKeyframes??[]).filter(a=>a.t!==t),{t,lit:i}].sort((a,o)=>a.t-o.t);return{...n,litKeyframes:s}}),this.ufoElement.refresh()}refreshDecorList(){const e=this.ufoElement.sighting.decor;this.decorSelect.innerHTML="";for(const t of e){const i=document.createElement("option");i.value=t.id,i.textContent=this.decorLabel(t),this.decorSelect.appendChild(i)}this.currentDecorId!==void 0&&(this.decorSelect.value=this.currentDecorId),this.syncDecorFields()}syncDecorFields(){const e=this.ufoElement.sighting.decor.find(i=>i.id===this.currentDecorId),t=e!==void 0;this.deleteDecorButton.disabled=!t;for(const i of[this.decorSelect,this.decorTitleInput,this.decorEastInput,this.decorNorthInput,this.decorHeadingInput,this.decorLitInput,this.decorSightingUrlInput,this.decorWidthInput,this.decorLengthInput,this.decorHeightInput,this.decorModelSelect,this.decorModelUrlInput,this.decorModelTitleInput,this.decorModelAuthorInput,this.decorModelLicenseInput,this.decorModelSourceInput,this.decorFloorsInput,this.decorOccupiedFloorInput,this.decorWitnessSideSelect,this.decorLightRigSelect,this.decorAltitudeInput,this.lookAtDecorButton])i.disabled=!t;this.decorTitleInput.value=this.said.read(e?.title)??"",this.decorColorInput.value=e?.color??"#808080",this.showDecorPlacement(e),this.decorLitInput.checked=e?sc(e,this.ufoElement.currentTime):!1,this.refreshDecorLightRigOptions(e),this.decorSightingUrlInput.value=e?.sightingUrl??"",this.syncDecorSizeFields(e),this.syncDecorModelFields(e),this.decorFloorsInput.value=String(e?.floors??ua),this.decorOccupiedFloorInput.value=String(e?.occupiedFloor??0),this.decorWitnessSideSelect.value=e?.witnessSide??"";for(const i of _r){const n=e?.windows?.[i];this.decorWindowInputs[i].value=n===void 0?"":String(n)}this.syncDecorVisibility(),this.updateDecorTitleValidity()}setRowVisible(e,t){const i=e.closest("label")??e;i.hidden=!t}syncDecorVisibility(){const e=this.ufoElement.sighting.decor.find(c=>c.id===this.currentDecorId),t=e!==void 0,i=e?.kind;this.setRowVisible(this.decorSelect,t),this.setRowVisible(this.deleteDecorButton,t),this.setRowVisible(this.decorTitleInput,t),this.setRowVisible(this.decorEastInput,t),this.setRowVisible(this.decorNorthInput,t),this.setRowVisible(this.decorAltitudeInput,t),this.setRowVisible(this.decorHeadingInput,t),this.setRowVisible(this.decorWidthInput,t),this.setRowVisible(this.decorLengthInput,t),this.setRowVisible(this.decorHeightInput,t),this.setRowVisible(this.decorModelSelect,t),this.decorModelAdvanced.hidden=!t,this.setRowVisible(this.decorLitInput,t&&e?.kind!=="aircraft");const n=t&&i!==void 0&&Yu(i);this.setRowVisible(this.labelDecorWindows,n);const s=i!==void 0?qu(i):[];for(const c of _r)this.decorWindowInputs[c].disabled=!t,this.decorWindowInputs[c].min=String(i!==void 0&&md(i,c)?0:pd),this.setRowVisible(this.decorWindowInputs[c],n&&s.includes(c));const a=t&&i!==void 0&&ra(i);this.setRowVisible(this.decorWitnessSideSelect,a);const o=i!==void 0?Bv(i):[];for(const c of _r)this.optionWitnessSide[c].hidden=!o.includes(c);const l=t&&i==="building";this.setRowVisible(this.decorFloorsInput,l),this.setRowVisible(this.decorOccupiedFloorInput,l),this.decorOccupiedFloorInput.max=String(e?.floors??ua)}showDecorPlacement(e){const t=e?_a(e,this.ufoElement.currentTime):void 0,i=[[this.decorEastInput,t?.eastM??0],[this.decorNorthInput,t?.northM??0],[this.decorAltitudeInput,t?.altitudeM??0],[this.decorHeadingInput,t?.headingDeg??0]];for(const[n,s]of i)this.shadow.activeElement!==n&&(n.value=String(this.rounded(s)))}syncDecorPlacementFromTimeline(){this.ufoElement.playbackState!=="playing"&&this.showDecorPlacement(this.ufoElement.sighting.decor.find(e=>e.id===this.currentDecorId))}showNextMeteor(){const e=this.sceneElement.meteorByRank(this.meteorRank++);e&&(this.ufoElement.playbackState==="playing"&&this.ufoElement.togglePlayPause(),this.ufoElement.currentTime=e.t,this.headingInput.value=String(Math.round(e.azimuthDeg*10)/10),this.pitchInput.value=String(Math.round(e.altitudeDeg*10)/10),this.updateObserver())}resetMeteorRankIfSkyChanged(){const e=this.sceneElement.meteorByRank(0),t=e?`${e.t}`:"";t!==this.meteorRankFor&&(this.meteorRankFor=t,this.meteorRank=0)}meteorRankFor;skyCandidatesKey;meteorRank=0;showerLanguage(){return fa(Ns.preferencesFor(this),["en","fr"])}get said(){return this.saidTexts??=new rs(Ns.preferencesFor(this))}saidTexts;tagNames=new vd({});get writingLanguage(){return this.showerLanguage()}refreshSkyCandidates(){this.resetMeteorRankIfSkyChanged();const e=this.ufoElement.sighting,t=e.event.place?.[0],i=e.event.time,n=t&&t.lat!==void 0&&t.lng!==void 0&&i?.year!==void 0?zn(i,t.lng,e.event.utcOffsetHours):void 0,s=JSON.stringify([n?.getTime(),t?.lat,t?.lng,this.groundElevationM,e.instrumentId,e.exposureSeconds,kt(e,0),this.messages.skyLine,this.meteorRankFor,this.sceneElement.satelliteState.status,this.satelliteSpanMs()]);if(s===this.skyCandidatesKey)return;if(this.skyCandidatesKey=s,!n||!t||t.lat===void 0||t.lng===void 0){this.showMeteorButton.hidden=!0,this.showCometButton.hidden=!0,this.showNovaButton.hidden=!0,this.showSatelliteButton.hidden=!0,this.skyCandidatesOutput.textContent=this.messages.skyLine.replace("{parts}",this.messages.skyUnknown);return}const a={lat:t.lat,lng:t.lng,elevationM:this.groundElevationM??0},o=[this.starsClause(n,a),this.showerClause(n,a),this.cometClause(n,a),this.novaClause(n,a),this.satelliteClause(n,a),this.opticsClause(n,a),this.rainbowClause(n,a),this.glowClause(n,a)].filter(l=>l!==void 0);this.skyCandidatesOutput.textContent=this.messages.skyLine.replace("{parts}",o.join(" · "))}instrumentGain(){const e=this.ufoElement.sighting;return Ei.gainFor(e.instrument,{fNumber:nt(e,0)?.fNumber,fieldOfViewDeg:gi.fovOf(e,0),exposureSeconds:e.exposure})}starsClause(e,t){const i=Ui("Sun",e,t).altitudeDeg,n=this.instrumentGain(),s=hr(i,n),a=c=>c.toLocaleString(void 0,{maximumFractionDigits:1});if(s<jT)return this.messages.skyStarsNone;const o=this.ufoElement.sighting.instrument,l=Math.abs(n)<.1?this.messages.skyStarsEye.replace("{limit}",a(s)):(n>0?this.messages.skyStarsDeeper:this.messages.skyStarsShallower).replace("{limit}",a(s)).replace("{device}",o.name[this.showerLanguage()]).replace("{gain}",a(Math.abs(n))).replace("{eye}",a(hr(i)));return s<=Mo?l:l+this.messages.skyStarsCatalogue.replace("{catalogue}",a(Mo))}showerClause(e,t){const i=Lt.observedRatePerHour(Lt.apexPosition(e,t).altitudeDeg).toLocaleString(void 0,{maximumFractionDigits:1}),n=Sa.activeAt(e);if(n.length===0)return this.showMeteorButton.hidden=!this.sceneElement.meteorByRank(0),this.messages.skyNothingActive.replace("{sporadic}",i);const s=n.map(a=>{const o=Sa.radiantPosition(a.shower,e,t);return{entry:a,position:o,rate:Sa.observedRatePerHour(a.zhr,o.altitudeDeg,a.shower.populationIndex)}}).sort((a,o)=>o.rate-a.rate)[0];return s.rate<=0?(this.showMeteorButton.hidden=!this.sceneElement.meteorByRank(0),this.messages.skyShowerBelowHorizon.replace("{name}",s.entry.shower.name[this.showerLanguage()])):(this.showMeteorButton.hidden=!this.sceneElement.meteorByRank(0),this.messages.skyShowerActive.replace("{name}",s.entry.shower.name[this.showerLanguage()]).replace("{altitude}",String(Math.round(s.position.altitudeDeg))).replace("{bearing}",dn.towards(s.position.azimuthDeg,this.showerLanguage())).replace("{rate}",s.rate.toLocaleString(void 0,{maximumFractionDigits:s.rate<10?1:0})).replace("{sporadic}",i))}cometClause(e,t){const i=Ql.brightestAt(e,t);if(!i||i.magnitude>La){this.showCometButton.hidden=!0;return}return this.showCometButton.hidden=i.position.altitudeDeg<=0,this.cometText(i)}novaClause(e,t){const i=Ac.brightestAt(e,t);if(!i||i.magnitude>La){this.showNovaButton.hidden=!0;return}return this.showNovaButton.hidden=i.position.altitudeDeg<=0,this.novaText(i)}novaText(e){return(e.position.altitudeDeg<=0?this.messages.skyNovaBelowHorizon:this.messages.skyNova).replace("{name}",e.outburst.name[this.showerLanguage()]).replace("{magnitude}",e.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{altitude}",String(Math.round(e.position.altitudeDeg))).replace("{bearing}",dn.towards(e.position.azimuthDeg,this.showerLanguage()))}satelliteClause(e,t){const i=Pn.visibilityAt(e,t),n=this.realSatelliteClause(i.lowOrbitLit||i.sunAltitudeDeg>=0);if(n!==void 0)return n;if(this.showSatelliteButton.hidden=!0,!i.anythingInOrbit)return i.sunAltitudeDeg<0?this.messages.skySatellitesNotYet:void 0;const s=hr(i.sunAltitudeDeg,this.instrumentGain()),a=i.classes.filter(d=>d.peakMagnitude<=s),o=this.listed(a.map(d=>d.name[this.showerLanguage()]));if(i.sunAltitudeDeg>=0)return a.length===0?void 0:(a.length===1?this.messages.skySatellitesDaylightOne:this.messages.skySatellitesDaylight).replace("{eras}",o);const l=Math.round(i.shadowHeightKm).toLocaleString(),c=(i.trackedObjects??0).toLocaleString(),h=d=>d.replace("{height}",l).replace("{count}",c);return i.lowOrbitLit?a.length===0?h(this.messages.skySatellitesLit):h(this.messages.skySatellitesLitWith).replace("{eras}",o):h(this.messages.skySatellitesShadowed)}realSatelliteClause(e){const t=this.sceneElement.satelliteState;if(t.status!=="ready")return;if(t.coverage?.every(h=>h.status!=="covered"))return this.showSatelliteButton.hidden=!0,t.coverage.some(h=>h.status==="gap")?this.messages.skySatelliteElementsGap:void 0;const i=this.visibleSatellitePasses(),n=i.filter(h=>this.passTimelineMs(h)<=this.ufoElement.seekableDuration);if(this.showSatelliteButton.hidden=n.length===0,i.length===0)return e?this.messages.skySatellitePassesNone:void 0;const a=i[0].peak,l=(i.length===1?this.messages.skySatellitePassesOne:this.messages.skySatellitePasses).replace("{count}",String(i.length)).replace("{name}",a.object.name).replace("{magnitude}",a.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{altitude}",String(Math.round(a.altitudeDeg))).replace("{bearing}",dn.towards(a.azimuthDeg,this.showerLanguage())).replace("{time}",this.witnessClock(a.date)),c=this.starlinkTrain(i);return c?`${l}, ${c}`:l}visibleSatellitePasses(){const e=this.instrumentGain(),t=this.observerAtStart();return this.sceneElement.satellitePassesDuring(this.satelliteSpanMs()).filter(i=>{const n=i.peak.magnitude;if(n===void 0)return!1;const s=Ui("Sun",i.peak.date,t);return n<=hr(s.altitudeDeg,e)}).sort((i,n)=>i.peak.magnitude-n.peak.magnitude)}starlinkTrain(e){const t=new Map;for(const a of e){const{kind:o,launch:l}=a.peak.object;o!=="starlink"||!l||(a.peak.date.getTime()-Date.parse(`${l}T00:00:00Z`))/864e5>60||t.set(l,(t.get(l)??0)+1)}const[i,n]=[...t.entries()].sort((a,o)=>o[1]-a[1])[0]??[];if(!i||!n||n<3)return;const s=new Date(`${i}T00:00:00Z`).toLocaleDateString(this.showerLanguage(),{day:"numeric",month:"long",year:"numeric",timeZone:"UTC"});return this.messages.skySatelliteTrain.replace("{count}",String(n)).replace("{date}",s)}satelliteSpanMs(){const e=(this.ufoElement.sighting.event.durationSeconds??0)*1e3;return Math.max(e,this.ufoElement.seekableDuration)}observerAtStart(){const e=this.ufoElement.sighting.event.place?.[0],t=nt(this.ufoElement.sighting,0);return{lat:t?.lat??e?.lat??0,lng:t?.lng??e?.lng??0,elevationM:this.groundElevationM??0}}passTimelineMs(e){const t=this.ufoElement.sighting,i=zn(t.event.time??{},this.observerAtStart().lng,t.event.utcOffsetHours);return i?e.peak.date.getTime()-i.getTime():1/0}witnessClock(e){const i=this.ufoElement.sighting.event.utcOffsetHours??Math.round(this.observerAtStart().lng/15);return new Date(e.getTime()+i*36e5).toLocaleTimeString(this.showerLanguage(),{hour:"2-digit",minute:"2-digit",second:"2-digit",timeZone:"UTC"})}showNextSatellite(){const e=this.visibleSatellitePasses().filter(n=>this.passTimelineMs(n)<=this.ufoElement.seekableDuration);if(e.length===0)return;const t=e.map(n=>`${n.object.norad}@${n.peak.date.getTime()}`).join();t!==this.satelliteRankFor&&(this.satelliteRankFor=t,this.satelliteRank=0);const i=e[this.satelliteRank++%e.length];this.ufoElement.playbackState==="playing"&&this.ufoElement.togglePlayPause(),this.ufoElement.currentTime=this.passTimelineMs(i),this.headingInput.value=String(Math.round(i.peak.azimuthDeg*10)/10),this.pitchInput.value=String(Math.round(i.peak.altitudeDeg*10)/10),this.updateObserver()}satelliteRankFor;satelliteRank=0;opticsClause(e,t){const i=kt(this.ufoElement.sighting,0),n=Ui("Sun",e,t),s=Ui("Moon",e,t),a=et.deckLitUntilDeg(et.DECK_HEIGHT_M),o=n.altitudeDeg>-a,l=o?n:s;if(l.altitudeDeg<=-a)return;const c=i.highCloudCover;if(c===void 0||c<=0)return this.messages.skyOpticsNoIce;if(et.strength(c,i.lowerCloudCover??i.cloudCover,l.altitudeDeg,a)<=0)return this.messages.skyOpticsHidden;const h=o?this.messages.skyOpticsSun:this.messages.skyOpticsMoon,d=this.listed(et.formsAt(l.altitudeDeg,a).map(f=>this.opticsFormName(f))),u=i.iceCrystalAlignment??.65;return this.messages.skyOpticsPossible.replace("{forms}",d).replace("{source}",h)+this.messages.skyOpticsAlignment.replace("{alignment}",String(Math.round(u*100)))}rainbowClause(e,t){const i=kt(this.ufoElement.sighting,0);if(i.precipitationType!=="rain"||i.precipitationIntensity<=0)return;const n=Ui("Sun",e,t),s=Ui("Moon",e,t),a=n.altitudeDeg>0,o=a?n:s;if(o.altitudeDeg<=0)return this.messages.skyBowNoSource;const l=i.lowerCloudCover??i.cloudCover;if(fi.strength(i.precipitationIntensity,l,o.altitudeDeg)<=0)return this.messages.skyBowHidden;const c=fi.formsAt(o.altitudeDeg);if(c.length===0)return this.messages.skyBowSourceTooHigh.replace("{altitude}",String(Math.round(o.altitudeDeg))).replace("{radius}",String(Math.round(fi.primary().radiusDeg)));const h=this.listed(c.map(u=>this.bowFormName(u)));if(a)return this.messages.skyBowPossible.replace("{forms}",h);const d=Math.round(_c(e).illuminatedFraction*100);return this.messages.skyBowMoon.replace("{forms}",h).replace("{lit}",String(d))}glowClause(e,t){if(Ui("Sun",e,t).altitudeDeg>rA)return;const n=this.glows.assess(e,t),s=this.showerLanguage(),a=[];if(n.milkyWay&&a.push(this.messages.skyGlowBand.replace("{contrast}",this.decimal(n.milkyWay.contrast,1)).replace("{altitude}",String(Math.round(n.milkyWay.altitudeDeg))).replace("{bearing}",dn.towards(n.milkyWay.azimuthDeg,s))),n.zodiacal){const h=n.zodiacal.sunSeparationDeg<=rt.CONE_SEPARATION_DEG;a.push((h?this.messages.skyGlowCone:this.messages.skyGlowZodiacalBand).replace("{contrast}",this.decimal(n.zodiacal.contrast,1)).replace("{altitude}",String(Math.round(n.zodiacal.altitudeDeg))).replace("{bearing}",dn.towards(n.zodiacal.azimuthDeg,s)).replace("{elongation}",String(Math.round(n.zodiacal.sunSeparationDeg))))}if(a.length>0)return this.listed(a);const o=this.decimal(n.darkestSkyMagPerArcsec2,1),l=Ui("Moon",e,t),c=n.darkestSkyMagPerArcsec2<aA;if(c&&l.altitudeDeg>0){const h=Math.round(_c(e).illuminatedFraction*100);return this.messages.skyGlowMoon.replace("{lit}",String(h)).replace("{sky}",o)}return c?this.messages.skyGlowTwilight.replace("{sky}",o):this.messages.skyGlowNothingUp.replace("{sky}",o)}glows=new rt;bowFormName(e){return(e.id==="primary"?this.messages.skyBowPrimary:this.messages.skyBowSecondary).replace("{radius}",String(Math.round(e.radiusDeg))).replace("{top}",String(Math.round(e.topAltitudeDeg)))}opticsFormName(e){const t=i=>String(Math.round(i??0));switch(e.id){case"halo22":return this.messages.skyOpticsHalo22.replace("{angle}",t(e.angleDeg));case"halo46":return this.messages.skyOpticsHalo46.replace("{angle}",t(e.angleDeg));case"parhelia":return this.messages.skyOpticsParhelia.replace("{angle}",t(e.angleDeg));case"tangentArc":return this.messages.skyOpticsTangentArc;case"parhelicCircle":return this.messages.skyOpticsParhelicCircle;case"circumzenithal":return this.messages.skyOpticsCircumzenithal.replace("{angle}",t(e.angleDeg));case"circumhorizontal":return this.messages.skyOpticsCircumhorizontal;case"pillar":return this.messages.skyOpticsPillar}}listed(e){return new Intl.ListFormat(this.showerLanguage(),{style:"long",type:"conjunction"}).format(e)}cometText(e){const t=e.apparition.name[this.showerLanguage()],i=e.magnitude.toLocaleString(void 0,{maximumFractionDigits:1});return e.position.altitudeDeg<=0?this.messages.skyCometBelowHorizon.replace("{name}",t).replace("{magnitude}",i):(e.elongationDeg<Ql.TWILIGHT_ELONGATION_DEG?this.messages.skyCometInDaylight:e.tailLengthDeg===void 0?this.messages.skyCometNoTail:this.messages.skyComet).replace("{name}",t).replace("{magnitude}",i).replace("{altitude}",String(Math.round(e.position.altitudeDeg))).replace("{bearing}",dn.towards(e.position.azimuthDeg,this.showerLanguage())).replace("{tail}",String(Math.round(e.tailLengthDeg??0))).replace("{elongation}",String(Math.round(e.elongationDeg)))}lookAtComet(){const e=this.ufoElement.sighting,t=e.event.place?.[0],i=e.event.time;if(!t||t.lat===void 0||t.lng===void 0||i?.year===void 0)return;const n=zn(i,t.lng,e.event.utcOffsetHours);if(!n)return;const s=Ql.brightestAt(n,{lat:t.lat,lng:t.lng,elevationM:this.groundElevationM??0});s&&(this.headingInput.value=String(this.rounded(s.position.azimuthDeg)),this.pitchInput.value=String(this.rounded(s.position.altitudeDeg)),this.updateObserver())}lookAtNova(){const e=this.ufoElement.sighting,t=e.event.place?.[0],i=e.event.time;if(!t||t.lat===void 0||t.lng===void 0||i?.year===void 0)return;const n=zn(i,t.lng,e.event.utcOffsetHours);if(!n)return;const s=Ac.brightestAt(n,{lat:t.lat,lng:t.lng,elevationM:this.groundElevationM??0});s&&(this.headingInput.value=String(this.rounded(s.position.azimuthDeg)),this.pitchInput.value=String(this.rounded(s.position.altitudeDeg)),this.updateObserver())}refreshHeadingPoint(){const e=this.numberOrUndefined(this.headingInput.value);this.headingUnit.textContent=e===void 0?"°":`° (${dn.point(e,this.showerLanguage())})`}rounded(e){return Math.round(e*10)/10}lookAtDecor(){const e=this.ufoElement.sighting.decor.find(l=>l.id===this.currentDecorId);if(!e)return;const{eastM:t,northM:i,altitudeM:n}=_a(e,this.ufoElement.currentTime),s=Math.hypot(t,i);if(s===0&&n===0)return;const a=Math.atan2(t,i)*180/Math.PI,o=Math.atan2(n-tA,s)*180/Math.PI;this.headingInput.value=String(Math.round(a*10)/10),this.pitchInput.value=String(Math.round(o*10)/10),this.updateObserver()}refreshDecorLightRigOptions(e){const t=e?Xc.forKind(e.kind):[],i=document.createElement("option");i.value="",i.textContent=this.messages.decorLightsNone,this.decorLightRigSelect.replaceChildren(i,...t.map(s=>{const a=document.createElement("option");return a.value=s.id,a.textContent=s.name,a}));const n=e?.lights?.map(s=>s.id).join()??"";this.decorLightRigSelect.value=t.find(s=>s.create().map(a=>a.id).join()===n)?.id??""}updateDecorLightRig(){const e=this.ufoElement.sighting,t=e.decor.find(n=>n.id===this.currentDecorId);if(!t)return;const i=Xc.byId(this.decorLightRigSelect.value);e.decor=e.decor.map(n=>n.id===t.id?{...n,lights:i?i.create():void 0}:n),this.ufoElement.refresh(),this.dispatchEvent(new CustomEvent("sightingchange"))}syncDecorLitFromTimeline(){if(this.ufoElement.playbackState==="playing"||this.shadow.activeElement===this.decorLitInput)return;const e=this.ufoElement.sighting.decor.find(t=>t.id===this.currentDecorId);e&&(this.decorLitInput.checked=sc(e,this.ufoElement.currentTime))}updatePresetButtons(){for(const e of ng)this.presetButtons[e]?.setAttribute("aria-pressed",String(e===this.currentAppearance.presetId))}get samplingRate(){return Number(this.samplingRateInput.value)}buildPrototype(e=this.defaultBounds()){return zf(e,this.currentAppearance)}defaultBounds(){const e=this.ufoElement.canvasElement;return{x:e.width/2-ea.width/2,y:e.height/2-ea.height/2,width:ea.width,height:ea.height}}toggleRecording(){this.endDrag();const e=this.ufoElement.canvasElement;this.isRecording?(this.recorder?.stop(),this.isRecording=!1,this.setRecordButtonLabel(!1),this.setCanvasCursor(void 0),e.style.touchAction="",this.sourceSelect.disabled=!1,this.addShapeButton.disabled=!1,this.ufoElement.refresh(),this.refreshSourceList()):(this.recorder=new bT(this.ufoElement.sighting.timeline,new wT(this.samplingRate)),this.recorder.start(this.currentSourceId,this.buildPrototype()),this.isRecording=!0,this.setRecordButtonLabel(!0),this.setCanvasCursor("record"),e.style.touchAction="none",this.sourceSelect.disabled=!0,this.addShapeButton.disabled=!0,this.deleteShapeButton.disabled=!0)}setRecordButtonLabel(e){this.recordButton.textContent=e?"⏹":"⏺";const t=e?this.messages.stop:this.messages.record;this.recordButton.title=t,this.recordButton.setAttribute("aria-label",t)}async loadLocaleMessages(){const e=fa(Ns.preferencesFor(this),bd);e!=="en"&&(this.tagNames=new vd(await o2(e)),this.showTags(),this.applyMessages(await a2(e)))}showTags(){this.tagsInput.value=this.ufoElement.sighting.event.tags?.map(e=>this.tagNames.name(e)).join(", ")??""}applyMessages(e){this.currentSourceId===Wl&&this.shapeTitleInput.value===`${this.messages.shape} 1`?(this.messages=e,this.shapeTitleInput.value=`${this.messages.shape} 1`,this.updateShapeTitle()):this.messages=e,this.presetButtons.oval.textContent=e.oval,this.presetButtons.polygon.textContent=e.polygon,this.contextAddVertexButton.textContent=e.addVertex,this.contextDeleteVertexButton.textContent=e.deleteVertex,this.labelColor.textContent=e.color,this.labelTransparency.textContent=e.transparency,this.labelHalo.textContent=e.halo,this.labelBlur.textContent=e.blur,this.labelBrightness.textContent=e.brightness,this.labelShape.textContent=e.shape,this.labelShapeTitle.textContent=e.shapeTitle,this.labelUtcOffset.textContent=e.utcOffset,this.utcOffsetInput.placeholder=e.utcOffsetPlaceholder,this.labelApparentWidth.textContent=e.apparentWidth,this.labelRealWidth.textContent=e.realWidth,this.labelObjectDistance.textContent=e.distance,this.labelSizeLock.textContent=e.sizeLock;for(const[n,s]of[["option-lock-none",e.lockNone],["option-lock-apparent",e.lockApparent],["option-lock-real",e.lockReal],["option-lock-distance",e.lockDistance]])this.shadow.getElementById(n).textContent=s;this.clearDistanceHypothesisButton.textContent=e.clearDistanceHypothesis,this.clearDistanceHypothesisButton.title=e.clearDistanceHypothesisTitle,this.refreshApparentSize(),this.labelSamplingRate.textContent=e.samplingRate,this.labelDuration.textContent=e.duration,this.durationInput.placeholder=e.durationPlaceholder,this.addShapeButton.title=e.addShape,this.addShapeButton.setAttribute("aria-label",e.addShape),this.deleteShapeButton.title=e.deleteShape,this.deleteShapeButton.setAttribute("aria-label",e.deleteShape),this.contextGroupButton.textContent=e.group,this.contextUngroupButton.textContent=e.ungroup,this.contextBringToFrontButton.textContent=e.bringToFront,this.contextSendToBackButton.textContent=e.sendToBack,this.contextDeleteButton.textContent=e.contextMenuDelete,this.exportButton.textContent=e.export,this.labelImportFile.textContent=e.importFile,this.labelImportUrl.textContent=e.importUrl,this.importUrlInput.placeholder=e.importUrlPlaceholder,this.importUrlButton.textContent=e.importButton,this.labelWitnessAge.textContent=e.witnessAge,this.labelWitnessOccupation.textContent=e.witnessOccupation,this.labelTestimonySource.textContent=e.testimonySource,this.labelTestimonyFollowedUp.textContent=e.testimonyFollowedUp;for(const[n,s]of[["option-source-unknown",e.testimonySourceUnknown],["option-source-on-site",e.testimonySourceOnSite],["option-source-interview",e.testimonySourceInterview],["option-source-telephone",e.testimonySourceTelephone],["option-source-questionnaire",e.testimonySourceQuestionnaire],["option-source-letter",e.testimonySourceLetter],["option-source-press",e.testimonySourcePress],["option-followed-unknown",e.testimonyUnknown],["option-followed-yes",e.testimonyYes],["option-followed-no",e.testimonyNo]]){const a=this.shadow.getElementById(n);a&&(a.textContent=s)}this.labelNarrativeKey.textContent=e.narrativeKey.replace("{source}",Vs[0].name),this.labelNarrativeWorkspace.textContent=e.narrativeWorkspace,this.narrativeWorkspaceInput.placeholder=e.narrativeWorkspacePlaceholder,this.narrativeWorkspaceInput.title=e.narrativeWorkspaceHint,this.labelNarrativeRemember.textContent=e.narrativeRemember,this.narrativeStopButton.textContent=e.narrativeStop,this.narrativeDraftButton.textContent=e.narrativeDraft,this.descriptionInput.placeholder=e.narrativePlaceholder,this.syncNarrativeEnabled(),this.refreshSourceRows(),this.refreshTimeZoneOptions(),this.labelPlaceName.textContent=e.placeName,this.placeNameInput.placeholder=e.placeNamePlaceholder,this.searchPlaceButton.textContent=e.searchPlace,this.labelPlaceMatch.textContent=e.placeMatch,this.labelLatitude.textContent=e.latitude,this.labelLongitude.textContent=e.longitude,this.labelHeading.textContent=e.heading,this.headingInput.placeholder=e.headingPlaceholder,this.labelPitch.textContent=e.pitch,this.labelRoll.textContent=e.roll,this.labelElevation.textContent=e.elevation,this.labelObservationTime.textContent=e.observationTime,this.labelObservationEndTime.textContent=e.observationEndTime,this.obsTimeInput.placeholder=e.edtfPlaceholder,this.obsTimeInput.title=e.observationTimeHint,this.obsEndTimeInput.placeholder=e.edtfPlaceholder,this.obsEndTimeInput.title=e.observationEndTimeHint,this.presetsGroup.setAttribute("aria-label",e.presetsGroupLabel),this.labelDecor.textContent=e.decor,this.labelDecorGroup.textContent=e.decor,this.optionDecorBuilding.textContent=e.decorBuilding,this.optionDecorTree.textContent=e.decorTree,this.optionDecorCrop.textContent=e.decorCrop,this.optionDecorMound.textContent=e.decorMound,this.optionDecorStreetlight.textContent=e.decorStreetlight,this.optionDecorVehicle.textContent=e.decorVehicle,this.optionDecorAircraft.textContent=e.decorAircraft,this.optionDecorEntity.textContent=e.decorEntity,this.labelDecorLights.textContent=e.decorLights,this.labelDecorAltitude.textContent=e.decorAltitude,this.showMeteorButton.title=e.showMeteor,this.showMeteorButton.setAttribute("aria-label",e.showMeteor),this.showCometButton.title=e.showComet,this.showCometButton.setAttribute("aria-label",e.showComet),this.showNovaButton.title=e.showNova,this.showNovaButton.setAttribute("aria-label",e.showNova),this.showSatelliteButton.title=e.showSatellite,this.showSatelliteButton.setAttribute("aria-label",e.showSatellite),this.lookAtDecorButton.title=e.lookAtDecor,this.lookAtDecorButton.setAttribute("aria-label",e.lookAtDecor),this.optionDecorWitness.textContent=e.decorWitness,this.deleteDecorButton.title=e.deleteDecor,this.deleteDecorButton.setAttribute("aria-label",e.deleteDecor),this.labelDecorTitle.textContent=e.decorTitle,this.labelDecorEast.textContent=e.decorEast,this.labelDecorNorth.textContent=e.decorNorth,this.labelDecorHeading.textContent=e.decorHeading,this.labelDecorColor.textContent=e.decorColor,this.labelDecorLit.textContent=e.decorLit,this.labelDecorSightingUrl.textContent=e.decorSightingUrl,this.contextViewTestimonyButton.textContent=e.viewTestimony,this.labelContextMasks.textContent=`${e.masks} ▸`,this.addDecorWitnessButton.textContent=e.addWitness,this.addDecorBuildingButton.title=e.addDecor,this.addDecorBuildingButton.setAttribute("aria-label",e.addDecor),this.confirmAcceptButton.textContent=e.confirmAccept,this.confirmDeclineButton.textContent=e.confirmDecline,this.labelMilestones.textContent=e.milestones,this.labelMilestoneLabel.textContent=e.milestoneLabel,this.labelMilestoneNote.textContent=e.milestoneNote;for(const[n,s]of[[this.addMilestoneButton,e.addMilestone],[this.deleteMilestoneButton,e.deleteMilestone]])n.title=s,n.setAttribute("aria-label",s);this.labelDecorWidth.textContent=e.decorWidth,this.labelDecorLength.textContent=e.decorLength,this.labelDecorHeight.textContent=e.decorHeight,this.labelDecorModel.textContent=e.decorModel,this.labelDecorModelAdvanced.textContent=e.decorModelAdvanced,this.labelDecorModelUrl.textContent=e.decorModelUrl,this.labelDecorModelTitle.textContent=e.decorModelTitle,this.labelDecorModelAuthor.textContent=e.decorModelAuthor,this.labelDecorModelLicense.textContent=e.decorModelLicense,this.labelDecorModelSource.textContent=e.decorModelSource,this.labelDecorFloors.textContent=e.decorFloors,this.labelDecorOccupiedFloor.textContent=e.decorOccupiedFloor,this.labelDecorWitnessSide.textContent=e.decorWitnessSide,this.labelDecorWindows.textContent=e.decorWindows,this.optionWitnessSideNone.textContent=e.decorWitnessSideNone;const t={front:e.decorSideFront,behind:e.decorSideBehind,left:e.decorSideLeft,right:e.decorSideRight,"front-left":e.decorSideFrontLeft,"front-right":e.decorSideFrontRight,"behind-left":e.decorSideBehindLeft,"behind-right":e.decorSideBehindRight};for(const n of _r)this.labelDecorSide[n].textContent=t[n],this.optionWitnessSide[n].textContent=t[n];this.refreshDecorList(),this.labelWitnessId.textContent=e.witnessId,this.labelWitnessDirName.textContent=e.witnessDirName,this.labelWitnessTitle.textContent=e.witnessTitle,this.labelWitnessLastName.textContent=e.witnessLastName,this.labelWitnessFirstNames.textContent=e.witnessFirstNames,this.witnessFirstNamesInput.placeholder=e.tagsPlaceholder,this.labelCaseId.textContent=e.caseId,this.labelDescription.textContent=e.description,this.labelTags.textContent=e.tags,this.tagsInput.placeholder=e.tagsPlaceholder,this.labelShapeGroup.textContent=e.shapeGroup,this.labelTemporalGroup.textContent=e.temporalGroup,this.labelLocationGroup.textContent=e.locationGroup,this.labelObservationGroup.textContent=e.observationGroup,this.labelWitnessGroup.textContent=e.witnessGroup,this.labelWeatherGroup.textContent=e.weather,this.refreshTimeQualifierOptions(),this.edtfModeButton.title=e.edtfModeTitle,this.edtfModeButton.setAttribute("aria-label",e.edtfModeTitle),this.paramSummaryBuilder=new tp(e,this.showerLanguage(),this.said,this.tagNames),this.refreshParamSummary();const i=this.skyDetailsButton.getAttribute("aria-expanded")==="true";this.skyDetailsButton.title=i?e.skyDetailsHide:e.skyDetails,this.skyDetailsButton.setAttribute("aria-label",this.skyDetailsButton.title),this.labelCloudCover.textContent=e.cloudCover,this.labelHighCloud.textContent=e.highCloudCover,this.labelIceAlignment.textContent=e.iceCrystalAlignment,this.labelFNumber.textContent=e.aperture,this.labelExposure.textContent=e.exposure,this.labelFocusDistance.textContent=e.focusDistance,this.syncOpticsFromInstrument(),this.labelCloudDarkness.textContent=e.cloudDarkness,this.labelCloudBase.textContent=e.cloudBase,this.labelPrecipitationType.textContent=e.precipitationType,this.optionPrecipitationNone.textContent=e.precipitationNone,this.optionPrecipitationRain.textContent=e.precipitationRain,this.optionPrecipitationSnow.textContent=e.precipitationSnow,this.optionPrecipitationHail.textContent=e.precipitationHail,this.labelPrecipitationIntensity.textContent=e.precipitationIntensity,this.labelWindDirection.textContent=e.windDirection,this.labelWindSpeed.textContent=e.windSpeed,this.labelStorm.textContent=e.storm,this.labelCloudsGroup.textContent=e.cloudsGroup,this.labelPrecipitationGroup.textContent=e.precipitationGroup,this.labelWindGroup.textContent=e.windGroup,this.labelWeatherInferred.textContent=e.weatherInferred,this.syncWeatherSourceState(),this.labelSoundGroup.textContent=e.soundGroup,this.labelSoundKind.textContent=e.soundKind,this.labelSoundVolume.textContent=e.soundVolume,this.labelSoundPitch.textContent=e.soundPitch,this.labelSoundSrc.textContent=e.soundSrc,this.soundSrcInput.placeholder=e.soundSrcPlaceholder,this.labelReferenceGroup.textContent=e.referenceGroup,this.labelReference.textContent=e.reference,this.labelReferenceTitle.textContent=e.referenceTitle,this.labelReferenceSrc.textContent=e.referenceSrc,this.referenceSrcInput.placeholder=e.referenceSrcPlaceholder,this.labelReferenceKind.textContent=e.referenceKind,this.referenceKindSelect.querySelector("#reference-kind-photo").textContent=e.referencePhoto,this.referenceKindSelect.querySelector("#reference-kind-panorama").textContent=e.referencePanorama,this.labelReferenceCredit.textContent=e.referenceCredit,this.labelReferenceCreditUrl.textContent=e.referenceCreditUrl,this.labelReferenceT.textContent=e.referenceT,this.labelReferenceDrawing.textContent=e.referenceDrawing,this.labelReferenceOpacity.textContent=e.referenceOpacity,this.labelReferenceHeading.textContent=e.referenceHeading,this.labelReferencePitch.textContent=e.referencePitch,this.labelReferenceRoll.textContent=e.referenceRoll,this.labelReferenceFov.textContent=e.referenceFov,this.referenceUsePoseButton.textContent=e.referenceUsePose,this.addReferenceUrlButton.textContent=e.addReferenceUrl,this.labelAddReferenceFile.textContent=e.addReferenceFile,this.deleteReferenceButton.title=e.deleteReference,this.deleteReferenceButton.setAttribute("aria-label",e.deleteReference),this.labelReferenceLandmarks.textContent=e.referenceLandmarks,this.addReferenceLandmarkButton.textContent=e.addReferenceLandmark,this.deleteReferenceLandmarkButton.title=e.deleteReferenceLandmark,this.deleteReferenceLandmarkButton.setAttribute("aria-label",e.deleteReferenceLandmark),this.labelReferenceLandmarkLabel.textContent=e.referenceLandmarkLabel,this.referenceLandmarkLabelInput.placeholder=e.referenceLandmarkLabelPlaceholder,this.referenceAdoptPoseButton.textContent=e.referenceAdoptPose,this.referenceStreetSearchButton.textContent=e.referenceStreetSearch,this.referenceStreetAddButton.textContent=e.referenceStreetAdd;for(const[n,s]of this.soundKindOptions)s.textContent=this.soundKindLabel(n,e);this.labelInstrument.textContent=e.instrument,this.setRecordButtonLabel(this.isRecording),this.syncPlaybackControls()}onPointerDown(e){if(this.isRecording){this.onPointerMove(e);return}const t=this.canvasPointFromEvent(e);if(!t)return;const i=this.canvasMode();if(i==="picture"){this.ufoElement.playbackState!=="playing"&&this.beginReferenceDrag(t);return}const n=this.ufoElement.sighting.timeline,s=this.ufoElement.currentTime,a=this.ufoElement.playbackState==="playing",o=i==="shape";if(o)if(this.selectedSourceIds.size>1){const h=new Wc(this.selectedMembers()),d=lt.hitTestHandle({bounds:h.bounds(),angle:0},t);if(d==="rotate"){if(a)return;this.dragState={kind:"group-rotate",group:h,startPointer:t},this.startDragListening();return}if(d){if(a)return;this.dragState={kind:"group-resize",group:h,handle:d},this.startDragListening();return}}else{const h=n.getInterpolatedShapeAt(s,this.currentSourceId),d=h?.kind==="polygon"?lt.hitTestVertex(h,t):void 0;if(h?.kind==="polygon"&&d!==void 0){if(a)return;this.dragState={kind:"vertex",sourceId:this.currentSourceId,original:h,vertexIndex:d},this.startDragListening();return}const u=h&&lt.hitTestHandle(h,t);if(h&&u){if(a)return;this.beginDrag(u==="rotate"?"rotate":"resize",this.currentSourceId,h,t,u);return}}const l=this.ufoElement.shapeAt(t.x,t.y,Qm);if(!l){const h=this.pickDecorAt(e);if(h!==void 0){this.selectDecor(h);return}a||this.beginCameraDrag(t);return}if(this.revealShapePanel(),e.shiftKey?this.toggleUnitSelection(l.sourceId):this.selectedSourceIds.has(l.sourceId)||this.selectUnit(l.sourceId),a||!o)return;const c=[...this.selectedSourceIds].map(h=>({sourceId:h,original:h===l.sourceId?l.shape:n.getInterpolatedShapeAt(s,h)??l.shape}));this.dragState={kind:"move",sources:c,startPointer:t},this.startDragListening()}revealShapePanel(){const e=this.groupTabs.find(t=>t.getAttribute("aria-controls")==="group-shape");e&&this.toggleGroup(e,!0)}selectedMembers(){const e=this.ufoElement.sighting.timeline,t=this.ufoElement.currentTime;return[...this.selectedSourceIds].map(i=>({sourceId:i,shape:e.getInterpolatedShapeAt(t,i)})).filter(i=>!!i.shape)}selectUnit(e){const t=this.ufoElement.sighting.timeline.groupMembers(e)??[e];t.length===this.selectedSourceIds.size&&t.every(i=>this.selectedSourceIds.has(i))&&e===this.currentSourceId||(this.selectedSourceIds=new Set(t),this.currentSourceId=e,this.refreshSourceList(),this.onSelectionOrTimeChanged())}toggleUnitSelection(e){const t=this.ufoElement.sighting.timeline,i=t.groupMembers(e)??[e];if(i.every(s=>this.selectedSourceIds.has(s))){if(i.length>=this.selectedSourceIds.size)return;for(const s of i)this.selectedSourceIds.delete(s);if(!this.selectedSourceIds.has(this.currentSourceId)){const s=t.sourceIds;this.currentSourceId=[...this.selectedSourceIds].sort((a,o)=>s.indexOf(a)-s.indexOf(o)).pop()}}else{for(const s of i)this.selectedSourceIds.add(s);this.currentSourceId=e}this.refreshSourceList(),this.onSelectionOrTimeChanged()}onContextMenu(e){if(e.preventDefault(),this.isRecording||this.ufoElement.playbackState==="playing")return;this.hideContextMenu(),this.hideDecorContextMenu();const t=this.canvasPointFromEvent(e);if(!t)return;const i=this.ufoElement.sighting.timeline,n=this.ufoElement.currentTime,s=this.selectedSourceIds.size===1?i.getInterpolatedShapeAt(n,this.currentSourceId):void 0,o=s?.kind==="polygon"&&lt.hitTestVertex(s,t)!==void 0?{sourceId:this.currentSourceId}:this.ufoElement.shapeAt(t.x,t.y,Qm);if(o){this.selectedSourceIds.has(o.sourceId)||this.selectUnit(o.sourceId),this.currentSourceId=o.sourceId,this.contextMenuPoint=t,this.showContextMenu(e.clientX,e.clientY);return}const l=this.pickDecorAt(e),c=l?this.ufoElement.sighting.decor.find(h=>h.id===l):void 0;c&&this.showDecorContextMenu(e.clientX,e.clientY,c)}pickDecorAt(e){const i=this.ufoElement.canvasElement.getBoundingClientRect();if(i.width===0||i.height===0)return;const n=(e.clientX-i.left)/i.width*2-1,s=-((e.clientY-i.top)/i.height*2-1);return this.sceneElement.pickDecorAt(n,s)}showContextMenu(e,t){this.contextMenu.style.left=`${e}px`,this.contextMenu.style.top=`${t}px`,this.contextMenu.hidden=!1;const i=this.ufoElement.sighting.timeline.sourceIds,n=i.filter(f=>this.selectedSourceIds.has(f)),s=i.length<=n.length,a=n.length>0&&i.slice(i.length-n.length).every(f=>this.selectedSourceIds.has(f)),o=n.length>0&&i.slice(0,n.length).every(f=>this.selectedSourceIds.has(f));this.contextBringToFrontButton.disabled=s||a,this.contextSendToBackButton.disabled=s||o,this.contextBringToFrontButton.title=s?this.messages.onlyOneShape:a?this.messages.alreadyAtFront:"",this.contextSendToBackButton.title=s?this.messages.onlyOneShape:o?this.messages.alreadyAtBack:"",this.contextGroupButton.disabled=this.selectedSourceIds.size<2,this.contextGroupButton.title=this.contextGroupButton.disabled?this.messages.needTwoShapesToGroup:"";const l=this.ufoElement.sighting.timeline.groupMembers(this.currentSourceId)!==void 0;this.contextUngroupButton.disabled=!l,this.contextUngroupButton.title=l?"":this.messages.notGrouped,this.contextDeleteButton.disabled=this.deleteShapeButton.disabled,this.contextDeleteButton.title=this.contextDeleteButton.disabled?this.messages.onlyOneShape:"";const c=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId),h=this.selectedSourceIds.size===1&&c?.kind==="polygon";this.contextAddVertexButton.disabled=!h,this.contextAddVertexButton.title=h?"":this.messages.notAPolygon;const d=h&&this.contextMenuPoint?lt.hitTestVertex(c,this.contextMenuPoint):void 0,u=h&&c.points.length<=dg;this.contextDeleteVertexButton.disabled=!h||d===void 0||u,this.contextDeleteVertexButton.title=h?u?this.messages.tooFewVertices:"":this.messages.notAPolygon,document.addEventListener("click",this.handleOutsideContextMenuClick)}hideContextMenu(){this.contextMenu.hidden=!0,this.contextMenuPoint=void 0,document.removeEventListener("click",this.handleOutsideContextMenuClick)}handleOutsideContextMenuClick=e=>{e.composedPath().includes(this.contextMenu)||e.composedPath().includes(this.decorContextMenu)||(this.hideContextMenu(),this.hideDecorContextMenu())};showDecorContextMenu(e,t,i){this.contextMenuDecorId=i.id,this.decorContextMenu.style.left=`${e}px`,this.decorContextMenu.style.top=`${t}px`,this.decorContextMenu.hidden=!1,this.contextViewTestimonyButton.disabled=!i.sightingUrl,this.contextViewTestimonyButton.title=i.sightingUrl?"":this.messages.noWitnessRecording,this.refreshContextMasksSubmenu(i),document.addEventListener("click",this.handleOutsideContextMenuClick)}hideDecorContextMenu(){this.decorContextMenu.hidden=!0,this.contextMenuDecorId=void 0,document.removeEventListener("click",this.handleOutsideContextMenuClick)}refreshContextMasksSubmenu(e){this.contextMasksSubmenu.innerHTML="";for(const t of this.ufoElement.sighting.timeline.sourceIds){const i=document.createElement("label"),n=document.createElement("input");n.type="checkbox",n.checked=e.occludesSourceIds?.includes(t)??!1,n.addEventListener("change",()=>this.updateDecorOccludesShape(e.id,t,n.checked)),i.appendChild(n),i.appendChild(document.createTextNode(this.shapeLabel(t))),this.contextMasksSubmenu.appendChild(i)}}updateDecorOccludesShape(e,t,i){const n=this.ufoElement.sighting;n.decor=n.decor.map(s=>{if(s.id!==e)return s;const a=i?[...new Set([...s.occludesSourceIds??[],t])]:(s.occludesSourceIds??[]).filter(o=>o!==t);return{...s,occludesSourceIds:a.length>0?a:void 0}}),this.ufoElement.refresh()}viewWitnessTestimony(){const e=this.ufoElement.sighting.decor.find(t=>t.id===this.contextMenuDecorId);this.hideDecorContextMenu(),e?.sightingUrl&&this.importFromUrl(e.sightingUrl)}addVertexAtContextMenu(){const e=this.contextMenuPoint;if(this.hideContextMenu(),!e)return;const t=this.ufoElement.currentTime,i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,this.currentSourceId);if(i?.kind!=="polygon")return;const n=lt.insertVertexNear(i,e);this.commitShapes(t,[{sourceId:this.currentSourceId,shape:n}]),this.ufoElement.refresh()}deleteVertexAtContextMenu(){const e=this.contextMenuPoint;if(this.hideContextMenu(),!e)return;const t=this.ufoElement.currentTime,i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,this.currentSourceId);if(i?.kind!=="polygon")return;const n=lt.hitTestVertex(i,e);if(n===void 0)return;const s=lt.deleteVertex(i,n);this.commitShapes(t,[{sourceId:this.currentSourceId,shape:s}]),this.ufoElement.refresh()}bringSelectedToFront(){const e=this.ufoElement.sighting.timeline;for(const t of e.sourceIds.filter(i=>this.selectedSourceIds.has(i)))e.bringToFront(t);this.hideContextMenu(),this.ufoElement.refresh()}sendSelectedToBack(){const e=this.ufoElement.sighting.timeline;for(const t of e.sourceIds.filter(i=>this.selectedSourceIds.has(i)).reverse())e.sendToBack(t);this.hideContextMenu(),this.ufoElement.refresh()}groupSelected(){this.selectedSourceIds.size<2||(this.ufoElement.sighting.timeline.group([...this.selectedSourceIds]),this.hideContextMenu(),this.ufoElement.refresh())}ungroupSelected(){this.ufoElement.sighting.timeline.ungroup(this.currentSourceId),this.selectedSourceIds=new Set([this.currentSourceId]),this.hideContextMenu(),this.ufoElement.refresh()}beginDrag(e,t,i,n,s){this.dragState={kind:e,sourceId:t,original:i,handle:s,startPointer:n},this.startDragListening()}beginCameraDrag(e){const t=this.isWitnessInsideDecor();this.cameraDragState={startPointer:e,startHeadingDeg:t?this.indoorLookYawDeg:this.numberOrUndefined(this.headingInput.value)??0,startPitchDeg:t?this.indoorLookPitchDeg:this.numberOrUndefined(this.pitchInput.value)??0,insideDecor:t},t||this.sceneElement.setCompassForced(!0),this.setCanvasCursor("panning"),this.startDragListening()}isWitnessInsideDecor(){return this.ufoElement.sighting.decor.some(e=>e.witnessSide!==void 0&&ra(e.kind))}syncIndoorLookReset(){const e=this.ufoElement.sighting.decor.find(i=>i.witnessSide!==void 0&&ra(i.kind)),t=e?`${e.id}:${e.witnessSide}`:void 0;t!==this.lastInhabitedKey&&(this.lastInhabitedKey=t,this.indoorLookYawDeg=0,this.indoorLookPitchDeg=0,this.sceneElement.setIndoorLook(0,0))}startDragListening(){document.addEventListener("pointermove",this.handleDragPointerMove),document.addEventListener("pointerup",this.handleDragPointerUp)}onDragPointerMove(e){if(this.referenceDragState){this.onReferenceDragPointerMove(e);return}if(this.cameraDragState){this.onCameraDragPointerMove(e);return}if(!this.dragState)return;const t=this.canvasPointFromEvent(e);if(!t)return;const i=this.ufoElement.currentTime;if(this.dragState.kind==="move"){const{sources:n,startPointer:s}=this.dragState,a=t.x-s.x,o=t.y-s.y,l=n.map(({sourceId:c,original:h})=>({sourceId:c,shape:{...h,bounds:{...h.bounds,x:h.bounds.x+a,y:h.bounds.y+o}}}));this.commitShapes(i,l)}else if(this.dragState.kind==="group-resize"){const{group:n,handle:s}=this.dragState;this.commitShapes(i,n.resize(s,t))}else if(this.dragState.kind==="group-rotate"){const{group:n,startPointer:s}=this.dragState;this.commitShapes(i,n.rotate(t,s))}else if(this.dragState.kind==="vertex"){const{sourceId:n,original:s,vertexIndex:a}=this.dragState,o=lt.moveVertex(s,a,t);this.commitShapes(i,[{sourceId:n,shape:o}])}else{const{kind:n,sourceId:s,original:a,handle:o}=this.dragState,l=n==="resize"?lt.resizeShape(a,o,t):lt.rotateShape(a,t);this.commitShapes(i,[{sourceId:s,shape:l}])}this.ufoElement.refresh()}onCameraDragPointerMove(e){if(!this.cameraDragState)return;const t=this.canvasPointFromEvent(e);if(!t)return;const{startPointer:i,startHeadingDeg:n,startPitchDeg:s,insideDecor:a}=this.cameraDragState,o=n+(t.x-i.x)*tg,l=Math.max(-90,Math.min(90,s-(t.y-i.y)*tg));if(a){this.indoorLookYawDeg=o,this.indoorLookPitchDeg=l,this.sceneElement.setIndoorLook(o,l),this.ufoElement.refresh();return}this.headingInput.value=String(this.rounded(o)),this.pitchInput.value=String(this.rounded(l)),this.updateObserver()}endDrag(){if(this.referenceDragState){this.endReferenceDrag();return}!this.dragState&&!this.cameraDragState||(this.cameraDragState&&!this.cameraDragState.insideDecor&&this.sceneElement.setCompassForced(!1),this.dragState=void 0,this.cameraDragState=void 0,this.setCanvasCursor(this.hoverCursor),document.removeEventListener("pointermove",this.handleDragPointerMove),document.removeEventListener("pointerup",this.handleDragPointerUp))}nudgeBounds(e,t){const i={...e};if(t.shiftKey){switch(t.key){case"ArrowLeft":i.width=Math.max(ks,i.width-As);break;case"ArrowRight":i.width+=As;break;case"ArrowUp":i.height=Math.max(ks,i.height-As);break;case"ArrowDown":i.height+=As;break}i.x-=(i.width-e.width)/2,i.y-=(i.height-e.height)/2}else switch(t.key){case"ArrowLeft":i.x-=As;break;case"ArrowRight":i.x+=As;break;case"ArrowUp":i.y-=As;break;case"ArrowDown":i.y+=As;break}return i}moveOrResizeSelectedShapes(e){if(this.isRecording||this.ufoElement.playbackState==="playing")return;const t=this.ufoElement.currentTime,i=this.selectedMembers();if(i.length!==0){if(e.preventDefault(),i.length===1){const{sourceId:n,shape:s}=i[0];this.commitShapes(t,[{sourceId:n,shape:{...s,bounds:this.nudgeBounds(s.bounds,e)}}])}else{const n=new Wc(i),s=this.nudgeBounds(n.bounds(),e);this.commitShapes(t,n.scaleTo(s))}this.ufoElement.refresh()}}updateHoverCursor(e){this.isRecording||this.dragState||this.cameraDragState||(this.hoverCursor=this.hoverCursorAt(e),this.setCanvasCursor(this.hoverCursor))}hoverCursorAt(e){const t=this.canvasPointFromEvent(e);if(!t)return;const i=this.canvasMode(),n=this.ufoElement.sighting.timeline,s=this.ufoElement.currentTime,a=this.ufoElement.playbackState!=="playing";if(i==="picture")return a?"pan":void 0;const o=i==="shape";if(a&&o)if(this.selectedSourceIds.size>1){const l=lt.hitTestHandle({bounds:new Wc(this.selectedMembers()).bounds(),angle:0},t);if(l)return this.cursorForHandle(l,0)}else{const l=n.getInterpolatedShapeAt(s,this.currentSourceId);if(l?.kind==="polygon"&&lt.hitTestVertex(l,t)!==void 0)return"vertex";const c=l&&lt.hitTestHandle(l,t);if(l&&c)return this.cursorForHandle(c,l.angle)}return n.hitTest(s,t.x,t.y)?a&&o?"move":"select":this.pickDecorAt(e)!==void 0?"select":a?"pan":void 0}cursorForHandle(e,t){return e==="rotate"?"rotate":`resize-${lt.resizeAxisFor(e,t)}`}setCanvasCursor(e){const t=this.ufoElement.canvasElement;e?t.dataset.cursor=e:delete t.dataset.cursor}onPointerMove(e){if(!this.isRecording){this.updateHoverCursor(e);return}const t=this.ufoElement.canvasElement,i=t.getBoundingClientRect(),n=e.clientX-i.left,s=e.clientY-i.top;this.recorder?.onPointerMove(n,s),this.ufoElement.renderer.clear(t.width,t.height),this.ufoElement.renderer.paintShape(cg(this.buildPrototype({x:0,y:0,width:ea.width,height:ea.height}),n,s))}canvasPointFromEvent(e){const t=this.ufoElement.canvasElement,i=t.getBoundingClientRect();if(!(i.width===0||i.height===0))return{x:(e.clientX-i.left)/i.width*t.width,y:(e.clientY-i.top)/i.height*t.height}}}const oA={stated:"narrativeStated",derived:"narrativeDerived",assumed:"narrativeAssumed"},sg="rr0-sighting-editor",rg="rr0-ufo-recorder";class lA extends Ct{}function cA(){Cc(),customElements.get(sg)||customElements.define(sg,Ct),customElements.get(rg)||customElements.define(rg,lA)}cA();export{zi as $,pn as A,ht as B,oe as C,a0 as D,rn as E,wA as F,bt as G,Tt as H,mA as I,pA as J,We as K,Uo as L,yA as M,Ko as N,_t as O,Mb as P,qn as Q,Io as R,xo as S,hA as T,gA as U,Te as V,Xg as W,vA as X,vo as Y,ci as Z,sn as _,uA as a,fA as a0,Hs as a1,Wg as a2,bA as a3,Wy as a4,lc as a5,ou as a6,mc as a7,di as a8,Jg as a9,uf as aa,ff as ab,tt as ac,Bs as ad,Fo as ae,bn as af,fs as ag,dA as b,Ui as c,SA as d,hc as e,Bi as f,xA as g,Ye as h,P as i,Wp as j,MA as k,EA as l,zy as m,or as n,Zc as o,yd as p,X2 as q,vt as r,zn as s,Nt as t,Cd as u,Ri as v,hf as w,ps as x,Zy as y,ib as z};