@iwsdk/vite-plugin-dev 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-rpc-errors.d.ts +13 -0
- package/dist/headless-browser.d.ts +6 -1
- package/dist/index.d.ts +0 -33
- package/dist/index.js +1420 -320
- package/dist/index.js.map +1 -1
- package/dist/injection-bundle.js +2 -2
- package/dist/mcp/ws-client.d.ts +3 -0
- package/dist/runtime-session.d.ts +21 -0
- package/dist/types.d.ts +2 -7
- package/package.json +6 -7
- package/dist/mcp-server.d.ts +0 -1379
- package/dist/mcp-server.js +0 -21312
- package/dist/mcp-server.js.map +0 -1
package/dist/injection-bundle.js
CHANGED
|
@@ -392,7 +392,7 @@
|
|
|
392
392
|
* Copyright 2010-2025 Three.js Authors
|
|
393
393
|
* SPDX-License-Identifier: MIT
|
|
394
394
|
*/
|
|
395
|
-
function Df(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Nf(e){const t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=t.get(n);i&&(e.deleteBuffer(i.buffer),t.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const e=t.get(n);return void((!e||e.version<n.version)&&t.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}const r=t.get(n);if(void 0===r)t.set(n,function(t,n){const i=t.array,r=t.usage,a=i.byteLength,s=e.createBuffer();let o;if(e.bindBuffer(n,s),e.bufferData(n,i,r),t.onUploadCallback(),i instanceof Float32Array)o=e.FLOAT;else if("undefined"!=typeof Float16Array&&i instanceof Float16Array)o=e.HALF_FLOAT;else if(i instanceof Uint16Array)o=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(i instanceof Int16Array)o=e.SHORT;else if(i instanceof Uint32Array)o=e.UNSIGNED_INT;else if(i instanceof Int32Array)o=e.INT;else if(i instanceof Int8Array)o=e.BYTE;else if(i instanceof Uint8Array)o=e.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);o=e.UNSIGNED_BYTE}return{buffer:s,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version,size:a}}(n,i));else if(r.version<n.version){if(r.size!==n.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(t,n,i){const r=n.array,a=n.updateRanges;if(e.bindBuffer(i,t),0===a.length)e.bufferSubData(i,0,r);else{a.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<a.length;e++){const n=a[t],i=a[e];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):(++t,a[t]=i)}a.length=t+1;for(let t=0,n=a.length;t<n;t++){const n=a[t];e.bufferSubData(i,n.start*r.BYTES_PER_ELEMENT,r,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}(r.buffer,n,i),r.version=n.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ro}})),"undefined"!=typeof window&&(window.__THREE__IWER__?kc("WARNING: Multiple instances of Three.js being imported."):window.__THREE__IWER__=Ro);const Of={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 uv = vec2( roughness, dotNV );\n\treturn texture2D( dfgLUT, uv ).rg;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );\n\tvec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );\n\tvec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\tfloat depth = unpackRGBAToDepth( texture2D( depths, uv ) );\n\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\treturn step( depth, compare );\n\t\t#else\n\t\t\treturn step( compare, depth );\n\t\t#endif\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow( sampler2D shadow, vec2 uv, float compare ) {\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\tfloat hard_shadow = step( distribution.x, compare );\n\t\t#else\n\t\t\tfloat hard_shadow = step( compare, distribution.x );\n\t\t#endif\n\t\tif ( hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},kf={common:{diffuse:{value:new zd(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Jc},alphaMap:{value:null},alphaMapTransform:{value:new Jc},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Jc}},envmap:{envMap:{value:null},envMapRotation:{value:new Jc},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Jc}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Jc}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Jc},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Jc},normalScale:{value:new $c(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Jc},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Jc}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Jc}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Jc}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new zd(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new zd(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Jc},alphaTest:{value:0},uvTransform:{value:new Jc}},sprite:{diffuse:{value:new zd(16777215)},opacity:{value:1},center:{value:new $c(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Jc},alphaMap:{value:null},alphaMapTransform:{value:new Jc},alphaTest:{value:0}}},Uf={basic:{uniforms:_h([kf.common,kf.specularmap,kf.envmap,kf.aomap,kf.lightmap,kf.fog]),vertexShader:Of.meshbasic_vert,fragmentShader:Of.meshbasic_frag},lambert:{uniforms:_h([kf.common,kf.specularmap,kf.envmap,kf.aomap,kf.lightmap,kf.emissivemap,kf.bumpmap,kf.normalmap,kf.displacementmap,kf.fog,kf.lights,{emissive:{value:new zd(0)}}]),vertexShader:Of.meshlambert_vert,fragmentShader:Of.meshlambert_frag},phong:{uniforms:_h([kf.common,kf.specularmap,kf.envmap,kf.aomap,kf.lightmap,kf.emissivemap,kf.bumpmap,kf.normalmap,kf.displacementmap,kf.fog,kf.lights,{emissive:{value:new zd(0)},specular:{value:new zd(1118481)},shininess:{value:30}}]),vertexShader:Of.meshphong_vert,fragmentShader:Of.meshphong_frag},standard:{uniforms:_h([kf.common,kf.envmap,kf.aomap,kf.lightmap,kf.emissivemap,kf.bumpmap,kf.normalmap,kf.displacementmap,kf.roughnessmap,kf.metalnessmap,kf.fog,kf.lights,{emissive:{value:new zd(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Of.meshphysical_vert,fragmentShader:Of.meshphysical_frag},toon:{uniforms:_h([kf.common,kf.aomap,kf.lightmap,kf.emissivemap,kf.bumpmap,kf.normalmap,kf.displacementmap,kf.gradientmap,kf.fog,kf.lights,{emissive:{value:new zd(0)}}]),vertexShader:Of.meshtoon_vert,fragmentShader:Of.meshtoon_frag},matcap:{uniforms:_h([kf.common,kf.bumpmap,kf.normalmap,kf.displacementmap,kf.fog,{matcap:{value:null}}]),vertexShader:Of.meshmatcap_vert,fragmentShader:Of.meshmatcap_frag},points:{uniforms:_h([kf.points,kf.fog]),vertexShader:Of.points_vert,fragmentShader:Of.points_frag},dashed:{uniforms:_h([kf.common,kf.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Of.linedashed_vert,fragmentShader:Of.linedashed_frag},depth:{uniforms:_h([kf.common,kf.displacementmap]),vertexShader:Of.depth_vert,fragmentShader:Of.depth_frag},normal:{uniforms:_h([kf.common,kf.bumpmap,kf.normalmap,kf.displacementmap,{opacity:{value:1}}]),vertexShader:Of.meshnormal_vert,fragmentShader:Of.meshnormal_frag},sprite:{uniforms:_h([kf.sprite,kf.fog]),vertexShader:Of.sprite_vert,fragmentShader:Of.sprite_frag},background:{uniforms:{uvTransform:{value:new Jc},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Of.background_vert,fragmentShader:Of.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Jc}},vertexShader:Of.backgroundCube_vert,fragmentShader:Of.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Of.cube_vert,fragmentShader:Of.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Of.equirect_vert,fragmentShader:Of.equirect_frag},distanceRGBA:{uniforms:_h([kf.common,kf.displacementmap,{referencePosition:{value:new Kc},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Of.distanceRGBA_vert,fragmentShader:Of.distanceRGBA_frag},shadow:{uniforms:_h([kf.lights,kf.fog,{color:{value:new zd(0)},opacity:{value:1}}]),vertexShader:Of.shadow_vert,fragmentShader:Of.shadow_frag}};Uf.physical={uniforms:_h([Uf.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Jc},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Jc},clearcoatNormalScale:{value:new $c(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Jc},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Jc},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Jc},sheen:{value:0},sheenColor:{value:new zd(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Jc},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Jc},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Jc},transmissionSamplerSize:{value:new $c},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Jc},attenuationDistance:{value:0},attenuationColor:{value:new zd(0)},specularColor:{value:new zd(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Jc},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Jc},anisotropyVector:{value:new $c},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Jc}}]),vertexShader:Of.meshphysical_vert,fragmentShader:Of.meshphysical_frag};const Ff={r:0,b:0,g:0},zf=new id,Bf=new qu;function Vf(e,t,n,i,r,a,s){const o=new zd(0);let l,c,u=!0===a?0:1,d=null,h=0,f=null;function p(e){let i=!0===e.isScene?e.background:null;if(i&&i.isTexture){i=(e.backgroundBlurriness>0?n:t).get(i)}return i}function m(t,n){t.getRGB(Ff,bh(e)),i.buffers.color.setClear(Ff.r,Ff.g,Ff.b,n,s)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),u=t,m(o,u)},getClearAlpha:function(){return u},setClearAlpha:function(e){u=e,m(o,u)},render:function(t){let n=!1;const r=p(t);null===r?m(o,u):r&&r.isColor&&(m(r,1),n=!0);const a=e.xr.getEnvironmentBlendMode();"additive"===a?i.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===a&&i.buffers.color.setClear(0,0,0,0,s),(e.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){const i=p(n);i&&(i.isCubeTexture||i.mapping===sl)?(void 0===c&&(c=new gh(new yh(1e4,1e4,1e4),new Sh({name:"BackgroundCubeMaterial",uniforms:xh(Uf.backgroundCube.uniforms),vertexShader:Uf.backgroundCube.vertexShader,fragmentShader:Uf.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),zf.copy(n.backgroundRotation),zf.x*=-1,zf.y*=-1,zf.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(zf.y*=-1,zf.z*=-1),c.material.uniforms.envMap.value=i,c.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Bf.makeRotationFromEuler(zf)),c.material.toneMapped=ru.getTransfer(i.colorSpace)!==yc,d===i&&h===i.version&&f===e.toneMapping||(c.material.needsUpdate=!0,d=i,h=i.version,f=e.toneMapping),c.layers.enableAll(),t.unshift(c,c.geometry,c.material,0,0,null)):i&&i.isTexture&&(void 0===l&&(l=new gh(new df(2,2),new Sh({name:"BackgroundMaterial",uniforms:xh(Uf.background.uniforms),vertexShader:Uf.background.vertexShader,fragmentShader:Uf.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=i,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=ru.getTransfer(i.colorSpace)!==yc,!0===i.matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),d===i&&h===i.version&&f===e.toneMapping||(l.material.needsUpdate=!0,d=i,h=i.version,f=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null))},dispose:function(){void 0!==c&&(c.geometry.dispose(),c.material.dispose(),c=void 0),void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}}}function Hf(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=c(null);let a=r,s=!1;function o(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function c(e){const t=[],i=[],r=[];for(let e=0;e<n;e++)t[e]=0,i[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:r,object:e,attributes:{},index:null}}function u(){const e=a.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function d(e){h(e,0)}function h(t,n){const i=a.newAttributes,r=a.enabledAttributes,s=a.attributeDivisors;i[t]=1,0===r[t]&&(e.enableVertexAttribArray(t),r[t]=1),s[t]!==n&&(e.vertexAttribDivisor(t,n),s[t]=n)}function f(){const t=a.newAttributes,n=a.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function p(t,n,i,r,a,s,o){!0===o?e.vertexAttribIPointer(t,n,i,a,s):e.vertexAttribPointer(t,n,i,r,a,s)}function m(){g(),s=!0,a!==r&&(a=r,o(a.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(n,r,l,m,g){let v=!1;const y=function(t,n,r){const a=!0===r.wireframe;let s=i[t.id];void 0===s&&(s={},i[t.id]=s);let o=s[n.id];void 0===o&&(o={},s[n.id]=o);let l=o[a];void 0===l&&(l=c(e.createVertexArray()),o[a]=l);return l}(m,l,r);a!==y&&(a=y,o(a.object)),v=function(e,t,n,i){const r=a.attributes,s=t.attributes;let o=0;const l=n.getAttributes();for(const t in l){if(l[t].location>=0){const n=r[t];let i=s[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}}return a.attributesNum!==o||a.index!==i}(n,m,l,g),v&&function(e,t,n,i){const r={},s=t.attributes;let o=0;const l=n.getAttributes();for(const t in l){if(l[t].location>=0){let n=s[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,o++}}a.attributes=r,a.attributesNum=o,a.index=i}(n,m,l,g),null!==g&&t.update(g,e.ELEMENT_ARRAY_BUFFER),(v||s)&&(s=!1,function(n,i,r,a){u();const s=a.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const r=o[i];if(r.location>=0){let o=s[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,s=o.itemSize,l=t.get(o);if(void 0===l)continue;const c=l.buffer,u=l.type,f=l.bytesPerElement,m=u===e.INT||u===e.UNSIGNED_INT||o.gpuType===_l;if(o.isInterleavedBufferAttribute){const t=o.data,l=t.stride,g=o.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e<r.locationSize;e++)h(r.location+e,t.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<r.locationSize;e++)d(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<r.locationSize;e++)p(r.location+e,s/r.locationSize,u,i,l*f,(g+s/r.locationSize*e)*f,m)}else{if(o.isInstancedBufferAttribute){for(let e=0;e<r.locationSize;e++)h(r.location+e,o.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let e=0;e<r.locationSize;e++)d(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<r.locationSize;e++)p(r.location+e,s/r.locationSize,u,i,s*f,s/r.locationSize*e*f,m)}}else if(void 0!==l){const t=l[i];if(void 0!==t)switch(t.length){case 2:e.vertexAttrib2fv(r.location,t);break;case 3:e.vertexAttrib3fv(r.location,t);break;case 4:e.vertexAttrib4fv(r.location,t);break;default:e.vertexAttrib1fv(r.location,t)}}}}f()}(n,r,l,m),null!==g&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(g).buffer))},reset:m,resetDefaultState:g,dispose:function(){m();for(const e in i){const t=i[e];for(const e in t){const n=t[e];for(const e in n)l(n[e].object),delete n[e];delete t[e]}delete i[e]}},releaseStatesOfGeometry:function(e){if(void 0===i[e.id])return;const t=i[e.id];for(const e in t){const n=t[e];for(const e in n)l(n[e].object),delete n[e];delete t[e]}delete i[e.id]},releaseStatesOfProgram:function(e){for(const t in i){const n=i[t];if(void 0===n[e.id])continue;const r=n[e.id];for(const e in r)l(r[e].object),delete r[e];delete n[e.id]}},initAttributes:u,enableAttribute:d,disableUnusedAttributes:f}}function Gf(e,t,n){let i;function r(t,r,a){0!==a&&(e.drawArraysInstanced(i,t,r,a),n.update(r,i,a))}this.setMode=function(e){i=e},this.render=function(t,r){e.drawArrays(i,t,r),n.update(r,i,1)},this.renderInstances=r,this.renderMultiDraw=function(e,r,a){if(0===a)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,e,0,r,0,a);let s=0;for(let e=0;e<a;e++)s+=r[e];n.update(s,i,1)},this.renderMultiDrawInstances=function(e,a,s,o){if(0===s)return;const l=t.get("WEBGL_multi_draw");if(null===l)for(let t=0;t<e.length;t++)r(e[t],a[t],o[t]);else{l.multiDrawArraysInstancedWEBGL(i,e,0,a,0,o,0,s);let t=0;for(let e=0;e<s;e++)t+=a[e]*o[e];n.update(t,i,1)}}}function jf(e,t,n,i){let r;function a(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let s=void 0!==n.precision?n.precision:"highp";const o=a(s);o!==s&&(kc("WebGLRenderer:",s,"not supported, using",o,"instead."),s=o);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reversedDepthBuffer&&t.has("EXT_clip_control"),u=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,textureFormatReadable:function(t){return t===Cl||i.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===Sl&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(n!==gl&&i.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==wl&&!r)},precision:s,logarithmicDepthBuffer:l,reversedDepthBuffer:c,maxTextures:u,maxVertexTextures:d,maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:d>0,maxSamples:e.getParameter(e.MAX_SAMPLES)}}function Wf(e){const t=this;let n=null,i=0,r=!1,a=!1;const s=new Vh,o=new Jc,l={value:null,needsUpdate:!1};function c(e,n,i,r){const a=null!==e?e.length:0;let c=null;if(0!==a){if(c=l.value,!0!==r||null===c){const t=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,n=i;t!==a;++t,n+=4)s.copy(e[t]).applyMatrix4(r,o),s.normal.toArray(c,n),c[n+3]=s.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=a,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){const n=0!==e.length||t||0!==i||r;return r=t,i=e.length,n},this.beginShadows=function(){a=!0,c(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=c(e,t,0)},this.setState=function(s,o,u){const d=s.clippingPlanes,h=s.clipIntersection,f=s.clipShadows,p=e.get(s);if(!r||null===d||0===d.length||a&&!f)a?c(null):function(){l.value!==n&&(l.value=n,l.needsUpdate=i>0);t.numPlanes=i,t.numIntersection=0}();else{const e=a?0:i,t=4*e;let r=p.clippingState||null;l.value=r,r=c(d,o,t,u);for(let e=0;e!==t;++e)r[e]=n[e];p.clippingState=r,this.numIntersection=h?this.numPlanes:0,this.numPlanes+=e}}}function Xf(e){let t=new WeakMap;function n(e,t){return 303===t?e.mapping=rl:304===t&&(e.mapping=al),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping;if(303===a||304===a){if(t.has(r)){return n(t.get(r).texture,r.mapping)}{const a=r.image;if(a&&a.height>0){const s=new Ih(a.height);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}const qf=[.125,.215,.35,.446,.526,.582],$f=20,Yf=new yf,Kf=new zd;let Zf=null,Qf=0,Jf=0,ep=!1;const tp=new Kc;class np{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,i=100,r={}){const{size:a=256,position:s=tp}=r;Zf=this._renderer.getRenderTarget(),Qf=this._renderer.getActiveCubeFace(),Jf=this._renderer.getActiveMipmapLevel(),ep=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(e,n,i,o,s),t>0&&this._blur(o,0,0,t),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=sp(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=ap(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Zf,Qf,Jf),this._renderer.xr.enabled=ep,e.scissorTest=!1,rp(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===rl||e.mapping===al?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Zf=this._renderer.getRenderTarget(),Qf=this._renderer.getActiveCubeFace(),Jf=this._renderer.getActiveMipmapLevel(),ep=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:fl,minFilter:fl,generateMipmaps:!1,type:Sl,format:Cl,colorSpace:gc,depthBuffer:!1},i=ip(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=ip(e,t,n);const{_lodMax:i}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(e){const t=[],n=[],i=[];let r=e;const a=e-4+1+qf.length;for(let s=0;s<a;s++){const a=Math.pow(2,r);t.push(a);let o=1/a;s>e-4?o=qf[s-e+4-1]:0===s&&(o=0),n.push(o);const l=1/(a-2),c=-l,u=1+l,d=[c,c,u,c,u,u,c,c,u,u,c,u],h=6,f=6,p=3,m=2,g=1,v=new Float32Array(p*f*h),y=new Float32Array(m*f*h),x=new Float32Array(g*f*h);for(let e=0;e<h;e++){const t=e%3*2/3-1,n=e>2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(i,p*f*e),y.set(d,m*f*e);const r=[e,e,e,e,e,e];x.set(r,g*f*e)}const _=new rh;_.setAttribute("position",new qd(v,p)),_.setAttribute("uv",new qd(y,m)),_.setAttribute("faceIndex",new qd(x,g)),i.push(new gh(_,null)),r>4&&r--}return{lodMeshes:i,sizeLods:t,sigmas:n}}(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array($f),r=new Kc(0,1,0),a=new Sh({name:"SphericalGaussianBlur",defines:{n:$f,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:op(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return a}(i,e,t)}return i}_compileMaterial(e){const t=new gh(new rh,e);this._renderer.compile(t,Yf)}_sceneToCubeUV(e,t,n,i,r){const a=new Rh(90,1,t,n),s=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear,u=l.toneMapping;l.getClearColor(Kf),l.toneMapping=0,l.autoClear=!1;l.state.buffers.depth.getReversed()&&(l.setRenderTarget(i),l.clearDepth(),l.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new gh(new yh,new Gd({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));const d=this._backgroundBox,h=d.material;let f=!1;const p=e.background;p?p.isColor&&(h.color.copy(p),e.background=null,f=!0):(h.color.copy(Kf),f=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(a.up.set(0,s[t],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+o[t],r.y,r.z)):1===n?(a.up.set(0,0,s[t]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+o[t],r.z)):(a.up.set(0,s[t],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+o[t]));const c=this._cubeSize;rp(i,n*c,t>2?c:0,c,c),l.setRenderTarget(i),f&&l.render(d,a),l.render(e,a)}l.toneMapping=u,l.autoClear=c,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===rl||e.mapping===al;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=sp()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=ap());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;r.uniforms.envMap.value=e;const s=this._cubeSize;rp(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,Yf)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let t=1;t<i;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=n}_applyGGXFilter(e,t,n){const i=this._renderer,r=this._pingPongRenderTarget;if(null===this._ggxMaterial){const e=3*Math.max(this._cubeSize,16),t=4*this._cubeSize;this._ggxMaterial=function(e,t,n){const i=new Sh({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:op(),fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 3.2: Transform view direction to hemisphere configuration\n\t\t\t\tvec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tfloat lensq = Vh.x * Vh.x + Vh.y * Vh.y;\n\t\t\t\tvec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(Vh, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + Vh.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:0,depthTest:!1,depthWrite:!1});return i}(this._lodMax,e,t)}const a=this._ggxMaterial,s=this._lodMeshes[n];s.material=a;const o=a.uniforms,l=n/(this._lodMeshes.length-1),c=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-c*c)*(.05+.95*l),{_lodMax:d}=this,h=this._sizeLods[n],f=3*h*(n>d-4?n-d+4:0),p=4*(this._cubeSize-h);o.envMap.value=e.texture,o.roughness.value=u,o.mipInt.value=d-t,rp(r,f,p,3*h,2*h),i.setRenderTarget(r),i.render(s,Yf),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=d-n,rp(e,f,p,3*h,2*h),i.setRenderTarget(e),i.render(s,Yf)}_blur(e,t,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,s){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&Uc("blur direction must be either latitudinal or longitudinal!");const c=this._lodMeshes[i];c.material=l;const u=l.uniforms,d=this._sizeLods[n]-1,h=isFinite(r)?Math.PI/(2*d):2*Math.PI/39,f=r/h,p=isFinite(r)?1+Math.floor(3*f):$f;p>$f&&kc(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<$f;++e){const t=e/f,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:e<p&&(g+=2*n)}for(let e=0;e<m.length;e++)m[e]=m[e]/g;u.envMap.value=e.texture,u.samples.value=p,u.weights.value=m,u.latitudinal.value="latitudinal"===a,s&&(u.poleAxis.value=s);const{_lodMax:v}=this;u.dTheta.value=h,u.mipInt.value=v-n;const y=this._sizeLods[i];rp(t,3*y*(i>v-4?i-v+4:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(t),o.render(c,Yf)}}function ip(e,t,n){const i=new vu(e,t,n);return i.texture.mapping=sl,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function rp(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function ap(){return new Sh({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:op(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function sp(){return new Sh({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:op(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function op(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function lp(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping,s=303===a||304===a,o=a===rl||a===al;if(s||o){let a=t.get(r);const l=void 0!==a?a.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new np(e)),a=s?n.fromEquirectangular(r,a):n.fromCubemap(r,a),a.texture.pmremVersion=r.pmremVersion,t.set(r,a),a.texture;if(void 0!==a)return a.texture;{const l=r.image;return s&&l&&l.height>0||o&&l&&function(e){let t=0;const n=6;for(let i=0;i<n;i++)void 0!==e[i]&&t++;return t===n}(l)?(null===n&&(n=new np(e)),a=s?n.fromEquirectangular(r):n.fromCubemap(r),a.texture.pmremVersion=r.pmremVersion,t.set(r,a),r.addEventListener("dispose",i),a.texture):null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function cp(e){const t={};function n(n){if(void 0!==t[n])return t[n];const i=e.getExtension(n);return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){const t=n(e);return null===t&&Fc("WebGLRenderer: "+e+" extension not supported."),t}}}function up(e,t,n,i){const r={},a=new WeakMap;function s(e){const o=e.target;null!==o.index&&t.remove(o.index);for(const e in o.attributes)t.remove(o.attributes[e]);o.removeEventListener("dispose",s),delete r[o.id];const l=a.get(o);l&&(t.remove(l),a.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(e){const n=[],i=e.index,r=e.attributes.position;let s=0;if(null!==i){const e=i.array;s=i.version;for(let t=0,i=e.length;t<i;t+=3){const i=e[t+0],r=e[t+1],a=e[t+2];n.push(i,r,r,a,a,i)}}else{if(void 0===r)return;{const e=r.array;s=r.version;for(let t=0,i=e.length/3-1;t<i;t+=3){const e=t+0,i=t+1,r=t+2;n.push(e,i,i,r,r,e)}}}const o=new(Lc(n)?Yd:$d)(n,1);o.version=s;const l=a.get(e);l&&t.remove(l),a.set(e,o)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",s),r[t.id]=!0,n.memory.geometries++),t},update:function(n){const i=n.attributes;for(const n in i)t.update(i[n],e.ARRAY_BUFFER)},getWireframeAttribute:function(e){const t=a.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&o(e)}else o(e);return a.get(e)}}}function dp(e,t,n){let i,r,a;function s(t,s,o){0!==o&&(e.drawElementsInstanced(i,s,r,t*a,o),n.update(s,i,o))}this.setMode=function(e){i=e},this.setIndex=function(e){r=e.type,a=e.bytesPerElement},this.render=function(t,s){e.drawElements(i,s,r,t*a),n.update(s,i,1)},this.renderInstances=s,this.renderMultiDraw=function(e,a,s){if(0===s)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,a,0,r,e,0,s);let o=0;for(let e=0;e<s;e++)o+=a[e];n.update(o,i,1)},this.renderMultiDrawInstances=function(e,o,l,c){if(0===l)return;const u=t.get("WEBGL_multi_draw");if(null===u)for(let t=0;t<e.length;t++)s(e[t]/a,o[t],c[t]);else{u.multiDrawElementsInstancedWEBGL(i,o,0,r,e,0,c,0,l);let t=0;for(let e=0;e<l;e++)t+=o[e]*c[e];n.update(t,i,1)}}}function hp(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,i,r){switch(t.calls++,i){case e.TRIANGLES:t.triangles+=r*(n/3);break;case e.LINES:t.lines+=r*(n/2);break;case e.LINE_STRIP:t.lines+=r*(n-1);break;case e.LINE_LOOP:t.lines+=r*n;break;case e.POINTS:t.points+=r*n;break;default:Uc("WebGLInfo: Unknown draw mode:",i)}}}}function fp(e,t,n){const i=new WeakMap,r=new mu;return{update:function(a,s,o){const l=a.morphTargetInfluences,c=s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color,u=void 0!==c?c.length:0;let d=i.get(s);if(void 0===d||d.count!==u){void 0!==d&&d.texture.dispose();const h=void 0!==s.morphAttributes.position,f=void 0!==s.morphAttributes.normal,p=void 0!==s.morphAttributes.color,m=s.morphAttributes.position||[],g=s.morphAttributes.normal||[],v=s.morphAttributes.color||[];let y=0;!0===h&&(y=1),!0===f&&(y=2),!0===p&&(y=3);let x=s.attributes.position.count*y,_=1;x>t.maxTextureSize&&(_=Math.ceil(x/t.maxTextureSize),x=t.maxTextureSize);const b=new Float32Array(x*_*4*u),w=new yu(b,x,_,u);w.type=wl,w.needsUpdate=!0;const S=4*y;for(let E=0;E<u;E++){const T=m[E],A=g[E],R=v[E],C=x*_*4*E;for(let P=0;P<T.count;P++){const L=P*S;!0===h&&(r.fromBufferAttribute(T,P),b[C+L+0]=r.x,b[C+L+1]=r.y,b[C+L+2]=r.z,b[C+L+3]=0),!0===f&&(r.fromBufferAttribute(A,P),b[C+L+4]=r.x,b[C+L+5]=r.y,b[C+L+6]=r.z,b[C+L+7]=0),!0===p&&(r.fromBufferAttribute(R,P),b[C+L+8]=r.x,b[C+L+9]=r.y,b[C+L+10]=r.z,b[C+L+11]=4===R.itemSize?r.w:1)}}function M(){w.dispose(),i.delete(s),s.removeEventListener("dispose",M)}d={count:u,texture:w,size:new $c(x,_)},i.set(s,d),s.addEventListener("dispose",M)}if(!0===a.isInstancedMesh&&null!==a.morphTexture)o.getUniforms().setValue(e,"morphTexture",a.morphTexture,n);else{let I=0;for(let N=0;N<l.length;N++)I+=l[N];const D=s.morphTargetsRelative?1:1-I;o.getUniforms().setValue(e,"morphTargetBaseInfluence",D),o.getUniforms().setValue(e,"morphTargetInfluences",l)}o.getUniforms().setValue(e,"morphTargetsTexture",d.texture,n),o.getUniforms().setValue(e,"morphTargetsTextureSize",d.size)}}}class pp{constructor(e,t,n){if(this.renderer=e,this.DEFAULT_NUMVIEWS=2,this.maxNumViews=0,this.gl=n,this.extensions=t,this.available=this.extensions.has("OCULUS_multiview"),this.available){const e=this.extensions.get("OCULUS_multiview");this.maxNumViews=this.gl.getParameter(e.MAX_VIEWS_OVR),this.mat4=[],this.mat3=[],this.cameraArray=[];for(var i=0;i<this.maxNumViews;i++)this.mat4[i]=new qu,this.mat3[i]=new Jc}}getCameraArray(e){return e.isArrayCamera?e.cameras:(this.cameraArray[0]=e,this.cameraArray)}updateCameraProjectionMatricesUniform(e,t){for(var n=this.getCameraArray(e),i=0;i<n.length;i++)this.mat4[i].copy(n[i].projectionMatrix);t.setValue(this.gl,"projectionMatrices",this.mat4)}updateCameraViewMatricesUniform(e,t){for(var n=this.getCameraArray(e),i=0;i<n.length;i++)this.mat4[i].copy(n[i].matrixWorldInverse);t.setValue(this.gl,"viewMatrices",this.mat4)}updateObjectMatricesUniforms(e,t,n){for(var i=this.getCameraArray(t),r=0;r<i.length;r++)this.mat4[r].multiplyMatrices(i[r].matrixWorldInverse,e.matrixWorld),this.mat3[r].getNormalMatrix(this.mat4[r]);n.setValue(this.gl,"modelViewMatrices",this.mat4),n.setValue(this.gl,"normalMatrices",this.mat3)}}function mp(e,t,n,i){let r=new WeakMap;function a(e){const t=e.target;t.removeEventListener("dispose",a),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(s){const o=i.render.frame,l=s.geometry,c=t.get(s,l);if(r.get(c)!==o&&(t.update(c),r.set(c,o)),s.isInstancedMesh&&(!1===s.hasEventListener("dispose",a)&&s.addEventListener("dispose",a),r.get(s)!==o&&(n.update(s.instanceMatrix,e.ARRAY_BUFFER),null!==s.instanceColor&&n.update(s.instanceColor,e.ARRAY_BUFFER),r.set(s,o))),s.isSkinnedMesh){const e=s.skeleton;r.get(e)!==o&&(e.update(),r.set(e,o))}return c},dispose:function(){r=new WeakMap}}}const gp=new pu,vp=new sf(1,1),yp=new yu,xp=new xu,_p=new Lh,bp=[],wp=[],Sp=new Float32Array(16),Mp=new Float32Array(9),Ep=new Float32Array(4);function Tp(e,t,n){const i=e[0];if(i<=0||i>0)return e;const r=t*n;let a=bp[r];if(void 0===a&&(a=new Float32Array(r),bp[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function Ap(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function Rp(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Cp(e,t){let n=wp[t];void 0===n&&(n=new Int32Array(t),wp[t]=n);for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function Pp(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function Lp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Ap(n,t))return;e.uniform2fv(this.addr,t),Rp(n,t)}}function Ip(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(Ap(n,t))return;e.uniform3fv(this.addr,t),Rp(n,t)}}function Dp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Ap(n,t))return;e.uniform4fv(this.addr,t),Rp(n,t)}}function Np(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Ap(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Rp(n,t)}else{if(Ap(n,i))return;Ep.set(i),e.uniformMatrix2fv(this.addr,!1,Ep),Rp(n,i)}}function Op(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Ap(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Rp(n,t)}else{if(Ap(n,i))return;Mp.set(i),e.uniformMatrix3fv(this.addr,!1,Mp),Rp(n,i)}}function kp(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Ap(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Rp(n,t)}else{if(Ap(n,i))return;Sp.set(i),e.uniformMatrix4fv(this.addr,!1,Sp),Rp(n,i)}}function Up(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function Fp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Ap(n,t))return;e.uniform2iv(this.addr,t),Rp(n,t)}}function zp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Ap(n,t))return;e.uniform3iv(this.addr,t),Rp(n,t)}}function Bp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Ap(n,t))return;e.uniform4iv(this.addr,t),Rp(n,t)}}function Vp(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function Hp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Ap(n,t))return;e.uniform2uiv(this.addr,t),Rp(n,t)}}function Gp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Ap(n,t))return;e.uniform3uiv(this.addr,t),Rp(n,t)}}function jp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Ap(n,t))return;e.uniform4uiv(this.addr,t),Rp(n,t)}}function Wp(e,t,n){const i=this.cache,r=n.allocateTextureUnit();let a;i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),this.type===e.SAMPLER_2D_SHADOW?(vp.compareFunction=515,a=vp):a=gp,n.setTexture2D(t||a,r)}function Xp(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(t||xp,r)}function qp(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(t||_p,r)}function $p(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(t||yp,r)}function Yp(e,t){e.uniform1fv(this.addr,t)}function Kp(e,t){const n=Tp(t,this.size,2);e.uniform2fv(this.addr,n)}function Zp(e,t){const n=Tp(t,this.size,3);e.uniform3fv(this.addr,n)}function Qp(e,t){const n=Tp(t,this.size,4);e.uniform4fv(this.addr,n)}function Jp(e,t){const n=Tp(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function em(e,t){const n=Tp(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function tm(e,t){const n=Tp(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function nm(e,t){e.uniform1iv(this.addr,t)}function im(e,t){e.uniform2iv(this.addr,t)}function rm(e,t){e.uniform3iv(this.addr,t)}function am(e,t){e.uniform4iv(this.addr,t)}function sm(e,t){e.uniform1uiv(this.addr,t)}function om(e,t){e.uniform2uiv(this.addr,t)}function lm(e,t){e.uniform3uiv(this.addr,t)}function cm(e,t){e.uniform4uiv(this.addr,t)}function um(e,t,n){const i=this.cache,r=t.length,a=Cp(n,r);Ap(i,a)||(e.uniform1iv(this.addr,a),Rp(i,a));for(let e=0;e!==r;++e)n.setTexture2D(t[e]||gp,a[e])}function dm(e,t,n){const i=this.cache,r=t.length,a=Cp(n,r);Ap(i,a)||(e.uniform1iv(this.addr,a),Rp(i,a));for(let e=0;e!==r;++e)n.setTexture3D(t[e]||xp,a[e])}function hm(e,t,n){const i=this.cache,r=t.length,a=Cp(n,r);Ap(i,a)||(e.uniform1iv(this.addr,a),Rp(i,a));for(let e=0;e!==r;++e)n.setTextureCube(t[e]||_p,a[e])}function fm(e,t,n){const i=this.cache,r=t.length,a=Cp(n,r);Ap(i,a)||(e.uniform1iv(this.addr,a),Rp(i,a));for(let e=0;e!==r;++e)n.setTexture2DArray(t[e]||yp,a[e])}class pm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=function(e){switch(e){case 5126:return Pp;case 35664:return Lp;case 35665:return Ip;case 35666:return Dp;case 35674:return Np;case 35675:return Op;case 35676:return kp;case 5124:case 35670:return Up;case 35667:case 35671:return Fp;case 35668:case 35672:return zp;case 35669:case 35673:return Bp;case 5125:return Vp;case 36294:return Hp;case 36295:return Gp;case 36296:return jp;case 35678:case 36198:case 36298:case 36306:case 35682:return Wp;case 35679:case 36299:case 36307:return Xp;case 35680:case 36300:case 36308:case 36293:return qp;case 36289:case 36303:case 36311:case 36292:return $p}}(t.type)}}class mm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return Yp;case 35664:return Kp;case 35665:return Zp;case 35666:return Qp;case 35674:return Jp;case 35675:return em;case 35676:return tm;case 5124:case 35670:return nm;case 35667:case 35671:return im;case 35668:case 35672:return rm;case 35669:case 35673:return am;case 5125:return sm;case 36294:return om;case 36295:return lm;case 36296:return cm;case 35678:case 36198:case 36298:case 36306:case 35682:return um;case 35679:case 36299:case 36307:return dm;case 35680:case 36300:case 36308:case 36293:return hm;case 36289:case 36303:case 36311:case 36292:return fm}}(t.type)}}class gm{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const a=i[r];a.setValue(e,t[a.id],n)}}}const vm=/(\w+)(\])?(\[|\.)?/g;function ym(e,t){e.seq.push(t),e.map[t.id]=t}function xm(e,t,n){const i=e.name,r=i.length;for(vm.lastIndex=0;;){const a=vm.exec(i),s=vm.lastIndex;let o=a[1];const l="]"===a[2],c=a[3];if(l&&(o|=0),void 0===c||"["===c&&s+2===r){ym(n,void 0===c?new pm(o,e,t):new mm(o,e,t));break}{let e=n.map[o];void 0===e&&(e=new gm(o),ym(n,e)),n=e}}}class _m{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const n=e.getActiveUniform(t,i);xm(n,e.getUniformLocation(t,n.name),this)}}setValue(e,t,n,i){const r=this.map[t];void 0!==r&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];void 0!==i&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){const a=t[r],s=n[a.id];!1!==s.needsUpdate&&a.setValue(e,s.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const r=e[i];r.id in t&&n.push(r)}return n}}function bm(e,t,n){const i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}let wm=0;const Sm=new Jc;function Mm(e,t,n){const i=e.getShaderParameter(t,e.COMPILE_STATUS),r=(e.getShaderInfoLog(t)||"").trim();if(i&&""===r)return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const i=parseInt(a[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(e,t){const n=e.split("\n"),i=[],r=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=r;e<a;e++){const r=e+1;i.push(`${r===t?">":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function Em(e,t){const n=function(e){ru._getMatrix(Sm,ru.workingColorSpace,e);const t=`mat3( ${Sm.elements.map(e=>e.toFixed(4))} )`;switch(ru.getTransfer(e)){case vc:return[t,"LinearTransferOETF"];case yc:return[t,"sRGBTransferOETF"];default:return kc("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(t);return[`vec4 ${e}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}function Tm(e,t){let n;switch(t){case 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="Cineon";break;case 4:n="ACESFilmic";break;case 6:n="AgX";break;case 7:n="Neutral";break;case 5:n="Custom";break;default:kc("WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Am=new Kc;function Rm(){ru.getLuminanceCoefficients(Am);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${Am.x.toFixed(4)}, ${Am.y.toFixed(4)}, ${Am.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function Cm(e){return""!==e}function Pm(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Lm(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Im=/^[ \t]*#include +<([\w\d./]+)>/gm;function Dm(e){return e.replace(Im,Om)}const Nm=new Map;function Om(e,t){let n=Of[t];if(void 0===n){const e=Nm.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=Of[e],kc('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return Dm(n)}const km=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Um(e){return e.replace(km,Fm)}function Fm(e,t,n,i){let r="";for(let e=parseInt(t);e<parseInt(n);e++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return r}function zm(e){let t=`precision ${e.precision} float;\n\tprecision ${e.precision} int;\n\tprecision ${e.precision} sampler2D;\n\tprecision ${e.precision} samplerCube;\n\tprecision ${e.precision} sampler3D;\n\tprecision ${e.precision} sampler2DArray;\n\tprecision ${e.precision} sampler2DShadow;\n\tprecision ${e.precision} samplerCubeShadow;\n\tprecision ${e.precision} sampler2DArrayShadow;\n\tprecision ${e.precision} isampler2D;\n\tprecision ${e.precision} isampler3D;\n\tprecision ${e.precision} isamplerCube;\n\tprecision ${e.precision} isampler2DArray;\n\tprecision ${e.precision} usampler2D;\n\tprecision ${e.precision} usampler3D;\n\tprecision ${e.precision} usamplerCube;\n\tprecision ${e.precision} usampler2DArray;\n\t`;return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function Bm(e,t,n,i){const r=e.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const l=function(e){let t="SHADOWMAP_TYPE_BASIC";return 1===e.shadowMapType?t="SHADOWMAP_TYPE_PCF":2===e.shadowMapType?t="SHADOWMAP_TYPE_PCF_SOFT":3===e.shadowMapType&&(t="SHADOWMAP_TYPE_VSM"),t}(n),c=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case rl:case al:t="ENVMAP_TYPE_CUBE";break;case sl:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),u=function(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===al&&(t="ENVMAP_MODE_REFRACTION");return t}(n),d=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case 0:t="ENVMAP_BLENDING_MULTIPLY";break;case 1:t="ENVMAP_BLENDING_MIX";break;case 2:t="ENVMAP_BLENDING_ADD"}return t}(n),h=function(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),f=function(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Cm).join("\n")}(n),p=function(e){const t=[];for(const n in e){const i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(a),m=r.createProgram();let g,v,y=n.glslVersion?"#version "+n.glslVersion+"\n":"";const x=n.numMultiviewViews;n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,p].filter(Cm).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,p].filter(Cm).join("\n"),v.length>0&&(v+="\n")):(g=[zm(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,p,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Cm).join("\n"),v=[zm(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,p,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?Of.tonemapping_pars_fragment:"",0!==n.toneMapping?Tm("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Of.colorspace_pars_fragment,Em("linearToOutputTexel",n.outputColorSpace),Rm(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Cm).join("\n")),s=Dm(s),s=Pm(s,n),s=Lm(s,n),o=Dm(o),o=Pm(o,n),o=Lm(o,n),s=Um(s),o=Um(o),!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===Rc?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Rc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v,x>0&&(g=["#extension GL_OVR_multiview : require","layout(num_views = "+x+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n")+"\n"+g,g=g.replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join("\n"),["uniform mat4 modelViewMatrices["+x+"];","uniform mat4 projectionMatrices["+x+"];","uniform mat4 viewMatrices["+x+"];","uniform mat3 normalMatrices["+x+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join("\n")),v=["#extension GL_OVR_multiview : require","#define VIEW_ID gl_ViewID_OVR"].join("\n")+"\n"+v,v=v.replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+x+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n"))));const _=y+g+s,b=y+v+o,w=bm(r,r.VERTEX_SHADER,_),S=bm(r,r.FRAGMENT_SHADER,b);function M(t){if(e.debug.checkShaderErrors){const n=r.getProgramInfoLog(m)||"",i=r.getShaderInfoLog(w)||"",a=r.getShaderInfoLog(S)||"",s=n.trim(),o=i.trim(),l=a.trim();let c=!0,u=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(c=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(r,m,w,S);else{const e=Mm(r,w,"vertex"),n=Mm(r,S,"fragment");Uc("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+s+"\n"+e+"\n"+n)}else""!==s?kc("WebGLProgram: Program Info Log:",s):""!==o&&""!==l||(u=!1);u&&(t.diagnostics={runnable:c,programLog:s,vertexShader:{log:o,prefix:g},fragmentShader:{log:l,prefix:v}})}r.deleteShader(w),r.deleteShader(S),E=new _m(r,m),T=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=e.getActiveAttrib(t,r),a=i.name;let s=1;i.type===e.FLOAT_MAT2&&(s=2),i.type===e.FLOAT_MAT3&&(s=3),i.type===e.FLOAT_MAT4&&(s=4),n[a]={type:i.type,location:e.getAttribLocation(t,a),locationSize:s}}return n}(r,m)}let E,T;r.attachShader(m,w),r.attachShader(m,S),void 0!==n.index0AttributeName?r.bindAttribLocation(m,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),this.getUniforms=function(){return void 0===E&&M(this),E},this.getAttributes=function(){return void 0===T&&M(this),T};let A=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===A&&(A=r.getProgramParameter(m,37297)),A},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=wm++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=S,this.numMultiviewViews=x,this}let Vm=0;class Hm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return!1===a.has(i)&&(a.add(i),i.usedTimes++),!1===a.has(r)&&(a.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return void 0===n&&(n=new Gm(e),t.set(e,n)),n}}class Gm{constructor(e){this.id=Vm++,this.code=e,this.usedTimes=0}}function jm(e,t,n,i,r,a,s){const o=new rd,l=new Hm,c=new Set,u=[],d=r.logarithmicDepthBuffer,h=r.vertexTextures;let f=r.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(e){return c.add(e),0===e?"uv":`uv${e}`}return{getParameters:function(a,o,u,g,v){const y=g.fog,x=v.geometry,_=a.isMeshStandardMaterial?g.environment:null,b=(a.isMeshStandardMaterial?n:t).get(a.envMap||_),w=b&&b.mapping===sl?b.image.height:null,S=p[a.type];null!==a.precision&&(f=r.getMaxPrecision(a.precision),f!==a.precision&&kc("WebGLProgram.getParameters:",a.precision,"not supported, using",f,"instead."));const M=x.morphAttributes.position||x.morphAttributes.normal||x.morphAttributes.color,E=void 0!==M?M.length:0;let T,A,R,C,P=0;if(void 0!==x.morphAttributes.position&&(P=1),void 0!==x.morphAttributes.normal&&(P=2),void 0!==x.morphAttributes.color&&(P=3),S){const e=Uf[S];T=e.vertexShader,A=e.fragmentShader}else T=a.vertexShader,A=a.fragmentShader,l.update(a),R=l.getVertexShaderID(a),C=l.getFragmentShaderID(a);const L=e.getRenderTarget(),I=e.state.buffers.depth.getReversed(),D=L&&L.isWebGLMultiviewRenderTarget?L.numViews:0,N=!0===v.isInstancedMesh,O=!0===v.isBatchedMesh,k=!!a.map,U=!!a.matcap,F=!!b,z=!!a.aoMap,B=!!a.lightMap,V=!!a.bumpMap,H=!!a.normalMap,G=!!a.displacementMap,j=!!a.emissiveMap,W=!!a.metalnessMap,X=!!a.roughnessMap,q=a.anisotropy>0,$=a.clearcoat>0,Y=a.dispersion>0,K=a.iridescence>0,Z=a.sheen>0,Q=a.transmission>0,J=q&&!!a.anisotropyMap,ee=$&&!!a.clearcoatMap,te=$&&!!a.clearcoatNormalMap,ne=$&&!!a.clearcoatRoughnessMap,ie=K&&!!a.iridescenceMap,re=K&&!!a.iridescenceThicknessMap,ae=Z&&!!a.sheenColorMap,se=Z&&!!a.sheenRoughnessMap,oe=!!a.specularMap,le=!!a.specularColorMap,ce=!!a.specularIntensityMap,ue=Q&&!!a.transmissionMap,de=Q&&!!a.thicknessMap,he=!!a.gradientMap,fe=!!a.alphaMap,pe=a.alphaTest>0,me=!!a.alphaHash,ge=!!a.extensions;let ve=0;a.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(ve=e.toneMapping));const ye={shaderID:S,shaderType:a.type,shaderName:a.name,vertexShader:T,fragmentShader:A,defines:a.defines,customVertexShaderID:R,customFragmentShaderID:C,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:f,batching:O,batchingColor:O&&null!==v._colorsTexture,instancing:N,instancingColor:N&&null!==v.instanceColor,instancingMorph:N&&null!==v.morphTexture,supportsVertexTextures:h,numMultiviewViews:D,outputColorSpace:null===L?e.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:gc,alphaToCoverage:!!a.alphaToCoverage,map:k,matcap:U,envMap:F,envMapMode:F&&b.mapping,envMapCubeUVHeight:w,aoMap:z,lightMap:B,bumpMap:V,normalMap:H,displacementMap:h&&G,emissiveMap:j,normalMapObjectSpace:H&&1===a.normalMapType,normalMapTangentSpace:H&&0===a.normalMapType,metalnessMap:W,roughnessMap:X,anisotropy:q,anisotropyMap:J,clearcoat:$,clearcoatMap:ee,clearcoatNormalMap:te,clearcoatRoughnessMap:ne,dispersion:Y,iridescence:K,iridescenceMap:ie,iridescenceThicknessMap:re,sheen:Z,sheenColorMap:ae,sheenRoughnessMap:se,specularMap:oe,specularColorMap:le,specularIntensityMap:ce,transmission:Q,transmissionMap:ue,thicknessMap:de,gradientMap:he,opaque:!1===a.transparent&&1===a.blending&&!1===a.alphaToCoverage,alphaMap:fe,alphaTest:pe,alphaHash:me,combine:a.combine,mapUv:k&&m(a.map.channel),aoMapUv:z&&m(a.aoMap.channel),lightMapUv:B&&m(a.lightMap.channel),bumpMapUv:V&&m(a.bumpMap.channel),normalMapUv:H&&m(a.normalMap.channel),displacementMapUv:G&&m(a.displacementMap.channel),emissiveMapUv:j&&m(a.emissiveMap.channel),metalnessMapUv:W&&m(a.metalnessMap.channel),roughnessMapUv:X&&m(a.roughnessMap.channel),anisotropyMapUv:J&&m(a.anisotropyMap.channel),clearcoatMapUv:ee&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:te&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ne&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:ie&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:re&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:se&&m(a.sheenRoughnessMap.channel),specularMapUv:oe&&m(a.specularMap.channel),specularColorMapUv:le&&m(a.specularColorMap.channel),specularIntensityMapUv:ce&&m(a.specularIntensityMap.channel),transmissionMapUv:ue&&m(a.transmissionMap.channel),thicknessMapUv:de&&m(a.thicknessMap.channel),alphaMapUv:fe&&m(a.alphaMap.channel),vertexTangents:!!x.attributes.tangent&&(H||q),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,pointsUvs:!0===v.isPoints&&!!x.attributes.uv&&(k||fe),fog:!!y,useFog:!0===a.fog,fogExp2:!!y&&y.isFogExp2,flatShading:!0===a.flatShading&&!1===a.wireframe,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:d,reversedDepthBuffer:I,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:E,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.length>0,shadowMapType:e.shadowMap.type,toneMapping:ve,decodeVideoTexture:k&&!0===a.map.isVideoTexture&&ru.getTransfer(a.map.colorSpace)===yc,decodeVideoTextureEmissive:j&&!0===a.emissiveMap.isVideoTexture&&ru.getTransfer(a.emissiveMap.colorSpace)===yc,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionClipCullDistance:ge&&!0===a.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&!0===a.extensions.multiDraw||O)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:a.customProgramCacheKey()};return ye.vertexUv1s=c.has(1),ye.vertexUv2s=c.has(2),ye.vertexUv3s=c.has(3),c.clear(),ye},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.supportsVertexTextures&&o.enable(0);t.instancing&&o.enable(1);t.instancingColor&&o.enable(2);t.instancingMorph&&o.enable(3);t.matcap&&o.enable(4);t.envMap&&o.enable(5);t.normalMapObjectSpace&&o.enable(6);t.normalMapTangentSpace&&o.enable(7);t.clearcoat&&o.enable(8);t.iridescence&&o.enable(9);t.alphaTest&&o.enable(10);t.vertexColors&&o.enable(11);t.vertexAlphas&&o.enable(12);t.vertexUv1s&&o.enable(13);t.vertexUv2s&&o.enable(14);t.vertexUv3s&&o.enable(15);t.vertexTangents&&o.enable(16);t.anisotropy&&o.enable(17);t.alphaHash&&o.enable(18);t.batching&&o.enable(19);t.dispersion&&o.enable(20);t.batchingColor&&o.enable(21);t.gradientMap&&o.enable(22);e.push(o.mask),o.disableAll(),t.fog&&o.enable(0);t.useFog&&o.enable(1);t.flatShading&&o.enable(2);t.logarithmicDepthBuffer&&o.enable(3);t.reversedDepthBuffer&&o.enable(4);t.skinning&&o.enable(5);t.morphTargets&&o.enable(6);t.morphNormals&&o.enable(7);t.morphColors&&o.enable(8);t.premultipliedAlpha&&o.enable(9);t.shadowMapEnabled&&o.enable(10);t.doubleSided&&o.enable(11);t.flipSided&&o.enable(12);t.useDepthPacking&&o.enable(13);t.dithering&&o.enable(14);t.transmission&&o.enable(15);t.sheen&&o.enable(16);t.opaque&&o.enable(17);t.pointsUvs&&o.enable(18);t.decodeVideoTexture&&o.enable(19);t.decodeVideoTextureEmissive&&o.enable(20);t.alphaToCoverage&&o.enable(21);t.numMultiviewViews&&o.enable(22);e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=p[e.type];let n;if(t){const e=Uf[t];n=wh.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=u.length;e<t;e++){const t=u[e];if(t.cacheKey===n){i=t,++i.usedTimes;break}}return void 0===i&&(i=new Bm(e,n,t,a),u.push(i)),i},releaseProgram:function(e){if(0===--e.usedTimes){const t=u.indexOf(e);u[t]=u[u.length-1],u.pop(),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:u,dispose:function(){l.dispose()}}}function Wm(){let e=new WeakMap;return{has:function(t){return e.has(t)},get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function Xm(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function qm(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function $m(){const e=[];let t=0;const n=[],i=[],r=[];function a(n,i,r,a,s,o){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:a,renderOrder:n.renderOrder,z:s,group:o},e[t]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=o),t++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){t=0,n.length=0,i.length=0,r.length=0},push:function(e,t,s,o,l,c){const u=a(e,t,s,o,l,c);s.transmission>0?i.push(u):!0===s.transparent?r.push(u):n.push(u)},unshift:function(e,t,s,o,l,c){const u=a(e,t,s,o,l,c);s.transmission>0?i.unshift(u):!0===s.transparent?r.unshift(u):n.unshift(u)},finish:function(){for(let n=t,i=e.length;n<i;n++){const t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){n.length>1&&n.sort(e||Xm),i.length>1&&i.sort(t||qm),r.length>1&&r.sort(t||qm)}}}function Ym(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new $m,e.set(t,[r])):n>=i.length?(r=new $m,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function Km(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Kc,color:new zd};break;case"SpotLight":n={position:new Kc,direction:new Kc,color:new zd,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Kc,color:new zd,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Kc,skyColor:new zd,groundColor:new zd};break;case"RectAreaLight":n={color:new zd,position:new Kc,halfWidth:new Kc,halfHeight:new Kc}}return e[t.id]=n,n}}}let Zm=0;function Qm(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Jm(e){const t=new Km,n=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $c};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $c,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),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 e=0;e<9;e++)i.probe.push(new Kc);const r=new Kc,a=new qu,s=new qu;return{setup:function(r){let a=0,s=0,o=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let l=0,c=0,u=0,d=0,h=0,f=0,p=0,m=0,g=0,v=0,y=0;r.sort(Qm);for(let e=0,x=r.length;e<x;e++){const x=r[e],_=x.color,b=x.intensity,w=x.distance,S=x.shadow&&x.shadow.map?x.shadow.map.texture:null;if(x.isAmbientLight)a+=_.r*b,s+=_.g*b,o+=_.b*b;else if(x.isLightProbe){for(let e=0;e<9;e++)i.probe[e].addScaledVector(x.sh.coefficients[e],b);y++}else if(x.isDirectionalLight){const e=t.get(x);if(e.color.copy(x.color).multiplyScalar(x.intensity),x.castShadow){const e=x.shadow,t=n.get(x);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,i.directionalShadow[l]=t,i.directionalShadowMap[l]=S,i.directionalShadowMatrix[l]=x.shadow.matrix,f++}i.directional[l]=e,l++}else if(x.isSpotLight){const e=t.get(x);e.position.setFromMatrixPosition(x.matrixWorld),e.color.copy(_).multiplyScalar(b),e.distance=w,e.coneCos=Math.cos(x.angle),e.penumbraCos=Math.cos(x.angle*(1-x.penumbra)),e.decay=x.decay,i.spot[u]=e;const r=x.shadow;if(x.map&&(i.spotLightMap[g]=x.map,g++,r.updateMatrices(x),x.castShadow&&v++),i.spotLightMatrix[u]=r.matrix,x.castShadow){const e=n.get(x);e.shadowIntensity=r.intensity,e.shadowBias=r.bias,e.shadowNormalBias=r.normalBias,e.shadowRadius=r.radius,e.shadowMapSize=r.mapSize,i.spotShadow[u]=e,i.spotShadowMap[u]=S,m++}u++}else if(x.isRectAreaLight){const e=t.get(x);e.color.copy(_).multiplyScalar(b),e.halfWidth.set(.5*x.width,0,0),e.halfHeight.set(0,.5*x.height,0),i.rectArea[d]=e,d++}else if(x.isPointLight){const e=t.get(x);if(e.color.copy(x.color).multiplyScalar(x.intensity),e.distance=x.distance,e.decay=x.decay,x.castShadow){const e=x.shadow,t=n.get(x);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,i.pointShadow[c]=t,i.pointShadowMap[c]=S,i.pointShadowMatrix[c]=x.shadow.matrix,p++}i.point[c]=e,c++}else if(x.isHemisphereLight){const e=t.get(x);e.skyColor.copy(x.color).multiplyScalar(b),e.groundColor.copy(x.groundColor).multiplyScalar(b),i.hemi[h]=e,h++}}d>0&&(!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=kf.LTC_FLOAT_1,i.rectAreaLTC2=kf.LTC_FLOAT_2):(i.rectAreaLTC1=kf.LTC_HALF_1,i.rectAreaLTC2=kf.LTC_HALF_2)),i.ambient[0]=a,i.ambient[1]=s,i.ambient[2]=o;const x=i.hash;x.directionalLength===l&&x.pointLength===c&&x.spotLength===u&&x.rectAreaLength===d&&x.hemiLength===h&&x.numDirectionalShadows===f&&x.numPointShadows===p&&x.numSpotShadows===m&&x.numSpotMaps===g&&x.numLightProbes===y||(i.directional.length=l,i.spot.length=u,i.rectArea.length=d,i.point.length=c,i.hemi.length=h,i.directionalShadow.length=f,i.directionalShadowMap.length=f,i.pointShadow.length=p,i.pointShadowMap.length=p,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=f,i.pointShadowMatrix.length=p,i.spotLightMatrix.length=m+g-v,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=v,i.numLightProbes=y,x.directionalLength=l,x.pointLength=c,x.spotLength=u,x.rectAreaLength=d,x.hemiLength=h,x.numDirectionalShadows=f,x.numPointShadows=p,x.numSpotShadows=m,x.numSpotMaps=g,x.numLightProbes=y,i.version=Zm++)},setupView:function(e,t){let n=0,o=0,l=0,c=0,u=0;const d=t.matrixWorldInverse;for(let t=0,h=e.length;t<h;t++){const h=e[t];if(h.isDirectionalLight){const e=i.directional[n];e.direction.setFromMatrixPosition(h.matrixWorld),r.setFromMatrixPosition(h.target.matrixWorld),e.direction.sub(r),e.direction.transformDirection(d),n++}else if(h.isSpotLight){const e=i.spot[l];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(d),e.direction.setFromMatrixPosition(h.matrixWorld),r.setFromMatrixPosition(h.target.matrixWorld),e.direction.sub(r),e.direction.transformDirection(d),l++}else if(h.isRectAreaLight){const e=i.rectArea[c];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(d),s.identity(),a.copy(h.matrixWorld),a.premultiply(d),s.extractRotation(a),e.halfWidth.set(.5*h.width,0,0),e.halfHeight.set(0,.5*h.height,0),e.halfWidth.applyMatrix4(s),e.halfHeight.applyMatrix4(s),c++}else if(h.isPointLight){const e=i.point[o];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(d),o++}else if(h.isHemisphereLight){const e=i.hemi[u];e.direction.setFromMatrixPosition(h.matrixWorld),e.direction.transformDirection(d),u++}}},state:i}}function eg(e){const t=new Jm(e),n=[],i=[];const r={lightsArray:n,shadowsArray:i,camera:null,lights:t,transmissionRenderTarget:{}};return{init:function(e){r.camera=e,n.length=0,i.length=0},state:r,setupLights:function(){t.setup(n)},setupLightsView:function(e){t.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){i.push(e)}}}function tg(e){let t=new WeakMap;return{get:function(n,i=0){const r=t.get(n);let a;return void 0===r?(a=new eg(e),t.set(n,[a])):i>=r.length?(a=new eg(e),r.push(a)):a=r[i],a},dispose:function(){t=new WeakMap}}}function ng(e,t,n){let i=new Wh;const r=new $c,a=new $c,s=new mu,o=new mf({depthPacking:3201}),l=new gf,c={},u=n.maxTextureSize,d={[Co]:1,[Po]:0,[Lo]:2},h=new Sh({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $c},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const p=new rh;p.setAttribute("position",new qd(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new gh(p,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function y(n,i){const a=t.update(m);h.defines.VSM_SAMPLES!==n.blurSamples&&(h.defines.VSM_SAMPLES=n.blurSamples,f.defines.VSM_SAMPLES=n.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new vu(r.x,r.y)),h.uniforms.shadow_pass.value=n.map.texture,h.uniforms.resolution.value=n.mapSize,h.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,a,h,m,null),f.uniforms.shadow_pass.value=n.mapPass.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,a,f,m,null)}function x(t,n,i,r){let a=null;const s=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){const e=a.uuid,t=n.uuid;let i=c[e];void 0===i&&(i={},c[e]=i);let r=i[t];void 0===r&&(r=a.clone(),i[t]=r,n.addEventListener("dispose",b)),a=r}if(a.visible=n.visible,a.wireframe=n.wireframe,a.side=3===r?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:d[n.side],a.alphaMap=n.alphaMap,a.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial){e.properties.get(a).light=i}return a}function _(n,r,a,s,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===o)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);const i=t.update(n),l=n.material;if(Array.isArray(l)){const t=i.groups;for(let c=0,u=t.length;c<u;c++){const u=t[c],d=l[u.materialIndex];if(d&&d.visible){const t=x(n,d,s,o);n.onBeforeShadow(e,n,r,a,i,t,u),e.renderBufferDirect(a,null,i,t,n,u),n.onAfterShadow(e,n,r,a,i,t,u)}}}else if(l.visible){const t=x(n,l,s,o);n.onBeforeShadow(e,n,r,a,i,t,null),e.renderBufferDirect(a,null,i,t,n,null),n.onAfterShadow(e,n,r,a,i,t,null)}}const l=n.children;for(let e=0,t=l.length;e<t;e++)_(l[e],r,a,s,o)}function b(e){e.target.removeEventListener("dispose",b);for(const t in c){const n=c[t],i=e.target.uuid;if(i in n){n[i].dispose(),delete n[i]}}}this.render=function(t,n,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===t.length)return;const l=e.getRenderTarget(),c=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),h=e.state;h.setBlending(0),!0===h.buffers.depth.getReversed()?h.buffers.color.setClear(0,0,0,0):h.buffers.color.setClear(1,1,1,1),h.buffers.depth.setTest(!0),h.setScissorTest(!1);const f=3!==v&&3===this.type,p=3===v&&3!==this.type;for(let l=0,c=t.length;l<c;l++){const c=t[l],d=c.shadow;if(void 0===d){kc("WebGLShadowMap:",c,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;r.copy(d.mapSize);const m=d.getFrameExtents();if(r.multiply(m),a.copy(d.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(a.x=Math.floor(u/m.x),r.x=a.x*m.x,d.mapSize.x=a.x),r.y>u&&(a.y=Math.floor(u/m.y),r.y=a.y*m.y,d.mapSize.y=a.y)),null===d.map||!0===f||!0===p){const e=3!==this.type?{minFilter:ul,magFilter:ul}:{};null!==d.map&&d.map.dispose(),d.map=new vu(r.x,r.y,e),d.map.texture.name=c.name+".shadowMap",d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();const g=d.getViewportCount();for(let e=0;e<g;e++){const t=d.getViewport(e);s.set(a.x*t.x,a.y*t.y,a.x*t.z,a.y*t.w),h.viewport(s),d.updateMatrices(c,e),i=d.getFrustum(),_(n,o,d.camera,c,this.type)}!0!==d.isPointLightShadow&&3===this.type&&y(d,o),d.needsUpdate=!1}v=this.type,g.needsUpdate=!1,e.setRenderTarget(l,c,d)}}const ig={[Ko]:1,[Qo]:6,[el]:7,[Jo]:5,[Zo]:0,[nl]:2,[il]:4,[tl]:3};function rg(e,t){const n=new function(){let t=!1;const n=new mu;let i=null;const r=new mu(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,a,s,o){!0===o&&(t*=s,i*=s,a*=s),n.set(t,i,a,s),!1===r.equals(n)&&(e.clearColor(t,i,a,s),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}},i=new function(){let n=!1,i=!1,r=null,a=null,s=null;return{setReversed:function(e){if(i!==e){const n=t.get("EXT_clip_control");e?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),i=e;const r=s;s=null,this.setClear(r)}},getReversed:function(){return i},setTest:function(t){t?B(e.DEPTH_TEST):V(e.DEPTH_TEST)},setMask:function(t){r===t||n||(e.depthMask(t),r=t)},setFunc:function(t){if(i&&(t=ig[t]),a!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:default:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL)}a=t}},setLocked:function(e){n=e},setClear:function(t){s!==t&&(i&&(t=1-t),e.clearDepth(t),s=t)},reset:function(){n=!1,r=null,a=null,s=null,i=!1}}},r=new function(){let t=!1,n=null,i=null,r=null,a=null,s=null,o=null,l=null,c=null;return{setTest:function(n){t||(n?B(e.STENCIL_TEST):V(e.STENCIL_TEST))},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,s){i===t&&r===n&&a===s||(e.stencilFunc(t,n,s),i=t,r=n,a=s)},setOp:function(t,n,i){s===t&&o===n&&l===i||(e.stencilOp(t,n,i),s=t,o=n,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,i=null,r=null,a=null,s=null,o=null,l=null,c=null}}},a=new WeakMap,s=new WeakMap;let o={},l={},c=new WeakMap,u=[],d=null,h=!1,f=null,p=null,m=null,g=null,v=null,y=null,x=null,_=new zd(0,0,0),b=0,w=!1,S=null,M=null,E=null,T=null,A=null;const R=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let C=!1,P=0;const L=e.getParameter(e.VERSION);-1!==L.indexOf("WebGL")?(P=parseFloat(/^WebGL (\d)/.exec(L)[1]),C=P>=1):-1!==L.indexOf("OpenGL ES")&&(P=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),C=P>=2);let I=null,D={};const N=e.getParameter(e.SCISSOR_BOX),O=e.getParameter(e.VIEWPORT),k=(new mu).fromArray(N),U=(new mu).fromArray(O);function F(t,n,i,r){const a=new Uint8Array(4),s=e.createTexture();e.bindTexture(t,s),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let s=0;s<i;s++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,r,0,e.RGBA,e.UNSIGNED_BYTE,a):e.texImage2D(n+s,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,a);return s}const z={};function B(t){!0!==o[t]&&(e.enable(t),o[t]=!0)}function V(t){!1!==o[t]&&(e.disable(t),o[t]=!1)}z[e.TEXTURE_2D]=F(e.TEXTURE_2D,e.TEXTURE_2D,1),z[e.TEXTURE_CUBE_MAP]=F(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),z[e.TEXTURE_2D_ARRAY]=F(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),z[e.TEXTURE_3D]=F(e.TEXTURE_3D,e.TEXTURE_3D,1,1),n.setClear(0,0,0,1),i.setClear(1),r.setClear(0),B(e.DEPTH_TEST),i.setFunc(3),W(!1),X(1),B(e.CULL_FACE),j(0);const H={[Io]:e.FUNC_ADD,[Do]:e.FUNC_SUBTRACT,[No]:e.FUNC_REVERSE_SUBTRACT};H[103]=e.MIN,H[104]=e.MAX;const G={[Oo]:e.ZERO,[ko]:e.ONE,[Uo]:e.SRC_COLOR,[zo]:e.SRC_ALPHA,[Wo]:e.SRC_ALPHA_SATURATE,[Go]:e.DST_COLOR,[Vo]:e.DST_ALPHA,[Fo]:e.ONE_MINUS_SRC_COLOR,[Bo]:e.ONE_MINUS_SRC_ALPHA,[jo]:e.ONE_MINUS_DST_COLOR,[Ho]:e.ONE_MINUS_DST_ALPHA,[Xo]:e.CONSTANT_COLOR,[qo]:e.ONE_MINUS_CONSTANT_COLOR,[$o]:e.CONSTANT_ALPHA,[Yo]:e.ONE_MINUS_CONSTANT_ALPHA};function j(t,n,i,r,a,s,o,l,c,u){if(0!==t){if(!1===h&&(B(e.BLEND),h=!0),5===t)a=a||n,s=s||i,o=o||r,n===p&&a===v||(e.blendEquationSeparate(H[n],H[a]),p=n,v=a),i===m&&r===g&&s===y&&o===x||(e.blendFuncSeparate(G[i],G[r],G[s],G[o]),m=i,g=r,y=s,x=o),!1!==l.equals(_)&&c===b||(e.blendColor(l.r,l.g,l.b,c),_.copy(l),b=c),f=t,w=!1;else if(t!==f||u!==w){if(p===Io&&v===Io||(e.blendEquation(e.FUNC_ADD),p=Io,v=Io),u)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Uc("WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case 3:Uc("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:Uc("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Uc("WebGLState: Invalid blending: ",t)}m=null,g=null,y=null,x=null,_.set(0,0,0),b=0,f=t,w=u}}else!0===h&&(V(e.BLEND),h=!1)}function W(t){S!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),S=t)}function X(t){0!==t?(B(e.CULL_FACE),t!==M&&(1===t?e.cullFace(e.BACK):2===t?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):V(e.CULL_FACE),M=t}function q(t,n,i){t?(B(e.POLYGON_OFFSET_FILL),T===n&&A===i||(e.polygonOffset(n,i),T=n,A=i)):V(e.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:i,stencil:r},enable:B,disable:V,bindFramebuffer:function(t,n){return l[t]!==n&&(e.bindFramebuffer(t,n),l[t]=n,t===e.DRAW_FRAMEBUFFER&&(l[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(l[e.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(t,n){let i=u,r=!1;if(t){i=c.get(n),void 0===i&&(i=[],c.set(n,i));const a=t.textures;if(i.length!==a.length||i[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=a.length;t<n;t++)i[t]=e.COLOR_ATTACHMENT0+t;i.length=a.length,r=!0}}else i[0]!==e.BACK&&(i[0]=e.BACK,r=!0);r&&e.drawBuffers(i)},useProgram:function(t){return d!==t&&(e.useProgram(t),d=t,!0)},setBlending:j,setMaterial:function(t,a){2===t.side?V(e.CULL_FACE):B(e.CULL_FACE);let s=1===t.side;a&&(s=!s),W(s),1===t.blending&&!1===t.transparent?j(0):j(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),i.setFunc(t.depthFunc),i.setTest(t.depthTest),i.setMask(t.depthWrite),n.setMask(t.colorWrite);const o=t.stencilWrite;r.setTest(o),o&&(r.setMask(t.stencilWriteMask),r.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),r.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),q(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?B(e.SAMPLE_ALPHA_TO_COVERAGE):V(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:W,setCullFace:X,setLineWidth:function(t){t!==E&&(C&&e.lineWidth(t),E=t)},setPolygonOffset:q,setScissorTest:function(t){t?B(e.SCISSOR_TEST):V(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+R-1),I!==t&&(e.activeTexture(t),I=t)},bindTexture:function(t,n,i){void 0===i&&(i=null===I?e.TEXTURE0+R-1:I);let r=D[i];void 0===r&&(r={type:void 0,texture:void 0},D[i]=r),r.type===t&&r.texture===n||(I!==i&&(e.activeTexture(i),I=i),e.bindTexture(t,n||z[t]),r.type=t,r.texture=n)},unbindTexture:function(){const t=D[I];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D(...arguments)}catch(e){e("WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D(...arguments)}catch(e){e("WebGLState:",e)}},texImage2D:function(){try{e.texImage2D(...arguments)}catch(e){e("WebGLState:",e)}},texImage3D:function(){try{e.texImage3D(...arguments)}catch(e){e("WebGLState:",e)}},updateUBOMapping:function(t,n){let i=s.get(n);void 0===i&&(i=new WeakMap,s.set(n,i));let r=i.get(t);void 0===r&&(r=e.getUniformBlockIndex(n,t.name),i.set(t,r))},uniformBlockBinding:function(t,n){const i=s.get(n).get(t);a.get(n)!==i&&(e.uniformBlockBinding(n,i,t.__bindingPointIndex),a.set(n,i))},texStorage2D:function(){try{e.texStorage2D(...arguments)}catch(e){e("WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D(...arguments)}catch(e){e("WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D(...arguments)}catch(e){e("WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D(...arguments)}catch(e){e("WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D(...arguments)}catch(e){e("WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D(...arguments)}catch(e){e("WebGLState:",e)}},scissor:function(t){!1===k.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),k.copy(t))},viewport:function(t){!1===U.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),U.copy(t))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),i.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),o={},I=null,D={},l={},c=new WeakMap,u=[],d=null,h=!1,f=null,p=null,m=null,g=null,v=null,y=null,x=null,_=new zd(0,0,0),b=0,w=!1,S=null,M=null,E=null,T=null,A=null,k.set(0,0,e.canvas.width,e.canvas.height),U.set(0,0,e.canvas.width,e.canvas.height),n.reset(),i.reset(),r.reset()}}}function ag(e,t,n,i,r,a,s){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=t.has("OCULUS_multiview")?t.get("OCULUS_multiview"):null,u=new $c,d=new WeakMap;let h;const f=new WeakMap;let p=[],m=!1,g=!1;try{g="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function v(e,t){return g?new OffscreenCanvas(e,t):Ic("canvas")}function y(e,t,n){let i=1;const r=q(e);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame){const n=Math.floor(i*r.width),a=Math.floor(i*r.height);void 0===h&&(h=v(n,a));const s=t?v(n,a):h;s.width=n,s.height=a;return s.getContext("2d").drawImage(e,0,0,n,a),kc("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+a+")."),s}return"data"in e&&kc("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),e}return e}function x(e){return e.generateMipmaps}function _(t){e.generateMipmap(t)}function b(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function w(n,i,r,a,s=!1){if(null!==n){if(void 0!==e[n])return e[n];kc("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===e.RED&&(r===e.FLOAT&&(o=e.R32F),r===e.HALF_FLOAT&&(o=e.R16F),r===e.UNSIGNED_BYTE&&(o=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.R8UI),r===e.UNSIGNED_SHORT&&(o=e.R16UI),r===e.UNSIGNED_INT&&(o=e.R32UI),r===e.BYTE&&(o=e.R8I),r===e.SHORT&&(o=e.R16I),r===e.INT&&(o=e.R32I)),i===e.RG&&(r===e.FLOAT&&(o=e.RG32F),r===e.HALF_FLOAT&&(o=e.RG16F),r===e.UNSIGNED_BYTE&&(o=e.RG8)),i===e.RG_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RG8UI),r===e.UNSIGNED_SHORT&&(o=e.RG16UI),r===e.UNSIGNED_INT&&(o=e.RG32UI),r===e.BYTE&&(o=e.RG8I),r===e.SHORT&&(o=e.RG16I),r===e.INT&&(o=e.RG32I)),i===e.RGB_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGB8UI),r===e.UNSIGNED_SHORT&&(o=e.RGB16UI),r===e.UNSIGNED_INT&&(o=e.RGB32UI),r===e.BYTE&&(o=e.RGB8I),r===e.SHORT&&(o=e.RGB16I),r===e.INT&&(o=e.RGB32I)),i===e.RGBA_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGBA8UI),r===e.UNSIGNED_SHORT&&(o=e.RGBA16UI),r===e.UNSIGNED_INT&&(o=e.RGBA32UI),r===e.BYTE&&(o=e.RGBA8I),r===e.SHORT&&(o=e.RGBA16I),r===e.INT&&(o=e.RGBA32I)),i===e.RGB&&(r===e.UNSIGNED_INT_5_9_9_9_REV&&(o=e.RGB9_E5),r===e.UNSIGNED_INT_10F_11F_11F_REV&&(o=e.R11F_G11F_B10F)),i===e.RGBA){const t=s?vc:ru.getTransfer(a);r===e.FLOAT&&(o=e.RGBA32F),r===e.HALF_FLOAT&&(o=e.RGBA16F),r===e.UNSIGNED_BYTE&&(o=t===yc?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(o=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(o=e.RGB5_A1)}return o!==e.R16F&&o!==e.R32F&&o!==e.RG16F&&o!==e.RG32F&&o!==e.RGBA16F&&o!==e.RGBA32F||t.get("EXT_color_buffer_float"),o}function S(t,n){let i;return t?null===n||n===bl||n===Tl?i=e.DEPTH24_STENCIL8:n===wl?i=e.DEPTH32F_STENCIL8:n===xl&&(i=e.DEPTH24_STENCIL8,kc("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===bl||n===Tl?i=e.DEPTH_COMPONENT24:n===wl?i=e.DEPTH_COMPONENT32F:n===xl&&(i=e.DEPTH_COMPONENT16),i}function M(e,t){return!0===x(e)||e.isFramebufferTexture&&e.minFilter!==ul&&e.minFilter!==fl?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function E(e){const t=e.target;t.removeEventListener("dispose",E),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=f.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&A(e),0===Object.keys(r).length&&f.delete(n)}i.remove(e)}(t),t.isVideoTexture&&d.delete(t)}function T(t){const n=t.target;n.removeEventListener("dispose",T),function(t){const n=i.get(t);t.depthTexture&&(t.depthTexture.dispose(),i.remove(t.depthTexture));if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let i=0;i<n.__webglFramebuffer[t].length;i++)e.deleteFramebuffer(n.__webglFramebuffer[t][i]);else e.deleteFramebuffer(n.__webglFramebuffer[t]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}const r=t.textures;for(let t=0,n=r.length;t<n;t++){const n=i.get(r[t]);n.__webglTexture&&(e.deleteTexture(n.__webglTexture),s.memory.textures--),i.remove(r[t])}i.remove(t)}(n)}function A(t){const n=i.get(t);e.deleteTexture(n.__webglTexture);const r=t.source;delete f.get(r)[n.__cacheKey],s.memory.textures--}let R=0;function C(t,r){const a=i.get(t);if(t.isVideoTexture&&function(e){const t=s.render.frame;d.get(e)!==t&&(d.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&!0!==t.isExternalTexture&&t.version>0&&a.__version!==t.version){const e=t.image;if(null===e)kc("WebGLRenderer: Texture marked for update but no image data found.");else if(!1===e.complete)kc("WebGLRenderer: Texture marked for update but image is incomplete");else if(U(a,t,r))return}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+r)}function P(t,r){const a=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?U(a,t,r):(t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r))}const L={[ol]:e.REPEAT,[ll]:e.CLAMP_TO_EDGE,[cl]:e.MIRRORED_REPEAT},I={[ul]:e.NEAREST,[dl]:e.NEAREST_MIPMAP_NEAREST,[hl]:e.NEAREST_MIPMAP_LINEAR,[fl]:e.LINEAR,[pl]:e.LINEAR_MIPMAP_NEAREST,[ml]:e.LINEAR_MIPMAP_LINEAR},D={[_c]:e.NEVER,[Ac]:e.ALWAYS,[bc]:e.LESS,[Sc]:e.LEQUAL,[wc]:e.EQUAL,[Tc]:e.GEQUAL,[Mc]:e.GREATER,[Ec]:e.NOTEQUAL};function N(n,a){if(a.type!==wl||!1!==t.has("OES_texture_float_linear")||a.magFilter!==fl&&a.magFilter!==pl&&a.magFilter!==hl&&a.magFilter!==ml&&a.minFilter!==fl&&a.minFilter!==pl&&a.minFilter!==hl&&a.minFilter!==ml||kc("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(n,e.TEXTURE_WRAP_S,L[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,L[a.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,L[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,I[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,I[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,D[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){if(a.magFilter===ul)return;if(a.minFilter!==hl&&a.minFilter!==ml)return;if(a.type===wl&&!1===t.has("OES_texture_float_linear"))return;if(a.anisotropy>1||i.get(a).__currentAnisotropy){const s=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy}}}function O(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",E));const r=n.source;let a=f.get(r);void 0===a&&(a={},f.set(r,a));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===a[o]&&(a[o]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,i=!0),a[o].usedTimes++;const r=a[t.__cacheKey];void 0!==r&&(a[t.__cacheKey].usedTimes--,0===r.usedTimes&&A(n)),t.__cacheKey=o,t.__webglTexture=a[o].texture}return i}function k(e,t,n){return Math.floor(Math.floor(e/n)/t)}function U(t,s,o){if(m)return s.isPendingDeferredUpload||(s.isPendingDeferredUpload=!0,p.push({textureProperties:t,texture:s,slot:o})),!1;let l=e.TEXTURE_2D;(s.isDataArrayTexture||s.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),s.isData3DTexture&&(l=e.TEXTURE_3D);const c=O(t,s),u=s.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+o);const d=i.get(u);if(u.version!==d.__version||!0===c){n.activeTexture(e.TEXTURE0+o);const t=ru.getPrimaries(ru.workingColorSpace),i=s.colorSpace===pc?null:ru.getPrimaries(s.colorSpace),h=s.colorSpace===pc||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,h);let f=y(s.image,!1,r.maxTextureSize);f=X(s,f);const p=a.convert(s.format,s.colorSpace),m=a.convert(s.type);let g,v=w(s.internalFormat,p,m,s.colorSpace,s.isVideoTexture);N(l,s);const b=s.mipmaps,E=!0!==s.isVideoTexture,T=void 0===d.__version||!0===c,A=u.dataReady,R=M(s,f);if(s.isDepthTexture)v=S(s.format===Ll,s.type),T&&(E?n.texStorage2D(e.TEXTURE_2D,1,v,f.width,f.height):n.texImage2D(e.TEXTURE_2D,0,v,f.width,f.height,0,p,m,null));else if(s.isDataTexture)if(b.length>0){E&&T&&n.texStorage2D(e.TEXTURE_2D,R,v,b[0].width,b[0].height);for(let t=0,i=b.length;t<i;t++)g=b[t],E?A&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,p,m,g.data):n.texImage2D(e.TEXTURE_2D,t,v,g.width,g.height,0,p,m,g.data);s.generateMipmaps=!1}else E?(T&&n.texStorage2D(e.TEXTURE_2D,R,v,f.width,f.height),A&&function(t,i,r,a){const s=t.updateRanges;if(0===s.length)n.texSubImage2D(e.TEXTURE_2D,0,0,0,i.width,i.height,r,a,i.data);else{s.sort((e,t)=>e.start-t.start);let o=0;for(let e=1;e<s.length;e++){const t=s[o],n=s[e],r=t.start+t.count,a=k(n.start,i.width,4),l=k(t.start,i.width,4);n.start<=r+1&&a===l&&k(n.start+n.count-1,i.width,4)===a?t.count=Math.max(t.count,n.start+n.count-t.start):(++o,s[o]=n)}s.length=o+1;const l=e.getParameter(e.UNPACK_ROW_LENGTH),c=e.getParameter(e.UNPACK_SKIP_PIXELS),u=e.getParameter(e.UNPACK_SKIP_ROWS);e.pixelStorei(e.UNPACK_ROW_LENGTH,i.width);for(let t=0,o=s.length;t<o;t++){const o=s[t],l=Math.floor(o.start/4),c=Math.ceil(o.count/4),u=l%i.width,d=Math.floor(l/i.width),h=c,f=1;e.pixelStorei(e.UNPACK_SKIP_PIXELS,u),e.pixelStorei(e.UNPACK_SKIP_ROWS,d),n.texSubImage2D(e.TEXTURE_2D,0,u,d,h,f,r,a,i.data)}t.clearUpdateRanges(),e.pixelStorei(e.UNPACK_ROW_LENGTH,l),e.pixelStorei(e.UNPACK_SKIP_PIXELS,c),e.pixelStorei(e.UNPACK_SKIP_ROWS,u)}}(s,f,p,m)):n.texImage2D(e.TEXTURE_2D,0,v,f.width,f.height,0,p,m,f.data);else if(s.isCompressedTexture)if(s.isCompressedArrayTexture){E&&T&&n.texStorage3D(e.TEXTURE_2D_ARRAY,R,v,b[0].width,b[0].height,f.depth);for(let t=0,i=b.length;t<i;t++)if(g=b[t],s.format!==Cl)if(null!==p)if(E){if(A)if(s.layerUpdates.size>0){const i=If(g.width,g.height,s.format,s.type);for(const r of s.layerUpdates){const a=g.data.subarray(r*i/g.data.BYTES_PER_ELEMENT,(r+1)*i/g.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,r,g.width,g.height,1,p,a)}s.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,g.width,g.height,f.depth,p,g.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,v,g.width,g.height,f.depth,0,g.data,0,0);else kc("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else E?A&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,g.width,g.height,f.depth,p,m,g.data):n.texImage3D(e.TEXTURE_2D_ARRAY,t,v,g.width,g.height,f.depth,0,p,m,g.data)}else{E&&T&&n.texStorage2D(e.TEXTURE_2D,R,v,b[0].width,b[0].height);for(let t=0,i=b.length;t<i;t++)g=b[t],s.format!==Cl?null!==p?E?A&&n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,p,g.data):n.compressedTexImage2D(e.TEXTURE_2D,t,v,g.width,g.height,0,g.data):kc("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):E?A&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,p,m,g.data):n.texImage2D(e.TEXTURE_2D,t,v,g.width,g.height,0,p,m,g.data)}else if(s.isDataArrayTexture)if(E){if(T&&n.texStorage3D(e.TEXTURE_2D_ARRAY,R,v,f.width,f.height,f.depth),A)if(s.layerUpdates.size>0){const t=If(f.width,f.height,s.format,s.type);for(const i of s.layerUpdates){const r=f.data.subarray(i*t/f.data.BYTES_PER_ELEMENT,(i+1)*t/f.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,i,f.width,f.height,1,p,m,r)}s.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,f.width,f.height,f.depth,p,m,f.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,v,f.width,f.height,f.depth,0,p,m,f.data);else if(s.isData3DTexture)E?(T&&n.texStorage3D(e.TEXTURE_3D,R,v,f.width,f.height,f.depth),A&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,f.width,f.height,f.depth,p,m,f.data)):n.texImage3D(e.TEXTURE_3D,0,v,f.width,f.height,f.depth,0,p,m,f.data);else if(s.isFramebufferTexture){if(T)if(E)n.texStorage2D(e.TEXTURE_2D,R,v,f.width,f.height);else{let t=f.width,i=f.height;for(let r=0;r<R;r++)n.texImage2D(e.TEXTURE_2D,r,v,t,i,0,p,m,null),t>>=1,i>>=1}}else if(b.length>0){if(E&&T){const t=q(b[0]);n.texStorage2D(e.TEXTURE_2D,R,v,t.width,t.height)}for(let t=0,i=b.length;t<i;t++)g=b[t],E?A&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,p,m,g):n.texImage2D(e.TEXTURE_2D,t,v,p,m,g);s.generateMipmaps=!1}else if(E){if(T){const t=q(f);n.texStorage2D(e.TEXTURE_2D,R,v,t.width,t.height)}A&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,p,m,f)}else n.texImage2D(e.TEXTURE_2D,0,v,p,m,f);x(s)&&_(l),d.__version=u.version,s.onUpdate&&s.onUpdate(s)}return t.__version=s.version,!0}function F(t,r,s,l,u,d){const h=a.convert(s.format,s.colorSpace),f=a.convert(s.type),p=w(s.internalFormat,h,f,s.colorSpace),m=i.get(r),g=i.get(s);if(g.__renderTarget=r,!m.__hasExternalTextures){const t=Math.max(1,r.width>>d),i=Math.max(1,r.height>>d);!0===r.isWebGLMultiviewRenderTarget?n.texStorage3D(e.TEXTURE_2D_ARRAY,0,p,r.width,r.height,r.numViews):u===e.TEXTURE_3D||u===e.TEXTURE_2D_ARRAY?n.texImage3D(u,d,p,t,i,r.depth,0,h,f,null):n.texImage2D(u,d,p,t,i,0,h,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t);const v=W(r);!0===r.isWebGLMultiviewRenderTarget?v?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,g.__webglTexture,0,j(r),0,r.numViews):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,g.__webglTexture,0,0,r.numViews):(u===e.TEXTURE_2D||u>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&u<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&(v?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,l,u,g.__webglTexture,0,j(r)):e.framebufferTexture2D(e.FRAMEBUFFER,l,u,g.__webglTexture,d)),n.bindFramebuffer(e.FRAMEBUFFER,null)}function z(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),!0===n.isWebGLMultiviewRenderTarget){const t=W(n),r=n.numViews,a=n.depthTexture;let s=e.DEPTH_COMPONENT24,o=e.DEPTH_ATTACHMENT;a&&a.isDepthTexture&&(a.type===wl?s=e.DEPTH_COMPONENT32F:a.type===Tl&&(s=e.DEPTH24_STENCIL8,o=e.DEPTH_STENCIL_ATTACHMENT));let l=i.get(n.depthTexture).__webglTexture;void 0===l&&(l=e.createTexture(),e.bindTexture(e.TEXTURE_2D_ARRAY,l),e.texStorage3D(e.TEXTURE_2D_ARRAY,1,s,n.width,n.height,r)),t?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,o,l,0,j(n),0,r):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,o,l,0,0,r)}else if(n.depthBuffer){const i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,s=S(n.stencilBuffer,a),l=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=j(n);W(n)?o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,c,s,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,c,s,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,s,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,l,e.RENDERBUFFER,t)}else{const t=n.textures;for(let i=0;i<t.length;i++){const s=t[i],l=a.convert(s.format,s.colorSpace),c=a.convert(s.type),u=w(s.internalFormat,l,c,s.colorSpace),d=j(n);r&&!1===W(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,d,u,n.width,n.height):W(n)?o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,d,u,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,u,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function B(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(e.FRAMEBUFFER,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const a=i.get(r.depthTexture);a.__renderTarget=r,a.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),1!=r.depthTexture.image.depth?P(r.depthTexture,0):C(r.depthTexture,0);const s=a.__webglTexture,l=j(r);if(!0===r.isWebGLMultiviewRenderTarget){const t=W(r),n=r.numViews;if(r.depthTexture.format===Pl)t?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,s,0,l,0,n):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,s,0,0,n);else{if(r.depthTexture.format!==Ll)throw new Error("Unknown depthTexture format");t?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,s,0,l,0,n):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,s,0,0,n)}}else if(r.depthTexture.format===Pl)W(r)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0,l):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0);else{if(r.depthTexture.format!==Ll)throw new Error("Unknown depthTexture format");W(r)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0,l):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0)}}function V(t){const r=i.get(t),a=!0===t.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==t.depthTexture){const e=t.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),e){const t=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),r.__depthDisposeCallback=t}r.__boundDepthTexture=e}if(t.depthTexture&&!r.__autoAllocateDepthBuffer){if(a)throw new Error("target.depthTexture not supported in Cube render targets");const e=t.texture.mipmaps;e&&e.length>0?B(r.__webglFramebuffer[0],t):B(r.__webglFramebuffer,t)}else if(a){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=e.createRenderbuffer(),z(r.__webglDepthbuffer[i],t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=r.__webglDepthbuffer[i];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else{const i=t.texture.mipmaps;if(i&&i.length>0?n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=e.createRenderbuffer(),z(r.__webglDepthbuffer,t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,i)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}const H=[],G=[];function j(e){return Math.min(r.maxSamples,e.samples)}function W(e){const n=i.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function X(e,t){const n=e.colorSpace,i=e.format,r=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==gc&&n!==pc&&(ru.getTransfer(n)===yc?i===Cl&&r===gl||kc("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Uc("WebGLTextures: Unsupported texture color space:",n)),t}function q(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(u.width=e.naturalWidth||e.width,u.height=e.naturalHeight||e.height):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?(u.width=e.displayWidth,u.height=e.displayHeight):(u.width=e.width,u.height=e.height),u}this.allocateTextureUnit=function(){const e=R;return e>=r.maxTextures&&kc("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures),R+=1,e},this.resetTextureUnits=function(){R=0},this.setTexture2D=C,this.setTexture2DArray=P,this.setTexture3D=function(t,r){const a=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?U(a,t,r):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,s){const o=i.get(t);t.version>0&&o.__version!==t.version?function(t,s,o){if(6!==s.image.length)return;const l=O(t,s),c=s.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+o);const u=i.get(c);if(c.version!==u.__version||!0===l){n.activeTexture(e.TEXTURE0+o);const t=ru.getPrimaries(ru.workingColorSpace),i=s.colorSpace===pc?null:ru.getPrimaries(s.colorSpace),d=s.colorSpace===pc||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const h=s.isCompressedTexture||s.image[0].isCompressedTexture,f=s.image[0]&&s.image[0].isDataTexture,p=[];for(let e=0;e<6;e++)p[e]=h||f?f?s.image[e].image:s.image[e]:y(s.image[e],!0,r.maxCubemapSize),p[e]=X(s,p[e]);const m=p[0],g=a.convert(s.format,s.colorSpace),v=a.convert(s.type),b=w(s.internalFormat,g,v,s.colorSpace),S=!0!==s.isVideoTexture,E=void 0===u.__version||!0===l,T=c.dataReady;let A,R=M(s,m);if(N(e.TEXTURE_CUBE_MAP,s),h){S&&E&&n.texStorage2D(e.TEXTURE_CUBE_MAP,R,b,m.width,m.height);for(let t=0;t<6;t++){A=p[t].mipmaps;for(let i=0;i<A.length;i++){const r=A[i];s.format!==Cl?null!==g?S?T&&n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,r.width,r.height,g,r.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,b,r.width,r.height,0,r.data):kc("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,r.width,r.height,g,v,r.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,b,r.width,r.height,0,g,v,r.data)}}}else{if(A=s.mipmaps,S&&E){A.length>0&&R++;const t=q(p[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,R,b,t.width,t.height)}for(let t=0;t<6;t++)if(f){S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,p[t].width,p[t].height,g,v,p[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,b,p[t].width,p[t].height,0,g,v,p[t].data);for(let i=0;i<A.length;i++){const r=A[i].image[t].image;S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,r.width,r.height,g,v,r.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,b,r.width,r.height,0,g,v,r.data)}}else{S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,g,v,p[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,b,g,v,p[t]);for(let i=0;i<A.length;i++){const r=A[i];S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,g,v,r.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,b,g,v,r.image[t])}}}x(s)&&_(e.TEXTURE_CUBE_MAP),u.__version=c.version,s.onUpdate&&s.onUpdate(s)}t.__version=s.version}(o,t,s):n.bindTexture(e.TEXTURE_CUBE_MAP,o.__webglTexture,e.TEXTURE0+s)},this.rebindTextures=function(t,n,r){const a=i.get(t);void 0!==n&&F(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==r&&V(t)},this.uploadTexture=U,this.setupRenderTarget=function(t){const r=t.texture,o=i.get(t),l=i.get(r);t.addEventListener("dispose",T);const c=t.textures,u=!0===t.isWebGLCubeRenderTarget,d=c.length>1;if(d||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=r.version,s.memory.textures++),u){o.__webglFramebuffer=[];for(let t=0;t<6;t++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[t]=[];for(let n=0;n<r.mipmaps.length;n++)o.__webglFramebuffer[t][n]=e.createFramebuffer()}else o.__webglFramebuffer[t]=e.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let t=0;t<r.mipmaps.length;t++)o.__webglFramebuffer[t]=e.createFramebuffer()}else o.__webglFramebuffer=e.createFramebuffer();if(d)for(let t=0,n=c.length;t<n;t++){const n=i.get(c[t]);void 0===n.__webglTexture&&(n.__webglTexture=e.createTexture(),s.memory.textures++)}if(t.samples>0&&!1===W(t)){o.__webglMultisampledFramebuffer=e.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n<c.length;n++){const i=c[n];o.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,o.__webglColorRenderbuffer[n]);const r=a.convert(i.format,i.colorSpace),s=a.convert(i.type),l=w(i.internalFormat,r,s,i.colorSpace,!0===t.isXRRenderTarget),u=j(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,u,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,o.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(o.__webglDepthRenderbuffer=e.createRenderbuffer(),z(o.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){n.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),N(e.TEXTURE_CUBE_MAP,r);for(let n=0;n<6;n++)if(r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)F(o.__webglFramebuffer[n][i],t,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else F(o.__webglFramebuffer[n],t,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);x(r)&&_(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(d){for(let r=0,a=c.length;r<a;r++){const a=c[r],s=i.get(a);let l=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(l=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(l,s.__webglTexture),N(l,a),F(o.__webglFramebuffer,t,a,e.COLOR_ATTACHMENT0+r,l,0),x(a)&&_(l)}n.unbindTexture()}else{let i=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(i=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),!0===t.isWebGLMultiviewRenderTarget&&(i=e.TEXTURE_2D_ARRAY),n.bindTexture(i,l.__webglTexture),N(i,r),r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)F(o.__webglFramebuffer[n],t,r,e.COLOR_ATTACHMENT0,i,n);else F(o.__webglFramebuffer,t,r,e.COLOR_ATTACHMENT0,i,0);x(r)&&_(i),n.unbindTexture()}(t.depthBuffer||!0===t.isWebGLMultiviewRenderTarget)&&this.setupDepthRenderbuffer(t)},this.updateRenderTargetMipmap=function(e){const t=e.textures;for(let r=0,a=t.length;r<a;r++){const a=t[r];if(x(a)){const t=b(e),r=i.get(a).__webglTexture;n.bindTexture(t,r),_(t),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.samples>0)if(!1===W(t)){const r=t.textures,a=t.width,s=t.height;let o=e.COLOR_BUFFER_BIT;const c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=i.get(t),d=r.length>1;if(d)for(let t=0;t<r.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer);const h=t.texture.mipmaps;h&&h.length>0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n<r.length;n++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(o|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(o|=e.STENCIL_BUFFER_BIT)),d){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,u.__webglColorRenderbuffer[n]);const t=i.get(r[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,a,s,0,0,a,s,o,e.NEAREST),!0===l&&(H.length=0,G.length=0,H.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&!1===t.resolveDepthBuffer&&(H.push(c),G.push(c),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,G)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,H))}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),d)for(let t=0;t<r.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,u.__webglColorRenderbuffer[t]);const a=i.get(r[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&!1===t.resolveDepthBuffer&&l){const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}},this.setupDepthTexture=B,this.setupDepthRenderbuffer=V,this.setupFrameBufferTexture=F,this.useMultisampledRTT=W,this.runDeferredUploads=function(){const e=m;m=!1;for(const e of p)U(e.textureProperties,e.texture,e.slot),e.texture.isPendingDeferredUpload=!1;p=[],m=e},this.setDeferTextureUploads=function(e){m=e}}function sg(e,t){return{convert:function(n,i=""){let r;const a=ru.getTransfer(i);if(n===gl)return e.UNSIGNED_BYTE;if(n===Ml)return e.UNSIGNED_SHORT_4_4_4_4;if(n===El)return e.UNSIGNED_SHORT_5_5_5_1;if(n===Al)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===Rl)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===vl)return e.BYTE;if(n===yl)return e.SHORT;if(n===xl)return e.UNSIGNED_SHORT;if(n===_l)return e.INT;if(n===bl)return e.UNSIGNED_INT;if(n===wl)return e.FLOAT;if(n===Sl)return e.HALF_FLOAT;if(1021===n)return e.ALPHA;if(1022===n)return e.RGB;if(n===Cl)return e.RGBA;if(n===Pl)return e.DEPTH_COMPONENT;if(n===Ll)return e.DEPTH_STENCIL;if(1028===n)return e.RED;if(n===Il)return e.RED_INTEGER;if(n===Dl)return e.RG;if(n===Nl)return e.RG_INTEGER;if(n===Ol)return e.RGBA_INTEGER;if(n===kl||n===Ul||n===Fl||n===zl)if(a===yc){if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(n===kl)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ul)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Fl)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===zl)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=t.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(n===kl)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ul)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Fl)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===zl)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===Bl||n===Vl||n===Hl||n===Gl){if(r=t.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(n===Bl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Vl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Hl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Gl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===jl||n===Wl||n===Xl){if(r=t.get("WEBGL_compressed_texture_etc"),null===r)return null;if(n===jl||n===Wl)return a===yc?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Xl)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(n===ql||n===$l||n===Yl||n===Kl||n===Zl||n===Ql||n===Jl||n===ec||n===tc||n===nc||n===ic||n===rc||n===ac||n===sc){if(r=t.get("WEBGL_compressed_texture_astc"),null===r)return null;if(n===ql)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===$l)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Yl)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Kl)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Zl)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ql)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Jl)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ec)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===tc)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===nc)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ic)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===rc)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ac)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===sc)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===oc||n===lc||n===cc){if(r=t.get("EXT_texture_compression_bptc"),null===r)return null;if(n===oc)return a===yc?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===lc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===cc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===uc||n===dc||n===hc||n===fc){if(r=t.get("EXT_texture_compression_rgtc"),null===r)return null;if(n===uc)return r.COMPRESSED_RED_RGTC1_EXT;if(n===dc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===hc)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===fc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===Tl?e.UNSIGNED_INT_24_8:void 0!==e[n]?e[n]:null}}}class og extends vu{constructor(e,t,n,i={}){super(e,t,i),this.depthBuffer=!1,this.stencilBuffer=!1,this.numViews=n}copy(e){return super.copy(e),this.numViews=e.numViews,this}}og.prototype.isWebGLMultiviewRenderTarget=!0;class lg{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(null===this.texture){const n=new of(e.texture);e.depthNear===t.depthNear&&e.depthFar===t.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(null!==this.texture&&null===this.mesh){const t=e.cameras[0].viewport,n=new Sh({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new gh(new df(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class cg extends zc{constructor(e,t,n,i){super();const r=this;let a=null,s=1;var o=null;let l=null,c="local-floor",u=1,d=null,h=null;var f=[];let p=null,m=null,g=null,v=null;const y="undefined"!=typeof XRWebGLBinding,x=new lg,_={},b=t.getContextAttributes();let w=null,S=null;const M=[],E=[],T=new $c;let A=null;const R=new Rh;R.viewport=new mu;const C=new Rh;C.viewport=new mu;const P=[R,C],L=new xf;let I=null,D=null;function N(e){const t=E.indexOf(e.inputSource);if(-1===t)return;const n=M[t];void 0!==n&&(n.update(e.inputSource,e.frame,d||l),n.dispatchEvent({type:e.type,data:e.inputSource}))}function O(){a.removeEventListener("select",N),a.removeEventListener("selectstart",N),a.removeEventListener("selectend",N),a.removeEventListener("squeeze",N),a.removeEventListener("squeezestart",N),a.removeEventListener("squeezeend",N),a.removeEventListener("end",O),a.removeEventListener("inputsourceschange",k);for(let e=0;e<M.length;e++){const t=E[e];null!==t&&(E[e]=null,M[e].disconnect(t))}I=null,D=null,x.reset();for(const e in _)delete _[e];r.isPresenting=!1,e.setRenderTarget(w),g=null,m=null,p=null,a=null,S=null,V.stop(),e.setPixelRatio(A),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}function k(e){for(let t=0;t<e.removed.length;t++){const n=e.removed[t],i=E.indexOf(n);i>=0&&(E[i]=null,M[i].disconnect(n))}for(let t=0;t<e.added.length;t++){const n=e.added[t];let i=E.indexOf(n);if(-1===i){for(let e=0;e<M.length;e++){if(e>=E.length){E.push(n),i=e;break}if(null===E[e]){E[e]=n,i=e;break}}if(-1===i)break}const r=M[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.layersEnabled=!1,this.isPresenting=!1,this.isMultiview=!1,this.getCameraPose=function(){return h},this.getController=function(e){let t=M[e];return void 0===t&&(t=new Oh,M[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=M[e];return void 0===t&&(t=new Oh,M[e]=t),t.getGripSpace()},this.getHand=function(e){let t=M[e];return void 0===t&&(t=new Oh,M[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){s=e,!0===r.isPresenting&&kc("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){c=e,!0===r.isPresenting&&kc("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||l},this.setReferenceSpace=function(e){d=e},this.getBaseLayer=function(){return null!==m?m:g},this.getBinding=function(){return null===p&&y&&(p=new XRWebGLBinding(a,t)),p},this.getFrame=function(){return v},this.getRenderTarget=function(){return S},this.getSession=function(){return a},this.setSession=async function(o){if(a=o,null!==a){w=e.getRenderTarget(),a.addEventListener("select",N),a.addEventListener("selectstart",N),a.addEventListener("selectend",N),a.addEventListener("squeeze",N),a.addEventListener("squeezestart",N),a.addEventListener("squeezeend",N),a.addEventListener("end",O),a.addEventListener("inputsourceschange",k),!0!==b.xrCompatible&&await t.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(T);if(y&&"createProjectionLayer"in XRWebGLBinding.prototype){let o=null,l=null,c=null;b.depth&&(c=b.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,o=b.stencil?Ll:Pl,l=b.stencil?Tl:bl),r.isMultiview=i&&n.has("OCULUS_multiview");const u={colorFormat:t.RGBA8,depthFormat:c,scaleFactor:s};r.isMultiview&&(u.textureType="texture-array"),p=this.getBinding(),m=p.createProjectionLayer(u),a.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1);const d={format:Cl,type:gl,depthTexture:new sf(m.textureWidth,m.textureHeight,l,void 0,void 0,void 0,void 0,void 0,void 0,o),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:!1===m.ignoreDepthValues,resolveStencilBuffer:!1===m.ignoreDepthValues};if(r.isMultiview){const e=n.get("OCULUS_multiview");this.maxNumViews=t.getParameter(e.MAX_VIEWS_OVR),S=new og(m.textureWidth,m.textureHeight,2,d)}else S=new vu(m.textureWidth,m.textureHeight,d)}else{const n={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:s};g=new XRWebGLLayer(a,t,n),a.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),S=new vu(g.framebufferWidth,g.framebufferHeight,{format:Cl,type:gl,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil,resolveDepthBuffer:!1===g.ignoreDepthValues,resolveStencilBuffer:!1===g.ignoreDepthValues})}S.isXRRenderTarget=!0,this.setFoveation(u),d=null,l=await a.requestReferenceSpace(c),V.setContext(a),V.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==a)return a.environmentBlendMode},this.addLayer=function(e){window.XRWebGLBinding&&this.layersEnabled&&a&&(f.push(e),this.updateLayers())},this.removeLayer=function(e){f.splice(f.indexOf(e),1),window.XRWebGLBinding&&this.layersEnabled&&a&&this.updateLayers()},this.updateLayers=function(){var e=f.map(function(e){return e});e.unshift(a.renderState.layers[0]),a.updateRenderState({layers:e})},this.getDepthTexture=function(){return x.getDepthTexture()};const U=new Kc,F=new Kc;function z(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.setPoseTarget=function(e){void 0!==e&&(o=e)},this.updateCamera=function(e){if(null===a)return;let t=e.near,n=e.far;null!==x.texture&&(x.depthNear>0&&(t=x.depthNear),x.depthFar>0&&(n=x.depthFar)),L.near=C.near=R.near=t,L.far=C.far=R.far=n,I===L.near&&D===L.far||(a.updateRenderState({depthNear:L.near,depthFar:L.far}),I=L.near,D=L.far),L.layers.mask=6|e.layers.mask,R.layers.mask=3&L.layers.mask,C.layers.mask=5&L.layers.mask;const i=L.cameras;var r=o||e;const s=r.parent;z(L,s);for(let e=0;e<i.length;e++)z(i[e],s);2===i.length?function(e,t,n){U.setFromMatrixPosition(t.matrixWorld),F.setFromMatrixPosition(n.matrixWorld);const i=U.distanceTo(F),r=t.projectionMatrix.elements,a=n.projectionMatrix.elements,s=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],u=(r[8]-1)/r[0],d=(a[8]+1)/a[0],h=s*u,f=s*d,p=i/(-u+d),m=p*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(p),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),-1===r[10])e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{const t=s+p,n=o+p,r=h-m,a=f+(i-m),u=l*o/n*t,d=c*o/n*t;e.projectionMatrix.makePerspective(r,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}(L,R,C):L.projectionMatrix.copy(R.projectionMatrix),function(e,t,n){t.matrixWorld.decompose(t.position,t.quaternion,t.scale),null===n.parent?n.matrix.copy(t.matrixWorld):(n.matrix.copy(n.parent.matrixWorld),n.matrix.invert(),n.matrix.multiply(t.matrixWorld));n.matrix.decompose(n.position,n.quaternion,n.scale),n.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*Hc*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,L,r)},this.getCamera=function(){return L},this.getFoveation=function(){if(null!==m||null!==g)return u},this.setFoveation=function(e){u=e,null!==m&&(m.fixedFoveation=e),null!==g&&void 0!==g.fixedFoveation&&(g.fixedFoveation=e)},this.hasDepthSensing=function(){return null!==x.texture},this.getDepthSensingMesh=function(){return x.getMesh(L)},this.getCameraTexture=function(e){return _[e]};let B=null;const V=new Df;V.setAnimationLoop(function(t,n){if(h=n.getViewerPose(d||l),v=n,null!==h){const t=h.views;null!==g&&(e.setRenderTargetFramebuffer(S,g.framebuffer),e.setRenderTarget(S));let n=!1;t.length!==L.cameras.length&&(L.cameras.length=0,n=!0);for(let i=0;i<t.length;i++){const r=t[i];let a=null;if(null!==g)a=g.getViewport(r);else{const t=p.getViewSubImage(m,r);a=t.viewport,0===i&&(e.setRenderTargetTextures(S,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(S))}let s=P[i];void 0===s&&(s=new Rh,s.layers.enable(i),s.viewport=new mu,P[i]=s),s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.projectionMatrix.fromArray(r.projectionMatrix),s.projectionMatrixInverse.copy(s.projectionMatrix).invert(),s.viewport.set(a.x,a.y,a.width,a.height),0===i&&(L.matrix.copy(s.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),!0===n&&L.cameras.push(s)}const i=a.enabledFeatures;if(i&&i.includes("depth-sensing")&&"gpu-optimized"==a.depthUsage&&y){p=r.getBinding();const e=p.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&x.init(e,a.renderState)}if(i&&i.includes("camera-access")&&y){e.state.unbindTexture(),p=r.getBinding();for(let e=0;e<t.length;e++){const n=t[e].camera;if(n){let e=_[n];e||(e=new of,_[n]=e);const t=p.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<M.length;e++){const t=E[e],i=M[e];null!==t&&void 0!==i&&i.update(t,n,d||l)}B&&B(t,n),n.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:n}),v=null}),this.setAnimationLoop=function(e){B=e},this.dispose=function(){}}}const ug=new id,dg=new qu;function hg(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function i(e,i){e.opacity.value=i.opacity,i.color&&e.diffuse.value.copy(i.color),i.emissive&&e.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(e.map.value=i.map,n(i.map,e.mapTransform)),i.alphaMap&&(e.alphaMap.value=i.alphaMap,n(i.alphaMap,e.alphaMapTransform)),i.bumpMap&&(e.bumpMap.value=i.bumpMap,n(i.bumpMap,e.bumpMapTransform),e.bumpScale.value=i.bumpScale,1===i.side&&(e.bumpScale.value*=-1)),i.normalMap&&(e.normalMap.value=i.normalMap,n(i.normalMap,e.normalMapTransform),e.normalScale.value.copy(i.normalScale),1===i.side&&e.normalScale.value.negate()),i.displacementMap&&(e.displacementMap.value=i.displacementMap,n(i.displacementMap,e.displacementMapTransform),e.displacementScale.value=i.displacementScale,e.displacementBias.value=i.displacementBias),i.emissiveMap&&(e.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,e.emissiveMapTransform)),i.specularMap&&(e.specularMap.value=i.specularMap,n(i.specularMap,e.specularMapTransform)),i.alphaTest>0&&(e.alphaTest.value=i.alphaTest);const r=t.get(i),a=r.envMap,s=r.envMapRotation;a&&(e.envMap.value=a,ug.copy(s),ug.x*=-1,ug.y*=-1,ug.z*=-1,a.isCubeTexture&&!1===a.isRenderTargetTexture&&(ug.y*=-1,ug.z*=-1),e.envMapRotation.value.setFromMatrix4(dg.makeRotationFromEuler(ug)),e.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,e.reflectivity.value=i.reflectivity,e.ior.value=i.ior,e.refractionRatio.value=i.refractionRatio),i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,e.lightMapTransform)),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,bh(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,s,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform));e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform));t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),1===t.side&&e.clearcoatNormalScale.value.negate()));t.dispersion>0&&(e.dispersion.value=t.dispersion);t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){const i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,a,s):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function fg(e,t,n,i){let r={},a={},s=[];const o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(e,t,n,i){const r=e.value,a=t+"_"+n;if(void 0===i[a])return i[a]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const e=i[a];if("number"==typeof r||"boolean"==typeof r){if(e!==r)return i[a]=r,!0}else if(!1===e.equals(r))return e.copy(r),!0}return!1}function c(e){const t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?kc("WebGLRenderer: Texture samplers can not be part of an uniforms group."):kc("WebGLRenderer: Unsupported uniform value type.",e),t}function u(t){const n=t.target;n.removeEventListener("dispose",u);const i=s.indexOf(n.__bindingPointIndex);s.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete a[n.id]}return{bind:function(e,t){const n=t.program;i.uniformBlockBinding(e,n)},update:function(n,d){let h=r[n.id];void 0===h&&(!function(e){const t=e.uniforms;let n=0;const i=16;for(let e=0,r=t.length;e<r;e++){const r=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=r.length;e<t;e++){const t=r[e],a=Array.isArray(t.value)?t.value:[t.value];for(let e=0,r=a.length;e<r;e++){const r=c(a[e]),s=n%i,o=s%r.boundary,l=s+o;n+=o,0!==l&&i-l<r.storage&&(n+=i-l),t.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=r.storage}}}const r=n%i;r>0&&(n+=i-r);e.__size=n,e.__cache={}}(n),h=function(t){const n=function(){for(let e=0;e<o;e++)if(-1===s.indexOf(e))return s.push(e),e;return Uc("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;const i=e.createBuffer(),r=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,i),e.bufferData(e.UNIFORM_BUFFER,r,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=h,n.addEventListener("dispose",u));const f=d.program;i.updateUBOMapping(n,f);const p=t.render.frame;a[n.id]!==p&&(!function(t){const n=r[t.id],i=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=i.length;t<n;t++){const n=Array.isArray(i[t])?i[t]:[i[t]];for(let i=0,r=n.length;i<r;i++){const r=n[i];if(!0===l(r,t,i,a)){const t=r.__offset,n=Array.isArray(r.value)?r.value:[r.value];let i=0;for(let a=0;a<n.length;a++){const s=n[a],o=c(s);"number"==typeof s||"boolean"==typeof s?(r.__data[0]=s,e.bufferSubData(e.UNIFORM_BUFFER,t+i,r.__data)):s.isMatrix3?(r.__data[0]=s.elements[0],r.__data[1]=s.elements[1],r.__data[2]=s.elements[2],r.__data[3]=0,r.__data[4]=s.elements[3],r.__data[5]=s.elements[4],r.__data[6]=s.elements[5],r.__data[7]=0,r.__data[8]=s.elements[6],r.__data[9]=s.elements[7],r.__data[10]=s.elements[8],r.__data[11]=0):(s.toArray(r.__data,i),i+=o.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,r.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(n),a[n.id]=p)},dispose:function(){for(const t in r)e.deleteBuffer(r[t]);s=[],r={},a={}}}}const pg=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let mg=null;class gg{constructor(e={}){const{canvas:t=Dc(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:s=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,multiviewStereo:h=!1}=e;let f;if(this.isWebGLRenderer=!0,null!==n){if("undefined"!=typeof WebGLRenderingContext&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=a;const p=new Set([Ol,Nl,Il]),m=new Set([gl,bl,xl,Tl,Ml,El]),g=new Uint32Array(4),v=new Int32Array(4);let y=null,x=null;const _=[],b=[];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=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const w=this;let S=!1;this._outputColorSpace=mc;let M=0,E=0,T=null,A=-1,R=null;const C=new mu,P=new mu;let L=null;const I=new zd(0);let D=0,N=t.width,O=t.height,k=1,U=null,F=null;const z=new mu(0,0,N,O),B=new mu(0,0,N,O);let V=!1;const H=new Wh;let G=!1,j=!1;const W=new qu,X=new Kc,q=new mu,$={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Y=!1;function K(){return null===T?k:1}let Z,Q,J,ee,te,ne,ie,re,ae,se,oe,le,ce,ue,de,he,fe,pe,me,ge,ve,ye,xe,_e,be,we=n;function Se(e,n){return t.getContext(e,n)}try{const e={alpha:!0,depth:i,stencil:r,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ro}`),t.addEventListener("webglcontextlost",Te,!1),t.addEventListener("webglcontextrestored",Ae,!1),t.addEventListener("webglcontextcreationerror",Re,!1),null===we){const t="webgl2";if(we=Se(t,e),null===we)throw Se(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(e){throw e("WebGLRenderer: "+e.message),e}function Me(){Z=new cp(we),Z.init(),xe=new sg(we,Z),Q=new jf(we,Z,e,xe),J=new rg(we,Z),Q.reversedDepthBuffer&&d&&J.buffers.depth.setReversed(!0),ee=new hp(we),te=new Wm,ne=new ag(we,Z,J,te,Q,xe,ee),ie=new Xf(w),re=new lp(w),ae=new Nf(we),_e=new Hf(we,ae),se=new up(we,ae,ee,_e),oe=new mp(we,se,ae,ee),ge=new fp(we,Q,ne),he=new Wf(te),le=new jm(w,ie,re,Z,Q,_e,he),ce=new hg(w,te),ue=new Ym,de=new tg(Z),me=new Vf(w,ie,re,J,oe,f,o),pe=new pp(w,Z,we),fe=new ng(w,oe,Q),be=new fg(we,ee,Q,J),ve=new Gf(we,Z,ee),ye=new dp(we,Z,ee),ee.programs=le.programs,w.capabilities=Q,w.extensions=Z,w.properties=te,w.renderLists=ue,w.shadowMap=fe,w.state=J,w.info=ee}Me();const Ee=new cg(w,we,Z,h);function Te(e){e.preventDefault(),Oc("WebGLRenderer: Context Lost."),S=!0}function Ae(){Oc("WebGLRenderer: Context Restored."),S=!1;const e=ee.autoReset,t=fe.enabled,n=fe.autoUpdate,i=fe.needsUpdate,r=fe.type;Me(),ee.autoReset=e,fe.enabled=t,fe.autoUpdate=n,fe.needsUpdate=i,fe.type=r}function Re(e){Uc("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Ce(e){const t=e.target;t.removeEventListener("dispose",Ce),function(e){(function(e){const t=te.get(e).programs;void 0!==t&&(t.forEach(function(e){le.releaseProgram(e)}),e.isShaderMaterial&&le.releaseShaderCache(e))})(e),te.remove(e)}(t)}function Pe(e,t,n){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=1,e.needsUpdate=!0,Be(e,t,n),e.side=0,e.needsUpdate=!0,Be(e,t,n),e.side=2):Be(e,t,n)}this.xr=Ee,this.getContext=function(){return we},this.getContextAttributes=function(){return we.getContextAttributes()},this.forceContextLoss=function(){const e=Z.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=Z.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return k},this.setPixelRatio=function(e){void 0!==e&&(k=e,this.setSize(N,O,!1))},this.getSize=function(e){return e.set(N,O)},this.setSize=function(e,n,i=!0){Ee.isPresenting?kc("WebGLRenderer: Can't change size while VR device is presenting."):(N=e,O=n,t.width=Math.floor(e*k),t.height=Math.floor(n*k),!0===i&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(N*k,O*k).floor()},this.setDrawingBufferSize=function(e,n,i){N=e,O=n,k=i,t.width=Math.floor(e*i),t.height=Math.floor(n*i),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(C)},this.getViewport=function(e){return e.copy(z)},this.setViewport=function(e,t,n,i){e.isVector4?z.set(e.x,e.y,e.z,e.w):z.set(e,t,n,i),J.viewport(C.copy(z).multiplyScalar(k).round())},this.getScissor=function(e){return e.copy(B)},this.setScissor=function(e,t,n,i){e.isVector4?B.set(e.x,e.y,e.z,e.w):B.set(e,t,n,i),J.scissor(P.copy(B).multiplyScalar(k).round())},this.getScissorTest=function(){return V},this.setScissorTest=function(e){J.setScissorTest(V=e)},this.setOpaqueSort=function(e){U=e},this.setTransparentSort=function(e){F=e},this.getClearColor=function(e){return e.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor(...arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let i=0;if(e){let e=!1;if(null!==T){const t=T.texture.format;e=p.has(t)}if(e){const e=T.texture.type,t=m.has(e),n=me.getClearColor(),i=me.getClearAlpha(),r=n.r,a=n.g,s=n.b;t?(g[0]=r,g[1]=a,g[2]=s,g[3]=i,we.clearBufferuiv(we.COLOR,0,g)):(v[0]=r,v[1]=a,v[2]=s,v[3]=i,we.clearBufferiv(we.COLOR,0,v))}else i|=we.COLOR_BUFFER_BIT}t&&(i|=we.DEPTH_BUFFER_BIT),n&&(i|=we.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),we.clear(i)},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.dispose=function(){t.removeEventListener("webglcontextlost",Te,!1),t.removeEventListener("webglcontextrestored",Ae,!1),t.removeEventListener("webglcontextcreationerror",Re,!1),me.dispose(),ue.dispose(),de.dispose(),te.dispose(),ie.dispose(),re.dispose(),oe.dispose(),_e.dispose(),be.dispose(),le.dispose(),Ee.dispose(),Ee.removeEventListener("sessionstart",Ie),Ee.removeEventListener("sessionend",De),Ne.stop()},this.renderBufferDirect=function(e,t,n,i,r,a){null===t&&(t=$);const s=r.isMesh&&r.matrixWorld.determinant()<0,o=function(e,t,n,i,r){!0!==t.isScene&&(t=$);ne.resetTextureUnits();const a=t.fog,s=i.isMeshStandardMaterial?t.environment:null,o=null===T?w.outputColorSpace:!0===T.isXRRenderTarget?T.texture.colorSpace:gc,l=(i.isMeshStandardMaterial?re:ie).get(i.envMap||s),c=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),d=!!n.morphAttributes.position,h=!!n.morphAttributes.normal,f=!!n.morphAttributes.color;let p=0;i.toneMapped&&(null!==T&&!0!==T.isXRRenderTarget||(p=w.toneMapping));const m=T&&T.isWebGLMultiviewRenderTarget?T.numViews:0,g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==g?g.length:0,y=te.get(i),_=x.state.lights;if(!0===G&&(!0===j||e!==R)){const t=e===R&&i.id===A;he.setState(i,e,t)}let b=!1;i.version===y.__version?y.needsLights&&y.lightsStateVersion!==_.state.version||y.outputColorSpace!==o||r.isBatchedMesh&&!1===y.batching?b=!0:r.isBatchedMesh||!0!==y.batching?r.isBatchedMesh&&!0===y.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===y.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===y.instancing?b=!0:r.isInstancedMesh||!0!==y.instancing?r.isSkinnedMesh&&!1===y.skinning?b=!0:r.isSkinnedMesh||!0!==y.skinning?r.isInstancedMesh&&!0===y.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===y.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===y.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===y.instancingMorph&&null!==r.morphTexture||y.envMap!==l||!0===i.fog&&y.fog!==a?b=!0:void 0===y.numClippingPlanes||y.numClippingPlanes===he.numPlanes&&y.numIntersection===he.numIntersection?(y.vertexAlphas!==c||y.vertexTangents!==u||y.morphTargets!==d||y.morphNormals!==h||y.morphColors!==f||y.toneMapping!==p||y.morphTargetsCount!==v||y.numMultiviewViews!==m)&&(b=!0):b=!0:b=!0:b=!0:b=!0:(b=!0,y.__version=i.version);let S=y.currentProgram;!0===b&&(S=Be(i,t,r));let M=!1,E=!1,C=!1;const P=S.getUniforms(),L=y.uniforms;J.useProgram(S.program)&&(M=!0,E=!0,C=!0);i.id!==A&&(A=i.id,E=!0);if(M||R!==e){if(S.numMultiviewViews>0)pe.updateCameraProjectionMatricesUniform(e,P),pe.updateCameraViewMatricesUniform(e,P);else{J.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),P.setValue(we,"projectionMatrix",e.projectionMatrix),P.setValue(we,"viewMatrix",e.matrixWorldInverse)}const t=P.map.cameraPosition;void 0!==t&&t.setValue(we,X.setFromMatrixPosition(e.matrixWorld)),Q.logarithmicDepthBuffer&&P.setValue(we,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&P.setValue(we,"isOrthographic",!0===e.isOrthographicCamera),R!==e&&(R=e,E=!0,C=!0)}if(r.isSkinnedMesh){P.setOptional(we,r,"bindMatrix"),P.setOptional(we,r,"bindMatrixInverse");const e=r.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),P.setValue(we,"boneTexture",e.boneTexture,ne))}r.isBatchedMesh&&(P.setOptional(we,r,"batchingTexture"),P.setValue(we,"batchingTexture",r._matricesTexture,ne),P.setOptional(we,r,"batchingIdTexture"),P.setValue(we,"batchingIdTexture",r._indirectTexture,ne),P.setOptional(we,r,"batchingColorTexture"),null!==r._colorsTexture&&P.setValue(we,"batchingColorTexture",r._colorsTexture,ne));const I=n.morphAttributes;void 0===I.position&&void 0===I.normal&&void 0===I.color||ge.update(r,n,S);(E||y.receiveShadow!==r.receiveShadow)&&(y.receiveShadow=r.receiveShadow,P.setValue(we,"receiveShadow",r.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(L.envMap.value=l,L.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);i.isMeshStandardMaterial&&null===i.envMap&&null!==t.environment&&(L.envMapIntensity.value=t.environmentIntensity);void 0!==L.dfgLUT&&(L.dfgLUT.value=(null===mg&&(mg=new Uh(pg,32,32,Dl,Sl),mg.minFilter=fl,mg.magFilter=fl,mg.wrapS=ll,mg.wrapT=ll,mg.generateMipmaps=!1,mg.needsUpdate=!0),mg));E&&(P.setValue(we,"toneMappingExposure",w.toneMappingExposure),y.needsLights&&(N=C,(D=L).ambientLightColor.needsUpdate=N,D.lightProbe.needsUpdate=N,D.directionalLights.needsUpdate=N,D.directionalLightShadows.needsUpdate=N,D.pointLights.needsUpdate=N,D.pointLightShadows.needsUpdate=N,D.spotLights.needsUpdate=N,D.spotLightShadows.needsUpdate=N,D.rectAreaLights.needsUpdate=N,D.hemisphereLights.needsUpdate=N),a&&!0===i.fog&&ce.refreshFogUniforms(L,a),ce.refreshMaterialUniforms(L,i,k,O,x.state.transmissionRenderTarget[e.id]),_m.upload(we,Ve(y),L,ne));var D,N;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(_m.upload(we,Ve(y),L,ne),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&P.setValue(we,"center",r.center);S.numMultiviewViews>0?pe.updateObjectMatricesUniforms(r,e,P):(P.setValue(we,"modelViewMatrix",r.modelViewMatrix),P.setValue(we,"normalMatrix",r.normalMatrix));if(P.setValue(we,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.uniformsGroups;for(let t=0,n=e.length;t<n;t++){const n=e[t];be.update(n,S),be.bind(n,S)}}return S}(e,t,n,i,r);J.setMaterial(i,s);let l=n.index,c=1;if(!0===i.wireframe){if(l=se.getWireframeAttribute(n),void 0===l)return;c=2}const u=n.drawRange,d=n.attributes.position;let h=u.start*c,f=(u.start+u.count)*c;null!==a&&(h=Math.max(h,a.start*c),f=Math.min(f,(a.start+a.count)*c)),null!==l?(h=Math.max(h,0),f=Math.min(f,l.count)):null!=d&&(h=Math.max(h,0),f=Math.min(f,d.count));const p=f-h;if(p<0||p===1/0)return;let m;_e.setup(r,i,o,n,l);let g=ve;if(null!==l&&(m=ae.get(l),g=ye,g.setIndex(m)),r.isMesh)!0===i.wireframe?(J.setLineWidth(i.wireframeLinewidth*K()),g.setMode(we.LINES)):g.setMode(we.TRIANGLES);else if(r.isLine){let e=i.linewidth;void 0===e&&(e=1),J.setLineWidth(e*K()),r.isLineSegments?g.setMode(we.LINES):r.isLineLoop?g.setMode(we.LINE_LOOP):g.setMode(we.LINE_STRIP)}else r.isPoints?g.setMode(we.POINTS):r.isSprite&&g.setMode(we.TRIANGLES);if(r.isBatchedMesh)if(null!==r._multiDrawInstances)Fc("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),g.renderMultiDrawInstances(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount,r._multiDrawInstances);else if(Z.get("WEBGL_multi_draw"))g.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const e=r._multiDrawStarts,t=r._multiDrawCounts,n=r._multiDrawCount,a=l?ae.get(l).bytesPerElement:1,s=te.get(i).currentProgram.getUniforms();for(let i=0;i<n;i++)s.setValue(we,"_gl_DrawID",i),g.render(e[i]/a,t[i])}else if(r.isInstancedMesh)g.renderInstances(h,p,r.count);else if(n.isInstancedBufferGeometry){const e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);g.renderInstances(h,p,t)}else g.render(h,p)},this.compile=function(e,t,n=null){null===n&&(n=e),x=de.get(n),x.init(t),b.push(x),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),x.setupLights();const i=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;const t=e.material;if(t)if(Array.isArray(t))for(let r=0;r<t.length;r++){const a=t[r];Pe(a,n,e),i.add(a)}else Pe(t,n,e),i.add(t)}),x=b.pop(),i},this.compileAsync=function(e,t,n=null){const i=this.compile(e,t,n);return new Promise(t=>{function n(){i.forEach(function(e){te.get(e).currentProgram.isReady()&&i.delete(e)}),0!==i.size?setTimeout(n,10):t(e)}null!==Z.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)})};let Le=null;function Ie(){Ne.stop()}function De(){Ne.start()}const Ne=new Df;function Oe(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||H.intersectsSprite(e)){i&&q.setFromMatrixPosition(e.matrixWorld).applyMatrix4(W);const t=oe.update(e),r=e.material;r.visible&&y.push(e,t,r,n,q.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||H.intersectsObject(e))){const t=oe.update(e),r=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),q.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),q.copy(t.boundingSphere.center)),q.applyMatrix4(e.matrixWorld).applyMatrix4(W)),Array.isArray(r)){const i=t.groups;for(let a=0,s=i.length;a<s;a++){const s=i[a],o=r[s.materialIndex];o&&o.visible&&y.push(e,t,o,n,q.z,s)}}else r.visible&&y.push(e,t,r,n,q.z,null)}const r=e.children;for(let e=0,a=r.length;e<a;e++)Oe(r[e],t,n,i)}function ke(e,t,n,i){const{opaque:r,transmissive:a,transparent:s}=e;x.setupLightsView(n),!0===G&&he.setGlobalState(w.clippingPlanes,n),i&&J.viewport(C.copy(i)),r.length>0&&Fe(r,t,n),a.length>0&&Fe(a,t,n),s.length>0&&Fe(s,t,n),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function Ue(e,t,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===x.state.transmissionRenderTarget[i.id]&&(x.state.transmissionRenderTarget[i.id]=new vu(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")||Z.has("EXT_color_buffer_float")?Sl:gl,minFilter:ml,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ru.workingColorSpace}));const a=x.state.transmissionRenderTarget[i.id],s=i.viewport||C;a.setSize(s.z*w.transmissionResolutionScale,s.w*w.transmissionResolutionScale);const o=w.getRenderTarget(),l=w.getActiveCubeFace(),c=w.getActiveMipmapLevel();w.setRenderTarget(a),w.getClearColor(I),D=w.getClearAlpha(),D<1&&w.setClearColor(16777215,.5),w.clear(),Y&&me.render(n);const u=w.toneMapping;w.toneMapping=0;const d=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),x.setupLightsView(i),!0===G&&he.setGlobalState(w.clippingPlanes,i),Fe(e,n,i),ne.updateMultisampleRenderTarget(a),ne.updateRenderTargetMipmap(a),!1===Z.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let r=0,a=t.length;r<a;r++){const a=t[r],{object:s,geometry:o,material:l,group:c}=a;if(2===l.side&&s.layers.test(i.layers)){const t=l.side;l.side=1,l.needsUpdate=!0,ze(s,n,i,o,l,c),l.side=t,l.needsUpdate=!0,e=!0}}!0===e&&(ne.updateMultisampleRenderTarget(a),ne.updateRenderTargetMipmap(a))}w.setRenderTarget(o,l,c),w.setClearColor(I,D),void 0!==d&&(i.viewport=d),w.toneMapping=u}function Fe(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,a=e.length;r<a;r++){const a=e[r],{object:s,geometry:o,group:l}=a;let c=a.material;!0===c.allowOverride&&null!==i&&(c=i),s.layers.test(n.layers)&&ze(s,t,n,o,c,l)}}function ze(e,t,n,i,r,a){e.onBeforeRender(w,t,n,i,r,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(w,t,n,i,e,a),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,w.renderBufferDirect(n,t,i,r,e,a),r.side=0,r.needsUpdate=!0,w.renderBufferDirect(n,t,i,r,e,a),r.side=2):w.renderBufferDirect(n,t,i,r,e,a),e.onAfterRender(w,t,n,i,r,a)}function Be(e,t,n){!0!==t.isScene&&(t=$);const i=te.get(e),r=x.state.lights,a=x.state.shadowsArray,s=r.state.version,o=le.getParameters(e,r.state,a,t,n),l=le.getProgramCacheKey(o);let c=i.programs;i.environment=e.isMeshStandardMaterial?t.environment:null,i.fog=t.fog,i.envMap=(e.isMeshStandardMaterial?re:ie).get(e.envMap||i.environment),i.envMapRotation=null!==i.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation,void 0===c&&(e.addEventListener("dispose",Ce),c=new Map,i.programs=c);let u=c.get(l);if(void 0!==u){if(i.currentProgram===u&&i.lightsStateVersion===s)return He(e,o),u}else o.uniforms=le.getUniforms(e),e.onBeforeCompile(o,w),u=le.acquireProgram(o,l),c.set(l,u),i.uniforms=o.uniforms;const d=i.uniforms;return(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(d.clippingPlanes=he.uniform),He(e,o),i.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),i.lightsStateVersion=s,i.needsLights&&(d.ambientLightColor.value=r.state.ambient,d.lightProbe.value=r.state.probe,d.directionalLights.value=r.state.directional,d.directionalLightShadows.value=r.state.directionalShadow,d.spotLights.value=r.state.spot,d.spotLightShadows.value=r.state.spotShadow,d.rectAreaLights.value=r.state.rectArea,d.ltc_1.value=r.state.rectAreaLTC1,d.ltc_2.value=r.state.rectAreaLTC2,d.pointLights.value=r.state.point,d.pointLightShadows.value=r.state.pointShadow,d.hemisphereLights.value=r.state.hemi,d.directionalShadowMap.value=r.state.directionalShadowMap,d.directionalShadowMatrix.value=r.state.directionalShadowMatrix,d.spotShadowMap.value=r.state.spotShadowMap,d.spotLightMatrix.value=r.state.spotLightMatrix,d.spotLightMap.value=r.state.spotLightMap,d.pointShadowMap.value=r.state.pointShadowMap,d.pointShadowMatrix.value=r.state.pointShadowMatrix),i.currentProgram=u,i.uniformsList=null,u}function Ve(e){if(null===e.uniformsList){const t=e.currentProgram.getUniforms();e.uniformsList=_m.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function He(e,t){const n=te.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping,n.numMultiviewViews=t.numMultiviewViews}var Ge;Ne.setAnimationLoop(function(e){Le&&Le(e)}),"undefined"!=typeof self&&Ne.setContext(self),this.setAnimationLoop=function(e){Le=e,Ee.setAnimationLoop(e),null===e?Ne.stop():Ne.start()},Ee.addEventListener("sessionstart",Ie),Ee.addEventListener("sessionend",De),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void Uc("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===S)return;if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===Ee.enabled&&!0===Ee.isPresenting&&(!0===Ee.cameraAutoUpdate&&Ee.updateCamera(t),t=Ee.getCamera()),!0===e.isScene&&e.onBeforeRender(w,e,t,T),x=de.get(e,b.length),x.init(t),b.push(x),W.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),H.setFromProjectionMatrix(W,Cc,t.reversedDepth),j=this.localClippingEnabled,G=he.init(this.clippingPlanes,j),y=ue.get(e,_.length),y.init(),_.push(y),!0===Ee.enabled&&!0===Ee.isPresenting){const e=w.xr.getDepthSensingMesh();null!==e&&Oe(e,t,-1/0,w.sortObjects)}Oe(e,t,0,w.sortObjects),y.finish(),!0===w.sortObjects&&y.sort(U,F),Y=!1===Ee.enabled||!1===Ee.isPresenting||!1===Ee.hasDepthSensing(),Y&&me.addToRenderList(y,e),this.info.render.frame++,!0===G&&he.beginShadows();const n=x.state.shadowsArray;fe.render(n,e,t),!0===G&&he.endShadows(),!0===this.info.autoReset&&this.info.reset();const i=y.opaque,r=y.transmissive;if(x.setupLights(),t.isArrayCamera){const n=t.cameras;if(r.length>0)for(let t=0,a=n.length;t<a;t++){Ue(i,r,e,n[t])}if(Y&&me.render(e),Ee.enabled&&Ee.isMultiview)ne.setDeferTextureUploads(!0),ke(y,e,t,t.cameras[0].viewport);else for(let t=0,i=n.length;t<i;t++){const i=n[t];ke(y,e,i,i.viewport)}}else r.length>0&&Ue(i,r,e,t),Y&&me.render(e),ke(y,e,t);null!==T&&0===E&&(ne.updateMultisampleRenderTarget(T),ne.updateRenderTargetMipmap(T)),!0===e.isScene&&e.onAfterRender(w,e,t),ne.runDeferredUploads(),_e.resetDefaultState(),A=-1,R=null,b.pop(),b.length>0?(x=b[b.length-1],!0===G&&he.setGlobalState(w.clippingPlanes,x.state.camera)):x=null,_.pop(),y=_.length>0?_[_.length-1]:null},this.setTexture2D=(Ge=!1,function(e,t){e&&e.isWebGLRenderTarget&&(Ge||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),Ge=!0),e=e.texture),ne.setTexture2D(e,t)}),this.getActiveCubeFace=function(){return M},this.getActiveMipmapLevel=function(){return E},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(e,t,n){const i=te.get(e);i.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,i.__autoAllocateDepthBuffer||(i.__useRenderToTexture=!1),te.get(e.texture).__webglTexture=t,te.get(e.depthTexture).__webglTexture=i.__autoAllocateDepthBuffer?void 0:n,i.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){const n=te.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t};const je=we.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){null===e&&this.xr.isPresenting&&(e=this.xr.getRenderTarget()),T=e,M=t,E=n;let i=!0,r=null,a=!1,s=!1;if(e){const o=te.get(e);if(void 0!==o.__useDefaultFramebuffer)J.bindFramebuffer(we.FRAMEBUFFER,null),i=!1;else if(void 0===o.__webglFramebuffer)ne.setupRenderTarget(e);else if(o.__hasExternalTextures)ne.rebindTextures(e,te.get(e.texture).__webglTexture,te.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){const t=e.depthTexture;if(o.__boundDepthTexture!==t){if(null!==t&&te.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ne.setupDepthRenderbuffer(e)}}const l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(s=!0);const c=te.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],a=!0):r=e.samples>0&&!1===ne.useMultisampledRTT(e)?te.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,C.copy(e.viewport),P.copy(e.scissor),L=e.scissorTest}else C.copy(z).multiplyScalar(k).floor(),P.copy(B).multiplyScalar(k).floor(),L=V;0!==n&&(r=je);if(J.bindFramebuffer(we.FRAMEBUFFER,r)&&i&&J.drawBuffers(e,r),J.viewport(C),J.scissor(P),J.setScissorTest(L),a){const i=te.get(e.texture);we.framebufferTexture2D(we.FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(s){const i=t;for(let t=0;t<e.textures.length;t++){const r=te.get(e.textures[t]);we.framebufferTextureLayer(we.FRAMEBUFFER,we.COLOR_ATTACHMENT0+t,r.__webglTexture,n,i)}}else if(null!==e&&0!==n){const t=te.get(e.texture);we.framebufferTexture2D(we.FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_2D,t.__webglTexture,n)}A=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,s,o=0){if(!e||!e.isWebGLRenderTarget)return void Uc("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=te.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(l=l[s]),l){J.bindFramebuffer(we.FRAMEBUFFER,l);try{const s=e.textures[o],l=s.format,c=s.type;if(!Q.textureFormatReadable(l))return void Uc("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!Q.textureTypeReadable(c))return void Uc("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&(e.textures.length>1&&we.readBuffer(we.COLOR_ATTACHMENT0+o),we.readPixels(t,n,i,r,xe.convert(l),xe.convert(c),a))}finally{const e=null!==T?te.get(T).__webglFramebuffer:null;J.bindFramebuffer(we.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,i,r,a,s,o=0){if(!e||!e.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=te.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(l=l[s]),l){if(t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r){J.bindFramebuffer(we.FRAMEBUFFER,l);const s=e.textures[o],c=s.format,u=s.type;if(!Q.textureFormatReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Q.textureTypeReadable(u))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const d=we.createBuffer();we.bindBuffer(we.PIXEL_PACK_BUFFER,d),we.bufferData(we.PIXEL_PACK_BUFFER,a.byteLength,we.STREAM_READ),e.textures.length>1&&we.readBuffer(we.COLOR_ATTACHMENT0+o),we.readPixels(t,n,i,r,xe.convert(c),xe.convert(u),0);const h=null!==T?te.get(T).__webglFramebuffer:null;J.bindFramebuffer(we.FRAMEBUFFER,h);const f=we.fenceSync(we.SYNC_GPU_COMMANDS_COMPLETE,0);return we.flush(),await function(e,t,n){return new Promise(function(i,r){setTimeout(function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:i()}},n)})}(we,f,4),we.bindBuffer(we.PIXEL_PACK_BUFFER,d),we.getBufferSubData(we.PIXEL_PACK_BUFFER,0,a),we.deleteBuffer(d),we.deleteSync(f),a}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(e,t=null,n=0){const i=Math.pow(2,-n),r=Math.floor(e.image.width*i),a=Math.floor(e.image.height*i),s=null!==t?t.x:0,o=null!==t?t.y:0;ne.setTexture2D(e,0),we.copyTexSubImage2D(we.TEXTURE_2D,n,0,0,s,o,r,a),J.unbindTexture()};const We=we.createFramebuffer(),Xe=we.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,i=null,r=0,a=null){let s,o,l,c,u,d,h,f,p;null===a&&(0!==r?(Fc("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),a=r,r=0):a=0);const m=e.isCompressedTexture?e.mipmaps[a]:e.image;if(null!==n)s=n.max.x-n.min.x,o=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{const t=Math.pow(2,-r);s=Math.floor(m.width*t),o=Math.floor(m.height*t),l=e.isDataArrayTexture?m.depth:e.isData3DTexture?Math.floor(m.depth*t):1,c=0,u=0,d=0}null!==i?(h=i.x,f=i.y,p=i.z):(h=0,f=0,p=0);const g=xe.convert(t.format),v=xe.convert(t.type);let y;t.isData3DTexture?(ne.setTexture3D(t,0),y=we.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(ne.setTexture2DArray(t,0),y=we.TEXTURE_2D_ARRAY):(ne.setTexture2D(t,0),y=we.TEXTURE_2D),we.pixelStorei(we.UNPACK_FLIP_Y_WEBGL,t.flipY),we.pixelStorei(we.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),we.pixelStorei(we.UNPACK_ALIGNMENT,t.unpackAlignment);const x=we.getParameter(we.UNPACK_ROW_LENGTH),_=we.getParameter(we.UNPACK_IMAGE_HEIGHT),b=we.getParameter(we.UNPACK_SKIP_PIXELS),w=we.getParameter(we.UNPACK_SKIP_ROWS),S=we.getParameter(we.UNPACK_SKIP_IMAGES);we.pixelStorei(we.UNPACK_ROW_LENGTH,m.width),we.pixelStorei(we.UNPACK_IMAGE_HEIGHT,m.height),we.pixelStorei(we.UNPACK_SKIP_PIXELS,c),we.pixelStorei(we.UNPACK_SKIP_ROWS,u),we.pixelStorei(we.UNPACK_SKIP_IMAGES,d);const M=e.isDataArrayTexture||e.isData3DTexture,E=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){const n=te.get(e),i=te.get(t),m=te.get(n.__renderTarget),g=te.get(i.__renderTarget);J.bindFramebuffer(we.READ_FRAMEBUFFER,m.__webglFramebuffer),J.bindFramebuffer(we.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<l;n++)M&&(we.framebufferTextureLayer(we.READ_FRAMEBUFFER,we.COLOR_ATTACHMENT0,te.get(e).__webglTexture,r,d+n),we.framebufferTextureLayer(we.DRAW_FRAMEBUFFER,we.COLOR_ATTACHMENT0,te.get(t).__webglTexture,a,p+n)),we.blitFramebuffer(c,u,s,o,h,f,s,o,we.DEPTH_BUFFER_BIT,we.NEAREST);J.bindFramebuffer(we.READ_FRAMEBUFFER,null),J.bindFramebuffer(we.DRAW_FRAMEBUFFER,null)}else if(0!==r||e.isRenderTargetTexture||te.has(e)){const n=te.get(e),i=te.get(t);J.bindFramebuffer(we.READ_FRAMEBUFFER,We),J.bindFramebuffer(we.DRAW_FRAMEBUFFER,Xe);for(let e=0;e<l;e++)M?we.framebufferTextureLayer(we.READ_FRAMEBUFFER,we.COLOR_ATTACHMENT0,n.__webglTexture,r,d+e):we.framebufferTexture2D(we.READ_FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_2D,n.__webglTexture,r),E?we.framebufferTextureLayer(we.DRAW_FRAMEBUFFER,we.COLOR_ATTACHMENT0,i.__webglTexture,a,p+e):we.framebufferTexture2D(we.DRAW_FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_2D,i.__webglTexture,a),0!==r?we.blitFramebuffer(c,u,s,o,h,f,s,o,we.COLOR_BUFFER_BIT,we.NEAREST):E?we.copyTexSubImage3D(y,a,h,f,p+e,c,u,s,o):we.copyTexSubImage2D(y,a,h,f,c,u,s,o);J.bindFramebuffer(we.READ_FRAMEBUFFER,null),J.bindFramebuffer(we.DRAW_FRAMEBUFFER,null)}else E?e.isDataTexture||e.isData3DTexture?we.texSubImage3D(y,a,h,f,p,s,o,l,g,v,m.data):t.isCompressedArrayTexture?we.compressedTexSubImage3D(y,a,h,f,p,s,o,l,g,m.data):we.texSubImage3D(y,a,h,f,p,s,o,l,g,v,m):e.isDataTexture?we.texSubImage2D(we.TEXTURE_2D,a,h,f,s,o,g,v,m.data):e.isCompressedTexture?we.compressedTexSubImage2D(we.TEXTURE_2D,a,h,f,m.width,m.height,g,m.data):we.texSubImage2D(we.TEXTURE_2D,a,h,f,s,o,g,v,m);we.pixelStorei(we.UNPACK_ROW_LENGTH,x),we.pixelStorei(we.UNPACK_IMAGE_HEIGHT,_),we.pixelStorei(we.UNPACK_SKIP_PIXELS,b),we.pixelStorei(we.UNPACK_SKIP_ROWS,w),we.pixelStorei(we.UNPACK_SKIP_IMAGES,S),0===a&&t.generateMipmaps&&we.generateMipmap(y),J.unbindTexture()},this.initRenderTarget=function(e){void 0===te.get(e).__webglFramebuffer&&ne.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?ne.setTextureCube(e,0):e.isData3DTexture?ne.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?ne.setTexture2DArray(e,0):ne.setTexture2D(e,0),J.unbindTexture()},this.resetState=function(){M=0,E=0,T=null,J.reset(),_e.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Cc}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=ru._getDrawingBufferColorSpace(e),t.unpackColorSpace=ru._getUnpackColorSpace()}}const vg=["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"];const yg=new qu,xg=new qu,_g={x:"XYZ",y:"YXZ",z:"ZXY"};function bg(e,t,n,i,r,a){yg.copy(n),null!=r&&yg.premultiply(xg.copy(r).invert());const s=new Kc,o=new Yc,l=new Kc;let c;yg.decompose(s,o,l),Ig(s,i.initialTargetPosition,a.translate??!0);const u=a.rotate??!0;if(!1===u)o.copy(i.initialTargetQuaternion),c=i.initialTargetRotation.clone();else if(Array.isArray(u)||!0===u||"string"!=typeof u&&!Array.isArray(u)&&!0===u.x&&!0===u.y&&!0===u.z)c=(new id).setFromQuaternion(o,i.initialTargetRotation.order);else if("string"==typeof u){const e=_g[u];c=(new id).setFromQuaternion(o,e);for(const t of e){const e=t.toLowerCase();e!==u&&(c[e]=0)}c.order=i.initialTargetRotation.order,o.setFromEuler(c)}else c=function(e,t,n){let i="",r="";for(const e of t.order)!1===n[e.toLowerCase()]?r+=e:i+=e;const a=i+r,s=(new id).setFromQuaternion(e,a);for(const e of a){const i=e.toLowerCase();s[i]=Dg(i,s[i],t[i],n)}return e.setFromEuler(s),s}(o,i.initialTargetRotation,u);return"object"==typeof a.scale&&a.scale.uniform||Ig(l,i.initialTargetScale,a.scale??!0),{pointerAmount:t,position:s,quaternion:o,rotation:c,scale:l,time:e}}const wg=new Vh,Sg=new Kc,Mg=new Kc,Eg=new Kc,Tg=new Yc;function Ag(e,t,n){return wg.normal.copy(e),wg.constant=0,function(e,t){if(0===t.x)return void e.set(1,0,0);if(0===t.y)return void e.set(0,1,0);if(0===t.z)return void e.set(0,0,1);e.set(-t.y,t.x,0)}(Sg,wg.normal),Mg.copy(Sg),Mg.applyQuaternion(Tg.copy(t).invert().premultiply(n)),wg.projectPoint(Sg,Sg).normalize(),wg.projectPoint(Mg,Mg).normalize(),(Eg.crossVectors(Sg,wg.normal).dot(Mg)<0?1:-1)*Sg.angleTo(Mg)}const Rg=new Kc,Cg=new Vh,Pg=new Kc,Lg=new Kc;function Ig(e,t,n){if(Array.isArray(n))switch(n.length){case 0:return void e.copy(t);case 1:return e.sub(t),Yg(e,n[0]instanceof Kc?n[0]:Rg.fromArray(n[0])),void e.add(t);case 2:return Rg.crossVectors(n[0]instanceof Kc?n[0]:Pg.fromArray(n[0]),n[1]instanceof Kc?n[1]:Lg.fromArray(n[1])),Cg.setFromNormalAndCoplanarPoint(Rg,t),void Cg.projectPoint(e,e)}else e.x=Dg("x",e.x,t.x,n),e.y=Dg("y",e.y,t.y,n),e.z=Dg("z",e.z,t.z,n)}function Dg(e,t,n,i){if("boolean"==typeof i)return i?t:n;if("string"==typeof i)return i===e?t:n;const r=i[e];return!1===r?n:Array.isArray(r)?function(e,t,n){return Math.max(t,Math.min(n,e))}(t,...r):t}function Ng(e=!0,t,n,i,r,a){if(e){switch(t.length){case 0:case 3:return;case 1:return void function(e,t,n,i,r){const a=null==r?0:1-Math.abs(t.dot(r));if(null==r||a<.001)return void $g(i,e,t);qg.subVectors(n,e);const s=t.dot(r),o=t.dot(qg),l=r.dot(qg),c=1-s*s,u=(o-s*l)/c;if((s*o-l)/c<0)return void $g(i,e,t);qg.copy(i),i.copy(e).addScaledVector(t,u)}(n,...t,i,r,a);case 2:return void function(e,t,n,i,r,a){Xg.crossVectors(e,t).normalize(),Wg.setFromNormalAndCoplanarPoint(Xg,n);const s=null==a?0:Math.abs(Xg.dot(a));if(null==a||s<.01)return void Wg.projectPoint(r,r);const o=Wg.distanceToPoint(i),l=-o/a.dot(Wg.normal);if(l<0)return void Wg.projectPoint(r,r);qg.copy(r),r.copy(i).addScaledVector(a,l)}(...t,n,i,r,a)}throw new Error(`space cannot be ${t.length}D but received (${t.map(e=>e.toArray().join("/")).join("; ")})`)}}const Og={x:new Kc(1,0,0),y:new Kc(0,1,0),z:new Kc(0,0,1)};function kg(e,t,n,i,r){if(!1!==i){if(!0===i)return e[0]=Og.x,e[1]=Og.y,void(e[2]=Og.z);if("string"!=typeof i)if(Array.isArray(i))for(const a of i)Hg(e,t,n,a,r);else!1!==i.x&&Hg(e,t,n,"x",r),!1!==i.y&&Hg(e,t,n,"y",r),!1!==i.z&&Hg(e,t,n,"z",r);else Hg(e,t,n,i,r)}}const Ug=new Yc,Fg=new id,zg=new Kc,Bg=new Kc,Vg=new Kc;function Hg(e,t,n,i,r){if(Array.isArray(i)?zg.set(...i):i instanceof Kc?zg.copy(i):zg.copy(Og[i]),"translate"===r)return zg.applyQuaternion(t),void jg(e,zg);if("scale"===r)return Array.isArray(i)?Ug.identity():Ug.setFromEuler(n),Ug.premultiply(t),zg.applyQuaternion(Ug),void jg(e,zg);if(Array.isArray(i))Fg.set(0,0,0);else{Fg.copy(n);for(let e=2;e>=0;e--){const t=n.order[e].toLowerCase();if(Fg[t]=0,t===i)break}}Ug.setFromEuler(Fg).premultiply(t),zg.normalize(),Bg.set(0,1,0),zg.dot(Bg)>.99&&Bg.set(0,0,1),Vg.crossVectors(zg,Bg).normalize(),Bg.copy(Vg),Vg.applyQuaternion(Ug),jg(e,Vg),Vg.crossVectors(zg,Bg).normalize(),Vg.applyQuaternion(Ug),jg(e,Vg)}const Gg=new Kc;function jg(e,t){3!==e.length&&(0!==e.length?1!==e.length?(Gg.crossVectors(e[0],e[1]),Math.abs(Gg.dot(t))<.001||e.push(t.clone())):Math.abs(e[0].dot(t))<.999&&e.push(t.clone()):e.push(t.clone()))}const Wg=new Vh,Xg=new Kc,qg=new Kc;function $g(e,t,n){e.sub(t),Yg(e,n),e.add(t)}function Yg(e,t){const n=e.dot(t);e.copy(t).multiplyScalar(n)}const Kg=new qu,Zg=new qu,Qg=new Kc,Jg=new Kc,ev=new Yc,tv=new Kc(1,1,1),nv=[];const iv=new Kc,rv=new Kc,av=new Kc,sv=new Kc,ov=new Kc,lv=new Kc,cv=new Kc,uv=new qu,dv=new qu,hv=new qu,fv=new Yc,pv=new Yc,mv=[];const gv=new Kc,vv=new Kc,yv=new Kc,xv=new Kc,_v=new Kc,bv=new Yc,wv=new Yc,Sv=new qu,Mv=new Kc,Ev=[];class Tv{t1;t2;_position;_quaternion;_rotation;_scale;constructor(e,t){this.t1=e,this.t2=t}get time(){return this.t1.time-this.t2.time}get position(){return this._position??=this.t1.position.clone().sub(this.t2.position)}get quaternion(){return this._quaternion??=this.t2.quaternion.clone().invert().premultiply(this.t1.quaternion)}get rotation(){return this._rotation??=(new id).setFromQuaternion(this.quaternion)}get scale(){return this._scale??=this.t1.scale.clone().sub(this.t2.scale)}}class Av{cancel;previous;memo;event;initial;current;first;last;_delta;_offset;constructor(e){this.cancel=e}start(e,t){this.event=e,this.previous=void 0,this.current=t,this.initial=t,this.first=!0,this.last=!1,this.memo=void 0,this._delta=void 0,this._offset=void 0}update(e,t){this.event=e,this.previous=this.current,this.current=t,this.first=!1,this.last=!1,this._delta=void 0,this._offset=void 0}end(e){this.event=e,this.first=!1,this.last=!0,this._delta=void 0,this._offset=void 0}get delta(){if(null!=this.previous)return this._delta??=new Tv(this.current,this.previous)}get offset(){return this._offset??=new Tv(this.current,this.initial)}}function Rv(e,t){if("sphere"===e.details.type)return!1;if("lines"===e.details.type){const{line:n}=e.details;return t.copy(n.end).sub(n.start).normalize(),!0}return"screen-ray"===e.details.type?(t.copy(e.details.direction),!0):(t.set(0,0,-1).applyQuaternion(e.pointerQuaternion),!0)}const Cv=new Kc;class Pv{target;getOptions;outputState;latestMoveEvent;inputState=new Map;capturedObjects=new Map;initialTargetPosition=new Kc;initialTargetQuaternion=new Yc;initialTargetRotation=new id;initialTargetScale=new Kc;initialTargetParentWorldMatrix;prevTwoPointerDeltaRotation;prevTranslateAsDeltaRotation;prevAngle;handlers={onPointerDown:this.onPointerDown.bind(this),onPointerMove:this.onPointerMove.bind(this),onPointerUp:this.onPointerUp.bind(this)};constructor(e,t=()=>({})){this.target=e,this.getOptions=t,this.outputState=new Av(this.cancel.bind(this))}firstOnPointer(e){const t=this.getTarget();if(null==t)return;const n=Rv(e,Cv)?Cv.clone():void 0;e.intersection.details.type,this.inputState.set(e.pointerId,{pointerWorldDirection:n,pointerWorldPoint:e.point,pointerWorldOrigin:e.pointerPosition,pointerWorldQuaternion:e.pointerQuaternion,initialPointerWorldPoint:e.point.clone(),initialPointerWorldDirection:n?.clone(),initialPointerWorldQuaternion:e.pointerQuaternion.clone(),prevPointerWorldQuaternion:e.pointerQuaternion}),this.save(),1===this.inputState.size&&this.outputState.start(e,{pointerAmount:1,time:e.timeStamp,position:this.initialTargetPosition.clone(),quaternion:this.initialTargetQuaternion.clone(),rotation:this.initialTargetRotation.clone(),scale:this.initialTargetScale.clone()}),this.outputState.memo=this.apply(t)}onPointerDown(e){!1!==this.getOptions().filter?.(e)&&(this.stopPropagation(e),this.capturePointer(e.pointerId,e.object)&&this.firstOnPointer(e))}onPointerMove(e){if(!this.capturedObjects.has(e.pointerId))return;this.stopPropagation(e);const t=this.inputState.get(e.pointerId);null!=t?(this.latestMoveEvent=e,t.pointerWorldPoint=e.point,t.prevPointerWorldQuaternion=t.pointerWorldQuaternion,t.pointerWorldQuaternion=e.pointerQuaternion,t.pointerWorldOrigin=e.pointerPosition,null!=t.pointerWorldDirection&&Rv(e,t.pointerWorldDirection)):this.firstOnPointer(e)}cancel(){if(0===this.capturedObjects.size)return;for(const[e,t]of this.capturedObjects)t.releasePointerCapture(e);this.capturedObjects.clear(),this.inputState.clear(),this.outputState.end(void 0);const e=this.getTarget();null!=e&&this.apply(e)}onPointerUp(e){this.capturedObjects.has(e.pointerId)&&(this.stopPropagation(e),this.releasePointer(e.pointerId,e.object,e))}update(e){const t=this.getTarget();if(null==t||0===this.inputState.size||null==this.latestMoveEvent&&!1===(this.getOptions().alwaysUpdate??!1))return;const n=this.getOptions();let i;if("as-rotate"===n.translate||"as-rotate-and-scale"===n.translate||"as-scale"===n.translate){n.translate,this.prevTwoPointerDeltaRotation=void 0,this.prevAngle=void 0;const[r]=this.inputState.values(),a=t.matrixWorld,s=t.parent?.matrixWorld;i=function(e,t,n,i,r,a){if(null==r?bv.identity():r.decompose(gv,bv,vv),Ev.length=0,"as-scale"===a.translate&&kg(Ev,bv,n.initialTargetRotation,a.scale??!0,"scale"),"as-scale"!=a.translate&&kg(Ev,bv,n.initialTargetRotation,a.rotate??!0,"rotate"),Sv.makeTranslation(n.initialTargetPosition),null!=n.initialTargetParentWorldMatrix&&Sv.premultiply(n.initialTargetParentWorldMatrix),xv.setFromMatrixPosition(Sv),Ng(a.projectRays,Ev,t.initialPointerWorldPoint,t.pointerWorldOrigin,xv,void 0),xv.negate().add(t.initialPointerWorldPoint),_v.setFromMatrixPosition(i),Ng(a.projectRays,Ev,t.initialPointerWorldPoint,t.pointerWorldOrigin,_v,void 0),Ng(a.projectRays,Ev,t.initialPointerWorldPoint,t.pointerWorldOrigin,vv.copy(t.pointerWorldPoint),t.pointerWorldDirection),_v.negate().add(vv),"as-scale"===a.translate?bv.copy(n.initialTargetQuaternion):(gv.copy(xv),null!=n.prevTranslateAsDeltaRotation&&gv.applyQuaternion(n.prevTranslateAsDeltaRotation),gv.normalize(),vv.copy(_v).normalize(),bv.setFromUnitVectors(gv,vv),null==n.prevTranslateAsDeltaRotation?n.prevTranslateAsDeltaRotation=new Yc:bv.multiply(n.prevTranslateAsDeltaRotation),n.prevTranslateAsDeltaRotation.copy(bv),null!=n.initialTargetParentWorldMatrix&&(wv.setFromRotationMatrix(n.initialTargetParentWorldMatrix),bv.multiply(wv.normalize()),bv.premultiply(wv.invert())),bv.multiply(n.initialTargetQuaternion)),"as-rotate"===a.translate)Mv.set(1,1,1);else if("object"==typeof a.scale&&a.scale.uniform)Mv.setScalar(_v.length()/xv.length());else if("as-rotate-and-scale"===a.translate){Sv.compose(n.initialTargetPosition,n.initialTargetQuaternion,n.initialTargetScale),null!=n.initialTargetParentWorldMatrix&&Sv.premultiply(n.initialTargetParentWorldMatrix),Sv.decompose(vv,wv,yv),gv.copy(xv).applyQuaternion(wv.invert()).divide(yv),gv.x=Math.abs(gv.x),gv.y=Math.abs(gv.y),gv.z=Math.abs(gv.z);const e=Math.max(...gv.toArray());gv.divideScalar(e),Mv.set(1,1,1),Mv.addScaledVector(gv,_v.length()/xv.length()-1)}else null!=n.initialTargetParentWorldMatrix?(n.initialTargetParentWorldMatrix.decompose(gv,wv,vv),wv.multiply(n.initialTargetQuaternion)):wv.copy(n.initialTargetQuaternion),gv.copy(xv).applyQuaternion(wv.invert()),null!=r?(r.decompose(vv,wv,yv),wv.multiply(n.initialTargetQuaternion)):wv.copy(n.initialTargetQuaternion),vv.copy(_v).applyQuaternion(wv.invert()),Mv.x=Math.abs(gv.x)<.001?1:Math.abs(vv.x/gv.x),Mv.y=Math.abs(gv.y)<.001?1:Math.abs(vv.y/gv.y),Mv.z=Math.abs(gv.z)<.001?1:Math.abs(vv.z/gv.z);return Mv.multiply(n.initialTargetScale),Sv.compose(n.initialTargetPosition,bv,Mv),bg(e,1,Sv,n,void 0,a)}(e,r,this,a,s,n)}else if(1===this.inputState.size){this.prevTwoPointerDeltaRotation=void 0,this.prevAngle=void 0,this.prevTranslateAsDeltaRotation=void 0;const[r]=this.inputState.values();i=function(e,t,n,i,r){return null==i?ev.identity():i.decompose(Qg,ev,Jg),nv.length=0,kg(nv,ev,n.initialTargetRotation,r.translate??!0,"translate"),Zg.makeRotationFromQuaternion(ev.copy(t.initialPointerWorldQuaternion).invert()).multiply(Kg.makeTranslation(Qg.copy(t.initialPointerWorldPoint).negate())),null!=n.initialTargetParentWorldMatrix&&Zg.multiply(n.initialTargetParentWorldMatrix),Ng(r.projectRays,nv,t.initialPointerWorldPoint,t.pointerWorldOrigin,Qg.copy(t.pointerWorldPoint),t.pointerWorldDirection),ev.copy(t.pointerWorldQuaternion),!1===(r.rotate??!0)&&ev.copy(t.initialPointerWorldQuaternion),Kg.compose(Qg,ev,tv).multiply(Zg).multiply(Zg.compose(n.initialTargetPosition,n.initialTargetQuaternion,n.initialTargetScale)),bg(e,1,Kg,n,i,r)}(e,r,this,t.parent?.matrixWorld,n)}else{this.prevTranslateAsDeltaRotation=void 0;const[r,a]=this.inputState.values();i=function(e,t,n,i,r,a){null==r?fv.identity():r.decompose(av,fv,sv),mv.length=0,kg(mv,fv,i.initialTargetRotation,a.translate??!0,"translate"),kg(mv,fv,i.initialTargetRotation,a.rotate??!0,"rotate"),kg(mv,fv,i.initialTargetRotation,a.scale??!0,"scale"),Ng(a.projectRays,mv,t.initialPointerWorldPoint,t.pointerWorldOrigin,av.copy(t.pointerWorldPoint),t.pointerWorldDirection),Ng(a.projectRays,mv,n.initialPointerWorldPoint,n.pointerWorldOrigin,sv.copy(n.pointerWorldPoint),n.pointerWorldDirection),iv.copy(n.initialPointerWorldPoint).sub(t.initialPointerWorldPoint),rv.copy(sv).sub(av),av.copy(iv),null!=i.prevTwoPointerDeltaRotation&&av.applyQuaternion(i.prevTwoPointerDeltaRotation),av.normalize(),sv.copy(rv).normalize(),fv.setFromUnitVectors(av,sv),null==i.prevTwoPointerDeltaRotation?i.prevTwoPointerDeltaRotation=new Yc:fv.multiply(i.prevTwoPointerDeltaRotation),i.prevTwoPointerDeltaRotation.copy(fv);const s=.5*(Ag(sv,t.prevPointerWorldQuaternion,t.pointerWorldQuaternion)+Ag(sv,n.prevPointerWorldQuaternion,n.pointerWorldQuaternion))+(i.prevAngle??0);if(i.prevAngle=s,fv.premultiply(pv.setFromAxisAngle(sv,s)),hv.compose(i.initialTargetPosition,i.initialTargetQuaternion,i.initialTargetScale),null!=i.initialTargetParentWorldMatrix&&hv.premultiply(i.initialTargetParentWorldMatrix),"object"==typeof a.scale&&a.scale.uniform)cv.setScalar(rv.length()/iv.length());else{hv.decompose(ov,pv,lv),av.copy(iv).applyQuaternion(pv.invert()).divide(lv),av.x=Math.abs(av.x),av.y=Math.abs(av.y),av.z=Math.abs(av.z);const e=Math.max(...av.toArray());av.divideScalar(e),cv.set(1,1,1),cv.addScaledVector(av,rv.length()/iv.length()-1)}return uv.makeTranslation(av.copy(rv).multiplyScalar(.5).add(t.pointerWorldPoint)).multiply(dv.makeRotationFromQuaternion(fv)).multiply(dv.makeRotationFromQuaternion(pv.invert())).multiply(dv.makeScale(cv.x,cv.y,cv.z)).multiply(dv.makeRotationFromQuaternion(pv.invert())).multiply(dv.makeTranslation(av.copy(iv).multiplyScalar(.5).add(t.initialPointerWorldPoint).negate())).multiply(hv),bg(e,2,uv,i,r,a)}(e,r,a,this,t.parent?.matrixWorld,n)}this.outputState.update(this.latestMoveEvent,i),this.outputState.memo=this.apply(t),this.latestMoveEvent=void 0}getTarget(){return this.target instanceof _d?this.target:this.target?.current}capturePointer(e,t){if(this.capturedObjects.has(e))return!1;const{multitouch:n,translate:i}=this.getOptions();return(!1!==(n??!0)&&"string"!=typeof i||1!==this.capturedObjects.size)&&(this.capturedObjects.set(e,t),t.setPointerCapture(e),!0)}releasePointer(e,t,n){const i=this.getTarget();null!=i&&this.capturedObjects.delete(e)&&(this.inputState.delete(e),t.releasePointerCapture(e),this.inputState.size>0?this.save():(this.outputState.end(n),this.apply(i)))}stopPropagation(e){null!=e&&(this.getOptions()?.stopPropagation??1)&&e.stopPropagation()}apply(e){return(this.getOptions().apply??Iv)(this.outputState,e)}getState(){return 0===this.inputState.size?void 0:this.outputState}save(){const e=this.getTarget();if(null!=e){e.updateWorldMatrix(!0,!1),this.prevAngle=void 0,this.prevTwoPointerDeltaRotation=void 0,this.prevTranslateAsDeltaRotation=void 0,this.initialTargetParentWorldMatrix=e.parent?.matrixWorld.clone(),e.matrixAutoUpdate?(this.initialTargetPosition.copy(e.position),this.initialTargetQuaternion.copy(e.quaternion),this.initialTargetRotation.copy(e.rotation),this.initialTargetScale.copy(e.scale)):(e.matrix.decompose(this.initialTargetPosition,this.initialTargetQuaternion,this.initialTargetScale),this.initialTargetRotation.setFromQuaternion(this.initialTargetQuaternion,e.rotation.order));for(const e of this.inputState.values())null!=e.pointerWorldDirection&&e.initialPointerWorldDirection?.copy(e.pointerWorldDirection),e.initialPointerWorldPoint.copy(e.pointerWorldPoint),e.initialPointerWorldQuaternion.copy(e.pointerWorldQuaternion)}}bind(e){const{onPointerDown:t,onPointerMove:n,onPointerUp:i}=this.handlers;return e.addEventListener("pointerdown",t),e.addEventListener("pointermove",n),e.addEventListener("pointerup",i),()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointermove",n),e.removeEventListener("pointerup",i),this.cancel()}}capture(e,t){return this.capturePointer(e,t)?()=>this.releasePointer(e,t,void 0):Lv}}function Lv(){}function Iv(e,t){t.position.copy(e.current.position),t.rotation.order=e.current.rotation.order,t.quaternion.copy(e.current.quaternion),t.scale.copy(e.current.scale)}class Dv{target;getOptions;handles=[];hoveredTagMap=new Map;hoverSubscriptions=[];applySubscriptions=[];space;constructor(e,t){this.target=e,this.getOptions=t}getSpace(){return this.space??"world"}getTarget(){return this.target instanceof _d?this.target:this.target.current}getHandleOptions(e,t){const n=this.getOptions?.(),i=t?.();return{...n,...i,apply:(t,r)=>(this.onApply(e,t,r),(i?.apply??n?.apply??Iv)?.(t,r))}}registerHandle(e,t,n){const i={object:t,store:e,tag:n};this.handles.push(i);const r=e.bind(t),a=this.onPointerEnter.bind(this,n),s=this.onPointerLeave.bind(this);return t.addEventListener("pointerenter",a),t.addEventListener("pointerleave",s),()=>{const t=this.handles.indexOf(i);-1!=t&&this.handles.splice(t,1),r(),e.cancel()}}subscribeHover(e){return this.hoverSubscriptions.push(e),e(Array.from(this.hoveredTagMap.values())),()=>{const t=this.hoverSubscriptions.indexOf(e);-1!==t&&this.hoverSubscriptions.splice(t,1)}}subscribeApply(e){return this.applySubscriptions.push(e),()=>{const t=this.applySubscriptions.indexOf(e);-1!==t&&this.applySubscriptions.splice(t,1)}}update(e){for(const{store:t}of this.handles)t.update(e)}onPointerEnter(e,t){this.hoveredTagMap.set(t.pointerId,e),this.updateHover()}onPointerLeave(e){this.hoveredTagMap.delete(e.pointerId),this.updateHover()}updateHover(){const e=Array.from(this.hoveredTagMap.values());for(const t of this.hoverSubscriptions)t(e)}onApply(e,t,n){for(const i of this.applySubscriptions)i(e,t,n)}}const Nv={depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0};function Ov(e,t,n,{color:i,hoverColor:r,hoverOpacity:a,opacity:s,disabled:o=!1}){return null==r&&null==a||o?(t.color.set(i),t.opacity=s??1,void(o&&(t.opacity*=.5,t.color.lerp(new zd(1,1,1),.5)))):(r??=i,e.subscribeHover(e=>{const o=e.some(e=>e.includes(n));t.color.set(o?r:i),t.opacity=(o?a:s)??1}))}const kv=new Yc,Uv=new rh;Uv.setAttribute("position",new Kd([-1e3,0,0,1e3,0,0],3));class Fv extends af{context;rotationOffset;constructor(e,t){super(Uv),this.context=e,this.rotationOffset=t,this.renderOrder=1/0}update(){this.quaternion.setFromEuler(this.rotationOffset);const e=this.context.getTarget();"world"===this.context.getSpace()&&null!=e&&(e.getWorldQuaternion(kv).invert(),this.quaternion.premultiply(kv))}bind(e){this.material=new Xh({...Nv,color:this.material.color??"white",opacity:this.material.opacity??1});const t=this.context.subscribeHover(t=>{const n=t.some(t=>t.includes(e));this.visible=n}),n=this.context.subscribeApply((e,t)=>{if(t.last)return void this.position.set(0,0,0);this.position.copy(t.initial.position).sub(t.current.position);const n=this.context.getTarget();null!=n&&(kv.copy(n.quaternion).invert(),this.position.applyQuaternion(kv))});return()=>{this.material.dispose(),t(),n()}}}class zv extends Dh{context;axis;store;options;tag;constructor(e,t,n,i){super(),this.context=e,this.axis=t,this.tag=(n??"")+t,this.store=new Pv(e.target,()=>e.getHandleOptions(this.tag,i))}}function Bv(e,t=!0){if(!1===t)return{options:!1,disabled:!0};if(!0===t){const t={x:!1,y:!1,z:!1,e:!1};for(const n of e)t[n]=!0;return{options:t,disabled:!1}}if("disabled"===t)return{options:{x:!0,y:!0,z:!0,e:!0},disabled:!0};if("string"==typeof t)return{options:t===e&&{x:!1,y:!1,z:!1,e:!1,[e]:!0},disabled:!1};const n={x:!1,y:!1,z:!1,e:!1};let i=!1;for(const r of e){let e=t[r]??!0;if(!1===e)return{options:!1,disabled:!0};"disabled"===e&&(i=!0,e=!0),n[r]=e}return{options:n,disabled:i}}const Vv=new Kc,Hv=new Kc;function Gv(e,t,n,i){if(!n)return i;let r;return t instanceof yf?r=(t.top-t.bottom)/t.zoom:(t.getWorldPosition(Vv),e.getWorldPosition(Hv),r=Vv.distanceTo(Hv)*Math.min(1.9*Math.tan(Math.PI*t.fov/360)/t.zoom,7)),r*i/4}const jv=new lf(0,.04,.1,12);jv.translate(0,.05,0);const Wv=new lf(.0075,.0075,.5,3);Wv.translate(0,.25,0);const Xv=new id(0,0,-Math.PI/2),qv=new id(0,0,Math.PI/2);class $v extends zv{invert;showArrowBody;constructor(e,t,n="",i,r=!1,a=!0){super(e,t,n,()=>({scale:!1,rotate:!1,translate:null!=i?[i]:this.options,multitouch:!1})),this.invert=r,this.showArrowBody=a}bind(e,t,n){const{options:i,disabled:r}=Bv(this.axis,n);if(!1===i)return;this.options=i;const a=this.invert?qv:Xv,s=new Gd(Nv),o=Ov(this.context,s,this.tag,{color:e,hoverColor:t,disabled:r}),l=new gh(jv,s);let c,u;if(l.renderOrder=1/0,l.position.x=this.invert?-.5:.5,l.rotation.copy(a),this.add(l),this.showArrowBody){const t=new Gd(Nv);c=Ov(this.context,t,this.tag,{color:e,hoverColor:16777024,disabled:r}),u=new gh(Wv,t),u.renderOrder=1/0,u.rotation.copy(a),this.add(u)}const d=new gh(new lf(.13,0,.6,4));d.pointerEventsOrder=1/0,d.position.x=this.invert?-.3:.3,d.rotation.copy(a),d.visible=!1,this.add(d);const h=r?void 0:this.context.registerHandle(this.store,d,this.tag);return()=>{s.dispose(),h?.(),o?.(),c?.(),this.remove(l),null!=u&&this.remove(u),this.remove(d)}}}class Yv extends zv{constructor(e,t,n="",i){super(e,t,n,()=>({translate:i??this.options,scale:!1,rotate:!1,multitouch:!1}))}bind(e,t,n){const{options:i,disabled:r}=Bv(this.axis,n);if(!1===i)return;this.options=i;const a=new Gd(Nv),s=Ov(this.context,a,this.tag,{opacity:.5,hoverOpacity:1,color:e,hoverColor:t,disabled:r}),o=new gh(new yh(.2,.2,.01),a);o.renderOrder=1/0,o.pointerEventsOrder=1/0,o.position.set(.15,.15,0);const l=r?void 0:this.context.registerHandle(this.store,o,this.tag);return this.add(o),()=>{a.dispose(),o.geometry.dispose(),l?.(),s?.(),this.remove(o)}}}new Kc;const Kv=new Yc;class Zv extends zv{constructor(e){super(e,"xyz","",()=>({translate:this.options,scale:!1,rotate:!1,multitouch:!1}))}bind(e){const{options:t,disabled:n}=Bv(this.axis,e);if(!1===t)return;this.options=t;const i=new Gd(Nv),r=Ov(this.context,i,this.tag,{color:16777215,hoverColor:16776960,opacity:.25,hoverOpacity:1,disabled:n}),a=new gh(new uf(.1,0),i);a.renderOrder=1/0,this.add(a);const s=new gh(new uf(.2,0));s.pointerEventsOrder=1/0,s.visible=!1,this.add(s);const o=n?void 0:this.context.registerHandle(this.store,s,this.tag);return()=>{i.dispose(),a.geometry.dispose(),s.geometry.dispose(),o?.(),r?.(),this.remove(a),this.remove(s)}}}const Qv=new Kc,Jv=new Yc,ey=new Yc,ty=(new Yc).setFromEuler(new id(0,0,Math.PI/2)),ny=(new Yc).setFromEuler(new id(0,-Math.PI/2,0)),iy=new Yc,ry=(new Yc).setFromEuler(new id(0,-Math.PI/2,0)),ay=(new Yc).setFromEuler(new id(Math.PI/2,0,0));class sy extends Dh{context;size;fixed;free;translationX;translationY;translationZ;translationNegX;translationNegY;translationNegZ;translationXY;translationYZ;translationXZ;scaleGroup=new Dh;xAxis=new Kc;yAxis=new Kc;zAxis=new Kc;negXAxis=new Kc;negYAxis=new Kc;negZAxis=new Kc;constructor(e,t,n){super(),this.context=e,this.size=t,this.fixed=n,this.add(this.scaleGroup),this.free=new Zv(this.context),this.scaleGroup.add(this.free),this.translationX=new $v(this.context,"x",void 0,this.xAxis),this.scaleGroup.add(this.translationX),this.translationY=new $v(this.context,"y",void 0,this.yAxis),this.scaleGroup.add(this.translationY),this.translationZ=new $v(this.context,"z",void 0,this.zAxis),this.scaleGroup.add(this.translationZ),this.translationNegX=new $v(this.context,"x",void 0,this.negXAxis,!0,!1),this.scaleGroup.add(this.translationNegX),this.translationNegY=new $v(this.context,"y",void 0,this.negYAxis,!0,!1),this.scaleGroup.add(this.translationNegY),this.translationNegZ=new $v(this.context,"z",void 0,this.negZAxis,!0,!1),this.scaleGroup.add(this.translationNegZ),this.translationXY=new Yv(this.context,"xy",void 0,[this.xAxis,this.yAxis]),this.scaleGroup.add(this.translationXY),this.translationXZ=new Yv(this.context,"xz",void 0,[this.xAxis,this.zAxis]),this.scaleGroup.add(this.translationXZ),this.translationYZ=new Yv(this.context,"yz",void 0,[this.yAxis,this.zAxis]),this.scaleGroup.add(this.translationYZ)}update(e){this.updateWorldMatrix(!0,!1),this.xAxis.set(1,0,0),this.yAxis.set(0,1,0),this.zAxis.set(0,0,1),this.free.quaternion.identity(),this.translationX.quaternion.copy(ey),this.translationY.quaternion.copy(ty),this.translationZ.quaternion.copy(ny),this.translationNegX.quaternion.copy(ey),this.translationNegY.quaternion.copy(ty),this.translationNegZ.quaternion.copy(ny),this.translationXY.quaternion.copy(iy),this.translationYZ.quaternion.copy(ry),this.translationXZ.quaternion.copy(ay);const t=this.context.getSpace(),n=this.context.getTarget();"world"==t&&null!=n?(n.getWorldQuaternion(Jv).invert(),this.free.quaternion.premultiply(Jv),this.translationX.quaternion.premultiply(Jv),this.translationY.quaternion.premultiply(Jv),this.translationZ.quaternion.premultiply(Jv),this.translationNegX.quaternion.premultiply(Jv),this.translationNegY.quaternion.premultiply(Jv),this.translationNegZ.quaternion.premultiply(Jv),this.translationXY.quaternion.premultiply(Jv),this.translationYZ.quaternion.premultiply(Jv),this.translationXZ.quaternion.premultiply(Jv),null!=n.parent&&(n.parent.getWorldQuaternion(Jv).invert(),this.xAxis.applyQuaternion(Jv),this.yAxis.applyQuaternion(Jv),this.zAxis.applyQuaternion(Jv))):null!=n&&(this.xAxis.applyQuaternion(n.quaternion),this.yAxis.applyQuaternion(n.quaternion),this.zAxis.applyQuaternion(n.quaternion)),this.negXAxis.copy(this.xAxis).negate(),this.negYAxis.copy(this.yAxis).negate(),this.negZAxis.copy(this.zAxis).negate(),this.scaleGroup.scale.setScalar(1),null!=n&&(n.getWorldScale(Qv),this.scaleGroup.scale.divide(Qv)),this.scaleGroup.scale.multiplyScalar(Gv(this,e,this.fixed??!0,this.size??1))}bind(e){const t=function(e,t){const n=new gh(new uf(.01,2),new Gd(Nv));n.renderOrder=1/0,n.visible=!1,e.add(n);const i=new gh(new uf(.01,2),new Gd(Nv));i.renderOrder=1/0,i.visible=!1,e.add(i);const r=new rh;r.setAttribute("position",new Kd([0,0,0,1,1,1],3));const a=new af(r,new Xh(Nv));a.renderOrder=1/0,a.visible=!1,e.add(a);const s=t.subscribeApply((e,r)=>{i.position.set(0,0,0),n.position.copy(r.initial.position).sub(r.current.position);const s=t.getTarget();null!=s&&(Kv.copy(s.quaternion).invert(),n.position.applyQuaternion(Kv)),a.position.set(0,0,0),a.scale.copy(n.position),n.visible=!r.last,a.visible=!r.last,i.visible=!r.last});return()=>{n.geometry.dispose(),n.material.dispose(),i.geometry.dispose(),i.material.dispose(),a.geometry.dispose(),a.material.dispose(),e.remove(n),e.remove(i),e.remove(a),s()}}(this,this.context),n=this.translationX.bind(16711680,16776960,e),i=this.translationY.bind(65280,16776960,e),r=this.translationZ.bind(255,16776960,e),a=this.translationNegX.bind(16711680,16776960,e),s=this.translationNegY.bind(65280,16776960,e),o=this.translationNegZ.bind(255,16776960,e),l=this.translationXY.bind(255,16776960,e),c=this.translationYZ.bind(16711680,16776960,e),u=this.translationXZ.bind(65280,16776960,e),d=this.free.bind(e);return()=>{t(),n?.(),i?.(),r?.(),a?.(),s?.(),o?.(),l?.(),c?.(),u?.(),d?.()}}}const oy=new id(0,0,-Math.PI/2),ly=new id(0,0,Math.PI/2);class cy extends zv{invert;showHandleLine;constructor(e,t,n="",i=!1,r=!0){super(e,t,n,()=>({scale:this.options,rotate:!1,translate:"as-scale",multitouch:!1})),this.invert=i,this.showHandleLine=r}bind(e,t,n){const{options:i,disabled:r}=Bv(this.axis,n);if(!1===i)return;this.options=i;const a=this.invert?ly:oy,s=new Dh;s.position.x=this.invert?-.5:.5,s.rotation.copy(a),this.add(s);const o=new Gd(Nv),l=Ov(this.context,o,this.tag,{color:e,hoverColor:t,disabled:r}),c=new gh(new yh(.08,.08,.08),o);let u,d,h;if(c.renderOrder=1/0,c.rotation.copy(a),s.add(c),this.showHandleLine){h=new Dh,h.rotation.copy(a),this.add(h);const n=new Gd(Nv);u=Ov(this.context,n,this.tag,{color:e,hoverColor:t,disabled:r}),d=new gh(new lf(.0075,.0075,.5,3),n),d.renderOrder=1/0,d.position.y=.25,h.add(d)}const f=new Dh;f.visible=!1,f.rotation.copy(a),f.position.x=this.invert?-.3:.3,this.add(f);const p=new gh(new lf(.2,0,.5,4));p.pointerEventsOrder=1/0,p.position.y=.04,f.add(p);const m=r?void 0:this.context.registerHandle(this.store,p,this.tag);return()=>{o.dispose(),p.geometry.dispose(),c.geometry.dispose(),d?.geometry.dispose(),m?.(),l?.(),u?.(),null!=h&&this.remove(h),this.remove(f),this.remove(s)}}}class uy extends zv{constructor(e,t,n=""){super(e,t,n,()=>({translate:"as-scale",scale:this.options,rotate:!1,multitouch:!1}))}bind(e,t,n){const{options:i,disabled:r}=Bv(this.axis,n);if(!1===i)return;this.options=i;const a=new Gd(Nv),s=Ov(this.context,a,this.tag,{opacity:.5,hoverOpacity:1,color:e,hoverColor:t,disabled:r}),o=new gh(new yh(.2,.2,.01),a);o.renderOrder=1/0,o.pointerEventsOrder=1/0,o.position.set(.15,.15,0);const l=r?void 0:this.context.registerHandle(this.store,o,this.tag);return this.add(o),()=>{a.dispose(),o.geometry.dispose(),l?.(),s?.(),this.remove(o)}}}const dy=new id(0,0,-Math.PI/2),hy=new id(0,0,Math.PI/2);class fy extends zv{actualAxis;invert;constructor(e,t="",n,i=!1){super(e,"xyz",t,()=>({scale:{uniform:!0,...this.options},rotate:!1,translate:"as-scale",multitouch:!1})),this.actualAxis=n,this.invert=i}bind(e,t,n){const{options:i,disabled:r}=Bv(this.actualAxis,n);if(!1===i)return;this.options=i;const a=this.invert?hy:dy,s=new Dh;s.position.x=this.invert?-.7:.7,s.rotation.copy(a),this.add(s);const o=new Gd(Nv),l=Ov(this.context,o,this.tag,{color:e,hoverColor:t,opacity:.5,hoverOpacity:1,disabled:r}),c=new gh(new yh(.08,.08,.08),o);c.renderOrder=1/0,c.rotation.copy(a),s.add(c);const u=new gh(new yh(.15,.15,.15),o);u.visible=!1,u.pointerEventsOrder=1/0,u.rotation.copy(a),s.add(u);const d=r?void 0:this.context.registerHandle(this.store,u,this.tag);return()=>{o.dispose(),c.geometry.dispose(),d?.(),l?.(),this.remove(s)}}}const py=new Kc;class my extends Dh{context;size;fixed;scaleX;scaleY;scaleZ;scaleNegX;scaleNegY;scaleNegZ;translationX;translationY;translationZ;translationNegX;translationNegY;translationNegZ;translationXY;translationYZ;translationXZ;constructor(e,t,n){super(),this.context=e,this.size=t,this.fixed=n,this.scaleX=new fy(this.context,void 0,"x"),this.add(this.scaleX),this.scaleY=new fy(this.context,void 0,"y"),this.scaleY.rotation.z=Math.PI/2,this.add(this.scaleY),this.scaleZ=new fy(this.context,void 0,"z"),this.scaleZ.rotation.y=-Math.PI/2,this.add(this.scaleZ),this.scaleNegX=new fy(this.context,void 0,"x",!0),this.add(this.scaleNegX),this.scaleNegY=new fy(this.context,void 0,"y",!0),this.scaleNegY.rotation.z=Math.PI/2,this.add(this.scaleNegY),this.scaleNegZ=new fy(this.context,void 0,"z",!0),this.scaleNegZ.rotation.y=-Math.PI/2,this.add(this.scaleNegZ),this.translationX=new cy(this.context,"x"),this.add(this.translationX),this.translationY=new cy(this.context,"y"),this.translationY.rotation.z=Math.PI/2,this.add(this.translationY),this.translationZ=new cy(this.context,"z"),this.translationZ.rotation.y=-Math.PI/2,this.add(this.translationZ),this.translationNegX=new cy(this.context,"x",void 0,!0,!1),this.add(this.translationNegX),this.translationNegY=new cy(this.context,"y",void 0,!0,!1),this.translationNegY.rotation.z=Math.PI/2,this.add(this.translationNegY),this.translationNegZ=new cy(this.context,"z",void 0,!0,!1),this.translationNegZ.rotation.y=-Math.PI/2,this.add(this.translationNegZ),this.translationXY=new uy(this.context,"xy"),this.add(this.translationXY),this.translationXZ=new uy(this.context,"xz"),this.translationXZ.rotation.x=Math.PI/2,this.add(this.translationXZ),this.translationYZ=new uy(this.context,"yz"),this.translationYZ.rotation.y=-Math.PI/2,this.add(this.translationYZ)}update(e){this.updateWorldMatrix(!0,!1),this.scale.setScalar(1);const t=this.context.getTarget();null!=t&&(t.getWorldScale(py),this.scale.divide(py)),this.scale.multiplyScalar(Gv(this,e,this.fixed??!0,this.size??1))}bind(e){const t=this.scaleX.bind(16777215,16776960,e),n=this.scaleY.bind(16777215,16776960,e),i=this.scaleZ.bind(16777215,16776960,e),r=this.scaleNegX.bind(16777215,16776960,e),a=this.scaleNegY.bind(16777215,16776960,e),s=this.scaleNegZ.bind(16777215,16776960,e),o=this.translationX.bind(16711680,16776960,e),l=this.translationY.bind(65280,16776960,e),c=this.translationZ.bind(255,16776960,e),u=this.translationNegX.bind(16711680,16776960,e),d=this.translationNegY.bind(65280,16776960,e),h=this.translationNegZ.bind(255,16776960,e),f=this.translationXY.bind(255,16776960,e),p=this.translationYZ.bind(16711680,16776960,e),m=this.translationXZ.bind(65280,16776960,e);return()=>{o?.(),l?.(),c?.(),u?.(),d?.(),h?.(),f?.(),p?.(),m?.(),t?.(),n?.(),i?.(),r?.(),a?.(),s?.()}}}const gy={x:{vector1:new Kc(0,0,-1),vector2:new Kc(0,-1,0),rotationOffset:new Yc,axis:[1,0,0]},y:{vector1:new Kc(0,0,-1),vector2:new Kc(-1,0,-1),rotationOffset:(new Yc).setFromEuler(new id(0,0,Math.PI/2)),axis:[0,1,0]},z:{vector1:new Kc(-1,0,0),vector2:new Kc(0,-1,0),rotationOffset:(new Yc).setFromEuler(new id(0,Math.PI/2,0)),axis:[0,0,1]}},vy=new Kc,yy=new Kc,xy=new Kc,_y=new Kc,by=new Yc;class wy extends zv{direction=new Kc(1,0,0);constructor(e,t,n=""){super(e,t,n,()=>({scale:!1,translate:"as-rotate",rotate:[this.direction],multitouch:!1}))}update(e){const{rotationOffset:t,vector1:n,vector2:i}=gy[this.axis];e.getWorldPosition(vy),this.getWorldPosition(yy).sub(vy),xy.copy(n),_y.copy(i);const r=this.context.getTarget(),a=this.context.getSpace();"local"===a&&null!=r&&(r.getWorldQuaternion(by),xy.applyQuaternion(by),_y.applyQuaternion(by)),_y.crossVectors(xy,_y);const s=yy.dot(_y);_y.multiplyScalar(s),yy.sub(_y),this.quaternion.setFromUnitVectors(xy,yy.normalize()),"local"===a&&null!=r&&(r.getWorldQuaternion(by),this.quaternion.multiply(by)),this.quaternion.multiply(t),null!=r?.parent?(r.parent.matrixWorld.decompose(vy,by,yy),by.invert(),this.quaternion.premultiply(by)):by.identity(),null==this.store.getState()&&(this.direction.fromArray(gy[this.axis].axis),this.direction.applyQuaternion("local"===a&&null!=r?r?.quaternion:by)),null!=r&&this.quaternion.premultiply(by.copy(r.quaternion).invert())}bind(e,t){const{options:n,disabled:i}=Bv(this.axis,t);if(!1===n)return;this.options=n;const r=new Gd(Nv),a=Ov(this.context,r,this.tag,{color:e,hoverColor:16776960,disabled:i}),s=new gh(Dy(.5,.5),r);s.renderOrder=1/0,this.add(s);const o=new gh(new pf(.5,.1,4,24));o.visible=!1,o.pointerEventsOrder=1/0,o.rotation.set(0,-Math.PI/2,-Math.PI/2),this.add(o);const l=i?void 0:this.context.registerHandle(this.store,o,this.tag);return()=>{r.dispose(),o.geometry.dispose(),s.geometry.dispose(),l?.(),a?.(),this.remove(o),this.remove(s)}}}const Sy=new Kc,My=new Kc,Ey=new Kc(1,0,0),Ty=new Yc;class Ay extends zv{constructor(e,t=""){super(e,"xyz",t,()=>({scale:!1,translate:"as-rotate",rotate:this.options,multitouch:!1}))}update(e){e.getWorldPosition(Sy),this.getWorldPosition(My).sub(Sy),this.quaternion.setFromUnitVectors(Ey,My.normalize());const t=this.context.getTarget();null!=t?.parent&&(t.parent.matrixWorld.decompose(Sy,Ty,My),Ty.invert(),this.quaternion.premultiply(Ty)),null!=t&&(Ty.copy(t.quaternion).invert(),this.quaternion.premultiply(Ty))}bind(e){const{options:t,disabled:n}=Bv(this.axis,e);if(!1===t)return;this.options=t;const i=new Gd(Nv),r=Ov(this.context,i,this.tag,{color:16777215,hoverColor:16776960,opacity:.25,disabled:n}),a=new gh(Dy(.5,1),i);a.renderOrder=1/0,this.add(a);const s=new gh(new ff(.25,10,8));s.visible=!1,s.pointerEventsOrder=1/0,this.add(s);const o=n?void 0:this.context.registerHandle(this.store,s,this.tag);return()=>{this.pointerEvents="none",i.dispose(),s.geometry.dispose(),a.geometry.dispose(),o?.(),r?.(),this.remove(s),this.remove(a)}}}const Ry=new Kc,Cy=new Kc,Py=new Kc(1,0,0),Ly=new Yc;class Iy extends zv{direction=new Kc(1,0,0);constructor(e,t=""){super(e,"e",t,()=>({scale:!1,translate:"as-rotate",rotate:[this.direction],multitouch:!1}))}update(e){e.getWorldPosition(Ry),this.getWorldPosition(this.direction).sub(Ry).normalize(),this.quaternion.setFromUnitVectors(Py,this.direction);const t=this.context.getTarget();null!=t?.parent&&(t.parent.matrixWorld.decompose(Ry,Ly,Cy),Ly.invert(),this.quaternion.premultiply(Ly),this.direction.applyQuaternion(Ly)),null!=t&&(Ly.copy(t.quaternion).invert(),this.quaternion.premultiply(Ly)),this.direction.negate()}bind(e){const{options:t,disabled:n}=Bv(this.axis,e);if(!1===t)return;this.options=t;const i=new Gd(Nv),r=Ov(this.context,i,this.tag,{color:16776960,hoverColor:16776960,opacity:.5,disabled:n}),a=new gh(Dy(.75,1),i);a.renderOrder=1/0,this.add(a);const s=new gh(new pf(.75,.1,2,24),new Gd({color:"white"}));s.visible=!1,s.rotation.y=Math.PI/2,s.pointerEventsOrder=1/0,this.add(s);const o=n?void 0:this.context.registerHandle(this.store,s,this.tag);return()=>{i.dispose(),s.geometry.dispose(),a.geometry.dispose(),o?.(),r?.(),this.remove(s),this.remove(a)}}}function Dy(e,t){const n=new pf(e,.0075,3,64,t*Math.PI*2);return n.rotateY(Math.PI/2),n.rotateX(Math.PI/2),n}const Ny=new Kc;class Oy extends Dh{context;fixed;size;rotationX;rotationY;rotationZ;free;screen;constructor(e,t,n){super(),this.context=e,this.fixed=t,this.size=n,this.rotationX=new wy(this.context,"x"),this.add(this.rotationX),this.rotationY=new wy(this.context,"y"),this.add(this.rotationY),this.rotationZ=new wy(this.context,"z"),this.add(this.rotationZ),this.free=new Ay(this.context),this.add(this.free),this.screen=new Iy(this.context),this.add(this.screen)}update(e){this.updateWorldMatrix(!0,!1),this.rotationX.update(e),this.rotationY.update(e),this.rotationZ.update(e),this.free.update(e),this.screen.update(e),this.scale.setScalar(1);const t=this.context.getTarget();null!=t&&(t.getWorldScale(Ny),this.scale.divide(Ny)),this.scale.multiplyScalar(Gv(this,e,this.fixed??!0,this.size??1))}bind(e){const t=this.rotationX.bind(16711680,e),n=this.rotationY.bind(65280,e),i=this.rotationZ.bind(255,e),r=this.screen.bind(e),a=this.free.bind(e);return()=>{t?.(),n?.(),i?.(),r?.(),a?.()}}}const ky=new id,Uy=new id(0,0,Math.PI/2),Fy=new id(0,-Math.PI/2,0);class zy extends Dh{xAxisHighlight;yAxisHighlight;zAxisHighlight;handles;context;constructor(e){super(),this.context=new Dv(this,e),this.xAxisHighlight=new Fv(this.context,ky),this.add(this.xAxisHighlight),this.yAxisHighlight=new Fv(this.context,Uy),this.add(this.yAxisHighlight),this.zAxisHighlight=new Fv(this.context,Fy),this.add(this.zAxisHighlight)}set space(e){this.context.space=e}get space(){return this.context.space}update(e,t){this.context.update(e),this.xAxisHighlight.update(),this.yAxisHighlight.update(),this.zAxisHighlight.update(),this.handles?.update(t)}bind(e,t){const n=this.xAxisHighlight.bind("x"),i=this.yAxisHighlight.bind("y"),r=this.zAxisHighlight.bind("z");switch(e){case"rotate":this.handles=new Oy(this.context);break;case"scale":this.handles=new my(this.context);break;case"translate":this.handles=new sy(this.context)}this.add(this.handles);const a=this.handles.bind(t);return()=>{null!=this.handles&&this.remove(this.handles),this.handles=void 0,a(),n(),i(),r()}}}new Kc(0,0,1),new Kc(0,1,0),new Kc,new Kc,new Kc;class By{nativeEvent;NONE=0;CAPTURING_PHASE=1;AT_TARGET=2;BUBBLING_PHASE=3;relatedTarget=null;get altKey(){return this.getFromNative("altKey",!1)}get button(){return this.getFromNative("button",0)}get buttons(){return this.getFromNative("buttons",0)}get clientX(){return this.getFromNative("clientX",0)}get clientY(){return this.getFromNative("clientY",0)}get ctrlKey(){return this.getFromNative("ctrlKey",!1)}get layerX(){return this.getFromNative("layerX",0)}get layerY(){return this.getFromNative("layerY",0)}get metaKey(){return this.getFromNative("metaKey",!1)}get movementX(){return this.getFromNative("movementX",0)}get movementY(){return this.getFromNative("movementY",0)}get offsetX(){return this.getFromNative("offsetX",0)}get offsetY(){return this.getFromNative("offsetY",0)}get pageX(){return this.getFromNative("pageX",0)}get pageY(){return this.getFromNative("pageY",0)}get screenX(){return this.getFromNative("screenX",0)}get screenY(){return this.getFromNative("screenY",0)}get shiftKey(){return this.getFromNative("shiftKey",!1)}get x(){return this.getFromNative("x",0)}get y(){return this.getFromNative("y",0)}get detail(){return this.getFromNative("detail",0)}get view(){return this.getFromNative("view",null)}get which(){return this.getFromNative("which",0)}get cancelBubble(){return this.getFromNative("cancelBubble",!1)}get composed(){return this.getFromNative("composed",!1)}get eventPhase(){return this.getFromNative("eventPhase",0)}get isTrusted(){return this.getFromNative("isTrusted",!1)}get returnValue(){return this.getFromNative("returnValue",!1)}get timeStamp(){return this.getFromNative("timeStamp",0)}get cancelable(){return this.getFromNative("cancelable",!1)}get defaultPrevented(){return this.getFromNative("defaultPrevented",!1)}constructor(e){this.nativeEvent=e}getFromNative(e,t){return e in this.nativeEvent?this.nativeEvent[e]:t}}const Vy=new Kc;class Hy extends By{type;bubbles;internalPointer;intersection;camera;currentObject;object;propagationState;get pointerId(){return this.internalPointer.id}get pointerType(){return this.internalPointer.type}get pointerState(){return this.internalPointer.state}get distance(){return this.intersection.distance}get distanceToRay(){return this.intersection.distanceToRay}get point(){return this.intersection.point}get index(){return this.intersection.index}get face(){return this.intersection.face}get faceIndex(){return this.intersection.faceIndex}get uv(){return this.intersection.uv}get uv1(){return this.intersection.uv1}get normal(){return this.intersection.normal}get instanceId(){return this.intersection.instanceId}get pointOnLine(){return this.intersection.pointOnLine}get batchId(){return this.intersection.batchId}get pointerPosition(){return this.intersection.pointerPosition}get pointerQuaternion(){return this.intersection.pointerQuaternion}get pointOnFace(){return this.intersection.pointOnFace}get localPoint(){return this.intersection.localPoint}get details(){return this.intersection.details}get target(){return this.object}get currentTarget(){return this.currentObject}get eventObject(){return this.currentObject}get srcElement(){return this.currentObject}_pointer;get pointer(){return null==this._pointer&&(Vy.copy(this.intersection.point).project(this.camera),this._pointer=new $c(Vy.x,Vy.y)),this._pointer}_ray;get ray(){if(null!=this._ray)return this._ray;switch(this.intersection.details.type){case"screen-ray":case"ray":case"sphere":return this._ray=new Xu(this.intersection.pointerPosition,new Kc(0,0,-1).applyQuaternion(this.intersection.pointerQuaternion));case"lines":return this._ray=new Xu(this.intersection.details.line.start,this.intersection.details.line.end.clone().sub(this.intersection.details.line.start).normalize())}}_intersections=[];get intersections(){return null==this._intersections&&(this._intersections=[{...this.intersection,eventObject:this.currentObject}]),this._intersections}_unprojectedPoint;get unprojectedPoint(){if(null==this._unprojectedPoint){const e=this.pointer;this._unprojectedPoint=new Kc(e.x,e.y,0).unproject(this.camera)}return this._unprojectedPoint}get stopped(){return this.propagationState.stoppedImmediate||this.propagationState.stopped}get stoppedImmediate(){return this.propagationState.stoppedImmediate}get delta(){throw new Error("not supported")}constructor(e,t,n,i,r,a,s=r.object,o=s,l={stopped:!t,stoppedImmediate:!1}){super(n),this.type=e,this.bubbles=t,this.internalPointer=i,this.intersection=r,this.camera=a,this.currentObject=s,this.object=o,this.propagationState=l}stopPropagation(){this.propagationState.stopped=!0}stopImmediatePropagation(){this.propagationState.stoppedImmediate=!0}retarget(e){return new Hy(this.type,this.bubbles,this.nativeEvent,this.internalPointer,this.intersection,this.camera,e,this.target,this.propagationState)}}class Gy extends Hy{get deltaX(){return this.nativeEvent.deltaX}get deltaY(){return this.nativeEvent.deltaY}get deltaZ(){return this.nativeEvent.deltaZ}constructor(e,t,n,i,r,a){super("wheel",!0,e,t,n,i,r,a)}retarget(e){return new Gy(this.nativeEvent,this.internalPointer,this.intersection,this.camera,e,this.target)}}function jy(e){Wy(e,e.currentObject)}function Wy(e,t){if(null==t)return;const n=function(e,t){if(null!=e._listeners&&t in e._listeners)return e._listeners[t];let n;e.isVoidObject&&"click"===t&&null!=e.parent?.__r3f&&(n=e.parent.__r3f.root.getState().onPointerMissed);null!=e.__r3f&&(n=e.__r3f.handlers[Xy[t]]);if(null==n)return;return[n]}(t,e.type);if(null!=n&&n.length>0){const i=e.retarget(t),r=n.length;for(let e=0;e<r&&!i.stoppedImmediate;e++)n[e](i)}e.stopped||Wy(e,t.parent)}const Xy={click:"onClick",contextmenu:"onContextMenu",dblclick:"onDoubleClick",pointercancel:"onPointerCancel",pointerdown:"onPointerDown",pointerenter:"onPointerEnter",pointerleave:"onPointerLeave",pointermove:"onPointerMove",pointerout:"onPointerOut",pointerover:"onPointerOver",pointerup:"onPointerUp",wheel:"onWheel"},qy=Object.keys(Xy);const $y=new ff(1e10),Yy=new Map;function Ky(e){let t=Yy.get(e);return null==t&&(t=new gh($y),t.isVoidObject=!0,t.parent=e,t.pointerEventsOrder=-1/0,Yy.set(e,t)),t}function Zy(e,t){return t?!e:e}function Qy(e,t,n,i=!1,r,a,s){const o=i||function(e,t){if(t.ancestorsHaveListeners)return!0;if("pointer"===e&&t.ancestorsHavePointerListeners)return!0;if("wheel"===e&&t.ancestorsHaveWheelListeners)return!0;if(null!=t.__r3f&&t.__r3f?.eventCount>0){if("wheel"===e&&null!=t.__r3f.handlers.onWheel)return!0;if("pointer"===e&&Object.keys(t.__r3f.handlers).some(e=>"onWheel"!=e))return!0}if(null==t._listeners)return!1;if("wheel"===e){const e=t._listeners.wheel;return null!=e&&e.length>0}const n=Object.entries(t._listeners),i=n.length;for(let e=0;e<i;e++){const t=n[e];if("wheel"!==t[0]&&(qy.includes(t[0])&&null!=t[1]&&t[1].length>0))return!0}return!1}(e,t),l=t.pointerEvents??r,c=l??t.defaultPointerEvents??"listener",u=t.pointerEventsType??a??"all",d=t.pointerEventsOrder??s??0,h=function(e,t,n){if("none"===t)return!1;if("listener"===t&&!e)return!1;if("all"===n)return!0;if("function"==typeof n)return({id:e,type:t,state:i})=>n(e,t,i);let i,r;return"deny"in n?(r=!0,i=n.deny):(r=!1,i=n.allow),Array.isArray(i)?e=>Zy(i.includes(e.type),r):e=>Zy(i===e.type,r)}(o,c,u),f=n.length;if(1===f)(!0===h||"function"==typeof h&&h(n[0]))&&Jy(n[0],t,c,u,d);else if(!0===h)for(let e=0;e<f;e++)Jy(n[e],t,c,u,d);else if("function"==typeof h)for(let e=0;e<f;e++){const i=n[e];h(i)&&Jy(i,t,c,u,d)}if(0===t.children.length||!1===t.intersectChildren)return;const p=t.interactableDescendants??t.children,m=p.length;for(let t=0;t<m;t++)Qy(e,p[t],n,o,l,u,d)}function Jy({intersector:e,options:t},n,i,r,a){!1!==t.filter?.(n,i,r,a)&&e.executeIntersection(n,a)}function ex(e,t=0,n,i=0){return t!=i?i-t:e.distance-n.distance}const tx=1e7;const nx=Symbol("buttonsDownTime"),ix=Symbol("buttonsClickTime");function rx(e){return globalThis.pointerEventspointerMap?.get(e)}globalThis.pointerEventspointerMap??=new Map,_d.prototype.setPointerCapture=function(e){rx(e)?.setCapture(this)},_d.prototype.releasePointerCapture=function(e){const t=rx(e);null!=t&&t.hasCaptured(this)&&t.setCapture(void 0)},_d.prototype.hasPointerCapture=function(e){return rx(e)?.hasCaptured(this)??!1};class ax{id;type;state;intersector;getCamera;onMoveCommited;parentSetPointerCapture;parentReleasePointerCapture;options;prevIntersection;intersection;prevEnabled=!0;enabled=!0;wheelIntersection;pointerEntered=[];pointerEnteredHelper=[];pointerCapture;buttonsDownTime=new Map;buttonsDown=new Set;wasMoved=!1;onFirstMove=[];constructor(e,t,n,i,r,a,s,o,l={}){this.id=e,this.type=t,this.state=n,this.intersector=i,this.getCamera=r,this.onMoveCommited=a,this.parentSetPointerCapture=s,this.parentReleasePointerCapture=o,this.options=l,globalThis.pointerEventspointerMap?.set(e,this)}getPointerCapture(){return this.pointerCapture}hasCaptured(e){return this.pointerCapture?.object===e}setCapture(e){this.pointerCapture?.object!==e&&(null!=this.pointerCapture&&(this.parentReleasePointerCapture?.(),this.pointerCapture=void 0),null!=e&&null!=this.intersection&&(this.pointerCapture={object:e,intersection:this.intersection},this.parentSetPointerCapture?.()))}getButtonsDown(){return this.buttonsDown}getIntersection(){return this.intersection}getEnabled(){return this.enabled}setEnabled(e,t,n=!0){this.enabled!==e&&(e||null==this.pointerCapture||(this.parentReleasePointerCapture?.(),this.pointerCapture=void 0),this.enabled=e,n&&this.commit(t,!1))}computeIntersection(e,t,n){return null!=this.pointerCapture?this.intersector.intersectPointerCapture(this.pointerCapture,n):(this.intersector.startIntersection(n),Qy(e,t,[this]),this.intersector.finalizeIntersection(t))}setIntersection(e){this.intersection=e}commit(e,t){const n=this.getCamera(),i=this.prevEnabled?this.prevIntersection:void 0,r=this.enabled?this.intersection:void 0;null!=i&&i.object!=r?.object&&jy(new Hy("pointerout",!0,e,this,i,n));const a=this.pointerEntered;this.pointerEntered=[],this.pointerEnteredHelper.length=0,sx(r?.object,this.pointerEntered,a,this.pointerEnteredHelper);const s=a.length;for(let t=0;t<s;t++){const r=a[t];jy(new Hy("pointerleave",!1,e,this,i,n,r))}null!=r&&i?.object!=r.object&&jy(new Hy("pointerover",!0,e,this,r,n));for(let t=this.pointerEnteredHelper.length-1;t>=0;t--){const i=this.pointerEnteredHelper[t];jy(new Hy("pointerenter",!1,e,this,r,n,i))}if(t&&null!=r&&jy(new Hy("pointermove",!0,e,this,r,n)),this.prevIntersection=this.intersection,this.prevEnabled=this.enabled,!this.wasMoved&&this.intersector.isReady()){this.wasMoved=!0;const e=this.onFirstMove.length;for(let t=0;t<e;t++)this.onFirstMove[t](n);this.onFirstMove.length=0}this.onMoveCommited?.(this)}move(e,t){this.intersection=this.computeIntersection("pointer",e,t),this.commit(t,!0)}emitMove(e){null!=this.intersection&&jy(new Hy("pointermove",!0,e,this,this.intersection,this.getCamera()))}down(e){if(this.buttonsDown.add(e.button),!this.enabled)return;if(!this.wasMoved)return void this.onFirstMove.push(this.down.bind(this,e));if(null==this.intersection)return;jy(new Hy("pointerdown",!0,e,this,this.intersection,this.getCamera()));const{object:t}=this.intersection;t[nx]??=new Map,t[nx].set(e.button,e.timeStamp),this.buttonsDownTime.set(e.button,e.timeStamp)}up(e){if(this.buttonsDown.delete(e.button),!this.enabled)return;if(!this.wasMoved)return void this.onFirstMove.push(this.up.bind(this,e));if(null==this.intersection)return;const{clickThesholdMs:t,contextMenuButton:n=2,dblClickThresholdMs:i=500,clickThresholdMs:r=t??300}=this.options;this.pointerCapture=void 0;const a=function(e,t,n,i,r){if(null==t)return!1;const a=t.get(n);if(null==a)return!1;if(i-a>r)return!1;if(a!=e.get(n))return!1;return!0}(this.buttonsDownTime,this.intersection.object[nx],e.button,e.timeStamp,r),s=this.getCamera();if(a&&e.button===n&&jy(new Hy("contextmenu",!0,e,this,this.intersection,s)),jy(new Hy("pointerup",!0,e,this,this.intersection,s)),!a||e.button===n)return;jy(new Hy("click",!0,e,this,this.intersection,s));const{object:o}=this.intersection,l=o[ix]??=new Map,c=l.get(e.button);null==c||e.timeStamp-c>i?l.set(e.button,e.timeStamp):(jy(new Hy("dblclick",!0,e,this,this.intersection,s)),l.delete(e.button))}cancel(e){this.enabled&&(this.wasMoved?null!=this.intersection&&jy(new Hy("pointercancel",!0,e,this,this.intersection,this.getCamera())):this.onFirstMove.push(this.cancel.bind(this,e)))}wheel(e,t,n=!1){if(!this.enabled)return;if(!this.wasMoved&&n)return void this.onFirstMove.push(this.wheel.bind(this,e,t,n));n||(this.wheelIntersection=this.computeIntersection("wheel",e,t));const i=n?this.intersection:this.wheelIntersection;null!=i&&jy(new Gy(t,this,i,this.getCamera()))}emitWheel(e,t=!1){if(!this.enabled)return;if(!this.wasMoved&&t)return void this.onFirstMove.push(this.emitWheel.bind(this,e,t));const n=t?this.intersection:this.wheelIntersection;null!=n&&jy(new Gy(e,this,n,this.getCamera()))}exit(e){this.wasMoved&&(null!=this.pointerCapture&&(this.parentReleasePointerCapture?.(),this.pointerCapture=void 0),this.intersection=void 0,this.commit(e,!1)),this.onFirstMove.length=0,this.wasMoved=!1}}function sx(e,t,n,i){if(null==e)return;const r=n.indexOf(e);-1!=r?n.splice(r,1):i.push(e),t.push(e),sx(e.parent,t,n,i)}const ox=new Nd,lx=new Nd,cx=new $c,ux=new $c,dx=new $c,hx=new Kc,fx=new qu,px=new Kc;function mx(e,t,n){px.copy(t).applyMatrix4(fx.copy(n.matrixWorld).invert());const i=n.geometry.attributes.uv;if(null==i||!(i instanceof qd))return!1;let r;return function(e,t){const n=e.geometry.drawRange;if(null!=e.geometry.index){const i=e.geometry.index,r=Math.max(0,n.start),a=Math.min(i.count,n.start+n.count);for(let e=r;e<a;e+=3)t(i.getX(e),i.getX(e+1),i.getX(e+2));return}const i=e.geometry.attributes.position;if(null==i)return;const r=Math.max(0,n.start),a=Math.min(i.count,n.start+n.count);for(let e=r;e<a;e+=3)t(e,e+1,e+2)}(n,(e,t,a)=>{n.getVertexPosition(e,ox.a),n.getVertexPosition(t,ox.b),n.getVertexPosition(a,ox.c);const s=ox.closestPointToPoint(px,hx).distanceTo(px);null!=r&&s>=r||(r=s,lx.copy(ox),cx.fromBufferAttribute(i,e),ux.fromBufferAttribute(i,t),dx.fromBufferAttribute(i,a))}),null!=r&&(lx.closestPointToPoint(px,hx),lx.getInterpolation(hx,cx,ux,dx,e),!0)}new qu,new class{constructor(e=new Kc,t=new Kc){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Mf.subVectors(e,this.start),Ef.subVectors(this.end,this.start);const n=Ef.dot(Ef);let i=Ef.dot(Mf)/n;return t&&(i=jc(i,0,1)),i}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(e,t=Cf,n=Pf){const i=1e-8*1e-8;let r,a;const s=this.start,o=e.start,l=this.end,c=e.end;Tf.subVectors(l,s),Af.subVectors(c,o),Rf.subVectors(s,o);const u=Tf.dot(Tf),d=Af.dot(Af),h=Af.dot(Rf);if(u<=i&&d<=i)return t.copy(s),n.copy(o),t.sub(n),t.dot(t);if(u<=i)r=0,a=h/d,a=jc(a,0,1);else{const e=Tf.dot(Rf);if(d<=i)a=0,r=jc(-e/u,0,1);else{const t=Tf.dot(Af),n=u*d-t*t;r=0!==n?jc((t*h-e*d)/n,0,1):0,a=(t*r+h)/d,a<0?(a=0,r=jc(-e/u,0,1)):a>1&&(a=1,r=jc((t-e)/u,0,1))}}return t.copy(s).add(Tf.multiplyScalar(r)),n.copy(o).add(Af.multiplyScalar(a)),t.sub(n),t.dot(t)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}},new Kc,new Vh,new Xu,new $c,new Kc(0,0,0),new Kc(0,0,1);const gx=new qu,vx=new Kc;new Kc(0,0,-1),new Vh;const yx=new $c,xx=new Kc;class _x{prepareTransformation;options;raycaster=new bf;cameraQuaternion=new Yc;fromPosition=new Kc;fromQuaternion=new Yc;coords=new $c;viewPlane=new Vh;intersects=[];pointerEventsOrders=[];constructor(e,t){this.prepareTransformation=e,this.options=t}isReady(){return!0}intersectPointerCapture({intersection:e,object:t},n){const i=e.details;if("screen-ray"!=i.type)throw new Error(`unable to process a pointer capture of type "${e.details.type}" with a camera ray intersector`);if(!this.startIntersection(n))return e;this.viewPlane.constant-=i.distanceViewPlane;const r=this.raycaster.ray.intersectPlane(this.viewPlane,new Kc);if(null==r)return e;e.object.updateWorldMatrix(!0,!1),function(e,t,n){const i=t.normal??t.face?.normal;null!=i&&(e.setFromNormalAndCoplanarPoint(i,t.localPoint),e.applyMatrix4(n))}(this.viewPlane,e,e.object.matrixWorld);let a=e.uv;return e.object instanceof gh&&mx(yx,r,e.object)&&(a=yx.clone()),{...e,details:{...i,direction:this.raycaster.ray.direction.clone(),screenPoint:this.coords.clone()},uv:a,object:t,point:r,pointOnFace:r,pointerPosition:this.raycaster.ray.origin.clone(),pointerQuaternion:this.cameraQuaternion.clone()}}startIntersection(e){const t=this.prepareTransformation(e,this.coords);return null!=t&&(t.updateWorldMatrix(!0,!1),t.matrixWorld.decompose(this.fromPosition,this.fromQuaternion,vx),this.raycaster.setFromCamera(this.coords,t),this.viewPlane.setFromNormalAndCoplanarPoint(t.getWorldDirection(xx),this.raycaster.ray.origin),!0)}executeIntersection(e,t){const n=this.intersects.length;e.raycast(this.raycaster,this.intersects),function(e,t,n){for(;n>0;)e.push(t),--n}(this.pointerEventsOrders,t,this.intersects.length-n)}finalizeIntersection(e){const t=this.fromPosition.clone(),n=this.cameraQuaternion.clone(),i=this.raycaster.ray.direction.clone(),r=function(e,t,{customSort:n=ex}={}){let i,r,a;const s=e.length;for(let o=0;o<s;o++){const s=e[o],l=t?.[o];(null==i||n(s,l,i,r)<0)&&(a=o,i=s,r=l)}return a}(this.intersects,this.pointerEventsOrders,this.options),a=null==r?void 0:this.intersects[r];return this.intersects.length=0,this.pointerEventsOrders.length=0,null==a?function(e,t,n,i,r,a=0){const s=t.direction.clone().multiplyScalar(tx),o=tx;return{distance:o+a,object:Ky(e),point:s,normal:t.origin.clone().sub(s).normalize(),details:n(s,o),pointerPosition:i,pointerQuaternion:r,pointOnFace:s,localPoint:s}}(e,this.raycaster.ray,(e,t)=>({type:"screen-ray",distanceViewPlane:t,screenPoint:this.coords.clone(),direction:i}),t,n):(a.object.updateWorldMatrix(!0,!1),gx.copy(a.object.matrixWorld).invert(),Object.assign(a,{details:{type:"screen-ray",distanceViewPlane:this.viewPlane.distanceToPoint(a.point),screenPoint:this.coords.clone(),direction:i},pointOnFace:a.point,pointerPosition:t,pointerQuaternion:n,localPoint:a.point.clone().applyMatrix4(gx)}))}}new Kc,new $c,new qu,new Kc,new Vh,new Fu,new Kc,new Kc,new Kc,new Kc(1e-4,1e-4,1e-4),new qu;let bx=23412;function wx(e,t,n){if(!(t instanceof globalThis.MouseEvent))return n.set(0,0);const{width:i,height:r,top:a,left:s}=e.getBoundingClientRect(),o=t.clientX-s,l=t.clientY-a;return n.set(o/i*2-1,-l/r*2+1)}function Sx(e,t,n,i){return function(e,t,n,i,r,a,s={}){const o=s?.forwardPointerCapture??!0,l=new Map,c=s.pointerTypePrefix??"forward-",u=(e,u)=>{let d=l.get(e.pointerId);return null!=d||(d=new ax(bx++,`${c}${e.pointerType}`,e.pointerState,new _x((e,n)=>(i(e,n),t()),s),t,void 0,o?r.bind(null,e.pointerId):void 0,o?a.bind(null,e.pointerId):void 0,s),"move"!=u&&"wheel"!=u&&(d.setIntersection(d.computeIntersection("pointer",n,e)),d.commit(e,!1)),l.set(e.pointerId,d)),d},d=new Map,h=new Map,f=[],p=[],m=(e,t,i)=>{switch(e){case"move":return void i.move(n,t);case"wheel":return void i.wheel(n,t);case"cancel":return void i.cancel(t);case"down":if(!Mx(t))return;return void i.down(t);case"up":if(!Mx(t))return;return void i.up(t);case"exit":return h.delete(i),d.delete(i),void i.exit(t)}},g=(e,t)=>{const n=u(t,e);"move"===e&&h.set(n,t),"wheel"===e&&d.set(n,t),s.batchEvents??1?p.push({type:e,event:t}):m(e,t,n)},v=g.bind(null,"move"),y=g.bind(null,"cancel"),x=g.bind(null,"down"),_=g.bind(null,"up"),b=g.bind(null,"wheel"),w=g.bind(null,"exit");return e.addEventListener("pointermove",v),e.addEventListener("pointercancel",y),e.addEventListener("pointerdown",x),e.addEventListener("pointerup",_),e.addEventListener("wheel",b),e.addEventListener("pointerleave",w),{destroy(){e.removeEventListener("pointermove",v),e.removeEventListener("pointercancel",y),e.removeEventListener("pointerdown",x),e.removeEventListener("pointerup",_),e.removeEventListener("wheel",b),e.removeEventListener("pointerleave",w),h.clear(),d.clear()},update(){const e=p.length;for(let t=0;t<e;t++){const{type:e,event:n}=p[t],i=u(n,e);"move"!==e||(f.push(i),h.get(i)==n)?"wheel"!==e||d.get(i)==n?m(e,n,i):i.emitWheel(n):i.emitMove(n)}if(p.length=0,s.intersectEveryFrame)for(const[e,t]of h.entries())f.includes(e)||e.move(n,t);f.length=0}}}(e,"function"==typeof t?t:()=>t,n,wx.bind(null,e),e.setPointerCapture.bind(e),t=>{e.hasPointerCapture(t)&&e.releasePointerCapture(t)},{pointerTypePrefix:"screen-",...i})}function Mx(e){return null!=e.button}new $c,new Kc,new Kc,new Kc,new $c,new $c,new Kc,new Kc,new $c,new $c,new $c,new $c,new Kc,new Kc;class Ex{constructor(e){this.xrDevice=e,this.combinedCameraPosition=new Kc,this.isPointerLocked=!1,this.vec3=new Kc,this.quat=new Yc,this.quatB=new Yc,this.euler=new id,this.keyState={ShiftLeft:!1,KeyW:!1,KeyA:!1,KeyS:!1,KeyD:!1,ArrowUp:!1,ArrowDown:!1},this.lastTime=0,this.isInProgrammaticMode=!1,this.interactionsEnabled=!0,this.scene=new kh,this.camera=new Rh(50,window.innerWidth/window.innerHeight,.1,40),this.playerRig=new Dh,this.cameraRig=new Dh,this.scene.add(this.playerRig),this.playerRig.add(this.cameraRig),this.cameraRig.position.fromArray(e.position.vec3),this.cameraRig.quaternion.fromArray(e.quaternion.quat),this.cameraRig.add(this.camera),this.camera.position.x-=e.ipd/2;const t=new gh(new hf(.25,.27,32),new Gd({color:16777215,side:0}));t.rotateX(-Math.PI/2),this.scene.add(t),this.renderer=new gg({alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(window.innerWidth,window.innerHeight),this.renderer.setClearColor(0,0),this.renderer.domElement.style.position="fixed",this.renderer.domElement.style.top="50vh",this.renderer.domElement.style.left="50vw",this.renderer.domElement.style.transform="translate(-50%, -50%)",this.transformHandles=new Map,["left","right"].forEach(t=>{const n=new zy;n.scale.setScalar(.1),n.position.fromArray(e.controllers[t].position.vec3),n.quaternion.fromArray(e.controllers[t].quaternion.quat),this.cameraRig.attach(n),n.userData={defaultPosition:n.position.toArray(),defaultQuaternion:n.quaternion.toArray()},n.userData.setMode=e=>{var t,i;null===(i=(t=n.userData).modeCleanup)||void 0===i||i.call(t),n.userData.modeCleanup=n.bind(e),n.userData.mode=e},n.userData.setMode("translate"),n.space="local",this.transformHandles.set(t,n),n.addEventListener("click",()=>{"translate"===n.userData.mode?n.userData.setMode("rotate"):n.userData.setMode("translate")})}),window.transformHandles=this.transformHandles,this.mouseMoveHandler=t=>{if(!this.isPointerLocked||this.isInProgrammaticMode)return;const n=t.movementX||t.mozMovementX||t.webkitMovementX||0,i=t.movementY||t.mozMovementY||t.webkitMovementY||0;this.playerRig.rotation.y-=.002*n,this.cameraRig.rotation.x-=.002*i,e.quaternion.copy(this.cameraRig.getWorldQuaternion(new Yc))},this.cameraRig.getWorldPosition(this.combinedCameraPosition),this.headsetDefaultPosition=this.cameraRig.position.clone(),this.headsetDefaultQuaternion=this.cameraRig.quaternion.clone(),this.forwardHtmlEvents=Sx(this.renderer.domElement,()=>this.camera,this.scene).update,document.addEventListener("pointerlockchange",this.pointerLockChangeHandler.bind(this),!1),document.addEventListener("mozpointerlockchange",this.pointerLockChangeHandler.bind(this),!1),document.addEventListener("webkitpointerlockchange",this.pointerLockChangeHandler.bind(this),!1),document.addEventListener("keydown",this.keyDownHandler.bind(this),!1),document.addEventListener("keyup",this.keyUpHandler.bind(this),!1)}lockPointer(){!this.isInProgrammaticMode&&this.interactionsEnabled&&(this.renderer.domElement.requestPointerLock=this.renderer.domElement.requestPointerLock||this.renderer.domElement.mozRequestPointerLock||this.renderer.domElement.webkitRequestPointerLock,this.renderer.domElement.requestPointerLock())}pointerLockChangeHandler(){this.isPointerLocked=document.pointerLockElement===this.renderer.domElement||document.mozPointerLockElement===this.renderer.domElement||document.webkitPointerLockElement===this.renderer.domElement,this.isPointerLocked?(document.addEventListener("mousemove",this.mouseMoveHandler,!1),Object.values(this.transformHandles).forEach(e=>{e.visible=!1})):(document.removeEventListener("mousemove",this.mouseMoveHandler,!1),Object.values(this.transformHandles).forEach(e=>{e.visible=!this.isInProgrammaticMode}))}keyDownHandler(e){const{keyState:t}=this;e.code in t&&(t[e.code]=!0),this.isInProgrammaticMode||(t.ShiftLeft&&t.ArrowUp&&(this.cameraRig.position.y+=.05),t.ShiftLeft&&t.ArrowDown&&(this.cameraRig.position.y-=.05))}keyUpHandler(e){const{keyState:t}=this;e.code in t&&(t[e.code]=!1)}movePlayerRig(e){const{playerRig:t,keyState:n,vec3:i}=this;i.set((n.KeyD?1:0)-(n.KeyA?1:0),0,(n.KeyS?1:0)-(n.KeyW?1:0)),i.lengthSq()>0&&n.ShiftLeft&&(i.normalize().multiplyScalar(2*e).applyQuaternion(t.quaternion),t.position.add(i))}resetDeviceTransforms(){const{playerRig:e,cameraRig:t,transformHandles:n}=this;t.position.copy(this.headsetDefaultPosition),t.quaternion.copy(this.headsetDefaultQuaternion),e.position.set(0,0,0),e.quaternion.set(0,0,0,1),n.forEach(e=>{e.position.fromArray(e.userData.defaultPosition),e.quaternion.fromArray(e.userData.defaultQuaternion)})}syncDeviceTransforms(){const{xrDevice:e,cameraRig:t,transformHandles:n}=this;e.position.copy(t.getWorldPosition(this.vec3)),e.quaternion.copy(t.getWorldQuaternion(this.quat)),n.forEach((t,n)=>{const i="controller"===e.primaryInputMode?e.controllers[n]:e.hands[n];i.position.copy(t.getWorldPosition(this.vec3)),i.quaternion.copy(t.getWorldQuaternion(this.quat))})}syncFromDevice(){const{xrDevice:e,playerRig:t,cameraRig:n,transformHandles:i}=this,r=e.position,a=e.quaternion;this.combinedCameraPosition.set(r.x,r.y,r.z),this.quatB.set(a.x,a.y,a.z,a.w),this.euler.setFromQuaternion(this.quatB,"YXZ"),t.position.set(r.x,0,r.z),t.rotation.set(0,this.euler.y,0),n.position.set(0,r.y,0),this.quat.setFromEuler(this.euler.set(0,this.euler.y,0,"YXZ")),n.quaternion.multiplyQuaternions(this.quat.invert(),this.quatB),t.updateMatrixWorld(!0),i.forEach((t,i)=>{const r="controller"===e.primaryInputMode?e.controllers[i]:e.hands[i],a=this.vec3.set(r.position.x,r.position.y,r.position.z);n.worldToLocal(a),t.position.copy(a),n.getWorldQuaternion(this.quat),this.quatB.set(r.quaternion.x,r.quaternion.y,r.quaternion.z,r.quaternion.w),this.quatB.premultiply(this.quat.invert()),t.quaternion.copy(this.quatB)})}setInteractionsEnabled(e){this.interactionsEnabled=e,!e&&this.isPointerLocked&&document.exitPointerLock()}renderScene(e){const t=this.xrDevice.fovy/Math.PI*180;let n=!1;this.camera.fov!==t&&(this.camera.fov=t,n=!0);const i=this.xrDevice.canvasDimensions;if(i){const e=this.renderer.domElement;(e.width!==i.width||e.height!==i.height)&&(this.camera.aspect=i.width/i.height,this.renderer.setSize(i.width,i.height),n=!0)}n&&this.camera.updateProjectionMatrix(),this.isInProgrammaticMode||(this.isPointerLocked?this.cameraRig.getWorldPosition(this.combinedCameraPosition):(this.cameraRig.position.y=this.combinedCameraPosition.y,this.playerRig.position.x=this.combinedCameraPosition.x,this.playerRig.position.z=this.combinedCameraPosition.z)),this.forwardHtmlEvents(),this.transformHandles.forEach((t,n)=>{var i;const r=Boolean(null===(i=this.xrDevice.controllers[n])||void 0===i?void 0:i.connected);t.visible=r&&!this.isPointerLocked&&!this.isInProgrammaticMode,r&&t.update(e,this.camera)});const r=Math.min((e-this.lastTime)/1e3,.1);this.isInProgrammaticMode||(this.movePlayerRig(r),this.syncDeviceTransforms()),this.renderer.render(this.scene,this.camera),this.lastTime=e}get domElement(){return this.renderer.domElement}dispose(){this.renderer.dispose(),document.removeEventListener("pointerlockchange",this.pointerLockChangeHandler.bind(this),!1),document.removeEventListener("mozpointerlockchange",this.pointerLockChangeHandler.bind(this),!1),document.removeEventListener("webkitpointerlockchange",this.pointerLockChangeHandler.bind(this),!1),document.removeEventListener("mousemove",this.mouseMoveHandler,!1),document.removeEventListener("keydown",this.keyDownHandler.bind(this),!1),document.removeEventListener("keyup",this.keyUpHandler.bind(this),!1)}}var Tx,Ax,Rx={exports:{}},Cx={},Px={exports:{}},Lx={};function Ix(){return Ax||(Ax=1,Px.exports=(Tx||(Tx=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var i=n-1>>>1,a=e[i];if(!(0<r(a,t)))break e;e[i]=t,e[n]=a,n=i}}function n(e){return 0===e.length?null:e[0]}function i(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var i=0,a=e.length,s=a>>>1;i<s;){var o=2*(i+1)-1,l=e[o],c=o+1,u=e[c];if(0>r(l,n))c<a&&0>r(u,l)?(e[i]=u,e[c]=n,i=c):(e[i]=l,e[o]=n,i=o);else{if(!(c<a&&0>r(u,n)))break e;e[i]=u,e[c]=n,i=c}}}return t}function r(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if(e.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var a=performance;e.unstable_now=function(){return a.now()}}else{var s=Date,o=s.now();e.unstable_now=function(){return s.now()-o}}var l=[],c=[],u=1,d=null,h=3,f=!1,p=!1,m=!1,g=!1,v="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,x="undefined"!=typeof setImmediate?setImmediate:null;function _(e){for(var r=n(c);null!==r;){if(null===r.callback)i(c);else{if(!(r.startTime<=e))break;i(c),r.sortIndex=r.expirationTime,t(l,r)}r=n(c)}}function b(e){if(m=!1,_(e),!p)if(null!==n(l))p=!0,S||(S=!0,w());else{var t=n(c);null!==t&&L(b,t.startTime-e)}}var w,S=!1,M=-1,E=5,T=-1;function A(){return!(!g&&e.unstable_now()-T<E)}function R(){if(g=!1,S){var t=e.unstable_now();T=t;var r=!0;try{e:{p=!1,m&&(m=!1,y(M),M=-1),f=!0;var a=h;try{t:{for(_(t),d=n(l);null!==d&&!(d.expirationTime>t&&A());){var s=d.callback;if("function"==typeof s){d.callback=null,h=d.priorityLevel;var o=s(d.expirationTime<=t);if(t=e.unstable_now(),"function"==typeof o){d.callback=o,_(t),r=!0;break t}d===n(l)&&i(l),_(t)}else i(l);d=n(l)}if(null!==d)r=!0;else{var u=n(c);null!==u&&L(b,u.startTime-t),r=!1}}break e}finally{d=null,h=a,f=!1}r=void 0}}finally{r?w():S=!1}}}if("function"==typeof x)w=function(){x(R)};else if("undefined"!=typeof MessageChannel){var C=new MessageChannel,P=C.port2;C.port1.onmessage=R,w=function(){P.postMessage(null)}}else w=function(){v(R,0)};function L(t,n){M=v(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_next=function(e){switch(h){case 1:case 2:case 3:var t=3;break;default:t=h}var n=h;h=t;try{return e()}finally{h=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=h;h=e;try{return t()}finally{h=n}},e.unstable_scheduleCallback=function(i,r,a){var s=e.unstable_now();switch(a="object"==typeof a&&null!==a&&"number"==typeof(a=a.delay)&&0<a?s+a:s,i){case 1:var o=-1;break;case 2:o=250;break;case 5:o=1073741823;break;case 4:o=1e4;break;default:o=5e3}return i={id:u++,callback:r,priorityLevel:i,startTime:a,expirationTime:o=a+o,sortIndex:-1},a>s?(i.sortIndex=a,t(c,i),null===n(l)&&i===n(c)&&(m?(y(M),M=-1):m=!0,L(b,a-s))):(i.sortIndex=o,t(l,i),p||f||(p=!0,S||(S=!0,w()))),i},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(e){var t=h;return function(){var n=h;h=t;try{return e.apply(this,arguments)}finally{h=n}}}}(Lx)),Lx)),Px.exports}var Dx,Nx,Ox,kx={exports:{}},Ux={};function Fx(){if(Dx)return Ux;Dx=1;var e=o;function t(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var i={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},r=Symbol.for("react.portal");var a=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function s(e,t){return"font"===e?"":"string"==typeof t?"use-credentials"===t?t:"":void 0}return Ux.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,Ux.createPortal=function(e,n){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!n||1!==n.nodeType&&9!==n.nodeType&&11!==n.nodeType)throw Error(t(299));return function(e,t,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:r,key:null==i?null:""+i,children:e,containerInfo:t,implementation:n}}(e,n,null,i)},Ux.flushSync=function(e){var t=a.T,n=i.p;try{if(a.T=null,i.p=2,e)return e()}finally{a.T=t,i.p=n,i.d.f()}},Ux.preconnect=function(e,t){"string"==typeof e&&(t?t="string"==typeof(t=t.crossOrigin)?"use-credentials"===t?t:"":void 0:t=null,i.d.C(e,t))},Ux.prefetchDNS=function(e){"string"==typeof e&&i.d.D(e)},Ux.preinit=function(e,t){if("string"==typeof e&&t&&"string"==typeof t.as){var n=t.as,r=s(n,t.crossOrigin),a="string"==typeof t.integrity?t.integrity:void 0,o="string"==typeof t.fetchPriority?t.fetchPriority:void 0;"style"===n?i.d.S(e,"string"==typeof t.precedence?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):"script"===n&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:"string"==typeof t.nonce?t.nonce:void 0})}},Ux.preinitModule=function(e,t){if("string"==typeof e)if("object"==typeof t&&null!==t){if(null==t.as||"script"===t.as){var n=s(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0})}}else null==t&&i.d.M(e)},Ux.preload=function(e,t){if("string"==typeof e&&"object"==typeof t&&null!==t&&"string"==typeof t.as){var n=t.as,r=s(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0,type:"string"==typeof t.type?t.type:void 0,fetchPriority:"string"==typeof t.fetchPriority?t.fetchPriority:void 0,referrerPolicy:"string"==typeof t.referrerPolicy?t.referrerPolicy:void 0,imageSrcSet:"string"==typeof t.imageSrcSet?t.imageSrcSet:void 0,imageSizes:"string"==typeof t.imageSizes?t.imageSizes:void 0,media:"string"==typeof t.media?t.media:void 0})}},Ux.preloadModule=function(e,t){if("string"==typeof e)if(t){var n=s(t.as,t.crossOrigin);i.d.m(e,{as:"string"==typeof t.as&&"script"!==t.as?t.as:void 0,crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0})}else i.d.m(e)},Ux.requestFormReset=function(e){i.d.r(e)},Ux.unstable_batchedUpdates=function(e,t){return e(t)},Ux.useFormState=function(e,t,n){return a.H.useFormState(e,t,n)},Ux.useFormStatus=function(){return a.H.useHostTransitionStatus()},Ux.version="19.2.0",Ux}!function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),Rx.exports=function(){if(Ox)return Cx;Ox=1;var e=Ix(),t=o,n=(Nx||(Nx=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),kx.exports=Fx()),kx.exports);function i(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function a(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{!!(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function s(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&null!==(e=e.alternate)&&(t=e.memoizedState),null!==t)return t.dehydrated}return null}function l(e){if(31===e.tag){var t=e.memoizedState;if(null===t&&null!==(e=e.alternate)&&(t=e.memoizedState),null!==t)return t.dehydrated}return null}function c(e){if(a(e)!==e)throw Error(i(188))}function u(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e;for(e=e.child;null!==e;){if(null!==(t=u(e)))return t;e=e.sibling}return null}var d=Object.assign,h=Symbol.for("react.element"),f=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),x=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),w=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),T=Symbol.for("react.memo_cache_sentinel"),A=Symbol.iterator;function R(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=A&&e[A]||e["@@iterator"])?e:null}var C=Symbol.for("react.client.reference");function P(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===C?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case m:return"Fragment";case v:return"Profiler";case g:return"StrictMode";case b:return"Suspense";case w:return"SuspenseList";case E:return"Activity"}if("object"==typeof e)switch(e.$$typeof){case p:return"Portal";case x:return e.displayName||"Context";case y:return(e._context.displayName||"Context")+".Consumer";case _:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case S:return null!==(t=e.displayName||null)?t:P(e.type)||"Memo";case M:t=e._payload,e=e._init;try{return P(e(t))}catch(e){}}return null}var L=Array.isArray,I=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N={pending:!1,data:null,method:null,action:null},O=[],k=-1;function U(e){return{current:e}}function F(e){0>k||(e.current=O[k],O[k]=null,k--)}function z(e,t){k++,O[k]=e.current,e.current=t}var B,V,H=U(null),G=U(null),j=U(null),W=U(null);function X(e,t){switch(z(j,t),z(G,e),z(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?md(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=gd(t=md(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}F(H),z(H,e)}function q(){F(H),F(G),F(j)}function $(e){null!==e.memoizedState&&z(W,e);var t=H.current,n=gd(t,e.type);t!==n&&(z(G,e),z(H,n))}function Y(e){G.current===e&&(F(H),F(G)),W.current===e&&(F(W),lh._currentValue=N)}function K(e){if(void 0===B)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);B=t&&t[1]||"",V=-1<e.stack.indexOf("\n at")?" (<anonymous>)":-1<e.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+B+e+V}var Z=!1;function Q(e,t){if(!e||Z)return"";Z=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var i=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){i=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){i=e}(n=e())&&"function"==typeof n.catch&&n.catch(function(){})}}catch(e){if(e&&i&&"string"==typeof e.stack)return[e.stack,i.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var r=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");r&&r.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var a=i.DetermineComponentFrameRoot(),s=a[0],o=a[1];if(s&&o){var l=s.split("\n"),c=o.split("\n");for(r=i=0;i<l.length&&!l[i].includes("DetermineComponentFrameRoot");)i++;for(;r<c.length&&!c[r].includes("DetermineComponentFrameRoot");)r++;if(i===l.length||r===c.length)for(i=l.length-1,r=c.length-1;1<=i&&0<=r&&l[i]!==c[r];)r--;for(;1<=i&&0<=r;i--,r--)if(l[i]!==c[r]){if(1!==i||1!==r)do{if(i--,0>--r||l[i]!==c[r]){var u="\n"+l[i].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}}while(1<=i&&0<=r);break}}}finally{Z=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?K(n):""}function J(e,t){switch(e.tag){case 26:case 27:case 5:return K(e.type);case 16:return K("Lazy");case 13:return e.child!==t&&null!==t?K("Suspense Fallback"):K("Suspense");case 19:return K("SuspenseList");case 0:case 15:return Q(e.type,!1);case 11:return Q(e.type.render,!1);case 1:return Q(e.type,!0);case 31:return K("Activity");default:return""}}function ee(e){try{var t="",n=null;do{t+=J(e,n),n=e,e=e.return}while(e);return t}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}var te=Object.prototype.hasOwnProperty,ne=e.unstable_scheduleCallback,ie=e.unstable_cancelCallback,re=e.unstable_shouldYield,ae=e.unstable_requestPaint,se=e.unstable_now,oe=e.unstable_getCurrentPriorityLevel,le=e.unstable_ImmediatePriority,ce=e.unstable_UserBlockingPriority,ue=e.unstable_NormalPriority,de=e.unstable_LowPriority,he=e.unstable_IdlePriority,fe=e.log,pe=e.unstable_setDisableYieldValue,me=null,ge=null;function ve(e){if("function"==typeof fe&&pe(e),ge&&"function"==typeof ge.setStrictMode)try{ge.setStrictMode(me,e)}catch(e){}}var ye=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(xe(e)/_e|0)|0},xe=Math.log,_e=Math.LN2,be=256,we=262144,Se=4194304;function Me(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ee(e,t,n){var i=e.pendingLanes;if(0===i)return 0;var r=0,a=e.suspendedLanes,s=e.pingedLanes;e=e.warmLanes;var o=134217727&i;return 0!==o?0!==(i=o&~a)?r=Me(i):0!==(s&=o)?r=Me(s):n||0!==(n=o&~e)&&(r=Me(n)):0!==(o=i&~a)?r=Me(o):0!==s?r=Me(s):n||0!==(n=i&~e)&&(r=Me(n)),0===r?0:0!==t&&t!==r&&0===(t&a)&&((a=r&-r)>=(n=t&-t)||32===a&&4194048&n)?t:r}function Te(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Ae(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function Re(){var e=Se;return!(62914560&(Se<<=1))&&(Se=4194304),e}function Ce(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Pe(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Le(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var i=31-ye(t);e.entangledLanes|=t,e.entanglements[i]=1073741824|e.entanglements[i]|261930&n}function Ie(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var i=31-ye(n),r=1<<i;r&t|e[i]&t&&(e[i]|=t),n&=~r}}function De(e,t){var n=t&-t;return 0!==((n=42&n?1:Ne(n))&(e.suspendedLanes|t))?0:n}function Ne(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Oe(e){return 2<(e&=-e)?8<e?134217727&e?32:268435456:8:2}function ke(){var e=D.p;return 0!==e?e:void 0===(e=window.event)?32:Mh(e.type)}function Ue(e,t){var n=D.p;try{return D.p=e,t()}finally{D.p=n}}var Fe=Math.random().toString(36).slice(2),ze="__reactFiber$"+Fe,Be="__reactProps$"+Fe,Ve="__reactContainer$"+Fe,He="__reactEvents$"+Fe,Ge="__reactListeners$"+Fe,je="__reactHandles$"+Fe,We="__reactResources$"+Fe,Xe="__reactMarker$"+Fe;function qe(e){delete e[ze],delete e[Be],delete e[He],delete e[Ge],delete e[je]}function $e(e){var t=e[ze];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ve]||n[ze]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Nd(e);null!==e;){if(n=e[ze])return n;e=Nd(e)}return t}n=(e=n).parentNode}return null}function Ye(e){if(e=e[ze]||e[Ve]){var t=e.tag;if(5===t||6===t||13===t||31===t||26===t||27===t||3===t)return e}return null}function Ke(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(i(33))}function Ze(e){var t=e[We];return t||(t=e[We]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Qe(e){e[Xe]=!0}var Je=new Set,et={};function tt(e,t){nt(e,t),nt(e+"Capture",t)}function nt(e,t){for(et[e]=t,e=0;e<t.length;e++)Je.add(t[e])}var it=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),rt={},at={};function st(e,t,n){if(r=t,te.call(at,r)||!te.call(rt,r)&&(it.test(r)?at[r]=!0:(rt[r]=!0,0)))if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":return void e.removeAttribute(t);case"boolean":var i=t.toLowerCase().slice(0,5);if("data-"!==i&&"aria-"!==i)return void e.removeAttribute(t)}e.setAttribute(t,""+n)}var r}function ot(e,t,n){if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(t)}e.setAttribute(t,""+n)}}function lt(e,t,n,i){if(null===i)e.removeAttribute(n);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(n)}e.setAttributeNS(t,n,""+i)}}function ct(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function ut(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function dt(e){if(!e._valueTracker){var t=ut(e)?"checked":"value";e._valueTracker=function(e,t,n){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&void 0!==i&&"function"==typeof i.get&&"function"==typeof i.set){var r=i.get,a=i.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(e){n=""+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:i.enumerable}),{getValue:function(){return n},setValue:function(e){n=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e,t,""+e[t])}}function ht(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),i="";return e&&(i=ut(e)?e.checked?"true":"false":e.value),(e=i)!==n&&(t.setValue(e),!0)}function ft(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}var pt=/[\n"\\]/g;function mt(e){return e.replace(pt,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function gt(e,t,n,i,r,a,s,o){e.name="",null!=s&&"function"!=typeof s&&"symbol"!=typeof s&&"boolean"!=typeof s?e.type=s:e.removeAttribute("type"),null!=t?"number"===s?(0===t&&""===e.value||e.value!=t)&&(e.value=""+ct(t)):e.value!==""+ct(t)&&(e.value=""+ct(t)):"submit"!==s&&"reset"!==s||e.removeAttribute("value"),null!=t?yt(e,s,ct(t)):null!=n?yt(e,s,ct(n)):null!=i&&e.removeAttribute("value"),null==r&&null!=a&&(e.defaultChecked=!!a),null!=r&&(e.checked=r&&"function"!=typeof r&&"symbol"!=typeof r),null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o?e.name=""+ct(o):e.removeAttribute("name")}function vt(e,t,n,i,r,a,s,o){if(null!=a&&"function"!=typeof a&&"symbol"!=typeof a&&"boolean"!=typeof a&&(e.type=a),null!=t||null!=n){if(("submit"===a||"reset"===a)&&null==t)return void dt(e);n=null!=n?""+ct(n):"",t=null!=t?""+ct(t):n,o||t===e.value||(e.value=t),e.defaultValue=t}i="function"!=typeof(i=null!=i?i:r)&&"symbol"!=typeof i&&!!i,e.checked=o?e.checked:!!i,e.defaultChecked=!!i,null!=s&&"function"!=typeof s&&"symbol"!=typeof s&&"boolean"!=typeof s&&(e.name=s),dt(e)}function yt(e,t,n){"number"===t&&ft(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function xt(e,t,n,i){if(e=e.options,t){t={};for(var r=0;r<n.length;r++)t["$"+n[r]]=!0;for(n=0;n<e.length;n++)r=t.hasOwnProperty("$"+e[n].value),e[n].selected!==r&&(e[n].selected=r),r&&i&&(e[n].defaultSelected=!0)}else{for(n=""+ct(n),t=null,r=0;r<e.length;r++){if(e[r].value===n)return e[r].selected=!0,void(i&&(e[r].defaultSelected=!0));null!==t||e[r].disabled||(t=e[r])}null!==t&&(t.selected=!0)}}function _t(e,t,n){null==t||((t=""+ct(t))!==e.value&&(e.value=t),null!=n)?e.defaultValue=null!=n?""+ct(n):"":e.defaultValue!==t&&(e.defaultValue=t)}function bt(e,t,n,r){if(null==t){if(null!=r){if(null!=n)throw Error(i(92));if(L(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}null==n&&(n=""),t=n}n=ct(t),e.defaultValue=n,(r=e.textContent)===n&&""!==r&&null!==r&&(e.value=r),dt(e)}function wt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var St=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Mt(e,t,n){var i=0===t.indexOf("--");null==n||"boolean"==typeof n||""===n?i?e.setProperty(t,""):"float"===t?e.cssFloat="":e[t]="":i?e.setProperty(t,n):"number"!=typeof n||0===n||St.has(t)?"float"===t?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Et(e,t,n){if(null!=t&&"object"!=typeof t)throw Error(i(62));if(e=e.style,null!=n){for(var r in n)!n.hasOwnProperty(r)||null!=t&&t.hasOwnProperty(r)||(0===r.indexOf("--")?e.setProperty(r,""):"float"===r?e.cssFloat="":e[r]="");for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Mt(e,a,r)}else for(var s in t)t.hasOwnProperty(s)&&Mt(e,s,t[s])}function Tt(e){if(-1===e.indexOf("-"))return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var At=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Rt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Ct(e){return Rt.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Pt(){}var Lt=null;function It(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Dt=null,Nt=null;function Ot(e){var t=Ye(e);if(t&&(e=t.stateNode)){var n=e[Be]||null;e:switch(e=t.stateNode,t.type){case"input":if(gt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,"radio"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+mt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[Be]||null;if(!a)throw Error(i(90));gt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)(r=n[t]).form===e.form&&ht(r)}break e;case"textarea":_t(e,n.value,n.defaultValue);break e;case"select":null!=(t=n.value)&&xt(e,!!n.multiple,t,!1)}}}var kt=!1;function Ut(e,t,n){if(kt)return e(t,n);kt=!0;try{return e(t)}finally{if(kt=!1,(null!==Dt||null!==Nt)&&(Zc(),Dt&&(t=Dt,e=Nt,Nt=Dt=null,Ot(t),e)))for(t=0;t<e.length;t++)Ot(e[t])}}function Ft(e,t){var n=e.stateNode;if(null===n)return null;var r=n[Be]||null;if(null===r)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(r=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!r;break e;default:e=!1}if(e)return null;if(n&&"function"!=typeof n)throw Error(i(231,t,typeof n));return n}var zt=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),Bt=!1;if(zt)try{var Vt={};Object.defineProperty(Vt,"passive",{get:function(){Bt=!0}}),window.addEventListener("test",Vt,Vt),window.removeEventListener("test",Vt,Vt)}catch(e){Bt=!1}var Ht=null,Gt=null,jt=null;function Wt(){if(jt)return jt;var e,t,n=Gt,i=n.length,r="value"in Ht?Ht.value:Ht.textContent,a=r.length;for(e=0;e<i&&n[e]===r[e];e++);var s=i-e;for(t=1;t<=s&&n[i-t]===r[a-t];t++);return jt=r.slice(e,1<t?1-t:void 0)}function Xt(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function qt(){return!0}function $t(){return!1}function Yt(e){function t(t,n,i,r,a){for(var s in this._reactName=t,this._targetInst=i,this.type=n,this.nativeEvent=r,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(s)&&(t=e[s],this[s]=t?t(r):r[s]);return this.isDefaultPrevented=(null!=r.defaultPrevented?r.defaultPrevented:!1===r.returnValue)?qt:$t,this.isPropagationStopped=$t,this}return d(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=qt)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=qt)},persist:function(){},isPersistent:qt}),t}var Kt,Zt,Qt,Jt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},en=Yt(Jt),tn=d({},Jt,{view:0,detail:0}),nn=Yt(tn),rn=d({},tn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:mn,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Qt&&(Qt&&"mousemove"===e.type?(Kt=e.screenX-Qt.screenX,Zt=e.screenY-Qt.screenY):Zt=Kt=0,Qt=e),Kt)},movementY:function(e){return"movementY"in e?e.movementY:Zt}}),an=Yt(rn),sn=Yt(d({},rn,{dataTransfer:0})),on=Yt(d({},tn,{relatedTarget:0})),ln=Yt(d({},Jt,{animationName:0,elapsedTime:0,pseudoElement:0})),cn=Yt(d({},Jt,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),un=Yt(d({},Jt,{data:0})),dn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},fn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function pn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=fn[e])&&!!t[e]}function mn(){return pn}var gn=Yt(d({},tn,{key:function(e){if(e.key){var t=dn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Xt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?hn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:mn,charCode:function(e){return"keypress"===e.type?Xt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Xt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}})),vn=Yt(d({},rn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),yn=Yt(d({},tn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:mn})),xn=Yt(d({},Jt,{propertyName:0,elapsedTime:0,pseudoElement:0})),_n=Yt(d({},rn,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),bn=Yt(d({},Jt,{newState:0,oldState:0})),wn=[9,13,27,32],Sn=zt&&"CompositionEvent"in window,Mn=null;zt&&"documentMode"in document&&(Mn=document.documentMode);var En=zt&&"TextEvent"in window&&!Mn,Tn=zt&&(!Sn||Mn&&8<Mn&&11>=Mn),An=String.fromCharCode(32),Rn=!1;function Cn(e,t){switch(e){case"keyup":return-1!==wn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pn(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Ln=!1,In={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Dn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!In[e.type]:"textarea"===t}function Nn(e,t,n,i){Dt?Nt?Nt.push(i):Nt=[i]:Dt=i,0<(t=td(t,"onChange")).length&&(n=new en("onChange","change",null,n,i),e.push({event:n,listeners:t}))}var On=null,kn=null;function Un(e){qu(e,0)}function Fn(e){if(ht(Ke(e)))return e}function zn(e,t){if("change"===e)return t}var Bn=!1;if(zt){var Vn;if(zt){var Hn="oninput"in document;if(!Hn){var Gn=document.createElement("div");Gn.setAttribute("oninput","return;"),Hn="function"==typeof Gn.oninput}Vn=Hn}else Vn=!1;Bn=Vn&&(!document.documentMode||9<document.documentMode)}function jn(){On&&(On.detachEvent("onpropertychange",Wn),kn=On=null)}function Wn(e){if("value"===e.propertyName&&Fn(kn)){var t=[];Nn(t,kn,e,It(e)),Ut(Un,t)}}function Xn(e,t,n){"focusin"===e?(jn(),kn=n,(On=t).attachEvent("onpropertychange",Wn)):"focusout"===e&&jn()}function qn(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Fn(kn)}function $n(e,t){if("click"===e)return Fn(t)}function Yn(e,t){if("input"===e||"change"===e)return Fn(t)}var Kn="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function Zn(e,t){if(Kn(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(i=0;i<n.length;i++){var r=n[i];if(!te.call(t,r)||!Kn(e[r],t[r]))return!1}return!0}function Qn(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Jn(e,t){var n,i=Qn(e);for(e=0;i;){if(3===i.nodeType){if(n=e+i.textContent.length,e<=t&&n>=t)return{node:i,offset:t-e};e=n}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qn(i)}}function ei(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?ei(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function ti(e){for(var t=ft((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(e){n=!1}if(!n)break;t=ft((e=t.contentWindow).document)}return t}function ni(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var ii=zt&&"documentMode"in document&&11>=document.documentMode,ri=null,ai=null,si=null,oi=!1;function li(e,t,n){var i=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;oi||null==ri||ri!==ft(i)||(i="selectionStart"in(i=ri)&&ni(i)?{start:i.selectionStart,end:i.selectionEnd}:{anchorNode:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset},si&&Zn(si,i)||(si=i,0<(i=td(ai,"onSelect")).length&&(t=new en("onSelect","select",null,t,n),e.push({event:t,listeners:i}),t.target=ri)))}function ci(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ui={animationend:ci("Animation","AnimationEnd"),animationiteration:ci("Animation","AnimationIteration"),animationstart:ci("Animation","AnimationStart"),transitionrun:ci("Transition","TransitionRun"),transitionstart:ci("Transition","TransitionStart"),transitioncancel:ci("Transition","TransitionCancel"),transitionend:ci("Transition","TransitionEnd")},di={},hi={};function fi(e){if(di[e])return di[e];if(!ui[e])return e;var t,n=ui[e];for(t in n)if(n.hasOwnProperty(t)&&t in hi)return di[e]=n[t];return e}zt&&(hi=document.createElement("div").style,"AnimationEvent"in window||(delete ui.animationend.animation,delete ui.animationiteration.animation,delete ui.animationstart.animation),"TransitionEvent"in window||delete ui.transitionend.transition);var pi=fi("animationend"),mi=fi("animationiteration"),gi=fi("animationstart"),vi=fi("transitionrun"),yi=fi("transitionstart"),xi=fi("transitioncancel"),_i=fi("transitionend"),bi=new Map,wi="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Si(e,t){bi.set(e,t),tt(t,[e])}wi.push("scrollEnd");var Mi="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},Ei=[],Ti=0,Ai=0;function Ri(){for(var e=Ti,t=Ai=Ti=0;t<e;){var n=Ei[t];Ei[t++]=null;var i=Ei[t];Ei[t++]=null;var r=Ei[t];Ei[t++]=null;var a=Ei[t];if(Ei[t++]=null,null!==i&&null!==r){var s=i.pending;null===s?r.next=r:(r.next=s.next,s.next=r),i.pending=r}0!==a&&Ii(n,r,a)}}function Ci(e,t,n,i){Ei[Ti++]=e,Ei[Ti++]=t,Ei[Ti++]=n,Ei[Ti++]=i,Ai|=i,e.lanes|=i,null!==(e=e.alternate)&&(e.lanes|=i)}function Pi(e,t,n,i){return Ci(e,t,n,i),Di(e)}function Li(e,t){return Ci(e,null,null,t),Di(e)}function Ii(e,t,n){e.lanes|=n;var i=e.alternate;null!==i&&(i.lanes|=n);for(var r=!1,a=e.return;null!==a;)a.childLanes|=n,null!==(i=a.alternate)&&(i.childLanes|=n),22===a.tag&&(null===(e=a.stateNode)||1&e._visibility||(r=!0)),e=a,a=a.return;return 3===e.tag?(a=e.stateNode,r&&null!==t&&(r=31-ye(n),null===(i=(e=a.hiddenUpdates)[r])?e[r]=[t]:i.push(t),t.lane=536870912|n),a):null}function Di(e){if(50<Hc)throw Hc=0,Gc=null,Error(i(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Ni={};function Oi(e,t,n,i){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ki(e,t,n,i){return new Oi(e,t,n,i)}function Ui(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Fi(e,t){var n=e.alternate;return null===n?((n=ki(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=65011712&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function zi(e,t){e.flags&=65011714;var n=e.alternate;return null===n?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Bi(e,t,n,r,a,s){var o=0;if(r=e,"function"==typeof e)Ui(e)&&(o=1);else if("string"==typeof e)o=function(e,t,n){if(1===n||null!=t.itemProp)return!1;switch(e){case"meta":case"title":return!0;case"style":if("string"!=typeof t.precedence||"string"!=typeof t.href||""===t.href)break;return!0;case"link":if("string"!=typeof t.rel||"string"!=typeof t.href||""===t.href||t.onLoad||t.onError)break;return"stylesheet"!==t.rel||(e=t.disabled,"string"==typeof t.precedence&&null==e);case"script":if(t.async&&"function"!=typeof t.async&&"symbol"!=typeof t.async&&!t.onLoad&&!t.onError&&t.src&&"string"==typeof t.src)return!0}return!1}(e,n,H.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case E:return(e=ki(31,n,t,a)).elementType=E,e.lanes=s,e;case m:return Vi(n.children,a,s,t);case g:o=8,a|=24;break;case v:return(e=ki(12,n,t,2|a)).elementType=v,e.lanes=s,e;case b:return(e=ki(13,n,t,a)).elementType=b,e.lanes=s,e;case w:return(e=ki(19,n,t,a)).elementType=w,e.lanes=s,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case x:o=10;break e;case y:o=9;break e;case _:o=11;break e;case S:o=14;break e;case M:o=16,r=null;break e}o=29,n=Error(i(130,null===e?"null":typeof e,"")),r=null}return(t=ki(o,n,t,a)).elementType=e,t.type=r,t.lanes=s,t}function Vi(e,t,n,i){return(e=ki(7,e,i,t)).lanes=n,e}function Hi(e,t,n){return(e=ki(6,e,null,t)).lanes=n,e}function Gi(e){var t=ki(18,null,null,0);return t.stateNode=e,t}function ji(e,t,n){return(t=ki(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Wi=new WeakMap;function Xi(e,t){if("object"==typeof e&&null!==e){var n=Wi.get(e);return void 0!==n?n:(t={value:e,source:t,stack:ee(t)},Wi.set(e,t),t)}return{value:e,source:t,stack:ee(t)}}var qi=[],$i=0,Yi=null,Ki=0,Zi=[],Qi=0,Ji=null,er=1,tr="";function nr(e,t){qi[$i++]=Ki,qi[$i++]=Yi,Yi=e,Ki=t}function ir(e,t,n){Zi[Qi++]=er,Zi[Qi++]=tr,Zi[Qi++]=Ji,Ji=e;var i=er;e=tr;var r=32-ye(i)-1;i&=~(1<<r),n+=1;var a=32-ye(t)+r;if(30<a){var s=r-r%5;a=(i&(1<<s)-1).toString(32),i>>=s,r-=s,er=1<<32-ye(t)+r|n<<r|i,tr=a+e}else er=1<<a|n<<r|i,tr=e}function rr(e){null!==e.return&&(nr(e,1),ir(e,1,0))}function ar(e){for(;e===Yi;)Yi=qi[--$i],qi[$i]=null,Ki=qi[--$i],qi[$i]=null;for(;e===Ji;)Ji=Zi[--Qi],Zi[Qi]=null,tr=Zi[--Qi],Zi[Qi]=null,er=Zi[--Qi],Zi[Qi]=null}function sr(e,t){Zi[Qi++]=er,Zi[Qi++]=tr,Zi[Qi++]=Ji,er=t.id,tr=t.overflow,Ji=e}var or=null,lr=null,cr=!1,ur=null,dr=!1,hr=Error(i(519));function fr(e){throw xr(Xi(Error(i(418,1<arguments.length&&void 0!==arguments[1]&&arguments[1]?"text":"HTML","")),e)),hr}function pr(e){var t=e.stateNode,n=e.type,i=e.memoizedProps;switch(t[ze]=e,t[Be]=i,n){case"dialog":$u("cancel",t),$u("close",t);break;case"iframe":case"object":case"embed":$u("load",t);break;case"video":case"audio":for(n=0;n<Wu.length;n++)$u(Wu[n],t);break;case"source":$u("error",t);break;case"img":case"image":case"link":$u("error",t),$u("load",t);break;case"details":$u("toggle",t);break;case"input":$u("invalid",t),vt(t,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":$u("invalid",t);break;case"textarea":$u("invalid",t),bt(t,i.value,i.defaultValue,i.children)}"string"!=typeof(n=i.children)&&"number"!=typeof n&&"bigint"!=typeof n||t.textContent===""+n||!0===i.suppressHydrationWarning||od(t.textContent,n)?(null!=i.popover&&($u("beforetoggle",t),$u("toggle",t)),null!=i.onScroll&&$u("scroll",t),null!=i.onScrollEnd&&$u("scrollend",t),null!=i.onClick&&(t.onclick=Pt),t=!0):t=!1,t||fr(e,!0)}function mr(e){for(or=e.return;or;)switch(or.tag){case 5:case 31:case 13:return void(dr=!1);case 27:case 3:return void(dr=!0);default:or=or.return}}function gr(e){if(e!==or)return!1;if(!cr)return mr(e),cr=!0,!1;var t,n=e.tag;if((t=3!==n&&27!==n)&&((t=5===n)&&(t=!("form"!==(t=e.type)&&"button"!==t)||vd(e.type,e.memoizedProps)),t=!t),t&&lr&&fr(e),mr(e),13===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(i(317));lr=Dd(e)}else if(31===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(i(317));lr=Dd(e)}else 27===n?(n=lr,Md(e.type)?(e=Id,Id=null,lr=e):lr=n):lr=or?Ld(e.stateNode.nextSibling):null;return!0}function vr(){lr=or=null,cr=!1}function yr(){var e=ur;return null!==e&&(null===Rc?Rc=e:Rc.push.apply(Rc,e),ur=null),e}function xr(e){null===ur?ur=[e]:ur.push(e)}var _r=U(null),br=null,wr=null;function Sr(e,t,n){z(_r,t._currentValue),t._currentValue=n}function Mr(e){e._currentValue=_r.current,F(_r)}function Er(e,t,n){for(;null!==e;){var i=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==i&&(i.childLanes|=t)):null!==i&&(i.childLanes&t)!==t&&(i.childLanes|=t),e===n)break;e=e.return}}function Tr(e,t,n,r){var a=e.child;for(null!==a&&(a.return=e);null!==a;){var s=a.dependencies;if(null!==s){var o=a.child;s=s.firstContext;e:for(;null!==s;){var l=s;s=a;for(var c=0;c<t.length;c++)if(l.context===t[c]){s.lanes|=n,null!==(l=s.alternate)&&(l.lanes|=n),Er(s.return,n,e),r||(o=null);break e}s=l.next}}else if(18===a.tag){if(null===(o=a.return))throw Error(i(341));o.lanes|=n,null!==(s=o.alternate)&&(s.lanes|=n),Er(o,n,e),o=null}else o=a.child;if(null!==o)o.return=a;else for(o=a;null!==o;){if(o===e){o=null;break}if(null!==(a=o.sibling)){a.return=o.return,o=a;break}o=o.return}a=o}}function Ar(e,t,n,r){e=null;for(var a=t,s=!1;null!==a;){if(!s)if(524288&a.flags)s=!0;else if(262144&a.flags)break;if(10===a.tag){var o=a.alternate;if(null===o)throw Error(i(387));if(null!==(o=o.memoizedProps)){var l=a.type;Kn(a.pendingProps.value,o.value)||(null!==e?e.push(l):e=[l])}}else if(a===W.current){if(null===(o=a.alternate))throw Error(i(387));o.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(null!==e?e.push(lh):e=[lh])}a=a.return}null!==e&&Tr(t,e,n,r),t.flags|=262144}function Rr(e){for(e=e.firstContext;null!==e;){if(!Kn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Cr(e){br=e,wr=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function Pr(e){return Ir(br,e)}function Lr(e,t){return null===br&&Cr(e),Ir(e,t)}function Ir(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},null===wr){if(null===e)throw Error(i(308));wr=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else wr=wr.next=t;return n}var Dr="undefined"!=typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Nr=e.unstable_scheduleCallback,Or=e.unstable_NormalPriority,kr={$$typeof:x,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ur(){return{controller:new Dr,data:new Map,refCount:0}}function Fr(e){e.refCount--,0===e.refCount&&Nr(Or,function(){e.controller.abort()})}var zr=null,Br=0,Vr=0,Hr=null;function Gr(){if(0===--Br&&null!==zr){null!==Hr&&(Hr.status="fulfilled");var e=zr;zr=null,Vr=0,Hr=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var jr=I.S;I.S=function(e,t){Lc=se(),"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===zr){var n=zr=[];Br=0,Vr=Bu(),Hr={status:"pending",value:void 0,then:function(e){n.push(e)}}}Br++,t.then(Gr,Gr)}(0,t),null!==jr&&jr(e,t)};var Wr=U(null);function Xr(){var e=Wr.current;return null!==e?e:hc.pooledCache}function qr(e,t){z(Wr,null===t?Wr.current:t.pool)}function $r(){var e=Xr();return null===e?null:{parent:kr._currentValue,pool:e}}var Yr=Error(i(460)),Kr=Error(i(474)),Zr=Error(i(542)),Qr={then:function(){}};function Jr(e){return"fulfilled"===(e=e.status)||"rejected"===e}function ea(e,t,n){switch(void 0===(n=e[n])?e.push(t):n!==t&&(t.then(Pt,Pt),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw ra(e=t.reason),e;default:if("string"==typeof t.status)t.then(Pt,Pt);else{if(null!==(e=hc)&&100<e.shellSuspendCounter)throw Error(i(482));(e=t).status="pending",e.then(function(e){if("pending"===t.status){var n=t;n.status="fulfilled",n.value=e}},function(e){if("pending"===t.status){var n=t;n.status="rejected",n.reason=e}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw ra(e=t.reason),e}throw na=t,Yr}}function ta(e){try{return(0,e._init)(e._payload)}catch(e){if(null!==e&&"object"==typeof e&&"function"==typeof e.then)throw na=e,Yr;throw e}}var na=null;function ia(){if(null===na)throw Error(i(459));var e=na;return na=null,e}function ra(e){if(e===Yr||e===Zr)throw Error(i(483))}var aa=null,sa=0;function oa(e){var t=sa;return sa+=1,null===aa&&(aa=[]),ea(aa,e,t)}function la(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function ca(e,t){if(t.$$typeof===h)throw Error(i(525));throw e=Object.prototype.toString.call(t),Error(i(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function ua(e){function t(t,n){if(e){var i=t.deletions;null===i?(t.deletions=[n],t.flags|=16):i.push(n)}}function n(n,i){if(!e)return null;for(;null!==i;)t(n,i),i=i.sibling;return null}function r(e){for(var t=new Map;null!==e;)null!==e.key?t.set(e.key,e):t.set(e.index,e),e=e.sibling;return t}function a(e,t){return(e=Fi(e,t)).index=0,e.sibling=null,e}function s(t,n,i){return t.index=i,e?null!==(i=t.alternate)?(i=i.index)<n?(t.flags|=67108866,n):i:(t.flags|=67108866,n):(t.flags|=1048576,n)}function o(t){return e&&null===t.alternate&&(t.flags|=67108866),t}function l(e,t,n,i){return null===t||6!==t.tag?((t=Hi(n,e.mode,i)).return=e,t):((t=a(t,n)).return=e,t)}function c(e,t,n,i){var r=n.type;return r===m?d(e,t,n.props.children,i,n.key):null!==t&&(t.elementType===r||"object"==typeof r&&null!==r&&r.$$typeof===M&&ta(r)===t.type)?(la(t=a(t,n.props),n),t.return=e,t):(la(t=Bi(n.type,n.key,n.props,null,e.mode,i),n),t.return=e,t)}function u(e,t,n,i){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=ji(n,e.mode,i)).return=e,t):((t=a(t,n.children||[])).return=e,t)}function d(e,t,n,i,r){return null===t||7!==t.tag?((t=Vi(n,e.mode,i,r)).return=e,t):((t=a(t,n)).return=e,t)}function h(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t||"bigint"==typeof t)return(t=Hi(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case f:return la(n=Bi(t.type,t.key,t.props,null,e.mode,n),t),n.return=e,n;case p:return(t=ji(t,e.mode,n)).return=e,t;case M:return h(e,t=ta(t),n)}if(L(t)||R(t))return(t=Vi(t,e.mode,n,null)).return=e,t;if("function"==typeof t.then)return h(e,oa(t),n);if(t.$$typeof===x)return h(e,Lr(e,t),n);ca(e,t)}return null}function g(e,t,n,i){var r=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n||"bigint"==typeof n)return null!==r?null:l(e,t,""+n,i);if("object"==typeof n&&null!==n){switch(n.$$typeof){case f:return n.key===r?c(e,t,n,i):null;case p:return n.key===r?u(e,t,n,i):null;case M:return g(e,t,n=ta(n),i)}if(L(n)||R(n))return null!==r?null:d(e,t,n,i,null);if("function"==typeof n.then)return g(e,t,oa(n),i);if(n.$$typeof===x)return g(e,t,Lr(e,n),i);ca(e,n)}return null}function v(e,t,n,i,r){if("string"==typeof i&&""!==i||"number"==typeof i||"bigint"==typeof i)return l(t,e=e.get(n)||null,""+i,r);if("object"==typeof i&&null!==i){switch(i.$$typeof){case f:return c(t,e=e.get(null===i.key?n:i.key)||null,i,r);case p:return u(t,e=e.get(null===i.key?n:i.key)||null,i,r);case M:return v(e,t,n,i=ta(i),r)}if(L(i)||R(i))return d(t,e=e.get(n)||null,i,r,null);if("function"==typeof i.then)return v(e,t,n,oa(i),r);if(i.$$typeof===x)return v(e,t,n,Lr(t,i),r);ca(t,i)}return null}function y(l,c,u,d){if("object"==typeof u&&null!==u&&u.type===m&&null===u.key&&(u=u.props.children),"object"==typeof u&&null!==u){switch(u.$$typeof){case f:e:{for(var _=u.key;null!==c;){if(c.key===_){if((_=u.type)===m){if(7===c.tag){n(l,c.sibling),(d=a(c,u.props.children)).return=l,l=d;break e}}else if(c.elementType===_||"object"==typeof _&&null!==_&&_.$$typeof===M&&ta(_)===c.type){n(l,c.sibling),la(d=a(c,u.props),u),d.return=l,l=d;break e}n(l,c);break}t(l,c),c=c.sibling}u.type===m?((d=Vi(u.props.children,l.mode,d,u.key)).return=l,l=d):(la(d=Bi(u.type,u.key,u.props,null,l.mode,d),u),d.return=l,l=d)}return o(l);case p:e:{for(_=u.key;null!==c;){if(c.key===_){if(4===c.tag&&c.stateNode.containerInfo===u.containerInfo&&c.stateNode.implementation===u.implementation){n(l,c.sibling),(d=a(c,u.children||[])).return=l,l=d;break e}n(l,c);break}t(l,c),c=c.sibling}(d=ji(u,l.mode,d)).return=l,l=d}return o(l);case M:return y(l,c,u=ta(u),d)}if(L(u))return function(i,a,o,l){for(var c=null,u=null,d=a,f=a=0,p=null;null!==d&&f<o.length;f++){d.index>f?(p=d,d=null):p=d.sibling;var m=g(i,d,o[f],l);if(null===m){null===d&&(d=p);break}e&&d&&null===m.alternate&&t(i,d),a=s(m,a,f),null===u?c=m:u.sibling=m,u=m,d=p}if(f===o.length)return n(i,d),cr&&nr(i,f),c;if(null===d){for(;f<o.length;f++)null!==(d=h(i,o[f],l))&&(a=s(d,a,f),null===u?c=d:u.sibling=d,u=d);return cr&&nr(i,f),c}for(d=r(d);f<o.length;f++)null!==(p=v(d,i,f,o[f],l))&&(e&&null!==p.alternate&&d.delete(null===p.key?f:p.key),a=s(p,a,f),null===u?c=p:u.sibling=p,u=p);return e&&d.forEach(function(e){return t(i,e)}),cr&&nr(i,f),c}(l,c,u,d);if(R(u)){if("function"!=typeof(_=R(u)))throw Error(i(150));return function(a,o,l,c){if(null==l)throw Error(i(151));for(var u=null,d=null,f=o,p=o=0,m=null,y=l.next();null!==f&&!y.done;p++,y=l.next()){f.index>p?(m=f,f=null):m=f.sibling;var x=g(a,f,y.value,c);if(null===x){null===f&&(f=m);break}e&&f&&null===x.alternate&&t(a,f),o=s(x,o,p),null===d?u=x:d.sibling=x,d=x,f=m}if(y.done)return n(a,f),cr&&nr(a,p),u;if(null===f){for(;!y.done;p++,y=l.next())null!==(y=h(a,y.value,c))&&(o=s(y,o,p),null===d?u=y:d.sibling=y,d=y);return cr&&nr(a,p),u}for(f=r(f);!y.done;p++,y=l.next())null!==(y=v(f,a,p,y.value,c))&&(e&&null!==y.alternate&&f.delete(null===y.key?p:y.key),o=s(y,o,p),null===d?u=y:d.sibling=y,d=y);return e&&f.forEach(function(e){return t(a,e)}),cr&&nr(a,p),u}(l,c,u=_.call(u),d)}if("function"==typeof u.then)return y(l,c,oa(u),d);if(u.$$typeof===x)return y(l,c,Lr(l,u),d);ca(l,u)}return"string"==typeof u&&""!==u||"number"==typeof u||"bigint"==typeof u?(u=""+u,null!==c&&6===c.tag?(n(l,c.sibling),(d=a(c,u)).return=l,l=d):(n(l,c),(d=Hi(u,l.mode,d)).return=l,l=d),o(l)):n(l,c)}return function(e,t,n,i){try{sa=0;var r=y(e,t,n,i);return aa=null,r}catch(t){if(t===Yr||t===Zr)throw t;var a=ki(29,t,null,e.mode);return a.lanes=i,a.return=e,a}}}var da=ua(!0),ha=ua(!1),fa=!1;function pa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ma(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ga(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function va(e,t,n){var i=e.updateQueue;if(null===i)return null;if(i=i.shared,2&dc){var r=i.pending;return null===r?t.next=t:(t.next=r.next,r.next=t),i.pending=t,t=Di(e),Ii(e,null,n),t}return Ci(e,i,t,n),Di(e)}function ya(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&n)){var i=t.lanes;n|=i&=e.pendingLanes,t.lanes=n,Ie(e,n)}}function xa(e,t){var n=e.updateQueue,i=e.alternate;if(null!==i&&n===(i=i.updateQueue)){var r=null,a=null;if(null!==(n=n.firstBaseUpdate)){do{var s={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};null===a?r=a=s:a=a.next=s,n=n.next}while(null!==n);null===a?r=a=t:a=a.next=t}else r=a=t;return n={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:a,shared:i.shared,callbacks:i.callbacks},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var _a=!1;function ba(){if(_a&&null!==Hr)throw Hr}function wa(e,t,n,i){_a=!1;var r=e.updateQueue;fa=!1;var a=r.firstBaseUpdate,s=r.lastBaseUpdate,o=r.shared.pending;if(null!==o){r.shared.pending=null;var l=o,c=l.next;l.next=null,null===s?a=c:s.next=c,s=l;var u=e.alternate;null!==u&&(o=(u=u.updateQueue).lastBaseUpdate)!==s&&(null===o?u.firstBaseUpdate=c:o.next=c,u.lastBaseUpdate=l)}if(null!==a){var h=r.baseState;for(s=0,u=c=l=null,o=a;;){var f=-536870913&o.lane,p=f!==o.lane;if(p?(pc&f)===f:(i&f)===f){0!==f&&f===Vr&&(_a=!0),null!==u&&(u=u.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});e:{var m=e,g=o;f=t;var v=n;switch(g.tag){case 1:if("function"==typeof(m=g.payload)){h=m.call(v,h,f);break e}h=m;break e;case 3:m.flags=-65537&m.flags|128;case 0:if(null==(f="function"==typeof(m=g.payload)?m.call(v,h,f):m))break e;h=d({},h,f);break e;case 2:fa=!0}}null!==(f=o.callback)&&(e.flags|=64,p&&(e.flags|=8192),null===(p=r.callbacks)?r.callbacks=[f]:p.push(f))}else p={lane:f,tag:o.tag,payload:o.payload,callback:o.callback,next:null},null===u?(c=u=p,l=h):u=u.next=p,s|=f;if(null===(o=o.next)){if(null===(o=r.shared.pending))break;o=(p=o).next,p.next=null,r.lastBaseUpdate=p,r.shared.pending=null}}null===u&&(l=h),r.baseState=l,r.firstBaseUpdate=c,r.lastBaseUpdate=u,null===a&&(r.shared.lanes=0),wc|=s,e.lanes=s,e.memoizedState=h}}function Sa(e,t){if("function"!=typeof e)throw Error(i(191,e));e.call(t)}function Ma(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;e<n.length;e++)Sa(n[e],t)}var Ea=U(null),Ta=U(0);function Aa(e,t){z(Ta,e=_c),z(Ea,t),_c=e|t.baseLanes}function Ra(){z(Ta,_c),z(Ea,Ea.current)}function Ca(){_c=Ta.current,F(Ea),F(Ta)}var Pa=U(null),La=null;function Ia(e){var t=e.alternate;z(Ua,1&Ua.current),z(Pa,e),null===La&&(null===t||null!==Ea.current||null!==t.memoizedState)&&(La=e)}function Da(e){z(Ua,Ua.current),z(Pa,e),null===La&&(La=e)}function Na(e){22===e.tag?(z(Ua,Ua.current),z(Pa,e),null===La&&(La=e)):Oa()}function Oa(){z(Ua,Ua.current),z(Pa,Pa.current)}function ka(e){F(Pa),La===e&&(La=null),F(Ua)}var Ua=U(0);function Fa(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||Cd(n)||Pd(n)))return t}else if(19!==t.tag||"forwards"!==t.memoizedProps.revealOrder&&"backwards"!==t.memoizedProps.revealOrder&&"unstable_legacy-backwards"!==t.memoizedProps.revealOrder&&"together"!==t.memoizedProps.revealOrder){if(null!==t.child){t.child.return=t,t=t.child;continue}}else if(128&t.flags)return t;if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var za=0,Ba=null,Va=null,Ha=null,Ga=!1,ja=!1,Wa=!1,Xa=0,qa=0,$a=null,Ya=0;function Ka(){throw Error(i(321))}function Za(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Kn(e[n],t[n]))return!1;return!0}function Qa(e,t,n,i,r,a){return za=a,Ba=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,I.H=null===e||null===e.memoizedState?po:mo,Wa=!1,a=n(i,r),Wa=!1,ja&&(a=es(t,n,i,r)),Ja(e),a}function Ja(e){I.H=fo;var t=null!==Va&&null!==Va.next;if(za=0,Ha=Va=Ba=null,Ga=!1,qa=0,$a=null,t)throw Error(i(300));null===e||Lo||null!==(e=e.dependencies)&&Rr(e)&&(Lo=!0)}function es(e,t,n,r){Ba=e;var a=0;do{if(ja&&($a=null),qa=0,ja=!1,25<=a)throw Error(i(301));if(a+=1,Ha=Va=null,null!=e.updateQueue){var s=e.updateQueue;s.lastEffect=null,s.events=null,s.stores=null,null!=s.memoCache&&(s.memoCache.index=0)}I.H=go,s=t(n,r)}while(ja);return s}function ts(){var e=I.H,t=e.useState()[0];return t="function"==typeof t.then?os(t):t,e=e.useState()[0],(null!==Va?Va.memoizedState:null)!==e&&(Ba.flags|=1024),t}function ns(){var e=0!==Xa;return Xa=0,e}function is(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function rs(e){if(Ga){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}Ga=!1}za=0,Ha=Va=Ba=null,ja=!1,qa=Xa=0,$a=null}function as(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Ha?Ba.memoizedState=Ha=e:Ha=Ha.next=e,Ha}function ss(){if(null===Va){var e=Ba.alternate;e=null!==e?e.memoizedState:null}else e=Va.next;var t=null===Ha?Ba.memoizedState:Ha.next;if(null!==t)Ha=t,Va=e;else{if(null===e){if(null===Ba.alternate)throw Error(i(467));throw Error(i(310))}e={memoizedState:(Va=e).memoizedState,baseState:Va.baseState,baseQueue:Va.baseQueue,queue:Va.queue,next:null},null===Ha?Ba.memoizedState=Ha=e:Ha=Ha.next=e}return Ha}function os(e){var t=qa;return qa+=1,null===$a&&($a=[]),e=ea($a,e,t),t=Ba,null===(null===Ha?t.memoizedState:Ha.next)&&(t=t.alternate,I.H=null===t||null===t.memoizedState?po:mo),e}function ls(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return os(e);if(e.$$typeof===x)return Pr(e)}throw Error(i(438,String(e)))}function cs(e){var t=null,n=Ba.updateQueue;if(null!==n&&(t=n.memoCache),null==t){var i=Ba.alternate;null!==i&&null!==(i=i.updateQueue)&&null!=(i=i.memoCache)&&(t={data:i.data.map(function(e){return e.slice()}),index:0})}if(null==t&&(t={data:[],index:0}),null===n&&(n={lastEffect:null,events:null,stores:null,memoCache:null},Ba.updateQueue=n),n.memoCache=t,void 0===(n=t.data[t.index]))for(n=t.data[t.index]=Array(e),i=0;i<e;i++)n[i]=T;return t.index++,n}function us(e,t){return"function"==typeof t?t(e):t}function ds(e){return hs(ss(),Va,e)}function hs(e,t,n){var r=e.queue;if(null===r)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,s=r.pending;if(null!==s){if(null!==a){var o=a.next;a.next=s.next,s.next=o}t.baseQueue=a=s,r.pending=null}if(s=e.baseState,null===a)e.memoizedState=s;else{var l=o=null,c=null,u=t=a.next,d=!1;do{var h=-536870913&u.lane;if(h!==u.lane?(pc&h)===h:(za&h)===h){var f=u.revertLane;if(0===f)null!==c&&(c=c.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),h===Vr&&(d=!0);else{if((za&f)===f){u=u.next,f===Vr&&(d=!0);continue}h={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=h,o=s):c=c.next=h,Ba.lanes|=f,wc|=f}h=u.action,Wa&&n(s,h),s=u.hasEagerState?u.eagerState:n(s,h)}else f={lane:h,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=f,o=s):c=c.next=f,Ba.lanes|=h,wc|=h;u=u.next}while(null!==u&&u!==t);if(null===c?o=s:c.next=l,!Kn(s,e.memoizedState)&&(Lo=!0,d&&null!==(n=Hr)))throw n;e.memoizedState=s,e.baseState=o,e.baseQueue=c,r.lastRenderedState=s}return null===a&&(r.lanes=0),[e.memoizedState,r.dispatch]}function fs(e){var t=ss(),n=t.queue;if(null===n)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,s=t.memoizedState;if(null!==a){n.pending=null;var o=a=a.next;do{s=e(s,o.action),o=o.next}while(o!==a);Kn(s,t.memoizedState)||(Lo=!0),t.memoizedState=s,null===t.baseQueue&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function ps(e,t,n){var r=Ba,a=ss(),s=cr;if(s){if(void 0===n)throw Error(i(407));n=n()}else n=t();var o=!Kn((Va||a).memoizedState,n);if(o&&(a.memoizedState=n,Lo=!0),a=a.queue,zs(vs.bind(null,r,a,e),[e]),a.getSnapshot!==t||o||null!==Ha&&1&Ha.memoizedState.tag){if(r.flags|=2048,Ns(9,{destroy:void 0},gs.bind(null,r,a,n,t),null),null===hc)throw Error(i(349));s||127&za||ms(r,t,n)}return n}function ms(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=Ba.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},Ba.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function gs(e,t,n,i){t.value=n,t.getSnapshot=i,ys(t)&&xs(e)}function vs(e,t,n){return n(function(){ys(t)&&xs(e)})}function ys(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Kn(e,n)}catch(e){return!0}}function xs(e){var t=Li(e,2);null!==t&&Xc(t,e,2)}function _s(e){var t=as();if("function"==typeof e){var n=e;if(e=n(),Wa){ve(!0);try{n()}finally{ve(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:e},t}function bs(e,t,n,i){return e.baseState=n,hs(e,Va,"function"==typeof i?i:us)}function ws(e,t,n,r,a){if(co(e))throw Error(i(485));if(null!==(e=t.action)){var s={payload:a,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(e){s.listeners.push(e)}};null!==I.T?n(!0):s.isTransition=!1,r(s),null===(n=t.pending)?(s.next=t.pending=s,Ss(t,s)):(s.next=n.next,t.pending=n.next=s)}}function Ss(e,t){var n=t.action,i=t.payload,r=e.state;if(t.isTransition){var a=I.T,s={};I.T=s;try{var o=n(r,i),l=I.S;null!==l&&l(s,o),Ms(e,t,o)}catch(n){Ts(e,t,n)}finally{null!==a&&null!==s.types&&(a.types=s.types),I.T=a}}else try{Ms(e,t,a=n(r,i))}catch(n){Ts(e,t,n)}}function Ms(e,t,n){null!==n&&"object"==typeof n&&"function"==typeof n.then?n.then(function(n){Es(e,t,n)},function(n){return Ts(e,t,n)}):Es(e,t,n)}function Es(e,t,n){t.status="fulfilled",t.value=n,As(t),e.state=n,null!==(t=e.pending)&&((n=t.next)===t?e.pending=null:(n=n.next,t.next=n,Ss(e,n)))}function Ts(e,t,n){var i=e.pending;if(e.pending=null,null!==i){i=i.next;do{t.status="rejected",t.reason=n,As(t),t=t.next}while(t!==i)}e.action=null}function As(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Rs(e,t){return t}function Cs(e,t){if(cr){var n=hc.formState;if(null!==n){e:{var i=Ba;if(cr){if(lr){t:{for(var r=lr,a=dr;8!==r.nodeType;){if(!a){r=null;break t}if(null===(r=Ld(r.nextSibling))){r=null;break t}}r="F!"===(a=r.data)||"F"===a?r:null}if(r){lr=Ld(r.nextSibling),i="F!"===r.data;break e}}fr(i)}i=!1}i&&(t=n[0])}}return(n=as()).memoizedState=n.baseState=t,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rs,lastRenderedState:t},n.queue=i,n=so.bind(null,Ba,i),i.dispatch=n,i=_s(!1),a=lo.bind(null,Ba,!1,i.queue),r={state:t,dispatch:null,action:e,pending:null},(i=as()).queue=r,n=ws.bind(null,Ba,r,a,n),r.dispatch=n,i.memoizedState=e,[t,n,!1]}function Ps(e){return Ls(ss(),Va,e)}function Ls(e,t,n){if(t=hs(e,t,Rs)[0],e=ds(us)[0],"object"==typeof t&&null!==t&&"function"==typeof t.then)try{var i=os(t)}catch(e){if(e===Yr)throw Zr;throw e}else i=t;var r=(t=ss()).queue,a=r.dispatch;return n!==t.memoizedState&&(Ba.flags|=2048,Ns(9,{destroy:void 0},Is.bind(null,r,n),null)),[i,a,e]}function Is(e,t){e.action=t}function Ds(e){var t=ss(),n=Va;if(null!==n)return Ls(t,n,e);ss(),t=t.memoizedState;var i=(n=ss()).queue.dispatch;return n.memoizedState=e,[t,i,!1]}function Ns(e,t,n,i){return e={tag:e,create:n,deps:i,inst:t,next:null},null===(t=Ba.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},Ba.updateQueue=t),null===(n=t.lastEffect)?t.lastEffect=e.next=e:(i=n.next,n.next=e,e.next=i,t.lastEffect=e),e}function Os(){return ss().memoizedState}function ks(e,t,n,i){var r=as();Ba.flags|=e,r.memoizedState=Ns(1|t,{destroy:void 0},n,void 0===i?null:i)}function Us(e,t,n,i){var r=ss();i=void 0===i?null:i;var a=r.memoizedState.inst;null!==Va&&null!==i&&Za(i,Va.memoizedState.deps)?r.memoizedState=Ns(t,a,n,i):(Ba.flags|=e,r.memoizedState=Ns(1|t,a,n,i))}function Fs(e,t){ks(8390656,8,e,t)}function zs(e,t){Us(2048,8,e,t)}function Bs(e){var t=ss().memoizedState;return function(e){Ba.flags|=4;var t=Ba.updateQueue;if(null===t)t={lastEffect:null,events:null,stores:null,memoCache:null},Ba.updateQueue=t,t.events=[e];else{var n=t.events;null===n?t.events=[e]:n.push(e)}}({ref:t,nextImpl:e}),function(){if(2&dc)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Vs(e,t){return Us(4,2,e,t)}function Hs(e,t){return Us(4,4,e,t)}function Gs(e,t){if("function"==typeof t){e=e();var n=t(e);return function(){"function"==typeof n?n():t(null)}}if(null!=t)return e=e(),t.current=e,function(){t.current=null}}function js(e,t,n){n=null!=n?n.concat([e]):null,Us(4,4,Gs.bind(null,t,e),n)}function Ws(){}function Xs(e,t){var n=ss();t=void 0===t?null:t;var i=n.memoizedState;return null!==t&&Za(t,i[1])?i[0]:(n.memoizedState=[e,t],e)}function qs(e,t){var n=ss();t=void 0===t?null:t;var i=n.memoizedState;if(null!==t&&Za(t,i[1]))return i[0];if(i=e(),Wa){ve(!0);try{e()}finally{ve(!1)}}return n.memoizedState=[i,t],i}function $s(e,t,n){return void 0===n||1073741824&za&&!(261930&pc)?e.memoizedState=t:(e.memoizedState=n,e=Wc(),Ba.lanes|=e,wc|=e,n)}function Ys(e,t,n,i){return Kn(n,t)?n:null!==Ea.current?(e=$s(e,n,i),Kn(e,t)||(Lo=!0),e):42&za&&(!(1073741824&za)||261930&pc)?(e=Wc(),Ba.lanes|=e,wc|=e,t):(Lo=!0,e.memoizedState=n)}function Ks(e,t,n,i,r){var a=D.p;D.p=0!==a&&8>a?a:8;var s,o,l,c=I.T,u={};I.T=u,lo(e,!1,t,n);try{var d=r(),h=I.S;if(null!==h&&h(u,d),null!==d&&"object"==typeof d&&"function"==typeof d.then){var f=(s=i,o=[],l={status:"pending",value:null,reason:null,then:function(e){o.push(e)}},d.then(function(){l.status="fulfilled",l.value=s;for(var e=0;e<o.length;e++)(0,o[e])(s)},function(e){for(l.status="rejected",l.reason=e,e=0;e<o.length;e++)(0,o[e])(void 0)}),l);oo(e,t,f,jc())}else oo(e,t,i,jc())}catch(n){oo(e,t,{then:function(){},status:"rejected",reason:n},jc())}finally{D.p=a,null!==c&&null!==u.types&&(c.types=u.types),I.T=c}}function Zs(){}function Qs(e,t,n,r){if(5!==e.tag)throw Error(i(476));var a=Js(e).queue;Ks(e,a,t,N,null===n?Zs:function(){return eo(e),n(r)})}function Js(e){var t=e.memoizedState;if(null!==t)return t;var n={};return(t={memoizedState:N,baseState:N,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:N},next:null}).next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:n},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function eo(e){var t=Js(e);null===t.next&&(t=e.alternate.memoizedState),oo(e,t.next.queue,{},jc())}function to(){return Pr(lh)}function no(){return ss().memoizedState}function io(){return ss().memoizedState}function ro(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var n=jc(),i=va(t,e=ga(n),n);return null!==i&&(Xc(i,t,n),ya(i,t,n)),t={cache:Ur()},void(e.payload=t)}t=t.return}}function ao(e,t,n){var i=jc();n={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},co(e)?uo(t,n):null!==(n=Pi(e,t,n,i))&&(Xc(n,e,i),ho(n,t,i))}function so(e,t,n){oo(e,t,n,jc())}function oo(e,t,n,i){var r={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(co(e))uo(t,r);else{var a=e.alternate;if(0===e.lanes&&(null===a||0===a.lanes)&&null!==(a=t.lastRenderedReducer))try{var s=t.lastRenderedState,o=a(s,n);if(r.hasEagerState=!0,r.eagerState=o,Kn(o,s))return Ci(e,t,r,0),null===hc&&Ri(),!1}catch(e){}if(null!==(n=Pi(e,t,r,i)))return Xc(n,e,i),ho(n,t,i),!0}return!1}function lo(e,t,n,r){if(r={lane:2,revertLane:Bu(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},co(e)){if(t)throw Error(i(479))}else null!==(t=Pi(e,n,r,2))&&Xc(t,e,2)}function co(e){var t=e.alternate;return e===Ba||null!==t&&t===Ba}function uo(e,t){ja=Ga=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ho(e,t,n){if(4194048&n){var i=t.lanes;n|=i&=e.pendingLanes,t.lanes=n,Ie(e,n)}}var fo={readContext:Pr,use:ls,useCallback:Ka,useContext:Ka,useEffect:Ka,useImperativeHandle:Ka,useLayoutEffect:Ka,useInsertionEffect:Ka,useMemo:Ka,useReducer:Ka,useRef:Ka,useState:Ka,useDebugValue:Ka,useDeferredValue:Ka,useTransition:Ka,useSyncExternalStore:Ka,useId:Ka,useHostTransitionStatus:Ka,useFormState:Ka,useActionState:Ka,useOptimistic:Ka,useMemoCache:Ka,useCacheRefresh:Ka};fo.useEffectEvent=Ka;var po={readContext:Pr,use:ls,useCallback:function(e,t){return as().memoizedState=[e,void 0===t?null:t],e},useContext:Pr,useEffect:Fs,useImperativeHandle:function(e,t,n){n=null!=n?n.concat([e]):null,ks(4194308,4,Gs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ks(4194308,4,e,t)},useInsertionEffect:function(e,t){ks(4,2,e,t)},useMemo:function(e,t){var n=as();t=void 0===t?null:t;var i=e();if(Wa){ve(!0);try{e()}finally{ve(!1)}}return n.memoizedState=[i,t],i},useReducer:function(e,t,n){var i=as();if(void 0!==n){var r=n(t);if(Wa){ve(!0);try{n(t)}finally{ve(!1)}}}else r=t;return i.memoizedState=i.baseState=r,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},i.queue=e,e=e.dispatch=ao.bind(null,Ba,e),[i.memoizedState,e]},useRef:function(e){return e={current:e},as().memoizedState=e},useState:function(e){var t=(e=_s(e)).queue,n=so.bind(null,Ba,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Ws,useDeferredValue:function(e,t){return $s(as(),e,t)},useTransition:function(){var e=_s(!1);return e=Ks.bind(null,Ba,e.queue,!0,!1),as().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Ba,a=as();if(cr){if(void 0===n)throw Error(i(407));n=n()}else{if(n=t(),null===hc)throw Error(i(349));127&pc||ms(r,t,n)}a.memoizedState=n;var s={value:n,getSnapshot:t};return a.queue=s,Fs(vs.bind(null,r,s,e),[e]),r.flags|=2048,Ns(9,{destroy:void 0},gs.bind(null,r,s,n,t),null),n},useId:function(){var e=as(),t=hc.identifierPrefix;if(cr){var n=tr;t="_"+t+"R_"+(n=(er&~(1<<32-ye(er)-1)).toString(32)+n),0<(n=Xa++)&&(t+="H"+n.toString(32)),t+="_"}else t="_"+t+"r_"+(n=Ya++).toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:to,useFormState:Cs,useActionState:Cs,useOptimistic:function(e){var t=as();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=lo.bind(null,Ba,!0,n),n.dispatch=t,[e,t]},useMemoCache:cs,useCacheRefresh:function(){return as().memoizedState=ro.bind(null,Ba)},useEffectEvent:function(e){var t=as(),n={impl:e};return t.memoizedState=n,function(){if(2&dc)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},mo={readContext:Pr,use:ls,useCallback:Xs,useContext:Pr,useEffect:zs,useImperativeHandle:js,useInsertionEffect:Vs,useLayoutEffect:Hs,useMemo:qs,useReducer:ds,useRef:Os,useState:function(){return ds(us)},useDebugValue:Ws,useDeferredValue:function(e,t){return Ys(ss(),Va.memoizedState,e,t)},useTransition:function(){var e=ds(us)[0],t=ss().memoizedState;return["boolean"==typeof e?e:os(e),t]},useSyncExternalStore:ps,useId:no,useHostTransitionStatus:to,useFormState:Ps,useActionState:Ps,useOptimistic:function(e,t){return bs(ss(),0,e,t)},useMemoCache:cs,useCacheRefresh:io};mo.useEffectEvent=Bs;var go={readContext:Pr,use:ls,useCallback:Xs,useContext:Pr,useEffect:zs,useImperativeHandle:js,useInsertionEffect:Vs,useLayoutEffect:Hs,useMemo:qs,useReducer:fs,useRef:Os,useState:function(){return fs(us)},useDebugValue:Ws,useDeferredValue:function(e,t){var n=ss();return null===Va?$s(n,e,t):Ys(n,Va.memoizedState,e,t)},useTransition:function(){var e=fs(us)[0],t=ss().memoizedState;return["boolean"==typeof e?e:os(e),t]},useSyncExternalStore:ps,useId:no,useHostTransitionStatus:to,useFormState:Ds,useActionState:Ds,useOptimistic:function(e,t){var n=ss();return null!==Va?bs(n,0,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:cs,useCacheRefresh:io};function vo(e,t,n,i){n=null==(n=n(i,t=e.memoizedState))?t:d({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}go.useEffectEvent=Bs;var yo={enqueueSetState:function(e,t,n){e=e._reactInternals;var i=jc(),r=ga(i);r.payload=t,null!=n&&(r.callback=n),null!==(t=va(e,r,i))&&(Xc(t,e,i),ya(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var i=jc(),r=ga(i);r.tag=1,r.payload=t,null!=n&&(r.callback=n),null!==(t=va(e,r,i))&&(Xc(t,e,i),ya(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=jc(),i=ga(n);i.tag=2,null!=t&&(i.callback=t),null!==(t=va(e,i,n))&&(Xc(t,e,n),ya(t,e,n))}};function xo(e,t,n,i,r,a,s){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(i,a,s):!(t.prototype&&t.prototype.isPureReactComponent&&Zn(n,i)&&Zn(r,a))}function _o(e,t,n,i){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,i),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,i),t.state!==e&&yo.enqueueReplaceState(t,t.state,null)}function bo(e,t){var n=t;if("ref"in t)for(var i in n={},t)"ref"!==i&&(n[i]=t[i]);if(e=e.defaultProps)for(var r in n===t&&(n=d({},n)),e)void 0===n[r]&&(n[r]=e[r]);return n}function wo(e){Mi(e)}function So(e){console.error(e)}function Mo(e){Mi(e)}function Eo(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function To(e,t,n){try{(0,e.onCaughtError)(n.value,{componentStack:n.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ao(e,t,n){return(n=ga(n)).tag=3,n.payload={element:null},n.callback=function(){Eo(e,t)},n}function Ro(e){return(e=ga(e)).tag=3,e}function Co(e,t,n,i){var r=n.type.getDerivedStateFromError;if("function"==typeof r){var a=i.value;e.payload=function(){return r(a)},e.callback=function(){To(t,n,i)}}var s=n.stateNode;null!==s&&"function"==typeof s.componentDidCatch&&(e.callback=function(){To(t,n,i),"function"!=typeof r&&(null===Nc?Nc=new Set([this]):Nc.add(this));var e=i.stack;this.componentDidCatch(i.value,{componentStack:null!==e?e:""})})}var Po=Error(i(461)),Lo=!1;function Io(e,t,n,i){t.child=null===e?ha(t,null,n,i):da(t,e.child,n,i)}function Do(e,t,n,i,r){n=n.render;var a=t.ref;if("ref"in i){var s={};for(var o in i)"ref"!==o&&(s[o]=i[o])}else s=i;return Cr(t),i=Qa(e,t,n,s,a,r),o=ns(),null===e||Lo?(cr&&o&&rr(t),t.flags|=1,Io(e,t,i,r),t.child):(is(e,t,r),nl(e,t,r))}function No(e,t,n,i,r){if(null===e){var a=n.type;return"function"!=typeof a||Ui(a)||void 0!==a.defaultProps||null!==n.compare?((e=Bi(n.type,null,i,t,t.mode,r)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=a,Oo(e,t,a,i,r))}if(a=e.child,!il(e,r)){var s=a.memoizedProps;if((n=null!==(n=n.compare)?n:Zn)(s,i)&&e.ref===t.ref)return nl(e,t,r)}return t.flags|=1,(e=Fi(a,i)).ref=t.ref,e.return=t,t.child=e}function Oo(e,t,n,i,r){if(null!==e){var a=e.memoizedProps;if(Zn(a,i)&&e.ref===t.ref){if(Lo=!1,t.pendingProps=i=a,!il(e,r))return t.lanes=e.lanes,nl(e,t,r);131072&e.flags&&(Lo=!0)}}return Ho(e,t,n,i,r)}function ko(e,t,n,i){var r=i.children,a=null!==e?e.memoizedState:null;if(null===e&&null===t.stateNode&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),"hidden"===i.mode){if(128&t.flags){if(a=null!==a?a.baseLanes|n:n,null!==e){for(i=t.child=e.child,r=0;null!==i;)r=r|i.lanes|i.childLanes,i=i.sibling;i=r&~a}else i=0,t.child=null;return Fo(e,t,a,n,i)}if(!(536870912&n))return i=t.lanes=536870912,Fo(e,t,null!==a?a.baseLanes|n:n,n,i);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&qr(0,null!==a?a.cachePool:null),null!==a?Aa(t,a):Ra(),Na(t)}else null!==a?(qr(0,a.cachePool),Aa(t,a),Oa(),t.memoizedState=null):(null!==e&&qr(0,null),Ra(),Oa());return Io(e,t,r,n),t.child}function Uo(e,t){return null!==e&&22===e.tag||null!==t.stateNode||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Fo(e,t,n,i,r){var a=Xr();return a=null===a?null:{parent:kr._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},null!==e&&qr(0,null),Ra(),Na(t),null!==e&&Ar(e,t,i,!0),t.childLanes=r,null}function zo(e,t){return(t=Zo({mode:t.mode,children:t.children},e.mode)).ref=e.ref,e.child=t,t.return=e,t}function Bo(e,t,n){return da(t,e.child,null,n),(e=zo(t,t.pendingProps)).flags|=2,ka(t),t.memoizedState=null,e}function Vo(e,t){var n=t.ref;if(null===n)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!=typeof n&&"object"!=typeof n)throw Error(i(284));null!==e&&e.ref===n||(t.flags|=4194816)}}function Ho(e,t,n,i,r){return Cr(t),n=Qa(e,t,n,i,void 0,r),i=ns(),null===e||Lo?(cr&&i&&rr(t),t.flags|=1,Io(e,t,n,r),t.child):(is(e,t,r),nl(e,t,r))}function Go(e,t,n,i,r,a){return Cr(t),t.updateQueue=null,n=es(t,i,n,r),Ja(e),i=ns(),null===e||Lo?(cr&&i&&rr(t),t.flags|=1,Io(e,t,n,a),t.child):(is(e,t,a),nl(e,t,a))}function jo(e,t,n,i,r){if(Cr(t),null===t.stateNode){var a=Ni,s=n.contextType;"object"==typeof s&&null!==s&&(a=Pr(s)),a=new n(i,a),t.memoizedState=null!==a.state&&void 0!==a.state?a.state:null,a.updater=yo,t.stateNode=a,a._reactInternals=t,(a=t.stateNode).props=i,a.state=t.memoizedState,a.refs={},pa(t),s=n.contextType,a.context="object"==typeof s&&null!==s?Pr(s):Ni,a.state=t.memoizedState,"function"==typeof(s=n.getDerivedStateFromProps)&&(vo(t,n,s,i),a.state=t.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof a.getSnapshotBeforeUpdate||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||(s=a.state,"function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount(),s!==a.state&&yo.enqueueReplaceState(a,a.state,null),wa(t,i,a,r),ba(),a.state=t.memoizedState),"function"==typeof a.componentDidMount&&(t.flags|=4194308),i=!0}else if(null===e){a=t.stateNode;var o=t.memoizedProps,l=bo(n,o);a.props=l;var c=a.context,u=n.contextType;s=Ni,"object"==typeof u&&null!==u&&(s=Pr(u));var d=n.getDerivedStateFromProps;u="function"==typeof d||"function"==typeof a.getSnapshotBeforeUpdate,o=t.pendingProps!==o,u||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(o||c!==s)&&_o(t,a,i,s),fa=!1;var h=t.memoizedState;a.state=h,wa(t,i,a,r),ba(),c=t.memoizedState,o||h!==c||fa?("function"==typeof d&&(vo(t,n,d,i),c=t.memoizedState),(l=fa||xo(t,n,l,i,h,c,s))?(u||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||("function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),"function"==typeof a.componentDidMount&&(t.flags|=4194308)):("function"==typeof a.componentDidMount&&(t.flags|=4194308),t.memoizedProps=i,t.memoizedState=c),a.props=i,a.state=c,a.context=s,i=l):("function"==typeof a.componentDidMount&&(t.flags|=4194308),i=!1)}else{a=t.stateNode,ma(e,t),u=bo(n,s=t.memoizedProps),a.props=u,d=t.pendingProps,h=a.context,c=n.contextType,l=Ni,"object"==typeof c&&null!==c&&(l=Pr(c)),(c="function"==typeof(o=n.getDerivedStateFromProps)||"function"==typeof a.getSnapshotBeforeUpdate)||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(s!==d||h!==l)&&_o(t,a,i,l),fa=!1,h=t.memoizedState,a.state=h,wa(t,i,a,r),ba();var f=t.memoizedState;s!==d||h!==f||fa||null!==e&&null!==e.dependencies&&Rr(e.dependencies)?("function"==typeof o&&(vo(t,n,o,i),f=t.memoizedState),(u=fa||xo(t,n,u,i,h,f,l)||null!==e&&null!==e.dependencies&&Rr(e.dependencies))?(c||"function"!=typeof a.UNSAFE_componentWillUpdate&&"function"!=typeof a.componentWillUpdate||("function"==typeof a.componentWillUpdate&&a.componentWillUpdate(i,f,l),"function"==typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(i,f,l)),"function"==typeof a.componentDidUpdate&&(t.flags|=4),"function"==typeof a.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof a.componentDidUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=i,t.memoizedState=f),a.props=i,a.state=f,a.context=l,i=u):("function"!=typeof a.componentDidUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),i=!1)}return a=i,Vo(e,t),i=!!(128&t.flags),a||i?(a=t.stateNode,n=i&&"function"!=typeof n.getDerivedStateFromError?null:a.render(),t.flags|=1,null!==e&&i?(t.child=da(t,e.child,null,r),t.child=da(t,null,n,r)):Io(e,t,n,r),t.memoizedState=a.state,e=t.child):e=nl(e,t,r),e}function Wo(e,t,n,i){return vr(),t.flags|=256,Io(e,t,n,i),t.child}var Xo={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function qo(e){return{baseLanes:e,cachePool:$r()}}function $o(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=Ec),e}function Yo(e,t,n){var r,a=t.pendingProps,s=!1,o=!!(128&t.flags);if((r=o)||(r=(null===e||null!==e.memoizedState)&&!!(2&Ua.current)),r&&(s=!0,t.flags&=-129),r=!!(32&t.flags),t.flags&=-33,null===e){if(cr){if(s?Ia(t):Oa(),(e=lr)?null!==(e=null!==(e=Rd(e,dr))&&"&"!==e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==Ji?{id:er,overflow:tr}:null,retryLane:536870912,hydrationErrors:null},(n=Gi(e)).return=t,t.child=n,or=t,lr=null):e=null,null===e)throw fr(t);return Pd(e)?t.lanes=32:t.lanes=536870912,null}var l=a.children;return a=a.fallback,s?(Oa(),l=Zo({mode:"hidden",children:l},s=t.mode),a=Vi(a,s,n,null),l.return=t,a.return=t,l.sibling=a,t.child=l,(a=t.child).memoizedState=qo(n),a.childLanes=$o(e,r,n),t.memoizedState=Xo,Uo(null,a)):(Ia(t),Ko(t,l))}var c=e.memoizedState;if(null!==c&&null!==(l=c.dehydrated)){if(o)256&t.flags?(Ia(t),t.flags&=-257,t=Qo(e,t,n)):null!==t.memoizedState?(Oa(),t.child=e.child,t.flags|=128,t=null):(Oa(),l=a.fallback,s=t.mode,a=Zo({mode:"visible",children:a.children},s),(l=Vi(l,s,n,null)).flags|=2,a.return=t,l.return=t,a.sibling=l,t.child=a,da(t,e.child,null,n),(a=t.child).memoizedState=qo(n),a.childLanes=$o(e,r,n),t.memoizedState=Xo,t=Uo(null,a));else if(Ia(t),Pd(l)){if(r=l.nextSibling&&l.nextSibling.dataset)var u=r.dgst;r=u,(a=Error(i(419))).stack="",a.digest=r,xr({value:a,source:null,stack:null}),t=Qo(e,t,n)}else if(Lo||Ar(e,t,n,!1),r=0!==(n&e.childLanes),Lo||r){if(null!==(r=hc)&&0!==(a=De(r,n))&&a!==c.retryLane)throw c.retryLane=a,Li(e,a),Xc(r,e,a),Po;Cd(l)||ru(),t=Qo(e,t,n)}else Cd(l)?(t.flags|=192,t.child=e.child,t=null):(e=c.treeContext,lr=Ld(l.nextSibling),or=t,cr=!0,ur=null,dr=!1,null!==e&&sr(t,e),(t=Ko(t,a.children)).flags|=4096);return t}return s?(Oa(),l=a.fallback,s=t.mode,u=(c=e.child).sibling,(a=Fi(c,{mode:"hidden",children:a.children})).subtreeFlags=65011712&c.subtreeFlags,null!==u?l=Fi(u,l):(l=Vi(l,s,n,null)).flags|=2,l.return=t,a.return=t,a.sibling=l,t.child=a,Uo(null,a),a=t.child,null===(l=e.child.memoizedState)?l=qo(n):(null!==(s=l.cachePool)?(c=kr._currentValue,s=s.parent!==c?{parent:c,pool:c}:s):s=$r(),l={baseLanes:l.baseLanes|n,cachePool:s}),a.memoizedState=l,a.childLanes=$o(e,r,n),t.memoizedState=Xo,Uo(e.child,a)):(Ia(t),e=(n=e.child).sibling,(n=Fi(n,{mode:"visible",children:a.children})).return=t,n.sibling=null,null!==e&&(null===(r=t.deletions)?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=n,t.memoizedState=null,n)}function Ko(e,t){return(t=Zo({mode:"visible",children:t},e.mode)).return=e,e.child=t}function Zo(e,t){return(e=ki(22,e,null,t)).lanes=0,e}function Qo(e,t,n){return da(t,e.child,null,n),(e=Ko(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function Jo(e,t,n){e.lanes|=t;var i=e.alternate;null!==i&&(i.lanes|=t),Er(e.return,t,n)}function el(e,t,n,i,r,a){var s=e.memoizedState;null===s?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:i,tail:n,tailMode:r,treeForkCount:a}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=i,s.tail=n,s.tailMode=r,s.treeForkCount=a)}function tl(e,t,n){var i=t.pendingProps,r=i.revealOrder,a=i.tail;i=i.children;var s=Ua.current,o=!!(2&s);if(o?(s=1&s|2,t.flags|=128):s&=1,z(Ua,s),Io(e,t,i,n),i=cr?Ki:0,!o&&null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Jo(e,n,t);else if(19===e.tag)Jo(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(r){case"forwards":for(n=t.child,r=null;null!==n;)null!==(e=n.alternate)&&null===Fa(e)&&(r=n),n=n.sibling;null===(n=r)?(r=t.child,t.child=null):(r=n.sibling,n.sibling=null),el(t,!1,r,n,a,i);break;case"backwards":case"unstable_legacy-backwards":for(n=null,r=t.child,t.child=null;null!==r;){if(null!==(e=r.alternate)&&null===Fa(e)){t.child=r;break}e=r.sibling,r.sibling=n,n=r,r=e}el(t,!0,n,null,a,i);break;case"together":el(t,!1,null,null,void 0,i);break;default:t.memoizedState=null}return t.child}function nl(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),wc|=t.lanes,0===(n&t.childLanes)){if(null===e)return null;if(Ar(e,t,n,!1),0===(n&t.childLanes))return null}if(null!==e&&t.child!==e.child)throw Error(i(153));if(null!==t.child){for(n=Fi(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=Fi(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function il(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!Rr(e))}function rl(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)Lo=!0;else{if(!(il(e,n)||128&t.flags))return Lo=!1,function(e,t,n){switch(t.tag){case 3:X(t,t.stateNode.containerInfo),Sr(0,kr,e.memoizedState.cache),vr();break;case 27:case 5:$(t);break;case 4:X(t,t.stateNode.containerInfo);break;case 10:Sr(0,t.type,t.memoizedProps.value);break;case 31:if(null!==t.memoizedState)return t.flags|=128,Da(t),null;break;case 13:var i=t.memoizedState;if(null!==i)return null!==i.dehydrated?(Ia(t),t.flags|=128,null):0!==(n&t.child.childLanes)?Yo(e,t,n):(Ia(t),null!==(e=nl(e,t,n))?e.sibling:null);Ia(t);break;case 19:var r=!!(128&e.flags);if((i=0!==(n&t.childLanes))||(Ar(e,t,n,!1),i=0!==(n&t.childLanes)),r){if(i)return tl(e,t,n);t.flags|=128}if(null!==(r=t.memoizedState)&&(r.rendering=null,r.tail=null,r.lastEffect=null),z(Ua,Ua.current),i)break;return null;case 22:return t.lanes=0,ko(e,t,n,t.pendingProps);case 24:Sr(0,kr,e.memoizedState.cache)}return nl(e,t,n)}(e,t,n);Lo=!!(131072&e.flags)}else Lo=!1,cr&&1048576&t.flags&&ir(t,Ki,t.index);switch(t.lanes=0,t.tag){case 16:e:{var r=t.pendingProps;if(e=ta(t.elementType),t.type=e,"function"!=typeof e){if(null!=e){var a=e.$$typeof;if(a===_){t.tag=11,t=Do(null,t,e,r,n);break e}if(a===S){t.tag=14,t=No(null,t,e,r,n);break e}}throw t=P(e)||e,Error(i(306,t,""))}Ui(e)?(r=bo(e,r),t.tag=1,t=jo(null,t,e,r,n)):(t.tag=0,t=Ho(null,t,e,r,n))}return t;case 0:return Ho(e,t,t.type,t.pendingProps,n);case 1:return jo(e,t,r=t.type,a=bo(r,t.pendingProps),n);case 3:e:{if(X(t,t.stateNode.containerInfo),null===e)throw Error(i(387));r=t.pendingProps;var s=t.memoizedState;a=s.element,ma(e,t),wa(t,r,null,n);var o=t.memoizedState;if(r=o.cache,Sr(0,kr,r),r!==s.cache&&Tr(t,[kr],n,!0),ba(),r=o.element,s.isDehydrated){if(s={element:r,isDehydrated:!1,cache:o.cache},t.updateQueue.baseState=s,t.memoizedState=s,256&t.flags){t=Wo(e,t,r,n);break e}if(r!==a){xr(a=Xi(Error(i(424)),t)),t=Wo(e,t,r,n);break e}for(e=9===(e=t.stateNode.containerInfo).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,lr=Ld(e.firstChild),or=t,cr=!0,ur=null,dr=!0,n=ha(t,null,r,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(vr(),r===a){t=nl(e,t,n);break e}Io(e,t,r,n)}t=t.child}return t;case 26:return Vo(e,t),null===e?(n=Gd(t.type,null,t.pendingProps,null))?t.memoizedState=n:cr||(n=t.type,e=t.pendingProps,(r=pd(j.current).createElement(n))[ze]=t,r[Be]=e,ud(r,n,e),Qe(r),t.stateNode=r):t.memoizedState=Gd(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return $(t),null===e&&cr&&(r=t.stateNode=Od(t.type,t.pendingProps,j.current),or=t,dr=!0,a=lr,Md(t.type)?(Id=a,lr=Ld(r.firstChild)):lr=a),Io(e,t,t.pendingProps.children,n),Vo(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&cr&&((a=r=lr)&&(null!==(r=function(e,t,n,i){for(;1===e.nodeType;){var r=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!i&&("INPUT"!==e.nodeName||"hidden"!==e.type))break}else if(i){if(!e[Xe])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if("stylesheet"===(a=e.getAttribute("rel"))&&e.hasAttribute("data-precedence"))break;if(a!==r.rel||e.getAttribute("href")!==(null==r.href||""===r.href?null:r.href)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin)||e.getAttribute("title")!==(null==r.title?null:r.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(((a=e.getAttribute("src"))!==(null==r.src?null:r.src)||e.getAttribute("type")!==(null==r.type?null:r.type)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin))&&a&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else{if("input"!==t||"hidden"!==e.type)return e;var a=null==r.name?null:""+r.name;if("hidden"===r.type&&e.getAttribute("name")===a)return e}if(null===(e=Ld(e.nextSibling)))break}return null}(r,t.type,t.pendingProps,dr))?(t.stateNode=r,or=t,lr=Ld(r.firstChild),dr=!1,a=!0):a=!1),a||fr(t)),$(t),a=t.type,s=t.pendingProps,o=null!==e?e.memoizedProps:null,r=s.children,vd(a,s)?r=null:null!==o&&vd(a,o)&&(t.flags|=32),null!==t.memoizedState&&(a=Qa(e,t,ts,null,null,n),lh._currentValue=a),Vo(e,t),Io(e,t,r,n),t.child;case 6:return null===e&&cr&&((e=n=lr)&&(null!==(n=function(e,t,n){if(""===t)return null;for(;3!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!n)return null;if(null===(e=Ld(e.nextSibling)))return null}return e}(n,t.pendingProps,dr))?(t.stateNode=n,or=t,lr=null,e=!0):e=!1),e||fr(t)),null;case 13:return Yo(e,t,n);case 4:return X(t,t.stateNode.containerInfo),r=t.pendingProps,null===e?t.child=da(t,null,r,n):Io(e,t,r,n),t.child;case 11:return Do(e,t,t.type,t.pendingProps,n);case 7:return Io(e,t,t.pendingProps,n),t.child;case 8:case 12:return Io(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Sr(0,t.type,r.value),Io(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Cr(t),r=r(a=Pr(a)),t.flags|=1,Io(e,t,r,n),t.child;case 14:return No(e,t,t.type,t.pendingProps,n);case 15:return Oo(e,t,t.type,t.pendingProps,n);case 19:return tl(e,t,n);case 31:return function(e,t,n){var r=t.pendingProps,a=!!(128&t.flags);if(t.flags&=-129,null===e){if(cr){if("hidden"===r.mode)return e=zo(t,r),t.lanes=536870912,Uo(null,e);if(Da(t),(e=lr)?null!==(e=null!==(e=Rd(e,dr))&&"&"===e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==Ji?{id:er,overflow:tr}:null,retryLane:536870912,hydrationErrors:null},(n=Gi(e)).return=t,t.child=n,or=t,lr=null):e=null,null===e)throw fr(t);return t.lanes=536870912,null}return zo(t,r)}var s=e.memoizedState;if(null!==s){var o=s.dehydrated;if(Da(t),a)if(256&t.flags)t.flags&=-257,t=Bo(e,t,n);else{if(null===t.memoizedState)throw Error(i(558));t.child=e.child,t.flags|=128,t=null}else if(Lo||Ar(e,t,n,!1),a=0!==(n&e.childLanes),Lo||a){if(null!==(r=hc)&&0!==(o=De(r,n))&&o!==s.retryLane)throw s.retryLane=o,Li(e,o),Xc(r,e,o),Po;ru(),t=Bo(e,t,n)}else e=s.treeContext,lr=Ld(o.nextSibling),or=t,cr=!0,ur=null,dr=!1,null!==e&&sr(t,e),(t=zo(t,r)).flags|=4096;return t}return(e=Fi(e.child,{mode:r.mode,children:r.children})).ref=t.ref,t.child=e,e.return=t,e}(e,t,n);case 22:return ko(e,t,n,t.pendingProps);case 24:return Cr(t),r=Pr(kr),null===e?(null===(a=Xr())&&(a=hc,s=Ur(),a.pooledCache=s,s.refCount++,null!==s&&(a.pooledCacheLanes|=n),a=s),t.memoizedState={parent:r,cache:a},pa(t),Sr(0,kr,a)):(0!==(e.lanes&n)&&(ma(e,t),wa(t,null,null,n),ba()),a=e.memoizedState,s=t.memoizedState,a.parent!==r?(a={parent:r,cache:r},t.memoizedState=a,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=a),Sr(0,kr,r)):(r=s.cache,Sr(0,kr,r),r!==a.cache&&Tr(t,[kr],n,!0))),Io(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function al(e){e.flags|=4}function sl(e,t,n,i,r){if((t=!!(32&e.mode))&&(t=!1),t){if(e.flags|=16777216,(335544128&r)===r)if(e.stateNode.complete)e.flags|=8192;else{if(!tu())throw na=Qr,Kr;e.flags|=8192}}else e.flags&=-16777217}function ol(e,t){if("stylesheet"!==t.type||4&t.state.loading)e.flags&=-16777217;else if(e.flags|=16777216,!nh(t)){if(!tu())throw na=Qr,Kr;e.flags|=8192}}function ll(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?Re():536870912,e.lanes|=t,Tc|=t)}function cl(e,t){if(!cr)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var i=null;null!==n;)null!==n.alternate&&(i=n),n=n.sibling;null===i?t||null===e.tail?e.tail=null:e.tail.sibling=null:i.sibling=null}}function ul(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,i=0;if(t)for(var r=e.child;null!==r;)n|=r.lanes|r.childLanes,i|=65011712&r.subtreeFlags,i|=65011712&r.flags,r.return=e,r=r.sibling;else for(r=e.child;null!==r;)n|=r.lanes|r.childLanes,i|=r.subtreeFlags,i|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=i,e.childLanes=n,t}function dl(e,t,n){var r=t.pendingProps;switch(ar(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return ul(t),null;case 3:return n=t.stateNode,r=null,null!==e&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Mr(kr),q(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(gr(t)?al(t):null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,yr())),ul(t),null;case 26:var a=t.type,s=t.memoizedState;return null===e?(al(t),null!==s?(ul(t),ol(t,s)):(ul(t),sl(t,a,0,0,n))):s?s!==e.memoizedState?(al(t),ul(t),ol(t,s)):(ul(t),t.flags&=-16777217):((e=e.memoizedProps)!==r&&al(t),ul(t),sl(t,a,0,0,n)),null;case 27:if(Y(t),n=j.current,a=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==r&&al(t);else{if(!r){if(null===t.stateNode)throw Error(i(166));return ul(t),null}e=H.current,gr(t)?pr(t):(e=Od(a,r,n),t.stateNode=e,al(t))}return ul(t),null;case 5:if(Y(t),a=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==r&&al(t);else{if(!r){if(null===t.stateNode)throw Error(i(166));return ul(t),null}if(s=H.current,gr(t))pr(t);else{var o=pd(j.current);switch(s){case 1:s=o.createElementNS("http://www.w3.org/2000/svg",a);break;case 2:s=o.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;default:switch(a){case"svg":s=o.createElementNS("http://www.w3.org/2000/svg",a);break;case"math":s=o.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;case"script":(s=o.createElement("div")).innerHTML="<script><\/script>",s=s.removeChild(s.firstChild);break;case"select":s="string"==typeof r.is?o.createElement("select",{is:r.is}):o.createElement("select"),r.multiple?s.multiple=!0:r.size&&(s.size=r.size);break;default:s="string"==typeof r.is?o.createElement(a,{is:r.is}):o.createElement(a)}}s[ze]=t,s[Be]=r;e:for(o=t.child;null!==o;){if(5===o.tag||6===o.tag)s.appendChild(o.stateNode);else if(4!==o.tag&&27!==o.tag&&null!==o.child){o.child.return=o,o=o.child;continue}if(o===t)break e;for(;null===o.sibling;){if(null===o.return||o.return===t)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}t.stateNode=s;e:switch(ud(s,a,r),a){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}r&&al(t)}}return ul(t),sl(t,t.type,null===e||e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==r&&al(t);else{if("string"!=typeof r&&null===t.stateNode)throw Error(i(166));if(e=j.current,gr(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,null!==(a=or))switch(a.tag){case 27:case 5:r=a.memoizedProps}e[ze]=t,(e=!!(e.nodeValue===n||null!==r&&!0===r.suppressHydrationWarning||od(e.nodeValue,n)))||fr(t,!0)}else(e=pd(e).createTextNode(r))[ze]=t,t.stateNode=e}return ul(t),null;case 31:if(n=t.memoizedState,null===e||null!==e.memoizedState){if(r=gr(t),null!==n){if(null===e){if(!r)throw Error(i(318));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(i(557));e[ze]=t}else vr(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;ul(t),e=!1}else n=yr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return 256&t.flags?(ka(t),t):(ka(t),null);if(128&t.flags)throw Error(i(558))}return ul(t),null;case 13:if(r=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(a=gr(t),null!==r&&null!==r.dehydrated){if(null===e){if(!a)throw Error(i(318));if(!(a=null!==(a=t.memoizedState)?a.dehydrated:null))throw Error(i(317));a[ze]=t}else vr(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;ul(t),a=!1}else a=yr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return 256&t.flags?(ka(t),t):(ka(t),null)}return ka(t),128&t.flags?(t.lanes=n,t):(n=null!==r,e=null!==e&&null!==e.memoizedState,n&&(a=null,null!==(r=t.child).alternate&&null!==r.alternate.memoizedState&&null!==r.alternate.memoizedState.cachePool&&(a=r.alternate.memoizedState.cachePool.pool),s=null,null!==r.memoizedState&&null!==r.memoizedState.cachePool&&(s=r.memoizedState.cachePool.pool),s!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),ll(t,t.updateQueue),ul(t),null);case 4:return q(),null===e&&Zu(t.stateNode.containerInfo),ul(t),null;case 10:return Mr(t.type),ul(t),null;case 19:if(F(Ua),null===(r=t.memoizedState))return ul(t),null;if(a=!!(128&t.flags),null===(s=r.rendering))if(a)cl(r,!1);else{if(0!==bc||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(s=Fa(e))){for(t.flags|=128,cl(r,!1),e=s.updateQueue,t.updateQueue=e,ll(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)zi(n,e),n=n.sibling;return z(Ua,1&Ua.current|2),cr&&nr(t,r.treeForkCount),t.child}e=e.sibling}null!==r.tail&&se()>Ic&&(t.flags|=128,a=!0,cl(r,!1),t.lanes=4194304)}else{if(!a)if(null!==(e=Fa(s))){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,ll(t,e),cl(r,!0),null===r.tail&&"hidden"===r.tailMode&&!s.alternate&&!cr)return ul(t),null}else 2*se()-r.renderingStartTime>Ic&&536870912!==n&&(t.flags|=128,a=!0,cl(r,!1),t.lanes=4194304);r.isBackwards?(s.sibling=t.child,t.child=s):(null!==(e=r.last)?e.sibling=s:t.child=s,r.last=s)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=se(),e.sibling=null,n=Ua.current,z(Ua,a?1&n|2:1&n),cr&&nr(t,r.treeForkCount),e):(ul(t),null);case 22:case 23:return ka(t),Ca(),r=null!==t.memoizedState,null!==e?null!==e.memoizedState!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?!!(536870912&n)&&!(128&t.flags)&&(ul(t),6&t.subtreeFlags&&(t.flags|=8192)):ul(t),null!==(n=t.updateQueue)&&ll(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),r=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),null!==e&&F(Wr),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Mr(kr),ul(t),null;case 25:case 30:return null}throw Error(i(156,t.tag))}function hl(e,t){switch(ar(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Mr(kr),q(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return Y(t),null;case 31:if(null!==t.memoizedState){if(ka(t),null===t.alternate)throw Error(i(340));vr()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(ka(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(i(340));vr()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return F(Ua),null;case 4:return q(),null;case 10:return Mr(t.type),null;case 22:case 23:return ka(t),Ca(),null!==e&&F(Wr),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return Mr(kr),null;default:return null}}function fl(e,t){switch(ar(t),t.tag){case 3:Mr(kr),q();break;case 26:case 27:case 5:Y(t);break;case 4:q();break;case 31:null!==t.memoizedState&&ka(t);break;case 13:ka(t);break;case 19:F(Ua);break;case 10:Mr(t.type);break;case 22:case 23:ka(t),Ca(),null!==e&&F(Wr);break;case 24:Mr(kr)}}function pl(e,t){try{var n=t.updateQueue,i=null!==n?n.lastEffect:null;if(null!==i){var r=i.next;n=r;do{if((n.tag&e)===e){i=void 0;var a=n.create,s=n.inst;i=a(),s.destroy=i}n=n.next}while(n!==r)}}catch(e){bu(t,t.return,e)}}function ml(e,t,n){try{var i=t.updateQueue,r=null!==i?i.lastEffect:null;if(null!==r){var a=r.next;i=a;do{if((i.tag&e)===e){var s=i.inst,o=s.destroy;if(void 0!==o){s.destroy=void 0,r=t;var l=n,c=o;try{c()}catch(e){bu(r,l,e)}}}i=i.next}while(i!==a)}}catch(e){bu(t,t.return,e)}}function gl(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{Ma(t,n)}catch(t){bu(e,e.return,t)}}}function vl(e,t,n){n.props=bo(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){bu(e,t,n)}}function yl(e,t){try{var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;default:i=e.stateNode}"function"==typeof n?e.refCleanup=n(i):n.current=i}}catch(n){bu(e,t,n)}}function xl(e,t){var n=e.ref,i=e.refCleanup;if(null!==n)if("function"==typeof i)try{i()}catch(n){bu(e,t,n)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof n)try{n(null)}catch(n){bu(e,t,n)}else n.current=null}function _l(e){var t=e.type,n=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&i.focus();break e;case"img":n.src?i.src=n.src:n.srcSet&&(i.srcset=n.srcSet)}}catch(t){bu(e,e.return,t)}}function bl(e,t,n){try{var r=e.stateNode;!function(e,t,n,r){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var a=null,s=null,o=null,l=null,c=null,u=null,d=null;for(p in n){var h=n[p];if(n.hasOwnProperty(p)&&null!=h)switch(p){case"checked":case"value":break;case"defaultValue":c=h;default:r.hasOwnProperty(p)||ld(e,t,p,null,r,h)}}for(var f in r){var p=r[f];if(h=n[f],r.hasOwnProperty(f)&&(null!=p||null!=h))switch(f){case"type":s=p;break;case"name":a=p;break;case"checked":u=p;break;case"defaultChecked":d=p;break;case"value":o=p;break;case"defaultValue":l=p;break;case"children":case"dangerouslySetInnerHTML":if(null!=p)throw Error(i(137,t));break;default:p!==h&&ld(e,t,f,p,r,h)}}return void gt(e,o,l,c,u,d,s,a);case"select":for(s in p=o=l=f=null,n)if(c=n[s],n.hasOwnProperty(s)&&null!=c)switch(s){case"value":break;case"multiple":p=c;default:r.hasOwnProperty(s)||ld(e,t,s,null,r,c)}for(a in r)if(s=r[a],c=n[a],r.hasOwnProperty(a)&&(null!=s||null!=c))switch(a){case"value":f=s;break;case"defaultValue":l=s;break;case"multiple":o=s;default:s!==c&&ld(e,t,a,s,r,c)}return t=l,n=o,r=p,void(null!=f?xt(e,!!n,f,!1):!!r!=!!n&&(null!=t?xt(e,!!n,t,!0):xt(e,!!n,n?[]:"",!1)));case"textarea":for(l in p=f=null,n)if(a=n[l],n.hasOwnProperty(l)&&null!=a&&!r.hasOwnProperty(l))switch(l){case"value":case"children":break;default:ld(e,t,l,null,r,a)}for(o in r)if(a=r[o],s=n[o],r.hasOwnProperty(o)&&(null!=a||null!=s))switch(o){case"value":f=a;break;case"defaultValue":p=a;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=a)throw Error(i(91));break;default:a!==s&&ld(e,t,o,a,r,s)}return void _t(e,f,p);case"option":for(var m in n)f=n[m],n.hasOwnProperty(m)&&null!=f&&!r.hasOwnProperty(m)&&("selected"===m?e.selected=!1:ld(e,t,m,null,r,f));for(c in r)f=r[c],p=n[c],!r.hasOwnProperty(c)||f===p||null==f&&null==p||("selected"===c?e.selected=f&&"function"!=typeof f&&"symbol"!=typeof f:ld(e,t,c,f,r,p));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var g in n)f=n[g],n.hasOwnProperty(g)&&null!=f&&!r.hasOwnProperty(g)&&ld(e,t,g,null,r,f);for(u in r)if(f=r[u],p=n[u],r.hasOwnProperty(u)&&f!==p&&(null!=f||null!=p))switch(u){case"children":case"dangerouslySetInnerHTML":if(null!=f)throw Error(i(137,t));break;default:ld(e,t,u,f,r,p)}return;default:if(Tt(t)){for(var v in n)f=n[v],n.hasOwnProperty(v)&&void 0!==f&&!r.hasOwnProperty(v)&&cd(e,t,v,void 0,r,f);for(d in r)f=r[d],p=n[d],!r.hasOwnProperty(d)||f===p||void 0===f&&void 0===p||cd(e,t,d,f,r,p);return}}for(var y in n)f=n[y],n.hasOwnProperty(y)&&null!=f&&!r.hasOwnProperty(y)&&ld(e,t,y,null,r,f);for(h in r)f=r[h],p=n[h],!r.hasOwnProperty(h)||f===p||null==f&&null==p||ld(e,t,h,f,r,p)}(r,e.type,n,t),r[Be]=t}catch(t){bu(e,e.return,t)}}function wl(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&Md(e.type)||4===e.tag}function Sl(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||wl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(27===e.tag&&Md(e.type))continue e;if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function Ml(e,t,n){var i=e.tag;if(5===i||6===i)e=e.stateNode,t?(9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).insertBefore(e,t):((t=9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=Pt));else if(4!==i&&(27===i&&Md(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(Ml(e,t,n),e=e.sibling;null!==e;)Ml(e,t,n),e=e.sibling}function El(e,t,n){var i=e.tag;if(5===i||6===i)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==i&&(27===i&&Md(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(El(e,t,n),e=e.sibling;null!==e;)El(e,t,n),e=e.sibling}function Tl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var i=e.type,r=t.attributes;r.length;)t.removeAttributeNode(r[0]);ud(t,i,n),t[ze]=e,t[Be]=n}catch(t){bu(e,e.return,t)}}var Al=!1,Rl=!1,Cl=!1,Pl="function"==typeof WeakSet?WeakSet:Set,Ll=null;function Il(e,t,n){var i=n.flags;switch(n.tag){case 0:case 11:case 15:Xl(e,n),4&i&&pl(5,n);break;case 1:if(Xl(e,n),4&i)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(e){bu(n,n.return,e)}else{var r=bo(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(r,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){bu(n,n.return,e)}}64&i&&gl(n),512&i&&yl(n,n.return);break;case 3:if(Xl(e,n),64&i&&null!==(e=n.updateQueue)){if(t=null,null!==n.child)switch(n.child.tag){case 27:case 5:case 1:t=n.child.stateNode}try{Ma(e,t)}catch(e){bu(n,n.return,e)}}break;case 27:null===t&&4&i&&Tl(n);case 26:case 5:Xl(e,n),null===t&&4&i&&_l(n),512&i&&yl(n,n.return);break;case 12:Xl(e,n);break;case 31:Xl(e,n),4&i&&Fl(e,n);break;case 13:Xl(e,n),4&i&&zl(e,n),64&i&&null!==(e=n.memoizedState)&&null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$~"===e.data)e._reactRetry=t;else if("$?"!==e.data||"loading"!==n.readyState)t();else{var i=function(){t(),n.removeEventListener("DOMContentLoaded",i)};n.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}(e,n=Eu.bind(null,n));break;case 22:if(!(i=null!==n.memoizedState||Al)){t=null!==t&&null!==t.memoizedState||Rl,r=Al;var a=Rl;Al=i,(Rl=t)&&!a?$l(e,n,!!(8772&n.subtreeFlags)):Xl(e,n),Al=r,Rl=a}break;case 30:break;default:Xl(e,n)}}function Dl(e){var t=e.alternate;null!==t&&(e.alternate=null,Dl(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&null!==(t=e.stateNode)&&qe(t),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Nl=null,Ol=!1;function kl(e,t,n){for(n=n.child;null!==n;)Ul(e,t,n),n=n.sibling}function Ul(e,t,n){if(ge&&"function"==typeof ge.onCommitFiberUnmount)try{ge.onCommitFiberUnmount(me,n)}catch(e){}switch(n.tag){case 26:Rl||xl(n,t),kl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:Rl||xl(n,t);var i=Nl,r=Ol;Md(n.type)&&(Nl=n.stateNode,Ol=!1),kl(e,t,n),kd(n.stateNode),Nl=i,Ol=r;break;case 5:Rl||xl(n,t);case 6:if(i=Nl,r=Ol,Nl=null,kl(e,t,n),Ol=r,null!==(Nl=i))if(Ol)try{(9===Nl.nodeType?Nl.body:"HTML"===Nl.nodeName?Nl.ownerDocument.body:Nl).removeChild(n.stateNode)}catch(e){bu(n,t,e)}else try{Nl.removeChild(n.stateNode)}catch(e){bu(n,t,e)}break;case 18:null!==Nl&&(Ol?(Ed(9===(e=Nl).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Hh(e)):Ed(Nl,n.stateNode));break;case 4:i=Nl,r=Ol,Nl=n.stateNode.containerInfo,Ol=!0,kl(e,t,n),Nl=i,Ol=r;break;case 0:case 11:case 14:case 15:ml(2,n,t),Rl||ml(4,n,t),kl(e,t,n);break;case 1:Rl||(xl(n,t),"function"==typeof(i=n.stateNode).componentWillUnmount&&vl(n,t,i)),kl(e,t,n);break;case 21:kl(e,t,n);break;case 22:Rl=(i=Rl)||null!==n.memoizedState,kl(e,t,n),Rl=i;break;default:kl(e,t,n)}}function Fl(e,t){if(null===t.memoizedState&&null!==(e=t.alternate)&&null!==(e=e.memoizedState)){e=e.dehydrated;try{Hh(e)}catch(e){bu(t,t.return,e)}}}function zl(e,t){if(null===t.memoizedState&&null!==(e=t.alternate)&&null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))try{Hh(e)}catch(e){bu(t,t.return,e)}}function Bl(e,t){var n=function(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new Pl),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new Pl),t;default:throw Error(i(435,e.tag))}}(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var i=Tu.bind(null,e,t);t.then(i,i)}})}function Vl(e,t){var n=t.deletions;if(null!==n)for(var r=0;r<n.length;r++){var a=n[r],s=e,o=t,l=o;e:for(;null!==l;){switch(l.tag){case 27:if(Md(l.type)){Nl=l.stateNode,Ol=!1;break e}break;case 5:Nl=l.stateNode,Ol=!1;break e;case 3:case 4:Nl=l.stateNode.containerInfo,Ol=!0;break e}l=l.return}if(null===Nl)throw Error(i(160));Ul(s,o,a),Nl=null,Ol=!1,null!==(s=a.alternate)&&(s.return=null),a.return=null}if(13886&t.subtreeFlags)for(t=t.child;null!==t;)Gl(t,e),t=t.sibling}var Hl=null;function Gl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Vl(t,e),jl(e),4&r&&(ml(3,e,e.return),pl(3,e),ml(5,e,e.return));break;case 1:Vl(t,e),jl(e),512&r&&(Rl||null===n||xl(n,n.return)),64&r&&Al&&null!==(e=e.updateQueue)&&null!==(r=e.callbacks)&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=null===n?r:n.concat(r));break;case 26:var a=Hl;if(Vl(t,e),jl(e),512&r&&(Rl||null===n||xl(n,n.return)),4&r){var s=null!==n?n.memoizedState:null;if(r=e.memoizedState,null===n)if(null===r)if(null===e.stateNode){e:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;t:switch(r){case"title":(!(s=a.getElementsByTagName("title")[0])||s[Xe]||s[ze]||"http://www.w3.org/2000/svg"===s.namespaceURI||s.hasAttribute("itemprop"))&&(s=a.createElement(r),a.head.insertBefore(s,a.querySelector("head > title"))),ud(s,r,n),s[ze]=e,Qe(s),r=s;break e;case"link":var o=eh("link","href",a).get(r+(n.href||""));if(o)for(var l=0;l<o.length;l++)if((s=o[l]).getAttribute("href")===(null==n.href||""===n.href?null:n.href)&&s.getAttribute("rel")===(null==n.rel?null:n.rel)&&s.getAttribute("title")===(null==n.title?null:n.title)&&s.getAttribute("crossorigin")===(null==n.crossOrigin?null:n.crossOrigin)){o.splice(l,1);break t}ud(s=a.createElement(r),r,n),a.head.appendChild(s);break;case"meta":if(o=eh("meta","content",a).get(r+(n.content||"")))for(l=0;l<o.length;l++)if((s=o[l]).getAttribute("content")===(null==n.content?null:""+n.content)&&s.getAttribute("name")===(null==n.name?null:n.name)&&s.getAttribute("property")===(null==n.property?null:n.property)&&s.getAttribute("http-equiv")===(null==n.httpEquiv?null:n.httpEquiv)&&s.getAttribute("charset")===(null==n.charSet?null:n.charSet)){o.splice(l,1);break t}ud(s=a.createElement(r),r,n),a.head.appendChild(s);break;default:throw Error(i(468,r))}s[ze]=e,Qe(s),r=s}e.stateNode=r}else th(a,e.type,e.stateNode);else e.stateNode=Yd(a,r,e.memoizedProps);else s!==r?(null===s?null!==n.stateNode&&(n=n.stateNode).parentNode.removeChild(n):s.count--,null===r?th(a,e.type,e.stateNode):Yd(a,r,e.memoizedProps)):null===r&&null!==e.stateNode&&bl(e,e.memoizedProps,n.memoizedProps)}break;case 27:Vl(t,e),jl(e),512&r&&(Rl||null===n||xl(n,n.return)),null!==n&&4&r&&bl(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Vl(t,e),jl(e),512&r&&(Rl||null===n||xl(n,n.return)),32&e.flags){a=e.stateNode;try{wt(a,"")}catch(t){bu(e,e.return,t)}}4&r&&null!=e.stateNode&&bl(e,a=e.memoizedProps,null!==n?n.memoizedProps:a),1024&r&&(Cl=!0);break;case 6:if(Vl(t,e),jl(e),4&r){if(null===e.stateNode)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){bu(e,e.return,t)}}break;case 3:if(Jd=null,a=Hl,Hl=zd(t.containerInfo),Vl(t,e),Hl=a,jl(e),4&r&&null!==n&&n.memoizedState.isDehydrated)try{Hh(t.containerInfo)}catch(t){bu(e,e.return,t)}Cl&&(Cl=!1,Wl(e));break;case 4:r=Hl,Hl=zd(e.stateNode.containerInfo),Vl(t,e),jl(e),Hl=r;break;case 12:default:Vl(t,e),jl(e);break;case 31:case 19:Vl(t,e),jl(e),4&r&&null!==(r=e.updateQueue)&&(e.updateQueue=null,Bl(e,r));break;case 13:Vl(t,e),jl(e),8192&e.child.flags&&null!==e.memoizedState!=(null!==n&&null!==n.memoizedState)&&(Pc=se()),4&r&&null!==(r=e.updateQueue)&&(e.updateQueue=null,Bl(e,r));break;case 22:a=null!==e.memoizedState;var c=null!==n&&null!==n.memoizedState,u=Al,d=Rl;if(Al=u||a,Rl=d||c,Vl(t,e),Rl=d,Al=u,jl(e),8192&r)e:for(t=e.stateNode,t._visibility=a?-2&t._visibility:1|t._visibility,a&&(null===n||c||Al||Rl||ql(e)),n=null,t=e;;){if(5===t.tag||26===t.tag){if(null===n){c=n=t;try{if(s=c.stateNode,a)"function"==typeof(o=s.style).setProperty?o.setProperty("display","none","important"):o.display="none";else{l=c.stateNode;var h=c.memoizedProps.style,f=null!=h&&h.hasOwnProperty("display")?h.display:null;l.style.display=null==f||"boolean"==typeof f?"":(""+f).trim()}}catch(e){bu(c,c.return,e)}}}else if(6===t.tag){if(null===n){c=t;try{c.stateNode.nodeValue=a?"":c.memoizedProps}catch(e){bu(c,c.return,e)}}}else if(18===t.tag){if(null===n){c=t;try{var p=c.stateNode;a?Td(p,!0):Td(c.stateNode,!1)}catch(e){bu(c,c.return,e)}}}else if((22!==t.tag&&23!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;null===t.sibling;){if(null===t.return||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}4&r&&null!==(r=e.updateQueue)&&null!==(n=r.retryQueue)&&(r.retryQueue=null,Bl(e,n));case 30:case 21:}}function jl(e){var t=e.flags;if(2&t){try{for(var n,r=e.return;null!==r;){if(wl(r)){n=r;break}r=r.return}if(null==n)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;El(e,Sl(e),a);break;case 5:var s=n.stateNode;32&n.flags&&(wt(s,""),n.flags&=-33),El(e,Sl(e),s);break;case 3:case 4:var o=n.stateNode.containerInfo;Ml(e,Sl(e),o);break;default:throw Error(i(161))}}catch(t){bu(e,e.return,t)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function Wl(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;Wl(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Xl(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)Il(e,t.alternate,t),t=t.sibling}function ql(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ml(4,t,t.return),ql(t);break;case 1:xl(t,t.return);var n=t.stateNode;"function"==typeof n.componentWillUnmount&&vl(t,t.return,n),ql(t);break;case 27:kd(t.stateNode);case 26:case 5:xl(t,t.return),ql(t);break;case 22:null===t.memoizedState&&ql(t);break;default:ql(t)}e=e.sibling}}function $l(e,t,n){for(n=n&&!!(8772&t.subtreeFlags),t=t.child;null!==t;){var i=t.alternate,r=e,a=t,s=a.flags;switch(a.tag){case 0:case 11:case 15:$l(r,a,n),pl(4,a);break;case 1:if($l(r,a,n),"function"==typeof(r=(i=a).stateNode).componentDidMount)try{r.componentDidMount()}catch(e){bu(i,i.return,e)}if(null!==(r=(i=a).updateQueue)){var o=i.stateNode;try{var l=r.shared.hiddenCallbacks;if(null!==l)for(r.shared.hiddenCallbacks=null,r=0;r<l.length;r++)Sa(l[r],o)}catch(e){bu(i,i.return,e)}}n&&64&s&&gl(a),yl(a,a.return);break;case 27:Tl(a);case 26:case 5:$l(r,a,n),n&&null===i&&4&s&&_l(a),yl(a,a.return);break;case 12:$l(r,a,n);break;case 31:$l(r,a,n),n&&4&s&&Fl(r,a);break;case 13:$l(r,a,n),n&&4&s&&zl(r,a);break;case 22:null===a.memoizedState&&$l(r,a,n),yl(a,a.return);break;case 30:break;default:$l(r,a,n)}t=t.sibling}}function Yl(e,t){var n=null;null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),e=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(e=t.memoizedState.cachePool.pool),e!==n&&(null!=e&&e.refCount++,null!=n&&Fr(n))}function Kl(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Fr(e))}function Zl(e,t,n,i){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)Ql(e,t,n,i),t=t.sibling}function Ql(e,t,n,i){var r=t.flags;switch(t.tag){case 0:case 11:case 15:Zl(e,t,n,i),2048&r&&pl(9,t);break;case 1:case 31:case 13:default:Zl(e,t,n,i);break;case 3:Zl(e,t,n,i),2048&r&&(e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Fr(e)));break;case 12:if(2048&r){Zl(e,t,n,i),e=t.stateNode;try{var a=t.memoizedProps,s=a.id,o=a.onPostCommit;"function"==typeof o&&o(s,null===t.alternate?"mount":"update",e.passiveEffectDuration,-0)}catch(e){bu(t,t.return,e)}}else Zl(e,t,n,i);break;case 23:break;case 22:a=t.stateNode,s=t.alternate,null!==t.memoizedState?2&a._visibility?Zl(e,t,n,i):ec(e,t):2&a._visibility?Zl(e,t,n,i):(a._visibility|=2,Jl(e,t,n,i,!!(10256&t.subtreeFlags)||!1)),2048&r&&Yl(s,t);break;case 24:Zl(e,t,n,i),2048&r&&Kl(t.alternate,t)}}function Jl(e,t,n,i,r){for(r=r&&(!!(10256&t.subtreeFlags)||!1),t=t.child;null!==t;){var a=e,s=t,o=n,l=i,c=s.flags;switch(s.tag){case 0:case 11:case 15:Jl(a,s,o,l,r),pl(8,s);break;case 23:break;case 22:var u=s.stateNode;null!==s.memoizedState?2&u._visibility?Jl(a,s,o,l,r):ec(a,s):(u._visibility|=2,Jl(a,s,o,l,r)),r&&2048&c&&Yl(s.alternate,s);break;case 24:Jl(a,s,o,l,r),r&&2048&c&&Kl(s.alternate,s);break;default:Jl(a,s,o,l,r)}t=t.sibling}}function ec(e,t){if(10256&t.subtreeFlags)for(t=t.child;null!==t;){var n=e,i=t,r=i.flags;switch(i.tag){case 22:ec(n,i),2048&r&&Yl(i.alternate,i);break;case 24:ec(n,i),2048&r&&Kl(i.alternate,i);break;default:ec(n,i)}t=t.sibling}}var tc=8192;function nc(e,t,n){if(e.subtreeFlags&tc)for(e=e.child;null!==e;)ic(e,t,n),e=e.sibling}function ic(e,t,n){switch(e.tag){case 26:nc(e,t,n),e.flags&tc&&null!==e.memoizedState&&function(e,t,n,i){if(!("stylesheet"!==n.type||"string"==typeof i.media&&!1===matchMedia(i.media).matches||4&n.state.loading)){if(null===n.instance){var r=jd(i.href),a=t.querySelector(Wd(r));if(a)return null!==(t=a._p)&&"object"==typeof t&&"function"==typeof t.then&&(e.count++,e=rh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,void Qe(a);a=t.ownerDocument||t,i=Xd(i),(r=Ud.get(r))&&Zd(i,r),Qe(a=a.createElement("link"));var s=a;s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ud(a,"link",i),n.instance=a}null===e.stylesheets&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(3&n.state.loading)&&(e.count++,n=rh.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}(n,Hl,e.memoizedState,e.memoizedProps);break;case 5:default:nc(e,t,n);break;case 3:case 4:var i=Hl;Hl=zd(e.stateNode.containerInfo),nc(e,t,n),Hl=i;break;case 22:null===e.memoizedState&&(null!==(i=e.alternate)&&null!==i.memoizedState?(i=tc,tc=16777216,nc(e,t,n),tc=i):nc(e,t,n))}}function rc(e){var t=e.alternate;if(null!==t&&null!==(e=t.child)){t.child=null;do{t=e.sibling,e.sibling=null,e=t}while(null!==e)}}function ac(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var i=t[n];Ll=i,lc(i,e)}rc(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)sc(e),e=e.sibling}function sc(e){switch(e.tag){case 0:case 11:case 15:ac(e),2048&e.flags&&ml(9,e,e.return);break;case 3:case 12:default:ac(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,oc(e)):ac(e)}}function oc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var i=t[n];Ll=i,lc(i,e)}rc(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:ml(8,t,t.return),oc(t);break;case 22:2&(n=t.stateNode)._visibility&&(n._visibility&=-3,oc(t));break;default:oc(t)}e=e.sibling}}function lc(e,t){for(;null!==Ll;){var n=Ll;switch(n.tag){case 0:case 11:case 15:ml(8,n,t);break;case 23:case 22:if(null!==n.memoizedState&&null!==n.memoizedState.cachePool){var i=n.memoizedState.cachePool.pool;null!=i&&i.refCount++}break;case 24:Fr(n.memoizedState.cache)}if(null!==(i=n.child))i.return=n,Ll=i;else e:for(n=e;null!==Ll;){var r=(i=Ll).sibling,a=i.return;if(Dl(i),i===n){Ll=null;break e}if(null!==r){r.return=a,Ll=r;break e}Ll=a}}}var cc={getCacheForType:function(e){var t=Pr(kr),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Pr(kr).controller.signal}},uc="function"==typeof WeakMap?WeakMap:Map,dc=0,hc=null,fc=null,pc=0,mc=0,gc=null,vc=!1,yc=!1,xc=!1,_c=0,bc=0,wc=0,Sc=0,Mc=0,Ec=0,Tc=0,Ac=null,Rc=null,Cc=!1,Pc=0,Lc=0,Ic=1/0,Dc=null,Nc=null,Oc=0,kc=null,Uc=null,Fc=0,zc=0,Bc=null,Vc=null,Hc=0,Gc=null;function jc(){return 2&dc&&0!==pc?pc&-pc:null!==I.T?Bu():ke()}function Wc(){if(0===Ec)if(536870912&pc&&!cr)Ec=536870912;else{var e=we;!(3932160&(we<<=1))&&(we=262144),Ec=e}return null!==(e=Pa.current)&&(e.flags|=32),Ec}function Xc(e,t,n){(e!==hc||2!==mc&&9!==mc)&&null===e.cancelPendingCommit||(Jc(e,0),Kc(e,pc,Ec,!1)),Pe(e,n),2&dc&&e===hc||(e===hc&&(!(2&dc)&&(Sc|=n),4===bc&&Kc(e,pc,Ec,!1)),Du(e))}function qc(e,t,n){if(6&dc)throw Error(i(327));for(var r=!n&&!(127&t)&&0===(t&e.expiredLanes)||Te(e,t),a=r?function(e,t){var n=dc;dc|=2;var r=nu(),a=iu();hc!==e||pc!==t?(Dc=null,Ic=se()+500,Jc(e,t)):yc=Te(e,t);e:for(;;)try{if(0!==mc&&null!==fc){t=fc;var s=gc;t:switch(mc){case 1:mc=0,gc=null,uu(e,t,s,1);break;case 2:case 9:if(Jr(s)){mc=0,gc=null,cu(t);break}t=function(){2!==mc&&9!==mc||hc!==e||(mc=7),Du(e)},s.then(t,t);break e;case 3:mc=7;break e;case 4:mc=5;break e;case 7:Jr(s)?(mc=0,gc=null,cu(t)):(mc=0,gc=null,uu(e,t,s,7));break;case 5:var o=null;switch(fc.tag){case 26:o=fc.memoizedState;case 5:case 27:var l=fc;if(o?nh(o):l.stateNode.complete){mc=0,gc=null;var c=l.sibling;if(null!==c)fc=c;else{var u=l.return;null!==u?(fc=u,du(u)):fc=null}break t}}mc=0,gc=null,uu(e,t,s,5);break;case 6:mc=0,gc=null,uu(e,t,s,6);break;case 8:Qc(),bc=6;break e;default:throw Error(i(462))}}ou();break}catch(t){eu(e,t)}return wr=br=null,I.H=r,I.A=a,dc=n,null!==fc?0:(hc=null,pc=0,Ri(),bc)}(e,t):au(e,t,!0),s=r;;){if(0===a){yc&&!r&&Kc(e,t,0,!1);break}if(n=e.current.alternate,!s||Yc(n)){if(2===a){if(s=t,e.errorRecoveryDisabledLanes&s)var o=0;else o=0!=(o=-536870913&e.pendingLanes)?o:536870912&o?536870912:0;if(0!==o){t=o;e:{var l=e;a=Ac;var c=l.current.memoizedState.isDehydrated;if(c&&(Jc(l,o).flags|=256),2!==(o=au(l,o,!1))){if(xc&&!c){l.errorRecoveryDisabledLanes|=s,Sc|=s,a=4;break e}s=Rc,Rc=a,null!==s&&(null===Rc?Rc=s:Rc.push.apply(Rc,s))}a=o}if(s=!1,2!==a)continue}}if(1===a){Jc(e,0),Kc(e,t,0,!0);break}e:{switch(r=e,s=a){case 0:case 1:throw Error(i(345));case 4:if((4194048&t)!==t)break;case 6:Kc(r,t,Ec,!vc);break e;case 2:Rc=null;break;case 3:case 5:break;default:throw Error(i(329))}if((62914560&t)===t&&10<(a=Pc+300-se())){if(Kc(r,t,Ec,!vc),0!==Ee(r,0,!0))break e;Fc=t,r.timeoutHandle=xd($c.bind(null,r,n,Rc,Dc,Cc,t,Ec,Sc,Tc,vc,s,"Throttled",-0,0),a)}else $c(r,n,Rc,Dc,Cc,t,Ec,Sc,Tc,vc,s,null,-0,0)}break}a=au(e,t,!1),s=!1}Du(e)}function $c(e,t,n,i,r,a,s,o,l,c,u,d,h,f){if(e.timeoutHandle=-1,8192&(d=t.subtreeFlags)||!(16785408&~d)){ic(t,a,d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Pt});var p=(62914560&a)===a?Pc-se():(4194048&a)===a?Lc-se():0;if(null!==(p=function(e,t){return e.stylesheets&&0===e.count&&sh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var i=setTimeout(function(){if(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&0===ih&&(ih=62500*function(){if("function"==typeof performance.getEntriesByType){for(var e=0,t=0,n=performance.getEntriesByType("resource"),i=0;i<n.length;i++){var r=n[i],a=r.transferSize,s=r.initiatorType,o=r.duration;if(a&&o&&dd(s)){for(s=0,o=r.responseEnd,i+=1;i<n.length;i++){var l=n[i],c=l.startTime;if(c>o)break;var u=l.transferSize,d=l.initiatorType;u&&dd(d)&&(s+=u*((l=l.responseEnd)<o?1:(o-c)/(l-c)))}if(--i,t+=8*(a+s)/(r.duration/1e3),10<++e)break}}if(0<e)return t/e/1e6}return navigator.connection&&"number"==typeof(e=navigator.connection.downlink)?e:5}());var r=setTimeout(function(){if(e.waitingForImages=!1,0===e.count&&(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>ih?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(r)}}:null}(d,p)))return Fc=a,e.cancelPendingCommit=p(fu.bind(null,e,t,a,n,i,r,s,o,l,u,d,null,h,f)),void Kc(e,a,s,!c)}fu(e,t,a,n,i,r,s,o,l)}function Yc(e){for(var t=e;;){var n=t.tag;if((0===n||11===n||15===n)&&16384&t.flags&&null!==(n=t.updateQueue)&&null!==(n=n.stores))for(var i=0;i<n.length;i++){var r=n[i],a=r.getSnapshot;r=r.value;try{if(!Kn(a(),r))return!1}catch(e){return!1}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Kc(e,t,n,i){t&=~Mc,t&=~Sc,e.suspendedLanes|=t,e.pingedLanes&=~t,i&&(e.warmLanes|=t),i=e.expirationTimes;for(var r=t;0<r;){var a=31-ye(r),s=1<<a;i[a]=-1,r&=~s}0!==n&&Le(e,n,t)}function Zc(){return!!(6&dc)||(Nu(0),!1)}function Qc(){if(null!==fc){if(0===mc)var e=fc.return;else wr=br=null,rs(e=fc),aa=null,sa=0,e=fc;for(;null!==e;)fl(e.alternate,e),e=e.return;fc=null}}function Jc(e,t){var n=e.timeoutHandle;-1!==n&&(e.timeoutHandle=-1,_d(n)),null!==(n=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,n()),Fc=0,Qc(),hc=e,fc=n=Fi(e.current,null),pc=t,mc=0,gc=null,vc=!1,yc=Te(e,t),xc=!1,Tc=Ec=Mc=Sc=wc=bc=0,Rc=Ac=null,Cc=!1,8&t&&(t|=32&t);var i=e.entangledLanes;if(0!==i)for(e=e.entanglements,i&=t;0<i;){var r=31-ye(i),a=1<<r;t|=e[r],i&=~a}return _c=t,Ri(),n}function eu(e,t){Ba=null,I.H=fo,t===Yr||t===Zr?(t=ia(),mc=3):t===Kr?(t=ia(),mc=4):mc=t===Po?8:null!==t&&"object"==typeof t&&"function"==typeof t.then?6:1,gc=t,null===fc&&(bc=1,Eo(e,Xi(t,e.current)))}function tu(){var e=Pa.current;return null===e||((4194048&pc)===pc?null===La:!!((62914560&pc)===pc||536870912&pc)&&e===La)}function nu(){var e=I.H;return I.H=fo,null===e?fo:e}function iu(){var e=I.A;return I.A=cc,e}function ru(){bc=4,vc||(4194048&pc)!==pc&&null!==Pa.current||(yc=!0),!(134217727&wc)&&!(134217727&Sc)||null===hc||Kc(hc,pc,Ec,!1)}function au(e,t,n){var i=dc;dc|=2;var r=nu(),a=iu();hc===e&&pc===t||(Dc=null,Jc(e,t)),t=!1;var s=bc;e:for(;;)try{if(0!==mc&&null!==fc){var o=fc,l=gc;switch(mc){case 8:Qc(),s=6;break e;case 3:case 2:case 9:case 6:null===Pa.current&&(t=!0);var c=mc;if(mc=0,gc=null,uu(e,o,l,c),n&&yc){s=0;break e}break;default:c=mc,mc=0,gc=null,uu(e,o,l,c)}}su(),s=bc;break}catch(t){eu(e,t)}return t&&e.shellSuspendCounter++,wr=br=null,dc=i,I.H=r,I.A=a,null===fc&&(hc=null,pc=0,Ri()),s}function su(){for(;null!==fc;)lu(fc)}function ou(){for(;null!==fc&&!re();)lu(fc)}function lu(e){var t=rl(e.alternate,e,_c);e.memoizedProps=e.pendingProps,null===t?du(e):fc=t}function cu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Go(n,t,t.pendingProps,t.type,void 0,pc);break;case 11:t=Go(n,t,t.pendingProps,t.type.render,t.ref,pc);break;case 5:rs(t);default:fl(n,t),t=rl(n,t=fc=zi(t,_c),_c)}e.memoizedProps=e.pendingProps,null===t?du(e):fc=t}function uu(e,t,n,r){wr=br=null,rs(t),aa=null,sa=0;var a=t.return;try{if(function(e,t,n,r,a){if(n.flags|=32768,null!==r&&"object"==typeof r&&"function"==typeof r.then){if(null!==(t=n.alternate)&&Ar(t,n,a,!0),null!==(n=Pa.current)){switch(n.tag){case 31:case 13:return null===La?ru():null===n.alternate&&0===bc&&(bc=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Qr?n.flags|=16384:(null===(t=n.updateQueue)?n.updateQueue=new Set([r]):t.add(r),wu(e,r,a)),!1;case 22:return n.flags|=65536,r===Qr?n.flags|=16384:(null===(t=n.updateQueue)?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):null===(n=t.retryQueue)?t.retryQueue=new Set([r]):n.add(r),wu(e,r,a)),!1}throw Error(i(435,n.tag))}return wu(e,r,a),ru(),!1}if(cr)return null!==(t=Pa.current)?(!(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==hr&&xr(Xi(e=Error(i(422),{cause:r}),n))):(r!==hr&&xr(Xi(t=Error(i(423),{cause:r}),n)),(e=e.current.alternate).flags|=65536,a&=-a,e.lanes|=a,r=Xi(r,n),xa(e,a=Ao(e.stateNode,r,a)),4!==bc&&(bc=2)),!1;var s=Error(i(520),{cause:r});if(s=Xi(s,n),null===Ac?Ac=[s]:Ac.push(s),4!==bc&&(bc=2),null===t)return!0;r=Xi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,xa(n,e=Ao(n.stateNode,r,e)),!1;case 1:if(t=n.type,s=n.stateNode,!(128&n.flags||"function"!=typeof t.getDerivedStateFromError&&(null===s||"function"!=typeof s.componentDidCatch||null!==Nc&&Nc.has(s))))return n.flags|=65536,a&=-a,n.lanes|=a,Co(a=Ro(a),e,n,r),xa(n,a),!1}n=n.return}while(null!==n);return!1}(e,a,t,n,pc))return bc=1,Eo(e,Xi(n,e.current)),void(fc=null)}catch(t){if(null!==a)throw fc=a,t;return bc=1,Eo(e,Xi(n,e.current)),void(fc=null)}32768&t.flags?(cr||1===r?e=!0:yc||536870912&pc?e=!1:(vc=e=!0,(2===r||9===r||3===r||6===r)&&null!==(r=Pa.current)&&13===r.tag&&(r.flags|=16384)),hu(t,e)):du(t)}function du(e){var t=e;do{if(32768&t.flags)return void hu(t,vc);e=t.return;var n=dl(t.alternate,t,_c);if(null!==n)return void(fc=n);if(null!==(t=t.sibling))return void(fc=t);fc=t=e}while(null!==t);0===bc&&(bc=5)}function hu(e,t){do{var n=hl(e.alternate,e);if(null!==n)return n.flags&=32767,void(fc=n);if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&null!==(e=e.sibling))return void(fc=e);fc=e=n}while(null!==e);bc=6,fc=null}function fu(e,t,n,r,a,s,o,l,c){e.cancelPendingCommit=null;do{yu()}while(0!==Oc);if(6&dc)throw Error(i(327));if(null!==t){if(t===e.current)throw Error(i(177));if(s=t.lanes|t.childLanes,function(e,t,n,i,r,a){var s=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var o=e.entanglements,l=e.expirationTimes,c=e.hiddenUpdates;for(n=s&~n;0<n;){var u=31-ye(n),d=1<<u;o[u]=0,l[u]=-1;var h=c[u];if(null!==h)for(c[u]=null,u=0;u<h.length;u++){var f=h[u];null!==f&&(f.lane&=-536870913)}n&=~d}0!==i&&Le(e,i,0),0!==a&&0===r&&0!==e.tag&&(e.suspendedLanes|=a&~(s&~t))}(e,n,s|=Ai,o,l,c),e===hc&&(fc=hc=null,pc=0),Uc=t,kc=e,Fc=n,zc=s,Bc=a,Vc=r,10256&t.subtreeFlags||10256&t.flags?(e.callbackNode=null,e.callbackPriority=0,ne(ue,function(){return xu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=!!(13878&t.flags),13878&t.subtreeFlags||r){r=I.T,I.T=null,a=D.p,D.p=2,o=dc,dc|=4;try{!function(e,t){if(e=e.containerInfo,hd=vh,ni(e=ti(e))){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{var r=(n=(n=e.ownerDocument)&&n.defaultView||window).getSelection&&n.getSelection();if(r&&0!==r.rangeCount){n=r.anchorNode;var a=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch(e){n=null;break e}var o=0,l=-1,c=-1,u=0,d=0,h=e,f=null;t:for(;;){for(var p;h!==n||0!==a&&3!==h.nodeType||(l=o+a),h!==s||0!==r&&3!==h.nodeType||(c=o+r),3===h.nodeType&&(o+=h.nodeValue.length),null!==(p=h.firstChild);)f=h,h=p;for(;;){if(h===e)break t;if(f===n&&++u===a&&(l=o),f===s&&++d===r&&(c=o),null!==(p=h.nextSibling))break;f=(h=f).parentNode}h=p}n=-1===l||-1===c?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(fd={focusedElem:e,selectionRange:n},vh=!1,Ll=t;null!==Ll;)if(e=(t=Ll).child,1028&t.subtreeFlags&&null!==e)e.return=t,Ll=e;else for(;null!==Ll;){switch(s=(t=Ll).alternate,e=t.flags,t.tag){case 0:if(4&e&&null!==(e=null!==(e=t.updateQueue)?e.events:null))for(n=0;n<e.length;n++)(a=e[n]).ref.impl=a.nextImpl;break;case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(1024&e&&null!==s){e=void 0,n=t,a=s.memoizedProps,s=s.memoizedState,r=n.stateNode;try{var m=bo(n.type,a);e=r.getSnapshotBeforeUpdate(m,s),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){bu(n,n.return,e)}}break;case 3:if(1024&e)if(9===(n=(e=t.stateNode.containerInfo).nodeType))Ad(e);else if(1===n)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ad(e);break;default:e.textContent=""}break;default:if(1024&e)throw Error(i(163))}if(null!==(e=t.sibling)){e.return=t.return,Ll=e;break}Ll=t.return}}(e,t)}finally{dc=o,D.p=a,I.T=r}}Oc=1,pu(),mu(),gu()}}function pu(){if(1===Oc){Oc=0;var e=kc,t=Uc,n=!!(13878&t.flags);if(13878&t.subtreeFlags||n){n=I.T,I.T=null;var i=D.p;D.p=2;var r=dc;dc|=4;try{Gl(t,e);var a=fd,s=ti(e.containerInfo),o=a.focusedElem,l=a.selectionRange;if(s!==o&&o&&o.ownerDocument&&ei(o.ownerDocument.documentElement,o)){if(null!==l&&ni(o)){var c=l.start,u=l.end;if(void 0===u&&(u=c),"selectionStart"in o)o.selectionStart=c,o.selectionEnd=Math.min(u,o.value.length);else{var d=o.ownerDocument||document,h=d&&d.defaultView||window;if(h.getSelection){var f=h.getSelection(),p=o.textContent.length,m=Math.min(l.start,p),g=void 0===l.end?m:Math.min(l.end,p);!f.extend&&m>g&&(s=g,g=m,m=s);var v=Jn(o,m),y=Jn(o,g);if(v&&y&&(1!==f.rangeCount||f.anchorNode!==v.node||f.anchorOffset!==v.offset||f.focusNode!==y.node||f.focusOffset!==y.offset)){var x=d.createRange();x.setStart(v.node,v.offset),f.removeAllRanges(),m>g?(f.addRange(x),f.extend(y.node,y.offset)):(x.setEnd(y.node,y.offset),f.addRange(x))}}}}for(d=[],f=o;f=f.parentNode;)1===f.nodeType&&d.push({element:f,left:f.scrollLeft,top:f.scrollTop});for("function"==typeof o.focus&&o.focus(),o=0;o<d.length;o++){var _=d[o];_.element.scrollLeft=_.left,_.element.scrollTop=_.top}}vh=!!hd,fd=hd=null}finally{dc=r,D.p=i,I.T=n}}e.current=t,Oc=2}}function mu(){if(2===Oc){Oc=0;var e=kc,t=Uc,n=!!(8772&t.flags);if(8772&t.subtreeFlags||n){n=I.T,I.T=null;var i=D.p;D.p=2;var r=dc;dc|=4;try{Il(e,t.alternate,t)}finally{dc=r,D.p=i,I.T=n}}Oc=3}}function gu(){if(4===Oc||3===Oc){Oc=0,ae();var e=kc,t=Uc,n=Fc,i=Vc;10256&t.subtreeFlags||10256&t.flags?Oc=5:(Oc=0,Uc=kc=null,vu(e,e.pendingLanes));var r=e.pendingLanes;if(0===r&&(Nc=null),Oe(n),t=t.stateNode,ge&&"function"==typeof ge.onCommitFiberRoot)try{ge.onCommitFiberRoot(me,t,void 0,!(128&~t.current.flags))}catch(e){}if(null!==i){t=I.T,r=D.p,D.p=2,I.T=null;try{for(var a=e.onRecoverableError,s=0;s<i.length;s++){var o=i[s];a(o.value,{componentStack:o.stack})}}finally{I.T=t,D.p=r}}3&Fc&&yu(),Du(e),r=e.pendingLanes,261930&n&&42&r?e===Gc?Hc++:(Hc=0,Gc=e):Hc=0,Nu(0)}}function vu(e,t){0===(e.pooledCacheLanes&=t)&&null!=(t=e.pooledCache)&&(e.pooledCache=null,Fr(t))}function yu(){return pu(),mu(),gu(),xu()}function xu(){if(5!==Oc)return!1;var e=kc,t=zc;zc=0;var n=Oe(Fc),r=I.T,a=D.p;try{D.p=32>n?32:n,I.T=null,n=Bc,Bc=null;var s=kc,o=Fc;if(Oc=0,Uc=kc=null,Fc=0,6&dc)throw Error(i(331));var l=dc;if(dc|=4,sc(s.current),Ql(s,s.current,o,n),dc=l,Nu(0,!1),ge&&"function"==typeof ge.onPostCommitFiberRoot)try{ge.onPostCommitFiberRoot(me,s)}catch(e){}return!0}finally{D.p=a,I.T=r,vu(e,t)}}function _u(e,t,n){t=Xi(n,t),null!==(e=va(e,t=Ao(e.stateNode,t,2),2))&&(Pe(e,2),Du(e))}function bu(e,t,n){if(3===e.tag)_u(e,e,n);else for(;null!==t;){if(3===t.tag){_u(t,e,n);break}if(1===t.tag){var i=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof i.componentDidCatch&&(null===Nc||!Nc.has(i))){e=Xi(n,e),null!==(i=va(t,n=Ro(2),2))&&(Co(n,i,t,e),Pe(i,2),Du(i));break}}t=t.return}}function wu(e,t,n){var i=e.pingCache;if(null===i){i=e.pingCache=new uc;var r=new Set;i.set(t,r)}else void 0===(r=i.get(t))&&(r=new Set,i.set(t,r));r.has(n)||(xc=!0,r.add(n),e=Su.bind(null,e,t,n),t.then(e,e))}function Su(e,t,n){var i=e.pingCache;null!==i&&i.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,hc===e&&(pc&n)===n&&(4===bc||3===bc&&(62914560&pc)===pc&&300>se()-Pc?!(2&dc)&&Jc(e,0):Mc|=n,Tc===pc&&(Tc=0)),Du(e)}function Mu(e,t){0===t&&(t=Re()),null!==(e=Li(e,t))&&(Pe(e,t),Du(e))}function Eu(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Mu(e,n)}function Tu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;null!==a&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}null!==r&&r.delete(t),Mu(e,n)}var Au=null,Ru=null,Cu=!1,Pu=!1,Lu=!1,Iu=0;function Du(e){e!==Ru&&null===e.next&&(null===Ru?Au=Ru=e:Ru=Ru.next=e),Pu=!0,Cu||(Cu=!0,wd(function(){6&dc?ne(le,Ou):ku()}))}function Nu(e,t){if(!Lu&&Pu){Lu=!0;do{for(var n=!1,i=Au;null!==i;){if(0!==e){var r=i.pendingLanes;if(0===r)var a=0;else{var s=i.suspendedLanes,o=i.pingedLanes;a=(1<<31-ye(42|e)+1)-1,a=201326741&(a&=r&~(s&~o))?201326741&a|1:a?2|a:0}0!==a&&(n=!0,zu(i,a))}else a=pc,!(3&(a=Ee(i,i===hc?a:0,null!==i.cancelPendingCommit||-1!==i.timeoutHandle)))||Te(i,a)||(n=!0,zu(i,a));i=i.next}}while(n);Lu=!1}}function Ou(){ku()}function ku(){Pu=Cu=!1;var e,t=0;0!==Iu&&((e=window.event)&&"popstate"===e.type?e!==yd&&(yd=e,1):(yd=null,0))&&(t=Iu);for(var n=se(),i=null,r=Au;null!==r;){var a=r.next,s=Uu(r,n);0===s?(r.next=null,null===i?Au=a:i.next=a,null===a&&(Ru=i)):(i=r,(0!==t||3&s)&&(Pu=!0)),r=a}0!==Oc&&5!==Oc||Nu(t),0!==Iu&&(Iu=0)}function Uu(e,t){for(var n=e.suspendedLanes,i=e.pingedLanes,r=e.expirationTimes,a=-62914561&e.pendingLanes;0<a;){var s=31-ye(a),o=1<<s,l=r[s];-1===l?0!==(o&n)&&0===(o&i)||(r[s]=Ae(o,t)):l<=t&&(e.expiredLanes|=o),a&=~o}if(n=pc,n=Ee(e,e===(t=hc)?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),i=e.callbackNode,0===n||e===t&&(2===mc||9===mc)||null!==e.cancelPendingCommit)return null!==i&&null!==i&&ie(i),e.callbackNode=null,e.callbackPriority=0;if(!(3&n)||Te(e,n)){if((t=n&-n)===e.callbackPriority)return t;switch(null!==i&&ie(i),Oe(n)){case 2:case 8:n=ce;break;case 32:default:n=ue;break;case 268435456:n=he}return i=Fu.bind(null,e),n=ne(n,i),e.callbackPriority=t,e.callbackNode=n,t}return null!==i&&null!==i&&ie(i),e.callbackPriority=2,e.callbackNode=null,2}function Fu(e,t){if(0!==Oc&&5!==Oc)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(yu()&&e.callbackNode!==n)return null;var i=pc;return 0===(i=Ee(e,e===hc?i:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:(qc(e,i,t),Uu(e,se()),null!=e.callbackNode&&e.callbackNode===n?Fu.bind(null,e):null)}function zu(e,t){if(yu())return null;qc(e,t,!0)}function Bu(){if(0===Iu){var e=Vr;0===e&&(e=be,!(261888&(be<<=1))&&(be=256)),Iu=e}return Iu}function Vu(e){return null==e||"symbol"==typeof e||"boolean"==typeof e?null:"function"==typeof e?e:Ct(""+e)}function Hu(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}for(var Gu=0;Gu<wi.length;Gu++){var ju=wi[Gu];Si(ju.toLowerCase(),"on"+(ju[0].toUpperCase()+ju.slice(1)))}Si(pi,"onAnimationEnd"),Si(mi,"onAnimationIteration"),Si(gi,"onAnimationStart"),Si("dblclick","onDoubleClick"),Si("focusin","onFocus"),Si("focusout","onBlur"),Si(vi,"onTransitionRun"),Si(yi,"onTransitionStart"),Si(xi,"onTransitionCancel"),Si(_i,"onTransitionEnd"),nt("onMouseEnter",["mouseout","mouseover"]),nt("onMouseLeave",["mouseout","mouseover"]),nt("onPointerEnter",["pointerout","pointerover"]),nt("onPointerLeave",["pointerout","pointerover"]),tt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),tt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),tt("onBeforeInput",["compositionend","keypress","textInput","paste"]),tt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),tt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),tt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Wu="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Xu=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Wu));function qu(e,t){t=!!(4&t);for(var n=0;n<e.length;n++){var i=e[n],r=i.event;i=i.listeners;e:{var a=void 0;if(t)for(var s=i.length-1;0<=s;s--){var o=i[s],l=o.instance,c=o.currentTarget;if(o=o.listener,l!==a&&r.isPropagationStopped())break e;a=o,r.currentTarget=c;try{a(r)}catch(e){Mi(e)}r.currentTarget=null,a=l}else for(s=0;s<i.length;s++){if(l=(o=i[s]).instance,c=o.currentTarget,o=o.listener,l!==a&&r.isPropagationStopped())break e;a=o,r.currentTarget=c;try{a(r)}catch(e){Mi(e)}r.currentTarget=null,a=l}}}}function $u(e,t){var n=t[He];void 0===n&&(n=t[He]=new Set);var i=e+"__bubble";n.has(i)||(Qu(t,e,2,!1),n.add(i))}function Yu(e,t,n){var i=0;t&&(i|=4),Qu(n,e,i,t)}var Ku="_reactListening"+Math.random().toString(36).slice(2);function Zu(e){if(!e[Ku]){e[Ku]=!0,Je.forEach(function(t){"selectionchange"!==t&&(Xu.has(t)||Yu(t,!1,e),Yu(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[Ku]||(t[Ku]=!0,Yu("selectionchange",!1,t))}}function Qu(e,t,n,i){switch(Mh(t)){case 2:var r=yh;break;case 8:r=xh;break;default:r=_h}n=r.bind(null,t,n,e),r=void 0,!Bt||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(r=!0),i?void 0!==r?e.addEventListener(t,n,{capture:!0,passive:r}):e.addEventListener(t,n,!0):void 0!==r?e.addEventListener(t,n,{passive:r}):e.addEventListener(t,n,!1)}function Ju(e,t,n,i,r){var s=i;if(!(1&t||2&t||null===i))e:for(;;){if(null===i)return;var o=i.tag;if(3===o||4===o){var l=i.stateNode.containerInfo;if(l===r)break;if(4===o)for(o=i.return;null!==o;){var c=o.tag;if((3===c||4===c)&&o.stateNode.containerInfo===r)return;o=o.return}for(;null!==l;){if(null===(o=$e(l)))return;if(5===(c=o.tag)||6===c||26===c||27===c){i=s=o;continue e}l=l.parentNode}}i=i.return}Ut(function(){var i=s,r=It(n),o=[];e:{var l=bi.get(e);if(void 0!==l){var c=en,u=e;switch(e){case"keypress":if(0===Xt(n))break e;case"keydown":case"keyup":c=gn;break;case"focusin":u="focus",c=on;break;case"focusout":u="blur",c=on;break;case"beforeblur":case"afterblur":c=on;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=an;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=sn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=yn;break;case pi:case mi:case gi:c=ln;break;case _i:c=xn;break;case"scroll":case"scrollend":c=nn;break;case"wheel":c=_n;break;case"copy":case"cut":case"paste":c=cn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=vn;break;case"toggle":case"beforetoggle":c=bn}var d=!!(4&t),h=!d&&("scroll"===e||"scrollend"===e),f=d?null!==l?l+"Capture":null:l;d=[];for(var p,m=i;null!==m;){var g=m;if(p=g.stateNode,5!==(g=g.tag)&&26!==g&&27!==g||null===p||null===f||null!=(g=Ft(m,f))&&d.push(ed(m,g,p)),h)break;m=m.return}0<d.length&&(l=new c(l,u,null,n,r),o.push({event:l,listeners:d}))}}if(!(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(l="mouseover"===e||"pointerover"===e)||n===Lt||!(u=n.relatedTarget||n.fromElement)||!$e(u)&&!u[Ve])&&(c||l)&&(l=r.window===r?r:(l=r.ownerDocument)?l.defaultView||l.parentWindow:window,c?(c=i,null!==(u=(u=n.relatedTarget||n.toElement)?$e(u):null)&&(h=a(u),d=u.tag,u!==h||5!==d&&27!==d&&6!==d)&&(u=null)):(c=null,u=i),c!==u)){if(d=an,g="onMouseLeave",f="onMouseEnter",m="mouse","pointerout"!==e&&"pointerover"!==e||(d=vn,g="onPointerLeave",f="onPointerEnter",m="pointer"),h=null==c?l:Ke(c),p=null==u?l:Ke(u),(l=new d(g,m+"leave",c,n,r)).target=h,l.relatedTarget=p,g=null,$e(r)===i&&((d=new d(f,m+"enter",u,n,r)).target=p,d.relatedTarget=h,g=d),h=g,c&&u)e:{for(d=nd,m=u,p=0,g=f=c;g;g=d(g))p++;g=0;for(var v=m;v;v=d(v))g++;for(;0<p-g;)f=d(f),p--;for(;0<g-p;)m=d(m),g--;for(;p--;){if(f===m||null!==m&&f===m.alternate){d=f;break e}f=d(f),m=d(m)}d=null}else d=null;null!==c&&id(o,l,c,d,!1),null!==u&&null!==h&&id(o,h,u,d,!0)}if("select"===(c=(l=i?Ke(i):window).nodeName&&l.nodeName.toLowerCase())||"input"===c&&"file"===l.type)var y=zn;else if(Dn(l))if(Bn)y=Yn;else{y=qn;var x=Xn}else!(c=l.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==l.type&&"radio"!==l.type?i&&Tt(i.elementType)&&(y=zn):y=$n;switch(y&&(y=y(e,i))?Nn(o,y,n,r):(x&&x(e,l,i),"focusout"===e&&i&&"number"===l.type&&null!=i.memoizedProps.value&&yt(l,"number",l.value)),x=i?Ke(i):window,e){case"focusin":(Dn(x)||"true"===x.contentEditable)&&(ri=x,ai=i,si=null);break;case"focusout":si=ai=ri=null;break;case"mousedown":oi=!0;break;case"contextmenu":case"mouseup":case"dragend":oi=!1,li(o,n,r);break;case"selectionchange":if(ii)break;case"keydown":case"keyup":li(o,n,r)}var _;if(Sn)e:{switch(e){case"compositionstart":var b="onCompositionStart";break e;case"compositionend":b="onCompositionEnd";break e;case"compositionupdate":b="onCompositionUpdate";break e}b=void 0}else Ln?Cn(e,n)&&(b="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(b="onCompositionStart");b&&(Tn&&"ko"!==n.locale&&(Ln||"onCompositionStart"!==b?"onCompositionEnd"===b&&Ln&&(_=Wt()):(Gt="value"in(Ht=r)?Ht.value:Ht.textContent,Ln=!0)),0<(x=td(i,b)).length&&(b=new un(b,e,null,n,r),o.push({event:b,listeners:x}),(_||null!==(_=Pn(n)))&&(b.data=_))),(_=En?function(e,t){switch(e){case"compositionend":return Pn(t);case"keypress":return 32!==t.which?null:(Rn=!0,An);case"textInput":return(e=t.data)===An&&Rn?null:e;default:return null}}(e,n):function(e,t){if(Ln)return"compositionend"===e||!Sn&&Cn(e,t)?(e=Wt(),jt=Gt=Ht=null,Ln=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Tn&&"ko"!==t.locale?null:t.data}}(e,n))&&0<(b=td(i,"onBeforeInput")).length&&(x=new un("onBeforeInput","beforeinput",null,n,r),o.push({event:x,listeners:b}),x.data=_),function(e,t,n,i,r){if("submit"===t&&n&&n.stateNode===r){var a=Vu((r[Be]||null).action),s=i.submitter;s&&null!==(t=(t=s[Be]||null)?Vu(t.formAction):s.getAttribute("formAction"))&&(a=t,s=null);var o=new en("action","action",null,i,r);e.push({event:o,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(0!==Iu){var e=s?Hu(r,s):new FormData(r);Qs(n,{pending:!0,data:e,method:r.method,action:a},null,e)}}else"function"==typeof a&&(o.preventDefault(),e=s?Hu(r,s):new FormData(r),Qs(n,{pending:!0,data:e,method:r.method,action:a},a,e))},currentTarget:r}]})}}(o,e,i,n,r)}qu(o,t)})}function ed(e,t,n){return{instance:e,listener:t,currentTarget:n}}function td(e,t){for(var n=t+"Capture",i=[];null!==e;){var r=e,a=r.stateNode;if(5!==(r=r.tag)&&26!==r&&27!==r||null===a||(null!=(r=Ft(e,n))&&i.unshift(ed(e,r,a)),null!=(r=Ft(e,t))&&i.push(ed(e,r,a))),3===e.tag)return i;e=e.return}return[]}function nd(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function id(e,t,n,i,r){for(var a=t._reactName,s=[];null!==n&&n!==i;){var o=n,l=o.alternate,c=o.stateNode;if(o=o.tag,null!==l&&l===i)break;5!==o&&26!==o&&27!==o||null===c||(l=c,r?null!=(c=Ft(n,a))&&s.unshift(ed(n,c,l)):r||null!=(c=Ft(n,a))&&s.push(ed(n,c,l))),n=n.return}0!==s.length&&e.push({event:t,listeners:s})}var rd=/\r\n?/g,ad=/\u0000|\uFFFD/g;function sd(e){return("string"==typeof e?e:""+e).replace(rd,"\n").replace(ad,"")}function od(e,t){return t=sd(t),sd(e)===t}function ld(e,t,n,r,a,s){switch(n){case"children":"string"==typeof r?"body"===t||"textarea"===t&&""===r||wt(e,r):("number"==typeof r||"bigint"==typeof r)&&"body"!==t&&wt(e,""+r);break;case"className":ot(e,"class",r);break;case"tabIndex":ot(e,"tabindex",r);break;case"dir":case"role":case"viewBox":case"width":case"height":ot(e,n,r);break;case"style":Et(e,r,s);break;case"data":if("object"!==t){ot(e,"data",r);break}case"src":case"href":if(""===r&&("a"!==t||"href"!==n)){e.removeAttribute(n);break}if(null==r||"function"==typeof r||"symbol"==typeof r||"boolean"==typeof r){e.removeAttribute(n);break}r=Ct(""+r),e.setAttribute(n,r);break;case"action":case"formAction":if("function"==typeof r){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}if("function"==typeof s&&("formAction"===n?("input"!==t&&ld(e,t,"name",a.name,a,null),ld(e,t,"formEncType",a.formEncType,a,null),ld(e,t,"formMethod",a.formMethod,a,null),ld(e,t,"formTarget",a.formTarget,a,null)):(ld(e,t,"encType",a.encType,a,null),ld(e,t,"method",a.method,a,null),ld(e,t,"target",a.target,a,null))),null==r||"symbol"==typeof r||"boolean"==typeof r){e.removeAttribute(n);break}r=Ct(""+r),e.setAttribute(n,r);break;case"onClick":null!=r&&(e.onclick=Pt);break;case"onScroll":null!=r&&$u("scroll",e);break;case"onScrollEnd":null!=r&&$u("scrollend",e);break;case"dangerouslySetInnerHTML":if(null!=r){if("object"!=typeof r||!("__html"in r))throw Error(i(61));if(null!=(n=r.__html)){if(null!=a.children)throw Error(i(60));e.innerHTML=n}}break;case"multiple":e.multiple=r&&"function"!=typeof r&&"symbol"!=typeof r;break;case"muted":e.muted=r&&"function"!=typeof r&&"symbol"!=typeof r;break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":case"autoFocus":break;case"xlinkHref":if(null==r||"function"==typeof r||"boolean"==typeof r||"symbol"==typeof r){e.removeAttribute("xlink:href");break}n=Ct(""+r),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":null!=r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,""+r):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":!0===r?e.setAttribute(n,""):!1!==r&&null!=r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,r):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":null!=r&&"function"!=typeof r&&"symbol"!=typeof r&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case"rowSpan":case"start":null==r||"function"==typeof r||"symbol"==typeof r||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case"popover":$u("beforetoggle",e),$u("toggle",e),st(e,"popover",r);break;case"xlinkActuate":lt(e,"http://www.w3.org/1999/xlink","xlink:actuate",r);break;case"xlinkArcrole":lt(e,"http://www.w3.org/1999/xlink","xlink:arcrole",r);break;case"xlinkRole":lt(e,"http://www.w3.org/1999/xlink","xlink:role",r);break;case"xlinkShow":lt(e,"http://www.w3.org/1999/xlink","xlink:show",r);break;case"xlinkTitle":lt(e,"http://www.w3.org/1999/xlink","xlink:title",r);break;case"xlinkType":lt(e,"http://www.w3.org/1999/xlink","xlink:type",r);break;case"xmlBase":lt(e,"http://www.w3.org/XML/1998/namespace","xml:base",r);break;case"xmlLang":lt(e,"http://www.w3.org/XML/1998/namespace","xml:lang",r);break;case"xmlSpace":lt(e,"http://www.w3.org/XML/1998/namespace","xml:space",r);break;case"is":st(e,"is",r);break;case"innerText":case"textContent":break;default:(!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&&st(e,n=At.get(n)||n,r)}}function cd(e,t,n,r,a,s){switch(n){case"style":Et(e,r,s);break;case"dangerouslySetInnerHTML":if(null!=r){if("object"!=typeof r||!("__html"in r))throw Error(i(61));if(null!=(n=r.__html)){if(null!=a.children)throw Error(i(60));e.innerHTML=n}}break;case"children":"string"==typeof r?wt(e,r):("number"==typeof r||"bigint"==typeof r)&&wt(e,""+r);break;case"onScroll":null!=r&&$u("scroll",e);break;case"onScrollEnd":null!=r&&$u("scrollend",e);break;case"onClick":null!=r&&(e.onclick=Pt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:et.hasOwnProperty(n)||("o"!==n[0]||"n"!==n[1]||(a=n.endsWith("Capture"),t=n.slice(2,a?n.length-7:void 0),"function"==typeof(s=null!=(s=e[Be]||null)?s[n]:null)&&e.removeEventListener(t,s,a),"function"!=typeof r)?n in e?e[n]=r:!0===r?e.setAttribute(n,""):st(e,n,r):("function"!=typeof s&&null!==s&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a)))}}function ud(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":$u("error",e),$u("load",e);var r,a=!1,s=!1;for(r in n)if(n.hasOwnProperty(r)){var o=n[r];if(null!=o)switch(r){case"src":a=!0;break;case"srcSet":s=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,t));default:ld(e,t,r,o,n,null)}}return s&&ld(e,t,"srcSet",n.srcSet,n,null),void(a&&ld(e,t,"src",n.src,n,null));case"input":$u("invalid",e);var l=r=o=s=null,c=null,u=null;for(a in n)if(n.hasOwnProperty(a)){var d=n[a];if(null!=d)switch(a){case"name":s=d;break;case"type":o=d;break;case"checked":c=d;break;case"defaultChecked":u=d;break;case"value":r=d;break;case"defaultValue":l=d;break;case"children":case"dangerouslySetInnerHTML":if(null!=d)throw Error(i(137,t));break;default:ld(e,t,a,d,n,null)}}return void vt(e,r,l,c,u,o,s,!1);case"select":for(s in $u("invalid",e),a=o=r=null,n)if(n.hasOwnProperty(s)&&null!=(l=n[s]))switch(s){case"value":r=l;break;case"defaultValue":o=l;break;case"multiple":a=l;default:ld(e,t,s,l,n,null)}return t=r,n=o,e.multiple=!!a,void(null!=t?xt(e,!!a,t,!1):null!=n&&xt(e,!!a,n,!0));case"textarea":for(o in $u("invalid",e),r=s=a=null,n)if(n.hasOwnProperty(o)&&null!=(l=n[o]))switch(o){case"value":a=l;break;case"defaultValue":s=l;break;case"children":r=l;break;case"dangerouslySetInnerHTML":if(null!=l)throw Error(i(91));break;default:ld(e,t,o,l,n,null)}return void bt(e,a,s,r);case"option":for(c in n)n.hasOwnProperty(c)&&null!=(a=n[c])&&("selected"===c?e.selected=a&&"function"!=typeof a&&"symbol"!=typeof a:ld(e,t,c,a,n,null));return;case"dialog":$u("beforetoggle",e),$u("toggle",e),$u("cancel",e),$u("close",e);break;case"iframe":case"object":$u("load",e);break;case"video":case"audio":for(a=0;a<Wu.length;a++)$u(Wu[a],e);break;case"image":$u("error",e),$u("load",e);break;case"details":$u("toggle",e);break;case"embed":case"source":case"link":$u("error",e),$u("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(u in n)if(n.hasOwnProperty(u)&&null!=(a=n[u]))switch(u){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,t));default:ld(e,t,u,a,n,null)}return;default:if(Tt(t)){for(d in n)n.hasOwnProperty(d)&&void 0!==(a=n[d])&&cd(e,t,d,a,n,void 0);return}}for(l in n)n.hasOwnProperty(l)&&null!=(a=n[l])&&ld(e,t,l,a,n,null)}function dd(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}var hd=null,fd=null;function pd(e){return 9===e.nodeType?e:e.ownerDocument}function md(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function gd(e,t){if(0===e)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return 1===e&&"foreignObject"===t?0:e}function vd(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"bigint"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var yd=null,xd="function"==typeof setTimeout?setTimeout:void 0,_d="function"==typeof clearTimeout?clearTimeout:void 0,bd="function"==typeof Promise?Promise:void 0,wd="function"==typeof queueMicrotask?queueMicrotask:void 0!==bd?function(e){return bd.resolve(null).then(e).catch(Sd)}:xd;function Sd(e){setTimeout(function(){throw e})}function Md(e){return"head"===e}function Ed(e,t){var n=t,i=0;do{var r=n.nextSibling;if(e.removeChild(n),r&&8===r.nodeType)if("/$"===(n=r.data)||"/&"===n){if(0===i)return e.removeChild(r),void Hh(t);i--}else if("$"===n||"$?"===n||"$~"===n||"$!"===n||"&"===n)i++;else if("html"===n)kd(e.ownerDocument.documentElement);else if("head"===n){kd(n=e.ownerDocument.head);for(var a=n.firstChild;a;){var s=a.nextSibling,o=a.nodeName;a[Xe]||"SCRIPT"===o||"STYLE"===o||"LINK"===o&&"stylesheet"===a.rel.toLowerCase()||n.removeChild(a),a=s}}else"body"===n&&kd(e.ownerDocument.body);n=r}while(n);Hh(t)}function Td(e,t){var n=e;e=0;do{var i=n.nextSibling;if(1===n.nodeType?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",""===n.getAttribute("style")&&n.removeAttribute("style")):3===n.nodeType&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),i&&8===i.nodeType)if("/$"===(n=i.data)){if(0===e)break;e--}else"$"!==n&&"$?"!==n&&"$~"!==n&&"$!"!==n||e++;n=i}while(n)}function Ad(e){var t=e.firstChild;for(t&&10===t.nodeType&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":Ad(n),qe(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===n.rel.toLowerCase())continue}e.removeChild(n)}}function Rd(e,t){for(;8!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!t)return null;if(null===(e=Ld(e.nextSibling)))return null}return e}function Cd(e){return"$?"===e.data||"$~"===e.data}function Pd(e){return"$!"===e.data||"$?"===e.data&&"loading"!==e.ownerDocument.readyState}function Ld(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t||"$~"===t||"&"===t||"F!"===t||"F"===t)break;if("/$"===t||"/&"===t)return null}}return e}var Id=null;function Dd(e){e=e.nextSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("/$"===n||"/&"===n){if(0===t)return Ld(e.nextSibling);t--}else"$"!==n&&"$!"!==n&&"$?"!==n&&"$~"!==n&&"&"!==n||t++}e=e.nextSibling}return null}function Nd(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n||"$~"===n||"&"===n){if(0===t)return e;t--}else"/$"!==n&&"/&"!==n||t++}e=e.previousSibling}return null}function Od(e,t,n){switch(t=pd(n),e){case"html":if(!(e=t.documentElement))throw Error(i(452));return e;case"head":if(!(e=t.head))throw Error(i(453));return e;case"body":if(!(e=t.body))throw Error(i(454));return e;default:throw Error(i(451))}}function kd(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);qe(e)}var Ud=new Map,Fd=new Set;function zd(e){return"function"==typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var Bd=D.d;D.d={f:function(){var e=Bd.f(),t=Zc();return e||t},r:function(e){var t=Ye(e);null!==t&&5===t.tag&&"form"===t.type?eo(t):Bd.r(e)},D:function(e){Bd.D(e),Hd("dns-prefetch",e,null)},C:function(e,t){Bd.C(e,t),Hd("preconnect",e,t)},L:function(e,t,n){Bd.L(e,t,n);var i=Vd;if(i&&e&&t){var r='link[rel="preload"][as="'+mt(t)+'"]';"image"===t&&n&&n.imageSrcSet?(r+='[imagesrcset="'+mt(n.imageSrcSet)+'"]',"string"==typeof n.imageSizes&&(r+='[imagesizes="'+mt(n.imageSizes)+'"]')):r+='[href="'+mt(e)+'"]';var a=r;switch(t){case"style":a=jd(e);break;case"script":a=qd(e)}Ud.has(a)||(e=d({rel:"preload",href:"image"===t&&n&&n.imageSrcSet?void 0:e,as:t},n),Ud.set(a,e),null!==i.querySelector(r)||"style"===t&&i.querySelector(Wd(a))||"script"===t&&i.querySelector($d(a))||(ud(t=i.createElement("link"),"link",e),Qe(t),i.head.appendChild(t)))}},m:function(e,t){Bd.m(e,t);var n=Vd;if(n&&e){var i=t&&"string"==typeof t.as?t.as:"script",r='link[rel="modulepreload"][as="'+mt(i)+'"][href="'+mt(e)+'"]',a=r;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":a=qd(e)}if(!Ud.has(a)&&(e=d({rel:"modulepreload",href:e},t),Ud.set(a,e),null===n.querySelector(r))){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector($d(a)))return}ud(i=n.createElement("link"),"link",e),Qe(i),n.head.appendChild(i)}}},X:function(e,t){Bd.X(e,t);var n=Vd;if(n&&e){var i=Ze(n).hoistableScripts,r=qd(e),a=i.get(r);a||((a=n.querySelector($d(r)))||(e=d({src:e,async:!0},t),(t=Ud.get(r))&&Qd(e,t),Qe(a=n.createElement("script")),ud(a,"link",e),n.head.appendChild(a)),a={type:"script",instance:a,count:1,state:null},i.set(r,a))}},S:function(e,t,n){Bd.S(e,t,n);var i=Vd;if(i&&e){var r=Ze(i).hoistableStyles,a=jd(e);t=t||"default";var s=r.get(a);if(!s){var o={loading:0,preload:null};if(s=i.querySelector(Wd(a)))o.loading=5;else{e=d({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Ud.get(a))&&Zd(e,n);var l=s=i.createElement("link");Qe(l),ud(l,"link",e),l._p=new Promise(function(e,t){l.onload=e,l.onerror=t}),l.addEventListener("load",function(){o.loading|=1}),l.addEventListener("error",function(){o.loading|=2}),o.loading|=4,Kd(s,t,i)}s={type:"stylesheet",instance:s,count:1,state:o},r.set(a,s)}}},M:function(e,t){Bd.M(e,t);var n=Vd;if(n&&e){var i=Ze(n).hoistableScripts,r=qd(e),a=i.get(r);a||((a=n.querySelector($d(r)))||(e=d({src:e,async:!0,type:"module"},t),(t=Ud.get(r))&&Qd(e,t),Qe(a=n.createElement("script")),ud(a,"link",e),n.head.appendChild(a)),a={type:"script",instance:a,count:1,state:null},i.set(r,a))}}};var Vd="undefined"==typeof document?null:document;function Hd(e,t,n){var i=Vd;if(i&&"string"==typeof t&&t){var r=mt(t);r='link[rel="'+e+'"][href="'+r+'"]',"string"==typeof n&&(r+='[crossorigin="'+n+'"]'),Fd.has(r)||(Fd.add(r),e={rel:e,crossOrigin:n,href:t},null===i.querySelector(r)&&(ud(t=i.createElement("link"),"link",e),Qe(t),i.head.appendChild(t)))}}function Gd(e,t,n,r){var a,s,o,l,c=(c=j.current)?zd(c):null;if(!c)throw Error(i(446));switch(e){case"meta":case"title":return null;case"style":return"string"==typeof n.precedence&&"string"==typeof n.href?(t=jd(n.href),(r=(n=Ze(c).hoistableStyles).get(t))||(r={type:"style",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};case"link":if("stylesheet"===n.rel&&"string"==typeof n.href&&"string"==typeof n.precedence){e=jd(n.href);var u=Ze(c).hoistableStyles,d=u.get(e);if(d||(c=c.ownerDocument||c,d={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,d),(u=c.querySelector(Wd(e)))&&!u._p&&(d.instance=u,d.state.loading=5),Ud.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Ud.set(e,n),u||(a=c,s=e,o=n,l=d.state,a.querySelector('link[rel="preload"][as="style"]['+s+"]")?l.loading=1:(s=a.createElement("link"),l.preload=s,s.addEventListener("load",function(){return l.loading|=1}),s.addEventListener("error",function(){return l.loading|=2}),ud(s,"link",o),Qe(s),a.head.appendChild(s))))),t&&null===r)throw Error(i(528,""));return d}if(t&&null!==r)throw Error(i(529,""));return null;case"script":return t=n.async,"string"==typeof(n=n.src)&&t&&"function"!=typeof t&&"symbol"!=typeof t?(t=qd(n),(r=(n=Ze(c).hoistableScripts).get(t))||(r={type:"script",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,e))}}function jd(e){return'href="'+mt(e)+'"'}function Wd(e){return'link[rel="stylesheet"]['+e+"]"}function Xd(e){return d({},e,{"data-precedence":e.precedence,precedence:null})}function qd(e){return'[src="'+mt(e)+'"]'}function $d(e){return"script[async]"+e}function Yd(e,t,n){if(t.count++,null===t.instance)switch(t.type){case"style":var r=e.querySelector('style[data-href~="'+mt(n.href)+'"]');if(r)return t.instance=r,Qe(r),r;var a=d({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return Qe(r=(e.ownerDocument||e).createElement("style")),ud(r,"style",a),Kd(r,n.precedence,e),t.instance=r;case"stylesheet":a=jd(n.href);var s=e.querySelector(Wd(a));if(s)return t.state.loading|=4,t.instance=s,Qe(s),s;r=Xd(n),(a=Ud.get(a))&&Zd(r,a),Qe(s=(e.ownerDocument||e).createElement("link"));var o=s;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),ud(s,"link",r),t.state.loading|=4,Kd(s,n.precedence,e),t.instance=s;case"script":return s=qd(n.src),(a=e.querySelector($d(s)))?(t.instance=a,Qe(a),a):(r=n,(a=Ud.get(s))&&Qd(r=d({},n),a),Qe(a=(e=e.ownerDocument||e).createElement("script")),ud(a,"link",r),e.head.appendChild(a),t.instance=a);case"void":return null;default:throw Error(i(443,t.type))}else"stylesheet"===t.type&&!(4&t.state.loading)&&(r=t.instance,t.state.loading|=4,Kd(r,n.precedence,e));return t.instance}function Kd(e,t,n){for(var i=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=i.length?i[i.length-1]:null,a=r,s=0;s<i.length;s++){var o=i[s];if(o.dataset.precedence===t)a=o;else if(a!==r)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=9===n.nodeType?n.head:n).insertBefore(e,t.firstChild)}function Zd(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function Qd(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var Jd=null;function eh(e,t,n){if(null===Jd){var i=new Map,r=Jd=new Map;r.set(n,i)}else(i=(r=Jd).get(n))||(i=new Map,r.set(n,i));if(i.has(e))return i;for(i.set(e,null),n=n.getElementsByTagName(e),r=0;r<n.length;r++){var a=n[r];if(!(a[Xe]||a[ze]||"link"===e&&"stylesheet"===a.getAttribute("rel"))&&"http://www.w3.org/2000/svg"!==a.namespaceURI){var s=a.getAttribute(t)||"";s=e+s;var o=i.get(s);o?o.push(a):i.set(s,[a])}}return i}function th(e,t,n){(e=e.ownerDocument||e).head.insertBefore(n,"title"===t?e.querySelector("head > title"):null)}function nh(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var ih=0;function rh(){if(this.count--,0===this.count&&(0===this.imgCount||!this.waitingForImages))if(this.stylesheets)sh(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var ah=null;function sh(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,ah=new Map,t.forEach(oh,e),ah=null,rh.call(e))}function oh(e,t){if(!(4&t.state.loading)){var n=ah.get(e);if(n)var i=n.get(null);else{n=new Map,ah.set(e,n);for(var r=e.querySelectorAll("link[data-precedence],style[data-precedence]"),a=0;a<r.length;a++){var s=r[a];"LINK"!==s.nodeName&&"not all"===s.getAttribute("media")||(n.set(s.dataset.precedence,s),i=s)}i&&n.set(null,i)}s=(r=t.instance).getAttribute("data-precedence"),(a=n.get(s)||i)===i&&n.set(null,r),n.set(s,r),this.count++,i=rh.bind(this),r.addEventListener("load",i),r.addEventListener("error",i),a?a.parentNode.insertBefore(r,a.nextSibling):(e=9===e.nodeType?e.head:e).insertBefore(r,e.firstChild),t.state.loading|=4}}var lh={$$typeof:x,Provider:null,Consumer:null,_currentValue:N,_currentValue2:N,_threadCount:0};function ch(e,t,n,i,r,a,s,o,l){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ce(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ce(0),this.hiddenUpdates=Ce(null),this.identifierPrefix=i,this.onUncaughtError=r,this.onCaughtError=a,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function uh(e,t,n,i,r,a,s,o,l,c,u,d){return e=new ch(e,t,n,s,l,c,u,d,o),t=1,!0===a&&(t|=24),a=ki(3,null,null,t),e.current=a,a.stateNode=e,(t=Ur()).refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:i,isDehydrated:n,cache:t},pa(a),e}function dh(e){return e?e=Ni:Ni}function hh(e,t,n,i,r,a){r=dh(r),null===i.context?i.context=r:i.pendingContext=r,(i=ga(t)).payload={element:n},null!==(a=void 0===a?null:a)&&(i.callback=a),null!==(n=va(e,i,t))&&(Xc(n,0,t),ya(n,e,t))}function fh(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function ph(e,t){fh(e,t),(e=e.alternate)&&fh(e,t)}function mh(e){if(13===e.tag||31===e.tag){var t=Li(e,67108864);null!==t&&Xc(t,0,67108864),ph(e,67108864)}}function gh(e){if(13===e.tag||31===e.tag){var t=jc(),n=Li(e,t=Ne(t));null!==n&&Xc(n,0,t),ph(e,t)}}var vh=!0;function yh(e,t,n,i){var r=I.T;I.T=null;var a=D.p;try{D.p=2,_h(e,t,n,i)}finally{D.p=a,I.T=r}}function xh(e,t,n,i){var r=I.T;I.T=null;var a=D.p;try{D.p=8,_h(e,t,n,i)}finally{D.p=a,I.T=r}}function _h(e,t,n,i){if(vh){var r=bh(i);if(null===r)Ju(e,t,i,wh,n),Dh(e,i);else if(function(e,t,n,i,r){switch(t){case"focusin":return Th=Nh(Th,e,t,n,i,r),!0;case"dragenter":return Ah=Nh(Ah,e,t,n,i,r),!0;case"mouseover":return Rh=Nh(Rh,e,t,n,i,r),!0;case"pointerover":var a=r.pointerId;return Ch.set(a,Nh(Ch.get(a)||null,e,t,n,i,r)),!0;case"gotpointercapture":return a=r.pointerId,Ph.set(a,Nh(Ph.get(a)||null,e,t,n,i,r)),!0}return!1}(r,e,t,n,i))i.stopPropagation();else if(Dh(e,i),4&t&&-1<Ih.indexOf(e)){for(;null!==r;){var a=Ye(r);if(null!==a)switch(a.tag){case 3:if((a=a.stateNode).current.memoizedState.isDehydrated){var s=Me(a.pendingLanes);if(0!==s){var o=a;for(o.pendingLanes|=2,o.entangledLanes|=2;s;){var l=1<<31-ye(s);o.entanglements[1]|=l,s&=~l}Du(a),!(6&dc)&&(Ic=se()+500,Nu(0))}}break;case 31:case 13:null!==(o=Li(a,2))&&Xc(o,0,2),Zc(),ph(a,2)}if(null===(a=bh(i))&&Ju(e,t,i,wh,n),a===r)break;r=a}null!==r&&i.stopPropagation()}else Ju(e,t,i,null,n)}}function bh(e){return Sh(e=It(e))}var wh=null;function Sh(e){if(wh=null,null!==(e=$e(e))){var t=a(e);if(null===t)e=null;else{var n=t.tag;if(13===n){if(null!==(e=s(t)))return e;e=null}else if(31===n){if(null!==(e=l(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return wh=e,null}function Mh(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(oe()){case le:return 2;case ce:return 8;case ue:case de:return 32;case he:return 268435456;default:return 32}default:return 32}}var Eh=!1,Th=null,Ah=null,Rh=null,Ch=new Map,Ph=new Map,Lh=[],Ih="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Dh(e,t){switch(e){case"focusin":case"focusout":Th=null;break;case"dragenter":case"dragleave":Ah=null;break;case"mouseover":case"mouseout":Rh=null;break;case"pointerover":case"pointerout":Ch.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ph.delete(t.pointerId)}}function Nh(e,t,n,i,r,a){return null===e||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:i,nativeEvent:a,targetContainers:[r]},null!==t&&null!==(t=Ye(t))&&mh(t),e):(e.eventSystemFlags|=i,t=e.targetContainers,null!==r&&-1===t.indexOf(r)&&t.push(r),e)}function Oh(e){var t=$e(e.target);if(null!==t){var n=a(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=s(n)))return e.blockedOn=t,void Ue(e.priority,function(){gh(n)})}else if(31===t){if(null!==(t=l(n)))return e.blockedOn=t,void Ue(e.priority,function(){gh(n)})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function kh(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=bh(e.nativeEvent);if(null!==n)return null!==(t=Ye(n))&&mh(t),e.blockedOn=n,!1;var i=new(n=e.nativeEvent).constructor(n.type,n);Lt=i,n.target.dispatchEvent(i),Lt=null,t.shift()}return!0}function Uh(e,t,n){kh(e)&&n.delete(t)}function Fh(){Eh=!1,null!==Th&&kh(Th)&&(Th=null),null!==Ah&&kh(Ah)&&(Ah=null),null!==Rh&&kh(Rh)&&(Rh=null),Ch.forEach(Uh),Ph.forEach(Uh)}function zh(t,n){t.blockedOn===n&&(t.blockedOn=null,Eh||(Eh=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Fh)))}var Bh=null;function Vh(t){Bh!==t&&(Bh=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Bh===t&&(Bh=null);for(var e=0;e<t.length;e+=3){var n=t[e],i=t[e+1],r=t[e+2];if("function"!=typeof i){if(null===Sh(i||n))continue;break}var a=Ye(n);null!==a&&(t.splice(e,3),e-=3,Qs(a,{pending:!0,data:r,method:n.method,action:i},i,r))}}))}function Hh(e){function t(t){return zh(t,e)}null!==Th&&zh(Th,e),null!==Ah&&zh(Ah,e),null!==Rh&&zh(Rh,e),Ch.forEach(t),Ph.forEach(t);for(var n=0;n<Lh.length;n++){var i=Lh[n];i.blockedOn===e&&(i.blockedOn=null)}for(;0<Lh.length&&null===(n=Lh[0]).blockedOn;)Oh(n),null===n.blockedOn&&Lh.shift();if(null!=(n=(e.ownerDocument||e).$$reactFormReplay))for(i=0;i<n.length;i+=3){var r=n[i],a=n[i+1],s=r[Be]||null;if("function"==typeof a)s||Vh(n);else if(s){var o=null;if(a&&a.hasAttribute("formAction")){if(r=a,s=a[Be]||null)o=s.formAction;else if(null!==Sh(r))continue}else o=s.action;"function"==typeof o?n[i+1]=o:(n.splice(i,3),i-=3),Vh(n)}}}function Gh(){function e(e){e.canIntercept&&"react-transition"===e.info&&e.intercept({handler:function(){return new Promise(function(e){return r=e})},focusReset:"manual",scroll:"manual"})}function t(){null!==r&&(r(),r=null),i||setTimeout(n,20)}function n(){if(!i&&!navigation.transition){var e=navigation.currentEntry;e&&null!=e.url&&navigation.navigate(e.url,{state:e.getState(),info:"react-transition",history:"replace"})}}if("object"==typeof navigation){var i=!1,r=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),null!==r&&(r(),r=null)}}}function jh(e){this._internalRoot=e}function Wh(e){this._internalRoot=e}Wh.prototype.render=jh.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(i(409));hh(t.current,jc(),e,t,null,null)},Wh.prototype.unmount=jh.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;hh(e.current,2,null,e,null,null),Zc(),t[Ve]=null}},Wh.prototype.unstable_scheduleHydration=function(e){if(e){var t=ke();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Lh.length&&0!==t&&t<Lh[n].priority;n++);Lh.splice(n,0,e),0===n&&Oh(e)}};var Xh=t.version;if("19.2.0"!==Xh)throw Error(i(527,Xh,"19.2.0"));D.findDOMNode=function(e){var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(i(188));throw e=Object.keys(e).join(","),Error(i(268,e))}return e=function(e){var t=e.alternate;if(!t){if(null===(t=a(e)))throw Error(i(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(null===s)break;var o=s.alternate;if(null===o){if(null!==(r=s.return)){n=r;continue}break}if(s.child===o.child){for(o=s.child;o;){if(o===n)return c(s),e;if(o===r)return c(s),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=s,r=o;else{for(var l=!1,u=s.child;u;){if(u===n){l=!0,n=s,r=o;break}if(u===r){l=!0,r=s,n=o;break}u=u.sibling}if(!l){for(u=o.child;u;){if(u===n){l=!0,n=o,r=s;break}if(u===r){l=!0,r=o,n=s;break}u=u.sibling}if(!l)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(3!==n.tag)throw Error(i(188));return n.stateNode.current===n?e:t}(t),null===(e=null!==e?u(e):null)?null:e.stateNode};var qh={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:I,reconcilerVersion:"19.2.0"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var $h=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!$h.isDisabled&&$h.supportsFiber)try{me=$h.inject(qh),ge=$h}catch(e){}}return Cx.createRoot=function(e,t){if(!r(e))throw Error(i(299));var n=!1,a="",s=wo,o=So,l=Mo;return null!=t&&(!0===t.unstable_strictMode&&(n=!0),void 0!==t.identifierPrefix&&(a=t.identifierPrefix),void 0!==t.onUncaughtError&&(s=t.onUncaughtError),void 0!==t.onCaughtError&&(o=t.onCaughtError),void 0!==t.onRecoverableError&&(l=t.onRecoverableError)),t=uh(e,1,!1,null,0,n,a,null,s,o,l,Gh),e[Ve]=t.current,Zu(e),new jh(t)},Cx.hydrateRoot=function(e,t,n){if(!r(e))throw Error(i(299));var a=!1,s="",o=wo,l=So,c=Mo,u=null;return null!=n&&(!0===n.unstable_strictMode&&(a=!0),void 0!==n.identifierPrefix&&(s=n.identifierPrefix),void 0!==n.onUncaughtError&&(o=n.onUncaughtError),void 0!==n.onCaughtError&&(l=n.onCaughtError),void 0!==n.onRecoverableError&&(c=n.onRecoverableError),void 0!==n.formState&&(u=n.formState)),(t=uh(e,1,!0,t,0,a,s,u,o,l,c,Gh)).context=dh(null),n=t.current,(s=ga(a=Ne(a=jc()))).callback=null,va(n,s,a),n=a,t.current.lanes=n,Pe(t,n),Du(t),e[Ve]=t.current,Zu(e),new Wh(t)},Cx.version="19.2.0",Cx}();var zx=Rx.exports;class Bx{constructor(e){this.version="2.2.0",e.ipd=0,yo.getState().setInputMode(e.primaryInputMode),this.devUIContainer=document.createElement("div"),this.devUIContainer.style.position="fixed",this.devUIContainer.style.width="100vw",this.devUIContainer.style.height="100vh",this.devUIContainer.style.top="50vh",this.devUIContainer.style.left="50vw",this.devUIContainer.style.transform="translate(-50%, -50%)",this.devUIContainer.style.pointerEvents="none";const t=this.devUIContainer.attachShadow({mode:"open"});this.inputLayer=new Ex(e),this.unsubscribeControlMode=e.onControlModeChange(e=>{this.inputLayer.isInProgrammaticMode="programmatic"===e,"programmatic"===e?(this.inputLayer.syncFromDevice(),this.inputLayer.setInteractionsEnabled(!1)):this.inputLayer.setInteractionsEnabled(!0)}),this.unsubscribeStateChange=e.onStateChange(()=>{this.inputLayer.isInProgrammaticMode&&this.inputLayer.syncFromDevice()});zx.createRoot(t).render(c.jsx(Vx,{xrDevice:e,inputLayer:this.inputLayer,shadowRoot:t}));const n=()=>{const t=document.createElement("div");document.body.appendChild(t);const n=t.attachShadow({mode:"open"});zx.createRoot(n).render(c.jsx(Hx,{xrDevice:e,shadowRoot:n}))};document.body?n():window.onload=n}render(e){this.inputLayer.renderScene(e)}dispose(){this.unsubscribeControlMode(),this.unsubscribeStateChange(),this.inputLayer.dispose()}get devUICanvas(){return this.inputLayer.domElement}}const Vx=({xrDevice:e,inputLayer:t,shadowRoot:n})=>{const[i,r]=o.useState(!1),[a,s]=o.useState(e.controlMode);return o.useEffect(()=>{const t=()=>{const e=document.pointerLockElement||document.mozPointerLockElement||document.webkitPointerLockElement;r(!!e)};document.addEventListener("pointerlockchange",t,!1),document.addEventListener("mozpointerlockchange",t,!1),document.addEventListener("webkitpointerlockchange",t,!1);const n=e.onControlModeChange(e=>{s(e)});return()=>{document.removeEventListener("pointerlockchange",t,!1),document.removeEventListener("mozpointerlockchange",t,!1),document.removeEventListener("webkitpointerlockchange",t,!1),n()}},[e]),c.jsx(aa,{target:n,disableCSSOMInjection:!0,children:c.jsxs("div",{style:{width:"100vw",height:"100vh",display:"flex",flexDirection:"column",justifyContent:"space-between",pointerEvents:"none"},children:["programmatic"===a&&c.jsxs(c.Fragment,{children:[c.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:999,boxShadow:"inset 0 0 20px 5px rgba(59, 130, 246, 0.5)"}}),c.jsxs("div",{style:{position:"absolute",bottom:"8px",left:"50%",transform:"translateX(-50%)",backgroundColor:"rgba(59, 130, 246, 0.9)",color:"white",padding:"6px 16px",borderRadius:"16px",fontSize:"12px",fontFamily:"system-ui, sans-serif",fontWeight:500,zIndex:1e3,display:"flex",alignItems:"center",gap:"6px",boxShadow:"0 2px 8px rgba(0,0,0,0.3)"},children:[c.jsx("span",{style:{fontSize:"14px"},children:"●"}),"Remote Control Active"]})]}),"programmatic"!==a&&c.jsxs(c.Fragment,{children:[c.jsx(Mo,{xrDevice:e,inputLayer:t}),c.jsx(Ao,{xrDevice:e,inputLayer:t,pointerLocked:i}),c.jsx(xo,{xrDevice:e,inputLayer:t,pointerLocked:i})]})]})})},Hx=({xrDevice:e,shadowRoot:t})=>{const[n,i]=l.useState(e.sessionOffered&&!e.activeSession);return l.useEffect(()=>{setInterval(()=>{i(e.sessionOffered&&!e.activeSession)},1e3)},[]),c.jsx(aa,{target:t,disableCSSOMInjection:!0,children:c.jsxs(Wa,{style:{zIndex:899,position:"fixed",top:n?"8px":"-30px",display:"flex",flexDirection:"row",alignItems:"center",justifyItems:"space-between",left:"50vw",transform:"translateX(-50%)",transition:"all 0.2s ease-in-out",paddingLeft:"5px",gap:"3px"},children:[c.jsx(Ls,{size:24}),c.jsx(Xa,{onClick:()=>{e.grantOfferedSession()},style:{fontSize:"16px"},children:"Enter XR"})]})})};var Gx=1e-6,jx="undefined"!=typeof Float32Array?Float32Array:Array;function Wx(){var e=new jx(16);return jx!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Xx(e){var t=new jx(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function qx(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function $x(e,t){var n=t[0],i=t[1],r=t[2],a=t[3],s=t[4],o=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],f=t[11],p=t[12],m=t[13],g=t[14],v=t[15],y=n*o-i*s,x=n*l-r*s,_=n*c-a*s,b=i*l-r*o,w=i*c-a*o,S=r*c-a*l,M=u*m-d*p,E=u*g-h*p,T=u*v-f*p,A=d*g-h*m,R=d*v-f*m,C=h*v-f*g,P=y*C-x*R+_*A+b*T-w*E+S*M;return P?(P=1/P,e[0]=(o*C-l*R+c*A)*P,e[1]=(r*R-i*C-a*A)*P,e[2]=(m*S-g*w+v*b)*P,e[3]=(h*w-d*S-f*b)*P,e[4]=(l*T-s*C-c*E)*P,e[5]=(n*C-r*T+a*E)*P,e[6]=(g*_-p*S-v*x)*P,e[7]=(u*S-h*_+f*x)*P,e[8]=(s*R-o*T+c*M)*P,e[9]=(i*T-n*R-a*M)*P,e[10]=(p*w-m*_+v*y)*P,e[11]=(d*_-u*w-f*y)*P,e[12]=(o*E-s*A-l*M)*P,e[13]=(n*A-i*E+r*M)*P,e[14]=(m*x-p*b-g*y)*P,e[15]=(u*b-d*x+h*y)*P,e):null}function Yx(e,t,n){var i=t[0],r=t[1],a=t[2],s=t[3],o=t[4],l=t[5],c=t[6],u=t[7],d=t[8],h=t[9],f=t[10],p=t[11],m=t[12],g=t[13],v=t[14],y=t[15],x=n[0],_=n[1],b=n[2],w=n[3];return e[0]=x*i+_*o+b*d+w*m,e[1]=x*r+_*l+b*h+w*g,e[2]=x*a+_*c+b*f+w*v,e[3]=x*s+_*u+b*p+w*y,x=n[4],_=n[5],b=n[6],w=n[7],e[4]=x*i+_*o+b*d+w*m,e[5]=x*r+_*l+b*h+w*g,e[6]=x*a+_*c+b*f+w*v,e[7]=x*s+_*u+b*p+w*y,x=n[8],_=n[9],b=n[10],w=n[11],e[8]=x*i+_*o+b*d+w*m,e[9]=x*r+_*l+b*h+w*g,e[10]=x*a+_*c+b*f+w*v,e[11]=x*s+_*u+b*p+w*y,x=n[12],_=n[13],b=n[14],w=n[15],e[12]=x*i+_*o+b*d+w*m,e[13]=x*r+_*l+b*h+w*g,e[14]=x*a+_*c+b*f+w*v,e[15]=x*s+_*u+b*p+w*y,e}function Kx(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function Zx(e,t,n){var i,r,a,s=n[0],o=n[1],l=n[2],c=Math.sqrt(s*s+o*o+l*l);return c<Gx?null:(s*=c=1/c,o*=c,l*=c,i=Math.sin(t),a=1-(r=Math.cos(t)),e[0]=s*s*a+r,e[1]=o*s*a+l*i,e[2]=l*s*a-o*i,e[3]=0,e[4]=s*o*a-l*i,e[5]=o*o*a+r,e[6]=l*o*a+s*i,e[7]=0,e[8]=s*l*a+o*i,e[9]=o*l*a-s*i,e[10]=l*l*a+r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function Qx(e,t,n){var i=t[0],r=t[1],a=t[2],s=t[3],o=i+i,l=r+r,c=a+a,u=i*o,d=i*l,h=i*c,f=r*l,p=r*c,m=a*c,g=s*o,v=s*l,y=s*c;return e[0]=1-(f+m),e[1]=d+y,e[2]=h-v,e[3]=0,e[4]=d-y,e[5]=1-(u+m),e[6]=p+g,e[7]=0,e[8]=h+v,e[9]=p-g,e[10]=1-(u+f),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Jx(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function e_(e,t){var n=t[0],i=t[1],r=t[2],a=t[4],s=t[5],o=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.sqrt(n*n+i*i+r*r),e[1]=Math.sqrt(a*a+s*s+o*o),e[2]=Math.sqrt(l*l+c*c+u*u),e}function t_(e,t){var n=new jx(3);e_(n,t);var i=1/n[0],r=1/n[1],a=1/n[2],s=t[0]*i,o=t[1]*r,l=t[2]*a,c=t[4]*i,u=t[5]*r,d=t[6]*a,h=t[8]*i,f=t[9]*r,p=t[10]*a,m=s+u+p,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(d-f)/g,e[1]=(h-l)/g,e[2]=(o-c)/g):s>u&&s>p?(g=2*Math.sqrt(1+s-u-p),e[3]=(d-f)/g,e[0]=.25*g,e[1]=(o+c)/g,e[2]=(h+l)/g):u>p?(g=2*Math.sqrt(1+u-s-p),e[3]=(h-l)/g,e[0]=(o+c)/g,e[1]=.25*g,e[2]=(d+f)/g):(g=2*Math.sqrt(1+p-s-u),e[3]=(o-c)/g,e[0]=(h+l)/g,e[1]=(d+f)/g,e[2]=.25*g),e}var n_=function(e,t,n,i,r){var a=1/Math.tan(t/2);if(e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=r&&r!==1/0){var s=1/(i-r);e[10]=(r+i)*s,e[14]=2*r*i*s}else e[10]=-1,e[14]=-2*i;return e};function i_(){var e=new jx(3);return jx!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function r_(e,t,n){var i=new jx(3);return i[0]=e,i[1]=t,i[2]=n,i}function a_(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function s_(e,t,n,i){return e[0]=t,e[1]=n,e[2]=i,e}function o_(e,t){var n=t[0],i=t[1],r=t[2],a=n*n+i*i+r*r;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e}function l_(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function c_(e,t,n){var i=t[0],r=t[1],a=t[2],s=n[0],o=n[1],l=n[2];return e[0]=r*l-a*o,e[1]=a*s-i*l,e[2]=i*o-r*s,e}function u_(e,t,n,i){var r=t[0],a=t[1],s=t[2];return e[0]=r+i*(n[0]-r),e[1]=a+i*(n[1]-a),e[2]=s+i*(n[2]-s),e}function d_(){var e=new jx(4);return jx!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function h_(e,t,n,i,r){return e[0]=t,e[1]=n,e[2]=i,e[3]=r,e}function f_(e,t,n){var i=t[0],r=t[1],a=t[2],s=t[3];return e[0]=n[0]*i+n[4]*r+n[8]*a+n[12]*s,e[1]=n[1]*i+n[5]*r+n[9]*a+n[13]*s,e[2]=n[2]*i+n[6]*r+n[10]*a+n[14]*s,e[3]=n[3]*i+n[7]*r+n[11]*a+n[15]*s,e}function p_(){var e=new jx(4);return jx!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function m_(e,t,n){n*=.5;var i=Math.sin(n);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(n),e}function g_(e,t,n,i){var r,a,s,o,l,c=t[0],u=t[1],d=t[2],h=t[3],f=n[0],p=n[1],m=n[2],g=n[3];return(a=c*f+u*p+d*m+h*g)<0&&(a=-a,f=-f,p=-p,m=-m,g=-g),1-a>Gx?(r=Math.acos(a),s=Math.sin(r),o=Math.sin((1-i)*r)/s,l=Math.sin(i*r)/s):(o=1-i,l=i),e[0]=o*c+l*f,e[1]=o*u+l*p,e[2]=o*d+l*m,e[3]=o*h+l*g,e}i_(),function(){var e=d_()}();var v_,y_=function(e,t,n,i){var r=new jx(4);return r[0]=e,r[1]=t,r[2]=n,r[3]=i,r},x_=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},__=h_,b_=function(e,t){var n=t[0],i=t[1],r=t[2],a=t[3],s=n*n+i*i+r*r+a*a;return s>0&&(s=1/Math.sqrt(s)),e[0]=n*s,e[1]=i*s,e[2]=r*s,e[3]=a*s,e};i_(),r_(1,0,0),r_(0,1,0),p_(),p_(),v_=new jx(9),jx!=Float32Array&&(v_[1]=0,v_[2]=0,v_[3]=0,v_[5]=0,v_[6]=0,v_[7]=0),v_[0]=1,v_[4]=1,v_[8]=1;const w_=Symbol("@iwer/action-player"),S_=Symbol("@iwer/xr-anchor"),M_=Symbol("@iwer/xr-controller"),E_=Symbol("@iwer/xr-device"),T_=Symbol("@iwer/xr-hand-input"),A_=Symbol("@iwer/xr-tracked-input"),R_=Symbol("@iwer/xr-frame"),C_=Symbol("@iwer/gamepad"),P_=Symbol("@iwer/xr-system"),L_=Symbol("@iwer/xr-input-source"),I_=Symbol("@iwer/xr-webgl-layer"),D_=Symbol("@iwer/xr-mesh"),N_=Symbol("@iwer/xr-plane"),O_=Symbol("@iwer/xr-joint-pose"),k_=Symbol("@iwer/xr-pose"),U_=Symbol("@iwer/xr-viewer-pose"),F_=Symbol("@iwer/xr-rigid-transform"),z_=Symbol("@iwer/xr-render-state"),B_=Symbol("@iwer/xr-session"),V_=Symbol("@iwer/xr-joint-space"),H_=Symbol("@iwer/xr-reference-space"),G_=Symbol("@iwer/xr-space"),j_=Symbol("@iwer/xr-view"),W_=Symbol("@iwer/xr-viewport"),X_=Symbol("@iwer/xr-ray"),q_=Symbol("@iwer/xr-hit-test");class $_ extends EventTarget{constructor(e,t){super(),this[G_]={parentSpace:e,offsetMatrix:t?Xx(t):Wx(),emulated:!0}}}class Y_ extends $_{constructor(){super(void 0,Wx())}}class K_{static updateOffsetPosition(e,t){Kx(e[G_].offsetMatrix,t)}static updateOffsetQuaternion(e,t){const n=e[G_].offsetMatrix,i=i_();Jx(i,n),Qx(n,t,i)}static updateOffsetMatrix(e,t){qx(e[G_].offsetMatrix,t)}static calculateGlobalOffsetMatrix(e,t=Wx()){return Yx(t,e[G_].parentSpace?K_.calculateGlobalOffsetMatrix(e[G_].parentSpace):Wx(),e[G_].offsetMatrix),t}}let Z_=class e{constructor(e=0,t=0,n=0){this.vec3=r_(e,t,n),this.tempVec3=i_()}get x(){return this.vec3[0]}set x(e){this.vec3[0]=e}get y(){return this.vec3[1]}set y(e){this.vec3[1]=e}get z(){return this.vec3[2]}set z(e){this.vec3[2]=e}set(e,t,n){return s_(this.vec3,e,t,n),this}clone(){return new e(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}normalize(){return a_(this.tempVec3,this.vec3),o_(this.vec3,this.tempVec3),this}add(e){return a_(this.tempVec3,this.vec3),function(e,t,n){e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2]}(this.vec3,this.tempVec3,e.vec3),this}applyQuaternion(e){return a_(this.tempVec3,this.vec3),function(e,t,n){var i=n[0],r=n[1],a=n[2],s=n[3],o=t[0],l=t[1],c=t[2],u=r*c-a*l,d=a*o-i*c,h=i*l-r*o;u+=u,d+=d,h+=h,e[0]=o+s*u+r*h-a*d,e[1]=l+s*d+a*u-i*h,e[2]=c+s*h+i*d-r*u}(this.vec3,this.tempVec3,e.quat),this}},Q_=class e{constructor(e=0,t=0,n=0,i=1){this.quat=y_(e,t,n,i),this.tempQuat=p_()}get x(){return this.quat[0]}set x(e){this.quat[0]=e}get y(){return this.quat[1]}set y(e){this.quat[1]=e}get z(){return this.quat[2]}set z(e){this.quat[2]=e}get w(){return this.quat[3]}set w(e){this.quat[3]=e}set(e,t,n,i){return __(this.quat,e,t,n,i),this}clone(){return new e(this.x,this.y,this.z,this.w)}copy(e){return __(this.quat,e.x,e.y,e.z,e.w),this}normalize(){return x_(this.tempQuat,this.quat),b_(this.quat,this.tempQuat),this}invert(){return x_(this.tempQuat,this.quat),function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(this.quat,this.tempQuat),this}multiply(e){return x_(this.tempQuat,this.quat),function(e,t,n){var i=t[0],r=t[1],a=t[2],s=t[3],o=n[0],l=n[1],c=n[2],u=n[3];e[0]=i*u+s*o+r*c-a*l,e[1]=r*u+s*l+a*o-i*c,e[2]=a*u+s*c+i*l-r*o,e[3]=s*u-i*o-r*l-a*c}(this.quat,this.tempQuat,e.quat),this}setFromAxisAngle(e,t){return m_(this.quat,e.vec3,t),this}};function J_(e){return{x:e.x,y:e.y,z:e.z}}function eb(e){return{x:e.x,y:e.y,z:e.z,w:e.w}}function tb(e){const{x:t,y:n,z:i,w:r}=e,a=180/Math.PI,s=Math.max(-1,Math.min(1,2*(r*t-n*i)));let o;o=Math.abs(s)>=1?Math.sign(s)*Math.PI/2:Math.asin(s);const l=2*(r*n+t*i),c=1-2*(t*t+n*n),u=2*(r*i+t*n),d=1-2*(t*t+i*i);return{pitch:o*a,yaw:Math.atan2(l,c)*a,roll:Math.atan2(u,d)*a}}function nb(e){var t,n,i;const r=Math.PI/180,a=(null!==(t=e.pitch)&&void 0!==t?t:0)*r,s=(null!==(n=e.yaw)&&void 0!==n?n:0)*r,o=(null!==(i=e.roll)&&void 0!==i?i:0)*r,l=Math.cos(.5*a),c=Math.sin(.5*a),u=Math.cos(.5*s),d=Math.sin(.5*s),h=Math.cos(.5*o),f=Math.sin(.5*o);return{w:l*u*h+c*d*f,x:c*u*h+l*d*f,y:l*d*h-c*u*f,z:l*u*f-c*d*h}}function ib(e){return function(e){return"pitch"in e||"yaw"in e||"roll"in e}(e)?nb(e):e}function rb(e,t,n){return e+(t-e)*n}class ab{constructor(e){this.commandQueue=[],this._isCaptured=!1,this.releaseTimer=null,this.actionIdCounter=0,this.RELEASE_TIMEOUT_MS=3e4,this.device=e}generateActionId(){return"action_"+ ++this.actionIdCounter}get isCaptured(){return this._isCaptured}get queueLength(){return this.commandQueue.length}enqueueDiscrete(e,t){return new Promise((n,i)=>{const r={type:"discrete",id:this.generateActionId(),method:e,params:t,resolve:n,reject:i};this.commandQueue.push(r)})}enqueueDuration(e,t,n,i,r){return new Promise((a,s)=>{const o={type:"duration",id:this.generateActionId(),method:e,params:t,durationMs:n,elapsedMs:0,startState:i,targetState:r,resolve:a,reject:s};this.commandQueue.push(o)})}update(e){if(0!==this.commandQueue.length){for(this.cancelReleaseTimer(),this._isCaptured||(this._isCaptured=!0,this.device.controlMode="programmatic");this.commandQueue.length>0;){const t=this.commandQueue[0];if("discrete"===t.type){try{const e=this.executeDiscreteAction(t);t.resolve(e)}catch(e){t.reject(e)}this.commandQueue.shift()}else{if(t.elapsedMs+=e,!(t.elapsedMs>=t.durationMs)){const e=t.elapsedMs/t.durationMs;this.applyDurationLerpState(t,e);break}this.applyDurationFinalState(t),t.resolve(this.getDurationResult(t)),this.commandQueue.shift()}}this.device.notifyStateChange(),0===this.commandQueue.length&&this.startReleaseTimer()}}startReleaseTimer(){this.cancelReleaseTimer(),this.releaseTimer=setTimeout(()=>{this._isCaptured=!1,this.device.controlMode="manual",this.releaseTimer=null},this.RELEASE_TIMEOUT_MS)}cancelReleaseTimer(){null!==this.releaseTimer&&(clearTimeout(this.releaseTimer),this.releaseTimer=null)}getDeviceTransform(e){switch(e){case"headset":return{position:J_(this.device.position),orientation:eb(this.device.quaternion)};case"controller-left":{const e=this.device.controllers.left;if(!e)throw new Error("Left controller not available");return{position:J_(e.position),orientation:eb(e.quaternion)}}case"controller-right":{const e=this.device.controllers.right;if(!e)throw new Error("Right controller not available");return{position:J_(e.position),orientation:eb(e.quaternion)}}case"hand-left":{const e=this.device.hands.left;if(!e)throw new Error("Left hand not available");return{position:J_(e.position),orientation:eb(e.quaternion)}}case"hand-right":{const e=this.device.hands.right;if(!e)throw new Error("Right hand not available");return{position:J_(e.position),orientation:eb(e.quaternion)}}default:throw new Error(`Unknown device: ${e}`)}}setDeviceTransform(e,t,n){switch(e){case"headset":t&&this.device.position.set(t.x,t.y,t.z),n&&this.device.quaternion.set(n.x,n.y,n.z,n.w);break;case"controller-left":{const e=this.device.controllers.left;if(!e)throw new Error("Left controller not available");t&&e.position.set(t.x,t.y,t.z),n&&e.quaternion.set(n.x,n.y,n.z,n.w);break}case"controller-right":{const e=this.device.controllers.right;if(!e)throw new Error("Right controller not available");t&&e.position.set(t.x,t.y,t.z),n&&e.quaternion.set(n.x,n.y,n.z,n.w);break}case"hand-left":{const e=this.device.hands.left;if(!e)throw new Error("Left hand not available");t&&e.position.set(t.x,t.y,t.z),n&&e.quaternion.set(n.x,n.y,n.z,n.w);break}case"hand-right":{const e=this.device.hands.right;if(!e)throw new Error("Right hand not available");t&&e.position.set(t.x,t.y,t.z),n&&e.quaternion.set(n.x,n.y,n.z,n.w);break}default:throw new Error(`Unknown device: ${e}`)}}transformXROriginToGlobal(e){var t,n;const i=this.device.activeSession;if(!i)return e;const r=null===(t=i[B_])||void 0===t?void 0:t.referenceSpaces;if(!r||0===r.length)return e;const a=null===(n=r[0][G_])||void 0===n?void 0:n.offsetMatrix;if(!a)return e;const s=r_(e.x,e.y,e.z);return function(e,t,n){var i=t[0],r=t[1],a=t[2],s=n[3]*i+n[7]*r+n[11]*a+n[15];s=s||1,e[0]=(n[0]*i+n[4]*r+n[8]*a+n[12])/s,e[1]=(n[1]*i+n[5]*r+n[9]*a+n[13])/s,e[2]=(n[2]*i+n[6]*r+n[10]*a+n[14])/s}(s,s,a),{x:s[0],y:s[1],z:s[2]}}getDeviceSelectValue(e){var t,n,i,r,a,s,o,l;switch(e){case"controller-left":return null!==(n=null===(t=this.device.controllers.left)||void 0===t?void 0:t.getButtonValue("trigger"))&&void 0!==n?n:0;case"controller-right":return null!==(r=null===(i=this.device.controllers.right)||void 0===i?void 0:i.getButtonValue("trigger"))&&void 0!==r?r:0;case"hand-left":return null!==(s=null===(a=this.device.hands.left)||void 0===a?void 0:a.pinchValue)&&void 0!==s?s:0;case"hand-right":return null!==(l=null===(o=this.device.hands.right)||void 0===o?void 0:o.pinchValue)&&void 0!==l?l:0;default:throw new Error(`Unknown input device: ${e}`)}}setDeviceSelectValue(e,t){var n,i,r,a;switch(e){case"controller-left":null===(n=this.device.controllers.left)||void 0===n||n.updateButtonValue("trigger",t);break;case"controller-right":null===(i=this.device.controllers.right)||void 0===i||i.updateButtonValue("trigger",t);break;case"hand-left":null===(r=this.device.hands.left)||void 0===r||r.updatePinchValue(t);break;case"hand-right":null===(a=this.device.hands.right)||void 0===a||a.updatePinchValue(t);break;default:throw new Error(`Unknown input device: ${e}`)}}setDeviceConnected(e,t){switch(e){case"controller-left":this.device.controllers.left&&(this.device.controllers.left.connected=t);break;case"controller-right":this.device.controllers.right&&(this.device.controllers.right.connected=t);break;case"hand-left":this.device.hands.left&&(this.device.hands.left.connected=t);break;case"hand-right":this.device.hands.right&&(this.device.hands.right.connected=t);break;default:throw new Error(`Unknown input device: ${e}`)}}executeDiscreteAction(e){const{method:t,params:n}=e;switch(t){case"get_session_status":return this.executeGetSessionStatus();case"accept_session":return this.executeAcceptSession();case"end_session":return this.executeEndSession();case"get_transform":return this.executeGetTransform(n);case"set_transform":return this.executeSetTransform(n);case"look_at":return this.executeLookAt(n);case"set_input_mode":return this.executeSetInputMode(n);case"set_connected":return this.executeSetConnected(n);case"get_select_value":return this.executeGetSelectValue(n);case"set_select_value":return this.executeSetSelectValue(n);case"get_gamepad_state":return this.executeGetGamepadState(n);case"set_gamepad_state":return this.executeSetGamepadState(n);case"get_device_state":return this.executeGetDeviceState();case"set_device_state":return this.executeSetDeviceState(n);case"capture_canvas":return this.executeCaptureCanvas(n);case"_select_press":{const e=n.device;return void this.setDeviceSelectValue(e,1)}case"_select_release":{const e=n.device;return void this.setDeviceSelectValue(e,0)}default:throw new Error(`Unknown method: ${t}`)}}executeGetSessionStatus(){const e=this.device.activeSession;return{deviceName:this.device.name,isRuntimeInstalled:!0,sessionActive:!!e,sessionOffered:this.device.sessionOffered,sessionMode:e?e.mode:null,enabledFeatures:e?Array.from(e.enabledFeatures||[]):[],visibilityState:this.device.visibilityState}}executeAcceptSession(){if(!this.device.sessionOffered)throw new Error("No session has been offered");return this.device.grantOfferedSession(),{success:!0}}executeEndSession(){const e=this.device.activeSession;if(!e)throw new Error("No active session");return e.end(),{success:!0}}executeGetTransform(e){const{device:t}=e,n=this.getDeviceTransform(t);return{device:t,position:n.position,orientation:n.orientation,euler:tb(n.orientation)}}executeSetTransform(e){const{device:t,position:n,orientation:i}=e,r=i?ib(i):void 0;this.setDeviceTransform(t,n,r);const a=this.getDeviceTransform(t);return{device:t,position:a.position,orientation:a.orientation}}executeLookAt(e){const{device:t,target:n,moveToDistance:i}=e,r=this.getDeviceTransform(t),a=this.transformXROriginToGlobal(n),s=function(e,t){const n=t.x-e.x,i=t.y-e.y,r=t.z-e.z,a=Math.sqrt(n*n+i*i+r*r);return 0===a?{x:0,y:0,z:-1}:{x:n/a,y:i/a,z:r/a}}(r.position,a),o="headset"===t?function(e){const t=Math.sqrt(e.x*e.x+e.z*e.z);let n=0;t>1e-4&&(n=Math.atan2(-e.x,-e.z));const i=Math.atan2(e.y,t),r=180/Math.PI;return nb({pitch:i*r,yaw:n*r,roll:0})}(s):function(e,t={x:0,y:1,z:0}){const n=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);if(0===n)return{x:0,y:0,z:0,w:1};const i=e.x/n,r=e.y/n,a=e.z/n,s={x:r*t.z-a*t.y,y:a*t.x-i*t.z,z:i*t.y-r*t.x},o=Math.sqrt(s.x*s.x+s.y*s.y+s.z*s.z);if(0===o){const e={x:1,y:0,z:0};s.x=r*e.z-a*e.y,s.y=a*e.x-i*e.z,s.z=i*e.y-r*e.x;const t=Math.sqrt(s.x*s.x+s.y*s.y+s.z*s.z);s.x/=t,s.y/=t,s.z/=t}else s.x/=o,s.y/=o,s.z/=o;const l={x:s.y*a-s.z*r,y:s.z*i-s.x*a,z:s.x*r-s.y*i},c=s.x,u=l.x,d=-i,h=s.y,f=l.y,p=-r,m=s.z,g=l.z,v=-a,y=c+f+v;let x,_,b,w;if(y>0){const e=.5/Math.sqrt(y+1);x=.25/e,_=(g-p)*e,b=(d-m)*e,w=(h-u)*e}else if(c>f&&c>v){const e=2*Math.sqrt(1+c-f-v);x=(g-p)/e,_=.25*e,b=(u+h)/e,w=(d+m)/e}else if(f>v){const e=2*Math.sqrt(1+f-c-v);x=(d-m)/e,_=(u+h)/e,b=.25*e,w=(p+g)/e}else{const e=2*Math.sqrt(1+v-c-f);x=(h-u)/e,_=(d+m)/e,b=(p+g)/e,w=.25*e}const S=Math.sqrt(_*_+b*b+w*w+x*x);return S>0&&(_/=S,b/=S,w/=S,x/=S),{x:_,y:b,z:w,w:x}}(s);let l;void 0!==i&&(l={x:a.x-s.x*i,y:a.y-s.y*i,z:a.z-s.z*i}),this.setDeviceTransform(t,l,o);const c=this.getDeviceTransform(t);return{device:t,position:c.position,orientation:c.orientation}}executeSetInputMode(e){var t,n,i,r;const{mode:a}=e;this.device.primaryInputMode=a;const s=[];return"controller"===a?((null===(t=this.device.controllers.left)||void 0===t?void 0:t.connected)&&s.push("controller-left"),(null===(n=this.device.controllers.right)||void 0===n?void 0:n.connected)&&s.push("controller-right")):((null===(i=this.device.hands.left)||void 0===i?void 0:i.connected)&&s.push("hand-left"),(null===(r=this.device.hands.right)||void 0===r?void 0:r.connected)&&s.push("hand-right")),{mode:a,activeDevices:s}}executeSetConnected(e){const{device:t,connected:n}=e;return this.setDeviceConnected(t,n),{device:t,connected:n}}executeGetSelectValue(e){const{device:t}=e;return{device:t,value:this.getDeviceSelectValue(t)}}executeSetSelectValue(e){const{device:t,value:n}=e;return this.setDeviceSelectValue(t,n),{device:t,value:n}}executeGetGamepadState(e){const{device:t}=e,n="controller-left"===t?"left":"right",i=this.device.controllers[n];if(!i)throw new Error(`Controller ${n} not available`);const r=["trigger","squeeze","thumbstick","left"===n?"x-button":"a-button","left"===n?"y-button":"b-button","thumbrest"].map((e,t)=>({index:t,name:e.replace("x-button","x").replace("y-button","y").replace("a-button","a").replace("b-button","b"),value:i.getButtonValue(e),touched:i.getButtonTouched(e),pressed:i.getButtonValue(e)>.5})),a=i.getAxes(),s=[{index:0,name:"thumbstick-x",value:a.x},{index:1,name:"thumbstick-y",value:a.y}];return{device:t,connected:i.connected,buttons:r,axes:s}}executeSetGamepadState(e){const{device:t,buttons:n,axes:i}=e,r="controller-left"===t?"left":"right",a=this.device.controllers[r];if(!a)throw new Error(`Controller ${r} not available`);let s=0,o=0;const l=["trigger","squeeze","thumbstick","left"===r?"x-button":"a-button","left"===r?"y-button":"b-button","thumbrest"];if(n)for(const e of n){const t=l[e.index];t&&(a.updateButtonValue(t,e.value),void 0!==e.touched&&a.updateButtonTouch(t,e.touched),s++)}if(i){let e,t;for(const n of i)0===n.index?(e=n.value,o++):1===n.index&&(t=n.value,o++);if(void 0!==e||void 0!==t){const n=a.getAxes();a.updateAxes("thumbstick",null!=e?e:n.x,null!=t?t:n.y)}}return{device:t,buttonsSet:s,axesSet:o}}executeGetDeviceState(){var e,t,n,i,r,a,s,o,l,c,u,d,h,f,p,m,g,v,y,x,_,b,w,S;return{headset:{position:J_(this.device.position),orientation:eb(this.device.quaternion)},inputMode:this.device.primaryInputMode,controllers:{left:{connected:null!==(t=null===(e=this.device.controllers.left)||void 0===e?void 0:e.connected)&&void 0!==t&&t,position:J_(null!==(i=null===(n=this.device.controllers.left)||void 0===n?void 0:n.position)&&void 0!==i?i:{x:0,y:0,z:0}),orientation:eb(null!==(a=null===(r=this.device.controllers.left)||void 0===r?void 0:r.quaternion)&&void 0!==a?a:{x:0,y:0,z:0,w:1})},right:{connected:null!==(o=null===(s=this.device.controllers.right)||void 0===s?void 0:s.connected)&&void 0!==o&&o,position:J_(null!==(c=null===(l=this.device.controllers.right)||void 0===l?void 0:l.position)&&void 0!==c?c:{x:0,y:0,z:0}),orientation:eb(null!==(d=null===(u=this.device.controllers.right)||void 0===u?void 0:u.quaternion)&&void 0!==d?d:{x:0,y:0,z:0,w:1})}},hands:{left:{connected:null!==(f=null===(h=this.device.hands.left)||void 0===h?void 0:h.connected)&&void 0!==f&&f,position:J_(null!==(m=null===(p=this.device.hands.left)||void 0===p?void 0:p.position)&&void 0!==m?m:{x:0,y:0,z:0}),orientation:eb(null!==(v=null===(g=this.device.hands.left)||void 0===g?void 0:g.quaternion)&&void 0!==v?v:{x:0,y:0,z:0,w:1})},right:{connected:null!==(x=null===(y=this.device.hands.right)||void 0===y?void 0:y.connected)&&void 0!==x&&x,position:J_(null!==(b=null===(_=this.device.hands.right)||void 0===_?void 0:_.position)&&void 0!==b?b:{x:0,y:0,z:0}),orientation:eb(null!==(S=null===(w=this.device.hands.right)||void 0===w?void 0:w.quaternion)&&void 0!==S?S:{x:0,y:0,z:0,w:1})}},stereoEnabled:this.device.stereoEnabled,fov:this.device.fovy*(180/Math.PI)}}executeSetDeviceState(e){const{state:t}=e;return t?(t.headset&&(t.headset.position&&this.device.position.set(t.headset.position.x,t.headset.position.y,t.headset.position.z),t.headset.orientation&&this.device.quaternion.set(t.headset.orientation.x,t.headset.orientation.y,t.headset.orientation.z,t.headset.orientation.w)),void 0!==t.inputMode&&(this.device.primaryInputMode=t.inputMode),void 0!==t.stereoEnabled&&(this.device.stereoEnabled=t.stereoEnabled),void 0!==t.fov&&(this.device.fovy=t.fov*(Math.PI/180)),t.controllers&&(this.applyInputState("controller-left",t.controllers.left),this.applyInputState("controller-right",t.controllers.right)),t.hands&&(this.applyInputState("hand-left",t.hands.left),this.applyInputState("hand-right",t.hands.right))):(this.device.position.set(0,1.6,0),this.device.quaternion.set(0,0,0,1),this.device.primaryInputMode="controller",this.device.stereoEnabled=!1,this.device.controllers.left&&(this.device.controllers.left.position.set(-.2,1.4,-.3),this.device.controllers.left.quaternion.set(0,0,0,1),this.device.controllers.left.connected=!0),this.device.controllers.right&&(this.device.controllers.right.position.set(.2,1.4,-.3),this.device.controllers.right.quaternion.set(0,0,0,1),this.device.controllers.right.connected=!0),this.device.hands.left&&(this.device.hands.left.position.set(-.15,1.3,-.4),this.device.hands.left.quaternion.set(0,0,0,1),this.device.hands.left.connected=!0),this.device.hands.right&&(this.device.hands.right.position.set(.15,1.3,-.4),this.device.hands.right.quaternion.set(0,0,0,1),this.device.hands.right.connected=!0)),{state:this.executeGetDeviceState()}}applyInputState(e,t){t&&(void 0!==t.connected&&this.setDeviceConnected(e,t.connected),(t.position||t.orientation)&&this.setDeviceTransform(e,t.position,t.orientation))}executeCaptureCanvas(e){const{maxWidth:t=800,format:n="png",quality:i=.92}=e;let r=this.device.appCanvas;if(!r){const e=document.querySelectorAll("canvas");if(1===e.length)r=e[0];else if(e.length>1){let t=null,n=0;e.forEach(e=>{const i=e.getBoundingClientRect(),r=i.width*i.height;r>n&&i.width>0&&i.height>0&&(n=r,t=e)}),r=t}}if(!r)throw new Error("No canvas available. Either start an XR session or ensure an app canvas is in the DOM.");const a=document.createElement("canvas"),s=a.getContext("2d");if(!s)throw new Error("Failed to create canvas context");const o=r.height/r.width,l=Math.min(r.width,t),c=Math.round(l*o);a.width=l,a.height=c,s.drawImage(r,0,0,l,c);const u=`image/${n}`;return{imageData:a.toDataURL(u,i).split(",")[1],width:l,height:c,format:n,timestamp:Date.now()}}applyDurationLerpState(e,t){const{startState:n,targetState:i,params:r}=e,a=r.device;let s,o;n.position&&i.position&&(s=function(e,t,n){return{x:rb(e.x,t.x,n),y:rb(e.y,t.y,n),z:rb(e.z,t.z,n)}}(n.position,i.position,t)),n.orientation&&i.orientation&&(o=function(e,t,n){let i=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,r=t.x,a=t.y,s=t.z,o=t.w;if(i<0&&(i=-i,r=-r,a=-a,s=-s,o=-o),i>.9995){const t={x:rb(e.x,r,n),y:rb(e.y,a,n),z:rb(e.z,s,n),w:rb(e.w,o,n)},i=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w);return{x:t.x/i,y:t.y/i,z:t.z/i,w:t.w/i}}const l=Math.acos(i),c=l*n,u=Math.sin(c),d=Math.sin(l),h=Math.cos(c)-i*u/d,f=u/d;return{x:h*e.x+f*r,y:h*e.y+f*a,z:h*e.z+f*s,w:h*e.w+f*o}}(n.orientation,i.orientation,t)),this.setDeviceTransform(a,s,o)}applyDurationFinalState(e){const{targetState:t,params:n}=e,i=n.device;this.setDeviceTransform(i,t.position,t.orientation)}getDurationResult(e){const{params:t,elapsedMs:n}=e,i=t.device,r=this.getDeviceTransform(i);return{device:i,position:r.position,orientation:r.orientation,actualDuration:n/1e3}}activateCaptureMode(){this._isCaptured||(this._isCaptured=!0,this.cancelReleaseTimer(),this.device.controlMode="programmatic"),this.startReleaseTimer()}async dispatch(e,t={}){var n;if(ab.IMMEDIATE_METHODS.has(e))return ab.ACTIVE_IMMEDIATE_METHODS.has(e)&&this.activateCaptureMode(),this.executeImmediateMethod(e,t);if(ab.SESSION_REQUIRED_METHODS.has(e)&&!this.device.activeSession)throw new Error(`Cannot execute '${e}': No active XR session. Use 'get_session_status' to check session state, and 'accept_session' to start a session.`);if("animate_to"===e){const i=t,r=this.getDeviceTransform(i.device),a=1e3*(null!==(n=i.duration)&&void 0!==n?n:.5),s=i.orientation?ib(i.orientation):void 0,o=i.position?this.transformXROriginToGlobal(i.position):void 0;return this.enqueueDuration(e,t,a,{position:i.position?r.position:void 0,orientation:s?r.orientation:void 0},{position:o,orientation:s})}if("select"===e){const e=t;return this.executeSelectSequence(e)}return this.enqueueDiscrete(e,t)}executeImmediateMethod(e,t){switch(e){case"get_session_status":return this.executeGetSessionStatus();case"accept_session":return this.executeAcceptSession();case"end_session":return this.executeEndSession();case"get_transform":return this.executeGetTransform(t);case"get_select_value":return this.executeGetSelectValue(t);case"get_gamepad_state":return this.executeGetGamepadState(t);case"get_device_state":return this.executeGetDeviceState();case"capture_canvas":return this.executeCaptureCanvas(t);default:throw new Error(`Unknown immediate method: ${e}`)}}executeSelectSequence(e){const{device:t,duration:n=.15}=e;return new Promise((e,i)=>{let r=0;const a=()=>{r++,3===r&&e({device:t,duration:n})},s={type:"discrete",id:this.generateActionId(),method:"_select_press",params:{device:t},resolve:a,reject:i},o={type:"duration",id:this.generateActionId(),method:"_select_wait",params:{device:t},durationMs:1e3*n,elapsedMs:0,startState:{},targetState:{},resolve:a,reject:i},l={type:"discrete",id:this.generateActionId(),method:"_select_release",params:{device:t},resolve:a,reject:i};this.commandQueue.push(s,o,l)})}async acceptSession(){if(!this.device.sessionOffered)throw new Error("No session has been offered");return this.device.grantOfferedSession(),await function(e,t=5e3){return new Promise((n,i)=>{const r=Date.now(),a=()=>{e()?n():Date.now()-r>t?i(new Error("Timeout waiting for condition")):requestAnimationFrame(a)};a()})}(()=>!!this.device.activeSession,5e3),{success:!0}}forceRelease(){this.cancelReleaseTimer(),this._isCaptured=!1,this.device.controlMode="manual";for(const e of this.commandQueue)e.reject(new Error("Capture released"));this.commandQueue=[];for(const e of["left","right"]){const t=this.device.controllers[e];t&&(t.updateButtonValue("trigger",0),t.updateButtonValue("squeeze",0))}}}var sb,ob,lb;ab.IMMEDIATE_METHODS=new Set(["get_session_status","accept_session","end_session","get_transform","get_select_value","get_gamepad_state","get_device_state","capture_canvas"]),ab.ACTIVE_IMMEDIATE_METHODS=new Set(["accept_session","end_session"]),ab.SESSION_REQUIRED_METHODS=new Set(["set_transform","look_at","animate_to","set_input_mode","set_connected","set_select_value","select","set_gamepad_state","set_device_state"]),function(e){e.None="",e.Standard="standard",e.XRStandard="xr-standard"}(sb||(sb={}));class cb{constructor(e,t){this[C_]={type:e,eventTrigger:t,pressed:!1,touched:!1,value:0,lastFrameValue:0,pendingValue:null}}get pressed(){return"manual"===this[C_].type?this[C_].pressed:this[C_].value>0}get touched(){return"manual"===this[C_].type?this[C_].touched:this[C_].touched||this.pressed}get value(){return this[C_].value}}class ub{constructor(){this.pressed=!1,this.touched=!1,this.value=0}}class db{constructor(e,t="",n=-1){this[C_]={id:t,index:n,connected:!1,timestamp:performance.now(),mapping:e.mapping,buttonsMap:{},buttonsSequence:[],axesMap:{},axesSequence:[],hapticActuators:[]},e.buttons.forEach(e=>{var t;null===e?this[C_].buttonsSequence.push(null):(this[C_].buttonsSequence.push(e.id),this[C_].buttonsMap[e.id]=new cb(e.type,null!==(t=e.eventTrigger)&&void 0!==t?t:null))}),e.axes.forEach(e=>{null===e?this[C_].axesSequence.push(null):(this[C_].axesSequence.push(e.id+e.type),this[C_].axesMap[e.id]||(this[C_].axesMap[e.id]={x:0,y:0}))})}get id(){return this[C_].id}get index(){return this[C_].index}get connected(){return this[C_].connected}get timestamp(){return this[C_].timestamp}get mapping(){return this[C_].mapping}get axes(){const e=[];return this[C_].axesSequence.forEach(t=>{if(null===t)e.push(null);else{const n=t.substring(0,t.length-6),i=t.substring(t.length-6);e.push("y-axis"===i?this[C_].axesMap[n].y:this[C_].axesMap[n].x)}}),e}get buttons(){return this[C_].buttonsSequence.map(e=>null===e?new ub:this[C_].buttonsMap[e])}get hapticActuators(){return this[C_].hapticActuators}get vibrationActuator(){return null}}!function(e){e.None="none",e.Left="left",e.Right="right"}(ob||(ob={})),function(e){e.Gaze="gaze",e.TrackedPointer="tracked-pointer",e.Screen="screen",e.TransientPointer="transient-pointer"}(lb||(lb={}));class hb extends Array{}class fb{constructor(e,t,n,i,r,a,s){this[L_]={handedness:e,targetRayMode:t,targetRaySpace:i,gripSpace:a,profiles:n,gamepad:r,hand:s}}get handedness(){return this[L_].handedness}get targetRayMode(){return this[L_].targetRayMode}get targetRaySpace(){return this[L_].targetRaySpace}get gripSpace(){return this[L_].gripSpace}get profiles(){return this[L_].profiles}get gamepad(){return this[L_].gamepad}get hand(){return this[L_].hand}}class pb extends Event{constructor(e,t){if(super(e,t),!t.frame)throw new Error("XRInputSourceEventInit.frame is required");if(!t.inputSource)throw new Error("XRInputSourceEventInit.inputSource is required");this.frame=t.frame,this.inputSource=t.inputSource}}const mb={[ob.Left]:{position:new Z_(-.25,1.5,-.4),quaternion:new Q_},[ob.Right]:{position:new Z_(.25,1.5,-.4),quaternion:new Q_},[ob.None]:{position:new Z_(.25,1.5,-.4),quaternion:new Q_}};class gb{constructor(e){this[A_]={inputSource:e,position:mb[e.handedness].position.clone(),quaternion:mb[e.handedness].quaternion.clone(),connected:!0,lastFrameConnected:!1,inputSourceChanged:!0}}get position(){return this[A_].position}get quaternion(){return this[A_].quaternion}get inputSource(){return this[A_].inputSource}get connected(){return this[A_].connected}set connected(e){this[A_].connected=e,this[A_].inputSource.gamepad[C_].connected=e}onFrameStart(e){Qx(this[A_].inputSource.targetRaySpace[G_].offsetMatrix,this[A_].quaternion.quat,this[A_].position.vec3);const t=e.session;this[A_].inputSource.gamepad.buttons.forEach(n=>{n instanceof cb&&(n[C_].lastFrameValue=n[C_].value,null!=n[C_].pendingValue&&(n[C_].value=n[C_].pendingValue,n[C_].pendingValue=null),null!=n[C_].eventTrigger&&(0===n[C_].lastFrameValue&&n[C_].value>0?(t.dispatchEvent(new pb(n[C_].eventTrigger,{frame:e,inputSource:this[A_].inputSource})),t.dispatchEvent(new pb(n[C_].eventTrigger+"start",{frame:e,inputSource:this[A_].inputSource}))):n[C_].lastFrameValue>0&&0===n[C_].value&&t.dispatchEvent(new pb(n[C_].eventTrigger+"end",{frame:e,inputSource:this[A_].inputSource}))))}),this[A_].inputSourceChanged=this.connected!==this[A_].lastFrameConnected,this[A_].lastFrameConnected=this.connected}}class vb extends gb{constructor(e,t,n){if(!e.layout[t])throw new DOMException("Handedness not supported","InvalidStateError");const i=new $_(n),r=e.layout[t].gripOffsetMatrix?new $_(i,e.layout[t].gripOffsetMatrix):void 0,a=[e.profileId,...e.fallbackProfileIds];super(new fb(t,lb.TrackedPointer,a,i,new db(e.layout[t].gamepad),r)),this[M_]={profileId:e.profileId,gamepadConfig:e.layout[t].gamepad}}get gamepadConfig(){return this[M_].gamepadConfig}get profileId(){return this[M_].profileId}updateButtonValue(e,t){if(t>1||t<0)return void console.warn(`Out-of-range value ${t} provided for button ${e}.`);const n=this[A_].inputSource.gamepad[C_].buttonsMap[e];if(n){if("binary"===n[C_].type&&1!=t&&0!=t)return void console.warn(`Non-binary value ${t} provided for binary button ${e}.`);n[C_].pendingValue=t}else console.warn(`Current controller does not have button ${e}.`)}setButtonValueImmediate(e,t){if(t>1||t<0)return void console.warn(`Out-of-range value ${t} provided for button ${e}.`);const n=this[A_].inputSource.gamepad[C_].buttonsMap[e];if(n){if("binary"===n[C_].type&&1!=t&&0!=t)return void console.warn(`Non-binary value ${t} provided for binary button ${e}.`);n[C_].value=t,n[C_].pendingValue=t}else console.warn(`Current controller does not have button ${e}.`)}updateButtonTouch(e,t){const n=this[A_].inputSource.gamepad[C_].buttonsMap[e];n?n[C_].touched=t:console.warn(`Current controller does not have button ${e}.`)}updateAxis(e,t,n){if(n>1||n<-1)return void console.warn(`Out-of-range value ${n} provided for ${e} axes.`);const i=this[A_].inputSource.gamepad[C_].axesMap[e];i?"x-axis"===t?i.x=n:"y-axis"===t&&(i.y=n):console.warn(`Current controller does not have ${e} axes.`)}updateAxes(e,t,n){if(t>1||t<-1||n>1||n<-1)return void console.warn(`Out-of-range value x:${t}, y:${n} provided for ${e} axes.`);const i=this[A_].inputSource.gamepad[C_].axesMap[e];i?(i.x=t,i.y=n):console.warn(`Current controller does not have ${e} axes.`)}getButtonValue(e){var t;const n=this[A_].inputSource.gamepad[C_].buttonsMap[e];return n?null!==(t=n[C_].pendingValue)&&void 0!==t?t:n.value:0}getButtonTouched(e){const t=this[A_].inputSource.gamepad[C_].buttonsMap[e];return!!t&&t.touched}getAxes(e="thumbstick"){const t=this[A_].inputSource.gamepad[C_].axesMap[e];return t?{x:t.x,y:t.y}:{x:0,y:0}}}class yb{constructor(e,t,n,i,r){this[D_]={nativeMesh:e,frame:void 0,meshSpace:t,vertices:n,indices:i,lastChangedTime:performance.now(),semanticLabel:r}}get meshSpace(){return this[D_].meshSpace}get vertices(){return this[D_].vertices}get indices(){return this[D_].indices}get lastChangedTime(){return this[D_].lastChangedTime}get semanticLabel(){return this[D_].semanticLabel}}class xb extends Set{}class _b{constructor(e,t,n,i){this.transform=e,this.vertices=t,this.indices=n,this.semanticLabel=i}}var bb,wb;!function(e){e.Desk="desk",e.Couch="couch",e.Floor="floor",e.Ceiling="ceiling",e.Wall="wall",e.Door="door",e.Window="window",e.Table="table",e.Shelf="shelf",e.Bed="bed",e.Screen="screen",e.Lamp="lamp",e.Plant="plant",e.WallArt="wall art",e.GlobalMesh="global mesh",e.Other="other"}(bb||(bb={})),function(e){e.Horizontal="horizontal",e.Vertical="vertical"}(wb||(wb={}));const Sb={[bb.Desk]:wb.Horizontal,[bb.Couch]:wb.Horizontal,[bb.Floor]:wb.Horizontal,[bb.Ceiling]:wb.Horizontal,[bb.Wall]:wb.Vertical,[bb.Door]:wb.Vertical,[bb.Window]:wb.Vertical,[bb.Table]:wb.Horizontal,[bb.Shelf]:wb.Horizontal,[bb.Bed]:wb.Horizontal,[bb.Screen]:wb.Horizontal,[bb.Lamp]:wb.Horizontal,[bb.Plant]:wb.Horizontal,[bb.WallArt]:wb.Vertical};class Mb{constructor(e,t,n,i){this[N_]={nativePlane:e,frame:void 0,planeSpace:t,polygon:n,lastChangedTime:performance.now(),semanticLabel:i,orientation:i?Sb[i]:void 0}}get planeSpace(){return this[N_].planeSpace}get polygon(){return this[N_].polygon}get orientation(){return this[N_].orientation}get lastChangedTime(){return this[N_].lastChangedTime}get semanticLabel(){return this[N_].semanticLabel}}class Eb extends Set{}class Tb{constructor(e,t,n){this.transform=e,this.polygon=t,this.semanticLabel=n}}class Ab{constructor(e,t){this[S_]={anchorSpace:e,session:t,deleted:!1},t[B_].trackedAnchors.add(this)}get anchorSpace(){if(this[S_].deleted)throw new DOMException("XRAnchor has already been deleted.","InvalidStateError");return this[S_].anchorSpace}requestPersistentHandle(){return new Promise((e,t)=>{if(this[S_].deleted)t(new DOMException("XRAnchor has already been deleted.","InvalidStateError"));else{const t=this[S_].session[B_].persistentAnchors;for(const[n,i]of t.entries())if(i===this)return void e(n);const n=crypto.randomUUID();Pb.createPersistentAnchor(this[S_].session,this,n),e(n)}})}delete(){this[S_].deleted||(this[S_].anchorSpace=null,this[S_].deleted=!0,this[S_].session[B_].trackedAnchors.delete(this))}}class Rb extends Set{}const Cb="@immersive-web-emulation-runtime/persistent-anchors";class Pb{static recoverPersistentAnchorsFromStorage(e){const t=JSON.parse(localStorage.getItem(Cb)||"{}");Object.entries(t).forEach(([t,n])=>{const i=e[B_].device[E_].globalSpace,r=new $_(i,n),a=new Ab(r,e);e[B_].persistentAnchors.set(t,a)})}static createPersistentAnchor(e,t,n){e[B_].trackedAnchors.add(t),e[B_].persistentAnchors.set(n,t);const i=JSON.parse(localStorage.getItem(Cb)||"{}");i[n]=Array.from(t[S_].anchorSpace[G_].offsetMatrix),localStorage.setItem(Cb,JSON.stringify(i))}}class Lb{constructor(e,t){const n=r_(0,0,0),i=p_();this[F_]={matrix:Wx(),position:e?r_(e.x,e.y,e.z):n,orientation:t?b_(p_(),y_(t.x,t.y,t.z,t.w)):i,inverse:null},this.updateMatrix()}updateMatrix(){Qx(this[F_].matrix,this[F_].orientation,this[F_].position)}get matrix(){return this[F_].matrix}get position(){const e=this[F_].position;return new DOMPointReadOnly(e[0],e[1],e[2],1)}get orientation(){const e=this[F_].orientation;return new DOMPointReadOnly(e[0],e[1],e[2],e[3])}get inverse(){if(!this[F_].inverse){const e=Wx();if(!$x(e,this[F_].matrix))throw new Error("Matrix is not invertible.");let t=i_();Jx(t,e);let n=p_();t_(n,e),this[F_].inverse=new Lb(new DOMPointReadOnly(t[0],t[1],t[2],1),new DOMPointReadOnly(n[0],n[1],n[2],n[3])),this[F_].inverse[F_].inverse=this}return this[F_].inverse}}let Ib=class{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}};class Db{constructor(e,t){const n={x:0,y:0,z:0,w:1},i={x:0,y:0,z:-1,w:0};if(e instanceof Lb){const t=e.matrix,r=h_(d_(),n.x,n.y,n.z,n.w),a=h_(d_(),i.x,i.y,i.z,i.w);f_(r,r,t),f_(a,a,t),n.x=r[0],n.y=r[1],n.z=r[2],n.w=r[3],i.x=a[0],i.y=a[1],i.z=a[2],i.w=a[3]}else if(e&&(n.x=e.x,n.y=e.y,n.z=e.z,n.w=e.w),t){if(0===t.x&&0===t.y&&0===t.z||0!==t.w)throw new DOMException("Invalid direction value to construct XRRay","TypeError");i.x=t.x,i.y=t.y,i.z=t.z,i.w=t.w}const r=Math.sqrt(i.x*i.x+i.y*i.y+i.z*i.z)||1;i.x=i.x/r,i.y=i.y/r,i.z=i.z/r,this[X_]={origin:new Ib(n.x,n.y,n.z,n.w),direction:new Ib(i.x,i.y,i.z,i.w),matrix:null}}get origin(){return this[X_].origin}get direction(){return this[X_].direction}get matrix(){if(this[X_].matrix)return this[X_].matrix;const e=s_(i_(),0,0,-1),t=s_(i_(),this[X_].origin.x,this[X_].origin.y,this[X_].origin.z),n=s_(i_(),this[X_].direction.x,this[X_].direction.y,this[X_].direction.z),i=c_(i_(),n,e),r=l_(n,e),a=Wx();r>-1&&r<1?Zx(a,Math.acos(r),i):-1===r?Zx(a,Math.acos(r),s_(i_(),1,0,0)):function(e){e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(a);const s=Kx(Wx(),t),o=Yx(Wx(),s,a);return this[X_].matrix=new Float32Array(o),this[X_].matrix}}class Nb{constructor(e,t){var n;this[q_]={session:e,space:t.space,offsetRay:null!==(n=t.offsetRay)&&void 0!==n?n:new Db}}cancel(){this[q_].session[B_].hitTestSources.delete(this)}}class Ob{constructor(e,t){this[q_]={frame:e,offsetSpace:t}}getPose(e){return this[q_].frame.getPose(this[q_].offsetSpace,e)}createAnchor(){return this[q_].frame.createAnchor(new Lb,this[q_].offsetSpace)}}class kb extends Event{constructor(e,t){if(super(e,t),!t.session)throw new Error("XRInputSourcesChangeEventInit.session is required");if(!t.added)throw new Error("XRInputSourcesChangeEventInit.added is required");if(!t.removed)throw new Error("XRInputSourcesChangeEventInit.removed is required");this.session=t.session,this.added=t.added,this.removed=t.removed}}var Ub,Fb,zb;!function(e){e.Viewer="viewer",e.Local="local",e.LocalFloor="local-floor",e.BoundedFloor="bounded-floor",e.Unbounded="unbounded"}(Fb||(Fb={}));class Bb extends $_{constructor(e,t,n){super(t,n),this[Ub]={type:null,onreset:()=>{}},this[H_].type=e}get onreset(){var e;return null!==(e=this[H_].onreset)&&void 0!==e?e:()=>{}}set onreset(e){this[H_].onreset&&this.removeEventListener("reset",this[H_].onreset),this[H_].onreset=e,e&&this.addEventListener("reset",e)}getOffsetReferenceSpace(e){return new Bb(this[H_].type,this,e)}}Ub=H_;class Vb{constructor(e={},t){this[z_]={depthNear:e.depthNear||(null==t?void 0:t.depthNear)||.1,depthFar:e.depthFar||(null==t?void 0:t.depthFar)||1e3,inlineVerticalFieldOfView:e.inlineVerticalFieldOfView||(null==t?void 0:t.inlineVerticalFieldOfView)||null,baseLayer:e.baseLayer||(null==t?void 0:t.baseLayer)||null}}get depthNear(){return this[z_].depthNear}get depthFar(){return this[z_].depthFar}get inlineVerticalFieldOfView(){return this[z_].inlineVerticalFieldOfView}get baseLayer(){return this[z_].baseLayer}}class Hb extends Event{constructor(e,t){if(super(e,t),!t.session)throw new Error("XRSessionEventInit.session is required");this.session=t.session}}!function(e){e.None="none",e.Left="left",e.Right="right"}(zb||(zb={}));class Gb{constructor(e,t,n,i){this[j_]={eye:e,projectionMatrix:t,transform:n,recommendedViewportScale:null,requestedViewportScale:1,session:i}}get eye(){return this[j_].eye}get projectionMatrix(){return this[j_].projectionMatrix}get transform(){return this[j_].transform}get recommendedViewportScale(){return this[j_].recommendedViewportScale}requestViewportScale(e){null===e||e<=0||e>1?console.warn("Invalid scale value. Scale must be > 0 and <= 1."):this[j_].requestedViewportScale=e}}class jb{constructor(e,t=!1,n=void 0,i=void 0){this[k_]={transform:e,emulatedPosition:t,linearVelocity:n,angularVelocity:i}}get transform(){return this[k_].transform}get emulatedPosition(){return this[k_].emulatedPosition}get linearVelocity(){return this[k_].linearVelocity}get angularVelocity(){return this[k_].angularVelocity}}class Wb extends jb{constructor(e,t,n=!1,i=void 0,r=void 0){super(e,n,i,r),this[O_]={radius:t}}get radius(){return this[O_].radius}}class Xb extends jb{constructor(e,t,n=!1,i=void 0,r=void 0){super(e,n,i,r),this[U_]={views:Object.freeze(t)}}get views(){return this[U_].views}}const qb=Wx(),$b=Wx(),Yb=Wx(),Kb=(e,t,n)=>{K_.calculateGlobalOffsetMatrix(t,qb),K_.calculateGlobalOffsetMatrix(n,$b),$x(Yb,$b),Yx(e,Yb,qb)};class Zb{constructor(e,t,n,i,r){this[R_]={session:e,id:t,active:n,animationFrame:i,predictedDisplayTime:r,tempMat4:Wx(),detectedPlanes:new Eb,detectedMeshes:new xb,trackedAnchors:e[B_].frameTrackedAnchors,hitTestResultsMap:new Map}}get session(){return this[R_].session}get predictedDisplayTime(){return this[R_].predictedDisplayTime}getPose(e,t){if(!this[R_].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");Kb(this[R_].tempMat4,e,t);const n=i_();Jx(n,this[R_].tempMat4);const i=p_();return t_(i,this[R_].tempMat4),new jb(new Lb({x:n[0],y:n[1],z:n[2],w:1},{x:i[0],y:i[1],z:i[2],w:i[3]}),e[G_].emulated)}getViewerPose(e){if(!this[R_].animationFrame)throw new DOMException("getViewerPose can only be called on XRFrame objects passed to XRSession.requestAnimationFrame callbacks.","InvalidStateError");const t=this[R_].session,n=t[B_].device,i=this.getPose(n.viewerSpace,e),r="inline"===t[B_].mode?[zb.None]:[zb.Left,zb.Right],a=[];return r.forEach(i=>{const r=n.viewSpaces[i],s=this.getPose(r,e),o=t[B_].getProjectionMatrix(i),l=new Gb(i,new Float32Array(o),s.transform,t);a.push(l)}),new Xb(i.transform,a,!1)}getJointPose(e,t){const n=this.getPose(e,t),i=e[V_].radius;return new Wb(n.transform,i,!1)}fillJointRadii(e,t){if(e=Array.from(e),!this[R_].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");if(e.length>t.length)throw new DOMException("The length of jointSpaces is larger than the number of elements in radii","TypeError");let n=!0;for(let i=0;i<e.length;i++)e[i][V_].radius?t[i]=e[i][V_].radius:(t[i]=NaN,n=!1);return n}fillPoses(e,t,n){if(e=Array.from(e),!this[R_].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");if(16*e.length>n.length)throw new DOMException("The length of spaces multiplied by 16 is larger than the number of elements in transforms","TypeError");return e.forEach((e,i)=>{Kb(this[R_].tempMat4,e,t);for(let e=0;e<16;e++)n[16*i+e]=this[R_].tempMat4[e]}),!0}get detectedPlanes(){if(!this[R_].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");return this[R_].detectedPlanes}get detectedMeshes(){if(!this[R_].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");return this[R_].detectedMeshes}get trackedAnchors(){if(!this[R_].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");return this[R_].trackedAnchors}createAnchor(e,t){return new Promise((n,i)=>{if(this[R_].active){const r=this[R_].session[B_].device[E_].globalSpace,a=new $_(t,e.matrix),s=K_.calculateGlobalOffsetMatrix(a),o=new $_(r,s),l=new Ab(o,this[R_].session);this[R_].session[B_].trackedAnchors.add(l),this[R_].session[B_].newAnchors.set(l,{resolve:n,reject:i})}else i(new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError"))})}getHitTestResults(e){if(this[R_].active){if(this[R_].hitTestResultsMap.has(e))return[...this[R_].hitTestResultsMap.get(e)];throw new DOMException("Requested hit test results are not available for current frame.","InvalidStateError")}throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError")}}var Qb,Jb,ew;!function(e){e.Opaque="opaque",e.AlphaBlend="alpha-blend",e.Additive="additive"}(Qb||(Qb={})),function(e){e.ScreenSpace="screen-space",e.WorldSpace="world-space"}(Jb||(Jb={}));class tw extends EventTarget{constructor(e,t,n){super(),this[B_]={device:e,mode:t,renderState:new Vb,pendingRenderState:null,enabledFeatures:n,isSystemKeyboardSupported:!1,ended:!1,projectionMatrices:{[zb.Left]:Wx(),[zb.Right]:Wx(),[zb.None]:Wx()},getProjectionMatrix:e=>this[B_].projectionMatrices[e],referenceSpaceIsSupported:e=>{if(!this[B_].enabledFeatures.includes(e))return!1;switch(e){case Fb.Viewer:return!0;case Fb.Local:case Fb.LocalFloor:case Fb.BoundedFloor:case Fb.Unbounded:return"inline"!=this[B_].mode}},frameHandle:0,frameCallbacks:[],currentFrameCallbacks:null,onDeviceFrame:()=>{if(this[B_].ended)return;this[B_].deviceFrameHandle=globalThis.requestAnimationFrame(this[B_].onDeviceFrame),null!=this[B_].pendingRenderState&&(this[B_].renderState=this[B_].pendingRenderState,this[B_].pendingRenderState=null,this[B_].device[E_].onBaseLayerSet(this[B_].renderState.baseLayer));const e=this[B_].renderState.baseLayer;if(null===e)return;const t=e.context,n=t.canvas;if("inline"!=this[B_].mode){const e=t.getParameter(t.COLOR_CLEAR_VALUE),n=t.getParameter(t.DEPTH_CLEAR_VALUE),i=t.getParameter(t.STENCIL_CLEAR_VALUE);t.clearColor(0,0,0,0),t.clearDepth(1),t.clearStencil(0),t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),t.clearColor(e[0],e[1],e[2],e[3]),t.clearDepth(n),t.clearStencil(i)}const{depthNear:i,depthFar:r}=this[B_].renderState,{width:a,height:s}=n;if("inline"!==this[B_].mode){const e=a*(this[B_].device.stereoEnabled?.5:1)/s;n_(this[B_].projectionMatrices[zb.Left],this[B_].device.fovy,e,i,r),qx(this[B_].projectionMatrices[zb.Right],this[B_].projectionMatrices[zb.Left])}else{const e=a/s;n_(this[B_].projectionMatrices[zb.None],this[B_].renderState.inlineVerticalFieldOfView,e,i,r)}const o=new Zb(this,this[B_].frameHandle,!0,!0,performance.now()),l=performance.now(),c=this[B_].device[E_].devui;if(c&&c.render(l),"immersive-ar"===this[B_].mode){const e=this[B_].device[E_].sem;e&&e.render(l)}this[B_].enabledFeatures.includes("anchors")&&this[B_].updateTrackedAnchors(),this[B_].enabledFeatures.includes("plane-detection")&&this[B_].updateTrackedPlanes(o),this[B_].enabledFeatures.includes("mesh-detection")&&this[B_].updateTrackedMeshes(o),this[B_].enabledFeatures.includes("hit-test")&&this[B_].computeHitTestResults(o),this[B_].device[E_].onFrameStart(o),this[B_].updateActiveInputSources();const u=this[B_].currentFrameCallbacks=this[B_].frameCallbacks;this[B_].frameCallbacks=[];const d=performance.now();for(let e=0;e<u.length;e++)try{u[e].cancelled||u[e].callback(d,o)}catch(e){console.error(e)}this[B_].currentFrameCallbacks=null,o[R_].active=!1},nominalFrameRate:e.internalNominalFrameRate,referenceSpaces:[],inputSourceArray:[],activeInputSources:[],updateActiveInputSources:()=>{const e=this[B_].enabledFeatures.includes("hand-tracking"),t=this[B_].activeInputSources,n=this[B_].device.inputSources.filter(t=>!t.hand||e),i=n.filter(e=>!t.includes(e)),r=t.filter(e=>!n.includes(e));this[B_].activeInputSources=n,(i.length>0||r.length>0)&&this.dispatchEvent(new kb("inputsourceschange",{session:this,added:i,removed:r}))},trackedAnchors:new Rb,persistentAnchors:new Map,newAnchors:new Map,frameTrackedAnchors:new Rb,updateTrackedAnchors:()=>{this[B_].enabledFeatures.includes("anchors")&&(this[B_].frameTrackedAnchors.clear(),Array.from(this[B_].trackedAnchors).forEach(e=>{if(e[S_].deleted){if(this[B_].trackedAnchors.delete(e),this[B_].newAnchors.has(e)){const{reject:t}=this[B_].newAnchors.get(e);t(new DOMException("Anchor is no longer tracked","InvalidStateError"))}}else if(this[B_].frameTrackedAnchors.add(e),this[B_].newAnchors.has(e)){const{resolve:t}=this[B_].newAnchors.get(e);t(e),this[B_].newAnchors.delete(e)}}))},trackedPlanes:new Map,updateTrackedPlanes:e=>{const t=this[B_].device[E_].sem;if(!t)return;Array.from(this[B_].trackedPlanes.keys()).forEach(e=>{t.trackedPlanes.has(e)||this[B_].trackedPlanes.delete(e)}),t.trackedPlanes.forEach(t=>{let n=this[B_].trackedPlanes.get(t);if(!n){const e=new $_(this[B_].device[E_].globalSpace,t.transform.matrix);n=new Mb(t,e,t.polygon,t.semanticLabel),this[B_].trackedPlanes.set(t,n)}n[N_].lastChangedTime=e.predictedDisplayTime,n[N_].frame=e,e[R_].detectedPlanes.add(n)})},trackedMeshes:new Map,updateTrackedMeshes:e=>{const t=this[B_].device[E_].sem;if(!t)return;Array.from(this[B_].trackedMeshes.keys()).forEach(e=>{t.trackedMeshes.has(e)||this[B_].trackedMeshes.delete(e)}),t.trackedMeshes.forEach(t=>{let n=this[B_].trackedMeshes.get(t);if(!n){const e=new $_(this[B_].device[E_].globalSpace,t.transform.matrix);n=new yb(t,e,t.vertices,t.indices,t.semanticLabel),this[B_].trackedMeshes.set(t,n)}n[D_].lastChangedTime=e.predictedDisplayTime,n[D_].frame=e,e[R_].detectedMeshes.add(n)})},hitTestSources:new Set,computeHitTestResults:e=>{const t=this[B_].device[E_].sem;if(!t)return;const n=this[B_].device[E_].globalSpace;this[B_].hitTestSources.forEach(i=>{const r=i[q_].space,a=K_.calculateGlobalOffsetMatrix(r),s=i[q_].offsetRay.matrix,o=Wx();Yx(o,a,s);const l=[];t.computeHitTestResults(o).forEach(t=>{const i=new $_(n,t),r=new Ob(e,i);l.push(r)}),e[R_].hitTestResultsMap.set(i,l)})},onend:null,oninputsourceschange:null,onselect:null,onselectstart:null,onselectend:null,onsqueeze:null,onsqueezestart:null,onsqueezeend:null,onvisibilitychange:null,onframeratechange:null},Pb.recoverPersistentAnchorsFromStorage(this),this[B_].onDeviceFrame()}get visibilityState(){return this[B_].device.visibilityState}get frameRate(){return this[B_].nominalFrameRate}get supportedFrameRates(){return new Float32Array(this[B_].device.supportedFrameRates)}get renderState(){return this[B_].renderState}get inputSources(){return this[B_].inputSourceArray.length=0,this[B_].ended||"inline"===this[B_].mode||this[B_].inputSourceArray.push(...this[B_].activeInputSources),this[B_].inputSourceArray}get enabledFeatures(){return this[B_].enabledFeatures}get isSystemKeyboardSupported(){return this[B_].isSystemKeyboardSupported}get environmentBlendMode(){var e;return null!==(e=this[B_].device[E_].environmentBlendModes[this[B_].mode])&&void 0!==e?e:Qb.Opaque}get interactionMode(){return this[B_].device[E_].interactionMode}updateRenderState(e={}){var t,n,i,r;if(this[B_].ended)throw new DOMException("XRSession has already ended.","InvalidStateError");if(e.baseLayer&&e.baseLayer[I_].session!==this)throw new DOMException("Base layer was created by a different XRSession","InvalidStateError");if(null!=e.inlineVerticalFieldOfView&&"inline"!==this[B_].mode)throw new DOMException("InlineVerticalFieldOfView must not be set for an immersive session","InvalidStateError");const a={baseLayer:e.baseLayer||(null===(t=this[B_].pendingRenderState)||void 0===t?void 0:t.baseLayer)||void 0,depthFar:e.depthFar||(null===(n=this[B_].pendingRenderState)||void 0===n?void 0:n.depthFar)||void 0,depthNear:e.depthNear||(null===(i=this[B_].pendingRenderState)||void 0===i?void 0:i.depthNear)||void 0,inlineVerticalFieldOfView:e.inlineVerticalFieldOfView||(null===(r=this[B_].pendingRenderState)||void 0===r?void 0:r.inlineVerticalFieldOfView)||void 0};this[B_].pendingRenderState=new Vb(a,this[B_].renderState)}async updateTargetFrameRate(e){return new Promise((t,n)=>{this[B_].ended?n(new DOMException("XRSession has already ended.","InvalidStateError")):this[B_].device.supportedFrameRates.includes(e)?(this[B_].nominalFrameRate===e?console.log("Requested frame rate is the same as the current nominal frame rate, no update made"):(this[B_].nominalFrameRate=e,this.dispatchEvent(new Hb("frameratechange",{session:this})),console.log(`Nominal frame rate updated to ${e}`)),t()):n(new DOMException("Requested frame rate not supported.","InvalidStateError"))})}async requestReferenceSpace(e){return new Promise((t,n)=>{if(this[B_].ended||!this[B_].referenceSpaceIsSupported(e))return void n(new DOMException("The requested reference space type is not supported.","NotSupportedError"));let i;switch(e){case Fb.Viewer:i=this[B_].device.viewerSpace;break;case Fb.Local:i=new Bb(e,this[B_].device[E_].globalSpace,this[B_].device.viewerSpace[G_].offsetMatrix);break;case Fb.LocalFloor:case Fb.BoundedFloor:case Fb.Unbounded:i=new Bb(e,this[B_].device[E_].globalSpace)}this[B_].referenceSpaces.push(i),t(i)})}requestAnimationFrame(e){if(this[B_].ended)return 0;const t=++this[B_].frameHandle;return this[B_].frameCallbacks.push({handle:t,callback:e,cancelled:!1}),t}cancelAnimationFrame(e){let t=this[B_].frameCallbacks,n=t.findIndex(t=>t&&t.handle===e);n>-1&&(t[n].cancelled=!0,t.splice(n,1)),t=this[B_].currentFrameCallbacks,t&&(n=t.findIndex(t=>t&&t.handle===e),n>-1&&(t[n].cancelled=!0))}async end(){return new Promise((e,t)=>{this[B_].ended||null===this[B_].deviceFrameHandle?t(new DOMException("XRSession has already ended.","InvalidStateError")):(globalThis.cancelAnimationFrame(this[B_].deviceFrameHandle),this[B_].device[E_].onSessionEnd(),this.dispatchEvent(new Hb("end",{session:this})),e())})}get persistentAnchors(){return Array.from(this[B_].persistentAnchors.keys())}restorePersistentAnchor(e){return new Promise((t,n)=>{if(this[B_].persistentAnchors.has(e))if(this[B_].ended)n(new DOMException("XRSession has already ended.","InvalidStateError"));else{const i=this[B_].persistentAnchors.get(e);this[B_].newAnchors.has(i)?n(new DOMException(`Multiple concurrent attempts detected to restore the anchor with UUID: ${e}.`,"InvalidStateError")):(this[B_].trackedAnchors.add(i),this[B_].newAnchors.set(i,{resolve:t,reject:n}))}else n(new DOMException(`Persistent anchor with uuid ${e} not found.`,"InvalidStateError"))})}deletePersistentAnchor(e){return new Promise((t,n)=>{if(this[B_].persistentAnchors.has(e)){const n=this[B_].persistentAnchors.get(e);this[B_].persistentAnchors.delete(e),n.delete(),t(void 0)}else n(new DOMException(`Persistent anchor with uuid ${e} not found.`,"InvalidStateError"))})}requestHitTestSource(e){return new Promise((t,n)=>{if(this[B_].enabledFeatures.includes("hit-test"))if(this[B_].ended)n(new DOMException("XRSession has already ended.","InvalidStateError"));else if(this[B_].device[E_].sem){const n=new Nb(this,e);this[B_].hitTestSources.add(n),t(n)}else n(new DOMException("Synthethic Environment Module required for emulating hit-test","OperationError"));else n(new DOMException('WebXR feature "hit-test" is not supported by current session',"NotSupportedError"))})}get onend(){var e;return null!==(e=this[B_].onend)&&void 0!==e?e:()=>{}}set onend(e){this[B_].onend&&this.removeEventListener("end",this[B_].onend),this[B_].onend=e,e&&this.addEventListener("end",e)}get oninputsourceschange(){var e;return null!==(e=this[B_].oninputsourceschange)&&void 0!==e?e:()=>{}}set oninputsourceschange(e){this[B_].oninputsourceschange&&this.removeEventListener("inputsourceschange",this[B_].oninputsourceschange),this[B_].oninputsourceschange=e,e&&this.addEventListener("inputsourceschange",e)}get onselect(){var e;return null!==(e=this[B_].onselect)&&void 0!==e?e:()=>{}}set onselect(e){this[B_].onselect&&this.removeEventListener("select",this[B_].onselect),this[B_].onselect=e,e&&this.addEventListener("select",e)}get onselectstart(){var e;return null!==(e=this[B_].onselectstart)&&void 0!==e?e:()=>{}}set onselectstart(e){this[B_].onselectstart&&this.removeEventListener("selectstart",this[B_].onselectstart),this[B_].onselectstart=e,e&&this.addEventListener("selectstart",e)}get onselectend(){var e;return null!==(e=this[B_].onselectend)&&void 0!==e?e:()=>{}}set onselectend(e){this[B_].onselectend&&this.removeEventListener("selectend",this[B_].onselectend),this[B_].onselectend=e,e&&this.addEventListener("selectend",e)}get onsqueeze(){var e;return null!==(e=this[B_].onsqueeze)&&void 0!==e?e:()=>{}}set onsqueeze(e){this[B_].onsqueeze&&this.removeEventListener("squeeze",this[B_].onsqueeze),this[B_].onsqueeze=e,e&&this.addEventListener("squeeze",e)}get onsqueezestart(){var e;return null!==(e=this[B_].onsqueezestart)&&void 0!==e?e:()=>{}}set onsqueezestart(e){this[B_].onsqueezestart&&this.removeEventListener("squeezestart",this[B_].onsqueezestart),this[B_].onsqueezestart=e,e&&this.addEventListener("squeezestart",e)}get onsqueezeend(){var e;return null!==(e=this[B_].onsqueezeend)&&void 0!==e?e:()=>{}}set onsqueezeend(e){this[B_].onsqueezeend&&this.removeEventListener("squeezeend",this[B_].onsqueezeend),this[B_].onsqueezeend=e,e&&this.addEventListener("squeezeend",e)}get onvisibilitychange(){var e;return null!==(e=this[B_].onvisibilitychange)&&void 0!==e?e:()=>{}}set onvisibilitychange(e){this[B_].onvisibilitychange&&this.removeEventListener("visibilitychange",this[B_].onvisibilitychange),this[B_].onvisibilitychange=e,e&&this.addEventListener("visibilitychange",e)}get onframeratechange(){var e;return null!==(e=this[B_].onframeratechange)&&void 0!==e?e:()=>{}}set onframeratechange(e){this[B_].onframeratechange&&this.removeEventListener("frameratechange",this[B_].onframeratechange),this[B_].onframeratechange=e,e&&this.addEventListener("frameratechange",e)}}!function(e){e.Wrist="wrist",e.ThumbMetacarpal="thumb-metacarpal",e.ThumbPhalanxProximal="thumb-phalanx-proximal",e.ThumbPhalanxDistal="thumb-phalanx-distal",e.ThumbTip="thumb-tip",e.IndexFingerMetacarpal="index-finger-metacarpal",e.IndexFingerPhalanxProximal="index-finger-phalanx-proximal",e.IndexFingerPhalanxIntermediate="index-finger-phalanx-intermediate",e.IndexFingerPhalanxDistal="index-finger-phalanx-distal",e.IndexFingerTip="index-finger-tip",e.MiddleFingerMetacarpal="middle-finger-metacarpal",e.MiddleFingerPhalanxProximal="middle-finger-phalanx-proximal",e.MiddleFingerPhalanxIntermediate="middle-finger-phalanx-intermediate",e.MiddleFingerPhalanxDistal="middle-finger-phalanx-distal",e.MiddleFingerTip="middle-finger-tip",e.RingFingerMetacarpal="ring-finger-metacarpal",e.RingFingerPhalanxProximal="ring-finger-phalanx-proximal",e.RingFingerPhalanxIntermediate="ring-finger-phalanx-intermediate",e.RingFingerPhalanxDistal="ring-finger-phalanx-distal",e.RingFingerTip="ring-finger-tip",e.PinkyFingerMetacarpal="pinky-finger-metacarpal",e.PinkyFingerPhalanxProximal="pinky-finger-phalanx-proximal",e.PinkyFingerPhalanxIntermediate="pinky-finger-phalanx-intermediate",e.PinkyFingerPhalanxDistal="pinky-finger-phalanx-distal",e.PinkyFingerTip="pinky-finger-tip"}(ew||(ew={}));class nw extends Map{}class iw extends $_{constructor(e,t,n){super(t,n),this[V_]={jointName:e,radius:0}}get jointName(){return this[V_].jointName}}const rw={profileId:"oculus-hand",fallbackProfileIds:["generic-hand","generic-hand-select","generic-trigger"],poses:{default:{jointTransforms:{wrist:{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.04913589730858803,.0021463718730956316,.11701996624469757,1],radius:.021460847929120064},"thumb-metacarpal":{offsetMatrix:[-.07536252588033676,-.9959676265716553,-.04867160692811012,0,.5877083539962769,-.08379616588354111,.8047218918800354,0,-.8055551648139954,.032041035592556,.5916536450386047,0,-.010643752291798592,.0006936835707165301,.08736639469861984,1],radius:.019382517784833908},"thumb-phalanx-proximal":{offsetMatrix:[.1374533325433731,-.9904957413673401,.004982374142855406,0,.5534393787384033,.08097179979085922,.8289443850517273,0,-.8214688897132874,-.11118389666080475,.559309184551239,0,.015547193586826324,-.0003480653394944966,.0681300163269043,1],radius:.01228295173496008},"thumb-phalanx-distal":{offsetMatrix:[-.04659227654337883,-.9974699020385742,-.05369402840733528,0,.6812446117401123,-.07104194164276123,.728600800037384,0,-.7305715084075928,-.002631746232509613,.6828309893608093,0,.04330715537071228,.003409178927540779,.0492292083799839,1],radius:.009768804535269737},"thumb-tip":{offsetMatrix:[-.04659227654337883,-.9974699020385742,-.05369402840733528,0,.6812446117401123,-.07104194164276123,.728600800037384,0,-.7305715084075928,-.002631746232509613,.6828309893608093,0,.062003348022699356,.004069602582603693,.03322213143110275,1],radius:.008768804371356964},"index-finger-metacarpal":{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.02009812369942665,.008770795539021492,.08660387247800827,1],radius:.021228281781077385},"index-finger-phalanx-proximal":{offsetMatrix:[.9001791477203369,-.2598813474178314,.3494834005832672,0,.06073702871799469,.8695210218429565,.490146666765213,0,-.4312632381916046,-.41999316215515137,.7985095381736755,0,-.00017739279428496957,.03890012577176094,.039073407649993896,1],radius:.010295259766280651},"index-finger-phalanx-intermediate":{offsetMatrix:[.9082008600234985,-.20898112654685974,.36262574791908264,0,.11045389622449875,.9553793668746948,.27395179867744446,0,-.40369608998298645,-.20874978601932526,.8907597661018372,0,.01617925800383091,.05482936650514603,.008788082748651505,1],radius:.00853810179978609},"index-finger-phalanx-distal":{offsetMatrix:[.9309692978858948,-.16783711314201355,.32423174381256104,0,.1080828532576561,.9749603867530823,.1943446695804596,0,-.34873148798942566,-.14588497579097748,.9257990717887878,0,.02599053829908371,.059902746230363846,-.012860597111284733,1],radius:.007636196445673704},"index-finger-tip":{offsetMatrix:[.9309692978858948,-.16783711314201355,.32423174381256104,0,.1080828532576561,.9749603867530823,.1943446695804596,0,-.34873148798942566,-.14588497579097748,.9257990717887878,0,.03362493962049484,.06421422213315964,-.033461250364780426,1],radius:.006636196281760931},"middle-finger-metacarpal":{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.03627845644950867,.011579737067222595,.08550142496824265,1],radius:.021231964230537415},"middle-finger-phalanx-proximal":{offsetMatrix:[.9876697659492493,-.06786545366048813,.1410750150680542,0,-.015095947310328484,.855663537979126,.5173118710517883,0,-.15582047402858734,-.5130629539489746,.8440889716148376,0,-.021259509027004242,.04587256908416748,.03659208118915558,1],radius:.01117393933236599},"middle-finger-phalanx-intermediate":{offsetMatrix:[.988391637802124,-.04354291781783104,.14555205404758453,0,.008894841186702251,.9729899168014526,.23067504167556763,0,-.15166506171226501,-.22670257091522217,.9620829224586487,0,-.014570588245987892,.06789684295654297,.0003578895702958107,1],radius:.008030958473682404},"middle-finger-phalanx-distal":{offsetMatrix:[.9853697419166565,.044260796159505844,.16458062827587128,0,-.0757969319820404,.9787378311157227,.19059516489505768,0,-.1526455283164978,-.20028135180473328,.9677740931510925,0,-.010392282158136368,.07414241135120392,-.026147106662392616,1],radius:.007629410829395056},"middle-finger-tip":{offsetMatrix:[.9853697419166565,.044260796159505844,.16458062827587128,0,-.0757969319820404,.9787378311157227,.19059516489505768,0,-.1526455283164978,-.20028135180473328,.9677740931510925,0,-.0069718430750072,.08024183660745621,-.05014154314994812,1],radius:.006629410665482283},"ring-finger-metacarpal":{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.05402477830648422,.015797706320881844,.08152295649051666,1],radius:.019088275730609894},"ring-finger-phalanx-proximal":{offsetMatrix:[.9940828680992126,.05735103040933609,.09224652498960495,0,-.10022822767496109,.8116500377655029,.5754809379577637,0,-.041867565363645554,-.5813214182853699,.8125960826873779,0,-.041623555123806,.04171867296099663,.03582974523305893,1],radius:.00992213748395443},"ring-finger-phalanx-intermediate":{offsetMatrix:[.9843675494194031,.12044742703437805,.12850022315979004,0,-.15629759430885315,.9337108135223389,.3221098482608795,0,-.08118485659360886,-.3371586799621582,.937940776348114,0,-.039990875869989395,.06438793987035751,.004141641780734062,1],radius:.007611672393977642},"ring-finger-phalanx-distal":{offsetMatrix:[.9748351573944092,.11857274919748306,.18877571821212769,0,-.15575434267520905,.9681083559989929,.19623035192489624,0,-.15948788821697235,-.22069483995437622,.9622148275375366,0,-.03783353418111801,.07334739714860916,-.020782606676220894,1],radius:.007231088820844889},"ring-finger-tip":{offsetMatrix:[.9748351573944092,.11857274919748306,.18877571821212769,0,-.15575434267520905,.9681083559989929,.19623035192489624,0,-.15948788821697235,-.22069483995437622,.9622148275375366,0,-.03445569798350334,.0802423357963562,-.04392268508672714,1],radius:.0062310886569321156},"pinky-finger-metacarpal":{offsetMatrix:[.9181402921676636,.35625091195106506,.17350243031978607,0,-.39615097641944885,.8352503180503845,.38134080171585083,0,-.009065053425729275,-.41885748505592346,.9080066680908203,0,-.06191859766840935,.013620133511722088,.07850203663110733,1],radius:.01808827556669712},"pinky-finger-phalanx-proximal":{offsetMatrix:[.9714386463165283,.236698180437088,-.016745081171393394,0,-.18462024629116058,.7982627749443054,.5733163952827454,0,.14906984567642212,-.5538501739501953,.8191629648208618,0,-.061502378433942795,.032741155475378036,.03705105185508728,1],radius:.008483353070914745},"pinky-finger-phalanx-intermediate":{offsetMatrix:[.9337416291236877,.35620439052581787,-.03527557849884033,0,-.33203884959220886,.8987522721290588,.28634607791900635,0,.13370157778263092,-.2556603252887726,.9574766755104065,0,-.06608185172080994,.049755651503801346,.011886020191013813,1],radius:.0067641944624483585},"pinky-finger-phalanx-distal":{offsetMatrix:[.9419984817504883,.3303581774234772,.059175245463848114,0,-.33483216166496277,.9130291938781738,.23294763267040253,0,.02292730286717415,-.2392500638961792,.970687210559845,0,-.0687975287437439,.054948460310697556,-.007561664097011089,1],radius:.0064259846694767475},"pinky-finger-tip":{offsetMatrix:[.9419984817504883,.3303581774234772,.059175245463848114,0,-.33483216166496277,.9130291938781738,.23294763267040253,0,.02292730286717415,-.2392500638961792,.970687210559845,0,-.06947512179613113,.0613851435482502,-.028543535619974136,1],radius:.005425984505563974}},gripOffsetMatrix:[-.0005348679260350764,-.8648636937141418,-.5020061135292053,0,-.2741127908229828,-.48265108466148376,.8318111896514893,0,-.9616971015930176,.13805119693279266,-.2368120402097702,0,-.02878567762672901,.0017147823236882687,.04536811262369156,1]},pinch:{jointTransforms:{wrist:{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.06867414712905884,-.009423808194696903,.10627774149179459,1],radius:.021460847929120064},"thumb-metacarpal":{offsetMatrix:[-.5012241005897522,-.8650535345077515,-.0213695727288723,0,.7415963411331177,-.4421543478965759,.5045139193534851,0,-.44587990641593933,.23702676594257355,.8631392121315002,0,-.032122574746608734,-.01196830440312624,.07194234430789948,1],radius:.019382517784833908},"thumb-phalanx-proximal":{offsetMatrix:[-.3175753057003021,-.9460570216178894,-.06419729441404343,0,.8958902955055237,-.32153913378715515,.30658137798309326,0,-.3106854259967804,.03984907269477844,.9496771097183228,0,-.017625702545046806,-.01967475935816765,.04387917369604111,1],radius:.01228295173496008},"thumb-phalanx-distal":{offsetMatrix:[-.4944636821746826,-.8691971898078918,.001086252392269671,0,.8307800889015198,-.4722411036491394,.2946045398712158,0,-.25555649399757385,.14657381176948547,.9556186199188232,0,-.007126678712666035,-.021021386608481407,.011786630377173424,1],radius:.009768804535269737},"thumb-tip":{offsetMatrix:[-.4944636821746826,-.8691971898078918,.001086252392269671,0,.8307800889015198,-.4722411036491394,.2946045398712158,0,-.25555649399757385,.14657381176948547,.9556186199188232,0,.0003423091256991029,-.024528030306100845,-.011410919018089771,1],radius:.008768804371356964},"index-finger-metacarpal":{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.038037415593862534,-.0020236473064869642,.07626739144325256,1],radius:.021228281781077385},"index-finger-phalanx-proximal":{offsetMatrix:[.7986818552017212,-.35985732078552246,.48229536414146423,0,.538311243057251,.7854709625244141,-.30537736415863037,0,-.2689369022846222,.5035246014595032,.8210577368736267,0,-.006869405973702669,.033938243985176086,.04206443578004837,1],radius:.010295259766280651},"index-finger-phalanx-intermediate":{offsetMatrix:[.8285930156707764,-.32672837376594543,.4546217918395996,0,.5577570199966431,.4116027057170868,-.7207564115524292,0,.04836784675717354,.8507823944091797,.5232869386672974,0,.0033306588884443045,.014840902760624886,.010923954658210278,1],radius:.00853810179978609},"index-finger-phalanx-distal":{offsetMatrix:[.8412464261054993,-.35794928669929504,.4051857888698578,0,.5139996409416199,.29711154103279114,-.8046918511390686,0,.16765329241752625,.8852096796035767,.4339304566383362,0,.0021551470272243023,-.0058362227864563465,-.0017938464879989624,1],radius:.007636196445673704},"index-finger-tip":{offsetMatrix:[.8412464261054993,-.35794928669929504,.4051857888698578,0,.5139996409416199,.29711154103279114,-.8046918511390686,0,.16765329241752625,.8852096796035767,.4339304566383362,0,-.00131594471167773,-.025222131982445717,-.012442642822861671,1],radius:.006636196281760931},"middle-finger-metacarpal":{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.05395089089870453,.003063359996303916,.07402937114238739,1],radius:.021231964230537415},"middle-finger-phalanx-proximal":{offsetMatrix:[.9187911748886108,-.1530158370733261,.36387869715690613,0,.038666240870952606,.9522662162780762,.302808940410614,0,-.3928440511226654,-.26414817571640015,.8808513283729553,0,-.02717282809317112,.04162866622209549,.03678669035434723,1],radius:.01117393933236599},"middle-finger-phalanx-intermediate":{offsetMatrix:[.9228746294975281,-.12856416404247284,.36300456523895264,0,.14524033665657043,.9892153143882751,-.01890045404434204,0,-.3566599190235138,.07016586512327194,.9315956234931946,0,-.01030921470373869,.05296773463487625,-.0010256498353555799,1],radius:.008030958473682404},"middle-finger-phalanx-distal":{offsetMatrix:[.9325166344642639,-.040404170751571655,.35885775089263916,0,.06836572289466858,.995502769947052,-.0655682161450386,0,-.3545948565006256,.08567725121974945,.9310863614082336,0,-.0004833847051486373,.05103470757603645,-.026690717786550522,1],radius:.007629410829395056},"middle-finger-tip":{offsetMatrix:[.9325166344642639,-.040404170751571655,.35885775089263916,0,.06836572289466858,.995502769947052,-.0655682161450386,0,-.3545948565006256,.08567725121974945,.9310863614082336,0,.008158999495208263,.05004044249653816,-.050120558589696884,1],radius:.006629410665482283},"ring-finger-metacarpal":{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.06732909381389618,.007902119308710098,.07209732383489609,1],radius:.019088275730609894},"ring-finger-phalanx-proximal":{offsetMatrix:[.9391821026802063,-.027994679287075996,.34227466583251953,0,-.18282271921634674,.8029410243034363,.5673282742500305,0,-.2907087206840515,-.5954000353813171,.7489906549453735,0,-.047129884362220764,.03806127607822418,.032147664576768875,1],radius:.00992213748395443},"ring-finger-phalanx-intermediate":{offsetMatrix:[.9249380826950073,.03699534013867378,.3783116042613983,0,-.12898847460746765,.9667453765869141,.2208271026611328,0,-.3575615882873535,-.25304901599884033,.8989526629447937,0,-.03579339757561684,.06127955764532089,.002939916681498289,1],radius:.007611672393977642},"ring-finger-phalanx-distal":{offsetMatrix:[.9001164436340332,.03983335196971893,.4338230490684509,0,-.09662467986345291,.9892624020576477,.10964841395616531,0,-.4247973561286926,-.14061418175697327,.8943013548851013,0,-.026291755959391594,.06800390034914017,-.02094830758869648,1],radius:.007231088820844889},"ring-finger-tip":{offsetMatrix:[.9001164436340332,.03983335196971893,.4338230490684509,0,-.09662467986345291,.9892624020576477,.10964841395616531,0,-.4247973561286926,-.14061418175697327,.8943013548851013,0,-.016345610842108727,.07300511747598648,-.04263874143362045,1],radius:.0062310886569321156},"pinky-finger-metacarpal":{offsetMatrix:[.8769711852073669,.31462907791137695,.36322021484375,0,-.4506046175956726,.801031768321991,.39408499002456665,0,-.16696058213710785,-.5092697143554688,.8442559838294983,0,-.07460174709558487,.0062340241856873035,.06756893545389175,1],radius:.01808827556669712},"pinky-finger-phalanx-proximal":{offsetMatrix:[.9498357176780701,.1553308218717575,.2714462876319885,0,-.3019258379936218,.6817675232887268,.6663586497306824,0,-.08155745267868042,-.7148879170417786,.694466233253479,0,-.06697750836610794,.029482364654541016,.02902858518064022,1],radius:.008483353070914745},"pinky-finger-phalanx-intermediate":{offsetMatrix:[.9214097261428833,.27928245067596436,.2701927423477173,0,-.3670244514942169,.8538867831230164,.36901235580444336,0,-.12765564024448395,-.43917882442474365,.8892839550971985,0,-.06447203457355499,.05144399777054787,.0076942890882492065,1],radius:.0067641944624483585},"pinky-finger-phalanx-distal":{offsetMatrix:[.9038633704185486,.23618005216121674,.3567195236682892,0,-.3532794713973999,.8823202252388,.3109731376171112,0,-.24129553139209747,-.4070987403392792,.8809353709220886,0,-.06187915802001953,.060364335775375366,-.010368337854743004,1],radius:.0064259846694767475},"pinky-finger-tip":{offsetMatrix:[.9038633704185486,.23618005216121674,.3567195236682892,0,-.3532794713973999,.8823202252388,.3109731376171112,0,-.24129553139209747,-.4070987403392792,.8809353709220886,0,-.056796226650476456,.07042007893323898,-.02921444922685623,1],radius:.005425984505563974}},gripOffsetMatrix:[.08027800917625427,-.8086723685264587,-.5827556252479553,0,-.4154181480407715,-.5585916638374329,.7179154753684998,0,-.9060805439949036,.1844543218612671,-.3807799518108368,0,-.038054611533880234,-.002910431008785963,.03720742464065552,1]},point:{jointTransforms:{wrist:{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.05789132043719292,.01670890860259533,.11183350533246994,1],radius:.021460847929120064},"thumb-metacarpal":{offsetMatrix:[.02145560085773468,-.9978390336036682,.0621047280728817,0,.41311800479888916,.06541631370782852,.9083252549171448,0,-.9104245901107788,.006167683284729719,.4136286973953247,0,-.016488194465637207,.012708572670817375,.08862338215112686,1],radius:.019382517784833908},"thumb-phalanx-proximal":{offsetMatrix:[.21270370483398438,-.966137707233429,.14606566727161407,0,.49890995025634766,.2359165996313095,.8339261412620544,0,-.8401462435722351,-.10450579971075058,.5321959853172302,0,.013112368993461132,.012508046813309193,.07517509907484055,1],radius:.01228295173496008},"thumb-phalanx-distal":{offsetMatrix:[.01653280481696129,-.9986647963523865,.048943229019641876,0,.26313456892967224,.051570065319538116,.9633802771568298,0,-.9646173715591431,-.0030490627977997065,.26363563537597656,0,.04150351136922836,.016039609909057617,.05719054117798805,1],radius:.009768804535269737},"thumb-tip":{offsetMatrix:[.01653280481696129,-.9986647963523865,.048943229019641876,0,.26313456892967224,.051570065319538116,.9633802771568298,0,-.9646173715591431,-.0030490627977997065,.26363563537597656,0,.06548332422971725,.01683700829744339,.0516640841960907,1],radius:.008768804371356964},"index-finger-metacarpal":{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.02592567168176174,.019982583820819855,.08479326963424683,1],radius:.021228281781077385},"index-finger-phalanx-proximal":{offsetMatrix:[.9063700437545776,-.21756279468536377,.3621589243412018,0,.0970839336514473,.9415287375450134,.3226419687271118,0,-.41117796301841736,-.2572731077671051,.8744958639144897,0,-.0015709538711234927,.043078210204839706,.034657616168260574,1],radius:.010295259766280651},"index-finger-phalanx-intermediate":{offsetMatrix:[.9159826040267944,-.1651475727558136,.36565208435058594,0,.09755707532167435,.9756820797920227,.1962820291519165,0,-.3891757130622864,-.14411886036396027,.9098196625709534,0,.014023927971720695,.052835866808891296,.0014903299743309617,1],radius:.00853810179978609},"index-finger-phalanx-distal":{offsetMatrix:[.9378057718276978,-.12329639494419098,.3245268166065216,0,.032558172941207886,.9619227051734924,.2713746726512909,0,-.3456292748451233,-.2439306229352951,.9061115384101868,0,.023482320830225945,.05633850023150444,-.020621655508875847,1],radius:.007636196445673704},"index-finger-tip":{offsetMatrix:[.9378057718276978,-.12329639494419098,.3245268166065216,0,.032558172941207886,.9619227051734924,.2713746726512909,0,-.3456292748451233,-.2439306229352951,.9061115384101868,0,.03096788562834263,.06281610578298569,-.040703095495700836,1],radius:.006636196281760931},"middle-finger-metacarpal":{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.04184452444314957,.022474845871329308,.08177298307418823,1],radius:.021231964230537415},"middle-finger-phalanx-proximal":{offsetMatrix:[.9720265865325928,-.08313076198101044,.21966552734375,0,.20477405190467834,.7580050826072693,-.6192700862884521,0,-.11502730846405029,.6469289064407349,.7538246512413025,0,-.022107340395450592,.05035499855875969,.02970452979207039,1],radius:.01117393933236599},"middle-finger-phalanx-intermediate":{offsetMatrix:[.9779140949249268,-.07129573822021484,.19646917283535004,0,.1287083923816681,-.5352076292037964,-.8348574042320251,0,.1646735966205597,.8417060971260071,-.5142109394073486,0,-.017169542610645294,.022584279999136925,-.00265491777099669,1],radius:.008030958473682404},"middle-finger-phalanx-distal":{offsetMatrix:[.9774913787841797,-.19657190144062042,.07661263644695282,0,-.1924918293952942,-.9796126484870911,-.05749811604619026,0,.08635343611240387,.041456472128629684,-.995401918888092,0,-.02170622907578945,-.0006043742760084569,.011511396616697311,1],radius:.007629410829395056},"middle-finger-tip":{offsetMatrix:[.9774913787841797,-.19657190144062042,.07661263644695282,0,-.1924918293952942,-.9796126484870911,-.05749811604619026,0,.08635343611240387,.041456472128629684,-.995401918888092,0,-.02438267692923546,-.0026927536819130182,.03627248480916023,1],radius:.006629410665482283},"ring-finger-metacarpal":{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.05944233387708664,.0264605600386858,.07478221505880356,1],radius:.019088275730609894},"ring-finger-phalanx-proximal":{offsetMatrix:[.9842101335525513,.024470895528793335,.1753024309873581,0,.12200043350458145,.6237703561782837,-.7720272541046143,0,-.12824076414108276,.7812241315841675,.610936164855957,0,-.04249368980526924,.0467497780919075,.027722163125872612,1],radius:.00992213748395443},"ring-finger-phalanx-intermediate":{offsetMatrix:[.9941774606704712,.05949164181947708,.08983955532312393,0,.10504482686519623,-.7208291888237,-.6851072907447815,0,.024001073092222214,.6905553936958313,-.7228817939758301,0,-.0374927744269371,.016285063698887825,.0038980208337306976,1],radius:.007611672393977642},"ring-finger-phalanx-distal":{offsetMatrix:[.9995742440223694,.01638498157262802,.02412819117307663,0,.007813597097992897,-.9474818110466003,.31971633434295654,0,.028100071474909782,-.31939181685447693,-.9472070932388306,0,-.038130562752485275,-.0020653479732573032,.02310742810368538,1],radius:.007231088820844889},"ring-finger-tip":{offsetMatrix:[.9995742440223694,.01638498157262802,.02412819117307663,0,.007813597097992897,-.9474818110466003,.31971633434295654,0,.028100071474909782,-.31939181685447693,-.9472070932388306,0,-.0390593595802784,.004176302347332239,.0466572530567646,1],radius:.0062310886569321156},"pinky-finger-metacarpal":{offsetMatrix:[.9147363901138306,.3458845317363739,.20885537564754486,0,-.3923271894454956,.8839452862739563,.2544005811214447,0,-.09662359952926636,-.3146490156650543,.9442773461341858,0,-.06715242564678192,.024195827543735504,.07137546688318253,1],radius:.01808827556669712},"pinky-finger-phalanx-proximal":{offsetMatrix:[.9613109827041626,.22439135611057281,.15977802872657776,0,.01002211682498455,.5511574745178223,-.8343409299850464,0,-.27528178691864014,.8036624789237976,.5275853276252747,0,-.06273911893367767,.038559623062610626,.028268879279494286,1],radius:.008483353070914745},"pinky-finger-phalanx-intermediate":{offsetMatrix:[.9820972084999084,.18811029195785522,-.00995189044624567,0,.14063723385334015,-.7673450708389282,-.6256227493286133,0,-.12532226741313934,.6130226850509644,-.7800630927085876,0,-.05428232625126839,.013870777562260628,.012061242014169693,1],radius:.0067641944624483585},"pinky-finger-phalanx-distal":{offsetMatrix:[.9744614362716675,.20454788208007812,-.09265263378620148,0,.22429193556308746,-.9065253138542175,.35764020681381226,0,-.010836843401193619,-.3692878782749176,-.9292529225349426,0,-.05173685774207115,.0014194445684552193,.02790539152920246,1],radius:.0064259846694767475},"pinky-finger-tip":{offsetMatrix:[.9744614362716675,.20454788208007812,-.09265263378620148,0,.22429193556308746,-.9065253138542175,.35764020681381226,0,-.010836843401193619,-.3692878782749176,-.9292529225349426,0,-.05098633095622063,.008463085629045963,.048688892275094986,1],radius:.005425984505563974}},gripOffsetMatrix:[.005510995630174875,-.9149997234344482,-.40341615676879883,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.9340395331382751,.13936474919319153,-.32885703444480896,0,-.031803809106349945,.007837686687707901,.04313928261399269,1]}}},aw={mapping:sb.None,buttons:[{id:"pinch",type:"analog",eventTrigger:"select"}],axes:[]},sw=i_(),ow=p_(),lw=i_(),cw=i_(),uw=p_(),dw=i_(),hw=i_(),fw=p_(),pw=i_(),mw=(e,t,n,i)=>(Jx(sw,t),t_(ow,t),e_(lw,t),Jx(cw,n),t_(uw,n),e_(dw,n),u_(hw,sw,cw,i),g_(fw,ow,uw,i),u_(pw,lw,dw,i),function(e,t,n,i){var r=t[0],a=t[1],s=t[2],o=t[3],l=r+r,c=a+a,u=s+s,d=r*l,h=r*c,f=r*u,p=a*c,m=a*u,g=s*u,v=o*l,y=o*c,x=o*u,_=i[0],b=i[1],w=i[2];e[0]=(1-(p+g))*_,e[1]=(h+x)*_,e[2]=(f-y)*_,e[3]=0,e[4]=(h-x)*b,e[5]=(1-(d+g))*b,e[6]=(m+v)*b,e[7]=0,e[8]=(f+y)*w,e[9]=(m-v)*w,e[10]=(1-(d+p))*w,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1}(e,fw,hw,pw),e),gw=[1,-1,-1,0,-1,1,1,0,-1,1,1,0,-1,1,1,1];class vw extends gb{constructor(e,t,n){if(t!==ob.Left&&t!==ob.Right)throw new DOMException('handedness for XRHandInput must be either "left" or "right"',"InvalidStateError");if(!e.poses.default||!e.poses.pinch)throw new DOMException('"default" and "pinch" hand pose configs are required',"InvalidStateError");const i=new $_(n),r=new $_(i),a=[e.profileId,...e.fallbackProfileIds],s=new nw;Object.values(ew).forEach(e=>{s.set(e,new iw(e,i))});super(new fb(t,lb.TrackedPointer,a,i,new db(aw),r,s)),this[T_]={poseId:"default",poses:e.poses},this.updateHandPose()}get poseId(){return this[T_].poseId}set poseId(e){this[T_].poses[e]?this[T_].poseId=e:console.warn(`Pose config ${e} not found`)}updateHandPose(){const e=this[T_].poses[this[T_].poseId],t=this[T_].poses.pinch;Object.values(ew).forEach(n=>{const i=e.jointTransforms[n].offsetMatrix,r=t.jointTransforms[n].offsetMatrix,a=this.inputSource.hand.get(n);mw(a[G_].offsetMatrix,i,r,this.pinchValue),this.inputSource.handedness===ob.Right&&(e=>{for(let t=0;t<16;t++)e[t]*=gw[t]})(a[G_].offsetMatrix),a[V_].radius=(1-this.pinchValue)*e.jointTransforms[n].radius+this.pinchValue*t.jointTransforms[n].radius}),e.gripOffsetMatrix&&t.gripOffsetMatrix&&mw(this.inputSource.gripSpace[G_].offsetMatrix,e.gripOffsetMatrix,t.gripOffsetMatrix,this.pinchValue)}get pinchValue(){return this[A_].inputSource.gamepad[C_].buttonsMap.pinch.value}updatePinchValue(e){if(e>1||e<0)return void console.warn(`Out-of-range value ${e} provided for pinch`);this[A_].inputSource.gamepad[C_].buttonsMap.pinch[C_].pendingValue=e}onFrameStart(e){super.onFrameStart(e),this.updateHandPose()}}class yw extends EventTarget{}const xw={antialias:!0,depth:!0,stencil:!1,alpha:!0,ignoreDepthValues:!1,framebufferScaleFactor:1};let _w=class extends yw{constructor(e,t,n={}){if(super(),e[B_].ended)throw new DOMException("Session has ended","InvalidStateError");const i={...xw,...n};this[I_]={session:e,context:t,antialias:i.antialias}}get context(){return this[I_].context}get antialias(){return this[I_].antialias}get ignoreDepthValues(){return!0}get framebuffer(){return null}get framebufferWidth(){return this[I_].context.drawingBufferWidth}get framebufferHeight(){return this[I_].context.drawingBufferHeight}getViewport(e){if(e[j_].session!==this[I_].session)throw new DOMException("View's session differs from Layer's session","InvalidStateError");return this[I_].session[B_].device[E_].getViewport(this,e)}static getNativeFramebufferScaleFactor(e){if(!(e instanceof tw))throw new TypeError("getNativeFramebufferScaleFactor must be passed a session.");return e[B_].ended?0:1}};class bw{constructor(e,t,n){const{schema:i,frames:r}=t;if(!r||!i||0===r.length)throw new DOMException("wrong recording format","NotSupportedError");const a=new Bb(Fb.Viewer,e),s={[zb.Left]:new $_(a),[zb.Right]:new $_(a),[zb.None]:new $_(a)};this[w_]={refSpace:e,inputSources:new Map,inputSchemas:new Map,frames:r,recordedFramePointer:0,startingTimeStamp:r[0][0],endingTimeStamp:r[r.length-1][0],playbackTime:r[0][0],playing:!1,viewerSpace:a,viewSpaces:s,vec3:i_(),quat:p_()},Kx(this[w_].viewSpaces[zb.Left][G_].offsetMatrix,r_(-n/2,0,0)),Kx(this[w_].viewSpaces[zb.Right][G_].offsetMatrix,r_(n/2,0,0)),i.forEach(t=>{const n=t[0],i=t[1];let r;if(i.hasGamepad){const e=[];for(let t=0;t<i.numButtons;t++)e.push({id:t.toString(),type:"manual"});const t=[];for(let e=0;e<i.numAxes;e++)t.push({id:e.toString(),type:"manual"});r=new db({mapping:i.mapping,buttons:e,axes:t})}const a=new $_(e);let s;i.hasHand&&(s=new nw,Object.values(ew).forEach(e=>{s.set(e,new iw(e,a))}));const o=new fb(i.handedness,i.targetRayMode,i.profiles,a,r,i.hasGrip?new $_(e):void 0,i.hasHand?s:void 0);this[w_].inputSources.set(n,{active:!1,source:o}),this[w_].inputSchemas.set(n,i)})}play(){this[w_].recordedFramePointer=0,this[w_].playbackTime=this[w_].startingTimeStamp,this[w_].playing=!0,this[w_].actualTimeStamp=performance.now()}stop(){this[w_].playing=!1}get playing(){return this[w_].playing}get viewerSpace(){return this[w_].viewerSpace}get viewSpaces(){return this[w_].viewSpaces}get inputSources(){return Array.from(this[w_].inputSources.values()).filter(e=>e.active).map(e=>e.source)}playFrame(){const e=performance.now(),t=e-this[w_].actualTimeStamp;if(this[w_].actualTimeStamp=e,this[w_].playbackTime+=t,this[w_].playbackTime>this[w_].endingTimeStamp)return void this.stop();for(;this[w_].frames[this[w_].recordedFramePointer+1][0]<this[w_].playbackTime;)this[w_].recordedFramePointer++;const n=this[w_].frames[this[w_].recordedFramePointer],i=this[w_].frames[this[w_].recordedFramePointer+1],r=(this[w_].playbackTime-n[0])/(i[0]-n[0]);this.updateXRSpaceFromMergedFrames(this[w_].viewerSpace,n.slice(1,8),i.slice(1,8),r);const a=new Map;for(let e=8;e<n.length;e++){const{index:t,inputData:i}=this.processRawInputData(n[e]);a.set(t,i)}const s=new Map;for(let e=8;e<i.length;e++){const{index:t,inputData:n}=this.processRawInputData(i[e]);s.set(t,n)}this[w_].inputSources.forEach(e=>{e.active=!1}),s.forEach((e,t)=>{this[w_].inputSources.get(t).active=!0;const n=this[w_].inputSources.get(t).source,i=this[w_].inputSchemas.get(t);this.updateInputSource(n,i,a.has(t)?a.get(t):e,e,r)})}updateInputSource(e,t,n,i,r){if(this.updateXRSpaceFromMergedFrames(e.targetRaySpace,n.targetRayTransform,i.targetRayTransform,r),t.hasGrip&&this.updateXRSpaceFromMergedFrames(e.gripSpace,n.gripTransform,i.gripTransform,r),t.hasHand)for(let a=0;a<25;a++){const s=n.handTransforms.slice(8*a,8*a+7),o=i.handTransforms.slice(8*a,8*a+7),l=n.handTransforms[8*a+7],c=i.handTransforms[8*a+7],u=e.hand.get(t.jointSequence[a]);this.updateXRSpaceFromMergedFrames(u,s,o,r),u[V_].radius=(c-l)*r+l}if(t.hasGamepad){const t=e.gamepad;i.buttons.forEach((e,i)=>{const a=t.buttons[i];a[C_].pressed=1===e[0],a[C_].touched=1===e[1];const s=n.buttons[i][2],o=e[2];a[C_].value=(o-s)*r+s}),i.axes.forEach((e,i)=>{const a=n.axes[i];t[C_].axesMap[i.toString()].x=(e-a)*r+a})}}updateXRSpaceFromMergedFrames(e,t,n,i){const r=r_(t[0],t[1],t[2]),a=y_(t[3],t[4],t[5],t[6]),s=r_(n[0],n[1],n[2]),o=y_(n[3],n[4],n[5],n[6]);u_(this[w_].vec3,r,s,i),g_(this[w_].quat,a,o,i),Qx(e[G_].offsetMatrix,this[w_].quat,this[w_].vec3)}processRawInputData(e){const t=e[0],n=this[w_].inputSchemas.get(t),i={targetRayTransform:e.slice(1,8)};let r=8;if(n.hasGrip&&(i.gripTransform=e[r++]),n.hasHand&&(i.handTransforms=e[r++]),n.hasGamepad){const t=e[r];i.buttons=t.slice(0,n.numButtons),i.axes=t.slice(n.numButtons)}return{index:t,inputData:i}}}const ww="2.2.0";class Sw extends Event{constructor(e,t){if(super(e,t),!t.referenceSpace)throw new Error("XRReferenceSpaceEventInit.referenceSpace is required");this.referenceSpace=t.referenceSpace,this.transform=t.transform}}class Mw extends EventTarget{constructor(e){super(),this[P_]={device:e,grantSession:({resolve:e,reject:t,mode:n,options:i})=>{if(this[P_].activeSession)return void t(new DOMException("An active XRSession already exists.","InvalidStateError"));const{requiredFeatures:r=[],optionalFeatures:a=[]}=i,{supportedFeatures:s}=this[P_].device;if(!r.every(e=>s.includes(e)))return void t(new Error("One or more required features are not supported by the device."));const o=a.filter(e=>s.includes(e)),l=Array.from(new Set([...r,...o,"viewer","local"])),c=new tw(this[P_].device,n,l);this[P_].activeSession=c,c.addEventListener("end",()=>{this[P_].activeSession=void 0}),e(c)}}}isSessionSupported(e){return new Promise((t,n)=>{t("inline"===e||this[P_].device.supportedSessionModes.includes(e))})}requestSession(e,t={}){return new Promise((n,i)=>{this.isSessionSupported(e).then(r=>{if(!r)return void i(new DOMException("The requested XRSession mode is not supported.","NotSupportedError"));const a={resolve:n,reject:i,mode:e,options:t};this[P_].grantSession(a)}).catch(i)})}offerSession(e,t={}){return new Promise((n,i)=>{this.isSessionSupported(e).then(r=>{r?this[P_].offeredSessionConfig={resolve:n,reject:i,mode:e,options:t}:i(new DOMException("The requested XRSession mode is not supported.","NotSupportedError"))}).catch(i)})}}class Ew{constructor(e,t,n,i){this[W_]={x:e,y:t,width:n,height:i}}get x(){return this[W_].x}get y(){return this[W_].y}get width(){return this[W_].width}get height(){return this[W_].height}}
|
|
395
|
+
function Df(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Nf(e){const t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=t.get(n);i&&(e.deleteBuffer(i.buffer),t.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const e=t.get(n);return void((!e||e.version<n.version)&&t.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}const r=t.get(n);if(void 0===r)t.set(n,function(t,n){const i=t.array,r=t.usage,a=i.byteLength,s=e.createBuffer();let o;if(e.bindBuffer(n,s),e.bufferData(n,i,r),t.onUploadCallback(),i instanceof Float32Array)o=e.FLOAT;else if("undefined"!=typeof Float16Array&&i instanceof Float16Array)o=e.HALF_FLOAT;else if(i instanceof Uint16Array)o=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(i instanceof Int16Array)o=e.SHORT;else if(i instanceof Uint32Array)o=e.UNSIGNED_INT;else if(i instanceof Int32Array)o=e.INT;else if(i instanceof Int8Array)o=e.BYTE;else if(i instanceof Uint8Array)o=e.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);o=e.UNSIGNED_BYTE}return{buffer:s,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version,size:a}}(n,i));else if(r.version<n.version){if(r.size!==n.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(t,n,i){const r=n.array,a=n.updateRanges;if(e.bindBuffer(i,t),0===a.length)e.bufferSubData(i,0,r);else{a.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<a.length;e++){const n=a[t],i=a[e];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):(++t,a[t]=i)}a.length=t+1;for(let t=0,n=a.length;t<n;t++){const n=a[t];e.bufferSubData(i,n.start*r.BYTES_PER_ELEMENT,r,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}(r.buffer,n,i),r.version=n.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ro}})),"undefined"!=typeof window&&(window.__THREE__IWER__?kc("WARNING: Multiple instances of Three.js being imported."):window.__THREE__IWER__=Ro);const Of={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 uv = vec2( roughness, dotNV );\n\treturn texture2D( dfgLUT, uv ).rg;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );\n\tvec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );\n\tvec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\tfloat depth = unpackRGBAToDepth( texture2D( depths, uv ) );\n\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\treturn step( depth, compare );\n\t\t#else\n\t\t\treturn step( compare, depth );\n\t\t#endif\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow( sampler2D shadow, vec2 uv, float compare ) {\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\tfloat hard_shadow = step( distribution.x, compare );\n\t\t#else\n\t\t\tfloat hard_shadow = step( compare, distribution.x );\n\t\t#endif\n\t\tif ( hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},kf={common:{diffuse:{value:new zd(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Jc},alphaMap:{value:null},alphaMapTransform:{value:new Jc},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Jc}},envmap:{envMap:{value:null},envMapRotation:{value:new Jc},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Jc}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Jc}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Jc},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Jc},normalScale:{value:new $c(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Jc},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Jc}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Jc}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Jc}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new zd(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new zd(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Jc},alphaTest:{value:0},uvTransform:{value:new Jc}},sprite:{diffuse:{value:new zd(16777215)},opacity:{value:1},center:{value:new $c(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Jc},alphaMap:{value:null},alphaMapTransform:{value:new Jc},alphaTest:{value:0}}},Uf={basic:{uniforms:_h([kf.common,kf.specularmap,kf.envmap,kf.aomap,kf.lightmap,kf.fog]),vertexShader:Of.meshbasic_vert,fragmentShader:Of.meshbasic_frag},lambert:{uniforms:_h([kf.common,kf.specularmap,kf.envmap,kf.aomap,kf.lightmap,kf.emissivemap,kf.bumpmap,kf.normalmap,kf.displacementmap,kf.fog,kf.lights,{emissive:{value:new zd(0)}}]),vertexShader:Of.meshlambert_vert,fragmentShader:Of.meshlambert_frag},phong:{uniforms:_h([kf.common,kf.specularmap,kf.envmap,kf.aomap,kf.lightmap,kf.emissivemap,kf.bumpmap,kf.normalmap,kf.displacementmap,kf.fog,kf.lights,{emissive:{value:new zd(0)},specular:{value:new zd(1118481)},shininess:{value:30}}]),vertexShader:Of.meshphong_vert,fragmentShader:Of.meshphong_frag},standard:{uniforms:_h([kf.common,kf.envmap,kf.aomap,kf.lightmap,kf.emissivemap,kf.bumpmap,kf.normalmap,kf.displacementmap,kf.roughnessmap,kf.metalnessmap,kf.fog,kf.lights,{emissive:{value:new zd(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Of.meshphysical_vert,fragmentShader:Of.meshphysical_frag},toon:{uniforms:_h([kf.common,kf.aomap,kf.lightmap,kf.emissivemap,kf.bumpmap,kf.normalmap,kf.displacementmap,kf.gradientmap,kf.fog,kf.lights,{emissive:{value:new zd(0)}}]),vertexShader:Of.meshtoon_vert,fragmentShader:Of.meshtoon_frag},matcap:{uniforms:_h([kf.common,kf.bumpmap,kf.normalmap,kf.displacementmap,kf.fog,{matcap:{value:null}}]),vertexShader:Of.meshmatcap_vert,fragmentShader:Of.meshmatcap_frag},points:{uniforms:_h([kf.points,kf.fog]),vertexShader:Of.points_vert,fragmentShader:Of.points_frag},dashed:{uniforms:_h([kf.common,kf.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Of.linedashed_vert,fragmentShader:Of.linedashed_frag},depth:{uniforms:_h([kf.common,kf.displacementmap]),vertexShader:Of.depth_vert,fragmentShader:Of.depth_frag},normal:{uniforms:_h([kf.common,kf.bumpmap,kf.normalmap,kf.displacementmap,{opacity:{value:1}}]),vertexShader:Of.meshnormal_vert,fragmentShader:Of.meshnormal_frag},sprite:{uniforms:_h([kf.sprite,kf.fog]),vertexShader:Of.sprite_vert,fragmentShader:Of.sprite_frag},background:{uniforms:{uvTransform:{value:new Jc},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Of.background_vert,fragmentShader:Of.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Jc}},vertexShader:Of.backgroundCube_vert,fragmentShader:Of.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Of.cube_vert,fragmentShader:Of.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Of.equirect_vert,fragmentShader:Of.equirect_frag},distanceRGBA:{uniforms:_h([kf.common,kf.displacementmap,{referencePosition:{value:new Kc},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Of.distanceRGBA_vert,fragmentShader:Of.distanceRGBA_frag},shadow:{uniforms:_h([kf.lights,kf.fog,{color:{value:new zd(0)},opacity:{value:1}}]),vertexShader:Of.shadow_vert,fragmentShader:Of.shadow_frag}};Uf.physical={uniforms:_h([Uf.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Jc},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Jc},clearcoatNormalScale:{value:new $c(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Jc},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Jc},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Jc},sheen:{value:0},sheenColor:{value:new zd(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Jc},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Jc},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Jc},transmissionSamplerSize:{value:new $c},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Jc},attenuationDistance:{value:0},attenuationColor:{value:new zd(0)},specularColor:{value:new zd(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Jc},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Jc},anisotropyVector:{value:new $c},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Jc}}]),vertexShader:Of.meshphysical_vert,fragmentShader:Of.meshphysical_frag};const Ff={r:0,b:0,g:0},zf=new id,Bf=new qu;function Vf(e,t,n,i,r,a,s){const o=new zd(0);let l,c,u=!0===a?0:1,d=null,h=0,f=null;function p(e){let i=!0===e.isScene?e.background:null;if(i&&i.isTexture){i=(e.backgroundBlurriness>0?n:t).get(i)}return i}function m(t,n){t.getRGB(Ff,bh(e)),i.buffers.color.setClear(Ff.r,Ff.g,Ff.b,n,s)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),u=t,m(o,u)},getClearAlpha:function(){return u},setClearAlpha:function(e){u=e,m(o,u)},render:function(t){let n=!1;const r=p(t);null===r?m(o,u):r&&r.isColor&&(m(r,1),n=!0);const a=e.xr.getEnvironmentBlendMode();"additive"===a?i.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===a&&i.buffers.color.setClear(0,0,0,0,s),(e.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){const i=p(n);i&&(i.isCubeTexture||i.mapping===sl)?(void 0===c&&(c=new gh(new yh(1e4,1e4,1e4),new Sh({name:"BackgroundCubeMaterial",uniforms:xh(Uf.backgroundCube.uniforms),vertexShader:Uf.backgroundCube.vertexShader,fragmentShader:Uf.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),zf.copy(n.backgroundRotation),zf.x*=-1,zf.y*=-1,zf.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(zf.y*=-1,zf.z*=-1),c.material.uniforms.envMap.value=i,c.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Bf.makeRotationFromEuler(zf)),c.material.toneMapped=ru.getTransfer(i.colorSpace)!==yc,d===i&&h===i.version&&f===e.toneMapping||(c.material.needsUpdate=!0,d=i,h=i.version,f=e.toneMapping),c.layers.enableAll(),t.unshift(c,c.geometry,c.material,0,0,null)):i&&i.isTexture&&(void 0===l&&(l=new gh(new df(2,2),new Sh({name:"BackgroundMaterial",uniforms:xh(Uf.background.uniforms),vertexShader:Uf.background.vertexShader,fragmentShader:Uf.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=i,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=ru.getTransfer(i.colorSpace)!==yc,!0===i.matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),d===i&&h===i.version&&f===e.toneMapping||(l.material.needsUpdate=!0,d=i,h=i.version,f=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null))},dispose:function(){void 0!==c&&(c.geometry.dispose(),c.material.dispose(),c=void 0),void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}}}function Hf(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=c(null);let a=r,s=!1;function o(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function c(e){const t=[],i=[],r=[];for(let e=0;e<n;e++)t[e]=0,i[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:r,object:e,attributes:{},index:null}}function u(){const e=a.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function d(e){h(e,0)}function h(t,n){const i=a.newAttributes,r=a.enabledAttributes,s=a.attributeDivisors;i[t]=1,0===r[t]&&(e.enableVertexAttribArray(t),r[t]=1),s[t]!==n&&(e.vertexAttribDivisor(t,n),s[t]=n)}function f(){const t=a.newAttributes,n=a.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function p(t,n,i,r,a,s,o){!0===o?e.vertexAttribIPointer(t,n,i,a,s):e.vertexAttribPointer(t,n,i,r,a,s)}function m(){g(),s=!0,a!==r&&(a=r,o(a.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(n,r,l,m,g){let v=!1;const y=function(t,n,r){const a=!0===r.wireframe;let s=i[t.id];void 0===s&&(s={},i[t.id]=s);let o=s[n.id];void 0===o&&(o={},s[n.id]=o);let l=o[a];void 0===l&&(l=c(e.createVertexArray()),o[a]=l);return l}(m,l,r);a!==y&&(a=y,o(a.object)),v=function(e,t,n,i){const r=a.attributes,s=t.attributes;let o=0;const l=n.getAttributes();for(const t in l){if(l[t].location>=0){const n=r[t];let i=s[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}}return a.attributesNum!==o||a.index!==i}(n,m,l,g),v&&function(e,t,n,i){const r={},s=t.attributes;let o=0;const l=n.getAttributes();for(const t in l){if(l[t].location>=0){let n=s[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,o++}}a.attributes=r,a.attributesNum=o,a.index=i}(n,m,l,g),null!==g&&t.update(g,e.ELEMENT_ARRAY_BUFFER),(v||s)&&(s=!1,function(n,i,r,a){u();const s=a.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const r=o[i];if(r.location>=0){let o=s[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,s=o.itemSize,l=t.get(o);if(void 0===l)continue;const c=l.buffer,u=l.type,f=l.bytesPerElement,m=u===e.INT||u===e.UNSIGNED_INT||o.gpuType===_l;if(o.isInterleavedBufferAttribute){const t=o.data,l=t.stride,g=o.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e<r.locationSize;e++)h(r.location+e,t.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<r.locationSize;e++)d(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<r.locationSize;e++)p(r.location+e,s/r.locationSize,u,i,l*f,(g+s/r.locationSize*e)*f,m)}else{if(o.isInstancedBufferAttribute){for(let e=0;e<r.locationSize;e++)h(r.location+e,o.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let e=0;e<r.locationSize;e++)d(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<r.locationSize;e++)p(r.location+e,s/r.locationSize,u,i,s*f,s/r.locationSize*e*f,m)}}else if(void 0!==l){const t=l[i];if(void 0!==t)switch(t.length){case 2:e.vertexAttrib2fv(r.location,t);break;case 3:e.vertexAttrib3fv(r.location,t);break;case 4:e.vertexAttrib4fv(r.location,t);break;default:e.vertexAttrib1fv(r.location,t)}}}}f()}(n,r,l,m),null!==g&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(g).buffer))},reset:m,resetDefaultState:g,dispose:function(){m();for(const e in i){const t=i[e];for(const e in t){const n=t[e];for(const e in n)l(n[e].object),delete n[e];delete t[e]}delete i[e]}},releaseStatesOfGeometry:function(e){if(void 0===i[e.id])return;const t=i[e.id];for(const e in t){const n=t[e];for(const e in n)l(n[e].object),delete n[e];delete t[e]}delete i[e.id]},releaseStatesOfProgram:function(e){for(const t in i){const n=i[t];if(void 0===n[e.id])continue;const r=n[e.id];for(const e in r)l(r[e].object),delete r[e];delete n[e.id]}},initAttributes:u,enableAttribute:d,disableUnusedAttributes:f}}function Gf(e,t,n){let i;function r(t,r,a){0!==a&&(e.drawArraysInstanced(i,t,r,a),n.update(r,i,a))}this.setMode=function(e){i=e},this.render=function(t,r){e.drawArrays(i,t,r),n.update(r,i,1)},this.renderInstances=r,this.renderMultiDraw=function(e,r,a){if(0===a)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,e,0,r,0,a);let s=0;for(let e=0;e<a;e++)s+=r[e];n.update(s,i,1)},this.renderMultiDrawInstances=function(e,a,s,o){if(0===s)return;const l=t.get("WEBGL_multi_draw");if(null===l)for(let t=0;t<e.length;t++)r(e[t],a[t],o[t]);else{l.multiDrawArraysInstancedWEBGL(i,e,0,a,0,o,0,s);let t=0;for(let e=0;e<s;e++)t+=a[e]*o[e];n.update(t,i,1)}}}function jf(e,t,n,i){let r;function a(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let s=void 0!==n.precision?n.precision:"highp";const o=a(s);o!==s&&(kc("WebGLRenderer:",s,"not supported, using",o,"instead."),s=o);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reversedDepthBuffer&&t.has("EXT_clip_control"),u=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,textureFormatReadable:function(t){return t===Cl||i.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===Sl&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(n!==gl&&i.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==wl&&!r)},precision:s,logarithmicDepthBuffer:l,reversedDepthBuffer:c,maxTextures:u,maxVertexTextures:d,maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:d>0,maxSamples:e.getParameter(e.MAX_SAMPLES)}}function Wf(e){const t=this;let n=null,i=0,r=!1,a=!1;const s=new Vh,o=new Jc,l={value:null,needsUpdate:!1};function c(e,n,i,r){const a=null!==e?e.length:0;let c=null;if(0!==a){if(c=l.value,!0!==r||null===c){const t=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,n=i;t!==a;++t,n+=4)s.copy(e[t]).applyMatrix4(r,o),s.normal.toArray(c,n),c[n+3]=s.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=a,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){const n=0!==e.length||t||0!==i||r;return r=t,i=e.length,n},this.beginShadows=function(){a=!0,c(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=c(e,t,0)},this.setState=function(s,o,u){const d=s.clippingPlanes,h=s.clipIntersection,f=s.clipShadows,p=e.get(s);if(!r||null===d||0===d.length||a&&!f)a?c(null):function(){l.value!==n&&(l.value=n,l.needsUpdate=i>0);t.numPlanes=i,t.numIntersection=0}();else{const e=a?0:i,t=4*e;let r=p.clippingState||null;l.value=r,r=c(d,o,t,u);for(let e=0;e!==t;++e)r[e]=n[e];p.clippingState=r,this.numIntersection=h?this.numPlanes:0,this.numPlanes+=e}}}function Xf(e){let t=new WeakMap;function n(e,t){return 303===t?e.mapping=rl:304===t&&(e.mapping=al),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping;if(303===a||304===a){if(t.has(r)){return n(t.get(r).texture,r.mapping)}{const a=r.image;if(a&&a.height>0){const s=new Ih(a.height);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}const qf=[.125,.215,.35,.446,.526,.582],$f=20,Yf=new yf,Kf=new zd;let Zf=null,Qf=0,Jf=0,ep=!1;const tp=new Kc;class np{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,i=100,r={}){const{size:a=256,position:s=tp}=r;Zf=this._renderer.getRenderTarget(),Qf=this._renderer.getActiveCubeFace(),Jf=this._renderer.getActiveMipmapLevel(),ep=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(e,n,i,o,s),t>0&&this._blur(o,0,0,t),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=sp(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=ap(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Zf,Qf,Jf),this._renderer.xr.enabled=ep,e.scissorTest=!1,rp(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===rl||e.mapping===al?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Zf=this._renderer.getRenderTarget(),Qf=this._renderer.getActiveCubeFace(),Jf=this._renderer.getActiveMipmapLevel(),ep=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:fl,minFilter:fl,generateMipmaps:!1,type:Sl,format:Cl,colorSpace:gc,depthBuffer:!1},i=ip(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=ip(e,t,n);const{_lodMax:i}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(e){const t=[],n=[],i=[];let r=e;const a=e-4+1+qf.length;for(let s=0;s<a;s++){const a=Math.pow(2,r);t.push(a);let o=1/a;s>e-4?o=qf[s-e+4-1]:0===s&&(o=0),n.push(o);const l=1/(a-2),c=-l,u=1+l,d=[c,c,u,c,u,u,c,c,u,u,c,u],h=6,f=6,p=3,m=2,g=1,v=new Float32Array(p*f*h),y=new Float32Array(m*f*h),x=new Float32Array(g*f*h);for(let e=0;e<h;e++){const t=e%3*2/3-1,n=e>2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(i,p*f*e),y.set(d,m*f*e);const r=[e,e,e,e,e,e];x.set(r,g*f*e)}const _=new rh;_.setAttribute("position",new qd(v,p)),_.setAttribute("uv",new qd(y,m)),_.setAttribute("faceIndex",new qd(x,g)),i.push(new gh(_,null)),r>4&&r--}return{lodMeshes:i,sizeLods:t,sigmas:n}}(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array($f),r=new Kc(0,1,0),a=new Sh({name:"SphericalGaussianBlur",defines:{n:$f,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:op(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return a}(i,e,t)}return i}_compileMaterial(e){const t=new gh(new rh,e);this._renderer.compile(t,Yf)}_sceneToCubeUV(e,t,n,i,r){const a=new Rh(90,1,t,n),s=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear,u=l.toneMapping;l.getClearColor(Kf),l.toneMapping=0,l.autoClear=!1;l.state.buffers.depth.getReversed()&&(l.setRenderTarget(i),l.clearDepth(),l.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new gh(new yh,new Gd({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));const d=this._backgroundBox,h=d.material;let f=!1;const p=e.background;p?p.isColor&&(h.color.copy(p),e.background=null,f=!0):(h.color.copy(Kf),f=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(a.up.set(0,s[t],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+o[t],r.y,r.z)):1===n?(a.up.set(0,0,s[t]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+o[t],r.z)):(a.up.set(0,s[t],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+o[t]));const c=this._cubeSize;rp(i,n*c,t>2?c:0,c,c),l.setRenderTarget(i),f&&l.render(d,a),l.render(e,a)}l.toneMapping=u,l.autoClear=c,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===rl||e.mapping===al;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=sp()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=ap());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;r.uniforms.envMap.value=e;const s=this._cubeSize;rp(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,Yf)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let t=1;t<i;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=n}_applyGGXFilter(e,t,n){const i=this._renderer,r=this._pingPongRenderTarget;if(null===this._ggxMaterial){const e=3*Math.max(this._cubeSize,16),t=4*this._cubeSize;this._ggxMaterial=function(e,t,n){const i=new Sh({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:op(),fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 3.2: Transform view direction to hemisphere configuration\n\t\t\t\tvec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tfloat lensq = Vh.x * Vh.x + Vh.y * Vh.y;\n\t\t\t\tvec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(Vh, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + Vh.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:0,depthTest:!1,depthWrite:!1});return i}(this._lodMax,e,t)}const a=this._ggxMaterial,s=this._lodMeshes[n];s.material=a;const o=a.uniforms,l=n/(this._lodMeshes.length-1),c=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-c*c)*(.05+.95*l),{_lodMax:d}=this,h=this._sizeLods[n],f=3*h*(n>d-4?n-d+4:0),p=4*(this._cubeSize-h);o.envMap.value=e.texture,o.roughness.value=u,o.mipInt.value=d-t,rp(r,f,p,3*h,2*h),i.setRenderTarget(r),i.render(s,Yf),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=d-n,rp(e,f,p,3*h,2*h),i.setRenderTarget(e),i.render(s,Yf)}_blur(e,t,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,s){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&Uc("blur direction must be either latitudinal or longitudinal!");const c=this._lodMeshes[i];c.material=l;const u=l.uniforms,d=this._sizeLods[n]-1,h=isFinite(r)?Math.PI/(2*d):2*Math.PI/39,f=r/h,p=isFinite(r)?1+Math.floor(3*f):$f;p>$f&&kc(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<$f;++e){const t=e/f,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:e<p&&(g+=2*n)}for(let e=0;e<m.length;e++)m[e]=m[e]/g;u.envMap.value=e.texture,u.samples.value=p,u.weights.value=m,u.latitudinal.value="latitudinal"===a,s&&(u.poleAxis.value=s);const{_lodMax:v}=this;u.dTheta.value=h,u.mipInt.value=v-n;const y=this._sizeLods[i];rp(t,3*y*(i>v-4?i-v+4:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(t),o.render(c,Yf)}}function ip(e,t,n){const i=new vu(e,t,n);return i.texture.mapping=sl,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function rp(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function ap(){return new Sh({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:op(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function sp(){return new Sh({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:op(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function op(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function lp(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping,s=303===a||304===a,o=a===rl||a===al;if(s||o){let a=t.get(r);const l=void 0!==a?a.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new np(e)),a=s?n.fromEquirectangular(r,a):n.fromCubemap(r,a),a.texture.pmremVersion=r.pmremVersion,t.set(r,a),a.texture;if(void 0!==a)return a.texture;{const l=r.image;return s&&l&&l.height>0||o&&l&&function(e){let t=0;const n=6;for(let i=0;i<n;i++)void 0!==e[i]&&t++;return t===n}(l)?(null===n&&(n=new np(e)),a=s?n.fromEquirectangular(r):n.fromCubemap(r),a.texture.pmremVersion=r.pmremVersion,t.set(r,a),r.addEventListener("dispose",i),a.texture):null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function cp(e){const t={};function n(n){if(void 0!==t[n])return t[n];const i=e.getExtension(n);return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){const t=n(e);return null===t&&Fc("WebGLRenderer: "+e+" extension not supported."),t}}}function up(e,t,n,i){const r={},a=new WeakMap;function s(e){const o=e.target;null!==o.index&&t.remove(o.index);for(const e in o.attributes)t.remove(o.attributes[e]);o.removeEventListener("dispose",s),delete r[o.id];const l=a.get(o);l&&(t.remove(l),a.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(e){const n=[],i=e.index,r=e.attributes.position;let s=0;if(null!==i){const e=i.array;s=i.version;for(let t=0,i=e.length;t<i;t+=3){const i=e[t+0],r=e[t+1],a=e[t+2];n.push(i,r,r,a,a,i)}}else{if(void 0===r)return;{const e=r.array;s=r.version;for(let t=0,i=e.length/3-1;t<i;t+=3){const e=t+0,i=t+1,r=t+2;n.push(e,i,i,r,r,e)}}}const o=new(Lc(n)?Yd:$d)(n,1);o.version=s;const l=a.get(e);l&&t.remove(l),a.set(e,o)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",s),r[t.id]=!0,n.memory.geometries++),t},update:function(n){const i=n.attributes;for(const n in i)t.update(i[n],e.ARRAY_BUFFER)},getWireframeAttribute:function(e){const t=a.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&o(e)}else o(e);return a.get(e)}}}function dp(e,t,n){let i,r,a;function s(t,s,o){0!==o&&(e.drawElementsInstanced(i,s,r,t*a,o),n.update(s,i,o))}this.setMode=function(e){i=e},this.setIndex=function(e){r=e.type,a=e.bytesPerElement},this.render=function(t,s){e.drawElements(i,s,r,t*a),n.update(s,i,1)},this.renderInstances=s,this.renderMultiDraw=function(e,a,s){if(0===s)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,a,0,r,e,0,s);let o=0;for(let e=0;e<s;e++)o+=a[e];n.update(o,i,1)},this.renderMultiDrawInstances=function(e,o,l,c){if(0===l)return;const u=t.get("WEBGL_multi_draw");if(null===u)for(let t=0;t<e.length;t++)s(e[t]/a,o[t],c[t]);else{u.multiDrawElementsInstancedWEBGL(i,o,0,r,e,0,c,0,l);let t=0;for(let e=0;e<l;e++)t+=o[e]*c[e];n.update(t,i,1)}}}function hp(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,i,r){switch(t.calls++,i){case e.TRIANGLES:t.triangles+=r*(n/3);break;case e.LINES:t.lines+=r*(n/2);break;case e.LINE_STRIP:t.lines+=r*(n-1);break;case e.LINE_LOOP:t.lines+=r*n;break;case e.POINTS:t.points+=r*n;break;default:Uc("WebGLInfo: Unknown draw mode:",i)}}}}function fp(e,t,n){const i=new WeakMap,r=new mu;return{update:function(a,s,o){const l=a.morphTargetInfluences,c=s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color,u=void 0!==c?c.length:0;let d=i.get(s);if(void 0===d||d.count!==u){void 0!==d&&d.texture.dispose();const h=void 0!==s.morphAttributes.position,f=void 0!==s.morphAttributes.normal,p=void 0!==s.morphAttributes.color,m=s.morphAttributes.position||[],g=s.morphAttributes.normal||[],v=s.morphAttributes.color||[];let y=0;!0===h&&(y=1),!0===f&&(y=2),!0===p&&(y=3);let x=s.attributes.position.count*y,_=1;x>t.maxTextureSize&&(_=Math.ceil(x/t.maxTextureSize),x=t.maxTextureSize);const b=new Float32Array(x*_*4*u),w=new yu(b,x,_,u);w.type=wl,w.needsUpdate=!0;const S=4*y;for(let E=0;E<u;E++){const T=m[E],A=g[E],R=v[E],C=x*_*4*E;for(let P=0;P<T.count;P++){const L=P*S;!0===h&&(r.fromBufferAttribute(T,P),b[C+L+0]=r.x,b[C+L+1]=r.y,b[C+L+2]=r.z,b[C+L+3]=0),!0===f&&(r.fromBufferAttribute(A,P),b[C+L+4]=r.x,b[C+L+5]=r.y,b[C+L+6]=r.z,b[C+L+7]=0),!0===p&&(r.fromBufferAttribute(R,P),b[C+L+8]=r.x,b[C+L+9]=r.y,b[C+L+10]=r.z,b[C+L+11]=4===R.itemSize?r.w:1)}}function M(){w.dispose(),i.delete(s),s.removeEventListener("dispose",M)}d={count:u,texture:w,size:new $c(x,_)},i.set(s,d),s.addEventListener("dispose",M)}if(!0===a.isInstancedMesh&&null!==a.morphTexture)o.getUniforms().setValue(e,"morphTexture",a.morphTexture,n);else{let I=0;for(let N=0;N<l.length;N++)I+=l[N];const D=s.morphTargetsRelative?1:1-I;o.getUniforms().setValue(e,"morphTargetBaseInfluence",D),o.getUniforms().setValue(e,"morphTargetInfluences",l)}o.getUniforms().setValue(e,"morphTargetsTexture",d.texture,n),o.getUniforms().setValue(e,"morphTargetsTextureSize",d.size)}}}class pp{constructor(e,t,n){if(this.renderer=e,this.DEFAULT_NUMVIEWS=2,this.maxNumViews=0,this.gl=n,this.extensions=t,this.available=this.extensions.has("OCULUS_multiview"),this.available){const e=this.extensions.get("OCULUS_multiview");this.maxNumViews=this.gl.getParameter(e.MAX_VIEWS_OVR),this.mat4=[],this.mat3=[],this.cameraArray=[];for(var i=0;i<this.maxNumViews;i++)this.mat4[i]=new qu,this.mat3[i]=new Jc}}getCameraArray(e){return e.isArrayCamera?e.cameras:(this.cameraArray[0]=e,this.cameraArray)}updateCameraProjectionMatricesUniform(e,t){for(var n=this.getCameraArray(e),i=0;i<n.length;i++)this.mat4[i].copy(n[i].projectionMatrix);t.setValue(this.gl,"projectionMatrices",this.mat4)}updateCameraViewMatricesUniform(e,t){for(var n=this.getCameraArray(e),i=0;i<n.length;i++)this.mat4[i].copy(n[i].matrixWorldInverse);t.setValue(this.gl,"viewMatrices",this.mat4)}updateObjectMatricesUniforms(e,t,n){for(var i=this.getCameraArray(t),r=0;r<i.length;r++)this.mat4[r].multiplyMatrices(i[r].matrixWorldInverse,e.matrixWorld),this.mat3[r].getNormalMatrix(this.mat4[r]);n.setValue(this.gl,"modelViewMatrices",this.mat4),n.setValue(this.gl,"normalMatrices",this.mat3)}}function mp(e,t,n,i){let r=new WeakMap;function a(e){const t=e.target;t.removeEventListener("dispose",a),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(s){const o=i.render.frame,l=s.geometry,c=t.get(s,l);if(r.get(c)!==o&&(t.update(c),r.set(c,o)),s.isInstancedMesh&&(!1===s.hasEventListener("dispose",a)&&s.addEventListener("dispose",a),r.get(s)!==o&&(n.update(s.instanceMatrix,e.ARRAY_BUFFER),null!==s.instanceColor&&n.update(s.instanceColor,e.ARRAY_BUFFER),r.set(s,o))),s.isSkinnedMesh){const e=s.skeleton;r.get(e)!==o&&(e.update(),r.set(e,o))}return c},dispose:function(){r=new WeakMap}}}const gp=new pu,vp=new sf(1,1),yp=new yu,xp=new xu,_p=new Lh,bp=[],wp=[],Sp=new Float32Array(16),Mp=new Float32Array(9),Ep=new Float32Array(4);function Tp(e,t,n){const i=e[0];if(i<=0||i>0)return e;const r=t*n;let a=bp[r];if(void 0===a&&(a=new Float32Array(r),bp[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function Ap(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function Rp(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Cp(e,t){let n=wp[t];void 0===n&&(n=new Int32Array(t),wp[t]=n);for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function Pp(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function Lp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Ap(n,t))return;e.uniform2fv(this.addr,t),Rp(n,t)}}function Ip(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(Ap(n,t))return;e.uniform3fv(this.addr,t),Rp(n,t)}}function Dp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Ap(n,t))return;e.uniform4fv(this.addr,t),Rp(n,t)}}function Np(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Ap(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Rp(n,t)}else{if(Ap(n,i))return;Ep.set(i),e.uniformMatrix2fv(this.addr,!1,Ep),Rp(n,i)}}function Op(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Ap(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Rp(n,t)}else{if(Ap(n,i))return;Mp.set(i),e.uniformMatrix3fv(this.addr,!1,Mp),Rp(n,i)}}function kp(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Ap(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Rp(n,t)}else{if(Ap(n,i))return;Sp.set(i),e.uniformMatrix4fv(this.addr,!1,Sp),Rp(n,i)}}function Up(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function Fp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Ap(n,t))return;e.uniform2iv(this.addr,t),Rp(n,t)}}function zp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Ap(n,t))return;e.uniform3iv(this.addr,t),Rp(n,t)}}function Bp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Ap(n,t))return;e.uniform4iv(this.addr,t),Rp(n,t)}}function Vp(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function Hp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Ap(n,t))return;e.uniform2uiv(this.addr,t),Rp(n,t)}}function Gp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Ap(n,t))return;e.uniform3uiv(this.addr,t),Rp(n,t)}}function jp(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Ap(n,t))return;e.uniform4uiv(this.addr,t),Rp(n,t)}}function Wp(e,t,n){const i=this.cache,r=n.allocateTextureUnit();let a;i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),this.type===e.SAMPLER_2D_SHADOW?(vp.compareFunction=515,a=vp):a=gp,n.setTexture2D(t||a,r)}function Xp(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(t||xp,r)}function qp(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(t||_p,r)}function $p(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(t||yp,r)}function Yp(e,t){e.uniform1fv(this.addr,t)}function Kp(e,t){const n=Tp(t,this.size,2);e.uniform2fv(this.addr,n)}function Zp(e,t){const n=Tp(t,this.size,3);e.uniform3fv(this.addr,n)}function Qp(e,t){const n=Tp(t,this.size,4);e.uniform4fv(this.addr,n)}function Jp(e,t){const n=Tp(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function em(e,t){const n=Tp(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function tm(e,t){const n=Tp(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function nm(e,t){e.uniform1iv(this.addr,t)}function im(e,t){e.uniform2iv(this.addr,t)}function rm(e,t){e.uniform3iv(this.addr,t)}function am(e,t){e.uniform4iv(this.addr,t)}function sm(e,t){e.uniform1uiv(this.addr,t)}function om(e,t){e.uniform2uiv(this.addr,t)}function lm(e,t){e.uniform3uiv(this.addr,t)}function cm(e,t){e.uniform4uiv(this.addr,t)}function um(e,t,n){const i=this.cache,r=t.length,a=Cp(n,r);Ap(i,a)||(e.uniform1iv(this.addr,a),Rp(i,a));for(let e=0;e!==r;++e)n.setTexture2D(t[e]||gp,a[e])}function dm(e,t,n){const i=this.cache,r=t.length,a=Cp(n,r);Ap(i,a)||(e.uniform1iv(this.addr,a),Rp(i,a));for(let e=0;e!==r;++e)n.setTexture3D(t[e]||xp,a[e])}function hm(e,t,n){const i=this.cache,r=t.length,a=Cp(n,r);Ap(i,a)||(e.uniform1iv(this.addr,a),Rp(i,a));for(let e=0;e!==r;++e)n.setTextureCube(t[e]||_p,a[e])}function fm(e,t,n){const i=this.cache,r=t.length,a=Cp(n,r);Ap(i,a)||(e.uniform1iv(this.addr,a),Rp(i,a));for(let e=0;e!==r;++e)n.setTexture2DArray(t[e]||yp,a[e])}class pm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=function(e){switch(e){case 5126:return Pp;case 35664:return Lp;case 35665:return Ip;case 35666:return Dp;case 35674:return Np;case 35675:return Op;case 35676:return kp;case 5124:case 35670:return Up;case 35667:case 35671:return Fp;case 35668:case 35672:return zp;case 35669:case 35673:return Bp;case 5125:return Vp;case 36294:return Hp;case 36295:return Gp;case 36296:return jp;case 35678:case 36198:case 36298:case 36306:case 35682:return Wp;case 35679:case 36299:case 36307:return Xp;case 35680:case 36300:case 36308:case 36293:return qp;case 36289:case 36303:case 36311:case 36292:return $p}}(t.type)}}class mm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return Yp;case 35664:return Kp;case 35665:return Zp;case 35666:return Qp;case 35674:return Jp;case 35675:return em;case 35676:return tm;case 5124:case 35670:return nm;case 35667:case 35671:return im;case 35668:case 35672:return rm;case 35669:case 35673:return am;case 5125:return sm;case 36294:return om;case 36295:return lm;case 36296:return cm;case 35678:case 36198:case 36298:case 36306:case 35682:return um;case 35679:case 36299:case 36307:return dm;case 35680:case 36300:case 36308:case 36293:return hm;case 36289:case 36303:case 36311:case 36292:return fm}}(t.type)}}class gm{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const a=i[r];a.setValue(e,t[a.id],n)}}}const vm=/(\w+)(\])?(\[|\.)?/g;function ym(e,t){e.seq.push(t),e.map[t.id]=t}function xm(e,t,n){const i=e.name,r=i.length;for(vm.lastIndex=0;;){const a=vm.exec(i),s=vm.lastIndex;let o=a[1];const l="]"===a[2],c=a[3];if(l&&(o|=0),void 0===c||"["===c&&s+2===r){ym(n,void 0===c?new pm(o,e,t):new mm(o,e,t));break}{let e=n.map[o];void 0===e&&(e=new gm(o),ym(n,e)),n=e}}}class _m{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const n=e.getActiveUniform(t,i);xm(n,e.getUniformLocation(t,n.name),this)}}setValue(e,t,n,i){const r=this.map[t];void 0!==r&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];void 0!==i&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){const a=t[r],s=n[a.id];!1!==s.needsUpdate&&a.setValue(e,s.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const r=e[i];r.id in t&&n.push(r)}return n}}function bm(e,t,n){const i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}let wm=0;const Sm=new Jc;function Mm(e,t,n){const i=e.getShaderParameter(t,e.COMPILE_STATUS),r=(e.getShaderInfoLog(t)||"").trim();if(i&&""===r)return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const i=parseInt(a[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(e,t){const n=e.split("\n"),i=[],r=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=r;e<a;e++){const r=e+1;i.push(`${r===t?">":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function Em(e,t){const n=function(e){ru._getMatrix(Sm,ru.workingColorSpace,e);const t=`mat3( ${Sm.elements.map(e=>e.toFixed(4))} )`;switch(ru.getTransfer(e)){case vc:return[t,"LinearTransferOETF"];case yc:return[t,"sRGBTransferOETF"];default:return kc("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(t);return[`vec4 ${e}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}function Tm(e,t){let n;switch(t){case 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="Cineon";break;case 4:n="ACESFilmic";break;case 6:n="AgX";break;case 7:n="Neutral";break;case 5:n="Custom";break;default:kc("WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Am=new Kc;function Rm(){ru.getLuminanceCoefficients(Am);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${Am.x.toFixed(4)}, ${Am.y.toFixed(4)}, ${Am.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function Cm(e){return""!==e}function Pm(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Lm(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Im=/^[ \t]*#include +<([\w\d./]+)>/gm;function Dm(e){return e.replace(Im,Om)}const Nm=new Map;function Om(e,t){let n=Of[t];if(void 0===n){const e=Nm.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=Of[e],kc('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return Dm(n)}const km=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Um(e){return e.replace(km,Fm)}function Fm(e,t,n,i){let r="";for(let e=parseInt(t);e<parseInt(n);e++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return r}function zm(e){let t=`precision ${e.precision} float;\n\tprecision ${e.precision} int;\n\tprecision ${e.precision} sampler2D;\n\tprecision ${e.precision} samplerCube;\n\tprecision ${e.precision} sampler3D;\n\tprecision ${e.precision} sampler2DArray;\n\tprecision ${e.precision} sampler2DShadow;\n\tprecision ${e.precision} samplerCubeShadow;\n\tprecision ${e.precision} sampler2DArrayShadow;\n\tprecision ${e.precision} isampler2D;\n\tprecision ${e.precision} isampler3D;\n\tprecision ${e.precision} isamplerCube;\n\tprecision ${e.precision} isampler2DArray;\n\tprecision ${e.precision} usampler2D;\n\tprecision ${e.precision} usampler3D;\n\tprecision ${e.precision} usamplerCube;\n\tprecision ${e.precision} usampler2DArray;\n\t`;return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function Bm(e,t,n,i){const r=e.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const l=function(e){let t="SHADOWMAP_TYPE_BASIC";return 1===e.shadowMapType?t="SHADOWMAP_TYPE_PCF":2===e.shadowMapType?t="SHADOWMAP_TYPE_PCF_SOFT":3===e.shadowMapType&&(t="SHADOWMAP_TYPE_VSM"),t}(n),c=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case rl:case al:t="ENVMAP_TYPE_CUBE";break;case sl:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),u=function(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===al&&(t="ENVMAP_MODE_REFRACTION");return t}(n),d=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case 0:t="ENVMAP_BLENDING_MULTIPLY";break;case 1:t="ENVMAP_BLENDING_MIX";break;case 2:t="ENVMAP_BLENDING_ADD"}return t}(n),h=function(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),f=function(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Cm).join("\n")}(n),p=function(e){const t=[];for(const n in e){const i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(a),m=r.createProgram();let g,v,y=n.glslVersion?"#version "+n.glslVersion+"\n":"";const x=n.numMultiviewViews;n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,p].filter(Cm).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,p].filter(Cm).join("\n"),v.length>0&&(v+="\n")):(g=[zm(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,p,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Cm).join("\n"),v=[zm(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,p,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?Of.tonemapping_pars_fragment:"",0!==n.toneMapping?Tm("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Of.colorspace_pars_fragment,Em("linearToOutputTexel",n.outputColorSpace),Rm(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Cm).join("\n")),s=Dm(s),s=Pm(s,n),s=Lm(s,n),o=Dm(o),o=Pm(o,n),o=Lm(o,n),s=Um(s),o=Um(o),!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===Rc?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Rc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v,x>0&&(g=["#extension GL_OVR_multiview : require","layout(num_views = "+x+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n")+"\n"+g,g=g.replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join("\n"),["uniform mat4 modelViewMatrices["+x+"];","uniform mat4 projectionMatrices["+x+"];","uniform mat4 viewMatrices["+x+"];","uniform mat3 normalMatrices["+x+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join("\n")),v=["#extension GL_OVR_multiview : require","#define VIEW_ID gl_ViewID_OVR"].join("\n")+"\n"+v,v=v.replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+x+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n"))));const _=y+g+s,b=y+v+o,w=bm(r,r.VERTEX_SHADER,_),S=bm(r,r.FRAGMENT_SHADER,b);function M(t){if(e.debug.checkShaderErrors){const n=r.getProgramInfoLog(m)||"",i=r.getShaderInfoLog(w)||"",a=r.getShaderInfoLog(S)||"",s=n.trim(),o=i.trim(),l=a.trim();let c=!0,u=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(c=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(r,m,w,S);else{const e=Mm(r,w,"vertex"),n=Mm(r,S,"fragment");Uc("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+s+"\n"+e+"\n"+n)}else""!==s?kc("WebGLProgram: Program Info Log:",s):""!==o&&""!==l||(u=!1);u&&(t.diagnostics={runnable:c,programLog:s,vertexShader:{log:o,prefix:g},fragmentShader:{log:l,prefix:v}})}r.deleteShader(w),r.deleteShader(S),E=new _m(r,m),T=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=e.getActiveAttrib(t,r),a=i.name;let s=1;i.type===e.FLOAT_MAT2&&(s=2),i.type===e.FLOAT_MAT3&&(s=3),i.type===e.FLOAT_MAT4&&(s=4),n[a]={type:i.type,location:e.getAttribLocation(t,a),locationSize:s}}return n}(r,m)}let E,T;r.attachShader(m,w),r.attachShader(m,S),void 0!==n.index0AttributeName?r.bindAttribLocation(m,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),this.getUniforms=function(){return void 0===E&&M(this),E},this.getAttributes=function(){return void 0===T&&M(this),T};let A=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===A&&(A=r.getProgramParameter(m,37297)),A},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=wm++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=S,this.numMultiviewViews=x,this}let Vm=0;class Hm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return!1===a.has(i)&&(a.add(i),i.usedTimes++),!1===a.has(r)&&(a.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return void 0===n&&(n=new Gm(e),t.set(e,n)),n}}class Gm{constructor(e){this.id=Vm++,this.code=e,this.usedTimes=0}}function jm(e,t,n,i,r,a,s){const o=new rd,l=new Hm,c=new Set,u=[],d=r.logarithmicDepthBuffer,h=r.vertexTextures;let f=r.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(e){return c.add(e),0===e?"uv":`uv${e}`}return{getParameters:function(a,o,u,g,v){const y=g.fog,x=v.geometry,_=a.isMeshStandardMaterial?g.environment:null,b=(a.isMeshStandardMaterial?n:t).get(a.envMap||_),w=b&&b.mapping===sl?b.image.height:null,S=p[a.type];null!==a.precision&&(f=r.getMaxPrecision(a.precision),f!==a.precision&&kc("WebGLProgram.getParameters:",a.precision,"not supported, using",f,"instead."));const M=x.morphAttributes.position||x.morphAttributes.normal||x.morphAttributes.color,E=void 0!==M?M.length:0;let T,A,R,C,P=0;if(void 0!==x.morphAttributes.position&&(P=1),void 0!==x.morphAttributes.normal&&(P=2),void 0!==x.morphAttributes.color&&(P=3),S){const e=Uf[S];T=e.vertexShader,A=e.fragmentShader}else T=a.vertexShader,A=a.fragmentShader,l.update(a),R=l.getVertexShaderID(a),C=l.getFragmentShaderID(a);const L=e.getRenderTarget(),I=e.state.buffers.depth.getReversed(),D=L&&L.isWebGLMultiviewRenderTarget?L.numViews:0,N=!0===v.isInstancedMesh,O=!0===v.isBatchedMesh,k=!!a.map,U=!!a.matcap,F=!!b,z=!!a.aoMap,B=!!a.lightMap,V=!!a.bumpMap,H=!!a.normalMap,G=!!a.displacementMap,j=!!a.emissiveMap,W=!!a.metalnessMap,X=!!a.roughnessMap,q=a.anisotropy>0,$=a.clearcoat>0,Y=a.dispersion>0,K=a.iridescence>0,Z=a.sheen>0,Q=a.transmission>0,J=q&&!!a.anisotropyMap,ee=$&&!!a.clearcoatMap,te=$&&!!a.clearcoatNormalMap,ne=$&&!!a.clearcoatRoughnessMap,ie=K&&!!a.iridescenceMap,re=K&&!!a.iridescenceThicknessMap,ae=Z&&!!a.sheenColorMap,se=Z&&!!a.sheenRoughnessMap,oe=!!a.specularMap,le=!!a.specularColorMap,ce=!!a.specularIntensityMap,ue=Q&&!!a.transmissionMap,de=Q&&!!a.thicknessMap,he=!!a.gradientMap,fe=!!a.alphaMap,pe=a.alphaTest>0,me=!!a.alphaHash,ge=!!a.extensions;let ve=0;a.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(ve=e.toneMapping));const ye={shaderID:S,shaderType:a.type,shaderName:a.name,vertexShader:T,fragmentShader:A,defines:a.defines,customVertexShaderID:R,customFragmentShaderID:C,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:f,batching:O,batchingColor:O&&null!==v._colorsTexture,instancing:N,instancingColor:N&&null!==v.instanceColor,instancingMorph:N&&null!==v.morphTexture,supportsVertexTextures:h,numMultiviewViews:D,outputColorSpace:null===L?e.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:gc,alphaToCoverage:!!a.alphaToCoverage,map:k,matcap:U,envMap:F,envMapMode:F&&b.mapping,envMapCubeUVHeight:w,aoMap:z,lightMap:B,bumpMap:V,normalMap:H,displacementMap:h&&G,emissiveMap:j,normalMapObjectSpace:H&&1===a.normalMapType,normalMapTangentSpace:H&&0===a.normalMapType,metalnessMap:W,roughnessMap:X,anisotropy:q,anisotropyMap:J,clearcoat:$,clearcoatMap:ee,clearcoatNormalMap:te,clearcoatRoughnessMap:ne,dispersion:Y,iridescence:K,iridescenceMap:ie,iridescenceThicknessMap:re,sheen:Z,sheenColorMap:ae,sheenRoughnessMap:se,specularMap:oe,specularColorMap:le,specularIntensityMap:ce,transmission:Q,transmissionMap:ue,thicknessMap:de,gradientMap:he,opaque:!1===a.transparent&&1===a.blending&&!1===a.alphaToCoverage,alphaMap:fe,alphaTest:pe,alphaHash:me,combine:a.combine,mapUv:k&&m(a.map.channel),aoMapUv:z&&m(a.aoMap.channel),lightMapUv:B&&m(a.lightMap.channel),bumpMapUv:V&&m(a.bumpMap.channel),normalMapUv:H&&m(a.normalMap.channel),displacementMapUv:G&&m(a.displacementMap.channel),emissiveMapUv:j&&m(a.emissiveMap.channel),metalnessMapUv:W&&m(a.metalnessMap.channel),roughnessMapUv:X&&m(a.roughnessMap.channel),anisotropyMapUv:J&&m(a.anisotropyMap.channel),clearcoatMapUv:ee&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:te&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ne&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:ie&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:re&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:se&&m(a.sheenRoughnessMap.channel),specularMapUv:oe&&m(a.specularMap.channel),specularColorMapUv:le&&m(a.specularColorMap.channel),specularIntensityMapUv:ce&&m(a.specularIntensityMap.channel),transmissionMapUv:ue&&m(a.transmissionMap.channel),thicknessMapUv:de&&m(a.thicknessMap.channel),alphaMapUv:fe&&m(a.alphaMap.channel),vertexTangents:!!x.attributes.tangent&&(H||q),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,pointsUvs:!0===v.isPoints&&!!x.attributes.uv&&(k||fe),fog:!!y,useFog:!0===a.fog,fogExp2:!!y&&y.isFogExp2,flatShading:!0===a.flatShading&&!1===a.wireframe,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:d,reversedDepthBuffer:I,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:E,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.length>0,shadowMapType:e.shadowMap.type,toneMapping:ve,decodeVideoTexture:k&&!0===a.map.isVideoTexture&&ru.getTransfer(a.map.colorSpace)===yc,decodeVideoTextureEmissive:j&&!0===a.emissiveMap.isVideoTexture&&ru.getTransfer(a.emissiveMap.colorSpace)===yc,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionClipCullDistance:ge&&!0===a.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&!0===a.extensions.multiDraw||O)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:a.customProgramCacheKey()};return ye.vertexUv1s=c.has(1),ye.vertexUv2s=c.has(2),ye.vertexUv3s=c.has(3),c.clear(),ye},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.supportsVertexTextures&&o.enable(0);t.instancing&&o.enable(1);t.instancingColor&&o.enable(2);t.instancingMorph&&o.enable(3);t.matcap&&o.enable(4);t.envMap&&o.enable(5);t.normalMapObjectSpace&&o.enable(6);t.normalMapTangentSpace&&o.enable(7);t.clearcoat&&o.enable(8);t.iridescence&&o.enable(9);t.alphaTest&&o.enable(10);t.vertexColors&&o.enable(11);t.vertexAlphas&&o.enable(12);t.vertexUv1s&&o.enable(13);t.vertexUv2s&&o.enable(14);t.vertexUv3s&&o.enable(15);t.vertexTangents&&o.enable(16);t.anisotropy&&o.enable(17);t.alphaHash&&o.enable(18);t.batching&&o.enable(19);t.dispersion&&o.enable(20);t.batchingColor&&o.enable(21);t.gradientMap&&o.enable(22);e.push(o.mask),o.disableAll(),t.fog&&o.enable(0);t.useFog&&o.enable(1);t.flatShading&&o.enable(2);t.logarithmicDepthBuffer&&o.enable(3);t.reversedDepthBuffer&&o.enable(4);t.skinning&&o.enable(5);t.morphTargets&&o.enable(6);t.morphNormals&&o.enable(7);t.morphColors&&o.enable(8);t.premultipliedAlpha&&o.enable(9);t.shadowMapEnabled&&o.enable(10);t.doubleSided&&o.enable(11);t.flipSided&&o.enable(12);t.useDepthPacking&&o.enable(13);t.dithering&&o.enable(14);t.transmission&&o.enable(15);t.sheen&&o.enable(16);t.opaque&&o.enable(17);t.pointsUvs&&o.enable(18);t.decodeVideoTexture&&o.enable(19);t.decodeVideoTextureEmissive&&o.enable(20);t.alphaToCoverage&&o.enable(21);t.numMultiviewViews&&o.enable(22);e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=p[e.type];let n;if(t){const e=Uf[t];n=wh.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=u.length;e<t;e++){const t=u[e];if(t.cacheKey===n){i=t,++i.usedTimes;break}}return void 0===i&&(i=new Bm(e,n,t,a),u.push(i)),i},releaseProgram:function(e){if(0===--e.usedTimes){const t=u.indexOf(e);u[t]=u[u.length-1],u.pop(),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:u,dispose:function(){l.dispose()}}}function Wm(){let e=new WeakMap;return{has:function(t){return e.has(t)},get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function Xm(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function qm(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function $m(){const e=[];let t=0;const n=[],i=[],r=[];function a(n,i,r,a,s,o){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:a,renderOrder:n.renderOrder,z:s,group:o},e[t]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=o),t++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){t=0,n.length=0,i.length=0,r.length=0},push:function(e,t,s,o,l,c){const u=a(e,t,s,o,l,c);s.transmission>0?i.push(u):!0===s.transparent?r.push(u):n.push(u)},unshift:function(e,t,s,o,l,c){const u=a(e,t,s,o,l,c);s.transmission>0?i.unshift(u):!0===s.transparent?r.unshift(u):n.unshift(u)},finish:function(){for(let n=t,i=e.length;n<i;n++){const t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){n.length>1&&n.sort(e||Xm),i.length>1&&i.sort(t||qm),r.length>1&&r.sort(t||qm)}}}function Ym(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new $m,e.set(t,[r])):n>=i.length?(r=new $m,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function Km(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Kc,color:new zd};break;case"SpotLight":n={position:new Kc,direction:new Kc,color:new zd,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Kc,color:new zd,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Kc,skyColor:new zd,groundColor:new zd};break;case"RectAreaLight":n={color:new zd,position:new Kc,halfWidth:new Kc,halfHeight:new Kc}}return e[t.id]=n,n}}}let Zm=0;function Qm(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Jm(e){const t=new Km,n=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $c};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $c,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),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 e=0;e<9;e++)i.probe.push(new Kc);const r=new Kc,a=new qu,s=new qu;return{setup:function(r){let a=0,s=0,o=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let l=0,c=0,u=0,d=0,h=0,f=0,p=0,m=0,g=0,v=0,y=0;r.sort(Qm);for(let e=0,x=r.length;e<x;e++){const x=r[e],_=x.color,b=x.intensity,w=x.distance,S=x.shadow&&x.shadow.map?x.shadow.map.texture:null;if(x.isAmbientLight)a+=_.r*b,s+=_.g*b,o+=_.b*b;else if(x.isLightProbe){for(let e=0;e<9;e++)i.probe[e].addScaledVector(x.sh.coefficients[e],b);y++}else if(x.isDirectionalLight){const e=t.get(x);if(e.color.copy(x.color).multiplyScalar(x.intensity),x.castShadow){const e=x.shadow,t=n.get(x);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,i.directionalShadow[l]=t,i.directionalShadowMap[l]=S,i.directionalShadowMatrix[l]=x.shadow.matrix,f++}i.directional[l]=e,l++}else if(x.isSpotLight){const e=t.get(x);e.position.setFromMatrixPosition(x.matrixWorld),e.color.copy(_).multiplyScalar(b),e.distance=w,e.coneCos=Math.cos(x.angle),e.penumbraCos=Math.cos(x.angle*(1-x.penumbra)),e.decay=x.decay,i.spot[u]=e;const r=x.shadow;if(x.map&&(i.spotLightMap[g]=x.map,g++,r.updateMatrices(x),x.castShadow&&v++),i.spotLightMatrix[u]=r.matrix,x.castShadow){const e=n.get(x);e.shadowIntensity=r.intensity,e.shadowBias=r.bias,e.shadowNormalBias=r.normalBias,e.shadowRadius=r.radius,e.shadowMapSize=r.mapSize,i.spotShadow[u]=e,i.spotShadowMap[u]=S,m++}u++}else if(x.isRectAreaLight){const e=t.get(x);e.color.copy(_).multiplyScalar(b),e.halfWidth.set(.5*x.width,0,0),e.halfHeight.set(0,.5*x.height,0),i.rectArea[d]=e,d++}else if(x.isPointLight){const e=t.get(x);if(e.color.copy(x.color).multiplyScalar(x.intensity),e.distance=x.distance,e.decay=x.decay,x.castShadow){const e=x.shadow,t=n.get(x);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,i.pointShadow[c]=t,i.pointShadowMap[c]=S,i.pointShadowMatrix[c]=x.shadow.matrix,p++}i.point[c]=e,c++}else if(x.isHemisphereLight){const e=t.get(x);e.skyColor.copy(x.color).multiplyScalar(b),e.groundColor.copy(x.groundColor).multiplyScalar(b),i.hemi[h]=e,h++}}d>0&&(!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=kf.LTC_FLOAT_1,i.rectAreaLTC2=kf.LTC_FLOAT_2):(i.rectAreaLTC1=kf.LTC_HALF_1,i.rectAreaLTC2=kf.LTC_HALF_2)),i.ambient[0]=a,i.ambient[1]=s,i.ambient[2]=o;const x=i.hash;x.directionalLength===l&&x.pointLength===c&&x.spotLength===u&&x.rectAreaLength===d&&x.hemiLength===h&&x.numDirectionalShadows===f&&x.numPointShadows===p&&x.numSpotShadows===m&&x.numSpotMaps===g&&x.numLightProbes===y||(i.directional.length=l,i.spot.length=u,i.rectArea.length=d,i.point.length=c,i.hemi.length=h,i.directionalShadow.length=f,i.directionalShadowMap.length=f,i.pointShadow.length=p,i.pointShadowMap.length=p,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=f,i.pointShadowMatrix.length=p,i.spotLightMatrix.length=m+g-v,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=v,i.numLightProbes=y,x.directionalLength=l,x.pointLength=c,x.spotLength=u,x.rectAreaLength=d,x.hemiLength=h,x.numDirectionalShadows=f,x.numPointShadows=p,x.numSpotShadows=m,x.numSpotMaps=g,x.numLightProbes=y,i.version=Zm++)},setupView:function(e,t){let n=0,o=0,l=0,c=0,u=0;const d=t.matrixWorldInverse;for(let t=0,h=e.length;t<h;t++){const h=e[t];if(h.isDirectionalLight){const e=i.directional[n];e.direction.setFromMatrixPosition(h.matrixWorld),r.setFromMatrixPosition(h.target.matrixWorld),e.direction.sub(r),e.direction.transformDirection(d),n++}else if(h.isSpotLight){const e=i.spot[l];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(d),e.direction.setFromMatrixPosition(h.matrixWorld),r.setFromMatrixPosition(h.target.matrixWorld),e.direction.sub(r),e.direction.transformDirection(d),l++}else if(h.isRectAreaLight){const e=i.rectArea[c];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(d),s.identity(),a.copy(h.matrixWorld),a.premultiply(d),s.extractRotation(a),e.halfWidth.set(.5*h.width,0,0),e.halfHeight.set(0,.5*h.height,0),e.halfWidth.applyMatrix4(s),e.halfHeight.applyMatrix4(s),c++}else if(h.isPointLight){const e=i.point[o];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(d),o++}else if(h.isHemisphereLight){const e=i.hemi[u];e.direction.setFromMatrixPosition(h.matrixWorld),e.direction.transformDirection(d),u++}}},state:i}}function eg(e){const t=new Jm(e),n=[],i=[];const r={lightsArray:n,shadowsArray:i,camera:null,lights:t,transmissionRenderTarget:{}};return{init:function(e){r.camera=e,n.length=0,i.length=0},state:r,setupLights:function(){t.setup(n)},setupLightsView:function(e){t.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){i.push(e)}}}function tg(e){let t=new WeakMap;return{get:function(n,i=0){const r=t.get(n);let a;return void 0===r?(a=new eg(e),t.set(n,[a])):i>=r.length?(a=new eg(e),r.push(a)):a=r[i],a},dispose:function(){t=new WeakMap}}}function ng(e,t,n){let i=new Wh;const r=new $c,a=new $c,s=new mu,o=new mf({depthPacking:3201}),l=new gf,c={},u=n.maxTextureSize,d={[Co]:1,[Po]:0,[Lo]:2},h=new Sh({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $c},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const p=new rh;p.setAttribute("position",new qd(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new gh(p,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function y(n,i){const a=t.update(m);h.defines.VSM_SAMPLES!==n.blurSamples&&(h.defines.VSM_SAMPLES=n.blurSamples,f.defines.VSM_SAMPLES=n.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new vu(r.x,r.y)),h.uniforms.shadow_pass.value=n.map.texture,h.uniforms.resolution.value=n.mapSize,h.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,a,h,m,null),f.uniforms.shadow_pass.value=n.mapPass.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,a,f,m,null)}function x(t,n,i,r){let a=null;const s=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){const e=a.uuid,t=n.uuid;let i=c[e];void 0===i&&(i={},c[e]=i);let r=i[t];void 0===r&&(r=a.clone(),i[t]=r,n.addEventListener("dispose",b)),a=r}if(a.visible=n.visible,a.wireframe=n.wireframe,a.side=3===r?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:d[n.side],a.alphaMap=n.alphaMap,a.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial){e.properties.get(a).light=i}return a}function _(n,r,a,s,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===o)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);const i=t.update(n),l=n.material;if(Array.isArray(l)){const t=i.groups;for(let c=0,u=t.length;c<u;c++){const u=t[c],d=l[u.materialIndex];if(d&&d.visible){const t=x(n,d,s,o);n.onBeforeShadow(e,n,r,a,i,t,u),e.renderBufferDirect(a,null,i,t,n,u),n.onAfterShadow(e,n,r,a,i,t,u)}}}else if(l.visible){const t=x(n,l,s,o);n.onBeforeShadow(e,n,r,a,i,t,null),e.renderBufferDirect(a,null,i,t,n,null),n.onAfterShadow(e,n,r,a,i,t,null)}}const l=n.children;for(let e=0,t=l.length;e<t;e++)_(l[e],r,a,s,o)}function b(e){e.target.removeEventListener("dispose",b);for(const t in c){const n=c[t],i=e.target.uuid;if(i in n){n[i].dispose(),delete n[i]}}}this.render=function(t,n,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===t.length)return;const l=e.getRenderTarget(),c=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),h=e.state;h.setBlending(0),!0===h.buffers.depth.getReversed()?h.buffers.color.setClear(0,0,0,0):h.buffers.color.setClear(1,1,1,1),h.buffers.depth.setTest(!0),h.setScissorTest(!1);const f=3!==v&&3===this.type,p=3===v&&3!==this.type;for(let l=0,c=t.length;l<c;l++){const c=t[l],d=c.shadow;if(void 0===d){kc("WebGLShadowMap:",c,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;r.copy(d.mapSize);const m=d.getFrameExtents();if(r.multiply(m),a.copy(d.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(a.x=Math.floor(u/m.x),r.x=a.x*m.x,d.mapSize.x=a.x),r.y>u&&(a.y=Math.floor(u/m.y),r.y=a.y*m.y,d.mapSize.y=a.y)),null===d.map||!0===f||!0===p){const e=3!==this.type?{minFilter:ul,magFilter:ul}:{};null!==d.map&&d.map.dispose(),d.map=new vu(r.x,r.y,e),d.map.texture.name=c.name+".shadowMap",d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();const g=d.getViewportCount();for(let e=0;e<g;e++){const t=d.getViewport(e);s.set(a.x*t.x,a.y*t.y,a.x*t.z,a.y*t.w),h.viewport(s),d.updateMatrices(c,e),i=d.getFrustum(),_(n,o,d.camera,c,this.type)}!0!==d.isPointLightShadow&&3===this.type&&y(d,o),d.needsUpdate=!1}v=this.type,g.needsUpdate=!1,e.setRenderTarget(l,c,d)}}const ig={[Ko]:1,[Qo]:6,[el]:7,[Jo]:5,[Zo]:0,[nl]:2,[il]:4,[tl]:3};function rg(e,t){const n=new function(){let t=!1;const n=new mu;let i=null;const r=new mu(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,a,s,o){!0===o&&(t*=s,i*=s,a*=s),n.set(t,i,a,s),!1===r.equals(n)&&(e.clearColor(t,i,a,s),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}},i=new function(){let n=!1,i=!1,r=null,a=null,s=null;return{setReversed:function(e){if(i!==e){const n=t.get("EXT_clip_control");e?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),i=e;const r=s;s=null,this.setClear(r)}},getReversed:function(){return i},setTest:function(t){t?B(e.DEPTH_TEST):V(e.DEPTH_TEST)},setMask:function(t){r===t||n||(e.depthMask(t),r=t)},setFunc:function(t){if(i&&(t=ig[t]),a!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:default:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL)}a=t}},setLocked:function(e){n=e},setClear:function(t){s!==t&&(i&&(t=1-t),e.clearDepth(t),s=t)},reset:function(){n=!1,r=null,a=null,s=null,i=!1}}},r=new function(){let t=!1,n=null,i=null,r=null,a=null,s=null,o=null,l=null,c=null;return{setTest:function(n){t||(n?B(e.STENCIL_TEST):V(e.STENCIL_TEST))},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,s){i===t&&r===n&&a===s||(e.stencilFunc(t,n,s),i=t,r=n,a=s)},setOp:function(t,n,i){s===t&&o===n&&l===i||(e.stencilOp(t,n,i),s=t,o=n,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,i=null,r=null,a=null,s=null,o=null,l=null,c=null}}},a=new WeakMap,s=new WeakMap;let o={},l={},c=new WeakMap,u=[],d=null,h=!1,f=null,p=null,m=null,g=null,v=null,y=null,x=null,_=new zd(0,0,0),b=0,w=!1,S=null,M=null,E=null,T=null,A=null;const R=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let C=!1,P=0;const L=e.getParameter(e.VERSION);-1!==L.indexOf("WebGL")?(P=parseFloat(/^WebGL (\d)/.exec(L)[1]),C=P>=1):-1!==L.indexOf("OpenGL ES")&&(P=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),C=P>=2);let I=null,D={};const N=e.getParameter(e.SCISSOR_BOX),O=e.getParameter(e.VIEWPORT),k=(new mu).fromArray(N),U=(new mu).fromArray(O);function F(t,n,i,r){const a=new Uint8Array(4),s=e.createTexture();e.bindTexture(t,s),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let s=0;s<i;s++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,r,0,e.RGBA,e.UNSIGNED_BYTE,a):e.texImage2D(n+s,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,a);return s}const z={};function B(t){!0!==o[t]&&(e.enable(t),o[t]=!0)}function V(t){!1!==o[t]&&(e.disable(t),o[t]=!1)}z[e.TEXTURE_2D]=F(e.TEXTURE_2D,e.TEXTURE_2D,1),z[e.TEXTURE_CUBE_MAP]=F(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),z[e.TEXTURE_2D_ARRAY]=F(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),z[e.TEXTURE_3D]=F(e.TEXTURE_3D,e.TEXTURE_3D,1,1),n.setClear(0,0,0,1),i.setClear(1),r.setClear(0),B(e.DEPTH_TEST),i.setFunc(3),W(!1),X(1),B(e.CULL_FACE),j(0);const H={[Io]:e.FUNC_ADD,[Do]:e.FUNC_SUBTRACT,[No]:e.FUNC_REVERSE_SUBTRACT};H[103]=e.MIN,H[104]=e.MAX;const G={[Oo]:e.ZERO,[ko]:e.ONE,[Uo]:e.SRC_COLOR,[zo]:e.SRC_ALPHA,[Wo]:e.SRC_ALPHA_SATURATE,[Go]:e.DST_COLOR,[Vo]:e.DST_ALPHA,[Fo]:e.ONE_MINUS_SRC_COLOR,[Bo]:e.ONE_MINUS_SRC_ALPHA,[jo]:e.ONE_MINUS_DST_COLOR,[Ho]:e.ONE_MINUS_DST_ALPHA,[Xo]:e.CONSTANT_COLOR,[qo]:e.ONE_MINUS_CONSTANT_COLOR,[$o]:e.CONSTANT_ALPHA,[Yo]:e.ONE_MINUS_CONSTANT_ALPHA};function j(t,n,i,r,a,s,o,l,c,u){if(0!==t){if(!1===h&&(B(e.BLEND),h=!0),5===t)a=a||n,s=s||i,o=o||r,n===p&&a===v||(e.blendEquationSeparate(H[n],H[a]),p=n,v=a),i===m&&r===g&&s===y&&o===x||(e.blendFuncSeparate(G[i],G[r],G[s],G[o]),m=i,g=r,y=s,x=o),!1!==l.equals(_)&&c===b||(e.blendColor(l.r,l.g,l.b,c),_.copy(l),b=c),f=t,w=!1;else if(t!==f||u!==w){if(p===Io&&v===Io||(e.blendEquation(e.FUNC_ADD),p=Io,v=Io),u)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Uc("WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case 3:Uc("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:Uc("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Uc("WebGLState: Invalid blending: ",t)}m=null,g=null,y=null,x=null,_.set(0,0,0),b=0,f=t,w=u}}else!0===h&&(V(e.BLEND),h=!1)}function W(t){S!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),S=t)}function X(t){0!==t?(B(e.CULL_FACE),t!==M&&(1===t?e.cullFace(e.BACK):2===t?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):V(e.CULL_FACE),M=t}function q(t,n,i){t?(B(e.POLYGON_OFFSET_FILL),T===n&&A===i||(e.polygonOffset(n,i),T=n,A=i)):V(e.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:i,stencil:r},enable:B,disable:V,bindFramebuffer:function(t,n){return l[t]!==n&&(e.bindFramebuffer(t,n),l[t]=n,t===e.DRAW_FRAMEBUFFER&&(l[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(l[e.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(t,n){let i=u,r=!1;if(t){i=c.get(n),void 0===i&&(i=[],c.set(n,i));const a=t.textures;if(i.length!==a.length||i[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=a.length;t<n;t++)i[t]=e.COLOR_ATTACHMENT0+t;i.length=a.length,r=!0}}else i[0]!==e.BACK&&(i[0]=e.BACK,r=!0);r&&e.drawBuffers(i)},useProgram:function(t){return d!==t&&(e.useProgram(t),d=t,!0)},setBlending:j,setMaterial:function(t,a){2===t.side?V(e.CULL_FACE):B(e.CULL_FACE);let s=1===t.side;a&&(s=!s),W(s),1===t.blending&&!1===t.transparent?j(0):j(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),i.setFunc(t.depthFunc),i.setTest(t.depthTest),i.setMask(t.depthWrite),n.setMask(t.colorWrite);const o=t.stencilWrite;r.setTest(o),o&&(r.setMask(t.stencilWriteMask),r.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),r.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),q(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?B(e.SAMPLE_ALPHA_TO_COVERAGE):V(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:W,setCullFace:X,setLineWidth:function(t){t!==E&&(C&&e.lineWidth(t),E=t)},setPolygonOffset:q,setScissorTest:function(t){t?B(e.SCISSOR_TEST):V(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+R-1),I!==t&&(e.activeTexture(t),I=t)},bindTexture:function(t,n,i){void 0===i&&(i=null===I?e.TEXTURE0+R-1:I);let r=D[i];void 0===r&&(r={type:void 0,texture:void 0},D[i]=r),r.type===t&&r.texture===n||(I!==i&&(e.activeTexture(i),I=i),e.bindTexture(t,n||z[t]),r.type=t,r.texture=n)},unbindTexture:function(){const t=D[I];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D(...arguments)}catch(e){e("WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D(...arguments)}catch(e){e("WebGLState:",e)}},texImage2D:function(){try{e.texImage2D(...arguments)}catch(e){e("WebGLState:",e)}},texImage3D:function(){try{e.texImage3D(...arguments)}catch(e){e("WebGLState:",e)}},updateUBOMapping:function(t,n){let i=s.get(n);void 0===i&&(i=new WeakMap,s.set(n,i));let r=i.get(t);void 0===r&&(r=e.getUniformBlockIndex(n,t.name),i.set(t,r))},uniformBlockBinding:function(t,n){const i=s.get(n).get(t);a.get(n)!==i&&(e.uniformBlockBinding(n,i,t.__bindingPointIndex),a.set(n,i))},texStorage2D:function(){try{e.texStorage2D(...arguments)}catch(e){e("WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D(...arguments)}catch(e){e("WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D(...arguments)}catch(e){e("WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D(...arguments)}catch(e){e("WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D(...arguments)}catch(e){e("WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D(...arguments)}catch(e){e("WebGLState:",e)}},scissor:function(t){!1===k.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),k.copy(t))},viewport:function(t){!1===U.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),U.copy(t))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),i.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),o={},I=null,D={},l={},c=new WeakMap,u=[],d=null,h=!1,f=null,p=null,m=null,g=null,v=null,y=null,x=null,_=new zd(0,0,0),b=0,w=!1,S=null,M=null,E=null,T=null,A=null,k.set(0,0,e.canvas.width,e.canvas.height),U.set(0,0,e.canvas.width,e.canvas.height),n.reset(),i.reset(),r.reset()}}}function ag(e,t,n,i,r,a,s){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=t.has("OCULUS_multiview")?t.get("OCULUS_multiview"):null,u=new $c,d=new WeakMap;let h;const f=new WeakMap;let p=[],m=!1,g=!1;try{g="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function v(e,t){return g?new OffscreenCanvas(e,t):Ic("canvas")}function y(e,t,n){let i=1;const r=q(e);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame){const n=Math.floor(i*r.width),a=Math.floor(i*r.height);void 0===h&&(h=v(n,a));const s=t?v(n,a):h;s.width=n,s.height=a;return s.getContext("2d").drawImage(e,0,0,n,a),kc("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+a+")."),s}return"data"in e&&kc("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),e}return e}function x(e){return e.generateMipmaps}function _(t){e.generateMipmap(t)}function b(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function w(n,i,r,a,s=!1){if(null!==n){if(void 0!==e[n])return e[n];kc("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===e.RED&&(r===e.FLOAT&&(o=e.R32F),r===e.HALF_FLOAT&&(o=e.R16F),r===e.UNSIGNED_BYTE&&(o=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.R8UI),r===e.UNSIGNED_SHORT&&(o=e.R16UI),r===e.UNSIGNED_INT&&(o=e.R32UI),r===e.BYTE&&(o=e.R8I),r===e.SHORT&&(o=e.R16I),r===e.INT&&(o=e.R32I)),i===e.RG&&(r===e.FLOAT&&(o=e.RG32F),r===e.HALF_FLOAT&&(o=e.RG16F),r===e.UNSIGNED_BYTE&&(o=e.RG8)),i===e.RG_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RG8UI),r===e.UNSIGNED_SHORT&&(o=e.RG16UI),r===e.UNSIGNED_INT&&(o=e.RG32UI),r===e.BYTE&&(o=e.RG8I),r===e.SHORT&&(o=e.RG16I),r===e.INT&&(o=e.RG32I)),i===e.RGB_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGB8UI),r===e.UNSIGNED_SHORT&&(o=e.RGB16UI),r===e.UNSIGNED_INT&&(o=e.RGB32UI),r===e.BYTE&&(o=e.RGB8I),r===e.SHORT&&(o=e.RGB16I),r===e.INT&&(o=e.RGB32I)),i===e.RGBA_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGBA8UI),r===e.UNSIGNED_SHORT&&(o=e.RGBA16UI),r===e.UNSIGNED_INT&&(o=e.RGBA32UI),r===e.BYTE&&(o=e.RGBA8I),r===e.SHORT&&(o=e.RGBA16I),r===e.INT&&(o=e.RGBA32I)),i===e.RGB&&(r===e.UNSIGNED_INT_5_9_9_9_REV&&(o=e.RGB9_E5),r===e.UNSIGNED_INT_10F_11F_11F_REV&&(o=e.R11F_G11F_B10F)),i===e.RGBA){const t=s?vc:ru.getTransfer(a);r===e.FLOAT&&(o=e.RGBA32F),r===e.HALF_FLOAT&&(o=e.RGBA16F),r===e.UNSIGNED_BYTE&&(o=t===yc?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(o=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(o=e.RGB5_A1)}return o!==e.R16F&&o!==e.R32F&&o!==e.RG16F&&o!==e.RG32F&&o!==e.RGBA16F&&o!==e.RGBA32F||t.get("EXT_color_buffer_float"),o}function S(t,n){let i;return t?null===n||n===bl||n===Tl?i=e.DEPTH24_STENCIL8:n===wl?i=e.DEPTH32F_STENCIL8:n===xl&&(i=e.DEPTH24_STENCIL8,kc("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===bl||n===Tl?i=e.DEPTH_COMPONENT24:n===wl?i=e.DEPTH_COMPONENT32F:n===xl&&(i=e.DEPTH_COMPONENT16),i}function M(e,t){return!0===x(e)||e.isFramebufferTexture&&e.minFilter!==ul&&e.minFilter!==fl?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function E(e){const t=e.target;t.removeEventListener("dispose",E),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=f.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&A(e),0===Object.keys(r).length&&f.delete(n)}i.remove(e)}(t),t.isVideoTexture&&d.delete(t)}function T(t){const n=t.target;n.removeEventListener("dispose",T),function(t){const n=i.get(t);t.depthTexture&&(t.depthTexture.dispose(),i.remove(t.depthTexture));if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let i=0;i<n.__webglFramebuffer[t].length;i++)e.deleteFramebuffer(n.__webglFramebuffer[t][i]);else e.deleteFramebuffer(n.__webglFramebuffer[t]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}const r=t.textures;for(let t=0,n=r.length;t<n;t++){const n=i.get(r[t]);n.__webglTexture&&(e.deleteTexture(n.__webglTexture),s.memory.textures--),i.remove(r[t])}i.remove(t)}(n)}function A(t){const n=i.get(t);e.deleteTexture(n.__webglTexture);const r=t.source;delete f.get(r)[n.__cacheKey],s.memory.textures--}let R=0;function C(t,r){const a=i.get(t);if(t.isVideoTexture&&function(e){const t=s.render.frame;d.get(e)!==t&&(d.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&!0!==t.isExternalTexture&&t.version>0&&a.__version!==t.version){const e=t.image;if(null===e)kc("WebGLRenderer: Texture marked for update but no image data found.");else if(!1===e.complete)kc("WebGLRenderer: Texture marked for update but image is incomplete");else if(U(a,t,r))return}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+r)}function P(t,r){const a=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?U(a,t,r):(t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r))}const L={[ol]:e.REPEAT,[ll]:e.CLAMP_TO_EDGE,[cl]:e.MIRRORED_REPEAT},I={[ul]:e.NEAREST,[dl]:e.NEAREST_MIPMAP_NEAREST,[hl]:e.NEAREST_MIPMAP_LINEAR,[fl]:e.LINEAR,[pl]:e.LINEAR_MIPMAP_NEAREST,[ml]:e.LINEAR_MIPMAP_LINEAR},D={[_c]:e.NEVER,[Ac]:e.ALWAYS,[bc]:e.LESS,[Sc]:e.LEQUAL,[wc]:e.EQUAL,[Tc]:e.GEQUAL,[Mc]:e.GREATER,[Ec]:e.NOTEQUAL};function N(n,a){if(a.type!==wl||!1!==t.has("OES_texture_float_linear")||a.magFilter!==fl&&a.magFilter!==pl&&a.magFilter!==hl&&a.magFilter!==ml&&a.minFilter!==fl&&a.minFilter!==pl&&a.minFilter!==hl&&a.minFilter!==ml||kc("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(n,e.TEXTURE_WRAP_S,L[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,L[a.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,L[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,I[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,I[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,D[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){if(a.magFilter===ul)return;if(a.minFilter!==hl&&a.minFilter!==ml)return;if(a.type===wl&&!1===t.has("OES_texture_float_linear"))return;if(a.anisotropy>1||i.get(a).__currentAnisotropy){const s=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy}}}function O(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",E));const r=n.source;let a=f.get(r);void 0===a&&(a={},f.set(r,a));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===a[o]&&(a[o]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,i=!0),a[o].usedTimes++;const r=a[t.__cacheKey];void 0!==r&&(a[t.__cacheKey].usedTimes--,0===r.usedTimes&&A(n)),t.__cacheKey=o,t.__webglTexture=a[o].texture}return i}function k(e,t,n){return Math.floor(Math.floor(e/n)/t)}function U(t,s,o){if(m)return s.isPendingDeferredUpload||(s.isPendingDeferredUpload=!0,p.push({textureProperties:t,texture:s,slot:o})),!1;let l=e.TEXTURE_2D;(s.isDataArrayTexture||s.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),s.isData3DTexture&&(l=e.TEXTURE_3D);const c=O(t,s),u=s.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+o);const d=i.get(u);if(u.version!==d.__version||!0===c){n.activeTexture(e.TEXTURE0+o);const t=ru.getPrimaries(ru.workingColorSpace),i=s.colorSpace===pc?null:ru.getPrimaries(s.colorSpace),h=s.colorSpace===pc||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,h);let f=y(s.image,!1,r.maxTextureSize);f=X(s,f);const p=a.convert(s.format,s.colorSpace),m=a.convert(s.type);let g,v=w(s.internalFormat,p,m,s.colorSpace,s.isVideoTexture);N(l,s);const b=s.mipmaps,E=!0!==s.isVideoTexture,T=void 0===d.__version||!0===c,A=u.dataReady,R=M(s,f);if(s.isDepthTexture)v=S(s.format===Ll,s.type),T&&(E?n.texStorage2D(e.TEXTURE_2D,1,v,f.width,f.height):n.texImage2D(e.TEXTURE_2D,0,v,f.width,f.height,0,p,m,null));else if(s.isDataTexture)if(b.length>0){E&&T&&n.texStorage2D(e.TEXTURE_2D,R,v,b[0].width,b[0].height);for(let t=0,i=b.length;t<i;t++)g=b[t],E?A&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,p,m,g.data):n.texImage2D(e.TEXTURE_2D,t,v,g.width,g.height,0,p,m,g.data);s.generateMipmaps=!1}else E?(T&&n.texStorage2D(e.TEXTURE_2D,R,v,f.width,f.height),A&&function(t,i,r,a){const s=t.updateRanges;if(0===s.length)n.texSubImage2D(e.TEXTURE_2D,0,0,0,i.width,i.height,r,a,i.data);else{s.sort((e,t)=>e.start-t.start);let o=0;for(let e=1;e<s.length;e++){const t=s[o],n=s[e],r=t.start+t.count,a=k(n.start,i.width,4),l=k(t.start,i.width,4);n.start<=r+1&&a===l&&k(n.start+n.count-1,i.width,4)===a?t.count=Math.max(t.count,n.start+n.count-t.start):(++o,s[o]=n)}s.length=o+1;const l=e.getParameter(e.UNPACK_ROW_LENGTH),c=e.getParameter(e.UNPACK_SKIP_PIXELS),u=e.getParameter(e.UNPACK_SKIP_ROWS);e.pixelStorei(e.UNPACK_ROW_LENGTH,i.width);for(let t=0,o=s.length;t<o;t++){const o=s[t],l=Math.floor(o.start/4),c=Math.ceil(o.count/4),u=l%i.width,d=Math.floor(l/i.width),h=c,f=1;e.pixelStorei(e.UNPACK_SKIP_PIXELS,u),e.pixelStorei(e.UNPACK_SKIP_ROWS,d),n.texSubImage2D(e.TEXTURE_2D,0,u,d,h,f,r,a,i.data)}t.clearUpdateRanges(),e.pixelStorei(e.UNPACK_ROW_LENGTH,l),e.pixelStorei(e.UNPACK_SKIP_PIXELS,c),e.pixelStorei(e.UNPACK_SKIP_ROWS,u)}}(s,f,p,m)):n.texImage2D(e.TEXTURE_2D,0,v,f.width,f.height,0,p,m,f.data);else if(s.isCompressedTexture)if(s.isCompressedArrayTexture){E&&T&&n.texStorage3D(e.TEXTURE_2D_ARRAY,R,v,b[0].width,b[0].height,f.depth);for(let t=0,i=b.length;t<i;t++)if(g=b[t],s.format!==Cl)if(null!==p)if(E){if(A)if(s.layerUpdates.size>0){const i=If(g.width,g.height,s.format,s.type);for(const r of s.layerUpdates){const a=g.data.subarray(r*i/g.data.BYTES_PER_ELEMENT,(r+1)*i/g.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,r,g.width,g.height,1,p,a)}s.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,g.width,g.height,f.depth,p,g.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,v,g.width,g.height,f.depth,0,g.data,0,0);else kc("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else E?A&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,g.width,g.height,f.depth,p,m,g.data):n.texImage3D(e.TEXTURE_2D_ARRAY,t,v,g.width,g.height,f.depth,0,p,m,g.data)}else{E&&T&&n.texStorage2D(e.TEXTURE_2D,R,v,b[0].width,b[0].height);for(let t=0,i=b.length;t<i;t++)g=b[t],s.format!==Cl?null!==p?E?A&&n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,p,g.data):n.compressedTexImage2D(e.TEXTURE_2D,t,v,g.width,g.height,0,g.data):kc("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):E?A&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,p,m,g.data):n.texImage2D(e.TEXTURE_2D,t,v,g.width,g.height,0,p,m,g.data)}else if(s.isDataArrayTexture)if(E){if(T&&n.texStorage3D(e.TEXTURE_2D_ARRAY,R,v,f.width,f.height,f.depth),A)if(s.layerUpdates.size>0){const t=If(f.width,f.height,s.format,s.type);for(const i of s.layerUpdates){const r=f.data.subarray(i*t/f.data.BYTES_PER_ELEMENT,(i+1)*t/f.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,i,f.width,f.height,1,p,m,r)}s.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,f.width,f.height,f.depth,p,m,f.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,v,f.width,f.height,f.depth,0,p,m,f.data);else if(s.isData3DTexture)E?(T&&n.texStorage3D(e.TEXTURE_3D,R,v,f.width,f.height,f.depth),A&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,f.width,f.height,f.depth,p,m,f.data)):n.texImage3D(e.TEXTURE_3D,0,v,f.width,f.height,f.depth,0,p,m,f.data);else if(s.isFramebufferTexture){if(T)if(E)n.texStorage2D(e.TEXTURE_2D,R,v,f.width,f.height);else{let t=f.width,i=f.height;for(let r=0;r<R;r++)n.texImage2D(e.TEXTURE_2D,r,v,t,i,0,p,m,null),t>>=1,i>>=1}}else if(b.length>0){if(E&&T){const t=q(b[0]);n.texStorage2D(e.TEXTURE_2D,R,v,t.width,t.height)}for(let t=0,i=b.length;t<i;t++)g=b[t],E?A&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,p,m,g):n.texImage2D(e.TEXTURE_2D,t,v,p,m,g);s.generateMipmaps=!1}else if(E){if(T){const t=q(f);n.texStorage2D(e.TEXTURE_2D,R,v,t.width,t.height)}A&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,p,m,f)}else n.texImage2D(e.TEXTURE_2D,0,v,p,m,f);x(s)&&_(l),d.__version=u.version,s.onUpdate&&s.onUpdate(s)}return t.__version=s.version,!0}function F(t,r,s,l,u,d){const h=a.convert(s.format,s.colorSpace),f=a.convert(s.type),p=w(s.internalFormat,h,f,s.colorSpace),m=i.get(r),g=i.get(s);if(g.__renderTarget=r,!m.__hasExternalTextures){const t=Math.max(1,r.width>>d),i=Math.max(1,r.height>>d);!0===r.isWebGLMultiviewRenderTarget?n.texStorage3D(e.TEXTURE_2D_ARRAY,0,p,r.width,r.height,r.numViews):u===e.TEXTURE_3D||u===e.TEXTURE_2D_ARRAY?n.texImage3D(u,d,p,t,i,r.depth,0,h,f,null):n.texImage2D(u,d,p,t,i,0,h,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t);const v=W(r);!0===r.isWebGLMultiviewRenderTarget?v?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,g.__webglTexture,0,j(r),0,r.numViews):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,g.__webglTexture,0,0,r.numViews):(u===e.TEXTURE_2D||u>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&u<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&(v?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,l,u,g.__webglTexture,0,j(r)):e.framebufferTexture2D(e.FRAMEBUFFER,l,u,g.__webglTexture,d)),n.bindFramebuffer(e.FRAMEBUFFER,null)}function z(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),!0===n.isWebGLMultiviewRenderTarget){const t=W(n),r=n.numViews,a=n.depthTexture;let s=e.DEPTH_COMPONENT24,o=e.DEPTH_ATTACHMENT;a&&a.isDepthTexture&&(a.type===wl?s=e.DEPTH_COMPONENT32F:a.type===Tl&&(s=e.DEPTH24_STENCIL8,o=e.DEPTH_STENCIL_ATTACHMENT));let l=i.get(n.depthTexture).__webglTexture;void 0===l&&(l=e.createTexture(),e.bindTexture(e.TEXTURE_2D_ARRAY,l),e.texStorage3D(e.TEXTURE_2D_ARRAY,1,s,n.width,n.height,r)),t?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,o,l,0,j(n),0,r):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,o,l,0,0,r)}else if(n.depthBuffer){const i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,s=S(n.stencilBuffer,a),l=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=j(n);W(n)?o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,c,s,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,c,s,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,s,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,l,e.RENDERBUFFER,t)}else{const t=n.textures;for(let i=0;i<t.length;i++){const s=t[i],l=a.convert(s.format,s.colorSpace),c=a.convert(s.type),u=w(s.internalFormat,l,c,s.colorSpace),d=j(n);r&&!1===W(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,d,u,n.width,n.height):W(n)?o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,d,u,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,u,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function B(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(e.FRAMEBUFFER,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const a=i.get(r.depthTexture);a.__renderTarget=r,a.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),1!=r.depthTexture.image.depth?P(r.depthTexture,0):C(r.depthTexture,0);const s=a.__webglTexture,l=j(r);if(!0===r.isWebGLMultiviewRenderTarget){const t=W(r),n=r.numViews;if(r.depthTexture.format===Pl)t?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,s,0,l,0,n):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,s,0,0,n);else{if(r.depthTexture.format!==Ll)throw new Error("Unknown depthTexture format");t?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,s,0,l,0,n):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,s,0,0,n)}}else if(r.depthTexture.format===Pl)W(r)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0,l):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0);else{if(r.depthTexture.format!==Ll)throw new Error("Unknown depthTexture format");W(r)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0,l):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0)}}function V(t){const r=i.get(t),a=!0===t.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==t.depthTexture){const e=t.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),e){const t=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),r.__depthDisposeCallback=t}r.__boundDepthTexture=e}if(t.depthTexture&&!r.__autoAllocateDepthBuffer){if(a)throw new Error("target.depthTexture not supported in Cube render targets");const e=t.texture.mipmaps;e&&e.length>0?B(r.__webglFramebuffer[0],t):B(r.__webglFramebuffer,t)}else if(a){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=e.createRenderbuffer(),z(r.__webglDepthbuffer[i],t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=r.__webglDepthbuffer[i];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else{const i=t.texture.mipmaps;if(i&&i.length>0?n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=e.createRenderbuffer(),z(r.__webglDepthbuffer,t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,i)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}const H=[],G=[];function j(e){return Math.min(r.maxSamples,e.samples)}function W(e){const n=i.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function X(e,t){const n=e.colorSpace,i=e.format,r=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==gc&&n!==pc&&(ru.getTransfer(n)===yc?i===Cl&&r===gl||kc("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Uc("WebGLTextures: Unsupported texture color space:",n)),t}function q(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(u.width=e.naturalWidth||e.width,u.height=e.naturalHeight||e.height):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?(u.width=e.displayWidth,u.height=e.displayHeight):(u.width=e.width,u.height=e.height),u}this.allocateTextureUnit=function(){const e=R;return e>=r.maxTextures&&kc("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures),R+=1,e},this.resetTextureUnits=function(){R=0},this.setTexture2D=C,this.setTexture2DArray=P,this.setTexture3D=function(t,r){const a=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?U(a,t,r):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,s){const o=i.get(t);t.version>0&&o.__version!==t.version?function(t,s,o){if(6!==s.image.length)return;const l=O(t,s),c=s.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+o);const u=i.get(c);if(c.version!==u.__version||!0===l){n.activeTexture(e.TEXTURE0+o);const t=ru.getPrimaries(ru.workingColorSpace),i=s.colorSpace===pc?null:ru.getPrimaries(s.colorSpace),d=s.colorSpace===pc||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const h=s.isCompressedTexture||s.image[0].isCompressedTexture,f=s.image[0]&&s.image[0].isDataTexture,p=[];for(let e=0;e<6;e++)p[e]=h||f?f?s.image[e].image:s.image[e]:y(s.image[e],!0,r.maxCubemapSize),p[e]=X(s,p[e]);const m=p[0],g=a.convert(s.format,s.colorSpace),v=a.convert(s.type),b=w(s.internalFormat,g,v,s.colorSpace),S=!0!==s.isVideoTexture,E=void 0===u.__version||!0===l,T=c.dataReady;let A,R=M(s,m);if(N(e.TEXTURE_CUBE_MAP,s),h){S&&E&&n.texStorage2D(e.TEXTURE_CUBE_MAP,R,b,m.width,m.height);for(let t=0;t<6;t++){A=p[t].mipmaps;for(let i=0;i<A.length;i++){const r=A[i];s.format!==Cl?null!==g?S?T&&n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,r.width,r.height,g,r.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,b,r.width,r.height,0,r.data):kc("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,r.width,r.height,g,v,r.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,b,r.width,r.height,0,g,v,r.data)}}}else{if(A=s.mipmaps,S&&E){A.length>0&&R++;const t=q(p[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,R,b,t.width,t.height)}for(let t=0;t<6;t++)if(f){S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,p[t].width,p[t].height,g,v,p[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,b,p[t].width,p[t].height,0,g,v,p[t].data);for(let i=0;i<A.length;i++){const r=A[i].image[t].image;S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,r.width,r.height,g,v,r.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,b,r.width,r.height,0,g,v,r.data)}}else{S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,g,v,p[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,b,g,v,p[t]);for(let i=0;i<A.length;i++){const r=A[i];S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,g,v,r.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,b,g,v,r.image[t])}}}x(s)&&_(e.TEXTURE_CUBE_MAP),u.__version=c.version,s.onUpdate&&s.onUpdate(s)}t.__version=s.version}(o,t,s):n.bindTexture(e.TEXTURE_CUBE_MAP,o.__webglTexture,e.TEXTURE0+s)},this.rebindTextures=function(t,n,r){const a=i.get(t);void 0!==n&&F(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==r&&V(t)},this.uploadTexture=U,this.setupRenderTarget=function(t){const r=t.texture,o=i.get(t),l=i.get(r);t.addEventListener("dispose",T);const c=t.textures,u=!0===t.isWebGLCubeRenderTarget,d=c.length>1;if(d||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=r.version,s.memory.textures++),u){o.__webglFramebuffer=[];for(let t=0;t<6;t++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[t]=[];for(let n=0;n<r.mipmaps.length;n++)o.__webglFramebuffer[t][n]=e.createFramebuffer()}else o.__webglFramebuffer[t]=e.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let t=0;t<r.mipmaps.length;t++)o.__webglFramebuffer[t]=e.createFramebuffer()}else o.__webglFramebuffer=e.createFramebuffer();if(d)for(let t=0,n=c.length;t<n;t++){const n=i.get(c[t]);void 0===n.__webglTexture&&(n.__webglTexture=e.createTexture(),s.memory.textures++)}if(t.samples>0&&!1===W(t)){o.__webglMultisampledFramebuffer=e.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n<c.length;n++){const i=c[n];o.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,o.__webglColorRenderbuffer[n]);const r=a.convert(i.format,i.colorSpace),s=a.convert(i.type),l=w(i.internalFormat,r,s,i.colorSpace,!0===t.isXRRenderTarget),u=j(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,u,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,o.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(o.__webglDepthRenderbuffer=e.createRenderbuffer(),z(o.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){n.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),N(e.TEXTURE_CUBE_MAP,r);for(let n=0;n<6;n++)if(r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)F(o.__webglFramebuffer[n][i],t,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else F(o.__webglFramebuffer[n],t,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);x(r)&&_(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(d){for(let r=0,a=c.length;r<a;r++){const a=c[r],s=i.get(a);let l=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(l=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(l,s.__webglTexture),N(l,a),F(o.__webglFramebuffer,t,a,e.COLOR_ATTACHMENT0+r,l,0),x(a)&&_(l)}n.unbindTexture()}else{let i=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(i=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),!0===t.isWebGLMultiviewRenderTarget&&(i=e.TEXTURE_2D_ARRAY),n.bindTexture(i,l.__webglTexture),N(i,r),r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)F(o.__webglFramebuffer[n],t,r,e.COLOR_ATTACHMENT0,i,n);else F(o.__webglFramebuffer,t,r,e.COLOR_ATTACHMENT0,i,0);x(r)&&_(i),n.unbindTexture()}(t.depthBuffer||!0===t.isWebGLMultiviewRenderTarget)&&this.setupDepthRenderbuffer(t)},this.updateRenderTargetMipmap=function(e){const t=e.textures;for(let r=0,a=t.length;r<a;r++){const a=t[r];if(x(a)){const t=b(e),r=i.get(a).__webglTexture;n.bindTexture(t,r),_(t),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.samples>0)if(!1===W(t)){const r=t.textures,a=t.width,s=t.height;let o=e.COLOR_BUFFER_BIT;const c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=i.get(t),d=r.length>1;if(d)for(let t=0;t<r.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer);const h=t.texture.mipmaps;h&&h.length>0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n<r.length;n++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(o|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(o|=e.STENCIL_BUFFER_BIT)),d){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,u.__webglColorRenderbuffer[n]);const t=i.get(r[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,a,s,0,0,a,s,o,e.NEAREST),!0===l&&(H.length=0,G.length=0,H.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&!1===t.resolveDepthBuffer&&(H.push(c),G.push(c),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,G)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,H))}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),d)for(let t=0;t<r.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,u.__webglColorRenderbuffer[t]);const a=i.get(r[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&!1===t.resolveDepthBuffer&&l){const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}},this.setupDepthTexture=B,this.setupDepthRenderbuffer=V,this.setupFrameBufferTexture=F,this.useMultisampledRTT=W,this.runDeferredUploads=function(){const e=m;m=!1;for(const e of p)U(e.textureProperties,e.texture,e.slot),e.texture.isPendingDeferredUpload=!1;p=[],m=e},this.setDeferTextureUploads=function(e){m=e}}function sg(e,t){return{convert:function(n,i=""){let r;const a=ru.getTransfer(i);if(n===gl)return e.UNSIGNED_BYTE;if(n===Ml)return e.UNSIGNED_SHORT_4_4_4_4;if(n===El)return e.UNSIGNED_SHORT_5_5_5_1;if(n===Al)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===Rl)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===vl)return e.BYTE;if(n===yl)return e.SHORT;if(n===xl)return e.UNSIGNED_SHORT;if(n===_l)return e.INT;if(n===bl)return e.UNSIGNED_INT;if(n===wl)return e.FLOAT;if(n===Sl)return e.HALF_FLOAT;if(1021===n)return e.ALPHA;if(1022===n)return e.RGB;if(n===Cl)return e.RGBA;if(n===Pl)return e.DEPTH_COMPONENT;if(n===Ll)return e.DEPTH_STENCIL;if(1028===n)return e.RED;if(n===Il)return e.RED_INTEGER;if(n===Dl)return e.RG;if(n===Nl)return e.RG_INTEGER;if(n===Ol)return e.RGBA_INTEGER;if(n===kl||n===Ul||n===Fl||n===zl)if(a===yc){if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(n===kl)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ul)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Fl)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===zl)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=t.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(n===kl)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ul)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Fl)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===zl)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===Bl||n===Vl||n===Hl||n===Gl){if(r=t.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(n===Bl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Vl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Hl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Gl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===jl||n===Wl||n===Xl){if(r=t.get("WEBGL_compressed_texture_etc"),null===r)return null;if(n===jl||n===Wl)return a===yc?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Xl)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(n===ql||n===$l||n===Yl||n===Kl||n===Zl||n===Ql||n===Jl||n===ec||n===tc||n===nc||n===ic||n===rc||n===ac||n===sc){if(r=t.get("WEBGL_compressed_texture_astc"),null===r)return null;if(n===ql)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===$l)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Yl)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Kl)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Zl)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ql)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Jl)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ec)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===tc)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===nc)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ic)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===rc)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ac)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===sc)return a===yc?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===oc||n===lc||n===cc){if(r=t.get("EXT_texture_compression_bptc"),null===r)return null;if(n===oc)return a===yc?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===lc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===cc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===uc||n===dc||n===hc||n===fc){if(r=t.get("EXT_texture_compression_rgtc"),null===r)return null;if(n===uc)return r.COMPRESSED_RED_RGTC1_EXT;if(n===dc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===hc)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===fc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===Tl?e.UNSIGNED_INT_24_8:void 0!==e[n]?e[n]:null}}}class og extends vu{constructor(e,t,n,i={}){super(e,t,i),this.depthBuffer=!1,this.stencilBuffer=!1,this.numViews=n}copy(e){return super.copy(e),this.numViews=e.numViews,this}}og.prototype.isWebGLMultiviewRenderTarget=!0;class lg{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(null===this.texture){const n=new of(e.texture);e.depthNear===t.depthNear&&e.depthFar===t.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(null!==this.texture&&null===this.mesh){const t=e.cameras[0].viewport,n=new Sh({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new gh(new df(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class cg extends zc{constructor(e,t,n,i){super();const r=this;let a=null,s=1;var o=null;let l=null,c="local-floor",u=1,d=null,h=null;var f=[];let p=null,m=null,g=null,v=null;const y="undefined"!=typeof XRWebGLBinding,x=new lg,_={},b=t.getContextAttributes();let w=null,S=null;const M=[],E=[],T=new $c;let A=null;const R=new Rh;R.viewport=new mu;const C=new Rh;C.viewport=new mu;const P=[R,C],L=new xf;let I=null,D=null;function N(e){const t=E.indexOf(e.inputSource);if(-1===t)return;const n=M[t];void 0!==n&&(n.update(e.inputSource,e.frame,d||l),n.dispatchEvent({type:e.type,data:e.inputSource}))}function O(){a.removeEventListener("select",N),a.removeEventListener("selectstart",N),a.removeEventListener("selectend",N),a.removeEventListener("squeeze",N),a.removeEventListener("squeezestart",N),a.removeEventListener("squeezeend",N),a.removeEventListener("end",O),a.removeEventListener("inputsourceschange",k);for(let e=0;e<M.length;e++){const t=E[e];null!==t&&(E[e]=null,M[e].disconnect(t))}I=null,D=null,x.reset();for(const e in _)delete _[e];r.isPresenting=!1,e.setRenderTarget(w),g=null,m=null,p=null,a=null,S=null,V.stop(),e.setPixelRatio(A),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}function k(e){for(let t=0;t<e.removed.length;t++){const n=e.removed[t],i=E.indexOf(n);i>=0&&(E[i]=null,M[i].disconnect(n))}for(let t=0;t<e.added.length;t++){const n=e.added[t];let i=E.indexOf(n);if(-1===i){for(let e=0;e<M.length;e++){if(e>=E.length){E.push(n),i=e;break}if(null===E[e]){E[e]=n,i=e;break}}if(-1===i)break}const r=M[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.layersEnabled=!1,this.isPresenting=!1,this.isMultiview=!1,this.getCameraPose=function(){return h},this.getController=function(e){let t=M[e];return void 0===t&&(t=new Oh,M[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=M[e];return void 0===t&&(t=new Oh,M[e]=t),t.getGripSpace()},this.getHand=function(e){let t=M[e];return void 0===t&&(t=new Oh,M[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){s=e,!0===r.isPresenting&&kc("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){c=e,!0===r.isPresenting&&kc("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||l},this.setReferenceSpace=function(e){d=e},this.getBaseLayer=function(){return null!==m?m:g},this.getBinding=function(){return null===p&&y&&(p=new XRWebGLBinding(a,t)),p},this.getFrame=function(){return v},this.getRenderTarget=function(){return S},this.getSession=function(){return a},this.setSession=async function(o){if(a=o,null!==a){w=e.getRenderTarget(),a.addEventListener("select",N),a.addEventListener("selectstart",N),a.addEventListener("selectend",N),a.addEventListener("squeeze",N),a.addEventListener("squeezestart",N),a.addEventListener("squeezeend",N),a.addEventListener("end",O),a.addEventListener("inputsourceschange",k),!0!==b.xrCompatible&&await t.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(T);if(y&&"createProjectionLayer"in XRWebGLBinding.prototype){let o=null,l=null,c=null;b.depth&&(c=b.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,o=b.stencil?Ll:Pl,l=b.stencil?Tl:bl),r.isMultiview=i&&n.has("OCULUS_multiview");const u={colorFormat:t.RGBA8,depthFormat:c,scaleFactor:s};r.isMultiview&&(u.textureType="texture-array"),p=this.getBinding(),m=p.createProjectionLayer(u),a.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1);const d={format:Cl,type:gl,depthTexture:new sf(m.textureWidth,m.textureHeight,l,void 0,void 0,void 0,void 0,void 0,void 0,o),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:!1===m.ignoreDepthValues,resolveStencilBuffer:!1===m.ignoreDepthValues};if(r.isMultiview){const e=n.get("OCULUS_multiview");this.maxNumViews=t.getParameter(e.MAX_VIEWS_OVR),S=new og(m.textureWidth,m.textureHeight,2,d)}else S=new vu(m.textureWidth,m.textureHeight,d)}else{const n={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:s};g=new XRWebGLLayer(a,t,n),a.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),S=new vu(g.framebufferWidth,g.framebufferHeight,{format:Cl,type:gl,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil,resolveDepthBuffer:!1===g.ignoreDepthValues,resolveStencilBuffer:!1===g.ignoreDepthValues})}S.isXRRenderTarget=!0,this.setFoveation(u),d=null,l=await a.requestReferenceSpace(c),V.setContext(a),V.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==a)return a.environmentBlendMode},this.addLayer=function(e){window.XRWebGLBinding&&this.layersEnabled&&a&&(f.push(e),this.updateLayers())},this.removeLayer=function(e){f.splice(f.indexOf(e),1),window.XRWebGLBinding&&this.layersEnabled&&a&&this.updateLayers()},this.updateLayers=function(){var e=f.map(function(e){return e});e.unshift(a.renderState.layers[0]),a.updateRenderState({layers:e})},this.getDepthTexture=function(){return x.getDepthTexture()};const U=new Kc,F=new Kc;function z(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.setPoseTarget=function(e){void 0!==e&&(o=e)},this.updateCamera=function(e){if(null===a)return;let t=e.near,n=e.far;null!==x.texture&&(x.depthNear>0&&(t=x.depthNear),x.depthFar>0&&(n=x.depthFar)),L.near=C.near=R.near=t,L.far=C.far=R.far=n,I===L.near&&D===L.far||(a.updateRenderState({depthNear:L.near,depthFar:L.far}),I=L.near,D=L.far),L.layers.mask=6|e.layers.mask,R.layers.mask=3&L.layers.mask,C.layers.mask=5&L.layers.mask;const i=L.cameras;var r=o||e;const s=r.parent;z(L,s);for(let e=0;e<i.length;e++)z(i[e],s);2===i.length?function(e,t,n){U.setFromMatrixPosition(t.matrixWorld),F.setFromMatrixPosition(n.matrixWorld);const i=U.distanceTo(F),r=t.projectionMatrix.elements,a=n.projectionMatrix.elements,s=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],u=(r[8]-1)/r[0],d=(a[8]+1)/a[0],h=s*u,f=s*d,p=i/(-u+d),m=p*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(p),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),-1===r[10])e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{const t=s+p,n=o+p,r=h-m,a=f+(i-m),u=l*o/n*t,d=c*o/n*t;e.projectionMatrix.makePerspective(r,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}(L,R,C):L.projectionMatrix.copy(R.projectionMatrix),function(e,t,n){t.matrixWorld.decompose(t.position,t.quaternion,t.scale),null===n.parent?n.matrix.copy(t.matrixWorld):(n.matrix.copy(n.parent.matrixWorld),n.matrix.invert(),n.matrix.multiply(t.matrixWorld));n.matrix.decompose(n.position,n.quaternion,n.scale),n.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*Hc*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,L,r)},this.getCamera=function(){return L},this.getFoveation=function(){if(null!==m||null!==g)return u},this.setFoveation=function(e){u=e,null!==m&&(m.fixedFoveation=e),null!==g&&void 0!==g.fixedFoveation&&(g.fixedFoveation=e)},this.hasDepthSensing=function(){return null!==x.texture},this.getDepthSensingMesh=function(){return x.getMesh(L)},this.getCameraTexture=function(e){return _[e]};let B=null;const V=new Df;V.setAnimationLoop(function(t,n){if(h=n.getViewerPose(d||l),v=n,null!==h){const t=h.views;null!==g&&(e.setRenderTargetFramebuffer(S,g.framebuffer),e.setRenderTarget(S));let n=!1;t.length!==L.cameras.length&&(L.cameras.length=0,n=!0);for(let i=0;i<t.length;i++){const r=t[i];let a=null;if(null!==g)a=g.getViewport(r);else{const t=p.getViewSubImage(m,r);a=t.viewport,0===i&&(e.setRenderTargetTextures(S,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(S))}let s=P[i];void 0===s&&(s=new Rh,s.layers.enable(i),s.viewport=new mu,P[i]=s),s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.projectionMatrix.fromArray(r.projectionMatrix),s.projectionMatrixInverse.copy(s.projectionMatrix).invert(),s.viewport.set(a.x,a.y,a.width,a.height),0===i&&(L.matrix.copy(s.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),!0===n&&L.cameras.push(s)}const i=a.enabledFeatures;if(i&&i.includes("depth-sensing")&&"gpu-optimized"==a.depthUsage&&y){p=r.getBinding();const e=p.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&x.init(e,a.renderState)}if(i&&i.includes("camera-access")&&y){e.state.unbindTexture(),p=r.getBinding();for(let e=0;e<t.length;e++){const n=t[e].camera;if(n){let e=_[n];e||(e=new of,_[n]=e);const t=p.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<M.length;e++){const t=E[e],i=M[e];null!==t&&void 0!==i&&i.update(t,n,d||l)}B&&B(t,n),n.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:n}),v=null}),this.setAnimationLoop=function(e){B=e},this.dispose=function(){}}}const ug=new id,dg=new qu;function hg(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function i(e,i){e.opacity.value=i.opacity,i.color&&e.diffuse.value.copy(i.color),i.emissive&&e.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(e.map.value=i.map,n(i.map,e.mapTransform)),i.alphaMap&&(e.alphaMap.value=i.alphaMap,n(i.alphaMap,e.alphaMapTransform)),i.bumpMap&&(e.bumpMap.value=i.bumpMap,n(i.bumpMap,e.bumpMapTransform),e.bumpScale.value=i.bumpScale,1===i.side&&(e.bumpScale.value*=-1)),i.normalMap&&(e.normalMap.value=i.normalMap,n(i.normalMap,e.normalMapTransform),e.normalScale.value.copy(i.normalScale),1===i.side&&e.normalScale.value.negate()),i.displacementMap&&(e.displacementMap.value=i.displacementMap,n(i.displacementMap,e.displacementMapTransform),e.displacementScale.value=i.displacementScale,e.displacementBias.value=i.displacementBias),i.emissiveMap&&(e.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,e.emissiveMapTransform)),i.specularMap&&(e.specularMap.value=i.specularMap,n(i.specularMap,e.specularMapTransform)),i.alphaTest>0&&(e.alphaTest.value=i.alphaTest);const r=t.get(i),a=r.envMap,s=r.envMapRotation;a&&(e.envMap.value=a,ug.copy(s),ug.x*=-1,ug.y*=-1,ug.z*=-1,a.isCubeTexture&&!1===a.isRenderTargetTexture&&(ug.y*=-1,ug.z*=-1),e.envMapRotation.value.setFromMatrix4(dg.makeRotationFromEuler(ug)),e.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,e.reflectivity.value=i.reflectivity,e.ior.value=i.ior,e.refractionRatio.value=i.refractionRatio),i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,e.lightMapTransform)),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,bh(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,s,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform));e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform));t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),1===t.side&&e.clearcoatNormalScale.value.negate()));t.dispersion>0&&(e.dispersion.value=t.dispersion);t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){const i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,a,s):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function fg(e,t,n,i){let r={},a={},s=[];const o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(e,t,n,i){const r=e.value,a=t+"_"+n;if(void 0===i[a])return i[a]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const e=i[a];if("number"==typeof r||"boolean"==typeof r){if(e!==r)return i[a]=r,!0}else if(!1===e.equals(r))return e.copy(r),!0}return!1}function c(e){const t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?kc("WebGLRenderer: Texture samplers can not be part of an uniforms group."):kc("WebGLRenderer: Unsupported uniform value type.",e),t}function u(t){const n=t.target;n.removeEventListener("dispose",u);const i=s.indexOf(n.__bindingPointIndex);s.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete a[n.id]}return{bind:function(e,t){const n=t.program;i.uniformBlockBinding(e,n)},update:function(n,d){let h=r[n.id];void 0===h&&(!function(e){const t=e.uniforms;let n=0;const i=16;for(let e=0,r=t.length;e<r;e++){const r=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=r.length;e<t;e++){const t=r[e],a=Array.isArray(t.value)?t.value:[t.value];for(let e=0,r=a.length;e<r;e++){const r=c(a[e]),s=n%i,o=s%r.boundary,l=s+o;n+=o,0!==l&&i-l<r.storage&&(n+=i-l),t.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=r.storage}}}const r=n%i;r>0&&(n+=i-r);e.__size=n,e.__cache={}}(n),h=function(t){const n=function(){for(let e=0;e<o;e++)if(-1===s.indexOf(e))return s.push(e),e;return Uc("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;const i=e.createBuffer(),r=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,i),e.bufferData(e.UNIFORM_BUFFER,r,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=h,n.addEventListener("dispose",u));const f=d.program;i.updateUBOMapping(n,f);const p=t.render.frame;a[n.id]!==p&&(!function(t){const n=r[t.id],i=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=i.length;t<n;t++){const n=Array.isArray(i[t])?i[t]:[i[t]];for(let i=0,r=n.length;i<r;i++){const r=n[i];if(!0===l(r,t,i,a)){const t=r.__offset,n=Array.isArray(r.value)?r.value:[r.value];let i=0;for(let a=0;a<n.length;a++){const s=n[a],o=c(s);"number"==typeof s||"boolean"==typeof s?(r.__data[0]=s,e.bufferSubData(e.UNIFORM_BUFFER,t+i,r.__data)):s.isMatrix3?(r.__data[0]=s.elements[0],r.__data[1]=s.elements[1],r.__data[2]=s.elements[2],r.__data[3]=0,r.__data[4]=s.elements[3],r.__data[5]=s.elements[4],r.__data[6]=s.elements[5],r.__data[7]=0,r.__data[8]=s.elements[6],r.__data[9]=s.elements[7],r.__data[10]=s.elements[8],r.__data[11]=0):(s.toArray(r.__data,i),i+=o.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,r.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(n),a[n.id]=p)},dispose:function(){for(const t in r)e.deleteBuffer(r[t]);s=[],r={},a={}}}}const pg=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let mg=null;class gg{constructor(e={}){const{canvas:t=Dc(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:s=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,multiviewStereo:h=!1}=e;let f;if(this.isWebGLRenderer=!0,null!==n){if("undefined"!=typeof WebGLRenderingContext&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=a;const p=new Set([Ol,Nl,Il]),m=new Set([gl,bl,xl,Tl,Ml,El]),g=new Uint32Array(4),v=new Int32Array(4);let y=null,x=null;const _=[],b=[];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=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const w=this;let S=!1;this._outputColorSpace=mc;let M=0,E=0,T=null,A=-1,R=null;const C=new mu,P=new mu;let L=null;const I=new zd(0);let D=0,N=t.width,O=t.height,k=1,U=null,F=null;const z=new mu(0,0,N,O),B=new mu(0,0,N,O);let V=!1;const H=new Wh;let G=!1,j=!1;const W=new qu,X=new Kc,q=new mu,$={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Y=!1;function K(){return null===T?k:1}let Z,Q,J,ee,te,ne,ie,re,ae,se,oe,le,ce,ue,de,he,fe,pe,me,ge,ve,ye,xe,_e,be,we=n;function Se(e,n){return t.getContext(e,n)}try{const e={alpha:!0,depth:i,stencil:r,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ro}`),t.addEventListener("webglcontextlost",Te,!1),t.addEventListener("webglcontextrestored",Ae,!1),t.addEventListener("webglcontextcreationerror",Re,!1),null===we){const t="webgl2";if(we=Se(t,e),null===we)throw Se(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(e){throw e("WebGLRenderer: "+e.message),e}function Me(){Z=new cp(we),Z.init(),xe=new sg(we,Z),Q=new jf(we,Z,e,xe),J=new rg(we,Z),Q.reversedDepthBuffer&&d&&J.buffers.depth.setReversed(!0),ee=new hp(we),te=new Wm,ne=new ag(we,Z,J,te,Q,xe,ee),ie=new Xf(w),re=new lp(w),ae=new Nf(we),_e=new Hf(we,ae),se=new up(we,ae,ee,_e),oe=new mp(we,se,ae,ee),ge=new fp(we,Q,ne),he=new Wf(te),le=new jm(w,ie,re,Z,Q,_e,he),ce=new hg(w,te),ue=new Ym,de=new tg(Z),me=new Vf(w,ie,re,J,oe,f,o),pe=new pp(w,Z,we),fe=new ng(w,oe,Q),be=new fg(we,ee,Q,J),ve=new Gf(we,Z,ee),ye=new dp(we,Z,ee),ee.programs=le.programs,w.capabilities=Q,w.extensions=Z,w.properties=te,w.renderLists=ue,w.shadowMap=fe,w.state=J,w.info=ee}Me();const Ee=new cg(w,we,Z,h);function Te(e){e.preventDefault(),Oc("WebGLRenderer: Context Lost."),S=!0}function Ae(){Oc("WebGLRenderer: Context Restored."),S=!1;const e=ee.autoReset,t=fe.enabled,n=fe.autoUpdate,i=fe.needsUpdate,r=fe.type;Me(),ee.autoReset=e,fe.enabled=t,fe.autoUpdate=n,fe.needsUpdate=i,fe.type=r}function Re(e){Uc("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Ce(e){const t=e.target;t.removeEventListener("dispose",Ce),function(e){(function(e){const t=te.get(e).programs;void 0!==t&&(t.forEach(function(e){le.releaseProgram(e)}),e.isShaderMaterial&&le.releaseShaderCache(e))})(e),te.remove(e)}(t)}function Pe(e,t,n){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=1,e.needsUpdate=!0,Be(e,t,n),e.side=0,e.needsUpdate=!0,Be(e,t,n),e.side=2):Be(e,t,n)}this.xr=Ee,this.getContext=function(){return we},this.getContextAttributes=function(){return we.getContextAttributes()},this.forceContextLoss=function(){const e=Z.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=Z.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return k},this.setPixelRatio=function(e){void 0!==e&&(k=e,this.setSize(N,O,!1))},this.getSize=function(e){return e.set(N,O)},this.setSize=function(e,n,i=!0){Ee.isPresenting?kc("WebGLRenderer: Can't change size while VR device is presenting."):(N=e,O=n,t.width=Math.floor(e*k),t.height=Math.floor(n*k),!0===i&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(N*k,O*k).floor()},this.setDrawingBufferSize=function(e,n,i){N=e,O=n,k=i,t.width=Math.floor(e*i),t.height=Math.floor(n*i),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(C)},this.getViewport=function(e){return e.copy(z)},this.setViewport=function(e,t,n,i){e.isVector4?z.set(e.x,e.y,e.z,e.w):z.set(e,t,n,i),J.viewport(C.copy(z).multiplyScalar(k).round())},this.getScissor=function(e){return e.copy(B)},this.setScissor=function(e,t,n,i){e.isVector4?B.set(e.x,e.y,e.z,e.w):B.set(e,t,n,i),J.scissor(P.copy(B).multiplyScalar(k).round())},this.getScissorTest=function(){return V},this.setScissorTest=function(e){J.setScissorTest(V=e)},this.setOpaqueSort=function(e){U=e},this.setTransparentSort=function(e){F=e},this.getClearColor=function(e){return e.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor(...arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let i=0;if(e){let e=!1;if(null!==T){const t=T.texture.format;e=p.has(t)}if(e){const e=T.texture.type,t=m.has(e),n=me.getClearColor(),i=me.getClearAlpha(),r=n.r,a=n.g,s=n.b;t?(g[0]=r,g[1]=a,g[2]=s,g[3]=i,we.clearBufferuiv(we.COLOR,0,g)):(v[0]=r,v[1]=a,v[2]=s,v[3]=i,we.clearBufferiv(we.COLOR,0,v))}else i|=we.COLOR_BUFFER_BIT}t&&(i|=we.DEPTH_BUFFER_BIT),n&&(i|=we.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),we.clear(i)},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.dispose=function(){t.removeEventListener("webglcontextlost",Te,!1),t.removeEventListener("webglcontextrestored",Ae,!1),t.removeEventListener("webglcontextcreationerror",Re,!1),me.dispose(),ue.dispose(),de.dispose(),te.dispose(),ie.dispose(),re.dispose(),oe.dispose(),_e.dispose(),be.dispose(),le.dispose(),Ee.dispose(),Ee.removeEventListener("sessionstart",Ie),Ee.removeEventListener("sessionend",De),Ne.stop()},this.renderBufferDirect=function(e,t,n,i,r,a){null===t&&(t=$);const s=r.isMesh&&r.matrixWorld.determinant()<0,o=function(e,t,n,i,r){!0!==t.isScene&&(t=$);ne.resetTextureUnits();const a=t.fog,s=i.isMeshStandardMaterial?t.environment:null,o=null===T?w.outputColorSpace:!0===T.isXRRenderTarget?T.texture.colorSpace:gc,l=(i.isMeshStandardMaterial?re:ie).get(i.envMap||s),c=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),d=!!n.morphAttributes.position,h=!!n.morphAttributes.normal,f=!!n.morphAttributes.color;let p=0;i.toneMapped&&(null!==T&&!0!==T.isXRRenderTarget||(p=w.toneMapping));const m=T&&T.isWebGLMultiviewRenderTarget?T.numViews:0,g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==g?g.length:0,y=te.get(i),_=x.state.lights;if(!0===G&&(!0===j||e!==R)){const t=e===R&&i.id===A;he.setState(i,e,t)}let b=!1;i.version===y.__version?y.needsLights&&y.lightsStateVersion!==_.state.version||y.outputColorSpace!==o||r.isBatchedMesh&&!1===y.batching?b=!0:r.isBatchedMesh||!0!==y.batching?r.isBatchedMesh&&!0===y.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===y.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===y.instancing?b=!0:r.isInstancedMesh||!0!==y.instancing?r.isSkinnedMesh&&!1===y.skinning?b=!0:r.isSkinnedMesh||!0!==y.skinning?r.isInstancedMesh&&!0===y.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===y.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===y.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===y.instancingMorph&&null!==r.morphTexture||y.envMap!==l||!0===i.fog&&y.fog!==a?b=!0:void 0===y.numClippingPlanes||y.numClippingPlanes===he.numPlanes&&y.numIntersection===he.numIntersection?(y.vertexAlphas!==c||y.vertexTangents!==u||y.morphTargets!==d||y.morphNormals!==h||y.morphColors!==f||y.toneMapping!==p||y.morphTargetsCount!==v||y.numMultiviewViews!==m)&&(b=!0):b=!0:b=!0:b=!0:b=!0:(b=!0,y.__version=i.version);let S=y.currentProgram;!0===b&&(S=Be(i,t,r));let M=!1,E=!1,C=!1;const P=S.getUniforms(),L=y.uniforms;J.useProgram(S.program)&&(M=!0,E=!0,C=!0);i.id!==A&&(A=i.id,E=!0);if(M||R!==e){if(S.numMultiviewViews>0)pe.updateCameraProjectionMatricesUniform(e,P),pe.updateCameraViewMatricesUniform(e,P);else{J.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),P.setValue(we,"projectionMatrix",e.projectionMatrix),P.setValue(we,"viewMatrix",e.matrixWorldInverse)}const t=P.map.cameraPosition;void 0!==t&&t.setValue(we,X.setFromMatrixPosition(e.matrixWorld)),Q.logarithmicDepthBuffer&&P.setValue(we,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&P.setValue(we,"isOrthographic",!0===e.isOrthographicCamera),R!==e&&(R=e,E=!0,C=!0)}if(r.isSkinnedMesh){P.setOptional(we,r,"bindMatrix"),P.setOptional(we,r,"bindMatrixInverse");const e=r.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),P.setValue(we,"boneTexture",e.boneTexture,ne))}r.isBatchedMesh&&(P.setOptional(we,r,"batchingTexture"),P.setValue(we,"batchingTexture",r._matricesTexture,ne),P.setOptional(we,r,"batchingIdTexture"),P.setValue(we,"batchingIdTexture",r._indirectTexture,ne),P.setOptional(we,r,"batchingColorTexture"),null!==r._colorsTexture&&P.setValue(we,"batchingColorTexture",r._colorsTexture,ne));const I=n.morphAttributes;void 0===I.position&&void 0===I.normal&&void 0===I.color||ge.update(r,n,S);(E||y.receiveShadow!==r.receiveShadow)&&(y.receiveShadow=r.receiveShadow,P.setValue(we,"receiveShadow",r.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(L.envMap.value=l,L.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);i.isMeshStandardMaterial&&null===i.envMap&&null!==t.environment&&(L.envMapIntensity.value=t.environmentIntensity);void 0!==L.dfgLUT&&(L.dfgLUT.value=(null===mg&&(mg=new Uh(pg,32,32,Dl,Sl),mg.minFilter=fl,mg.magFilter=fl,mg.wrapS=ll,mg.wrapT=ll,mg.generateMipmaps=!1,mg.needsUpdate=!0),mg));E&&(P.setValue(we,"toneMappingExposure",w.toneMappingExposure),y.needsLights&&(N=C,(D=L).ambientLightColor.needsUpdate=N,D.lightProbe.needsUpdate=N,D.directionalLights.needsUpdate=N,D.directionalLightShadows.needsUpdate=N,D.pointLights.needsUpdate=N,D.pointLightShadows.needsUpdate=N,D.spotLights.needsUpdate=N,D.spotLightShadows.needsUpdate=N,D.rectAreaLights.needsUpdate=N,D.hemisphereLights.needsUpdate=N),a&&!0===i.fog&&ce.refreshFogUniforms(L,a),ce.refreshMaterialUniforms(L,i,k,O,x.state.transmissionRenderTarget[e.id]),_m.upload(we,Ve(y),L,ne));var D,N;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(_m.upload(we,Ve(y),L,ne),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&P.setValue(we,"center",r.center);S.numMultiviewViews>0?pe.updateObjectMatricesUniforms(r,e,P):(P.setValue(we,"modelViewMatrix",r.modelViewMatrix),P.setValue(we,"normalMatrix",r.normalMatrix));if(P.setValue(we,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.uniformsGroups;for(let t=0,n=e.length;t<n;t++){const n=e[t];be.update(n,S),be.bind(n,S)}}return S}(e,t,n,i,r);J.setMaterial(i,s);let l=n.index,c=1;if(!0===i.wireframe){if(l=se.getWireframeAttribute(n),void 0===l)return;c=2}const u=n.drawRange,d=n.attributes.position;let h=u.start*c,f=(u.start+u.count)*c;null!==a&&(h=Math.max(h,a.start*c),f=Math.min(f,(a.start+a.count)*c)),null!==l?(h=Math.max(h,0),f=Math.min(f,l.count)):null!=d&&(h=Math.max(h,0),f=Math.min(f,d.count));const p=f-h;if(p<0||p===1/0)return;let m;_e.setup(r,i,o,n,l);let g=ve;if(null!==l&&(m=ae.get(l),g=ye,g.setIndex(m)),r.isMesh)!0===i.wireframe?(J.setLineWidth(i.wireframeLinewidth*K()),g.setMode(we.LINES)):g.setMode(we.TRIANGLES);else if(r.isLine){let e=i.linewidth;void 0===e&&(e=1),J.setLineWidth(e*K()),r.isLineSegments?g.setMode(we.LINES):r.isLineLoop?g.setMode(we.LINE_LOOP):g.setMode(we.LINE_STRIP)}else r.isPoints?g.setMode(we.POINTS):r.isSprite&&g.setMode(we.TRIANGLES);if(r.isBatchedMesh)if(null!==r._multiDrawInstances)Fc("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),g.renderMultiDrawInstances(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount,r._multiDrawInstances);else if(Z.get("WEBGL_multi_draw"))g.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const e=r._multiDrawStarts,t=r._multiDrawCounts,n=r._multiDrawCount,a=l?ae.get(l).bytesPerElement:1,s=te.get(i).currentProgram.getUniforms();for(let i=0;i<n;i++)s.setValue(we,"_gl_DrawID",i),g.render(e[i]/a,t[i])}else if(r.isInstancedMesh)g.renderInstances(h,p,r.count);else if(n.isInstancedBufferGeometry){const e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);g.renderInstances(h,p,t)}else g.render(h,p)},this.compile=function(e,t,n=null){null===n&&(n=e),x=de.get(n),x.init(t),b.push(x),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),x.setupLights();const i=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;const t=e.material;if(t)if(Array.isArray(t))for(let r=0;r<t.length;r++){const a=t[r];Pe(a,n,e),i.add(a)}else Pe(t,n,e),i.add(t)}),x=b.pop(),i},this.compileAsync=function(e,t,n=null){const i=this.compile(e,t,n);return new Promise(t=>{function n(){i.forEach(function(e){te.get(e).currentProgram.isReady()&&i.delete(e)}),0!==i.size?setTimeout(n,10):t(e)}null!==Z.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)})};let Le=null;function Ie(){Ne.stop()}function De(){Ne.start()}const Ne=new Df;function Oe(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||H.intersectsSprite(e)){i&&q.setFromMatrixPosition(e.matrixWorld).applyMatrix4(W);const t=oe.update(e),r=e.material;r.visible&&y.push(e,t,r,n,q.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||H.intersectsObject(e))){const t=oe.update(e),r=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),q.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),q.copy(t.boundingSphere.center)),q.applyMatrix4(e.matrixWorld).applyMatrix4(W)),Array.isArray(r)){const i=t.groups;for(let a=0,s=i.length;a<s;a++){const s=i[a],o=r[s.materialIndex];o&&o.visible&&y.push(e,t,o,n,q.z,s)}}else r.visible&&y.push(e,t,r,n,q.z,null)}const r=e.children;for(let e=0,a=r.length;e<a;e++)Oe(r[e],t,n,i)}function ke(e,t,n,i){const{opaque:r,transmissive:a,transparent:s}=e;x.setupLightsView(n),!0===G&&he.setGlobalState(w.clippingPlanes,n),i&&J.viewport(C.copy(i)),r.length>0&&Fe(r,t,n),a.length>0&&Fe(a,t,n),s.length>0&&Fe(s,t,n),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function Ue(e,t,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===x.state.transmissionRenderTarget[i.id]&&(x.state.transmissionRenderTarget[i.id]=new vu(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")||Z.has("EXT_color_buffer_float")?Sl:gl,minFilter:ml,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ru.workingColorSpace}));const a=x.state.transmissionRenderTarget[i.id],s=i.viewport||C;a.setSize(s.z*w.transmissionResolutionScale,s.w*w.transmissionResolutionScale);const o=w.getRenderTarget(),l=w.getActiveCubeFace(),c=w.getActiveMipmapLevel();w.setRenderTarget(a),w.getClearColor(I),D=w.getClearAlpha(),D<1&&w.setClearColor(16777215,.5),w.clear(),Y&&me.render(n);const u=w.toneMapping;w.toneMapping=0;const d=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),x.setupLightsView(i),!0===G&&he.setGlobalState(w.clippingPlanes,i),Fe(e,n,i),ne.updateMultisampleRenderTarget(a),ne.updateRenderTargetMipmap(a),!1===Z.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let r=0,a=t.length;r<a;r++){const a=t[r],{object:s,geometry:o,material:l,group:c}=a;if(2===l.side&&s.layers.test(i.layers)){const t=l.side;l.side=1,l.needsUpdate=!0,ze(s,n,i,o,l,c),l.side=t,l.needsUpdate=!0,e=!0}}!0===e&&(ne.updateMultisampleRenderTarget(a),ne.updateRenderTargetMipmap(a))}w.setRenderTarget(o,l,c),w.setClearColor(I,D),void 0!==d&&(i.viewport=d),w.toneMapping=u}function Fe(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,a=e.length;r<a;r++){const a=e[r],{object:s,geometry:o,group:l}=a;let c=a.material;!0===c.allowOverride&&null!==i&&(c=i),s.layers.test(n.layers)&&ze(s,t,n,o,c,l)}}function ze(e,t,n,i,r,a){e.onBeforeRender(w,t,n,i,r,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(w,t,n,i,e,a),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,w.renderBufferDirect(n,t,i,r,e,a),r.side=0,r.needsUpdate=!0,w.renderBufferDirect(n,t,i,r,e,a),r.side=2):w.renderBufferDirect(n,t,i,r,e,a),e.onAfterRender(w,t,n,i,r,a)}function Be(e,t,n){!0!==t.isScene&&(t=$);const i=te.get(e),r=x.state.lights,a=x.state.shadowsArray,s=r.state.version,o=le.getParameters(e,r.state,a,t,n),l=le.getProgramCacheKey(o);let c=i.programs;i.environment=e.isMeshStandardMaterial?t.environment:null,i.fog=t.fog,i.envMap=(e.isMeshStandardMaterial?re:ie).get(e.envMap||i.environment),i.envMapRotation=null!==i.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation,void 0===c&&(e.addEventListener("dispose",Ce),c=new Map,i.programs=c);let u=c.get(l);if(void 0!==u){if(i.currentProgram===u&&i.lightsStateVersion===s)return He(e,o),u}else o.uniforms=le.getUniforms(e),e.onBeforeCompile(o,w),u=le.acquireProgram(o,l),c.set(l,u),i.uniforms=o.uniforms;const d=i.uniforms;return(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(d.clippingPlanes=he.uniform),He(e,o),i.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),i.lightsStateVersion=s,i.needsLights&&(d.ambientLightColor.value=r.state.ambient,d.lightProbe.value=r.state.probe,d.directionalLights.value=r.state.directional,d.directionalLightShadows.value=r.state.directionalShadow,d.spotLights.value=r.state.spot,d.spotLightShadows.value=r.state.spotShadow,d.rectAreaLights.value=r.state.rectArea,d.ltc_1.value=r.state.rectAreaLTC1,d.ltc_2.value=r.state.rectAreaLTC2,d.pointLights.value=r.state.point,d.pointLightShadows.value=r.state.pointShadow,d.hemisphereLights.value=r.state.hemi,d.directionalShadowMap.value=r.state.directionalShadowMap,d.directionalShadowMatrix.value=r.state.directionalShadowMatrix,d.spotShadowMap.value=r.state.spotShadowMap,d.spotLightMatrix.value=r.state.spotLightMatrix,d.spotLightMap.value=r.state.spotLightMap,d.pointShadowMap.value=r.state.pointShadowMap,d.pointShadowMatrix.value=r.state.pointShadowMatrix),i.currentProgram=u,i.uniformsList=null,u}function Ve(e){if(null===e.uniformsList){const t=e.currentProgram.getUniforms();e.uniformsList=_m.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function He(e,t){const n=te.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping,n.numMultiviewViews=t.numMultiviewViews}var Ge;Ne.setAnimationLoop(function(e){Le&&Le(e)}),"undefined"!=typeof self&&Ne.setContext(self),this.setAnimationLoop=function(e){Le=e,Ee.setAnimationLoop(e),null===e?Ne.stop():Ne.start()},Ee.addEventListener("sessionstart",Ie),Ee.addEventListener("sessionend",De),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void Uc("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===S)return;if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===Ee.enabled&&!0===Ee.isPresenting&&(!0===Ee.cameraAutoUpdate&&Ee.updateCamera(t),t=Ee.getCamera()),!0===e.isScene&&e.onBeforeRender(w,e,t,T),x=de.get(e,b.length),x.init(t),b.push(x),W.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),H.setFromProjectionMatrix(W,Cc,t.reversedDepth),j=this.localClippingEnabled,G=he.init(this.clippingPlanes,j),y=ue.get(e,_.length),y.init(),_.push(y),!0===Ee.enabled&&!0===Ee.isPresenting){const e=w.xr.getDepthSensingMesh();null!==e&&Oe(e,t,-1/0,w.sortObjects)}Oe(e,t,0,w.sortObjects),y.finish(),!0===w.sortObjects&&y.sort(U,F),Y=!1===Ee.enabled||!1===Ee.isPresenting||!1===Ee.hasDepthSensing(),Y&&me.addToRenderList(y,e),this.info.render.frame++,!0===G&&he.beginShadows();const n=x.state.shadowsArray;fe.render(n,e,t),!0===G&&he.endShadows(),!0===this.info.autoReset&&this.info.reset();const i=y.opaque,r=y.transmissive;if(x.setupLights(),t.isArrayCamera){const n=t.cameras;if(r.length>0)for(let t=0,a=n.length;t<a;t++){Ue(i,r,e,n[t])}if(Y&&me.render(e),Ee.enabled&&Ee.isMultiview)ne.setDeferTextureUploads(!0),ke(y,e,t,t.cameras[0].viewport);else for(let t=0,i=n.length;t<i;t++){const i=n[t];ke(y,e,i,i.viewport)}}else r.length>0&&Ue(i,r,e,t),Y&&me.render(e),ke(y,e,t);null!==T&&0===E&&(ne.updateMultisampleRenderTarget(T),ne.updateRenderTargetMipmap(T)),!0===e.isScene&&e.onAfterRender(w,e,t),ne.runDeferredUploads(),_e.resetDefaultState(),A=-1,R=null,b.pop(),b.length>0?(x=b[b.length-1],!0===G&&he.setGlobalState(w.clippingPlanes,x.state.camera)):x=null,_.pop(),y=_.length>0?_[_.length-1]:null},this.setTexture2D=(Ge=!1,function(e,t){e&&e.isWebGLRenderTarget&&(Ge||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),Ge=!0),e=e.texture),ne.setTexture2D(e,t)}),this.getActiveCubeFace=function(){return M},this.getActiveMipmapLevel=function(){return E},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(e,t,n){const i=te.get(e);i.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,i.__autoAllocateDepthBuffer||(i.__useRenderToTexture=!1),te.get(e.texture).__webglTexture=t,te.get(e.depthTexture).__webglTexture=i.__autoAllocateDepthBuffer?void 0:n,i.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){const n=te.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t};const je=we.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){null===e&&this.xr.isPresenting&&(e=this.xr.getRenderTarget()),T=e,M=t,E=n;let i=!0,r=null,a=!1,s=!1;if(e){const o=te.get(e);if(void 0!==o.__useDefaultFramebuffer)J.bindFramebuffer(we.FRAMEBUFFER,null),i=!1;else if(void 0===o.__webglFramebuffer)ne.setupRenderTarget(e);else if(o.__hasExternalTextures)ne.rebindTextures(e,te.get(e.texture).__webglTexture,te.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){const t=e.depthTexture;if(o.__boundDepthTexture!==t){if(null!==t&&te.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ne.setupDepthRenderbuffer(e)}}const l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(s=!0);const c=te.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],a=!0):r=e.samples>0&&!1===ne.useMultisampledRTT(e)?te.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,C.copy(e.viewport),P.copy(e.scissor),L=e.scissorTest}else C.copy(z).multiplyScalar(k).floor(),P.copy(B).multiplyScalar(k).floor(),L=V;0!==n&&(r=je);if(J.bindFramebuffer(we.FRAMEBUFFER,r)&&i&&J.drawBuffers(e,r),J.viewport(C),J.scissor(P),J.setScissorTest(L),a){const i=te.get(e.texture);we.framebufferTexture2D(we.FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(s){const i=t;for(let t=0;t<e.textures.length;t++){const r=te.get(e.textures[t]);we.framebufferTextureLayer(we.FRAMEBUFFER,we.COLOR_ATTACHMENT0+t,r.__webglTexture,n,i)}}else if(null!==e&&0!==n){const t=te.get(e.texture);we.framebufferTexture2D(we.FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_2D,t.__webglTexture,n)}A=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,s,o=0){if(!e||!e.isWebGLRenderTarget)return void Uc("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=te.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(l=l[s]),l){J.bindFramebuffer(we.FRAMEBUFFER,l);try{const s=e.textures[o],l=s.format,c=s.type;if(!Q.textureFormatReadable(l))return void Uc("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!Q.textureTypeReadable(c))return void Uc("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&(e.textures.length>1&&we.readBuffer(we.COLOR_ATTACHMENT0+o),we.readPixels(t,n,i,r,xe.convert(l),xe.convert(c),a))}finally{const e=null!==T?te.get(T).__webglFramebuffer:null;J.bindFramebuffer(we.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,i,r,a,s,o=0){if(!e||!e.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=te.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(l=l[s]),l){if(t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r){J.bindFramebuffer(we.FRAMEBUFFER,l);const s=e.textures[o],c=s.format,u=s.type;if(!Q.textureFormatReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Q.textureTypeReadable(u))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const d=we.createBuffer();we.bindBuffer(we.PIXEL_PACK_BUFFER,d),we.bufferData(we.PIXEL_PACK_BUFFER,a.byteLength,we.STREAM_READ),e.textures.length>1&&we.readBuffer(we.COLOR_ATTACHMENT0+o),we.readPixels(t,n,i,r,xe.convert(c),xe.convert(u),0);const h=null!==T?te.get(T).__webglFramebuffer:null;J.bindFramebuffer(we.FRAMEBUFFER,h);const f=we.fenceSync(we.SYNC_GPU_COMMANDS_COMPLETE,0);return we.flush(),await function(e,t,n){return new Promise(function(i,r){setTimeout(function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:i()}},n)})}(we,f,4),we.bindBuffer(we.PIXEL_PACK_BUFFER,d),we.getBufferSubData(we.PIXEL_PACK_BUFFER,0,a),we.deleteBuffer(d),we.deleteSync(f),a}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(e,t=null,n=0){const i=Math.pow(2,-n),r=Math.floor(e.image.width*i),a=Math.floor(e.image.height*i),s=null!==t?t.x:0,o=null!==t?t.y:0;ne.setTexture2D(e,0),we.copyTexSubImage2D(we.TEXTURE_2D,n,0,0,s,o,r,a),J.unbindTexture()};const We=we.createFramebuffer(),Xe=we.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,i=null,r=0,a=null){let s,o,l,c,u,d,h,f,p;null===a&&(0!==r?(Fc("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),a=r,r=0):a=0);const m=e.isCompressedTexture?e.mipmaps[a]:e.image;if(null!==n)s=n.max.x-n.min.x,o=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{const t=Math.pow(2,-r);s=Math.floor(m.width*t),o=Math.floor(m.height*t),l=e.isDataArrayTexture?m.depth:e.isData3DTexture?Math.floor(m.depth*t):1,c=0,u=0,d=0}null!==i?(h=i.x,f=i.y,p=i.z):(h=0,f=0,p=0);const g=xe.convert(t.format),v=xe.convert(t.type);let y;t.isData3DTexture?(ne.setTexture3D(t,0),y=we.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(ne.setTexture2DArray(t,0),y=we.TEXTURE_2D_ARRAY):(ne.setTexture2D(t,0),y=we.TEXTURE_2D),we.pixelStorei(we.UNPACK_FLIP_Y_WEBGL,t.flipY),we.pixelStorei(we.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),we.pixelStorei(we.UNPACK_ALIGNMENT,t.unpackAlignment);const x=we.getParameter(we.UNPACK_ROW_LENGTH),_=we.getParameter(we.UNPACK_IMAGE_HEIGHT),b=we.getParameter(we.UNPACK_SKIP_PIXELS),w=we.getParameter(we.UNPACK_SKIP_ROWS),S=we.getParameter(we.UNPACK_SKIP_IMAGES);we.pixelStorei(we.UNPACK_ROW_LENGTH,m.width),we.pixelStorei(we.UNPACK_IMAGE_HEIGHT,m.height),we.pixelStorei(we.UNPACK_SKIP_PIXELS,c),we.pixelStorei(we.UNPACK_SKIP_ROWS,u),we.pixelStorei(we.UNPACK_SKIP_IMAGES,d);const M=e.isDataArrayTexture||e.isData3DTexture,E=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){const n=te.get(e),i=te.get(t),m=te.get(n.__renderTarget),g=te.get(i.__renderTarget);J.bindFramebuffer(we.READ_FRAMEBUFFER,m.__webglFramebuffer),J.bindFramebuffer(we.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<l;n++)M&&(we.framebufferTextureLayer(we.READ_FRAMEBUFFER,we.COLOR_ATTACHMENT0,te.get(e).__webglTexture,r,d+n),we.framebufferTextureLayer(we.DRAW_FRAMEBUFFER,we.COLOR_ATTACHMENT0,te.get(t).__webglTexture,a,p+n)),we.blitFramebuffer(c,u,s,o,h,f,s,o,we.DEPTH_BUFFER_BIT,we.NEAREST);J.bindFramebuffer(we.READ_FRAMEBUFFER,null),J.bindFramebuffer(we.DRAW_FRAMEBUFFER,null)}else if(0!==r||e.isRenderTargetTexture||te.has(e)){const n=te.get(e),i=te.get(t);J.bindFramebuffer(we.READ_FRAMEBUFFER,We),J.bindFramebuffer(we.DRAW_FRAMEBUFFER,Xe);for(let e=0;e<l;e++)M?we.framebufferTextureLayer(we.READ_FRAMEBUFFER,we.COLOR_ATTACHMENT0,n.__webglTexture,r,d+e):we.framebufferTexture2D(we.READ_FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_2D,n.__webglTexture,r),E?we.framebufferTextureLayer(we.DRAW_FRAMEBUFFER,we.COLOR_ATTACHMENT0,i.__webglTexture,a,p+e):we.framebufferTexture2D(we.DRAW_FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_2D,i.__webglTexture,a),0!==r?we.blitFramebuffer(c,u,s,o,h,f,s,o,we.COLOR_BUFFER_BIT,we.NEAREST):E?we.copyTexSubImage3D(y,a,h,f,p+e,c,u,s,o):we.copyTexSubImage2D(y,a,h,f,c,u,s,o);J.bindFramebuffer(we.READ_FRAMEBUFFER,null),J.bindFramebuffer(we.DRAW_FRAMEBUFFER,null)}else E?e.isDataTexture||e.isData3DTexture?we.texSubImage3D(y,a,h,f,p,s,o,l,g,v,m.data):t.isCompressedArrayTexture?we.compressedTexSubImage3D(y,a,h,f,p,s,o,l,g,m.data):we.texSubImage3D(y,a,h,f,p,s,o,l,g,v,m):e.isDataTexture?we.texSubImage2D(we.TEXTURE_2D,a,h,f,s,o,g,v,m.data):e.isCompressedTexture?we.compressedTexSubImage2D(we.TEXTURE_2D,a,h,f,m.width,m.height,g,m.data):we.texSubImage2D(we.TEXTURE_2D,a,h,f,s,o,g,v,m);we.pixelStorei(we.UNPACK_ROW_LENGTH,x),we.pixelStorei(we.UNPACK_IMAGE_HEIGHT,_),we.pixelStorei(we.UNPACK_SKIP_PIXELS,b),we.pixelStorei(we.UNPACK_SKIP_ROWS,w),we.pixelStorei(we.UNPACK_SKIP_IMAGES,S),0===a&&t.generateMipmaps&&we.generateMipmap(y),J.unbindTexture()},this.initRenderTarget=function(e){void 0===te.get(e).__webglFramebuffer&&ne.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?ne.setTextureCube(e,0):e.isData3DTexture?ne.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?ne.setTexture2DArray(e,0):ne.setTexture2D(e,0),J.unbindTexture()},this.resetState=function(){M=0,E=0,T=null,J.reset(),_e.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Cc}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=ru._getDrawingBufferColorSpace(e),t.unpackColorSpace=ru._getUnpackColorSpace()}}const vg=["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"];const yg=new qu,xg=new qu,_g={x:"XYZ",y:"YXZ",z:"ZXY"};function bg(e,t,n,i,r,a){yg.copy(n),null!=r&&yg.premultiply(xg.copy(r).invert());const s=new Kc,o=new Yc,l=new Kc;let c;yg.decompose(s,o,l),Ig(s,i.initialTargetPosition,a.translate??!0);const u=a.rotate??!0;if(!1===u)o.copy(i.initialTargetQuaternion),c=i.initialTargetRotation.clone();else if(Array.isArray(u)||!0===u||"string"!=typeof u&&!Array.isArray(u)&&!0===u.x&&!0===u.y&&!0===u.z)c=(new id).setFromQuaternion(o,i.initialTargetRotation.order);else if("string"==typeof u){const e=_g[u];c=(new id).setFromQuaternion(o,e);for(const t of e){const e=t.toLowerCase();e!==u&&(c[e]=0)}c.order=i.initialTargetRotation.order,o.setFromEuler(c)}else c=function(e,t,n){let i="",r="";for(const e of t.order)!1===n[e.toLowerCase()]?r+=e:i+=e;const a=i+r,s=(new id).setFromQuaternion(e,a);for(const e of a){const i=e.toLowerCase();s[i]=Dg(i,s[i],t[i],n)}return e.setFromEuler(s),s}(o,i.initialTargetRotation,u);return"object"==typeof a.scale&&a.scale.uniform||Ig(l,i.initialTargetScale,a.scale??!0),{pointerAmount:t,position:s,quaternion:o,rotation:c,scale:l,time:e}}const wg=new Vh,Sg=new Kc,Mg=new Kc,Eg=new Kc,Tg=new Yc;function Ag(e,t,n){return wg.normal.copy(e),wg.constant=0,function(e,t){if(0===t.x)return void e.set(1,0,0);if(0===t.y)return void e.set(0,1,0);if(0===t.z)return void e.set(0,0,1);e.set(-t.y,t.x,0)}(Sg,wg.normal),Mg.copy(Sg),Mg.applyQuaternion(Tg.copy(t).invert().premultiply(n)),wg.projectPoint(Sg,Sg).normalize(),wg.projectPoint(Mg,Mg).normalize(),(Eg.crossVectors(Sg,wg.normal).dot(Mg)<0?1:-1)*Sg.angleTo(Mg)}const Rg=new Kc,Cg=new Vh,Pg=new Kc,Lg=new Kc;function Ig(e,t,n){if(Array.isArray(n))switch(n.length){case 0:return void e.copy(t);case 1:return e.sub(t),Yg(e,n[0]instanceof Kc?n[0]:Rg.fromArray(n[0])),void e.add(t);case 2:return Rg.crossVectors(n[0]instanceof Kc?n[0]:Pg.fromArray(n[0]),n[1]instanceof Kc?n[1]:Lg.fromArray(n[1])),Cg.setFromNormalAndCoplanarPoint(Rg,t),void Cg.projectPoint(e,e)}else e.x=Dg("x",e.x,t.x,n),e.y=Dg("y",e.y,t.y,n),e.z=Dg("z",e.z,t.z,n)}function Dg(e,t,n,i){if("boolean"==typeof i)return i?t:n;if("string"==typeof i)return i===e?t:n;const r=i[e];return!1===r?n:Array.isArray(r)?function(e,t,n){return Math.max(t,Math.min(n,e))}(t,...r):t}function Ng(e=!0,t,n,i,r,a){if(e){switch(t.length){case 0:case 3:return;case 1:return void function(e,t,n,i,r){const a=null==r?0:1-Math.abs(t.dot(r));if(null==r||a<.001)return void $g(i,e,t);qg.subVectors(n,e);const s=t.dot(r),o=t.dot(qg),l=r.dot(qg),c=1-s*s,u=(o-s*l)/c;if((s*o-l)/c<0)return void $g(i,e,t);qg.copy(i),i.copy(e).addScaledVector(t,u)}(n,...t,i,r,a);case 2:return void function(e,t,n,i,r,a){Xg.crossVectors(e,t).normalize(),Wg.setFromNormalAndCoplanarPoint(Xg,n);const s=null==a?0:Math.abs(Xg.dot(a));if(null==a||s<.01)return void Wg.projectPoint(r,r);const o=Wg.distanceToPoint(i),l=-o/a.dot(Wg.normal);if(l<0)return void Wg.projectPoint(r,r);qg.copy(r),r.copy(i).addScaledVector(a,l)}(...t,n,i,r,a)}throw new Error(`space cannot be ${t.length}D but received (${t.map(e=>e.toArray().join("/")).join("; ")})`)}}const Og={x:new Kc(1,0,0),y:new Kc(0,1,0),z:new Kc(0,0,1)};function kg(e,t,n,i,r){if(!1!==i){if(!0===i)return e[0]=Og.x,e[1]=Og.y,void(e[2]=Og.z);if("string"!=typeof i)if(Array.isArray(i))for(const a of i)Hg(e,t,n,a,r);else!1!==i.x&&Hg(e,t,n,"x",r),!1!==i.y&&Hg(e,t,n,"y",r),!1!==i.z&&Hg(e,t,n,"z",r);else Hg(e,t,n,i,r)}}const Ug=new Yc,Fg=new id,zg=new Kc,Bg=new Kc,Vg=new Kc;function Hg(e,t,n,i,r){if(Array.isArray(i)?zg.set(...i):i instanceof Kc?zg.copy(i):zg.copy(Og[i]),"translate"===r)return zg.applyQuaternion(t),void jg(e,zg);if("scale"===r)return Array.isArray(i)?Ug.identity():Ug.setFromEuler(n),Ug.premultiply(t),zg.applyQuaternion(Ug),void jg(e,zg);if(Array.isArray(i))Fg.set(0,0,0);else{Fg.copy(n);for(let e=2;e>=0;e--){const t=n.order[e].toLowerCase();if(Fg[t]=0,t===i)break}}Ug.setFromEuler(Fg).premultiply(t),zg.normalize(),Bg.set(0,1,0),zg.dot(Bg)>.99&&Bg.set(0,0,1),Vg.crossVectors(zg,Bg).normalize(),Bg.copy(Vg),Vg.applyQuaternion(Ug),jg(e,Vg),Vg.crossVectors(zg,Bg).normalize(),Vg.applyQuaternion(Ug),jg(e,Vg)}const Gg=new Kc;function jg(e,t){3!==e.length&&(0!==e.length?1!==e.length?(Gg.crossVectors(e[0],e[1]),Math.abs(Gg.dot(t))<.001||e.push(t.clone())):Math.abs(e[0].dot(t))<.999&&e.push(t.clone()):e.push(t.clone()))}const Wg=new Vh,Xg=new Kc,qg=new Kc;function $g(e,t,n){e.sub(t),Yg(e,n),e.add(t)}function Yg(e,t){const n=e.dot(t);e.copy(t).multiplyScalar(n)}const Kg=new qu,Zg=new qu,Qg=new Kc,Jg=new Kc,ev=new Yc,tv=new Kc(1,1,1),nv=[];const iv=new Kc,rv=new Kc,av=new Kc,sv=new Kc,ov=new Kc,lv=new Kc,cv=new Kc,uv=new qu,dv=new qu,hv=new qu,fv=new Yc,pv=new Yc,mv=[];const gv=new Kc,vv=new Kc,yv=new Kc,xv=new Kc,_v=new Kc,bv=new Yc,wv=new Yc,Sv=new qu,Mv=new Kc,Ev=[];class Tv{t1;t2;_position;_quaternion;_rotation;_scale;constructor(e,t){this.t1=e,this.t2=t}get time(){return this.t1.time-this.t2.time}get position(){return this._position??=this.t1.position.clone().sub(this.t2.position)}get quaternion(){return this._quaternion??=this.t2.quaternion.clone().invert().premultiply(this.t1.quaternion)}get rotation(){return this._rotation??=(new id).setFromQuaternion(this.quaternion)}get scale(){return this._scale??=this.t1.scale.clone().sub(this.t2.scale)}}class Av{cancel;previous;memo;event;initial;current;first;last;_delta;_offset;constructor(e){this.cancel=e}start(e,t){this.event=e,this.previous=void 0,this.current=t,this.initial=t,this.first=!0,this.last=!1,this.memo=void 0,this._delta=void 0,this._offset=void 0}update(e,t){this.event=e,this.previous=this.current,this.current=t,this.first=!1,this.last=!1,this._delta=void 0,this._offset=void 0}end(e){this.event=e,this.first=!1,this.last=!0,this._delta=void 0,this._offset=void 0}get delta(){if(null!=this.previous)return this._delta??=new Tv(this.current,this.previous)}get offset(){return this._offset??=new Tv(this.current,this.initial)}}function Rv(e,t){if("sphere"===e.details.type)return!1;if("lines"===e.details.type){const{line:n}=e.details;return t.copy(n.end).sub(n.start).normalize(),!0}return"screen-ray"===e.details.type?(t.copy(e.details.direction),!0):(t.set(0,0,-1).applyQuaternion(e.pointerQuaternion),!0)}const Cv=new Kc;class Pv{target;getOptions;outputState;latestMoveEvent;inputState=new Map;capturedObjects=new Map;initialTargetPosition=new Kc;initialTargetQuaternion=new Yc;initialTargetRotation=new id;initialTargetScale=new Kc;initialTargetParentWorldMatrix;prevTwoPointerDeltaRotation;prevTranslateAsDeltaRotation;prevAngle;handlers={onPointerDown:this.onPointerDown.bind(this),onPointerMove:this.onPointerMove.bind(this),onPointerUp:this.onPointerUp.bind(this)};constructor(e,t=()=>({})){this.target=e,this.getOptions=t,this.outputState=new Av(this.cancel.bind(this))}firstOnPointer(e){const t=this.getTarget();if(null==t)return;const n=Rv(e,Cv)?Cv.clone():void 0;e.intersection.details.type,this.inputState.set(e.pointerId,{pointerWorldDirection:n,pointerWorldPoint:e.point,pointerWorldOrigin:e.pointerPosition,pointerWorldQuaternion:e.pointerQuaternion,initialPointerWorldPoint:e.point.clone(),initialPointerWorldDirection:n?.clone(),initialPointerWorldQuaternion:e.pointerQuaternion.clone(),prevPointerWorldQuaternion:e.pointerQuaternion}),this.save(),1===this.inputState.size&&this.outputState.start(e,{pointerAmount:1,time:e.timeStamp,position:this.initialTargetPosition.clone(),quaternion:this.initialTargetQuaternion.clone(),rotation:this.initialTargetRotation.clone(),scale:this.initialTargetScale.clone()}),this.outputState.memo=this.apply(t)}onPointerDown(e){!1!==this.getOptions().filter?.(e)&&(this.stopPropagation(e),this.capturePointer(e.pointerId,e.object)&&this.firstOnPointer(e))}onPointerMove(e){if(!this.capturedObjects.has(e.pointerId))return;this.stopPropagation(e);const t=this.inputState.get(e.pointerId);null!=t?(this.latestMoveEvent=e,t.pointerWorldPoint=e.point,t.prevPointerWorldQuaternion=t.pointerWorldQuaternion,t.pointerWorldQuaternion=e.pointerQuaternion,t.pointerWorldOrigin=e.pointerPosition,null!=t.pointerWorldDirection&&Rv(e,t.pointerWorldDirection)):this.firstOnPointer(e)}cancel(){if(0===this.capturedObjects.size)return;for(const[e,t]of this.capturedObjects)t.releasePointerCapture(e);this.capturedObjects.clear(),this.inputState.clear(),this.outputState.end(void 0);const e=this.getTarget();null!=e&&this.apply(e)}onPointerUp(e){this.capturedObjects.has(e.pointerId)&&(this.stopPropagation(e),this.releasePointer(e.pointerId,e.object,e))}update(e){const t=this.getTarget();if(null==t||0===this.inputState.size||null==this.latestMoveEvent&&!1===(this.getOptions().alwaysUpdate??!1))return;const n=this.getOptions();let i;if("as-rotate"===n.translate||"as-rotate-and-scale"===n.translate||"as-scale"===n.translate){n.translate,this.prevTwoPointerDeltaRotation=void 0,this.prevAngle=void 0;const[r]=this.inputState.values(),a=t.matrixWorld,s=t.parent?.matrixWorld;i=function(e,t,n,i,r,a){if(null==r?bv.identity():r.decompose(gv,bv,vv),Ev.length=0,"as-scale"===a.translate&&kg(Ev,bv,n.initialTargetRotation,a.scale??!0,"scale"),"as-scale"!=a.translate&&kg(Ev,bv,n.initialTargetRotation,a.rotate??!0,"rotate"),Sv.makeTranslation(n.initialTargetPosition),null!=n.initialTargetParentWorldMatrix&&Sv.premultiply(n.initialTargetParentWorldMatrix),xv.setFromMatrixPosition(Sv),Ng(a.projectRays,Ev,t.initialPointerWorldPoint,t.pointerWorldOrigin,xv,void 0),xv.negate().add(t.initialPointerWorldPoint),_v.setFromMatrixPosition(i),Ng(a.projectRays,Ev,t.initialPointerWorldPoint,t.pointerWorldOrigin,_v,void 0),Ng(a.projectRays,Ev,t.initialPointerWorldPoint,t.pointerWorldOrigin,vv.copy(t.pointerWorldPoint),t.pointerWorldDirection),_v.negate().add(vv),"as-scale"===a.translate?bv.copy(n.initialTargetQuaternion):(gv.copy(xv),null!=n.prevTranslateAsDeltaRotation&&gv.applyQuaternion(n.prevTranslateAsDeltaRotation),gv.normalize(),vv.copy(_v).normalize(),bv.setFromUnitVectors(gv,vv),null==n.prevTranslateAsDeltaRotation?n.prevTranslateAsDeltaRotation=new Yc:bv.multiply(n.prevTranslateAsDeltaRotation),n.prevTranslateAsDeltaRotation.copy(bv),null!=n.initialTargetParentWorldMatrix&&(wv.setFromRotationMatrix(n.initialTargetParentWorldMatrix),bv.multiply(wv.normalize()),bv.premultiply(wv.invert())),bv.multiply(n.initialTargetQuaternion)),"as-rotate"===a.translate)Mv.set(1,1,1);else if("object"==typeof a.scale&&a.scale.uniform)Mv.setScalar(_v.length()/xv.length());else if("as-rotate-and-scale"===a.translate){Sv.compose(n.initialTargetPosition,n.initialTargetQuaternion,n.initialTargetScale),null!=n.initialTargetParentWorldMatrix&&Sv.premultiply(n.initialTargetParentWorldMatrix),Sv.decompose(vv,wv,yv),gv.copy(xv).applyQuaternion(wv.invert()).divide(yv),gv.x=Math.abs(gv.x),gv.y=Math.abs(gv.y),gv.z=Math.abs(gv.z);const e=Math.max(...gv.toArray());gv.divideScalar(e),Mv.set(1,1,1),Mv.addScaledVector(gv,_v.length()/xv.length()-1)}else null!=n.initialTargetParentWorldMatrix?(n.initialTargetParentWorldMatrix.decompose(gv,wv,vv),wv.multiply(n.initialTargetQuaternion)):wv.copy(n.initialTargetQuaternion),gv.copy(xv).applyQuaternion(wv.invert()),null!=r?(r.decompose(vv,wv,yv),wv.multiply(n.initialTargetQuaternion)):wv.copy(n.initialTargetQuaternion),vv.copy(_v).applyQuaternion(wv.invert()),Mv.x=Math.abs(gv.x)<.001?1:Math.abs(vv.x/gv.x),Mv.y=Math.abs(gv.y)<.001?1:Math.abs(vv.y/gv.y),Mv.z=Math.abs(gv.z)<.001?1:Math.abs(vv.z/gv.z);return Mv.multiply(n.initialTargetScale),Sv.compose(n.initialTargetPosition,bv,Mv),bg(e,1,Sv,n,void 0,a)}(e,r,this,a,s,n)}else if(1===this.inputState.size){this.prevTwoPointerDeltaRotation=void 0,this.prevAngle=void 0,this.prevTranslateAsDeltaRotation=void 0;const[r]=this.inputState.values();i=function(e,t,n,i,r){return null==i?ev.identity():i.decompose(Qg,ev,Jg),nv.length=0,kg(nv,ev,n.initialTargetRotation,r.translate??!0,"translate"),Zg.makeRotationFromQuaternion(ev.copy(t.initialPointerWorldQuaternion).invert()).multiply(Kg.makeTranslation(Qg.copy(t.initialPointerWorldPoint).negate())),null!=n.initialTargetParentWorldMatrix&&Zg.multiply(n.initialTargetParentWorldMatrix),Ng(r.projectRays,nv,t.initialPointerWorldPoint,t.pointerWorldOrigin,Qg.copy(t.pointerWorldPoint),t.pointerWorldDirection),ev.copy(t.pointerWorldQuaternion),!1===(r.rotate??!0)&&ev.copy(t.initialPointerWorldQuaternion),Kg.compose(Qg,ev,tv).multiply(Zg).multiply(Zg.compose(n.initialTargetPosition,n.initialTargetQuaternion,n.initialTargetScale)),bg(e,1,Kg,n,i,r)}(e,r,this,t.parent?.matrixWorld,n)}else{this.prevTranslateAsDeltaRotation=void 0;const[r,a]=this.inputState.values();i=function(e,t,n,i,r,a){null==r?fv.identity():r.decompose(av,fv,sv),mv.length=0,kg(mv,fv,i.initialTargetRotation,a.translate??!0,"translate"),kg(mv,fv,i.initialTargetRotation,a.rotate??!0,"rotate"),kg(mv,fv,i.initialTargetRotation,a.scale??!0,"scale"),Ng(a.projectRays,mv,t.initialPointerWorldPoint,t.pointerWorldOrigin,av.copy(t.pointerWorldPoint),t.pointerWorldDirection),Ng(a.projectRays,mv,n.initialPointerWorldPoint,n.pointerWorldOrigin,sv.copy(n.pointerWorldPoint),n.pointerWorldDirection),iv.copy(n.initialPointerWorldPoint).sub(t.initialPointerWorldPoint),rv.copy(sv).sub(av),av.copy(iv),null!=i.prevTwoPointerDeltaRotation&&av.applyQuaternion(i.prevTwoPointerDeltaRotation),av.normalize(),sv.copy(rv).normalize(),fv.setFromUnitVectors(av,sv),null==i.prevTwoPointerDeltaRotation?i.prevTwoPointerDeltaRotation=new Yc:fv.multiply(i.prevTwoPointerDeltaRotation),i.prevTwoPointerDeltaRotation.copy(fv);const s=.5*(Ag(sv,t.prevPointerWorldQuaternion,t.pointerWorldQuaternion)+Ag(sv,n.prevPointerWorldQuaternion,n.pointerWorldQuaternion))+(i.prevAngle??0);if(i.prevAngle=s,fv.premultiply(pv.setFromAxisAngle(sv,s)),hv.compose(i.initialTargetPosition,i.initialTargetQuaternion,i.initialTargetScale),null!=i.initialTargetParentWorldMatrix&&hv.premultiply(i.initialTargetParentWorldMatrix),"object"==typeof a.scale&&a.scale.uniform)cv.setScalar(rv.length()/iv.length());else{hv.decompose(ov,pv,lv),av.copy(iv).applyQuaternion(pv.invert()).divide(lv),av.x=Math.abs(av.x),av.y=Math.abs(av.y),av.z=Math.abs(av.z);const e=Math.max(...av.toArray());av.divideScalar(e),cv.set(1,1,1),cv.addScaledVector(av,rv.length()/iv.length()-1)}return uv.makeTranslation(av.copy(rv).multiplyScalar(.5).add(t.pointerWorldPoint)).multiply(dv.makeRotationFromQuaternion(fv)).multiply(dv.makeRotationFromQuaternion(pv.invert())).multiply(dv.makeScale(cv.x,cv.y,cv.z)).multiply(dv.makeRotationFromQuaternion(pv.invert())).multiply(dv.makeTranslation(av.copy(iv).multiplyScalar(.5).add(t.initialPointerWorldPoint).negate())).multiply(hv),bg(e,2,uv,i,r,a)}(e,r,a,this,t.parent?.matrixWorld,n)}this.outputState.update(this.latestMoveEvent,i),this.outputState.memo=this.apply(t),this.latestMoveEvent=void 0}getTarget(){return this.target instanceof _d?this.target:this.target?.current}capturePointer(e,t){if(this.capturedObjects.has(e))return!1;const{multitouch:n,translate:i}=this.getOptions();return(!1!==(n??!0)&&"string"!=typeof i||1!==this.capturedObjects.size)&&(this.capturedObjects.set(e,t),t.setPointerCapture(e),!0)}releasePointer(e,t,n){const i=this.getTarget();null!=i&&this.capturedObjects.delete(e)&&(this.inputState.delete(e),t.releasePointerCapture(e),this.inputState.size>0?this.save():(this.outputState.end(n),this.apply(i)))}stopPropagation(e){null!=e&&(this.getOptions()?.stopPropagation??1)&&e.stopPropagation()}apply(e){return(this.getOptions().apply??Iv)(this.outputState,e)}getState(){return 0===this.inputState.size?void 0:this.outputState}save(){const e=this.getTarget();if(null!=e){e.updateWorldMatrix(!0,!1),this.prevAngle=void 0,this.prevTwoPointerDeltaRotation=void 0,this.prevTranslateAsDeltaRotation=void 0,this.initialTargetParentWorldMatrix=e.parent?.matrixWorld.clone(),e.matrixAutoUpdate?(this.initialTargetPosition.copy(e.position),this.initialTargetQuaternion.copy(e.quaternion),this.initialTargetRotation.copy(e.rotation),this.initialTargetScale.copy(e.scale)):(e.matrix.decompose(this.initialTargetPosition,this.initialTargetQuaternion,this.initialTargetScale),this.initialTargetRotation.setFromQuaternion(this.initialTargetQuaternion,e.rotation.order));for(const e of this.inputState.values())null!=e.pointerWorldDirection&&e.initialPointerWorldDirection?.copy(e.pointerWorldDirection),e.initialPointerWorldPoint.copy(e.pointerWorldPoint),e.initialPointerWorldQuaternion.copy(e.pointerWorldQuaternion)}}bind(e){const{onPointerDown:t,onPointerMove:n,onPointerUp:i}=this.handlers;return e.addEventListener("pointerdown",t),e.addEventListener("pointermove",n),e.addEventListener("pointerup",i),()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointermove",n),e.removeEventListener("pointerup",i),this.cancel()}}capture(e,t){return this.capturePointer(e,t)?()=>this.releasePointer(e,t,void 0):Lv}}function Lv(){}function Iv(e,t){t.position.copy(e.current.position),t.rotation.order=e.current.rotation.order,t.quaternion.copy(e.current.quaternion),t.scale.copy(e.current.scale)}class Dv{target;getOptions;handles=[];hoveredTagMap=new Map;hoverSubscriptions=[];applySubscriptions=[];space;constructor(e,t){this.target=e,this.getOptions=t}getSpace(){return this.space??"world"}getTarget(){return this.target instanceof _d?this.target:this.target.current}getHandleOptions(e,t){const n=this.getOptions?.(),i=t?.();return{...n,...i,apply:(t,r)=>(this.onApply(e,t,r),(i?.apply??n?.apply??Iv)?.(t,r))}}registerHandle(e,t,n){const i={object:t,store:e,tag:n};this.handles.push(i);const r=e.bind(t),a=this.onPointerEnter.bind(this,n),s=this.onPointerLeave.bind(this);return t.addEventListener("pointerenter",a),t.addEventListener("pointerleave",s),()=>{const t=this.handles.indexOf(i);-1!=t&&this.handles.splice(t,1),r(),e.cancel()}}subscribeHover(e){return this.hoverSubscriptions.push(e),e(Array.from(this.hoveredTagMap.values())),()=>{const t=this.hoverSubscriptions.indexOf(e);-1!==t&&this.hoverSubscriptions.splice(t,1)}}subscribeApply(e){return this.applySubscriptions.push(e),()=>{const t=this.applySubscriptions.indexOf(e);-1!==t&&this.applySubscriptions.splice(t,1)}}update(e){for(const{store:t}of this.handles)t.update(e)}onPointerEnter(e,t){this.hoveredTagMap.set(t.pointerId,e),this.updateHover()}onPointerLeave(e){this.hoveredTagMap.delete(e.pointerId),this.updateHover()}updateHover(){const e=Array.from(this.hoveredTagMap.values());for(const t of this.hoverSubscriptions)t(e)}onApply(e,t,n){for(const i of this.applySubscriptions)i(e,t,n)}}const Nv={depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0};function Ov(e,t,n,{color:i,hoverColor:r,hoverOpacity:a,opacity:s,disabled:o=!1}){return null==r&&null==a||o?(t.color.set(i),t.opacity=s??1,void(o&&(t.opacity*=.5,t.color.lerp(new zd(1,1,1),.5)))):(r??=i,e.subscribeHover(e=>{const o=e.some(e=>e.includes(n));t.color.set(o?r:i),t.opacity=(o?a:s)??1}))}const kv=new Yc,Uv=new rh;Uv.setAttribute("position",new Kd([-1e3,0,0,1e3,0,0],3));class Fv extends af{context;rotationOffset;constructor(e,t){super(Uv),this.context=e,this.rotationOffset=t,this.renderOrder=1/0}update(){this.quaternion.setFromEuler(this.rotationOffset);const e=this.context.getTarget();"world"===this.context.getSpace()&&null!=e&&(e.getWorldQuaternion(kv).invert(),this.quaternion.premultiply(kv))}bind(e){this.material=new Xh({...Nv,color:this.material.color??"white",opacity:this.material.opacity??1});const t=this.context.subscribeHover(t=>{const n=t.some(t=>t.includes(e));this.visible=n}),n=this.context.subscribeApply((e,t)=>{if(t.last)return void this.position.set(0,0,0);this.position.copy(t.initial.position).sub(t.current.position);const n=this.context.getTarget();null!=n&&(kv.copy(n.quaternion).invert(),this.position.applyQuaternion(kv))});return()=>{this.material.dispose(),t(),n()}}}class zv extends Dh{context;axis;store;options;tag;constructor(e,t,n,i){super(),this.context=e,this.axis=t,this.tag=(n??"")+t,this.store=new Pv(e.target,()=>e.getHandleOptions(this.tag,i))}}function Bv(e,t=!0){if(!1===t)return{options:!1,disabled:!0};if(!0===t){const t={x:!1,y:!1,z:!1,e:!1};for(const n of e)t[n]=!0;return{options:t,disabled:!1}}if("disabled"===t)return{options:{x:!0,y:!0,z:!0,e:!0},disabled:!0};if("string"==typeof t)return{options:t===e&&{x:!1,y:!1,z:!1,e:!1,[e]:!0},disabled:!1};const n={x:!1,y:!1,z:!1,e:!1};let i=!1;for(const r of e){let e=t[r]??!0;if(!1===e)return{options:!1,disabled:!0};"disabled"===e&&(i=!0,e=!0),n[r]=e}return{options:n,disabled:i}}const Vv=new Kc,Hv=new Kc;function Gv(e,t,n,i){if(!n)return i;let r;return t instanceof yf?r=(t.top-t.bottom)/t.zoom:(t.getWorldPosition(Vv),e.getWorldPosition(Hv),r=Vv.distanceTo(Hv)*Math.min(1.9*Math.tan(Math.PI*t.fov/360)/t.zoom,7)),r*i/4}const jv=new lf(0,.04,.1,12);jv.translate(0,.05,0);const Wv=new lf(.0075,.0075,.5,3);Wv.translate(0,.25,0);const Xv=new id(0,0,-Math.PI/2),qv=new id(0,0,Math.PI/2);class $v extends zv{invert;showArrowBody;constructor(e,t,n="",i,r=!1,a=!0){super(e,t,n,()=>({scale:!1,rotate:!1,translate:null!=i?[i]:this.options,multitouch:!1})),this.invert=r,this.showArrowBody=a}bind(e,t,n){const{options:i,disabled:r}=Bv(this.axis,n);if(!1===i)return;this.options=i;const a=this.invert?qv:Xv,s=new Gd(Nv),o=Ov(this.context,s,this.tag,{color:e,hoverColor:t,disabled:r}),l=new gh(jv,s);let c,u;if(l.renderOrder=1/0,l.position.x=this.invert?-.5:.5,l.rotation.copy(a),this.add(l),this.showArrowBody){const t=new Gd(Nv);c=Ov(this.context,t,this.tag,{color:e,hoverColor:16777024,disabled:r}),u=new gh(Wv,t),u.renderOrder=1/0,u.rotation.copy(a),this.add(u)}const d=new gh(new lf(.13,0,.6,4));d.pointerEventsOrder=1/0,d.position.x=this.invert?-.3:.3,d.rotation.copy(a),d.visible=!1,this.add(d);const h=r?void 0:this.context.registerHandle(this.store,d,this.tag);return()=>{s.dispose(),h?.(),o?.(),c?.(),this.remove(l),null!=u&&this.remove(u),this.remove(d)}}}class Yv extends zv{constructor(e,t,n="",i){super(e,t,n,()=>({translate:i??this.options,scale:!1,rotate:!1,multitouch:!1}))}bind(e,t,n){const{options:i,disabled:r}=Bv(this.axis,n);if(!1===i)return;this.options=i;const a=new Gd(Nv),s=Ov(this.context,a,this.tag,{opacity:.5,hoverOpacity:1,color:e,hoverColor:t,disabled:r}),o=new gh(new yh(.2,.2,.01),a);o.renderOrder=1/0,o.pointerEventsOrder=1/0,o.position.set(.15,.15,0);const l=r?void 0:this.context.registerHandle(this.store,o,this.tag);return this.add(o),()=>{a.dispose(),o.geometry.dispose(),l?.(),s?.(),this.remove(o)}}}new Kc;const Kv=new Yc;class Zv extends zv{constructor(e){super(e,"xyz","",()=>({translate:this.options,scale:!1,rotate:!1,multitouch:!1}))}bind(e){const{options:t,disabled:n}=Bv(this.axis,e);if(!1===t)return;this.options=t;const i=new Gd(Nv),r=Ov(this.context,i,this.tag,{color:16777215,hoverColor:16776960,opacity:.25,hoverOpacity:1,disabled:n}),a=new gh(new uf(.1,0),i);a.renderOrder=1/0,this.add(a);const s=new gh(new uf(.2,0));s.pointerEventsOrder=1/0,s.visible=!1,this.add(s);const o=n?void 0:this.context.registerHandle(this.store,s,this.tag);return()=>{i.dispose(),a.geometry.dispose(),s.geometry.dispose(),o?.(),r?.(),this.remove(a),this.remove(s)}}}const Qv=new Kc,Jv=new Yc,ey=new Yc,ty=(new Yc).setFromEuler(new id(0,0,Math.PI/2)),ny=(new Yc).setFromEuler(new id(0,-Math.PI/2,0)),iy=new Yc,ry=(new Yc).setFromEuler(new id(0,-Math.PI/2,0)),ay=(new Yc).setFromEuler(new id(Math.PI/2,0,0));class sy extends Dh{context;size;fixed;free;translationX;translationY;translationZ;translationNegX;translationNegY;translationNegZ;translationXY;translationYZ;translationXZ;scaleGroup=new Dh;xAxis=new Kc;yAxis=new Kc;zAxis=new Kc;negXAxis=new Kc;negYAxis=new Kc;negZAxis=new Kc;constructor(e,t,n){super(),this.context=e,this.size=t,this.fixed=n,this.add(this.scaleGroup),this.free=new Zv(this.context),this.scaleGroup.add(this.free),this.translationX=new $v(this.context,"x",void 0,this.xAxis),this.scaleGroup.add(this.translationX),this.translationY=new $v(this.context,"y",void 0,this.yAxis),this.scaleGroup.add(this.translationY),this.translationZ=new $v(this.context,"z",void 0,this.zAxis),this.scaleGroup.add(this.translationZ),this.translationNegX=new $v(this.context,"x",void 0,this.negXAxis,!0,!1),this.scaleGroup.add(this.translationNegX),this.translationNegY=new $v(this.context,"y",void 0,this.negYAxis,!0,!1),this.scaleGroup.add(this.translationNegY),this.translationNegZ=new $v(this.context,"z",void 0,this.negZAxis,!0,!1),this.scaleGroup.add(this.translationNegZ),this.translationXY=new Yv(this.context,"xy",void 0,[this.xAxis,this.yAxis]),this.scaleGroup.add(this.translationXY),this.translationXZ=new Yv(this.context,"xz",void 0,[this.xAxis,this.zAxis]),this.scaleGroup.add(this.translationXZ),this.translationYZ=new Yv(this.context,"yz",void 0,[this.yAxis,this.zAxis]),this.scaleGroup.add(this.translationYZ)}update(e){this.updateWorldMatrix(!0,!1),this.xAxis.set(1,0,0),this.yAxis.set(0,1,0),this.zAxis.set(0,0,1),this.free.quaternion.identity(),this.translationX.quaternion.copy(ey),this.translationY.quaternion.copy(ty),this.translationZ.quaternion.copy(ny),this.translationNegX.quaternion.copy(ey),this.translationNegY.quaternion.copy(ty),this.translationNegZ.quaternion.copy(ny),this.translationXY.quaternion.copy(iy),this.translationYZ.quaternion.copy(ry),this.translationXZ.quaternion.copy(ay);const t=this.context.getSpace(),n=this.context.getTarget();"world"==t&&null!=n?(n.getWorldQuaternion(Jv).invert(),this.free.quaternion.premultiply(Jv),this.translationX.quaternion.premultiply(Jv),this.translationY.quaternion.premultiply(Jv),this.translationZ.quaternion.premultiply(Jv),this.translationNegX.quaternion.premultiply(Jv),this.translationNegY.quaternion.premultiply(Jv),this.translationNegZ.quaternion.premultiply(Jv),this.translationXY.quaternion.premultiply(Jv),this.translationYZ.quaternion.premultiply(Jv),this.translationXZ.quaternion.premultiply(Jv),null!=n.parent&&(n.parent.getWorldQuaternion(Jv).invert(),this.xAxis.applyQuaternion(Jv),this.yAxis.applyQuaternion(Jv),this.zAxis.applyQuaternion(Jv))):null!=n&&(this.xAxis.applyQuaternion(n.quaternion),this.yAxis.applyQuaternion(n.quaternion),this.zAxis.applyQuaternion(n.quaternion)),this.negXAxis.copy(this.xAxis).negate(),this.negYAxis.copy(this.yAxis).negate(),this.negZAxis.copy(this.zAxis).negate(),this.scaleGroup.scale.setScalar(1),null!=n&&(n.getWorldScale(Qv),this.scaleGroup.scale.divide(Qv)),this.scaleGroup.scale.multiplyScalar(Gv(this,e,this.fixed??!0,this.size??1))}bind(e){const t=function(e,t){const n=new gh(new uf(.01,2),new Gd(Nv));n.renderOrder=1/0,n.visible=!1,e.add(n);const i=new gh(new uf(.01,2),new Gd(Nv));i.renderOrder=1/0,i.visible=!1,e.add(i);const r=new rh;r.setAttribute("position",new Kd([0,0,0,1,1,1],3));const a=new af(r,new Xh(Nv));a.renderOrder=1/0,a.visible=!1,e.add(a);const s=t.subscribeApply((e,r)=>{i.position.set(0,0,0),n.position.copy(r.initial.position).sub(r.current.position);const s=t.getTarget();null!=s&&(Kv.copy(s.quaternion).invert(),n.position.applyQuaternion(Kv)),a.position.set(0,0,0),a.scale.copy(n.position),n.visible=!r.last,a.visible=!r.last,i.visible=!r.last});return()=>{n.geometry.dispose(),n.material.dispose(),i.geometry.dispose(),i.material.dispose(),a.geometry.dispose(),a.material.dispose(),e.remove(n),e.remove(i),e.remove(a),s()}}(this,this.context),n=this.translationX.bind(16711680,16776960,e),i=this.translationY.bind(65280,16776960,e),r=this.translationZ.bind(255,16776960,e),a=this.translationNegX.bind(16711680,16776960,e),s=this.translationNegY.bind(65280,16776960,e),o=this.translationNegZ.bind(255,16776960,e),l=this.translationXY.bind(255,16776960,e),c=this.translationYZ.bind(16711680,16776960,e),u=this.translationXZ.bind(65280,16776960,e),d=this.free.bind(e);return()=>{t(),n?.(),i?.(),r?.(),a?.(),s?.(),o?.(),l?.(),c?.(),u?.(),d?.()}}}const oy=new id(0,0,-Math.PI/2),ly=new id(0,0,Math.PI/2);class cy extends zv{invert;showHandleLine;constructor(e,t,n="",i=!1,r=!0){super(e,t,n,()=>({scale:this.options,rotate:!1,translate:"as-scale",multitouch:!1})),this.invert=i,this.showHandleLine=r}bind(e,t,n){const{options:i,disabled:r}=Bv(this.axis,n);if(!1===i)return;this.options=i;const a=this.invert?ly:oy,s=new Dh;s.position.x=this.invert?-.5:.5,s.rotation.copy(a),this.add(s);const o=new Gd(Nv),l=Ov(this.context,o,this.tag,{color:e,hoverColor:t,disabled:r}),c=new gh(new yh(.08,.08,.08),o);let u,d,h;if(c.renderOrder=1/0,c.rotation.copy(a),s.add(c),this.showHandleLine){h=new Dh,h.rotation.copy(a),this.add(h);const n=new Gd(Nv);u=Ov(this.context,n,this.tag,{color:e,hoverColor:t,disabled:r}),d=new gh(new lf(.0075,.0075,.5,3),n),d.renderOrder=1/0,d.position.y=.25,h.add(d)}const f=new Dh;f.visible=!1,f.rotation.copy(a),f.position.x=this.invert?-.3:.3,this.add(f);const p=new gh(new lf(.2,0,.5,4));p.pointerEventsOrder=1/0,p.position.y=.04,f.add(p);const m=r?void 0:this.context.registerHandle(this.store,p,this.tag);return()=>{o.dispose(),p.geometry.dispose(),c.geometry.dispose(),d?.geometry.dispose(),m?.(),l?.(),u?.(),null!=h&&this.remove(h),this.remove(f),this.remove(s)}}}class uy extends zv{constructor(e,t,n=""){super(e,t,n,()=>({translate:"as-scale",scale:this.options,rotate:!1,multitouch:!1}))}bind(e,t,n){const{options:i,disabled:r}=Bv(this.axis,n);if(!1===i)return;this.options=i;const a=new Gd(Nv),s=Ov(this.context,a,this.tag,{opacity:.5,hoverOpacity:1,color:e,hoverColor:t,disabled:r}),o=new gh(new yh(.2,.2,.01),a);o.renderOrder=1/0,o.pointerEventsOrder=1/0,o.position.set(.15,.15,0);const l=r?void 0:this.context.registerHandle(this.store,o,this.tag);return this.add(o),()=>{a.dispose(),o.geometry.dispose(),l?.(),s?.(),this.remove(o)}}}const dy=new id(0,0,-Math.PI/2),hy=new id(0,0,Math.PI/2);class fy extends zv{actualAxis;invert;constructor(e,t="",n,i=!1){super(e,"xyz",t,()=>({scale:{uniform:!0,...this.options},rotate:!1,translate:"as-scale",multitouch:!1})),this.actualAxis=n,this.invert=i}bind(e,t,n){const{options:i,disabled:r}=Bv(this.actualAxis,n);if(!1===i)return;this.options=i;const a=this.invert?hy:dy,s=new Dh;s.position.x=this.invert?-.7:.7,s.rotation.copy(a),this.add(s);const o=new Gd(Nv),l=Ov(this.context,o,this.tag,{color:e,hoverColor:t,opacity:.5,hoverOpacity:1,disabled:r}),c=new gh(new yh(.08,.08,.08),o);c.renderOrder=1/0,c.rotation.copy(a),s.add(c);const u=new gh(new yh(.15,.15,.15),o);u.visible=!1,u.pointerEventsOrder=1/0,u.rotation.copy(a),s.add(u);const d=r?void 0:this.context.registerHandle(this.store,u,this.tag);return()=>{o.dispose(),c.geometry.dispose(),d?.(),l?.(),this.remove(s)}}}const py=new Kc;class my extends Dh{context;size;fixed;scaleX;scaleY;scaleZ;scaleNegX;scaleNegY;scaleNegZ;translationX;translationY;translationZ;translationNegX;translationNegY;translationNegZ;translationXY;translationYZ;translationXZ;constructor(e,t,n){super(),this.context=e,this.size=t,this.fixed=n,this.scaleX=new fy(this.context,void 0,"x"),this.add(this.scaleX),this.scaleY=new fy(this.context,void 0,"y"),this.scaleY.rotation.z=Math.PI/2,this.add(this.scaleY),this.scaleZ=new fy(this.context,void 0,"z"),this.scaleZ.rotation.y=-Math.PI/2,this.add(this.scaleZ),this.scaleNegX=new fy(this.context,void 0,"x",!0),this.add(this.scaleNegX),this.scaleNegY=new fy(this.context,void 0,"y",!0),this.scaleNegY.rotation.z=Math.PI/2,this.add(this.scaleNegY),this.scaleNegZ=new fy(this.context,void 0,"z",!0),this.scaleNegZ.rotation.y=-Math.PI/2,this.add(this.scaleNegZ),this.translationX=new cy(this.context,"x"),this.add(this.translationX),this.translationY=new cy(this.context,"y"),this.translationY.rotation.z=Math.PI/2,this.add(this.translationY),this.translationZ=new cy(this.context,"z"),this.translationZ.rotation.y=-Math.PI/2,this.add(this.translationZ),this.translationNegX=new cy(this.context,"x",void 0,!0,!1),this.add(this.translationNegX),this.translationNegY=new cy(this.context,"y",void 0,!0,!1),this.translationNegY.rotation.z=Math.PI/2,this.add(this.translationNegY),this.translationNegZ=new cy(this.context,"z",void 0,!0,!1),this.translationNegZ.rotation.y=-Math.PI/2,this.add(this.translationNegZ),this.translationXY=new uy(this.context,"xy"),this.add(this.translationXY),this.translationXZ=new uy(this.context,"xz"),this.translationXZ.rotation.x=Math.PI/2,this.add(this.translationXZ),this.translationYZ=new uy(this.context,"yz"),this.translationYZ.rotation.y=-Math.PI/2,this.add(this.translationYZ)}update(e){this.updateWorldMatrix(!0,!1),this.scale.setScalar(1);const t=this.context.getTarget();null!=t&&(t.getWorldScale(py),this.scale.divide(py)),this.scale.multiplyScalar(Gv(this,e,this.fixed??!0,this.size??1))}bind(e){const t=this.scaleX.bind(16777215,16776960,e),n=this.scaleY.bind(16777215,16776960,e),i=this.scaleZ.bind(16777215,16776960,e),r=this.scaleNegX.bind(16777215,16776960,e),a=this.scaleNegY.bind(16777215,16776960,e),s=this.scaleNegZ.bind(16777215,16776960,e),o=this.translationX.bind(16711680,16776960,e),l=this.translationY.bind(65280,16776960,e),c=this.translationZ.bind(255,16776960,e),u=this.translationNegX.bind(16711680,16776960,e),d=this.translationNegY.bind(65280,16776960,e),h=this.translationNegZ.bind(255,16776960,e),f=this.translationXY.bind(255,16776960,e),p=this.translationYZ.bind(16711680,16776960,e),m=this.translationXZ.bind(65280,16776960,e);return()=>{o?.(),l?.(),c?.(),u?.(),d?.(),h?.(),f?.(),p?.(),m?.(),t?.(),n?.(),i?.(),r?.(),a?.(),s?.()}}}const gy={x:{vector1:new Kc(0,0,-1),vector2:new Kc(0,-1,0),rotationOffset:new Yc,axis:[1,0,0]},y:{vector1:new Kc(0,0,-1),vector2:new Kc(-1,0,-1),rotationOffset:(new Yc).setFromEuler(new id(0,0,Math.PI/2)),axis:[0,1,0]},z:{vector1:new Kc(-1,0,0),vector2:new Kc(0,-1,0),rotationOffset:(new Yc).setFromEuler(new id(0,Math.PI/2,0)),axis:[0,0,1]}},vy=new Kc,yy=new Kc,xy=new Kc,_y=new Kc,by=new Yc;class wy extends zv{direction=new Kc(1,0,0);constructor(e,t,n=""){super(e,t,n,()=>({scale:!1,translate:"as-rotate",rotate:[this.direction],multitouch:!1}))}update(e){const{rotationOffset:t,vector1:n,vector2:i}=gy[this.axis];e.getWorldPosition(vy),this.getWorldPosition(yy).sub(vy),xy.copy(n),_y.copy(i);const r=this.context.getTarget(),a=this.context.getSpace();"local"===a&&null!=r&&(r.getWorldQuaternion(by),xy.applyQuaternion(by),_y.applyQuaternion(by)),_y.crossVectors(xy,_y);const s=yy.dot(_y);_y.multiplyScalar(s),yy.sub(_y),this.quaternion.setFromUnitVectors(xy,yy.normalize()),"local"===a&&null!=r&&(r.getWorldQuaternion(by),this.quaternion.multiply(by)),this.quaternion.multiply(t),null!=r?.parent?(r.parent.matrixWorld.decompose(vy,by,yy),by.invert(),this.quaternion.premultiply(by)):by.identity(),null==this.store.getState()&&(this.direction.fromArray(gy[this.axis].axis),this.direction.applyQuaternion("local"===a&&null!=r?r?.quaternion:by)),null!=r&&this.quaternion.premultiply(by.copy(r.quaternion).invert())}bind(e,t){const{options:n,disabled:i}=Bv(this.axis,t);if(!1===n)return;this.options=n;const r=new Gd(Nv),a=Ov(this.context,r,this.tag,{color:e,hoverColor:16776960,disabled:i}),s=new gh(Dy(.5,.5),r);s.renderOrder=1/0,this.add(s);const o=new gh(new pf(.5,.1,4,24));o.visible=!1,o.pointerEventsOrder=1/0,o.rotation.set(0,-Math.PI/2,-Math.PI/2),this.add(o);const l=i?void 0:this.context.registerHandle(this.store,o,this.tag);return()=>{r.dispose(),o.geometry.dispose(),s.geometry.dispose(),l?.(),a?.(),this.remove(o),this.remove(s)}}}const Sy=new Kc,My=new Kc,Ey=new Kc(1,0,0),Ty=new Yc;class Ay extends zv{constructor(e,t=""){super(e,"xyz",t,()=>({scale:!1,translate:"as-rotate",rotate:this.options,multitouch:!1}))}update(e){e.getWorldPosition(Sy),this.getWorldPosition(My).sub(Sy),this.quaternion.setFromUnitVectors(Ey,My.normalize());const t=this.context.getTarget();null!=t?.parent&&(t.parent.matrixWorld.decompose(Sy,Ty,My),Ty.invert(),this.quaternion.premultiply(Ty)),null!=t&&(Ty.copy(t.quaternion).invert(),this.quaternion.premultiply(Ty))}bind(e){const{options:t,disabled:n}=Bv(this.axis,e);if(!1===t)return;this.options=t;const i=new Gd(Nv),r=Ov(this.context,i,this.tag,{color:16777215,hoverColor:16776960,opacity:.25,disabled:n}),a=new gh(Dy(.5,1),i);a.renderOrder=1/0,this.add(a);const s=new gh(new ff(.25,10,8));s.visible=!1,s.pointerEventsOrder=1/0,this.add(s);const o=n?void 0:this.context.registerHandle(this.store,s,this.tag);return()=>{this.pointerEvents="none",i.dispose(),s.geometry.dispose(),a.geometry.dispose(),o?.(),r?.(),this.remove(s),this.remove(a)}}}const Ry=new Kc,Cy=new Kc,Py=new Kc(1,0,0),Ly=new Yc;class Iy extends zv{direction=new Kc(1,0,0);constructor(e,t=""){super(e,"e",t,()=>({scale:!1,translate:"as-rotate",rotate:[this.direction],multitouch:!1}))}update(e){e.getWorldPosition(Ry),this.getWorldPosition(this.direction).sub(Ry).normalize(),this.quaternion.setFromUnitVectors(Py,this.direction);const t=this.context.getTarget();null!=t?.parent&&(t.parent.matrixWorld.decompose(Ry,Ly,Cy),Ly.invert(),this.quaternion.premultiply(Ly),this.direction.applyQuaternion(Ly)),null!=t&&(Ly.copy(t.quaternion).invert(),this.quaternion.premultiply(Ly)),this.direction.negate()}bind(e){const{options:t,disabled:n}=Bv(this.axis,e);if(!1===t)return;this.options=t;const i=new Gd(Nv),r=Ov(this.context,i,this.tag,{color:16776960,hoverColor:16776960,opacity:.5,disabled:n}),a=new gh(Dy(.75,1),i);a.renderOrder=1/0,this.add(a);const s=new gh(new pf(.75,.1,2,24),new Gd({color:"white"}));s.visible=!1,s.rotation.y=Math.PI/2,s.pointerEventsOrder=1/0,this.add(s);const o=n?void 0:this.context.registerHandle(this.store,s,this.tag);return()=>{i.dispose(),s.geometry.dispose(),a.geometry.dispose(),o?.(),r?.(),this.remove(s),this.remove(a)}}}function Dy(e,t){const n=new pf(e,.0075,3,64,t*Math.PI*2);return n.rotateY(Math.PI/2),n.rotateX(Math.PI/2),n}const Ny=new Kc;class Oy extends Dh{context;fixed;size;rotationX;rotationY;rotationZ;free;screen;constructor(e,t,n){super(),this.context=e,this.fixed=t,this.size=n,this.rotationX=new wy(this.context,"x"),this.add(this.rotationX),this.rotationY=new wy(this.context,"y"),this.add(this.rotationY),this.rotationZ=new wy(this.context,"z"),this.add(this.rotationZ),this.free=new Ay(this.context),this.add(this.free),this.screen=new Iy(this.context),this.add(this.screen)}update(e){this.updateWorldMatrix(!0,!1),this.rotationX.update(e),this.rotationY.update(e),this.rotationZ.update(e),this.free.update(e),this.screen.update(e),this.scale.setScalar(1);const t=this.context.getTarget();null!=t&&(t.getWorldScale(Ny),this.scale.divide(Ny)),this.scale.multiplyScalar(Gv(this,e,this.fixed??!0,this.size??1))}bind(e){const t=this.rotationX.bind(16711680,e),n=this.rotationY.bind(65280,e),i=this.rotationZ.bind(255,e),r=this.screen.bind(e),a=this.free.bind(e);return()=>{t?.(),n?.(),i?.(),r?.(),a?.()}}}const ky=new id,Uy=new id(0,0,Math.PI/2),Fy=new id(0,-Math.PI/2,0);class zy extends Dh{xAxisHighlight;yAxisHighlight;zAxisHighlight;handles;context;constructor(e){super(),this.context=new Dv(this,e),this.xAxisHighlight=new Fv(this.context,ky),this.add(this.xAxisHighlight),this.yAxisHighlight=new Fv(this.context,Uy),this.add(this.yAxisHighlight),this.zAxisHighlight=new Fv(this.context,Fy),this.add(this.zAxisHighlight)}set space(e){this.context.space=e}get space(){return this.context.space}update(e,t){this.context.update(e),this.xAxisHighlight.update(),this.yAxisHighlight.update(),this.zAxisHighlight.update(),this.handles?.update(t)}bind(e,t){const n=this.xAxisHighlight.bind("x"),i=this.yAxisHighlight.bind("y"),r=this.zAxisHighlight.bind("z");switch(e){case"rotate":this.handles=new Oy(this.context);break;case"scale":this.handles=new my(this.context);break;case"translate":this.handles=new sy(this.context)}this.add(this.handles);const a=this.handles.bind(t);return()=>{null!=this.handles&&this.remove(this.handles),this.handles=void 0,a(),n(),i(),r()}}}new Kc(0,0,1),new Kc(0,1,0),new Kc,new Kc,new Kc;class By{nativeEvent;NONE=0;CAPTURING_PHASE=1;AT_TARGET=2;BUBBLING_PHASE=3;relatedTarget=null;get altKey(){return this.getFromNative("altKey",!1)}get button(){return this.getFromNative("button",0)}get buttons(){return this.getFromNative("buttons",0)}get clientX(){return this.getFromNative("clientX",0)}get clientY(){return this.getFromNative("clientY",0)}get ctrlKey(){return this.getFromNative("ctrlKey",!1)}get layerX(){return this.getFromNative("layerX",0)}get layerY(){return this.getFromNative("layerY",0)}get metaKey(){return this.getFromNative("metaKey",!1)}get movementX(){return this.getFromNative("movementX",0)}get movementY(){return this.getFromNative("movementY",0)}get offsetX(){return this.getFromNative("offsetX",0)}get offsetY(){return this.getFromNative("offsetY",0)}get pageX(){return this.getFromNative("pageX",0)}get pageY(){return this.getFromNative("pageY",0)}get screenX(){return this.getFromNative("screenX",0)}get screenY(){return this.getFromNative("screenY",0)}get shiftKey(){return this.getFromNative("shiftKey",!1)}get x(){return this.getFromNative("x",0)}get y(){return this.getFromNative("y",0)}get detail(){return this.getFromNative("detail",0)}get view(){return this.getFromNative("view",null)}get which(){return this.getFromNative("which",0)}get cancelBubble(){return this.getFromNative("cancelBubble",!1)}get composed(){return this.getFromNative("composed",!1)}get eventPhase(){return this.getFromNative("eventPhase",0)}get isTrusted(){return this.getFromNative("isTrusted",!1)}get returnValue(){return this.getFromNative("returnValue",!1)}get timeStamp(){return this.getFromNative("timeStamp",0)}get cancelable(){return this.getFromNative("cancelable",!1)}get defaultPrevented(){return this.getFromNative("defaultPrevented",!1)}constructor(e){this.nativeEvent=e}getFromNative(e,t){return e in this.nativeEvent?this.nativeEvent[e]:t}}const Vy=new Kc;class Hy extends By{type;bubbles;internalPointer;intersection;camera;currentObject;object;propagationState;get pointerId(){return this.internalPointer.id}get pointerType(){return this.internalPointer.type}get pointerState(){return this.internalPointer.state}get distance(){return this.intersection.distance}get distanceToRay(){return this.intersection.distanceToRay}get point(){return this.intersection.point}get index(){return this.intersection.index}get face(){return this.intersection.face}get faceIndex(){return this.intersection.faceIndex}get uv(){return this.intersection.uv}get uv1(){return this.intersection.uv1}get normal(){return this.intersection.normal}get instanceId(){return this.intersection.instanceId}get pointOnLine(){return this.intersection.pointOnLine}get batchId(){return this.intersection.batchId}get pointerPosition(){return this.intersection.pointerPosition}get pointerQuaternion(){return this.intersection.pointerQuaternion}get pointOnFace(){return this.intersection.pointOnFace}get localPoint(){return this.intersection.localPoint}get details(){return this.intersection.details}get target(){return this.object}get currentTarget(){return this.currentObject}get eventObject(){return this.currentObject}get srcElement(){return this.currentObject}_pointer;get pointer(){return null==this._pointer&&(Vy.copy(this.intersection.point).project(this.camera),this._pointer=new $c(Vy.x,Vy.y)),this._pointer}_ray;get ray(){if(null!=this._ray)return this._ray;switch(this.intersection.details.type){case"screen-ray":case"ray":case"sphere":return this._ray=new Xu(this.intersection.pointerPosition,new Kc(0,0,-1).applyQuaternion(this.intersection.pointerQuaternion));case"lines":return this._ray=new Xu(this.intersection.details.line.start,this.intersection.details.line.end.clone().sub(this.intersection.details.line.start).normalize())}}_intersections=[];get intersections(){return null==this._intersections&&(this._intersections=[{...this.intersection,eventObject:this.currentObject}]),this._intersections}_unprojectedPoint;get unprojectedPoint(){if(null==this._unprojectedPoint){const e=this.pointer;this._unprojectedPoint=new Kc(e.x,e.y,0).unproject(this.camera)}return this._unprojectedPoint}get stopped(){return this.propagationState.stoppedImmediate||this.propagationState.stopped}get stoppedImmediate(){return this.propagationState.stoppedImmediate}get delta(){throw new Error("not supported")}constructor(e,t,n,i,r,a,s=r.object,o=s,l={stopped:!t,stoppedImmediate:!1}){super(n),this.type=e,this.bubbles=t,this.internalPointer=i,this.intersection=r,this.camera=a,this.currentObject=s,this.object=o,this.propagationState=l}stopPropagation(){this.propagationState.stopped=!0}stopImmediatePropagation(){this.propagationState.stoppedImmediate=!0}retarget(e){return new Hy(this.type,this.bubbles,this.nativeEvent,this.internalPointer,this.intersection,this.camera,e,this.target,this.propagationState)}}class Gy extends Hy{get deltaX(){return this.nativeEvent.deltaX}get deltaY(){return this.nativeEvent.deltaY}get deltaZ(){return this.nativeEvent.deltaZ}constructor(e,t,n,i,r,a){super("wheel",!0,e,t,n,i,r,a)}retarget(e){return new Gy(this.nativeEvent,this.internalPointer,this.intersection,this.camera,e,this.target)}}function jy(e){Wy(e,e.currentObject)}function Wy(e,t){if(null==t)return;const n=function(e,t){if(null!=e._listeners&&t in e._listeners)return e._listeners[t];let n;e.isVoidObject&&"click"===t&&null!=e.parent?.__r3f&&(n=e.parent.__r3f.root.getState().onPointerMissed);null!=e.__r3f&&(n=e.__r3f.handlers[Xy[t]]);if(null==n)return;return[n]}(t,e.type);if(null!=n&&n.length>0){const i=e.retarget(t),r=n.length;for(let e=0;e<r&&!i.stoppedImmediate;e++)n[e](i)}e.stopped||Wy(e,t.parent)}const Xy={click:"onClick",contextmenu:"onContextMenu",dblclick:"onDoubleClick",pointercancel:"onPointerCancel",pointerdown:"onPointerDown",pointerenter:"onPointerEnter",pointerleave:"onPointerLeave",pointermove:"onPointerMove",pointerout:"onPointerOut",pointerover:"onPointerOver",pointerup:"onPointerUp",wheel:"onWheel"},qy=Object.keys(Xy);const $y=new ff(1e10),Yy=new Map;function Ky(e){let t=Yy.get(e);return null==t&&(t=new gh($y),t.isVoidObject=!0,t.parent=e,t.pointerEventsOrder=-1/0,Yy.set(e,t)),t}function Zy(e,t){return t?!e:e}function Qy(e,t,n,i=!1,r,a,s){const o=i||function(e,t){if(t.ancestorsHaveListeners)return!0;if("pointer"===e&&t.ancestorsHavePointerListeners)return!0;if("wheel"===e&&t.ancestorsHaveWheelListeners)return!0;if(null!=t.__r3f&&t.__r3f?.eventCount>0){if("wheel"===e&&null!=t.__r3f.handlers.onWheel)return!0;if("pointer"===e&&Object.keys(t.__r3f.handlers).some(e=>"onWheel"!=e))return!0}if(null==t._listeners)return!1;if("wheel"===e){const e=t._listeners.wheel;return null!=e&&e.length>0}const n=Object.entries(t._listeners),i=n.length;for(let e=0;e<i;e++){const t=n[e];if("wheel"!==t[0]&&(qy.includes(t[0])&&null!=t[1]&&t[1].length>0))return!0}return!1}(e,t),l=t.pointerEvents??r,c=l??t.defaultPointerEvents??"listener",u=t.pointerEventsType??a??"all",d=t.pointerEventsOrder??s??0,h=function(e,t,n){if("none"===t)return!1;if("listener"===t&&!e)return!1;if("all"===n)return!0;if("function"==typeof n)return({id:e,type:t,state:i})=>n(e,t,i);let i,r;return"deny"in n?(r=!0,i=n.deny):(r=!1,i=n.allow),Array.isArray(i)?e=>Zy(i.includes(e.type),r):e=>Zy(i===e.type,r)}(o,c,u),f=n.length;if(1===f)(!0===h||"function"==typeof h&&h(n[0]))&&Jy(n[0],t,c,u,d);else if(!0===h)for(let e=0;e<f;e++)Jy(n[e],t,c,u,d);else if("function"==typeof h)for(let e=0;e<f;e++){const i=n[e];h(i)&&Jy(i,t,c,u,d)}if(0===t.children.length||!1===t.intersectChildren)return;const p=t.interactableDescendants??t.children,m=p.length;for(let t=0;t<m;t++)Qy(e,p[t],n,o,l,u,d)}function Jy({intersector:e,options:t},n,i,r,a){!1!==t.filter?.(n,i,r,a)&&e.executeIntersection(n,a)}function ex(e,t=0,n,i=0){return t!=i?i-t:e.distance-n.distance}const tx=1e7;const nx=Symbol("buttonsDownTime"),ix=Symbol("buttonsClickTime");function rx(e){return globalThis.pointerEventspointerMap?.get(e)}globalThis.pointerEventspointerMap??=new Map,_d.prototype.setPointerCapture=function(e){rx(e)?.setCapture(this)},_d.prototype.releasePointerCapture=function(e){const t=rx(e);null!=t&&t.hasCaptured(this)&&t.setCapture(void 0)},_d.prototype.hasPointerCapture=function(e){return rx(e)?.hasCaptured(this)??!1};class ax{id;type;state;intersector;getCamera;onMoveCommited;parentSetPointerCapture;parentReleasePointerCapture;options;prevIntersection;intersection;prevEnabled=!0;enabled=!0;wheelIntersection;pointerEntered=[];pointerEnteredHelper=[];pointerCapture;buttonsDownTime=new Map;buttonsDown=new Set;wasMoved=!1;onFirstMove=[];constructor(e,t,n,i,r,a,s,o,l={}){this.id=e,this.type=t,this.state=n,this.intersector=i,this.getCamera=r,this.onMoveCommited=a,this.parentSetPointerCapture=s,this.parentReleasePointerCapture=o,this.options=l,globalThis.pointerEventspointerMap?.set(e,this)}getPointerCapture(){return this.pointerCapture}hasCaptured(e){return this.pointerCapture?.object===e}setCapture(e){this.pointerCapture?.object!==e&&(null!=this.pointerCapture&&(this.parentReleasePointerCapture?.(),this.pointerCapture=void 0),null!=e&&null!=this.intersection&&(this.pointerCapture={object:e,intersection:this.intersection},this.parentSetPointerCapture?.()))}getButtonsDown(){return this.buttonsDown}getIntersection(){return this.intersection}getEnabled(){return this.enabled}setEnabled(e,t,n=!0){this.enabled!==e&&(e||null==this.pointerCapture||(this.parentReleasePointerCapture?.(),this.pointerCapture=void 0),this.enabled=e,n&&this.commit(t,!1))}computeIntersection(e,t,n){return null!=this.pointerCapture?this.intersector.intersectPointerCapture(this.pointerCapture,n):(this.intersector.startIntersection(n),Qy(e,t,[this]),this.intersector.finalizeIntersection(t))}setIntersection(e){this.intersection=e}commit(e,t){const n=this.getCamera(),i=this.prevEnabled?this.prevIntersection:void 0,r=this.enabled?this.intersection:void 0;null!=i&&i.object!=r?.object&&jy(new Hy("pointerout",!0,e,this,i,n));const a=this.pointerEntered;this.pointerEntered=[],this.pointerEnteredHelper.length=0,sx(r?.object,this.pointerEntered,a,this.pointerEnteredHelper);const s=a.length;for(let t=0;t<s;t++){const r=a[t];jy(new Hy("pointerleave",!1,e,this,i,n,r))}null!=r&&i?.object!=r.object&&jy(new Hy("pointerover",!0,e,this,r,n));for(let t=this.pointerEnteredHelper.length-1;t>=0;t--){const i=this.pointerEnteredHelper[t];jy(new Hy("pointerenter",!1,e,this,r,n,i))}if(t&&null!=r&&jy(new Hy("pointermove",!0,e,this,r,n)),this.prevIntersection=this.intersection,this.prevEnabled=this.enabled,!this.wasMoved&&this.intersector.isReady()){this.wasMoved=!0;const e=this.onFirstMove.length;for(let t=0;t<e;t++)this.onFirstMove[t](n);this.onFirstMove.length=0}this.onMoveCommited?.(this)}move(e,t){this.intersection=this.computeIntersection("pointer",e,t),this.commit(t,!0)}emitMove(e){null!=this.intersection&&jy(new Hy("pointermove",!0,e,this,this.intersection,this.getCamera()))}down(e){if(this.buttonsDown.add(e.button),!this.enabled)return;if(!this.wasMoved)return void this.onFirstMove.push(this.down.bind(this,e));if(null==this.intersection)return;jy(new Hy("pointerdown",!0,e,this,this.intersection,this.getCamera()));const{object:t}=this.intersection;t[nx]??=new Map,t[nx].set(e.button,e.timeStamp),this.buttonsDownTime.set(e.button,e.timeStamp)}up(e){if(this.buttonsDown.delete(e.button),!this.enabled)return;if(!this.wasMoved)return void this.onFirstMove.push(this.up.bind(this,e));if(null==this.intersection)return;const{clickThesholdMs:t,contextMenuButton:n=2,dblClickThresholdMs:i=500,clickThresholdMs:r=t??300}=this.options;this.pointerCapture=void 0;const a=function(e,t,n,i,r){if(null==t)return!1;const a=t.get(n);if(null==a)return!1;if(i-a>r)return!1;if(a!=e.get(n))return!1;return!0}(this.buttonsDownTime,this.intersection.object[nx],e.button,e.timeStamp,r),s=this.getCamera();if(a&&e.button===n&&jy(new Hy("contextmenu",!0,e,this,this.intersection,s)),jy(new Hy("pointerup",!0,e,this,this.intersection,s)),!a||e.button===n)return;jy(new Hy("click",!0,e,this,this.intersection,s));const{object:o}=this.intersection,l=o[ix]??=new Map,c=l.get(e.button);null==c||e.timeStamp-c>i?l.set(e.button,e.timeStamp):(jy(new Hy("dblclick",!0,e,this,this.intersection,s)),l.delete(e.button))}cancel(e){this.enabled&&(this.wasMoved?null!=this.intersection&&jy(new Hy("pointercancel",!0,e,this,this.intersection,this.getCamera())):this.onFirstMove.push(this.cancel.bind(this,e)))}wheel(e,t,n=!1){if(!this.enabled)return;if(!this.wasMoved&&n)return void this.onFirstMove.push(this.wheel.bind(this,e,t,n));n||(this.wheelIntersection=this.computeIntersection("wheel",e,t));const i=n?this.intersection:this.wheelIntersection;null!=i&&jy(new Gy(t,this,i,this.getCamera()))}emitWheel(e,t=!1){if(!this.enabled)return;if(!this.wasMoved&&t)return void this.onFirstMove.push(this.emitWheel.bind(this,e,t));const n=t?this.intersection:this.wheelIntersection;null!=n&&jy(new Gy(e,this,n,this.getCamera()))}exit(e){this.wasMoved&&(null!=this.pointerCapture&&(this.parentReleasePointerCapture?.(),this.pointerCapture=void 0),this.intersection=void 0,this.commit(e,!1)),this.onFirstMove.length=0,this.wasMoved=!1}}function sx(e,t,n,i){if(null==e)return;const r=n.indexOf(e);-1!=r?n.splice(r,1):i.push(e),t.push(e),sx(e.parent,t,n,i)}const ox=new Nd,lx=new Nd,cx=new $c,ux=new $c,dx=new $c,hx=new Kc,fx=new qu,px=new Kc;function mx(e,t,n){px.copy(t).applyMatrix4(fx.copy(n.matrixWorld).invert());const i=n.geometry.attributes.uv;if(null==i||!(i instanceof qd))return!1;let r;return function(e,t){const n=e.geometry.drawRange;if(null!=e.geometry.index){const i=e.geometry.index,r=Math.max(0,n.start),a=Math.min(i.count,n.start+n.count);for(let e=r;e<a;e+=3)t(i.getX(e),i.getX(e+1),i.getX(e+2));return}const i=e.geometry.attributes.position;if(null==i)return;const r=Math.max(0,n.start),a=Math.min(i.count,n.start+n.count);for(let e=r;e<a;e+=3)t(e,e+1,e+2)}(n,(e,t,a)=>{n.getVertexPosition(e,ox.a),n.getVertexPosition(t,ox.b),n.getVertexPosition(a,ox.c);const s=ox.closestPointToPoint(px,hx).distanceTo(px);null!=r&&s>=r||(r=s,lx.copy(ox),cx.fromBufferAttribute(i,e),ux.fromBufferAttribute(i,t),dx.fromBufferAttribute(i,a))}),null!=r&&(lx.closestPointToPoint(px,hx),lx.getInterpolation(hx,cx,ux,dx,e),!0)}new qu,new class{constructor(e=new Kc,t=new Kc){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Mf.subVectors(e,this.start),Ef.subVectors(this.end,this.start);const n=Ef.dot(Ef);let i=Ef.dot(Mf)/n;return t&&(i=jc(i,0,1)),i}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(e,t=Cf,n=Pf){const i=1e-8*1e-8;let r,a;const s=this.start,o=e.start,l=this.end,c=e.end;Tf.subVectors(l,s),Af.subVectors(c,o),Rf.subVectors(s,o);const u=Tf.dot(Tf),d=Af.dot(Af),h=Af.dot(Rf);if(u<=i&&d<=i)return t.copy(s),n.copy(o),t.sub(n),t.dot(t);if(u<=i)r=0,a=h/d,a=jc(a,0,1);else{const e=Tf.dot(Rf);if(d<=i)a=0,r=jc(-e/u,0,1);else{const t=Tf.dot(Af),n=u*d-t*t;r=0!==n?jc((t*h-e*d)/n,0,1):0,a=(t*r+h)/d,a<0?(a=0,r=jc(-e/u,0,1)):a>1&&(a=1,r=jc((t-e)/u,0,1))}}return t.copy(s).add(Tf.multiplyScalar(r)),n.copy(o).add(Af.multiplyScalar(a)),t.sub(n),t.dot(t)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}},new Kc,new Vh,new Xu,new $c,new Kc(0,0,0),new Kc(0,0,1);const gx=new qu,vx=new Kc;new Kc(0,0,-1),new Vh;const yx=new $c,xx=new Kc;class _x{prepareTransformation;options;raycaster=new bf;cameraQuaternion=new Yc;fromPosition=new Kc;fromQuaternion=new Yc;coords=new $c;viewPlane=new Vh;intersects=[];pointerEventsOrders=[];constructor(e,t){this.prepareTransformation=e,this.options=t}isReady(){return!0}intersectPointerCapture({intersection:e,object:t},n){const i=e.details;if("screen-ray"!=i.type)throw new Error(`unable to process a pointer capture of type "${e.details.type}" with a camera ray intersector`);if(!this.startIntersection(n))return e;this.viewPlane.constant-=i.distanceViewPlane;const r=this.raycaster.ray.intersectPlane(this.viewPlane,new Kc);if(null==r)return e;e.object.updateWorldMatrix(!0,!1),function(e,t,n){const i=t.normal??t.face?.normal;null!=i&&(e.setFromNormalAndCoplanarPoint(i,t.localPoint),e.applyMatrix4(n))}(this.viewPlane,e,e.object.matrixWorld);let a=e.uv;return e.object instanceof gh&&mx(yx,r,e.object)&&(a=yx.clone()),{...e,details:{...i,direction:this.raycaster.ray.direction.clone(),screenPoint:this.coords.clone()},uv:a,object:t,point:r,pointOnFace:r,pointerPosition:this.raycaster.ray.origin.clone(),pointerQuaternion:this.cameraQuaternion.clone()}}startIntersection(e){const t=this.prepareTransformation(e,this.coords);return null!=t&&(t.updateWorldMatrix(!0,!1),t.matrixWorld.decompose(this.fromPosition,this.fromQuaternion,vx),this.raycaster.setFromCamera(this.coords,t),this.viewPlane.setFromNormalAndCoplanarPoint(t.getWorldDirection(xx),this.raycaster.ray.origin),!0)}executeIntersection(e,t){const n=this.intersects.length;e.raycast(this.raycaster,this.intersects),function(e,t,n){for(;n>0;)e.push(t),--n}(this.pointerEventsOrders,t,this.intersects.length-n)}finalizeIntersection(e){const t=this.fromPosition.clone(),n=this.cameraQuaternion.clone(),i=this.raycaster.ray.direction.clone(),r=function(e,t,{customSort:n=ex}={}){let i,r,a;const s=e.length;for(let o=0;o<s;o++){const s=e[o],l=t?.[o];(null==i||n(s,l,i,r)<0)&&(a=o,i=s,r=l)}return a}(this.intersects,this.pointerEventsOrders,this.options),a=null==r?void 0:this.intersects[r];return this.intersects.length=0,this.pointerEventsOrders.length=0,null==a?function(e,t,n,i,r,a=0){const s=t.direction.clone().multiplyScalar(tx),o=tx;return{distance:o+a,object:Ky(e),point:s,normal:t.origin.clone().sub(s).normalize(),details:n(s,o),pointerPosition:i,pointerQuaternion:r,pointOnFace:s,localPoint:s}}(e,this.raycaster.ray,(e,t)=>({type:"screen-ray",distanceViewPlane:t,screenPoint:this.coords.clone(),direction:i}),t,n):(a.object.updateWorldMatrix(!0,!1),gx.copy(a.object.matrixWorld).invert(),Object.assign(a,{details:{type:"screen-ray",distanceViewPlane:this.viewPlane.distanceToPoint(a.point),screenPoint:this.coords.clone(),direction:i},pointOnFace:a.point,pointerPosition:t,pointerQuaternion:n,localPoint:a.point.clone().applyMatrix4(gx)}))}}new Kc,new $c,new qu,new Kc,new Vh,new Fu,new Kc,new Kc,new Kc,new Kc(1e-4,1e-4,1e-4),new qu;let bx=99412;function wx(e,t,n){if(!(t instanceof globalThis.MouseEvent))return n.set(0,0);const{width:i,height:r,top:a,left:s}=e.getBoundingClientRect(),o=t.clientX-s,l=t.clientY-a;return n.set(o/i*2-1,-l/r*2+1)}function Sx(e,t,n,i){return function(e,t,n,i,r,a,s={}){const o=s?.forwardPointerCapture??!0,l=new Map,c=s.pointerTypePrefix??"forward-",u=(e,u)=>{let d=l.get(e.pointerId);return null!=d||(d=new ax(bx++,`${c}${e.pointerType}`,e.pointerState,new _x((e,n)=>(i(e,n),t()),s),t,void 0,o?r.bind(null,e.pointerId):void 0,o?a.bind(null,e.pointerId):void 0,s),"move"!=u&&"wheel"!=u&&(d.setIntersection(d.computeIntersection("pointer",n,e)),d.commit(e,!1)),l.set(e.pointerId,d)),d},d=new Map,h=new Map,f=[],p=[],m=(e,t,i)=>{switch(e){case"move":return void i.move(n,t);case"wheel":return void i.wheel(n,t);case"cancel":return void i.cancel(t);case"down":if(!Mx(t))return;return void i.down(t);case"up":if(!Mx(t))return;return void i.up(t);case"exit":return h.delete(i),d.delete(i),void i.exit(t)}},g=(e,t)=>{const n=u(t,e);"move"===e&&h.set(n,t),"wheel"===e&&d.set(n,t),s.batchEvents??1?p.push({type:e,event:t}):m(e,t,n)},v=g.bind(null,"move"),y=g.bind(null,"cancel"),x=g.bind(null,"down"),_=g.bind(null,"up"),b=g.bind(null,"wheel"),w=g.bind(null,"exit");return e.addEventListener("pointermove",v),e.addEventListener("pointercancel",y),e.addEventListener("pointerdown",x),e.addEventListener("pointerup",_),e.addEventListener("wheel",b),e.addEventListener("pointerleave",w),{destroy(){e.removeEventListener("pointermove",v),e.removeEventListener("pointercancel",y),e.removeEventListener("pointerdown",x),e.removeEventListener("pointerup",_),e.removeEventListener("wheel",b),e.removeEventListener("pointerleave",w),h.clear(),d.clear()},update(){const e=p.length;for(let t=0;t<e;t++){const{type:e,event:n}=p[t],i=u(n,e);"move"!==e||(f.push(i),h.get(i)==n)?"wheel"!==e||d.get(i)==n?m(e,n,i):i.emitWheel(n):i.emitMove(n)}if(p.length=0,s.intersectEveryFrame)for(const[e,t]of h.entries())f.includes(e)||e.move(n,t);f.length=0}}}(e,"function"==typeof t?t:()=>t,n,wx.bind(null,e),e.setPointerCapture.bind(e),t=>{e.hasPointerCapture(t)&&e.releasePointerCapture(t)},{pointerTypePrefix:"screen-",...i})}function Mx(e){return null!=e.button}new $c,new Kc,new Kc,new Kc,new $c,new $c,new Kc,new Kc,new $c,new $c,new $c,new $c,new Kc,new Kc;class Ex{constructor(e){this.xrDevice=e,this.combinedCameraPosition=new Kc,this.isPointerLocked=!1,this.vec3=new Kc,this.quat=new Yc,this.quatB=new Yc,this.euler=new id,this.keyState={ShiftLeft:!1,KeyW:!1,KeyA:!1,KeyS:!1,KeyD:!1,ArrowUp:!1,ArrowDown:!1},this.lastTime=0,this.isInProgrammaticMode=!1,this.interactionsEnabled=!0,this.scene=new kh,this.camera=new Rh(50,window.innerWidth/window.innerHeight,.1,40),this.playerRig=new Dh,this.cameraRig=new Dh,this.scene.add(this.playerRig),this.playerRig.add(this.cameraRig),this.cameraRig.position.fromArray(e.position.vec3),this.cameraRig.quaternion.fromArray(e.quaternion.quat),this.cameraRig.add(this.camera),this.camera.position.x-=e.ipd/2;const t=new gh(new hf(.25,.27,32),new Gd({color:16777215,side:0}));t.rotateX(-Math.PI/2),this.scene.add(t),this.renderer=new gg({alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(window.innerWidth,window.innerHeight),this.renderer.setClearColor(0,0),this.renderer.domElement.style.position="fixed",this.renderer.domElement.style.top="50vh",this.renderer.domElement.style.left="50vw",this.renderer.domElement.style.transform="translate(-50%, -50%)",this.transformHandles=new Map,["left","right"].forEach(t=>{const n=new zy;n.scale.setScalar(.1),n.position.fromArray(e.controllers[t].position.vec3),n.quaternion.fromArray(e.controllers[t].quaternion.quat),this.cameraRig.attach(n),n.userData={defaultPosition:n.position.toArray(),defaultQuaternion:n.quaternion.toArray()},n.userData.setMode=e=>{var t,i;null===(i=(t=n.userData).modeCleanup)||void 0===i||i.call(t),n.userData.modeCleanup=n.bind(e),n.userData.mode=e},n.userData.setMode("translate"),n.space="local",this.transformHandles.set(t,n),n.addEventListener("click",()=>{"translate"===n.userData.mode?n.userData.setMode("rotate"):n.userData.setMode("translate")})}),window.transformHandles=this.transformHandles,this.mouseMoveHandler=t=>{if(!this.isPointerLocked||this.isInProgrammaticMode)return;const n=t.movementX||t.mozMovementX||t.webkitMovementX||0,i=t.movementY||t.mozMovementY||t.webkitMovementY||0;this.playerRig.rotation.y-=.002*n,this.cameraRig.rotation.x-=.002*i,e.quaternion.copy(this.cameraRig.getWorldQuaternion(new Yc))},this.cameraRig.getWorldPosition(this.combinedCameraPosition),this.headsetDefaultPosition=this.cameraRig.position.clone(),this.headsetDefaultQuaternion=this.cameraRig.quaternion.clone(),this.forwardHtmlEvents=Sx(this.renderer.domElement,()=>this.camera,this.scene).update,document.addEventListener("pointerlockchange",this.pointerLockChangeHandler.bind(this),!1),document.addEventListener("mozpointerlockchange",this.pointerLockChangeHandler.bind(this),!1),document.addEventListener("webkitpointerlockchange",this.pointerLockChangeHandler.bind(this),!1),document.addEventListener("keydown",this.keyDownHandler.bind(this),!1),document.addEventListener("keyup",this.keyUpHandler.bind(this),!1)}lockPointer(){!this.isInProgrammaticMode&&this.interactionsEnabled&&(this.renderer.domElement.requestPointerLock=this.renderer.domElement.requestPointerLock||this.renderer.domElement.mozRequestPointerLock||this.renderer.domElement.webkitRequestPointerLock,this.renderer.domElement.requestPointerLock())}pointerLockChangeHandler(){this.isPointerLocked=document.pointerLockElement===this.renderer.domElement||document.mozPointerLockElement===this.renderer.domElement||document.webkitPointerLockElement===this.renderer.domElement,this.isPointerLocked?(document.addEventListener("mousemove",this.mouseMoveHandler,!1),Object.values(this.transformHandles).forEach(e=>{e.visible=!1})):(document.removeEventListener("mousemove",this.mouseMoveHandler,!1),Object.values(this.transformHandles).forEach(e=>{e.visible=!this.isInProgrammaticMode}))}keyDownHandler(e){const{keyState:t}=this;e.code in t&&(t[e.code]=!0),this.isInProgrammaticMode||(t.ShiftLeft&&t.ArrowUp&&(this.cameraRig.position.y+=.05),t.ShiftLeft&&t.ArrowDown&&(this.cameraRig.position.y-=.05))}keyUpHandler(e){const{keyState:t}=this;e.code in t&&(t[e.code]=!1)}movePlayerRig(e){const{playerRig:t,keyState:n,vec3:i}=this;i.set((n.KeyD?1:0)-(n.KeyA?1:0),0,(n.KeyS?1:0)-(n.KeyW?1:0)),i.lengthSq()>0&&n.ShiftLeft&&(i.normalize().multiplyScalar(2*e).applyQuaternion(t.quaternion),t.position.add(i))}resetDeviceTransforms(){const{playerRig:e,cameraRig:t,transformHandles:n}=this;t.position.copy(this.headsetDefaultPosition),t.quaternion.copy(this.headsetDefaultQuaternion),e.position.set(0,0,0),e.quaternion.set(0,0,0,1),n.forEach(e=>{e.position.fromArray(e.userData.defaultPosition),e.quaternion.fromArray(e.userData.defaultQuaternion)})}syncDeviceTransforms(){const{xrDevice:e,cameraRig:t,transformHandles:n}=this;e.position.copy(t.getWorldPosition(this.vec3)),e.quaternion.copy(t.getWorldQuaternion(this.quat)),n.forEach((t,n)=>{const i="controller"===e.primaryInputMode?e.controllers[n]:e.hands[n];i.position.copy(t.getWorldPosition(this.vec3)),i.quaternion.copy(t.getWorldQuaternion(this.quat))})}syncFromDevice(){const{xrDevice:e,playerRig:t,cameraRig:n,transformHandles:i}=this,r=e.position,a=e.quaternion;this.combinedCameraPosition.set(r.x,r.y,r.z),this.quatB.set(a.x,a.y,a.z,a.w),this.euler.setFromQuaternion(this.quatB,"YXZ"),t.position.set(r.x,0,r.z),t.rotation.set(0,this.euler.y,0),n.position.set(0,r.y,0),this.quat.setFromEuler(this.euler.set(0,this.euler.y,0,"YXZ")),n.quaternion.multiplyQuaternions(this.quat.invert(),this.quatB),t.updateMatrixWorld(!0),i.forEach((t,i)=>{const r="controller"===e.primaryInputMode?e.controllers[i]:e.hands[i],a=this.vec3.set(r.position.x,r.position.y,r.position.z);n.worldToLocal(a),t.position.copy(a),n.getWorldQuaternion(this.quat),this.quatB.set(r.quaternion.x,r.quaternion.y,r.quaternion.z,r.quaternion.w),this.quatB.premultiply(this.quat.invert()),t.quaternion.copy(this.quatB)})}setInteractionsEnabled(e){this.interactionsEnabled=e,!e&&this.isPointerLocked&&document.exitPointerLock()}renderScene(e){const t=this.xrDevice.fovy/Math.PI*180;let n=!1;this.camera.fov!==t&&(this.camera.fov=t,n=!0);const i=this.xrDevice.canvasDimensions;if(i){const e=this.renderer.domElement;(e.width!==i.width||e.height!==i.height)&&(this.camera.aspect=i.width/i.height,this.renderer.setSize(i.width,i.height),n=!0)}n&&this.camera.updateProjectionMatrix(),this.isInProgrammaticMode||(this.isPointerLocked?this.cameraRig.getWorldPosition(this.combinedCameraPosition):(this.cameraRig.position.y=this.combinedCameraPosition.y,this.playerRig.position.x=this.combinedCameraPosition.x,this.playerRig.position.z=this.combinedCameraPosition.z)),this.forwardHtmlEvents(),this.transformHandles.forEach((t,n)=>{var i;const r=Boolean(null===(i=this.xrDevice.controllers[n])||void 0===i?void 0:i.connected);t.visible=r&&!this.isPointerLocked&&!this.isInProgrammaticMode,r&&t.update(e,this.camera)});const r=Math.min((e-this.lastTime)/1e3,.1);this.isInProgrammaticMode||(this.movePlayerRig(r),this.syncDeviceTransforms()),this.renderer.render(this.scene,this.camera),this.lastTime=e}get domElement(){return this.renderer.domElement}dispose(){this.renderer.dispose(),document.removeEventListener("pointerlockchange",this.pointerLockChangeHandler.bind(this),!1),document.removeEventListener("mozpointerlockchange",this.pointerLockChangeHandler.bind(this),!1),document.removeEventListener("webkitpointerlockchange",this.pointerLockChangeHandler.bind(this),!1),document.removeEventListener("mousemove",this.mouseMoveHandler,!1),document.removeEventListener("keydown",this.keyDownHandler.bind(this),!1),document.removeEventListener("keyup",this.keyUpHandler.bind(this),!1)}}var Tx,Ax,Rx={exports:{}},Cx={},Px={exports:{}},Lx={};function Ix(){return Ax||(Ax=1,Px.exports=(Tx||(Tx=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var i=n-1>>>1,a=e[i];if(!(0<r(a,t)))break e;e[i]=t,e[n]=a,n=i}}function n(e){return 0===e.length?null:e[0]}function i(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var i=0,a=e.length,s=a>>>1;i<s;){var o=2*(i+1)-1,l=e[o],c=o+1,u=e[c];if(0>r(l,n))c<a&&0>r(u,l)?(e[i]=u,e[c]=n,i=c):(e[i]=l,e[o]=n,i=o);else{if(!(c<a&&0>r(u,n)))break e;e[i]=u,e[c]=n,i=c}}}return t}function r(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if(e.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var a=performance;e.unstable_now=function(){return a.now()}}else{var s=Date,o=s.now();e.unstable_now=function(){return s.now()-o}}var l=[],c=[],u=1,d=null,h=3,f=!1,p=!1,m=!1,g=!1,v="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,x="undefined"!=typeof setImmediate?setImmediate:null;function _(e){for(var r=n(c);null!==r;){if(null===r.callback)i(c);else{if(!(r.startTime<=e))break;i(c),r.sortIndex=r.expirationTime,t(l,r)}r=n(c)}}function b(e){if(m=!1,_(e),!p)if(null!==n(l))p=!0,S||(S=!0,w());else{var t=n(c);null!==t&&L(b,t.startTime-e)}}var w,S=!1,M=-1,E=5,T=-1;function A(){return!(!g&&e.unstable_now()-T<E)}function R(){if(g=!1,S){var t=e.unstable_now();T=t;var r=!0;try{e:{p=!1,m&&(m=!1,y(M),M=-1),f=!0;var a=h;try{t:{for(_(t),d=n(l);null!==d&&!(d.expirationTime>t&&A());){var s=d.callback;if("function"==typeof s){d.callback=null,h=d.priorityLevel;var o=s(d.expirationTime<=t);if(t=e.unstable_now(),"function"==typeof o){d.callback=o,_(t),r=!0;break t}d===n(l)&&i(l),_(t)}else i(l);d=n(l)}if(null!==d)r=!0;else{var u=n(c);null!==u&&L(b,u.startTime-t),r=!1}}break e}finally{d=null,h=a,f=!1}r=void 0}}finally{r?w():S=!1}}}if("function"==typeof x)w=function(){x(R)};else if("undefined"!=typeof MessageChannel){var C=new MessageChannel,P=C.port2;C.port1.onmessage=R,w=function(){P.postMessage(null)}}else w=function(){v(R,0)};function L(t,n){M=v(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_next=function(e){switch(h){case 1:case 2:case 3:var t=3;break;default:t=h}var n=h;h=t;try{return e()}finally{h=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=h;h=e;try{return t()}finally{h=n}},e.unstable_scheduleCallback=function(i,r,a){var s=e.unstable_now();switch(a="object"==typeof a&&null!==a&&"number"==typeof(a=a.delay)&&0<a?s+a:s,i){case 1:var o=-1;break;case 2:o=250;break;case 5:o=1073741823;break;case 4:o=1e4;break;default:o=5e3}return i={id:u++,callback:r,priorityLevel:i,startTime:a,expirationTime:o=a+o,sortIndex:-1},a>s?(i.sortIndex=a,t(c,i),null===n(l)&&i===n(c)&&(m?(y(M),M=-1):m=!0,L(b,a-s))):(i.sortIndex=o,t(l,i),p||f||(p=!0,S||(S=!0,w()))),i},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(e){var t=h;return function(){var n=h;h=t;try{return e.apply(this,arguments)}finally{h=n}}}}(Lx)),Lx)),Px.exports}var Dx,Nx,Ox,kx={exports:{}},Ux={};function Fx(){if(Dx)return Ux;Dx=1;var e=o;function t(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var i={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},r=Symbol.for("react.portal");var a=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function s(e,t){return"font"===e?"":"string"==typeof t?"use-credentials"===t?t:"":void 0}return Ux.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,Ux.createPortal=function(e,n){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!n||1!==n.nodeType&&9!==n.nodeType&&11!==n.nodeType)throw Error(t(299));return function(e,t,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:r,key:null==i?null:""+i,children:e,containerInfo:t,implementation:n}}(e,n,null,i)},Ux.flushSync=function(e){var t=a.T,n=i.p;try{if(a.T=null,i.p=2,e)return e()}finally{a.T=t,i.p=n,i.d.f()}},Ux.preconnect=function(e,t){"string"==typeof e&&(t?t="string"==typeof(t=t.crossOrigin)?"use-credentials"===t?t:"":void 0:t=null,i.d.C(e,t))},Ux.prefetchDNS=function(e){"string"==typeof e&&i.d.D(e)},Ux.preinit=function(e,t){if("string"==typeof e&&t&&"string"==typeof t.as){var n=t.as,r=s(n,t.crossOrigin),a="string"==typeof t.integrity?t.integrity:void 0,o="string"==typeof t.fetchPriority?t.fetchPriority:void 0;"style"===n?i.d.S(e,"string"==typeof t.precedence?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):"script"===n&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:"string"==typeof t.nonce?t.nonce:void 0})}},Ux.preinitModule=function(e,t){if("string"==typeof e)if("object"==typeof t&&null!==t){if(null==t.as||"script"===t.as){var n=s(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0})}}else null==t&&i.d.M(e)},Ux.preload=function(e,t){if("string"==typeof e&&"object"==typeof t&&null!==t&&"string"==typeof t.as){var n=t.as,r=s(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0,type:"string"==typeof t.type?t.type:void 0,fetchPriority:"string"==typeof t.fetchPriority?t.fetchPriority:void 0,referrerPolicy:"string"==typeof t.referrerPolicy?t.referrerPolicy:void 0,imageSrcSet:"string"==typeof t.imageSrcSet?t.imageSrcSet:void 0,imageSizes:"string"==typeof t.imageSizes?t.imageSizes:void 0,media:"string"==typeof t.media?t.media:void 0})}},Ux.preloadModule=function(e,t){if("string"==typeof e)if(t){var n=s(t.as,t.crossOrigin);i.d.m(e,{as:"string"==typeof t.as&&"script"!==t.as?t.as:void 0,crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0})}else i.d.m(e)},Ux.requestFormReset=function(e){i.d.r(e)},Ux.unstable_batchedUpdates=function(e,t){return e(t)},Ux.useFormState=function(e,t,n){return a.H.useFormState(e,t,n)},Ux.useFormStatus=function(){return a.H.useHostTransitionStatus()},Ux.version="19.2.0",Ux}!function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),Rx.exports=function(){if(Ox)return Cx;Ox=1;var e=Ix(),t=o,n=(Nx||(Nx=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),kx.exports=Fx()),kx.exports);function i(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function a(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{!!(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function s(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&null!==(e=e.alternate)&&(t=e.memoizedState),null!==t)return t.dehydrated}return null}function l(e){if(31===e.tag){var t=e.memoizedState;if(null===t&&null!==(e=e.alternate)&&(t=e.memoizedState),null!==t)return t.dehydrated}return null}function c(e){if(a(e)!==e)throw Error(i(188))}function u(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e;for(e=e.child;null!==e;){if(null!==(t=u(e)))return t;e=e.sibling}return null}var d=Object.assign,h=Symbol.for("react.element"),f=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),x=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),w=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),T=Symbol.for("react.memo_cache_sentinel"),A=Symbol.iterator;function R(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=A&&e[A]||e["@@iterator"])?e:null}var C=Symbol.for("react.client.reference");function P(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===C?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case m:return"Fragment";case v:return"Profiler";case g:return"StrictMode";case b:return"Suspense";case w:return"SuspenseList";case E:return"Activity"}if("object"==typeof e)switch(e.$$typeof){case p:return"Portal";case x:return e.displayName||"Context";case y:return(e._context.displayName||"Context")+".Consumer";case _:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case S:return null!==(t=e.displayName||null)?t:P(e.type)||"Memo";case M:t=e._payload,e=e._init;try{return P(e(t))}catch(e){}}return null}var L=Array.isArray,I=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N={pending:!1,data:null,method:null,action:null},O=[],k=-1;function U(e){return{current:e}}function F(e){0>k||(e.current=O[k],O[k]=null,k--)}function z(e,t){k++,O[k]=e.current,e.current=t}var B,V,H=U(null),G=U(null),j=U(null),W=U(null);function X(e,t){switch(z(j,t),z(G,e),z(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?md(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=gd(t=md(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}F(H),z(H,e)}function q(){F(H),F(G),F(j)}function $(e){null!==e.memoizedState&&z(W,e);var t=H.current,n=gd(t,e.type);t!==n&&(z(G,e),z(H,n))}function Y(e){G.current===e&&(F(H),F(G)),W.current===e&&(F(W),lh._currentValue=N)}function K(e){if(void 0===B)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);B=t&&t[1]||"",V=-1<e.stack.indexOf("\n at")?" (<anonymous>)":-1<e.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+B+e+V}var Z=!1;function Q(e,t){if(!e||Z)return"";Z=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var i=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){i=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){i=e}(n=e())&&"function"==typeof n.catch&&n.catch(function(){})}}catch(e){if(e&&i&&"string"==typeof e.stack)return[e.stack,i.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var r=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");r&&r.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var a=i.DetermineComponentFrameRoot(),s=a[0],o=a[1];if(s&&o){var l=s.split("\n"),c=o.split("\n");for(r=i=0;i<l.length&&!l[i].includes("DetermineComponentFrameRoot");)i++;for(;r<c.length&&!c[r].includes("DetermineComponentFrameRoot");)r++;if(i===l.length||r===c.length)for(i=l.length-1,r=c.length-1;1<=i&&0<=r&&l[i]!==c[r];)r--;for(;1<=i&&0<=r;i--,r--)if(l[i]!==c[r]){if(1!==i||1!==r)do{if(i--,0>--r||l[i]!==c[r]){var u="\n"+l[i].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}}while(1<=i&&0<=r);break}}}finally{Z=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?K(n):""}function J(e,t){switch(e.tag){case 26:case 27:case 5:return K(e.type);case 16:return K("Lazy");case 13:return e.child!==t&&null!==t?K("Suspense Fallback"):K("Suspense");case 19:return K("SuspenseList");case 0:case 15:return Q(e.type,!1);case 11:return Q(e.type.render,!1);case 1:return Q(e.type,!0);case 31:return K("Activity");default:return""}}function ee(e){try{var t="",n=null;do{t+=J(e,n),n=e,e=e.return}while(e);return t}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}var te=Object.prototype.hasOwnProperty,ne=e.unstable_scheduleCallback,ie=e.unstable_cancelCallback,re=e.unstable_shouldYield,ae=e.unstable_requestPaint,se=e.unstable_now,oe=e.unstable_getCurrentPriorityLevel,le=e.unstable_ImmediatePriority,ce=e.unstable_UserBlockingPriority,ue=e.unstable_NormalPriority,de=e.unstable_LowPriority,he=e.unstable_IdlePriority,fe=e.log,pe=e.unstable_setDisableYieldValue,me=null,ge=null;function ve(e){if("function"==typeof fe&&pe(e),ge&&"function"==typeof ge.setStrictMode)try{ge.setStrictMode(me,e)}catch(e){}}var ye=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(xe(e)/_e|0)|0},xe=Math.log,_e=Math.LN2,be=256,we=262144,Se=4194304;function Me(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ee(e,t,n){var i=e.pendingLanes;if(0===i)return 0;var r=0,a=e.suspendedLanes,s=e.pingedLanes;e=e.warmLanes;var o=134217727&i;return 0!==o?0!==(i=o&~a)?r=Me(i):0!==(s&=o)?r=Me(s):n||0!==(n=o&~e)&&(r=Me(n)):0!==(o=i&~a)?r=Me(o):0!==s?r=Me(s):n||0!==(n=i&~e)&&(r=Me(n)),0===r?0:0!==t&&t!==r&&0===(t&a)&&((a=r&-r)>=(n=t&-t)||32===a&&4194048&n)?t:r}function Te(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Ae(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function Re(){var e=Se;return!(62914560&(Se<<=1))&&(Se=4194304),e}function Ce(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Pe(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Le(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var i=31-ye(t);e.entangledLanes|=t,e.entanglements[i]=1073741824|e.entanglements[i]|261930&n}function Ie(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var i=31-ye(n),r=1<<i;r&t|e[i]&t&&(e[i]|=t),n&=~r}}function De(e,t){var n=t&-t;return 0!==((n=42&n?1:Ne(n))&(e.suspendedLanes|t))?0:n}function Ne(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Oe(e){return 2<(e&=-e)?8<e?134217727&e?32:268435456:8:2}function ke(){var e=D.p;return 0!==e?e:void 0===(e=window.event)?32:Mh(e.type)}function Ue(e,t){var n=D.p;try{return D.p=e,t()}finally{D.p=n}}var Fe=Math.random().toString(36).slice(2),ze="__reactFiber$"+Fe,Be="__reactProps$"+Fe,Ve="__reactContainer$"+Fe,He="__reactEvents$"+Fe,Ge="__reactListeners$"+Fe,je="__reactHandles$"+Fe,We="__reactResources$"+Fe,Xe="__reactMarker$"+Fe;function qe(e){delete e[ze],delete e[Be],delete e[He],delete e[Ge],delete e[je]}function $e(e){var t=e[ze];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ve]||n[ze]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Nd(e);null!==e;){if(n=e[ze])return n;e=Nd(e)}return t}n=(e=n).parentNode}return null}function Ye(e){if(e=e[ze]||e[Ve]){var t=e.tag;if(5===t||6===t||13===t||31===t||26===t||27===t||3===t)return e}return null}function Ke(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(i(33))}function Ze(e){var t=e[We];return t||(t=e[We]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Qe(e){e[Xe]=!0}var Je=new Set,et={};function tt(e,t){nt(e,t),nt(e+"Capture",t)}function nt(e,t){for(et[e]=t,e=0;e<t.length;e++)Je.add(t[e])}var it=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),rt={},at={};function st(e,t,n){if(r=t,te.call(at,r)||!te.call(rt,r)&&(it.test(r)?at[r]=!0:(rt[r]=!0,0)))if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":return void e.removeAttribute(t);case"boolean":var i=t.toLowerCase().slice(0,5);if("data-"!==i&&"aria-"!==i)return void e.removeAttribute(t)}e.setAttribute(t,""+n)}var r}function ot(e,t,n){if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(t)}e.setAttribute(t,""+n)}}function lt(e,t,n,i){if(null===i)e.removeAttribute(n);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(n)}e.setAttributeNS(t,n,""+i)}}function ct(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function ut(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function dt(e){if(!e._valueTracker){var t=ut(e)?"checked":"value";e._valueTracker=function(e,t,n){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&void 0!==i&&"function"==typeof i.get&&"function"==typeof i.set){var r=i.get,a=i.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(e){n=""+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:i.enumerable}),{getValue:function(){return n},setValue:function(e){n=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e,t,""+e[t])}}function ht(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),i="";return e&&(i=ut(e)?e.checked?"true":"false":e.value),(e=i)!==n&&(t.setValue(e),!0)}function ft(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}var pt=/[\n"\\]/g;function mt(e){return e.replace(pt,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function gt(e,t,n,i,r,a,s,o){e.name="",null!=s&&"function"!=typeof s&&"symbol"!=typeof s&&"boolean"!=typeof s?e.type=s:e.removeAttribute("type"),null!=t?"number"===s?(0===t&&""===e.value||e.value!=t)&&(e.value=""+ct(t)):e.value!==""+ct(t)&&(e.value=""+ct(t)):"submit"!==s&&"reset"!==s||e.removeAttribute("value"),null!=t?yt(e,s,ct(t)):null!=n?yt(e,s,ct(n)):null!=i&&e.removeAttribute("value"),null==r&&null!=a&&(e.defaultChecked=!!a),null!=r&&(e.checked=r&&"function"!=typeof r&&"symbol"!=typeof r),null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o?e.name=""+ct(o):e.removeAttribute("name")}function vt(e,t,n,i,r,a,s,o){if(null!=a&&"function"!=typeof a&&"symbol"!=typeof a&&"boolean"!=typeof a&&(e.type=a),null!=t||null!=n){if(("submit"===a||"reset"===a)&&null==t)return void dt(e);n=null!=n?""+ct(n):"",t=null!=t?""+ct(t):n,o||t===e.value||(e.value=t),e.defaultValue=t}i="function"!=typeof(i=null!=i?i:r)&&"symbol"!=typeof i&&!!i,e.checked=o?e.checked:!!i,e.defaultChecked=!!i,null!=s&&"function"!=typeof s&&"symbol"!=typeof s&&"boolean"!=typeof s&&(e.name=s),dt(e)}function yt(e,t,n){"number"===t&&ft(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function xt(e,t,n,i){if(e=e.options,t){t={};for(var r=0;r<n.length;r++)t["$"+n[r]]=!0;for(n=0;n<e.length;n++)r=t.hasOwnProperty("$"+e[n].value),e[n].selected!==r&&(e[n].selected=r),r&&i&&(e[n].defaultSelected=!0)}else{for(n=""+ct(n),t=null,r=0;r<e.length;r++){if(e[r].value===n)return e[r].selected=!0,void(i&&(e[r].defaultSelected=!0));null!==t||e[r].disabled||(t=e[r])}null!==t&&(t.selected=!0)}}function _t(e,t,n){null==t||((t=""+ct(t))!==e.value&&(e.value=t),null!=n)?e.defaultValue=null!=n?""+ct(n):"":e.defaultValue!==t&&(e.defaultValue=t)}function bt(e,t,n,r){if(null==t){if(null!=r){if(null!=n)throw Error(i(92));if(L(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}null==n&&(n=""),t=n}n=ct(t),e.defaultValue=n,(r=e.textContent)===n&&""!==r&&null!==r&&(e.value=r),dt(e)}function wt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var St=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Mt(e,t,n){var i=0===t.indexOf("--");null==n||"boolean"==typeof n||""===n?i?e.setProperty(t,""):"float"===t?e.cssFloat="":e[t]="":i?e.setProperty(t,n):"number"!=typeof n||0===n||St.has(t)?"float"===t?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Et(e,t,n){if(null!=t&&"object"!=typeof t)throw Error(i(62));if(e=e.style,null!=n){for(var r in n)!n.hasOwnProperty(r)||null!=t&&t.hasOwnProperty(r)||(0===r.indexOf("--")?e.setProperty(r,""):"float"===r?e.cssFloat="":e[r]="");for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Mt(e,a,r)}else for(var s in t)t.hasOwnProperty(s)&&Mt(e,s,t[s])}function Tt(e){if(-1===e.indexOf("-"))return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var At=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Rt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Ct(e){return Rt.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Pt(){}var Lt=null;function It(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Dt=null,Nt=null;function Ot(e){var t=Ye(e);if(t&&(e=t.stateNode)){var n=e[Be]||null;e:switch(e=t.stateNode,t.type){case"input":if(gt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,"radio"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+mt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[Be]||null;if(!a)throw Error(i(90));gt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)(r=n[t]).form===e.form&&ht(r)}break e;case"textarea":_t(e,n.value,n.defaultValue);break e;case"select":null!=(t=n.value)&&xt(e,!!n.multiple,t,!1)}}}var kt=!1;function Ut(e,t,n){if(kt)return e(t,n);kt=!0;try{return e(t)}finally{if(kt=!1,(null!==Dt||null!==Nt)&&(Zc(),Dt&&(t=Dt,e=Nt,Nt=Dt=null,Ot(t),e)))for(t=0;t<e.length;t++)Ot(e[t])}}function Ft(e,t){var n=e.stateNode;if(null===n)return null;var r=n[Be]||null;if(null===r)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(r=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!r;break e;default:e=!1}if(e)return null;if(n&&"function"!=typeof n)throw Error(i(231,t,typeof n));return n}var zt=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),Bt=!1;if(zt)try{var Vt={};Object.defineProperty(Vt,"passive",{get:function(){Bt=!0}}),window.addEventListener("test",Vt,Vt),window.removeEventListener("test",Vt,Vt)}catch(e){Bt=!1}var Ht=null,Gt=null,jt=null;function Wt(){if(jt)return jt;var e,t,n=Gt,i=n.length,r="value"in Ht?Ht.value:Ht.textContent,a=r.length;for(e=0;e<i&&n[e]===r[e];e++);var s=i-e;for(t=1;t<=s&&n[i-t]===r[a-t];t++);return jt=r.slice(e,1<t?1-t:void 0)}function Xt(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function qt(){return!0}function $t(){return!1}function Yt(e){function t(t,n,i,r,a){for(var s in this._reactName=t,this._targetInst=i,this.type=n,this.nativeEvent=r,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(s)&&(t=e[s],this[s]=t?t(r):r[s]);return this.isDefaultPrevented=(null!=r.defaultPrevented?r.defaultPrevented:!1===r.returnValue)?qt:$t,this.isPropagationStopped=$t,this}return d(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=qt)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=qt)},persist:function(){},isPersistent:qt}),t}var Kt,Zt,Qt,Jt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},en=Yt(Jt),tn=d({},Jt,{view:0,detail:0}),nn=Yt(tn),rn=d({},tn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:mn,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Qt&&(Qt&&"mousemove"===e.type?(Kt=e.screenX-Qt.screenX,Zt=e.screenY-Qt.screenY):Zt=Kt=0,Qt=e),Kt)},movementY:function(e){return"movementY"in e?e.movementY:Zt}}),an=Yt(rn),sn=Yt(d({},rn,{dataTransfer:0})),on=Yt(d({},tn,{relatedTarget:0})),ln=Yt(d({},Jt,{animationName:0,elapsedTime:0,pseudoElement:0})),cn=Yt(d({},Jt,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),un=Yt(d({},Jt,{data:0})),dn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},fn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function pn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=fn[e])&&!!t[e]}function mn(){return pn}var gn=Yt(d({},tn,{key:function(e){if(e.key){var t=dn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Xt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?hn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:mn,charCode:function(e){return"keypress"===e.type?Xt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Xt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}})),vn=Yt(d({},rn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),yn=Yt(d({},tn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:mn})),xn=Yt(d({},Jt,{propertyName:0,elapsedTime:0,pseudoElement:0})),_n=Yt(d({},rn,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),bn=Yt(d({},Jt,{newState:0,oldState:0})),wn=[9,13,27,32],Sn=zt&&"CompositionEvent"in window,Mn=null;zt&&"documentMode"in document&&(Mn=document.documentMode);var En=zt&&"TextEvent"in window&&!Mn,Tn=zt&&(!Sn||Mn&&8<Mn&&11>=Mn),An=String.fromCharCode(32),Rn=!1;function Cn(e,t){switch(e){case"keyup":return-1!==wn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pn(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Ln=!1,In={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Dn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!In[e.type]:"textarea"===t}function Nn(e,t,n,i){Dt?Nt?Nt.push(i):Nt=[i]:Dt=i,0<(t=td(t,"onChange")).length&&(n=new en("onChange","change",null,n,i),e.push({event:n,listeners:t}))}var On=null,kn=null;function Un(e){qu(e,0)}function Fn(e){if(ht(Ke(e)))return e}function zn(e,t){if("change"===e)return t}var Bn=!1;if(zt){var Vn;if(zt){var Hn="oninput"in document;if(!Hn){var Gn=document.createElement("div");Gn.setAttribute("oninput","return;"),Hn="function"==typeof Gn.oninput}Vn=Hn}else Vn=!1;Bn=Vn&&(!document.documentMode||9<document.documentMode)}function jn(){On&&(On.detachEvent("onpropertychange",Wn),kn=On=null)}function Wn(e){if("value"===e.propertyName&&Fn(kn)){var t=[];Nn(t,kn,e,It(e)),Ut(Un,t)}}function Xn(e,t,n){"focusin"===e?(jn(),kn=n,(On=t).attachEvent("onpropertychange",Wn)):"focusout"===e&&jn()}function qn(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Fn(kn)}function $n(e,t){if("click"===e)return Fn(t)}function Yn(e,t){if("input"===e||"change"===e)return Fn(t)}var Kn="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function Zn(e,t){if(Kn(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(i=0;i<n.length;i++){var r=n[i];if(!te.call(t,r)||!Kn(e[r],t[r]))return!1}return!0}function Qn(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Jn(e,t){var n,i=Qn(e);for(e=0;i;){if(3===i.nodeType){if(n=e+i.textContent.length,e<=t&&n>=t)return{node:i,offset:t-e};e=n}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qn(i)}}function ei(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?ei(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function ti(e){for(var t=ft((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(e){n=!1}if(!n)break;t=ft((e=t.contentWindow).document)}return t}function ni(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var ii=zt&&"documentMode"in document&&11>=document.documentMode,ri=null,ai=null,si=null,oi=!1;function li(e,t,n){var i=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;oi||null==ri||ri!==ft(i)||(i="selectionStart"in(i=ri)&&ni(i)?{start:i.selectionStart,end:i.selectionEnd}:{anchorNode:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset},si&&Zn(si,i)||(si=i,0<(i=td(ai,"onSelect")).length&&(t=new en("onSelect","select",null,t,n),e.push({event:t,listeners:i}),t.target=ri)))}function ci(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ui={animationend:ci("Animation","AnimationEnd"),animationiteration:ci("Animation","AnimationIteration"),animationstart:ci("Animation","AnimationStart"),transitionrun:ci("Transition","TransitionRun"),transitionstart:ci("Transition","TransitionStart"),transitioncancel:ci("Transition","TransitionCancel"),transitionend:ci("Transition","TransitionEnd")},di={},hi={};function fi(e){if(di[e])return di[e];if(!ui[e])return e;var t,n=ui[e];for(t in n)if(n.hasOwnProperty(t)&&t in hi)return di[e]=n[t];return e}zt&&(hi=document.createElement("div").style,"AnimationEvent"in window||(delete ui.animationend.animation,delete ui.animationiteration.animation,delete ui.animationstart.animation),"TransitionEvent"in window||delete ui.transitionend.transition);var pi=fi("animationend"),mi=fi("animationiteration"),gi=fi("animationstart"),vi=fi("transitionrun"),yi=fi("transitionstart"),xi=fi("transitioncancel"),_i=fi("transitionend"),bi=new Map,wi="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Si(e,t){bi.set(e,t),tt(t,[e])}wi.push("scrollEnd");var Mi="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},Ei=[],Ti=0,Ai=0;function Ri(){for(var e=Ti,t=Ai=Ti=0;t<e;){var n=Ei[t];Ei[t++]=null;var i=Ei[t];Ei[t++]=null;var r=Ei[t];Ei[t++]=null;var a=Ei[t];if(Ei[t++]=null,null!==i&&null!==r){var s=i.pending;null===s?r.next=r:(r.next=s.next,s.next=r),i.pending=r}0!==a&&Ii(n,r,a)}}function Ci(e,t,n,i){Ei[Ti++]=e,Ei[Ti++]=t,Ei[Ti++]=n,Ei[Ti++]=i,Ai|=i,e.lanes|=i,null!==(e=e.alternate)&&(e.lanes|=i)}function Pi(e,t,n,i){return Ci(e,t,n,i),Di(e)}function Li(e,t){return Ci(e,null,null,t),Di(e)}function Ii(e,t,n){e.lanes|=n;var i=e.alternate;null!==i&&(i.lanes|=n);for(var r=!1,a=e.return;null!==a;)a.childLanes|=n,null!==(i=a.alternate)&&(i.childLanes|=n),22===a.tag&&(null===(e=a.stateNode)||1&e._visibility||(r=!0)),e=a,a=a.return;return 3===e.tag?(a=e.stateNode,r&&null!==t&&(r=31-ye(n),null===(i=(e=a.hiddenUpdates)[r])?e[r]=[t]:i.push(t),t.lane=536870912|n),a):null}function Di(e){if(50<Hc)throw Hc=0,Gc=null,Error(i(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Ni={};function Oi(e,t,n,i){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ki(e,t,n,i){return new Oi(e,t,n,i)}function Ui(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Fi(e,t){var n=e.alternate;return null===n?((n=ki(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=65011712&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function zi(e,t){e.flags&=65011714;var n=e.alternate;return null===n?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Bi(e,t,n,r,a,s){var o=0;if(r=e,"function"==typeof e)Ui(e)&&(o=1);else if("string"==typeof e)o=function(e,t,n){if(1===n||null!=t.itemProp)return!1;switch(e){case"meta":case"title":return!0;case"style":if("string"!=typeof t.precedence||"string"!=typeof t.href||""===t.href)break;return!0;case"link":if("string"!=typeof t.rel||"string"!=typeof t.href||""===t.href||t.onLoad||t.onError)break;return"stylesheet"!==t.rel||(e=t.disabled,"string"==typeof t.precedence&&null==e);case"script":if(t.async&&"function"!=typeof t.async&&"symbol"!=typeof t.async&&!t.onLoad&&!t.onError&&t.src&&"string"==typeof t.src)return!0}return!1}(e,n,H.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case E:return(e=ki(31,n,t,a)).elementType=E,e.lanes=s,e;case m:return Vi(n.children,a,s,t);case g:o=8,a|=24;break;case v:return(e=ki(12,n,t,2|a)).elementType=v,e.lanes=s,e;case b:return(e=ki(13,n,t,a)).elementType=b,e.lanes=s,e;case w:return(e=ki(19,n,t,a)).elementType=w,e.lanes=s,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case x:o=10;break e;case y:o=9;break e;case _:o=11;break e;case S:o=14;break e;case M:o=16,r=null;break e}o=29,n=Error(i(130,null===e?"null":typeof e,"")),r=null}return(t=ki(o,n,t,a)).elementType=e,t.type=r,t.lanes=s,t}function Vi(e,t,n,i){return(e=ki(7,e,i,t)).lanes=n,e}function Hi(e,t,n){return(e=ki(6,e,null,t)).lanes=n,e}function Gi(e){var t=ki(18,null,null,0);return t.stateNode=e,t}function ji(e,t,n){return(t=ki(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Wi=new WeakMap;function Xi(e,t){if("object"==typeof e&&null!==e){var n=Wi.get(e);return void 0!==n?n:(t={value:e,source:t,stack:ee(t)},Wi.set(e,t),t)}return{value:e,source:t,stack:ee(t)}}var qi=[],$i=0,Yi=null,Ki=0,Zi=[],Qi=0,Ji=null,er=1,tr="";function nr(e,t){qi[$i++]=Ki,qi[$i++]=Yi,Yi=e,Ki=t}function ir(e,t,n){Zi[Qi++]=er,Zi[Qi++]=tr,Zi[Qi++]=Ji,Ji=e;var i=er;e=tr;var r=32-ye(i)-1;i&=~(1<<r),n+=1;var a=32-ye(t)+r;if(30<a){var s=r-r%5;a=(i&(1<<s)-1).toString(32),i>>=s,r-=s,er=1<<32-ye(t)+r|n<<r|i,tr=a+e}else er=1<<a|n<<r|i,tr=e}function rr(e){null!==e.return&&(nr(e,1),ir(e,1,0))}function ar(e){for(;e===Yi;)Yi=qi[--$i],qi[$i]=null,Ki=qi[--$i],qi[$i]=null;for(;e===Ji;)Ji=Zi[--Qi],Zi[Qi]=null,tr=Zi[--Qi],Zi[Qi]=null,er=Zi[--Qi],Zi[Qi]=null}function sr(e,t){Zi[Qi++]=er,Zi[Qi++]=tr,Zi[Qi++]=Ji,er=t.id,tr=t.overflow,Ji=e}var or=null,lr=null,cr=!1,ur=null,dr=!1,hr=Error(i(519));function fr(e){throw xr(Xi(Error(i(418,1<arguments.length&&void 0!==arguments[1]&&arguments[1]?"text":"HTML","")),e)),hr}function pr(e){var t=e.stateNode,n=e.type,i=e.memoizedProps;switch(t[ze]=e,t[Be]=i,n){case"dialog":$u("cancel",t),$u("close",t);break;case"iframe":case"object":case"embed":$u("load",t);break;case"video":case"audio":for(n=0;n<Wu.length;n++)$u(Wu[n],t);break;case"source":$u("error",t);break;case"img":case"image":case"link":$u("error",t),$u("load",t);break;case"details":$u("toggle",t);break;case"input":$u("invalid",t),vt(t,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":$u("invalid",t);break;case"textarea":$u("invalid",t),bt(t,i.value,i.defaultValue,i.children)}"string"!=typeof(n=i.children)&&"number"!=typeof n&&"bigint"!=typeof n||t.textContent===""+n||!0===i.suppressHydrationWarning||od(t.textContent,n)?(null!=i.popover&&($u("beforetoggle",t),$u("toggle",t)),null!=i.onScroll&&$u("scroll",t),null!=i.onScrollEnd&&$u("scrollend",t),null!=i.onClick&&(t.onclick=Pt),t=!0):t=!1,t||fr(e,!0)}function mr(e){for(or=e.return;or;)switch(or.tag){case 5:case 31:case 13:return void(dr=!1);case 27:case 3:return void(dr=!0);default:or=or.return}}function gr(e){if(e!==or)return!1;if(!cr)return mr(e),cr=!0,!1;var t,n=e.tag;if((t=3!==n&&27!==n)&&((t=5===n)&&(t=!("form"!==(t=e.type)&&"button"!==t)||vd(e.type,e.memoizedProps)),t=!t),t&&lr&&fr(e),mr(e),13===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(i(317));lr=Dd(e)}else if(31===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(i(317));lr=Dd(e)}else 27===n?(n=lr,Md(e.type)?(e=Id,Id=null,lr=e):lr=n):lr=or?Ld(e.stateNode.nextSibling):null;return!0}function vr(){lr=or=null,cr=!1}function yr(){var e=ur;return null!==e&&(null===Rc?Rc=e:Rc.push.apply(Rc,e),ur=null),e}function xr(e){null===ur?ur=[e]:ur.push(e)}var _r=U(null),br=null,wr=null;function Sr(e,t,n){z(_r,t._currentValue),t._currentValue=n}function Mr(e){e._currentValue=_r.current,F(_r)}function Er(e,t,n){for(;null!==e;){var i=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==i&&(i.childLanes|=t)):null!==i&&(i.childLanes&t)!==t&&(i.childLanes|=t),e===n)break;e=e.return}}function Tr(e,t,n,r){var a=e.child;for(null!==a&&(a.return=e);null!==a;){var s=a.dependencies;if(null!==s){var o=a.child;s=s.firstContext;e:for(;null!==s;){var l=s;s=a;for(var c=0;c<t.length;c++)if(l.context===t[c]){s.lanes|=n,null!==(l=s.alternate)&&(l.lanes|=n),Er(s.return,n,e),r||(o=null);break e}s=l.next}}else if(18===a.tag){if(null===(o=a.return))throw Error(i(341));o.lanes|=n,null!==(s=o.alternate)&&(s.lanes|=n),Er(o,n,e),o=null}else o=a.child;if(null!==o)o.return=a;else for(o=a;null!==o;){if(o===e){o=null;break}if(null!==(a=o.sibling)){a.return=o.return,o=a;break}o=o.return}a=o}}function Ar(e,t,n,r){e=null;for(var a=t,s=!1;null!==a;){if(!s)if(524288&a.flags)s=!0;else if(262144&a.flags)break;if(10===a.tag){var o=a.alternate;if(null===o)throw Error(i(387));if(null!==(o=o.memoizedProps)){var l=a.type;Kn(a.pendingProps.value,o.value)||(null!==e?e.push(l):e=[l])}}else if(a===W.current){if(null===(o=a.alternate))throw Error(i(387));o.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(null!==e?e.push(lh):e=[lh])}a=a.return}null!==e&&Tr(t,e,n,r),t.flags|=262144}function Rr(e){for(e=e.firstContext;null!==e;){if(!Kn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Cr(e){br=e,wr=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function Pr(e){return Ir(br,e)}function Lr(e,t){return null===br&&Cr(e),Ir(e,t)}function Ir(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},null===wr){if(null===e)throw Error(i(308));wr=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else wr=wr.next=t;return n}var Dr="undefined"!=typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Nr=e.unstable_scheduleCallback,Or=e.unstable_NormalPriority,kr={$$typeof:x,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ur(){return{controller:new Dr,data:new Map,refCount:0}}function Fr(e){e.refCount--,0===e.refCount&&Nr(Or,function(){e.controller.abort()})}var zr=null,Br=0,Vr=0,Hr=null;function Gr(){if(0===--Br&&null!==zr){null!==Hr&&(Hr.status="fulfilled");var e=zr;zr=null,Vr=0,Hr=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var jr=I.S;I.S=function(e,t){Lc=se(),"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===zr){var n=zr=[];Br=0,Vr=Bu(),Hr={status:"pending",value:void 0,then:function(e){n.push(e)}}}Br++,t.then(Gr,Gr)}(0,t),null!==jr&&jr(e,t)};var Wr=U(null);function Xr(){var e=Wr.current;return null!==e?e:hc.pooledCache}function qr(e,t){z(Wr,null===t?Wr.current:t.pool)}function $r(){var e=Xr();return null===e?null:{parent:kr._currentValue,pool:e}}var Yr=Error(i(460)),Kr=Error(i(474)),Zr=Error(i(542)),Qr={then:function(){}};function Jr(e){return"fulfilled"===(e=e.status)||"rejected"===e}function ea(e,t,n){switch(void 0===(n=e[n])?e.push(t):n!==t&&(t.then(Pt,Pt),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw ra(e=t.reason),e;default:if("string"==typeof t.status)t.then(Pt,Pt);else{if(null!==(e=hc)&&100<e.shellSuspendCounter)throw Error(i(482));(e=t).status="pending",e.then(function(e){if("pending"===t.status){var n=t;n.status="fulfilled",n.value=e}},function(e){if("pending"===t.status){var n=t;n.status="rejected",n.reason=e}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw ra(e=t.reason),e}throw na=t,Yr}}function ta(e){try{return(0,e._init)(e._payload)}catch(e){if(null!==e&&"object"==typeof e&&"function"==typeof e.then)throw na=e,Yr;throw e}}var na=null;function ia(){if(null===na)throw Error(i(459));var e=na;return na=null,e}function ra(e){if(e===Yr||e===Zr)throw Error(i(483))}var aa=null,sa=0;function oa(e){var t=sa;return sa+=1,null===aa&&(aa=[]),ea(aa,e,t)}function la(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function ca(e,t){if(t.$$typeof===h)throw Error(i(525));throw e=Object.prototype.toString.call(t),Error(i(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function ua(e){function t(t,n){if(e){var i=t.deletions;null===i?(t.deletions=[n],t.flags|=16):i.push(n)}}function n(n,i){if(!e)return null;for(;null!==i;)t(n,i),i=i.sibling;return null}function r(e){for(var t=new Map;null!==e;)null!==e.key?t.set(e.key,e):t.set(e.index,e),e=e.sibling;return t}function a(e,t){return(e=Fi(e,t)).index=0,e.sibling=null,e}function s(t,n,i){return t.index=i,e?null!==(i=t.alternate)?(i=i.index)<n?(t.flags|=67108866,n):i:(t.flags|=67108866,n):(t.flags|=1048576,n)}function o(t){return e&&null===t.alternate&&(t.flags|=67108866),t}function l(e,t,n,i){return null===t||6!==t.tag?((t=Hi(n,e.mode,i)).return=e,t):((t=a(t,n)).return=e,t)}function c(e,t,n,i){var r=n.type;return r===m?d(e,t,n.props.children,i,n.key):null!==t&&(t.elementType===r||"object"==typeof r&&null!==r&&r.$$typeof===M&&ta(r)===t.type)?(la(t=a(t,n.props),n),t.return=e,t):(la(t=Bi(n.type,n.key,n.props,null,e.mode,i),n),t.return=e,t)}function u(e,t,n,i){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=ji(n,e.mode,i)).return=e,t):((t=a(t,n.children||[])).return=e,t)}function d(e,t,n,i,r){return null===t||7!==t.tag?((t=Vi(n,e.mode,i,r)).return=e,t):((t=a(t,n)).return=e,t)}function h(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t||"bigint"==typeof t)return(t=Hi(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case f:return la(n=Bi(t.type,t.key,t.props,null,e.mode,n),t),n.return=e,n;case p:return(t=ji(t,e.mode,n)).return=e,t;case M:return h(e,t=ta(t),n)}if(L(t)||R(t))return(t=Vi(t,e.mode,n,null)).return=e,t;if("function"==typeof t.then)return h(e,oa(t),n);if(t.$$typeof===x)return h(e,Lr(e,t),n);ca(e,t)}return null}function g(e,t,n,i){var r=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n||"bigint"==typeof n)return null!==r?null:l(e,t,""+n,i);if("object"==typeof n&&null!==n){switch(n.$$typeof){case f:return n.key===r?c(e,t,n,i):null;case p:return n.key===r?u(e,t,n,i):null;case M:return g(e,t,n=ta(n),i)}if(L(n)||R(n))return null!==r?null:d(e,t,n,i,null);if("function"==typeof n.then)return g(e,t,oa(n),i);if(n.$$typeof===x)return g(e,t,Lr(e,n),i);ca(e,n)}return null}function v(e,t,n,i,r){if("string"==typeof i&&""!==i||"number"==typeof i||"bigint"==typeof i)return l(t,e=e.get(n)||null,""+i,r);if("object"==typeof i&&null!==i){switch(i.$$typeof){case f:return c(t,e=e.get(null===i.key?n:i.key)||null,i,r);case p:return u(t,e=e.get(null===i.key?n:i.key)||null,i,r);case M:return v(e,t,n,i=ta(i),r)}if(L(i)||R(i))return d(t,e=e.get(n)||null,i,r,null);if("function"==typeof i.then)return v(e,t,n,oa(i),r);if(i.$$typeof===x)return v(e,t,n,Lr(t,i),r);ca(t,i)}return null}function y(l,c,u,d){if("object"==typeof u&&null!==u&&u.type===m&&null===u.key&&(u=u.props.children),"object"==typeof u&&null!==u){switch(u.$$typeof){case f:e:{for(var _=u.key;null!==c;){if(c.key===_){if((_=u.type)===m){if(7===c.tag){n(l,c.sibling),(d=a(c,u.props.children)).return=l,l=d;break e}}else if(c.elementType===_||"object"==typeof _&&null!==_&&_.$$typeof===M&&ta(_)===c.type){n(l,c.sibling),la(d=a(c,u.props),u),d.return=l,l=d;break e}n(l,c);break}t(l,c),c=c.sibling}u.type===m?((d=Vi(u.props.children,l.mode,d,u.key)).return=l,l=d):(la(d=Bi(u.type,u.key,u.props,null,l.mode,d),u),d.return=l,l=d)}return o(l);case p:e:{for(_=u.key;null!==c;){if(c.key===_){if(4===c.tag&&c.stateNode.containerInfo===u.containerInfo&&c.stateNode.implementation===u.implementation){n(l,c.sibling),(d=a(c,u.children||[])).return=l,l=d;break e}n(l,c);break}t(l,c),c=c.sibling}(d=ji(u,l.mode,d)).return=l,l=d}return o(l);case M:return y(l,c,u=ta(u),d)}if(L(u))return function(i,a,o,l){for(var c=null,u=null,d=a,f=a=0,p=null;null!==d&&f<o.length;f++){d.index>f?(p=d,d=null):p=d.sibling;var m=g(i,d,o[f],l);if(null===m){null===d&&(d=p);break}e&&d&&null===m.alternate&&t(i,d),a=s(m,a,f),null===u?c=m:u.sibling=m,u=m,d=p}if(f===o.length)return n(i,d),cr&&nr(i,f),c;if(null===d){for(;f<o.length;f++)null!==(d=h(i,o[f],l))&&(a=s(d,a,f),null===u?c=d:u.sibling=d,u=d);return cr&&nr(i,f),c}for(d=r(d);f<o.length;f++)null!==(p=v(d,i,f,o[f],l))&&(e&&null!==p.alternate&&d.delete(null===p.key?f:p.key),a=s(p,a,f),null===u?c=p:u.sibling=p,u=p);return e&&d.forEach(function(e){return t(i,e)}),cr&&nr(i,f),c}(l,c,u,d);if(R(u)){if("function"!=typeof(_=R(u)))throw Error(i(150));return function(a,o,l,c){if(null==l)throw Error(i(151));for(var u=null,d=null,f=o,p=o=0,m=null,y=l.next();null!==f&&!y.done;p++,y=l.next()){f.index>p?(m=f,f=null):m=f.sibling;var x=g(a,f,y.value,c);if(null===x){null===f&&(f=m);break}e&&f&&null===x.alternate&&t(a,f),o=s(x,o,p),null===d?u=x:d.sibling=x,d=x,f=m}if(y.done)return n(a,f),cr&&nr(a,p),u;if(null===f){for(;!y.done;p++,y=l.next())null!==(y=h(a,y.value,c))&&(o=s(y,o,p),null===d?u=y:d.sibling=y,d=y);return cr&&nr(a,p),u}for(f=r(f);!y.done;p++,y=l.next())null!==(y=v(f,a,p,y.value,c))&&(e&&null!==y.alternate&&f.delete(null===y.key?p:y.key),o=s(y,o,p),null===d?u=y:d.sibling=y,d=y);return e&&f.forEach(function(e){return t(a,e)}),cr&&nr(a,p),u}(l,c,u=_.call(u),d)}if("function"==typeof u.then)return y(l,c,oa(u),d);if(u.$$typeof===x)return y(l,c,Lr(l,u),d);ca(l,u)}return"string"==typeof u&&""!==u||"number"==typeof u||"bigint"==typeof u?(u=""+u,null!==c&&6===c.tag?(n(l,c.sibling),(d=a(c,u)).return=l,l=d):(n(l,c),(d=Hi(u,l.mode,d)).return=l,l=d),o(l)):n(l,c)}return function(e,t,n,i){try{sa=0;var r=y(e,t,n,i);return aa=null,r}catch(t){if(t===Yr||t===Zr)throw t;var a=ki(29,t,null,e.mode);return a.lanes=i,a.return=e,a}}}var da=ua(!0),ha=ua(!1),fa=!1;function pa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ma(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ga(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function va(e,t,n){var i=e.updateQueue;if(null===i)return null;if(i=i.shared,2&dc){var r=i.pending;return null===r?t.next=t:(t.next=r.next,r.next=t),i.pending=t,t=Di(e),Ii(e,null,n),t}return Ci(e,i,t,n),Di(e)}function ya(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&n)){var i=t.lanes;n|=i&=e.pendingLanes,t.lanes=n,Ie(e,n)}}function xa(e,t){var n=e.updateQueue,i=e.alternate;if(null!==i&&n===(i=i.updateQueue)){var r=null,a=null;if(null!==(n=n.firstBaseUpdate)){do{var s={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};null===a?r=a=s:a=a.next=s,n=n.next}while(null!==n);null===a?r=a=t:a=a.next=t}else r=a=t;return n={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:a,shared:i.shared,callbacks:i.callbacks},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var _a=!1;function ba(){if(_a&&null!==Hr)throw Hr}function wa(e,t,n,i){_a=!1;var r=e.updateQueue;fa=!1;var a=r.firstBaseUpdate,s=r.lastBaseUpdate,o=r.shared.pending;if(null!==o){r.shared.pending=null;var l=o,c=l.next;l.next=null,null===s?a=c:s.next=c,s=l;var u=e.alternate;null!==u&&(o=(u=u.updateQueue).lastBaseUpdate)!==s&&(null===o?u.firstBaseUpdate=c:o.next=c,u.lastBaseUpdate=l)}if(null!==a){var h=r.baseState;for(s=0,u=c=l=null,o=a;;){var f=-536870913&o.lane,p=f!==o.lane;if(p?(pc&f)===f:(i&f)===f){0!==f&&f===Vr&&(_a=!0),null!==u&&(u=u.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});e:{var m=e,g=o;f=t;var v=n;switch(g.tag){case 1:if("function"==typeof(m=g.payload)){h=m.call(v,h,f);break e}h=m;break e;case 3:m.flags=-65537&m.flags|128;case 0:if(null==(f="function"==typeof(m=g.payload)?m.call(v,h,f):m))break e;h=d({},h,f);break e;case 2:fa=!0}}null!==(f=o.callback)&&(e.flags|=64,p&&(e.flags|=8192),null===(p=r.callbacks)?r.callbacks=[f]:p.push(f))}else p={lane:f,tag:o.tag,payload:o.payload,callback:o.callback,next:null},null===u?(c=u=p,l=h):u=u.next=p,s|=f;if(null===(o=o.next)){if(null===(o=r.shared.pending))break;o=(p=o).next,p.next=null,r.lastBaseUpdate=p,r.shared.pending=null}}null===u&&(l=h),r.baseState=l,r.firstBaseUpdate=c,r.lastBaseUpdate=u,null===a&&(r.shared.lanes=0),wc|=s,e.lanes=s,e.memoizedState=h}}function Sa(e,t){if("function"!=typeof e)throw Error(i(191,e));e.call(t)}function Ma(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;e<n.length;e++)Sa(n[e],t)}var Ea=U(null),Ta=U(0);function Aa(e,t){z(Ta,e=_c),z(Ea,t),_c=e|t.baseLanes}function Ra(){z(Ta,_c),z(Ea,Ea.current)}function Ca(){_c=Ta.current,F(Ea),F(Ta)}var Pa=U(null),La=null;function Ia(e){var t=e.alternate;z(Ua,1&Ua.current),z(Pa,e),null===La&&(null===t||null!==Ea.current||null!==t.memoizedState)&&(La=e)}function Da(e){z(Ua,Ua.current),z(Pa,e),null===La&&(La=e)}function Na(e){22===e.tag?(z(Ua,Ua.current),z(Pa,e),null===La&&(La=e)):Oa()}function Oa(){z(Ua,Ua.current),z(Pa,Pa.current)}function ka(e){F(Pa),La===e&&(La=null),F(Ua)}var Ua=U(0);function Fa(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||Cd(n)||Pd(n)))return t}else if(19!==t.tag||"forwards"!==t.memoizedProps.revealOrder&&"backwards"!==t.memoizedProps.revealOrder&&"unstable_legacy-backwards"!==t.memoizedProps.revealOrder&&"together"!==t.memoizedProps.revealOrder){if(null!==t.child){t.child.return=t,t=t.child;continue}}else if(128&t.flags)return t;if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var za=0,Ba=null,Va=null,Ha=null,Ga=!1,ja=!1,Wa=!1,Xa=0,qa=0,$a=null,Ya=0;function Ka(){throw Error(i(321))}function Za(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Kn(e[n],t[n]))return!1;return!0}function Qa(e,t,n,i,r,a){return za=a,Ba=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,I.H=null===e||null===e.memoizedState?po:mo,Wa=!1,a=n(i,r),Wa=!1,ja&&(a=es(t,n,i,r)),Ja(e),a}function Ja(e){I.H=fo;var t=null!==Va&&null!==Va.next;if(za=0,Ha=Va=Ba=null,Ga=!1,qa=0,$a=null,t)throw Error(i(300));null===e||Lo||null!==(e=e.dependencies)&&Rr(e)&&(Lo=!0)}function es(e,t,n,r){Ba=e;var a=0;do{if(ja&&($a=null),qa=0,ja=!1,25<=a)throw Error(i(301));if(a+=1,Ha=Va=null,null!=e.updateQueue){var s=e.updateQueue;s.lastEffect=null,s.events=null,s.stores=null,null!=s.memoCache&&(s.memoCache.index=0)}I.H=go,s=t(n,r)}while(ja);return s}function ts(){var e=I.H,t=e.useState()[0];return t="function"==typeof t.then?os(t):t,e=e.useState()[0],(null!==Va?Va.memoizedState:null)!==e&&(Ba.flags|=1024),t}function ns(){var e=0!==Xa;return Xa=0,e}function is(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function rs(e){if(Ga){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}Ga=!1}za=0,Ha=Va=Ba=null,ja=!1,qa=Xa=0,$a=null}function as(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Ha?Ba.memoizedState=Ha=e:Ha=Ha.next=e,Ha}function ss(){if(null===Va){var e=Ba.alternate;e=null!==e?e.memoizedState:null}else e=Va.next;var t=null===Ha?Ba.memoizedState:Ha.next;if(null!==t)Ha=t,Va=e;else{if(null===e){if(null===Ba.alternate)throw Error(i(467));throw Error(i(310))}e={memoizedState:(Va=e).memoizedState,baseState:Va.baseState,baseQueue:Va.baseQueue,queue:Va.queue,next:null},null===Ha?Ba.memoizedState=Ha=e:Ha=Ha.next=e}return Ha}function os(e){var t=qa;return qa+=1,null===$a&&($a=[]),e=ea($a,e,t),t=Ba,null===(null===Ha?t.memoizedState:Ha.next)&&(t=t.alternate,I.H=null===t||null===t.memoizedState?po:mo),e}function ls(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return os(e);if(e.$$typeof===x)return Pr(e)}throw Error(i(438,String(e)))}function cs(e){var t=null,n=Ba.updateQueue;if(null!==n&&(t=n.memoCache),null==t){var i=Ba.alternate;null!==i&&null!==(i=i.updateQueue)&&null!=(i=i.memoCache)&&(t={data:i.data.map(function(e){return e.slice()}),index:0})}if(null==t&&(t={data:[],index:0}),null===n&&(n={lastEffect:null,events:null,stores:null,memoCache:null},Ba.updateQueue=n),n.memoCache=t,void 0===(n=t.data[t.index]))for(n=t.data[t.index]=Array(e),i=0;i<e;i++)n[i]=T;return t.index++,n}function us(e,t){return"function"==typeof t?t(e):t}function ds(e){return hs(ss(),Va,e)}function hs(e,t,n){var r=e.queue;if(null===r)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,s=r.pending;if(null!==s){if(null!==a){var o=a.next;a.next=s.next,s.next=o}t.baseQueue=a=s,r.pending=null}if(s=e.baseState,null===a)e.memoizedState=s;else{var l=o=null,c=null,u=t=a.next,d=!1;do{var h=-536870913&u.lane;if(h!==u.lane?(pc&h)===h:(za&h)===h){var f=u.revertLane;if(0===f)null!==c&&(c=c.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),h===Vr&&(d=!0);else{if((za&f)===f){u=u.next,f===Vr&&(d=!0);continue}h={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=h,o=s):c=c.next=h,Ba.lanes|=f,wc|=f}h=u.action,Wa&&n(s,h),s=u.hasEagerState?u.eagerState:n(s,h)}else f={lane:h,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=f,o=s):c=c.next=f,Ba.lanes|=h,wc|=h;u=u.next}while(null!==u&&u!==t);if(null===c?o=s:c.next=l,!Kn(s,e.memoizedState)&&(Lo=!0,d&&null!==(n=Hr)))throw n;e.memoizedState=s,e.baseState=o,e.baseQueue=c,r.lastRenderedState=s}return null===a&&(r.lanes=0),[e.memoizedState,r.dispatch]}function fs(e){var t=ss(),n=t.queue;if(null===n)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,s=t.memoizedState;if(null!==a){n.pending=null;var o=a=a.next;do{s=e(s,o.action),o=o.next}while(o!==a);Kn(s,t.memoizedState)||(Lo=!0),t.memoizedState=s,null===t.baseQueue&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function ps(e,t,n){var r=Ba,a=ss(),s=cr;if(s){if(void 0===n)throw Error(i(407));n=n()}else n=t();var o=!Kn((Va||a).memoizedState,n);if(o&&(a.memoizedState=n,Lo=!0),a=a.queue,zs(vs.bind(null,r,a,e),[e]),a.getSnapshot!==t||o||null!==Ha&&1&Ha.memoizedState.tag){if(r.flags|=2048,Ns(9,{destroy:void 0},gs.bind(null,r,a,n,t),null),null===hc)throw Error(i(349));s||127&za||ms(r,t,n)}return n}function ms(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=Ba.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},Ba.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function gs(e,t,n,i){t.value=n,t.getSnapshot=i,ys(t)&&xs(e)}function vs(e,t,n){return n(function(){ys(t)&&xs(e)})}function ys(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Kn(e,n)}catch(e){return!0}}function xs(e){var t=Li(e,2);null!==t&&Xc(t,e,2)}function _s(e){var t=as();if("function"==typeof e){var n=e;if(e=n(),Wa){ve(!0);try{n()}finally{ve(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:e},t}function bs(e,t,n,i){return e.baseState=n,hs(e,Va,"function"==typeof i?i:us)}function ws(e,t,n,r,a){if(co(e))throw Error(i(485));if(null!==(e=t.action)){var s={payload:a,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(e){s.listeners.push(e)}};null!==I.T?n(!0):s.isTransition=!1,r(s),null===(n=t.pending)?(s.next=t.pending=s,Ss(t,s)):(s.next=n.next,t.pending=n.next=s)}}function Ss(e,t){var n=t.action,i=t.payload,r=e.state;if(t.isTransition){var a=I.T,s={};I.T=s;try{var o=n(r,i),l=I.S;null!==l&&l(s,o),Ms(e,t,o)}catch(n){Ts(e,t,n)}finally{null!==a&&null!==s.types&&(a.types=s.types),I.T=a}}else try{Ms(e,t,a=n(r,i))}catch(n){Ts(e,t,n)}}function Ms(e,t,n){null!==n&&"object"==typeof n&&"function"==typeof n.then?n.then(function(n){Es(e,t,n)},function(n){return Ts(e,t,n)}):Es(e,t,n)}function Es(e,t,n){t.status="fulfilled",t.value=n,As(t),e.state=n,null!==(t=e.pending)&&((n=t.next)===t?e.pending=null:(n=n.next,t.next=n,Ss(e,n)))}function Ts(e,t,n){var i=e.pending;if(e.pending=null,null!==i){i=i.next;do{t.status="rejected",t.reason=n,As(t),t=t.next}while(t!==i)}e.action=null}function As(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Rs(e,t){return t}function Cs(e,t){if(cr){var n=hc.formState;if(null!==n){e:{var i=Ba;if(cr){if(lr){t:{for(var r=lr,a=dr;8!==r.nodeType;){if(!a){r=null;break t}if(null===(r=Ld(r.nextSibling))){r=null;break t}}r="F!"===(a=r.data)||"F"===a?r:null}if(r){lr=Ld(r.nextSibling),i="F!"===r.data;break e}}fr(i)}i=!1}i&&(t=n[0])}}return(n=as()).memoizedState=n.baseState=t,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rs,lastRenderedState:t},n.queue=i,n=so.bind(null,Ba,i),i.dispatch=n,i=_s(!1),a=lo.bind(null,Ba,!1,i.queue),r={state:t,dispatch:null,action:e,pending:null},(i=as()).queue=r,n=ws.bind(null,Ba,r,a,n),r.dispatch=n,i.memoizedState=e,[t,n,!1]}function Ps(e){return Ls(ss(),Va,e)}function Ls(e,t,n){if(t=hs(e,t,Rs)[0],e=ds(us)[0],"object"==typeof t&&null!==t&&"function"==typeof t.then)try{var i=os(t)}catch(e){if(e===Yr)throw Zr;throw e}else i=t;var r=(t=ss()).queue,a=r.dispatch;return n!==t.memoizedState&&(Ba.flags|=2048,Ns(9,{destroy:void 0},Is.bind(null,r,n),null)),[i,a,e]}function Is(e,t){e.action=t}function Ds(e){var t=ss(),n=Va;if(null!==n)return Ls(t,n,e);ss(),t=t.memoizedState;var i=(n=ss()).queue.dispatch;return n.memoizedState=e,[t,i,!1]}function Ns(e,t,n,i){return e={tag:e,create:n,deps:i,inst:t,next:null},null===(t=Ba.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},Ba.updateQueue=t),null===(n=t.lastEffect)?t.lastEffect=e.next=e:(i=n.next,n.next=e,e.next=i,t.lastEffect=e),e}function Os(){return ss().memoizedState}function ks(e,t,n,i){var r=as();Ba.flags|=e,r.memoizedState=Ns(1|t,{destroy:void 0},n,void 0===i?null:i)}function Us(e,t,n,i){var r=ss();i=void 0===i?null:i;var a=r.memoizedState.inst;null!==Va&&null!==i&&Za(i,Va.memoizedState.deps)?r.memoizedState=Ns(t,a,n,i):(Ba.flags|=e,r.memoizedState=Ns(1|t,a,n,i))}function Fs(e,t){ks(8390656,8,e,t)}function zs(e,t){Us(2048,8,e,t)}function Bs(e){var t=ss().memoizedState;return function(e){Ba.flags|=4;var t=Ba.updateQueue;if(null===t)t={lastEffect:null,events:null,stores:null,memoCache:null},Ba.updateQueue=t,t.events=[e];else{var n=t.events;null===n?t.events=[e]:n.push(e)}}({ref:t,nextImpl:e}),function(){if(2&dc)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Vs(e,t){return Us(4,2,e,t)}function Hs(e,t){return Us(4,4,e,t)}function Gs(e,t){if("function"==typeof t){e=e();var n=t(e);return function(){"function"==typeof n?n():t(null)}}if(null!=t)return e=e(),t.current=e,function(){t.current=null}}function js(e,t,n){n=null!=n?n.concat([e]):null,Us(4,4,Gs.bind(null,t,e),n)}function Ws(){}function Xs(e,t){var n=ss();t=void 0===t?null:t;var i=n.memoizedState;return null!==t&&Za(t,i[1])?i[0]:(n.memoizedState=[e,t],e)}function qs(e,t){var n=ss();t=void 0===t?null:t;var i=n.memoizedState;if(null!==t&&Za(t,i[1]))return i[0];if(i=e(),Wa){ve(!0);try{e()}finally{ve(!1)}}return n.memoizedState=[i,t],i}function $s(e,t,n){return void 0===n||1073741824&za&&!(261930&pc)?e.memoizedState=t:(e.memoizedState=n,e=Wc(),Ba.lanes|=e,wc|=e,n)}function Ys(e,t,n,i){return Kn(n,t)?n:null!==Ea.current?(e=$s(e,n,i),Kn(e,t)||(Lo=!0),e):42&za&&(!(1073741824&za)||261930&pc)?(e=Wc(),Ba.lanes|=e,wc|=e,t):(Lo=!0,e.memoizedState=n)}function Ks(e,t,n,i,r){var a=D.p;D.p=0!==a&&8>a?a:8;var s,o,l,c=I.T,u={};I.T=u,lo(e,!1,t,n);try{var d=r(),h=I.S;if(null!==h&&h(u,d),null!==d&&"object"==typeof d&&"function"==typeof d.then){var f=(s=i,o=[],l={status:"pending",value:null,reason:null,then:function(e){o.push(e)}},d.then(function(){l.status="fulfilled",l.value=s;for(var e=0;e<o.length;e++)(0,o[e])(s)},function(e){for(l.status="rejected",l.reason=e,e=0;e<o.length;e++)(0,o[e])(void 0)}),l);oo(e,t,f,jc())}else oo(e,t,i,jc())}catch(n){oo(e,t,{then:function(){},status:"rejected",reason:n},jc())}finally{D.p=a,null!==c&&null!==u.types&&(c.types=u.types),I.T=c}}function Zs(){}function Qs(e,t,n,r){if(5!==e.tag)throw Error(i(476));var a=Js(e).queue;Ks(e,a,t,N,null===n?Zs:function(){return eo(e),n(r)})}function Js(e){var t=e.memoizedState;if(null!==t)return t;var n={};return(t={memoizedState:N,baseState:N,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:N},next:null}).next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:n},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function eo(e){var t=Js(e);null===t.next&&(t=e.alternate.memoizedState),oo(e,t.next.queue,{},jc())}function to(){return Pr(lh)}function no(){return ss().memoizedState}function io(){return ss().memoizedState}function ro(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var n=jc(),i=va(t,e=ga(n),n);return null!==i&&(Xc(i,t,n),ya(i,t,n)),t={cache:Ur()},void(e.payload=t)}t=t.return}}function ao(e,t,n){var i=jc();n={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},co(e)?uo(t,n):null!==(n=Pi(e,t,n,i))&&(Xc(n,e,i),ho(n,t,i))}function so(e,t,n){oo(e,t,n,jc())}function oo(e,t,n,i){var r={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(co(e))uo(t,r);else{var a=e.alternate;if(0===e.lanes&&(null===a||0===a.lanes)&&null!==(a=t.lastRenderedReducer))try{var s=t.lastRenderedState,o=a(s,n);if(r.hasEagerState=!0,r.eagerState=o,Kn(o,s))return Ci(e,t,r,0),null===hc&&Ri(),!1}catch(e){}if(null!==(n=Pi(e,t,r,i)))return Xc(n,e,i),ho(n,t,i),!0}return!1}function lo(e,t,n,r){if(r={lane:2,revertLane:Bu(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},co(e)){if(t)throw Error(i(479))}else null!==(t=Pi(e,n,r,2))&&Xc(t,e,2)}function co(e){var t=e.alternate;return e===Ba||null!==t&&t===Ba}function uo(e,t){ja=Ga=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ho(e,t,n){if(4194048&n){var i=t.lanes;n|=i&=e.pendingLanes,t.lanes=n,Ie(e,n)}}var fo={readContext:Pr,use:ls,useCallback:Ka,useContext:Ka,useEffect:Ka,useImperativeHandle:Ka,useLayoutEffect:Ka,useInsertionEffect:Ka,useMemo:Ka,useReducer:Ka,useRef:Ka,useState:Ka,useDebugValue:Ka,useDeferredValue:Ka,useTransition:Ka,useSyncExternalStore:Ka,useId:Ka,useHostTransitionStatus:Ka,useFormState:Ka,useActionState:Ka,useOptimistic:Ka,useMemoCache:Ka,useCacheRefresh:Ka};fo.useEffectEvent=Ka;var po={readContext:Pr,use:ls,useCallback:function(e,t){return as().memoizedState=[e,void 0===t?null:t],e},useContext:Pr,useEffect:Fs,useImperativeHandle:function(e,t,n){n=null!=n?n.concat([e]):null,ks(4194308,4,Gs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ks(4194308,4,e,t)},useInsertionEffect:function(e,t){ks(4,2,e,t)},useMemo:function(e,t){var n=as();t=void 0===t?null:t;var i=e();if(Wa){ve(!0);try{e()}finally{ve(!1)}}return n.memoizedState=[i,t],i},useReducer:function(e,t,n){var i=as();if(void 0!==n){var r=n(t);if(Wa){ve(!0);try{n(t)}finally{ve(!1)}}}else r=t;return i.memoizedState=i.baseState=r,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},i.queue=e,e=e.dispatch=ao.bind(null,Ba,e),[i.memoizedState,e]},useRef:function(e){return e={current:e},as().memoizedState=e},useState:function(e){var t=(e=_s(e)).queue,n=so.bind(null,Ba,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Ws,useDeferredValue:function(e,t){return $s(as(),e,t)},useTransition:function(){var e=_s(!1);return e=Ks.bind(null,Ba,e.queue,!0,!1),as().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Ba,a=as();if(cr){if(void 0===n)throw Error(i(407));n=n()}else{if(n=t(),null===hc)throw Error(i(349));127&pc||ms(r,t,n)}a.memoizedState=n;var s={value:n,getSnapshot:t};return a.queue=s,Fs(vs.bind(null,r,s,e),[e]),r.flags|=2048,Ns(9,{destroy:void 0},gs.bind(null,r,s,n,t),null),n},useId:function(){var e=as(),t=hc.identifierPrefix;if(cr){var n=tr;t="_"+t+"R_"+(n=(er&~(1<<32-ye(er)-1)).toString(32)+n),0<(n=Xa++)&&(t+="H"+n.toString(32)),t+="_"}else t="_"+t+"r_"+(n=Ya++).toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:to,useFormState:Cs,useActionState:Cs,useOptimistic:function(e){var t=as();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=lo.bind(null,Ba,!0,n),n.dispatch=t,[e,t]},useMemoCache:cs,useCacheRefresh:function(){return as().memoizedState=ro.bind(null,Ba)},useEffectEvent:function(e){var t=as(),n={impl:e};return t.memoizedState=n,function(){if(2&dc)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},mo={readContext:Pr,use:ls,useCallback:Xs,useContext:Pr,useEffect:zs,useImperativeHandle:js,useInsertionEffect:Vs,useLayoutEffect:Hs,useMemo:qs,useReducer:ds,useRef:Os,useState:function(){return ds(us)},useDebugValue:Ws,useDeferredValue:function(e,t){return Ys(ss(),Va.memoizedState,e,t)},useTransition:function(){var e=ds(us)[0],t=ss().memoizedState;return["boolean"==typeof e?e:os(e),t]},useSyncExternalStore:ps,useId:no,useHostTransitionStatus:to,useFormState:Ps,useActionState:Ps,useOptimistic:function(e,t){return bs(ss(),0,e,t)},useMemoCache:cs,useCacheRefresh:io};mo.useEffectEvent=Bs;var go={readContext:Pr,use:ls,useCallback:Xs,useContext:Pr,useEffect:zs,useImperativeHandle:js,useInsertionEffect:Vs,useLayoutEffect:Hs,useMemo:qs,useReducer:fs,useRef:Os,useState:function(){return fs(us)},useDebugValue:Ws,useDeferredValue:function(e,t){var n=ss();return null===Va?$s(n,e,t):Ys(n,Va.memoizedState,e,t)},useTransition:function(){var e=fs(us)[0],t=ss().memoizedState;return["boolean"==typeof e?e:os(e),t]},useSyncExternalStore:ps,useId:no,useHostTransitionStatus:to,useFormState:Ds,useActionState:Ds,useOptimistic:function(e,t){var n=ss();return null!==Va?bs(n,0,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:cs,useCacheRefresh:io};function vo(e,t,n,i){n=null==(n=n(i,t=e.memoizedState))?t:d({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}go.useEffectEvent=Bs;var yo={enqueueSetState:function(e,t,n){e=e._reactInternals;var i=jc(),r=ga(i);r.payload=t,null!=n&&(r.callback=n),null!==(t=va(e,r,i))&&(Xc(t,e,i),ya(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var i=jc(),r=ga(i);r.tag=1,r.payload=t,null!=n&&(r.callback=n),null!==(t=va(e,r,i))&&(Xc(t,e,i),ya(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=jc(),i=ga(n);i.tag=2,null!=t&&(i.callback=t),null!==(t=va(e,i,n))&&(Xc(t,e,n),ya(t,e,n))}};function xo(e,t,n,i,r,a,s){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(i,a,s):!(t.prototype&&t.prototype.isPureReactComponent&&Zn(n,i)&&Zn(r,a))}function _o(e,t,n,i){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,i),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,i),t.state!==e&&yo.enqueueReplaceState(t,t.state,null)}function bo(e,t){var n=t;if("ref"in t)for(var i in n={},t)"ref"!==i&&(n[i]=t[i]);if(e=e.defaultProps)for(var r in n===t&&(n=d({},n)),e)void 0===n[r]&&(n[r]=e[r]);return n}function wo(e){Mi(e)}function So(e){console.error(e)}function Mo(e){Mi(e)}function Eo(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function To(e,t,n){try{(0,e.onCaughtError)(n.value,{componentStack:n.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ao(e,t,n){return(n=ga(n)).tag=3,n.payload={element:null},n.callback=function(){Eo(e,t)},n}function Ro(e){return(e=ga(e)).tag=3,e}function Co(e,t,n,i){var r=n.type.getDerivedStateFromError;if("function"==typeof r){var a=i.value;e.payload=function(){return r(a)},e.callback=function(){To(t,n,i)}}var s=n.stateNode;null!==s&&"function"==typeof s.componentDidCatch&&(e.callback=function(){To(t,n,i),"function"!=typeof r&&(null===Nc?Nc=new Set([this]):Nc.add(this));var e=i.stack;this.componentDidCatch(i.value,{componentStack:null!==e?e:""})})}var Po=Error(i(461)),Lo=!1;function Io(e,t,n,i){t.child=null===e?ha(t,null,n,i):da(t,e.child,n,i)}function Do(e,t,n,i,r){n=n.render;var a=t.ref;if("ref"in i){var s={};for(var o in i)"ref"!==o&&(s[o]=i[o])}else s=i;return Cr(t),i=Qa(e,t,n,s,a,r),o=ns(),null===e||Lo?(cr&&o&&rr(t),t.flags|=1,Io(e,t,i,r),t.child):(is(e,t,r),nl(e,t,r))}function No(e,t,n,i,r){if(null===e){var a=n.type;return"function"!=typeof a||Ui(a)||void 0!==a.defaultProps||null!==n.compare?((e=Bi(n.type,null,i,t,t.mode,r)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=a,Oo(e,t,a,i,r))}if(a=e.child,!il(e,r)){var s=a.memoizedProps;if((n=null!==(n=n.compare)?n:Zn)(s,i)&&e.ref===t.ref)return nl(e,t,r)}return t.flags|=1,(e=Fi(a,i)).ref=t.ref,e.return=t,t.child=e}function Oo(e,t,n,i,r){if(null!==e){var a=e.memoizedProps;if(Zn(a,i)&&e.ref===t.ref){if(Lo=!1,t.pendingProps=i=a,!il(e,r))return t.lanes=e.lanes,nl(e,t,r);131072&e.flags&&(Lo=!0)}}return Ho(e,t,n,i,r)}function ko(e,t,n,i){var r=i.children,a=null!==e?e.memoizedState:null;if(null===e&&null===t.stateNode&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),"hidden"===i.mode){if(128&t.flags){if(a=null!==a?a.baseLanes|n:n,null!==e){for(i=t.child=e.child,r=0;null!==i;)r=r|i.lanes|i.childLanes,i=i.sibling;i=r&~a}else i=0,t.child=null;return Fo(e,t,a,n,i)}if(!(536870912&n))return i=t.lanes=536870912,Fo(e,t,null!==a?a.baseLanes|n:n,n,i);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&qr(0,null!==a?a.cachePool:null),null!==a?Aa(t,a):Ra(),Na(t)}else null!==a?(qr(0,a.cachePool),Aa(t,a),Oa(),t.memoizedState=null):(null!==e&&qr(0,null),Ra(),Oa());return Io(e,t,r,n),t.child}function Uo(e,t){return null!==e&&22===e.tag||null!==t.stateNode||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Fo(e,t,n,i,r){var a=Xr();return a=null===a?null:{parent:kr._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},null!==e&&qr(0,null),Ra(),Na(t),null!==e&&Ar(e,t,i,!0),t.childLanes=r,null}function zo(e,t){return(t=Zo({mode:t.mode,children:t.children},e.mode)).ref=e.ref,e.child=t,t.return=e,t}function Bo(e,t,n){return da(t,e.child,null,n),(e=zo(t,t.pendingProps)).flags|=2,ka(t),t.memoizedState=null,e}function Vo(e,t){var n=t.ref;if(null===n)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!=typeof n&&"object"!=typeof n)throw Error(i(284));null!==e&&e.ref===n||(t.flags|=4194816)}}function Ho(e,t,n,i,r){return Cr(t),n=Qa(e,t,n,i,void 0,r),i=ns(),null===e||Lo?(cr&&i&&rr(t),t.flags|=1,Io(e,t,n,r),t.child):(is(e,t,r),nl(e,t,r))}function Go(e,t,n,i,r,a){return Cr(t),t.updateQueue=null,n=es(t,i,n,r),Ja(e),i=ns(),null===e||Lo?(cr&&i&&rr(t),t.flags|=1,Io(e,t,n,a),t.child):(is(e,t,a),nl(e,t,a))}function jo(e,t,n,i,r){if(Cr(t),null===t.stateNode){var a=Ni,s=n.contextType;"object"==typeof s&&null!==s&&(a=Pr(s)),a=new n(i,a),t.memoizedState=null!==a.state&&void 0!==a.state?a.state:null,a.updater=yo,t.stateNode=a,a._reactInternals=t,(a=t.stateNode).props=i,a.state=t.memoizedState,a.refs={},pa(t),s=n.contextType,a.context="object"==typeof s&&null!==s?Pr(s):Ni,a.state=t.memoizedState,"function"==typeof(s=n.getDerivedStateFromProps)&&(vo(t,n,s,i),a.state=t.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof a.getSnapshotBeforeUpdate||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||(s=a.state,"function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount(),s!==a.state&&yo.enqueueReplaceState(a,a.state,null),wa(t,i,a,r),ba(),a.state=t.memoizedState),"function"==typeof a.componentDidMount&&(t.flags|=4194308),i=!0}else if(null===e){a=t.stateNode;var o=t.memoizedProps,l=bo(n,o);a.props=l;var c=a.context,u=n.contextType;s=Ni,"object"==typeof u&&null!==u&&(s=Pr(u));var d=n.getDerivedStateFromProps;u="function"==typeof d||"function"==typeof a.getSnapshotBeforeUpdate,o=t.pendingProps!==o,u||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(o||c!==s)&&_o(t,a,i,s),fa=!1;var h=t.memoizedState;a.state=h,wa(t,i,a,r),ba(),c=t.memoizedState,o||h!==c||fa?("function"==typeof d&&(vo(t,n,d,i),c=t.memoizedState),(l=fa||xo(t,n,l,i,h,c,s))?(u||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||("function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),"function"==typeof a.componentDidMount&&(t.flags|=4194308)):("function"==typeof a.componentDidMount&&(t.flags|=4194308),t.memoizedProps=i,t.memoizedState=c),a.props=i,a.state=c,a.context=s,i=l):("function"==typeof a.componentDidMount&&(t.flags|=4194308),i=!1)}else{a=t.stateNode,ma(e,t),u=bo(n,s=t.memoizedProps),a.props=u,d=t.pendingProps,h=a.context,c=n.contextType,l=Ni,"object"==typeof c&&null!==c&&(l=Pr(c)),(c="function"==typeof(o=n.getDerivedStateFromProps)||"function"==typeof a.getSnapshotBeforeUpdate)||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(s!==d||h!==l)&&_o(t,a,i,l),fa=!1,h=t.memoizedState,a.state=h,wa(t,i,a,r),ba();var f=t.memoizedState;s!==d||h!==f||fa||null!==e&&null!==e.dependencies&&Rr(e.dependencies)?("function"==typeof o&&(vo(t,n,o,i),f=t.memoizedState),(u=fa||xo(t,n,u,i,h,f,l)||null!==e&&null!==e.dependencies&&Rr(e.dependencies))?(c||"function"!=typeof a.UNSAFE_componentWillUpdate&&"function"!=typeof a.componentWillUpdate||("function"==typeof a.componentWillUpdate&&a.componentWillUpdate(i,f,l),"function"==typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(i,f,l)),"function"==typeof a.componentDidUpdate&&(t.flags|=4),"function"==typeof a.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof a.componentDidUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=i,t.memoizedState=f),a.props=i,a.state=f,a.context=l,i=u):("function"!=typeof a.componentDidUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),i=!1)}return a=i,Vo(e,t),i=!!(128&t.flags),a||i?(a=t.stateNode,n=i&&"function"!=typeof n.getDerivedStateFromError?null:a.render(),t.flags|=1,null!==e&&i?(t.child=da(t,e.child,null,r),t.child=da(t,null,n,r)):Io(e,t,n,r),t.memoizedState=a.state,e=t.child):e=nl(e,t,r),e}function Wo(e,t,n,i){return vr(),t.flags|=256,Io(e,t,n,i),t.child}var Xo={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function qo(e){return{baseLanes:e,cachePool:$r()}}function $o(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=Ec),e}function Yo(e,t,n){var r,a=t.pendingProps,s=!1,o=!!(128&t.flags);if((r=o)||(r=(null===e||null!==e.memoizedState)&&!!(2&Ua.current)),r&&(s=!0,t.flags&=-129),r=!!(32&t.flags),t.flags&=-33,null===e){if(cr){if(s?Ia(t):Oa(),(e=lr)?null!==(e=null!==(e=Rd(e,dr))&&"&"!==e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==Ji?{id:er,overflow:tr}:null,retryLane:536870912,hydrationErrors:null},(n=Gi(e)).return=t,t.child=n,or=t,lr=null):e=null,null===e)throw fr(t);return Pd(e)?t.lanes=32:t.lanes=536870912,null}var l=a.children;return a=a.fallback,s?(Oa(),l=Zo({mode:"hidden",children:l},s=t.mode),a=Vi(a,s,n,null),l.return=t,a.return=t,l.sibling=a,t.child=l,(a=t.child).memoizedState=qo(n),a.childLanes=$o(e,r,n),t.memoizedState=Xo,Uo(null,a)):(Ia(t),Ko(t,l))}var c=e.memoizedState;if(null!==c&&null!==(l=c.dehydrated)){if(o)256&t.flags?(Ia(t),t.flags&=-257,t=Qo(e,t,n)):null!==t.memoizedState?(Oa(),t.child=e.child,t.flags|=128,t=null):(Oa(),l=a.fallback,s=t.mode,a=Zo({mode:"visible",children:a.children},s),(l=Vi(l,s,n,null)).flags|=2,a.return=t,l.return=t,a.sibling=l,t.child=a,da(t,e.child,null,n),(a=t.child).memoizedState=qo(n),a.childLanes=$o(e,r,n),t.memoizedState=Xo,t=Uo(null,a));else if(Ia(t),Pd(l)){if(r=l.nextSibling&&l.nextSibling.dataset)var u=r.dgst;r=u,(a=Error(i(419))).stack="",a.digest=r,xr({value:a,source:null,stack:null}),t=Qo(e,t,n)}else if(Lo||Ar(e,t,n,!1),r=0!==(n&e.childLanes),Lo||r){if(null!==(r=hc)&&0!==(a=De(r,n))&&a!==c.retryLane)throw c.retryLane=a,Li(e,a),Xc(r,e,a),Po;Cd(l)||ru(),t=Qo(e,t,n)}else Cd(l)?(t.flags|=192,t.child=e.child,t=null):(e=c.treeContext,lr=Ld(l.nextSibling),or=t,cr=!0,ur=null,dr=!1,null!==e&&sr(t,e),(t=Ko(t,a.children)).flags|=4096);return t}return s?(Oa(),l=a.fallback,s=t.mode,u=(c=e.child).sibling,(a=Fi(c,{mode:"hidden",children:a.children})).subtreeFlags=65011712&c.subtreeFlags,null!==u?l=Fi(u,l):(l=Vi(l,s,n,null)).flags|=2,l.return=t,a.return=t,a.sibling=l,t.child=a,Uo(null,a),a=t.child,null===(l=e.child.memoizedState)?l=qo(n):(null!==(s=l.cachePool)?(c=kr._currentValue,s=s.parent!==c?{parent:c,pool:c}:s):s=$r(),l={baseLanes:l.baseLanes|n,cachePool:s}),a.memoizedState=l,a.childLanes=$o(e,r,n),t.memoizedState=Xo,Uo(e.child,a)):(Ia(t),e=(n=e.child).sibling,(n=Fi(n,{mode:"visible",children:a.children})).return=t,n.sibling=null,null!==e&&(null===(r=t.deletions)?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=n,t.memoizedState=null,n)}function Ko(e,t){return(t=Zo({mode:"visible",children:t},e.mode)).return=e,e.child=t}function Zo(e,t){return(e=ki(22,e,null,t)).lanes=0,e}function Qo(e,t,n){return da(t,e.child,null,n),(e=Ko(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function Jo(e,t,n){e.lanes|=t;var i=e.alternate;null!==i&&(i.lanes|=t),Er(e.return,t,n)}function el(e,t,n,i,r,a){var s=e.memoizedState;null===s?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:i,tail:n,tailMode:r,treeForkCount:a}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=i,s.tail=n,s.tailMode=r,s.treeForkCount=a)}function tl(e,t,n){var i=t.pendingProps,r=i.revealOrder,a=i.tail;i=i.children;var s=Ua.current,o=!!(2&s);if(o?(s=1&s|2,t.flags|=128):s&=1,z(Ua,s),Io(e,t,i,n),i=cr?Ki:0,!o&&null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Jo(e,n,t);else if(19===e.tag)Jo(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(r){case"forwards":for(n=t.child,r=null;null!==n;)null!==(e=n.alternate)&&null===Fa(e)&&(r=n),n=n.sibling;null===(n=r)?(r=t.child,t.child=null):(r=n.sibling,n.sibling=null),el(t,!1,r,n,a,i);break;case"backwards":case"unstable_legacy-backwards":for(n=null,r=t.child,t.child=null;null!==r;){if(null!==(e=r.alternate)&&null===Fa(e)){t.child=r;break}e=r.sibling,r.sibling=n,n=r,r=e}el(t,!0,n,null,a,i);break;case"together":el(t,!1,null,null,void 0,i);break;default:t.memoizedState=null}return t.child}function nl(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),wc|=t.lanes,0===(n&t.childLanes)){if(null===e)return null;if(Ar(e,t,n,!1),0===(n&t.childLanes))return null}if(null!==e&&t.child!==e.child)throw Error(i(153));if(null!==t.child){for(n=Fi(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=Fi(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function il(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!Rr(e))}function rl(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)Lo=!0;else{if(!(il(e,n)||128&t.flags))return Lo=!1,function(e,t,n){switch(t.tag){case 3:X(t,t.stateNode.containerInfo),Sr(0,kr,e.memoizedState.cache),vr();break;case 27:case 5:$(t);break;case 4:X(t,t.stateNode.containerInfo);break;case 10:Sr(0,t.type,t.memoizedProps.value);break;case 31:if(null!==t.memoizedState)return t.flags|=128,Da(t),null;break;case 13:var i=t.memoizedState;if(null!==i)return null!==i.dehydrated?(Ia(t),t.flags|=128,null):0!==(n&t.child.childLanes)?Yo(e,t,n):(Ia(t),null!==(e=nl(e,t,n))?e.sibling:null);Ia(t);break;case 19:var r=!!(128&e.flags);if((i=0!==(n&t.childLanes))||(Ar(e,t,n,!1),i=0!==(n&t.childLanes)),r){if(i)return tl(e,t,n);t.flags|=128}if(null!==(r=t.memoizedState)&&(r.rendering=null,r.tail=null,r.lastEffect=null),z(Ua,Ua.current),i)break;return null;case 22:return t.lanes=0,ko(e,t,n,t.pendingProps);case 24:Sr(0,kr,e.memoizedState.cache)}return nl(e,t,n)}(e,t,n);Lo=!!(131072&e.flags)}else Lo=!1,cr&&1048576&t.flags&&ir(t,Ki,t.index);switch(t.lanes=0,t.tag){case 16:e:{var r=t.pendingProps;if(e=ta(t.elementType),t.type=e,"function"!=typeof e){if(null!=e){var a=e.$$typeof;if(a===_){t.tag=11,t=Do(null,t,e,r,n);break e}if(a===S){t.tag=14,t=No(null,t,e,r,n);break e}}throw t=P(e)||e,Error(i(306,t,""))}Ui(e)?(r=bo(e,r),t.tag=1,t=jo(null,t,e,r,n)):(t.tag=0,t=Ho(null,t,e,r,n))}return t;case 0:return Ho(e,t,t.type,t.pendingProps,n);case 1:return jo(e,t,r=t.type,a=bo(r,t.pendingProps),n);case 3:e:{if(X(t,t.stateNode.containerInfo),null===e)throw Error(i(387));r=t.pendingProps;var s=t.memoizedState;a=s.element,ma(e,t),wa(t,r,null,n);var o=t.memoizedState;if(r=o.cache,Sr(0,kr,r),r!==s.cache&&Tr(t,[kr],n,!0),ba(),r=o.element,s.isDehydrated){if(s={element:r,isDehydrated:!1,cache:o.cache},t.updateQueue.baseState=s,t.memoizedState=s,256&t.flags){t=Wo(e,t,r,n);break e}if(r!==a){xr(a=Xi(Error(i(424)),t)),t=Wo(e,t,r,n);break e}for(e=9===(e=t.stateNode.containerInfo).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,lr=Ld(e.firstChild),or=t,cr=!0,ur=null,dr=!0,n=ha(t,null,r,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(vr(),r===a){t=nl(e,t,n);break e}Io(e,t,r,n)}t=t.child}return t;case 26:return Vo(e,t),null===e?(n=Gd(t.type,null,t.pendingProps,null))?t.memoizedState=n:cr||(n=t.type,e=t.pendingProps,(r=pd(j.current).createElement(n))[ze]=t,r[Be]=e,ud(r,n,e),Qe(r),t.stateNode=r):t.memoizedState=Gd(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return $(t),null===e&&cr&&(r=t.stateNode=Od(t.type,t.pendingProps,j.current),or=t,dr=!0,a=lr,Md(t.type)?(Id=a,lr=Ld(r.firstChild)):lr=a),Io(e,t,t.pendingProps.children,n),Vo(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&cr&&((a=r=lr)&&(null!==(r=function(e,t,n,i){for(;1===e.nodeType;){var r=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!i&&("INPUT"!==e.nodeName||"hidden"!==e.type))break}else if(i){if(!e[Xe])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if("stylesheet"===(a=e.getAttribute("rel"))&&e.hasAttribute("data-precedence"))break;if(a!==r.rel||e.getAttribute("href")!==(null==r.href||""===r.href?null:r.href)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin)||e.getAttribute("title")!==(null==r.title?null:r.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(((a=e.getAttribute("src"))!==(null==r.src?null:r.src)||e.getAttribute("type")!==(null==r.type?null:r.type)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin))&&a&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else{if("input"!==t||"hidden"!==e.type)return e;var a=null==r.name?null:""+r.name;if("hidden"===r.type&&e.getAttribute("name")===a)return e}if(null===(e=Ld(e.nextSibling)))break}return null}(r,t.type,t.pendingProps,dr))?(t.stateNode=r,or=t,lr=Ld(r.firstChild),dr=!1,a=!0):a=!1),a||fr(t)),$(t),a=t.type,s=t.pendingProps,o=null!==e?e.memoizedProps:null,r=s.children,vd(a,s)?r=null:null!==o&&vd(a,o)&&(t.flags|=32),null!==t.memoizedState&&(a=Qa(e,t,ts,null,null,n),lh._currentValue=a),Vo(e,t),Io(e,t,r,n),t.child;case 6:return null===e&&cr&&((e=n=lr)&&(null!==(n=function(e,t,n){if(""===t)return null;for(;3!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!n)return null;if(null===(e=Ld(e.nextSibling)))return null}return e}(n,t.pendingProps,dr))?(t.stateNode=n,or=t,lr=null,e=!0):e=!1),e||fr(t)),null;case 13:return Yo(e,t,n);case 4:return X(t,t.stateNode.containerInfo),r=t.pendingProps,null===e?t.child=da(t,null,r,n):Io(e,t,r,n),t.child;case 11:return Do(e,t,t.type,t.pendingProps,n);case 7:return Io(e,t,t.pendingProps,n),t.child;case 8:case 12:return Io(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Sr(0,t.type,r.value),Io(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Cr(t),r=r(a=Pr(a)),t.flags|=1,Io(e,t,r,n),t.child;case 14:return No(e,t,t.type,t.pendingProps,n);case 15:return Oo(e,t,t.type,t.pendingProps,n);case 19:return tl(e,t,n);case 31:return function(e,t,n){var r=t.pendingProps,a=!!(128&t.flags);if(t.flags&=-129,null===e){if(cr){if("hidden"===r.mode)return e=zo(t,r),t.lanes=536870912,Uo(null,e);if(Da(t),(e=lr)?null!==(e=null!==(e=Rd(e,dr))&&"&"===e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==Ji?{id:er,overflow:tr}:null,retryLane:536870912,hydrationErrors:null},(n=Gi(e)).return=t,t.child=n,or=t,lr=null):e=null,null===e)throw fr(t);return t.lanes=536870912,null}return zo(t,r)}var s=e.memoizedState;if(null!==s){var o=s.dehydrated;if(Da(t),a)if(256&t.flags)t.flags&=-257,t=Bo(e,t,n);else{if(null===t.memoizedState)throw Error(i(558));t.child=e.child,t.flags|=128,t=null}else if(Lo||Ar(e,t,n,!1),a=0!==(n&e.childLanes),Lo||a){if(null!==(r=hc)&&0!==(o=De(r,n))&&o!==s.retryLane)throw s.retryLane=o,Li(e,o),Xc(r,e,o),Po;ru(),t=Bo(e,t,n)}else e=s.treeContext,lr=Ld(o.nextSibling),or=t,cr=!0,ur=null,dr=!1,null!==e&&sr(t,e),(t=zo(t,r)).flags|=4096;return t}return(e=Fi(e.child,{mode:r.mode,children:r.children})).ref=t.ref,t.child=e,e.return=t,e}(e,t,n);case 22:return ko(e,t,n,t.pendingProps);case 24:return Cr(t),r=Pr(kr),null===e?(null===(a=Xr())&&(a=hc,s=Ur(),a.pooledCache=s,s.refCount++,null!==s&&(a.pooledCacheLanes|=n),a=s),t.memoizedState={parent:r,cache:a},pa(t),Sr(0,kr,a)):(0!==(e.lanes&n)&&(ma(e,t),wa(t,null,null,n),ba()),a=e.memoizedState,s=t.memoizedState,a.parent!==r?(a={parent:r,cache:r},t.memoizedState=a,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=a),Sr(0,kr,r)):(r=s.cache,Sr(0,kr,r),r!==a.cache&&Tr(t,[kr],n,!0))),Io(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function al(e){e.flags|=4}function sl(e,t,n,i,r){if((t=!!(32&e.mode))&&(t=!1),t){if(e.flags|=16777216,(335544128&r)===r)if(e.stateNode.complete)e.flags|=8192;else{if(!tu())throw na=Qr,Kr;e.flags|=8192}}else e.flags&=-16777217}function ol(e,t){if("stylesheet"!==t.type||4&t.state.loading)e.flags&=-16777217;else if(e.flags|=16777216,!nh(t)){if(!tu())throw na=Qr,Kr;e.flags|=8192}}function ll(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?Re():536870912,e.lanes|=t,Tc|=t)}function cl(e,t){if(!cr)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var i=null;null!==n;)null!==n.alternate&&(i=n),n=n.sibling;null===i?t||null===e.tail?e.tail=null:e.tail.sibling=null:i.sibling=null}}function ul(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,i=0;if(t)for(var r=e.child;null!==r;)n|=r.lanes|r.childLanes,i|=65011712&r.subtreeFlags,i|=65011712&r.flags,r.return=e,r=r.sibling;else for(r=e.child;null!==r;)n|=r.lanes|r.childLanes,i|=r.subtreeFlags,i|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=i,e.childLanes=n,t}function dl(e,t,n){var r=t.pendingProps;switch(ar(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return ul(t),null;case 3:return n=t.stateNode,r=null,null!==e&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Mr(kr),q(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(gr(t)?al(t):null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,yr())),ul(t),null;case 26:var a=t.type,s=t.memoizedState;return null===e?(al(t),null!==s?(ul(t),ol(t,s)):(ul(t),sl(t,a,0,0,n))):s?s!==e.memoizedState?(al(t),ul(t),ol(t,s)):(ul(t),t.flags&=-16777217):((e=e.memoizedProps)!==r&&al(t),ul(t),sl(t,a,0,0,n)),null;case 27:if(Y(t),n=j.current,a=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==r&&al(t);else{if(!r){if(null===t.stateNode)throw Error(i(166));return ul(t),null}e=H.current,gr(t)?pr(t):(e=Od(a,r,n),t.stateNode=e,al(t))}return ul(t),null;case 5:if(Y(t),a=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==r&&al(t);else{if(!r){if(null===t.stateNode)throw Error(i(166));return ul(t),null}if(s=H.current,gr(t))pr(t);else{var o=pd(j.current);switch(s){case 1:s=o.createElementNS("http://www.w3.org/2000/svg",a);break;case 2:s=o.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;default:switch(a){case"svg":s=o.createElementNS("http://www.w3.org/2000/svg",a);break;case"math":s=o.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;case"script":(s=o.createElement("div")).innerHTML="<script><\/script>",s=s.removeChild(s.firstChild);break;case"select":s="string"==typeof r.is?o.createElement("select",{is:r.is}):o.createElement("select"),r.multiple?s.multiple=!0:r.size&&(s.size=r.size);break;default:s="string"==typeof r.is?o.createElement(a,{is:r.is}):o.createElement(a)}}s[ze]=t,s[Be]=r;e:for(o=t.child;null!==o;){if(5===o.tag||6===o.tag)s.appendChild(o.stateNode);else if(4!==o.tag&&27!==o.tag&&null!==o.child){o.child.return=o,o=o.child;continue}if(o===t)break e;for(;null===o.sibling;){if(null===o.return||o.return===t)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}t.stateNode=s;e:switch(ud(s,a,r),a){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}r&&al(t)}}return ul(t),sl(t,t.type,null===e||e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==r&&al(t);else{if("string"!=typeof r&&null===t.stateNode)throw Error(i(166));if(e=j.current,gr(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,null!==(a=or))switch(a.tag){case 27:case 5:r=a.memoizedProps}e[ze]=t,(e=!!(e.nodeValue===n||null!==r&&!0===r.suppressHydrationWarning||od(e.nodeValue,n)))||fr(t,!0)}else(e=pd(e).createTextNode(r))[ze]=t,t.stateNode=e}return ul(t),null;case 31:if(n=t.memoizedState,null===e||null!==e.memoizedState){if(r=gr(t),null!==n){if(null===e){if(!r)throw Error(i(318));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(i(557));e[ze]=t}else vr(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;ul(t),e=!1}else n=yr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return 256&t.flags?(ka(t),t):(ka(t),null);if(128&t.flags)throw Error(i(558))}return ul(t),null;case 13:if(r=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(a=gr(t),null!==r&&null!==r.dehydrated){if(null===e){if(!a)throw Error(i(318));if(!(a=null!==(a=t.memoizedState)?a.dehydrated:null))throw Error(i(317));a[ze]=t}else vr(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;ul(t),a=!1}else a=yr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return 256&t.flags?(ka(t),t):(ka(t),null)}return ka(t),128&t.flags?(t.lanes=n,t):(n=null!==r,e=null!==e&&null!==e.memoizedState,n&&(a=null,null!==(r=t.child).alternate&&null!==r.alternate.memoizedState&&null!==r.alternate.memoizedState.cachePool&&(a=r.alternate.memoizedState.cachePool.pool),s=null,null!==r.memoizedState&&null!==r.memoizedState.cachePool&&(s=r.memoizedState.cachePool.pool),s!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),ll(t,t.updateQueue),ul(t),null);case 4:return q(),null===e&&Zu(t.stateNode.containerInfo),ul(t),null;case 10:return Mr(t.type),ul(t),null;case 19:if(F(Ua),null===(r=t.memoizedState))return ul(t),null;if(a=!!(128&t.flags),null===(s=r.rendering))if(a)cl(r,!1);else{if(0!==bc||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(s=Fa(e))){for(t.flags|=128,cl(r,!1),e=s.updateQueue,t.updateQueue=e,ll(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)zi(n,e),n=n.sibling;return z(Ua,1&Ua.current|2),cr&&nr(t,r.treeForkCount),t.child}e=e.sibling}null!==r.tail&&se()>Ic&&(t.flags|=128,a=!0,cl(r,!1),t.lanes=4194304)}else{if(!a)if(null!==(e=Fa(s))){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,ll(t,e),cl(r,!0),null===r.tail&&"hidden"===r.tailMode&&!s.alternate&&!cr)return ul(t),null}else 2*se()-r.renderingStartTime>Ic&&536870912!==n&&(t.flags|=128,a=!0,cl(r,!1),t.lanes=4194304);r.isBackwards?(s.sibling=t.child,t.child=s):(null!==(e=r.last)?e.sibling=s:t.child=s,r.last=s)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=se(),e.sibling=null,n=Ua.current,z(Ua,a?1&n|2:1&n),cr&&nr(t,r.treeForkCount),e):(ul(t),null);case 22:case 23:return ka(t),Ca(),r=null!==t.memoizedState,null!==e?null!==e.memoizedState!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?!!(536870912&n)&&!(128&t.flags)&&(ul(t),6&t.subtreeFlags&&(t.flags|=8192)):ul(t),null!==(n=t.updateQueue)&&ll(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),r=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),null!==e&&F(Wr),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Mr(kr),ul(t),null;case 25:case 30:return null}throw Error(i(156,t.tag))}function hl(e,t){switch(ar(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Mr(kr),q(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return Y(t),null;case 31:if(null!==t.memoizedState){if(ka(t),null===t.alternate)throw Error(i(340));vr()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(ka(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(i(340));vr()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return F(Ua),null;case 4:return q(),null;case 10:return Mr(t.type),null;case 22:case 23:return ka(t),Ca(),null!==e&&F(Wr),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return Mr(kr),null;default:return null}}function fl(e,t){switch(ar(t),t.tag){case 3:Mr(kr),q();break;case 26:case 27:case 5:Y(t);break;case 4:q();break;case 31:null!==t.memoizedState&&ka(t);break;case 13:ka(t);break;case 19:F(Ua);break;case 10:Mr(t.type);break;case 22:case 23:ka(t),Ca(),null!==e&&F(Wr);break;case 24:Mr(kr)}}function pl(e,t){try{var n=t.updateQueue,i=null!==n?n.lastEffect:null;if(null!==i){var r=i.next;n=r;do{if((n.tag&e)===e){i=void 0;var a=n.create,s=n.inst;i=a(),s.destroy=i}n=n.next}while(n!==r)}}catch(e){bu(t,t.return,e)}}function ml(e,t,n){try{var i=t.updateQueue,r=null!==i?i.lastEffect:null;if(null!==r){var a=r.next;i=a;do{if((i.tag&e)===e){var s=i.inst,o=s.destroy;if(void 0!==o){s.destroy=void 0,r=t;var l=n,c=o;try{c()}catch(e){bu(r,l,e)}}}i=i.next}while(i!==a)}}catch(e){bu(t,t.return,e)}}function gl(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{Ma(t,n)}catch(t){bu(e,e.return,t)}}}function vl(e,t,n){n.props=bo(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){bu(e,t,n)}}function yl(e,t){try{var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;default:i=e.stateNode}"function"==typeof n?e.refCleanup=n(i):n.current=i}}catch(n){bu(e,t,n)}}function xl(e,t){var n=e.ref,i=e.refCleanup;if(null!==n)if("function"==typeof i)try{i()}catch(n){bu(e,t,n)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof n)try{n(null)}catch(n){bu(e,t,n)}else n.current=null}function _l(e){var t=e.type,n=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&i.focus();break e;case"img":n.src?i.src=n.src:n.srcSet&&(i.srcset=n.srcSet)}}catch(t){bu(e,e.return,t)}}function bl(e,t,n){try{var r=e.stateNode;!function(e,t,n,r){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var a=null,s=null,o=null,l=null,c=null,u=null,d=null;for(p in n){var h=n[p];if(n.hasOwnProperty(p)&&null!=h)switch(p){case"checked":case"value":break;case"defaultValue":c=h;default:r.hasOwnProperty(p)||ld(e,t,p,null,r,h)}}for(var f in r){var p=r[f];if(h=n[f],r.hasOwnProperty(f)&&(null!=p||null!=h))switch(f){case"type":s=p;break;case"name":a=p;break;case"checked":u=p;break;case"defaultChecked":d=p;break;case"value":o=p;break;case"defaultValue":l=p;break;case"children":case"dangerouslySetInnerHTML":if(null!=p)throw Error(i(137,t));break;default:p!==h&&ld(e,t,f,p,r,h)}}return void gt(e,o,l,c,u,d,s,a);case"select":for(s in p=o=l=f=null,n)if(c=n[s],n.hasOwnProperty(s)&&null!=c)switch(s){case"value":break;case"multiple":p=c;default:r.hasOwnProperty(s)||ld(e,t,s,null,r,c)}for(a in r)if(s=r[a],c=n[a],r.hasOwnProperty(a)&&(null!=s||null!=c))switch(a){case"value":f=s;break;case"defaultValue":l=s;break;case"multiple":o=s;default:s!==c&&ld(e,t,a,s,r,c)}return t=l,n=o,r=p,void(null!=f?xt(e,!!n,f,!1):!!r!=!!n&&(null!=t?xt(e,!!n,t,!0):xt(e,!!n,n?[]:"",!1)));case"textarea":for(l in p=f=null,n)if(a=n[l],n.hasOwnProperty(l)&&null!=a&&!r.hasOwnProperty(l))switch(l){case"value":case"children":break;default:ld(e,t,l,null,r,a)}for(o in r)if(a=r[o],s=n[o],r.hasOwnProperty(o)&&(null!=a||null!=s))switch(o){case"value":f=a;break;case"defaultValue":p=a;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=a)throw Error(i(91));break;default:a!==s&&ld(e,t,o,a,r,s)}return void _t(e,f,p);case"option":for(var m in n)f=n[m],n.hasOwnProperty(m)&&null!=f&&!r.hasOwnProperty(m)&&("selected"===m?e.selected=!1:ld(e,t,m,null,r,f));for(c in r)f=r[c],p=n[c],!r.hasOwnProperty(c)||f===p||null==f&&null==p||("selected"===c?e.selected=f&&"function"!=typeof f&&"symbol"!=typeof f:ld(e,t,c,f,r,p));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var g in n)f=n[g],n.hasOwnProperty(g)&&null!=f&&!r.hasOwnProperty(g)&&ld(e,t,g,null,r,f);for(u in r)if(f=r[u],p=n[u],r.hasOwnProperty(u)&&f!==p&&(null!=f||null!=p))switch(u){case"children":case"dangerouslySetInnerHTML":if(null!=f)throw Error(i(137,t));break;default:ld(e,t,u,f,r,p)}return;default:if(Tt(t)){for(var v in n)f=n[v],n.hasOwnProperty(v)&&void 0!==f&&!r.hasOwnProperty(v)&&cd(e,t,v,void 0,r,f);for(d in r)f=r[d],p=n[d],!r.hasOwnProperty(d)||f===p||void 0===f&&void 0===p||cd(e,t,d,f,r,p);return}}for(var y in n)f=n[y],n.hasOwnProperty(y)&&null!=f&&!r.hasOwnProperty(y)&&ld(e,t,y,null,r,f);for(h in r)f=r[h],p=n[h],!r.hasOwnProperty(h)||f===p||null==f&&null==p||ld(e,t,h,f,r,p)}(r,e.type,n,t),r[Be]=t}catch(t){bu(e,e.return,t)}}function wl(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&Md(e.type)||4===e.tag}function Sl(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||wl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(27===e.tag&&Md(e.type))continue e;if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function Ml(e,t,n){var i=e.tag;if(5===i||6===i)e=e.stateNode,t?(9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).insertBefore(e,t):((t=9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=Pt));else if(4!==i&&(27===i&&Md(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(Ml(e,t,n),e=e.sibling;null!==e;)Ml(e,t,n),e=e.sibling}function El(e,t,n){var i=e.tag;if(5===i||6===i)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==i&&(27===i&&Md(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(El(e,t,n),e=e.sibling;null!==e;)El(e,t,n),e=e.sibling}function Tl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var i=e.type,r=t.attributes;r.length;)t.removeAttributeNode(r[0]);ud(t,i,n),t[ze]=e,t[Be]=n}catch(t){bu(e,e.return,t)}}var Al=!1,Rl=!1,Cl=!1,Pl="function"==typeof WeakSet?WeakSet:Set,Ll=null;function Il(e,t,n){var i=n.flags;switch(n.tag){case 0:case 11:case 15:Xl(e,n),4&i&&pl(5,n);break;case 1:if(Xl(e,n),4&i)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(e){bu(n,n.return,e)}else{var r=bo(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(r,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){bu(n,n.return,e)}}64&i&&gl(n),512&i&&yl(n,n.return);break;case 3:if(Xl(e,n),64&i&&null!==(e=n.updateQueue)){if(t=null,null!==n.child)switch(n.child.tag){case 27:case 5:case 1:t=n.child.stateNode}try{Ma(e,t)}catch(e){bu(n,n.return,e)}}break;case 27:null===t&&4&i&&Tl(n);case 26:case 5:Xl(e,n),null===t&&4&i&&_l(n),512&i&&yl(n,n.return);break;case 12:Xl(e,n);break;case 31:Xl(e,n),4&i&&Fl(e,n);break;case 13:Xl(e,n),4&i&&zl(e,n),64&i&&null!==(e=n.memoizedState)&&null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$~"===e.data)e._reactRetry=t;else if("$?"!==e.data||"loading"!==n.readyState)t();else{var i=function(){t(),n.removeEventListener("DOMContentLoaded",i)};n.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}(e,n=Eu.bind(null,n));break;case 22:if(!(i=null!==n.memoizedState||Al)){t=null!==t&&null!==t.memoizedState||Rl,r=Al;var a=Rl;Al=i,(Rl=t)&&!a?$l(e,n,!!(8772&n.subtreeFlags)):Xl(e,n),Al=r,Rl=a}break;case 30:break;default:Xl(e,n)}}function Dl(e){var t=e.alternate;null!==t&&(e.alternate=null,Dl(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&null!==(t=e.stateNode)&&qe(t),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Nl=null,Ol=!1;function kl(e,t,n){for(n=n.child;null!==n;)Ul(e,t,n),n=n.sibling}function Ul(e,t,n){if(ge&&"function"==typeof ge.onCommitFiberUnmount)try{ge.onCommitFiberUnmount(me,n)}catch(e){}switch(n.tag){case 26:Rl||xl(n,t),kl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:Rl||xl(n,t);var i=Nl,r=Ol;Md(n.type)&&(Nl=n.stateNode,Ol=!1),kl(e,t,n),kd(n.stateNode),Nl=i,Ol=r;break;case 5:Rl||xl(n,t);case 6:if(i=Nl,r=Ol,Nl=null,kl(e,t,n),Ol=r,null!==(Nl=i))if(Ol)try{(9===Nl.nodeType?Nl.body:"HTML"===Nl.nodeName?Nl.ownerDocument.body:Nl).removeChild(n.stateNode)}catch(e){bu(n,t,e)}else try{Nl.removeChild(n.stateNode)}catch(e){bu(n,t,e)}break;case 18:null!==Nl&&(Ol?(Ed(9===(e=Nl).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Hh(e)):Ed(Nl,n.stateNode));break;case 4:i=Nl,r=Ol,Nl=n.stateNode.containerInfo,Ol=!0,kl(e,t,n),Nl=i,Ol=r;break;case 0:case 11:case 14:case 15:ml(2,n,t),Rl||ml(4,n,t),kl(e,t,n);break;case 1:Rl||(xl(n,t),"function"==typeof(i=n.stateNode).componentWillUnmount&&vl(n,t,i)),kl(e,t,n);break;case 21:kl(e,t,n);break;case 22:Rl=(i=Rl)||null!==n.memoizedState,kl(e,t,n),Rl=i;break;default:kl(e,t,n)}}function Fl(e,t){if(null===t.memoizedState&&null!==(e=t.alternate)&&null!==(e=e.memoizedState)){e=e.dehydrated;try{Hh(e)}catch(e){bu(t,t.return,e)}}}function zl(e,t){if(null===t.memoizedState&&null!==(e=t.alternate)&&null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))try{Hh(e)}catch(e){bu(t,t.return,e)}}function Bl(e,t){var n=function(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new Pl),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new Pl),t;default:throw Error(i(435,e.tag))}}(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var i=Tu.bind(null,e,t);t.then(i,i)}})}function Vl(e,t){var n=t.deletions;if(null!==n)for(var r=0;r<n.length;r++){var a=n[r],s=e,o=t,l=o;e:for(;null!==l;){switch(l.tag){case 27:if(Md(l.type)){Nl=l.stateNode,Ol=!1;break e}break;case 5:Nl=l.stateNode,Ol=!1;break e;case 3:case 4:Nl=l.stateNode.containerInfo,Ol=!0;break e}l=l.return}if(null===Nl)throw Error(i(160));Ul(s,o,a),Nl=null,Ol=!1,null!==(s=a.alternate)&&(s.return=null),a.return=null}if(13886&t.subtreeFlags)for(t=t.child;null!==t;)Gl(t,e),t=t.sibling}var Hl=null;function Gl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Vl(t,e),jl(e),4&r&&(ml(3,e,e.return),pl(3,e),ml(5,e,e.return));break;case 1:Vl(t,e),jl(e),512&r&&(Rl||null===n||xl(n,n.return)),64&r&&Al&&null!==(e=e.updateQueue)&&null!==(r=e.callbacks)&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=null===n?r:n.concat(r));break;case 26:var a=Hl;if(Vl(t,e),jl(e),512&r&&(Rl||null===n||xl(n,n.return)),4&r){var s=null!==n?n.memoizedState:null;if(r=e.memoizedState,null===n)if(null===r)if(null===e.stateNode){e:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;t:switch(r){case"title":(!(s=a.getElementsByTagName("title")[0])||s[Xe]||s[ze]||"http://www.w3.org/2000/svg"===s.namespaceURI||s.hasAttribute("itemprop"))&&(s=a.createElement(r),a.head.insertBefore(s,a.querySelector("head > title"))),ud(s,r,n),s[ze]=e,Qe(s),r=s;break e;case"link":var o=eh("link","href",a).get(r+(n.href||""));if(o)for(var l=0;l<o.length;l++)if((s=o[l]).getAttribute("href")===(null==n.href||""===n.href?null:n.href)&&s.getAttribute("rel")===(null==n.rel?null:n.rel)&&s.getAttribute("title")===(null==n.title?null:n.title)&&s.getAttribute("crossorigin")===(null==n.crossOrigin?null:n.crossOrigin)){o.splice(l,1);break t}ud(s=a.createElement(r),r,n),a.head.appendChild(s);break;case"meta":if(o=eh("meta","content",a).get(r+(n.content||"")))for(l=0;l<o.length;l++)if((s=o[l]).getAttribute("content")===(null==n.content?null:""+n.content)&&s.getAttribute("name")===(null==n.name?null:n.name)&&s.getAttribute("property")===(null==n.property?null:n.property)&&s.getAttribute("http-equiv")===(null==n.httpEquiv?null:n.httpEquiv)&&s.getAttribute("charset")===(null==n.charSet?null:n.charSet)){o.splice(l,1);break t}ud(s=a.createElement(r),r,n),a.head.appendChild(s);break;default:throw Error(i(468,r))}s[ze]=e,Qe(s),r=s}e.stateNode=r}else th(a,e.type,e.stateNode);else e.stateNode=Yd(a,r,e.memoizedProps);else s!==r?(null===s?null!==n.stateNode&&(n=n.stateNode).parentNode.removeChild(n):s.count--,null===r?th(a,e.type,e.stateNode):Yd(a,r,e.memoizedProps)):null===r&&null!==e.stateNode&&bl(e,e.memoizedProps,n.memoizedProps)}break;case 27:Vl(t,e),jl(e),512&r&&(Rl||null===n||xl(n,n.return)),null!==n&&4&r&&bl(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Vl(t,e),jl(e),512&r&&(Rl||null===n||xl(n,n.return)),32&e.flags){a=e.stateNode;try{wt(a,"")}catch(t){bu(e,e.return,t)}}4&r&&null!=e.stateNode&&bl(e,a=e.memoizedProps,null!==n?n.memoizedProps:a),1024&r&&(Cl=!0);break;case 6:if(Vl(t,e),jl(e),4&r){if(null===e.stateNode)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){bu(e,e.return,t)}}break;case 3:if(Jd=null,a=Hl,Hl=zd(t.containerInfo),Vl(t,e),Hl=a,jl(e),4&r&&null!==n&&n.memoizedState.isDehydrated)try{Hh(t.containerInfo)}catch(t){bu(e,e.return,t)}Cl&&(Cl=!1,Wl(e));break;case 4:r=Hl,Hl=zd(e.stateNode.containerInfo),Vl(t,e),jl(e),Hl=r;break;case 12:default:Vl(t,e),jl(e);break;case 31:case 19:Vl(t,e),jl(e),4&r&&null!==(r=e.updateQueue)&&(e.updateQueue=null,Bl(e,r));break;case 13:Vl(t,e),jl(e),8192&e.child.flags&&null!==e.memoizedState!=(null!==n&&null!==n.memoizedState)&&(Pc=se()),4&r&&null!==(r=e.updateQueue)&&(e.updateQueue=null,Bl(e,r));break;case 22:a=null!==e.memoizedState;var c=null!==n&&null!==n.memoizedState,u=Al,d=Rl;if(Al=u||a,Rl=d||c,Vl(t,e),Rl=d,Al=u,jl(e),8192&r)e:for(t=e.stateNode,t._visibility=a?-2&t._visibility:1|t._visibility,a&&(null===n||c||Al||Rl||ql(e)),n=null,t=e;;){if(5===t.tag||26===t.tag){if(null===n){c=n=t;try{if(s=c.stateNode,a)"function"==typeof(o=s.style).setProperty?o.setProperty("display","none","important"):o.display="none";else{l=c.stateNode;var h=c.memoizedProps.style,f=null!=h&&h.hasOwnProperty("display")?h.display:null;l.style.display=null==f||"boolean"==typeof f?"":(""+f).trim()}}catch(e){bu(c,c.return,e)}}}else if(6===t.tag){if(null===n){c=t;try{c.stateNode.nodeValue=a?"":c.memoizedProps}catch(e){bu(c,c.return,e)}}}else if(18===t.tag){if(null===n){c=t;try{var p=c.stateNode;a?Td(p,!0):Td(c.stateNode,!1)}catch(e){bu(c,c.return,e)}}}else if((22!==t.tag&&23!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;null===t.sibling;){if(null===t.return||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}4&r&&null!==(r=e.updateQueue)&&null!==(n=r.retryQueue)&&(r.retryQueue=null,Bl(e,n));case 30:case 21:}}function jl(e){var t=e.flags;if(2&t){try{for(var n,r=e.return;null!==r;){if(wl(r)){n=r;break}r=r.return}if(null==n)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;El(e,Sl(e),a);break;case 5:var s=n.stateNode;32&n.flags&&(wt(s,""),n.flags&=-33),El(e,Sl(e),s);break;case 3:case 4:var o=n.stateNode.containerInfo;Ml(e,Sl(e),o);break;default:throw Error(i(161))}}catch(t){bu(e,e.return,t)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function Wl(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;Wl(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Xl(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)Il(e,t.alternate,t),t=t.sibling}function ql(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ml(4,t,t.return),ql(t);break;case 1:xl(t,t.return);var n=t.stateNode;"function"==typeof n.componentWillUnmount&&vl(t,t.return,n),ql(t);break;case 27:kd(t.stateNode);case 26:case 5:xl(t,t.return),ql(t);break;case 22:null===t.memoizedState&&ql(t);break;default:ql(t)}e=e.sibling}}function $l(e,t,n){for(n=n&&!!(8772&t.subtreeFlags),t=t.child;null!==t;){var i=t.alternate,r=e,a=t,s=a.flags;switch(a.tag){case 0:case 11:case 15:$l(r,a,n),pl(4,a);break;case 1:if($l(r,a,n),"function"==typeof(r=(i=a).stateNode).componentDidMount)try{r.componentDidMount()}catch(e){bu(i,i.return,e)}if(null!==(r=(i=a).updateQueue)){var o=i.stateNode;try{var l=r.shared.hiddenCallbacks;if(null!==l)for(r.shared.hiddenCallbacks=null,r=0;r<l.length;r++)Sa(l[r],o)}catch(e){bu(i,i.return,e)}}n&&64&s&&gl(a),yl(a,a.return);break;case 27:Tl(a);case 26:case 5:$l(r,a,n),n&&null===i&&4&s&&_l(a),yl(a,a.return);break;case 12:$l(r,a,n);break;case 31:$l(r,a,n),n&&4&s&&Fl(r,a);break;case 13:$l(r,a,n),n&&4&s&&zl(r,a);break;case 22:null===a.memoizedState&&$l(r,a,n),yl(a,a.return);break;case 30:break;default:$l(r,a,n)}t=t.sibling}}function Yl(e,t){var n=null;null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),e=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(e=t.memoizedState.cachePool.pool),e!==n&&(null!=e&&e.refCount++,null!=n&&Fr(n))}function Kl(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Fr(e))}function Zl(e,t,n,i){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)Ql(e,t,n,i),t=t.sibling}function Ql(e,t,n,i){var r=t.flags;switch(t.tag){case 0:case 11:case 15:Zl(e,t,n,i),2048&r&&pl(9,t);break;case 1:case 31:case 13:default:Zl(e,t,n,i);break;case 3:Zl(e,t,n,i),2048&r&&(e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Fr(e)));break;case 12:if(2048&r){Zl(e,t,n,i),e=t.stateNode;try{var a=t.memoizedProps,s=a.id,o=a.onPostCommit;"function"==typeof o&&o(s,null===t.alternate?"mount":"update",e.passiveEffectDuration,-0)}catch(e){bu(t,t.return,e)}}else Zl(e,t,n,i);break;case 23:break;case 22:a=t.stateNode,s=t.alternate,null!==t.memoizedState?2&a._visibility?Zl(e,t,n,i):ec(e,t):2&a._visibility?Zl(e,t,n,i):(a._visibility|=2,Jl(e,t,n,i,!!(10256&t.subtreeFlags)||!1)),2048&r&&Yl(s,t);break;case 24:Zl(e,t,n,i),2048&r&&Kl(t.alternate,t)}}function Jl(e,t,n,i,r){for(r=r&&(!!(10256&t.subtreeFlags)||!1),t=t.child;null!==t;){var a=e,s=t,o=n,l=i,c=s.flags;switch(s.tag){case 0:case 11:case 15:Jl(a,s,o,l,r),pl(8,s);break;case 23:break;case 22:var u=s.stateNode;null!==s.memoizedState?2&u._visibility?Jl(a,s,o,l,r):ec(a,s):(u._visibility|=2,Jl(a,s,o,l,r)),r&&2048&c&&Yl(s.alternate,s);break;case 24:Jl(a,s,o,l,r),r&&2048&c&&Kl(s.alternate,s);break;default:Jl(a,s,o,l,r)}t=t.sibling}}function ec(e,t){if(10256&t.subtreeFlags)for(t=t.child;null!==t;){var n=e,i=t,r=i.flags;switch(i.tag){case 22:ec(n,i),2048&r&&Yl(i.alternate,i);break;case 24:ec(n,i),2048&r&&Kl(i.alternate,i);break;default:ec(n,i)}t=t.sibling}}var tc=8192;function nc(e,t,n){if(e.subtreeFlags&tc)for(e=e.child;null!==e;)ic(e,t,n),e=e.sibling}function ic(e,t,n){switch(e.tag){case 26:nc(e,t,n),e.flags&tc&&null!==e.memoizedState&&function(e,t,n,i){if(!("stylesheet"!==n.type||"string"==typeof i.media&&!1===matchMedia(i.media).matches||4&n.state.loading)){if(null===n.instance){var r=jd(i.href),a=t.querySelector(Wd(r));if(a)return null!==(t=a._p)&&"object"==typeof t&&"function"==typeof t.then&&(e.count++,e=rh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,void Qe(a);a=t.ownerDocument||t,i=Xd(i),(r=Ud.get(r))&&Zd(i,r),Qe(a=a.createElement("link"));var s=a;s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ud(a,"link",i),n.instance=a}null===e.stylesheets&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(3&n.state.loading)&&(e.count++,n=rh.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}(n,Hl,e.memoizedState,e.memoizedProps);break;case 5:default:nc(e,t,n);break;case 3:case 4:var i=Hl;Hl=zd(e.stateNode.containerInfo),nc(e,t,n),Hl=i;break;case 22:null===e.memoizedState&&(null!==(i=e.alternate)&&null!==i.memoizedState?(i=tc,tc=16777216,nc(e,t,n),tc=i):nc(e,t,n))}}function rc(e){var t=e.alternate;if(null!==t&&null!==(e=t.child)){t.child=null;do{t=e.sibling,e.sibling=null,e=t}while(null!==e)}}function ac(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var i=t[n];Ll=i,lc(i,e)}rc(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)sc(e),e=e.sibling}function sc(e){switch(e.tag){case 0:case 11:case 15:ac(e),2048&e.flags&&ml(9,e,e.return);break;case 3:case 12:default:ac(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,oc(e)):ac(e)}}function oc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var i=t[n];Ll=i,lc(i,e)}rc(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:ml(8,t,t.return),oc(t);break;case 22:2&(n=t.stateNode)._visibility&&(n._visibility&=-3,oc(t));break;default:oc(t)}e=e.sibling}}function lc(e,t){for(;null!==Ll;){var n=Ll;switch(n.tag){case 0:case 11:case 15:ml(8,n,t);break;case 23:case 22:if(null!==n.memoizedState&&null!==n.memoizedState.cachePool){var i=n.memoizedState.cachePool.pool;null!=i&&i.refCount++}break;case 24:Fr(n.memoizedState.cache)}if(null!==(i=n.child))i.return=n,Ll=i;else e:for(n=e;null!==Ll;){var r=(i=Ll).sibling,a=i.return;if(Dl(i),i===n){Ll=null;break e}if(null!==r){r.return=a,Ll=r;break e}Ll=a}}}var cc={getCacheForType:function(e){var t=Pr(kr),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Pr(kr).controller.signal}},uc="function"==typeof WeakMap?WeakMap:Map,dc=0,hc=null,fc=null,pc=0,mc=0,gc=null,vc=!1,yc=!1,xc=!1,_c=0,bc=0,wc=0,Sc=0,Mc=0,Ec=0,Tc=0,Ac=null,Rc=null,Cc=!1,Pc=0,Lc=0,Ic=1/0,Dc=null,Nc=null,Oc=0,kc=null,Uc=null,Fc=0,zc=0,Bc=null,Vc=null,Hc=0,Gc=null;function jc(){return 2&dc&&0!==pc?pc&-pc:null!==I.T?Bu():ke()}function Wc(){if(0===Ec)if(536870912&pc&&!cr)Ec=536870912;else{var e=we;!(3932160&(we<<=1))&&(we=262144),Ec=e}return null!==(e=Pa.current)&&(e.flags|=32),Ec}function Xc(e,t,n){(e!==hc||2!==mc&&9!==mc)&&null===e.cancelPendingCommit||(Jc(e,0),Kc(e,pc,Ec,!1)),Pe(e,n),2&dc&&e===hc||(e===hc&&(!(2&dc)&&(Sc|=n),4===bc&&Kc(e,pc,Ec,!1)),Du(e))}function qc(e,t,n){if(6&dc)throw Error(i(327));for(var r=!n&&!(127&t)&&0===(t&e.expiredLanes)||Te(e,t),a=r?function(e,t){var n=dc;dc|=2;var r=nu(),a=iu();hc!==e||pc!==t?(Dc=null,Ic=se()+500,Jc(e,t)):yc=Te(e,t);e:for(;;)try{if(0!==mc&&null!==fc){t=fc;var s=gc;t:switch(mc){case 1:mc=0,gc=null,uu(e,t,s,1);break;case 2:case 9:if(Jr(s)){mc=0,gc=null,cu(t);break}t=function(){2!==mc&&9!==mc||hc!==e||(mc=7),Du(e)},s.then(t,t);break e;case 3:mc=7;break e;case 4:mc=5;break e;case 7:Jr(s)?(mc=0,gc=null,cu(t)):(mc=0,gc=null,uu(e,t,s,7));break;case 5:var o=null;switch(fc.tag){case 26:o=fc.memoizedState;case 5:case 27:var l=fc;if(o?nh(o):l.stateNode.complete){mc=0,gc=null;var c=l.sibling;if(null!==c)fc=c;else{var u=l.return;null!==u?(fc=u,du(u)):fc=null}break t}}mc=0,gc=null,uu(e,t,s,5);break;case 6:mc=0,gc=null,uu(e,t,s,6);break;case 8:Qc(),bc=6;break e;default:throw Error(i(462))}}ou();break}catch(t){eu(e,t)}return wr=br=null,I.H=r,I.A=a,dc=n,null!==fc?0:(hc=null,pc=0,Ri(),bc)}(e,t):au(e,t,!0),s=r;;){if(0===a){yc&&!r&&Kc(e,t,0,!1);break}if(n=e.current.alternate,!s||Yc(n)){if(2===a){if(s=t,e.errorRecoveryDisabledLanes&s)var o=0;else o=0!=(o=-536870913&e.pendingLanes)?o:536870912&o?536870912:0;if(0!==o){t=o;e:{var l=e;a=Ac;var c=l.current.memoizedState.isDehydrated;if(c&&(Jc(l,o).flags|=256),2!==(o=au(l,o,!1))){if(xc&&!c){l.errorRecoveryDisabledLanes|=s,Sc|=s,a=4;break e}s=Rc,Rc=a,null!==s&&(null===Rc?Rc=s:Rc.push.apply(Rc,s))}a=o}if(s=!1,2!==a)continue}}if(1===a){Jc(e,0),Kc(e,t,0,!0);break}e:{switch(r=e,s=a){case 0:case 1:throw Error(i(345));case 4:if((4194048&t)!==t)break;case 6:Kc(r,t,Ec,!vc);break e;case 2:Rc=null;break;case 3:case 5:break;default:throw Error(i(329))}if((62914560&t)===t&&10<(a=Pc+300-se())){if(Kc(r,t,Ec,!vc),0!==Ee(r,0,!0))break e;Fc=t,r.timeoutHandle=xd($c.bind(null,r,n,Rc,Dc,Cc,t,Ec,Sc,Tc,vc,s,"Throttled",-0,0),a)}else $c(r,n,Rc,Dc,Cc,t,Ec,Sc,Tc,vc,s,null,-0,0)}break}a=au(e,t,!1),s=!1}Du(e)}function $c(e,t,n,i,r,a,s,o,l,c,u,d,h,f){if(e.timeoutHandle=-1,8192&(d=t.subtreeFlags)||!(16785408&~d)){ic(t,a,d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Pt});var p=(62914560&a)===a?Pc-se():(4194048&a)===a?Lc-se():0;if(null!==(p=function(e,t){return e.stylesheets&&0===e.count&&sh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var i=setTimeout(function(){if(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&0===ih&&(ih=62500*function(){if("function"==typeof performance.getEntriesByType){for(var e=0,t=0,n=performance.getEntriesByType("resource"),i=0;i<n.length;i++){var r=n[i],a=r.transferSize,s=r.initiatorType,o=r.duration;if(a&&o&&dd(s)){for(s=0,o=r.responseEnd,i+=1;i<n.length;i++){var l=n[i],c=l.startTime;if(c>o)break;var u=l.transferSize,d=l.initiatorType;u&&dd(d)&&(s+=u*((l=l.responseEnd)<o?1:(o-c)/(l-c)))}if(--i,t+=8*(a+s)/(r.duration/1e3),10<++e)break}}if(0<e)return t/e/1e6}return navigator.connection&&"number"==typeof(e=navigator.connection.downlink)?e:5}());var r=setTimeout(function(){if(e.waitingForImages=!1,0===e.count&&(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>ih?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(r)}}:null}(d,p)))return Fc=a,e.cancelPendingCommit=p(fu.bind(null,e,t,a,n,i,r,s,o,l,u,d,null,h,f)),void Kc(e,a,s,!c)}fu(e,t,a,n,i,r,s,o,l)}function Yc(e){for(var t=e;;){var n=t.tag;if((0===n||11===n||15===n)&&16384&t.flags&&null!==(n=t.updateQueue)&&null!==(n=n.stores))for(var i=0;i<n.length;i++){var r=n[i],a=r.getSnapshot;r=r.value;try{if(!Kn(a(),r))return!1}catch(e){return!1}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Kc(e,t,n,i){t&=~Mc,t&=~Sc,e.suspendedLanes|=t,e.pingedLanes&=~t,i&&(e.warmLanes|=t),i=e.expirationTimes;for(var r=t;0<r;){var a=31-ye(r),s=1<<a;i[a]=-1,r&=~s}0!==n&&Le(e,n,t)}function Zc(){return!!(6&dc)||(Nu(0),!1)}function Qc(){if(null!==fc){if(0===mc)var e=fc.return;else wr=br=null,rs(e=fc),aa=null,sa=0,e=fc;for(;null!==e;)fl(e.alternate,e),e=e.return;fc=null}}function Jc(e,t){var n=e.timeoutHandle;-1!==n&&(e.timeoutHandle=-1,_d(n)),null!==(n=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,n()),Fc=0,Qc(),hc=e,fc=n=Fi(e.current,null),pc=t,mc=0,gc=null,vc=!1,yc=Te(e,t),xc=!1,Tc=Ec=Mc=Sc=wc=bc=0,Rc=Ac=null,Cc=!1,8&t&&(t|=32&t);var i=e.entangledLanes;if(0!==i)for(e=e.entanglements,i&=t;0<i;){var r=31-ye(i),a=1<<r;t|=e[r],i&=~a}return _c=t,Ri(),n}function eu(e,t){Ba=null,I.H=fo,t===Yr||t===Zr?(t=ia(),mc=3):t===Kr?(t=ia(),mc=4):mc=t===Po?8:null!==t&&"object"==typeof t&&"function"==typeof t.then?6:1,gc=t,null===fc&&(bc=1,Eo(e,Xi(t,e.current)))}function tu(){var e=Pa.current;return null===e||((4194048&pc)===pc?null===La:!!((62914560&pc)===pc||536870912&pc)&&e===La)}function nu(){var e=I.H;return I.H=fo,null===e?fo:e}function iu(){var e=I.A;return I.A=cc,e}function ru(){bc=4,vc||(4194048&pc)!==pc&&null!==Pa.current||(yc=!0),!(134217727&wc)&&!(134217727&Sc)||null===hc||Kc(hc,pc,Ec,!1)}function au(e,t,n){var i=dc;dc|=2;var r=nu(),a=iu();hc===e&&pc===t||(Dc=null,Jc(e,t)),t=!1;var s=bc;e:for(;;)try{if(0!==mc&&null!==fc){var o=fc,l=gc;switch(mc){case 8:Qc(),s=6;break e;case 3:case 2:case 9:case 6:null===Pa.current&&(t=!0);var c=mc;if(mc=0,gc=null,uu(e,o,l,c),n&&yc){s=0;break e}break;default:c=mc,mc=0,gc=null,uu(e,o,l,c)}}su(),s=bc;break}catch(t){eu(e,t)}return t&&e.shellSuspendCounter++,wr=br=null,dc=i,I.H=r,I.A=a,null===fc&&(hc=null,pc=0,Ri()),s}function su(){for(;null!==fc;)lu(fc)}function ou(){for(;null!==fc&&!re();)lu(fc)}function lu(e){var t=rl(e.alternate,e,_c);e.memoizedProps=e.pendingProps,null===t?du(e):fc=t}function cu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Go(n,t,t.pendingProps,t.type,void 0,pc);break;case 11:t=Go(n,t,t.pendingProps,t.type.render,t.ref,pc);break;case 5:rs(t);default:fl(n,t),t=rl(n,t=fc=zi(t,_c),_c)}e.memoizedProps=e.pendingProps,null===t?du(e):fc=t}function uu(e,t,n,r){wr=br=null,rs(t),aa=null,sa=0;var a=t.return;try{if(function(e,t,n,r,a){if(n.flags|=32768,null!==r&&"object"==typeof r&&"function"==typeof r.then){if(null!==(t=n.alternate)&&Ar(t,n,a,!0),null!==(n=Pa.current)){switch(n.tag){case 31:case 13:return null===La?ru():null===n.alternate&&0===bc&&(bc=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Qr?n.flags|=16384:(null===(t=n.updateQueue)?n.updateQueue=new Set([r]):t.add(r),wu(e,r,a)),!1;case 22:return n.flags|=65536,r===Qr?n.flags|=16384:(null===(t=n.updateQueue)?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):null===(n=t.retryQueue)?t.retryQueue=new Set([r]):n.add(r),wu(e,r,a)),!1}throw Error(i(435,n.tag))}return wu(e,r,a),ru(),!1}if(cr)return null!==(t=Pa.current)?(!(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==hr&&xr(Xi(e=Error(i(422),{cause:r}),n))):(r!==hr&&xr(Xi(t=Error(i(423),{cause:r}),n)),(e=e.current.alternate).flags|=65536,a&=-a,e.lanes|=a,r=Xi(r,n),xa(e,a=Ao(e.stateNode,r,a)),4!==bc&&(bc=2)),!1;var s=Error(i(520),{cause:r});if(s=Xi(s,n),null===Ac?Ac=[s]:Ac.push(s),4!==bc&&(bc=2),null===t)return!0;r=Xi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,xa(n,e=Ao(n.stateNode,r,e)),!1;case 1:if(t=n.type,s=n.stateNode,!(128&n.flags||"function"!=typeof t.getDerivedStateFromError&&(null===s||"function"!=typeof s.componentDidCatch||null!==Nc&&Nc.has(s))))return n.flags|=65536,a&=-a,n.lanes|=a,Co(a=Ro(a),e,n,r),xa(n,a),!1}n=n.return}while(null!==n);return!1}(e,a,t,n,pc))return bc=1,Eo(e,Xi(n,e.current)),void(fc=null)}catch(t){if(null!==a)throw fc=a,t;return bc=1,Eo(e,Xi(n,e.current)),void(fc=null)}32768&t.flags?(cr||1===r?e=!0:yc||536870912&pc?e=!1:(vc=e=!0,(2===r||9===r||3===r||6===r)&&null!==(r=Pa.current)&&13===r.tag&&(r.flags|=16384)),hu(t,e)):du(t)}function du(e){var t=e;do{if(32768&t.flags)return void hu(t,vc);e=t.return;var n=dl(t.alternate,t,_c);if(null!==n)return void(fc=n);if(null!==(t=t.sibling))return void(fc=t);fc=t=e}while(null!==t);0===bc&&(bc=5)}function hu(e,t){do{var n=hl(e.alternate,e);if(null!==n)return n.flags&=32767,void(fc=n);if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&null!==(e=e.sibling))return void(fc=e);fc=e=n}while(null!==e);bc=6,fc=null}function fu(e,t,n,r,a,s,o,l,c){e.cancelPendingCommit=null;do{yu()}while(0!==Oc);if(6&dc)throw Error(i(327));if(null!==t){if(t===e.current)throw Error(i(177));if(s=t.lanes|t.childLanes,function(e,t,n,i,r,a){var s=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var o=e.entanglements,l=e.expirationTimes,c=e.hiddenUpdates;for(n=s&~n;0<n;){var u=31-ye(n),d=1<<u;o[u]=0,l[u]=-1;var h=c[u];if(null!==h)for(c[u]=null,u=0;u<h.length;u++){var f=h[u];null!==f&&(f.lane&=-536870913)}n&=~d}0!==i&&Le(e,i,0),0!==a&&0===r&&0!==e.tag&&(e.suspendedLanes|=a&~(s&~t))}(e,n,s|=Ai,o,l,c),e===hc&&(fc=hc=null,pc=0),Uc=t,kc=e,Fc=n,zc=s,Bc=a,Vc=r,10256&t.subtreeFlags||10256&t.flags?(e.callbackNode=null,e.callbackPriority=0,ne(ue,function(){return xu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=!!(13878&t.flags),13878&t.subtreeFlags||r){r=I.T,I.T=null,a=D.p,D.p=2,o=dc,dc|=4;try{!function(e,t){if(e=e.containerInfo,hd=vh,ni(e=ti(e))){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{var r=(n=(n=e.ownerDocument)&&n.defaultView||window).getSelection&&n.getSelection();if(r&&0!==r.rangeCount){n=r.anchorNode;var a=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch(e){n=null;break e}var o=0,l=-1,c=-1,u=0,d=0,h=e,f=null;t:for(;;){for(var p;h!==n||0!==a&&3!==h.nodeType||(l=o+a),h!==s||0!==r&&3!==h.nodeType||(c=o+r),3===h.nodeType&&(o+=h.nodeValue.length),null!==(p=h.firstChild);)f=h,h=p;for(;;){if(h===e)break t;if(f===n&&++u===a&&(l=o),f===s&&++d===r&&(c=o),null!==(p=h.nextSibling))break;f=(h=f).parentNode}h=p}n=-1===l||-1===c?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(fd={focusedElem:e,selectionRange:n},vh=!1,Ll=t;null!==Ll;)if(e=(t=Ll).child,1028&t.subtreeFlags&&null!==e)e.return=t,Ll=e;else for(;null!==Ll;){switch(s=(t=Ll).alternate,e=t.flags,t.tag){case 0:if(4&e&&null!==(e=null!==(e=t.updateQueue)?e.events:null))for(n=0;n<e.length;n++)(a=e[n]).ref.impl=a.nextImpl;break;case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(1024&e&&null!==s){e=void 0,n=t,a=s.memoizedProps,s=s.memoizedState,r=n.stateNode;try{var m=bo(n.type,a);e=r.getSnapshotBeforeUpdate(m,s),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){bu(n,n.return,e)}}break;case 3:if(1024&e)if(9===(n=(e=t.stateNode.containerInfo).nodeType))Ad(e);else if(1===n)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ad(e);break;default:e.textContent=""}break;default:if(1024&e)throw Error(i(163))}if(null!==(e=t.sibling)){e.return=t.return,Ll=e;break}Ll=t.return}}(e,t)}finally{dc=o,D.p=a,I.T=r}}Oc=1,pu(),mu(),gu()}}function pu(){if(1===Oc){Oc=0;var e=kc,t=Uc,n=!!(13878&t.flags);if(13878&t.subtreeFlags||n){n=I.T,I.T=null;var i=D.p;D.p=2;var r=dc;dc|=4;try{Gl(t,e);var a=fd,s=ti(e.containerInfo),o=a.focusedElem,l=a.selectionRange;if(s!==o&&o&&o.ownerDocument&&ei(o.ownerDocument.documentElement,o)){if(null!==l&&ni(o)){var c=l.start,u=l.end;if(void 0===u&&(u=c),"selectionStart"in o)o.selectionStart=c,o.selectionEnd=Math.min(u,o.value.length);else{var d=o.ownerDocument||document,h=d&&d.defaultView||window;if(h.getSelection){var f=h.getSelection(),p=o.textContent.length,m=Math.min(l.start,p),g=void 0===l.end?m:Math.min(l.end,p);!f.extend&&m>g&&(s=g,g=m,m=s);var v=Jn(o,m),y=Jn(o,g);if(v&&y&&(1!==f.rangeCount||f.anchorNode!==v.node||f.anchorOffset!==v.offset||f.focusNode!==y.node||f.focusOffset!==y.offset)){var x=d.createRange();x.setStart(v.node,v.offset),f.removeAllRanges(),m>g?(f.addRange(x),f.extend(y.node,y.offset)):(x.setEnd(y.node,y.offset),f.addRange(x))}}}}for(d=[],f=o;f=f.parentNode;)1===f.nodeType&&d.push({element:f,left:f.scrollLeft,top:f.scrollTop});for("function"==typeof o.focus&&o.focus(),o=0;o<d.length;o++){var _=d[o];_.element.scrollLeft=_.left,_.element.scrollTop=_.top}}vh=!!hd,fd=hd=null}finally{dc=r,D.p=i,I.T=n}}e.current=t,Oc=2}}function mu(){if(2===Oc){Oc=0;var e=kc,t=Uc,n=!!(8772&t.flags);if(8772&t.subtreeFlags||n){n=I.T,I.T=null;var i=D.p;D.p=2;var r=dc;dc|=4;try{Il(e,t.alternate,t)}finally{dc=r,D.p=i,I.T=n}}Oc=3}}function gu(){if(4===Oc||3===Oc){Oc=0,ae();var e=kc,t=Uc,n=Fc,i=Vc;10256&t.subtreeFlags||10256&t.flags?Oc=5:(Oc=0,Uc=kc=null,vu(e,e.pendingLanes));var r=e.pendingLanes;if(0===r&&(Nc=null),Oe(n),t=t.stateNode,ge&&"function"==typeof ge.onCommitFiberRoot)try{ge.onCommitFiberRoot(me,t,void 0,!(128&~t.current.flags))}catch(e){}if(null!==i){t=I.T,r=D.p,D.p=2,I.T=null;try{for(var a=e.onRecoverableError,s=0;s<i.length;s++){var o=i[s];a(o.value,{componentStack:o.stack})}}finally{I.T=t,D.p=r}}3&Fc&&yu(),Du(e),r=e.pendingLanes,261930&n&&42&r?e===Gc?Hc++:(Hc=0,Gc=e):Hc=0,Nu(0)}}function vu(e,t){0===(e.pooledCacheLanes&=t)&&null!=(t=e.pooledCache)&&(e.pooledCache=null,Fr(t))}function yu(){return pu(),mu(),gu(),xu()}function xu(){if(5!==Oc)return!1;var e=kc,t=zc;zc=0;var n=Oe(Fc),r=I.T,a=D.p;try{D.p=32>n?32:n,I.T=null,n=Bc,Bc=null;var s=kc,o=Fc;if(Oc=0,Uc=kc=null,Fc=0,6&dc)throw Error(i(331));var l=dc;if(dc|=4,sc(s.current),Ql(s,s.current,o,n),dc=l,Nu(0,!1),ge&&"function"==typeof ge.onPostCommitFiberRoot)try{ge.onPostCommitFiberRoot(me,s)}catch(e){}return!0}finally{D.p=a,I.T=r,vu(e,t)}}function _u(e,t,n){t=Xi(n,t),null!==(e=va(e,t=Ao(e.stateNode,t,2),2))&&(Pe(e,2),Du(e))}function bu(e,t,n){if(3===e.tag)_u(e,e,n);else for(;null!==t;){if(3===t.tag){_u(t,e,n);break}if(1===t.tag){var i=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof i.componentDidCatch&&(null===Nc||!Nc.has(i))){e=Xi(n,e),null!==(i=va(t,n=Ro(2),2))&&(Co(n,i,t,e),Pe(i,2),Du(i));break}}t=t.return}}function wu(e,t,n){var i=e.pingCache;if(null===i){i=e.pingCache=new uc;var r=new Set;i.set(t,r)}else void 0===(r=i.get(t))&&(r=new Set,i.set(t,r));r.has(n)||(xc=!0,r.add(n),e=Su.bind(null,e,t,n),t.then(e,e))}function Su(e,t,n){var i=e.pingCache;null!==i&&i.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,hc===e&&(pc&n)===n&&(4===bc||3===bc&&(62914560&pc)===pc&&300>se()-Pc?!(2&dc)&&Jc(e,0):Mc|=n,Tc===pc&&(Tc=0)),Du(e)}function Mu(e,t){0===t&&(t=Re()),null!==(e=Li(e,t))&&(Pe(e,t),Du(e))}function Eu(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Mu(e,n)}function Tu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;null!==a&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}null!==r&&r.delete(t),Mu(e,n)}var Au=null,Ru=null,Cu=!1,Pu=!1,Lu=!1,Iu=0;function Du(e){e!==Ru&&null===e.next&&(null===Ru?Au=Ru=e:Ru=Ru.next=e),Pu=!0,Cu||(Cu=!0,wd(function(){6&dc?ne(le,Ou):ku()}))}function Nu(e,t){if(!Lu&&Pu){Lu=!0;do{for(var n=!1,i=Au;null!==i;){if(0!==e){var r=i.pendingLanes;if(0===r)var a=0;else{var s=i.suspendedLanes,o=i.pingedLanes;a=(1<<31-ye(42|e)+1)-1,a=201326741&(a&=r&~(s&~o))?201326741&a|1:a?2|a:0}0!==a&&(n=!0,zu(i,a))}else a=pc,!(3&(a=Ee(i,i===hc?a:0,null!==i.cancelPendingCommit||-1!==i.timeoutHandle)))||Te(i,a)||(n=!0,zu(i,a));i=i.next}}while(n);Lu=!1}}function Ou(){ku()}function ku(){Pu=Cu=!1;var e,t=0;0!==Iu&&((e=window.event)&&"popstate"===e.type?e!==yd&&(yd=e,1):(yd=null,0))&&(t=Iu);for(var n=se(),i=null,r=Au;null!==r;){var a=r.next,s=Uu(r,n);0===s?(r.next=null,null===i?Au=a:i.next=a,null===a&&(Ru=i)):(i=r,(0!==t||3&s)&&(Pu=!0)),r=a}0!==Oc&&5!==Oc||Nu(t),0!==Iu&&(Iu=0)}function Uu(e,t){for(var n=e.suspendedLanes,i=e.pingedLanes,r=e.expirationTimes,a=-62914561&e.pendingLanes;0<a;){var s=31-ye(a),o=1<<s,l=r[s];-1===l?0!==(o&n)&&0===(o&i)||(r[s]=Ae(o,t)):l<=t&&(e.expiredLanes|=o),a&=~o}if(n=pc,n=Ee(e,e===(t=hc)?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),i=e.callbackNode,0===n||e===t&&(2===mc||9===mc)||null!==e.cancelPendingCommit)return null!==i&&null!==i&&ie(i),e.callbackNode=null,e.callbackPriority=0;if(!(3&n)||Te(e,n)){if((t=n&-n)===e.callbackPriority)return t;switch(null!==i&&ie(i),Oe(n)){case 2:case 8:n=ce;break;case 32:default:n=ue;break;case 268435456:n=he}return i=Fu.bind(null,e),n=ne(n,i),e.callbackPriority=t,e.callbackNode=n,t}return null!==i&&null!==i&&ie(i),e.callbackPriority=2,e.callbackNode=null,2}function Fu(e,t){if(0!==Oc&&5!==Oc)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(yu()&&e.callbackNode!==n)return null;var i=pc;return 0===(i=Ee(e,e===hc?i:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:(qc(e,i,t),Uu(e,se()),null!=e.callbackNode&&e.callbackNode===n?Fu.bind(null,e):null)}function zu(e,t){if(yu())return null;qc(e,t,!0)}function Bu(){if(0===Iu){var e=Vr;0===e&&(e=be,!(261888&(be<<=1))&&(be=256)),Iu=e}return Iu}function Vu(e){return null==e||"symbol"==typeof e||"boolean"==typeof e?null:"function"==typeof e?e:Ct(""+e)}function Hu(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}for(var Gu=0;Gu<wi.length;Gu++){var ju=wi[Gu];Si(ju.toLowerCase(),"on"+(ju[0].toUpperCase()+ju.slice(1)))}Si(pi,"onAnimationEnd"),Si(mi,"onAnimationIteration"),Si(gi,"onAnimationStart"),Si("dblclick","onDoubleClick"),Si("focusin","onFocus"),Si("focusout","onBlur"),Si(vi,"onTransitionRun"),Si(yi,"onTransitionStart"),Si(xi,"onTransitionCancel"),Si(_i,"onTransitionEnd"),nt("onMouseEnter",["mouseout","mouseover"]),nt("onMouseLeave",["mouseout","mouseover"]),nt("onPointerEnter",["pointerout","pointerover"]),nt("onPointerLeave",["pointerout","pointerover"]),tt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),tt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),tt("onBeforeInput",["compositionend","keypress","textInput","paste"]),tt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),tt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),tt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Wu="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Xu=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Wu));function qu(e,t){t=!!(4&t);for(var n=0;n<e.length;n++){var i=e[n],r=i.event;i=i.listeners;e:{var a=void 0;if(t)for(var s=i.length-1;0<=s;s--){var o=i[s],l=o.instance,c=o.currentTarget;if(o=o.listener,l!==a&&r.isPropagationStopped())break e;a=o,r.currentTarget=c;try{a(r)}catch(e){Mi(e)}r.currentTarget=null,a=l}else for(s=0;s<i.length;s++){if(l=(o=i[s]).instance,c=o.currentTarget,o=o.listener,l!==a&&r.isPropagationStopped())break e;a=o,r.currentTarget=c;try{a(r)}catch(e){Mi(e)}r.currentTarget=null,a=l}}}}function $u(e,t){var n=t[He];void 0===n&&(n=t[He]=new Set);var i=e+"__bubble";n.has(i)||(Qu(t,e,2,!1),n.add(i))}function Yu(e,t,n){var i=0;t&&(i|=4),Qu(n,e,i,t)}var Ku="_reactListening"+Math.random().toString(36).slice(2);function Zu(e){if(!e[Ku]){e[Ku]=!0,Je.forEach(function(t){"selectionchange"!==t&&(Xu.has(t)||Yu(t,!1,e),Yu(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[Ku]||(t[Ku]=!0,Yu("selectionchange",!1,t))}}function Qu(e,t,n,i){switch(Mh(t)){case 2:var r=yh;break;case 8:r=xh;break;default:r=_h}n=r.bind(null,t,n,e),r=void 0,!Bt||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(r=!0),i?void 0!==r?e.addEventListener(t,n,{capture:!0,passive:r}):e.addEventListener(t,n,!0):void 0!==r?e.addEventListener(t,n,{passive:r}):e.addEventListener(t,n,!1)}function Ju(e,t,n,i,r){var s=i;if(!(1&t||2&t||null===i))e:for(;;){if(null===i)return;var o=i.tag;if(3===o||4===o){var l=i.stateNode.containerInfo;if(l===r)break;if(4===o)for(o=i.return;null!==o;){var c=o.tag;if((3===c||4===c)&&o.stateNode.containerInfo===r)return;o=o.return}for(;null!==l;){if(null===(o=$e(l)))return;if(5===(c=o.tag)||6===c||26===c||27===c){i=s=o;continue e}l=l.parentNode}}i=i.return}Ut(function(){var i=s,r=It(n),o=[];e:{var l=bi.get(e);if(void 0!==l){var c=en,u=e;switch(e){case"keypress":if(0===Xt(n))break e;case"keydown":case"keyup":c=gn;break;case"focusin":u="focus",c=on;break;case"focusout":u="blur",c=on;break;case"beforeblur":case"afterblur":c=on;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=an;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=sn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=yn;break;case pi:case mi:case gi:c=ln;break;case _i:c=xn;break;case"scroll":case"scrollend":c=nn;break;case"wheel":c=_n;break;case"copy":case"cut":case"paste":c=cn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=vn;break;case"toggle":case"beforetoggle":c=bn}var d=!!(4&t),h=!d&&("scroll"===e||"scrollend"===e),f=d?null!==l?l+"Capture":null:l;d=[];for(var p,m=i;null!==m;){var g=m;if(p=g.stateNode,5!==(g=g.tag)&&26!==g&&27!==g||null===p||null===f||null!=(g=Ft(m,f))&&d.push(ed(m,g,p)),h)break;m=m.return}0<d.length&&(l=new c(l,u,null,n,r),o.push({event:l,listeners:d}))}}if(!(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(l="mouseover"===e||"pointerover"===e)||n===Lt||!(u=n.relatedTarget||n.fromElement)||!$e(u)&&!u[Ve])&&(c||l)&&(l=r.window===r?r:(l=r.ownerDocument)?l.defaultView||l.parentWindow:window,c?(c=i,null!==(u=(u=n.relatedTarget||n.toElement)?$e(u):null)&&(h=a(u),d=u.tag,u!==h||5!==d&&27!==d&&6!==d)&&(u=null)):(c=null,u=i),c!==u)){if(d=an,g="onMouseLeave",f="onMouseEnter",m="mouse","pointerout"!==e&&"pointerover"!==e||(d=vn,g="onPointerLeave",f="onPointerEnter",m="pointer"),h=null==c?l:Ke(c),p=null==u?l:Ke(u),(l=new d(g,m+"leave",c,n,r)).target=h,l.relatedTarget=p,g=null,$e(r)===i&&((d=new d(f,m+"enter",u,n,r)).target=p,d.relatedTarget=h,g=d),h=g,c&&u)e:{for(d=nd,m=u,p=0,g=f=c;g;g=d(g))p++;g=0;for(var v=m;v;v=d(v))g++;for(;0<p-g;)f=d(f),p--;for(;0<g-p;)m=d(m),g--;for(;p--;){if(f===m||null!==m&&f===m.alternate){d=f;break e}f=d(f),m=d(m)}d=null}else d=null;null!==c&&id(o,l,c,d,!1),null!==u&&null!==h&&id(o,h,u,d,!0)}if("select"===(c=(l=i?Ke(i):window).nodeName&&l.nodeName.toLowerCase())||"input"===c&&"file"===l.type)var y=zn;else if(Dn(l))if(Bn)y=Yn;else{y=qn;var x=Xn}else!(c=l.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==l.type&&"radio"!==l.type?i&&Tt(i.elementType)&&(y=zn):y=$n;switch(y&&(y=y(e,i))?Nn(o,y,n,r):(x&&x(e,l,i),"focusout"===e&&i&&"number"===l.type&&null!=i.memoizedProps.value&&yt(l,"number",l.value)),x=i?Ke(i):window,e){case"focusin":(Dn(x)||"true"===x.contentEditable)&&(ri=x,ai=i,si=null);break;case"focusout":si=ai=ri=null;break;case"mousedown":oi=!0;break;case"contextmenu":case"mouseup":case"dragend":oi=!1,li(o,n,r);break;case"selectionchange":if(ii)break;case"keydown":case"keyup":li(o,n,r)}var _;if(Sn)e:{switch(e){case"compositionstart":var b="onCompositionStart";break e;case"compositionend":b="onCompositionEnd";break e;case"compositionupdate":b="onCompositionUpdate";break e}b=void 0}else Ln?Cn(e,n)&&(b="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(b="onCompositionStart");b&&(Tn&&"ko"!==n.locale&&(Ln||"onCompositionStart"!==b?"onCompositionEnd"===b&&Ln&&(_=Wt()):(Gt="value"in(Ht=r)?Ht.value:Ht.textContent,Ln=!0)),0<(x=td(i,b)).length&&(b=new un(b,e,null,n,r),o.push({event:b,listeners:x}),(_||null!==(_=Pn(n)))&&(b.data=_))),(_=En?function(e,t){switch(e){case"compositionend":return Pn(t);case"keypress":return 32!==t.which?null:(Rn=!0,An);case"textInput":return(e=t.data)===An&&Rn?null:e;default:return null}}(e,n):function(e,t){if(Ln)return"compositionend"===e||!Sn&&Cn(e,t)?(e=Wt(),jt=Gt=Ht=null,Ln=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Tn&&"ko"!==t.locale?null:t.data}}(e,n))&&0<(b=td(i,"onBeforeInput")).length&&(x=new un("onBeforeInput","beforeinput",null,n,r),o.push({event:x,listeners:b}),x.data=_),function(e,t,n,i,r){if("submit"===t&&n&&n.stateNode===r){var a=Vu((r[Be]||null).action),s=i.submitter;s&&null!==(t=(t=s[Be]||null)?Vu(t.formAction):s.getAttribute("formAction"))&&(a=t,s=null);var o=new en("action","action",null,i,r);e.push({event:o,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(0!==Iu){var e=s?Hu(r,s):new FormData(r);Qs(n,{pending:!0,data:e,method:r.method,action:a},null,e)}}else"function"==typeof a&&(o.preventDefault(),e=s?Hu(r,s):new FormData(r),Qs(n,{pending:!0,data:e,method:r.method,action:a},a,e))},currentTarget:r}]})}}(o,e,i,n,r)}qu(o,t)})}function ed(e,t,n){return{instance:e,listener:t,currentTarget:n}}function td(e,t){for(var n=t+"Capture",i=[];null!==e;){var r=e,a=r.stateNode;if(5!==(r=r.tag)&&26!==r&&27!==r||null===a||(null!=(r=Ft(e,n))&&i.unshift(ed(e,r,a)),null!=(r=Ft(e,t))&&i.push(ed(e,r,a))),3===e.tag)return i;e=e.return}return[]}function nd(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function id(e,t,n,i,r){for(var a=t._reactName,s=[];null!==n&&n!==i;){var o=n,l=o.alternate,c=o.stateNode;if(o=o.tag,null!==l&&l===i)break;5!==o&&26!==o&&27!==o||null===c||(l=c,r?null!=(c=Ft(n,a))&&s.unshift(ed(n,c,l)):r||null!=(c=Ft(n,a))&&s.push(ed(n,c,l))),n=n.return}0!==s.length&&e.push({event:t,listeners:s})}var rd=/\r\n?/g,ad=/\u0000|\uFFFD/g;function sd(e){return("string"==typeof e?e:""+e).replace(rd,"\n").replace(ad,"")}function od(e,t){return t=sd(t),sd(e)===t}function ld(e,t,n,r,a,s){switch(n){case"children":"string"==typeof r?"body"===t||"textarea"===t&&""===r||wt(e,r):("number"==typeof r||"bigint"==typeof r)&&"body"!==t&&wt(e,""+r);break;case"className":ot(e,"class",r);break;case"tabIndex":ot(e,"tabindex",r);break;case"dir":case"role":case"viewBox":case"width":case"height":ot(e,n,r);break;case"style":Et(e,r,s);break;case"data":if("object"!==t){ot(e,"data",r);break}case"src":case"href":if(""===r&&("a"!==t||"href"!==n)){e.removeAttribute(n);break}if(null==r||"function"==typeof r||"symbol"==typeof r||"boolean"==typeof r){e.removeAttribute(n);break}r=Ct(""+r),e.setAttribute(n,r);break;case"action":case"formAction":if("function"==typeof r){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}if("function"==typeof s&&("formAction"===n?("input"!==t&&ld(e,t,"name",a.name,a,null),ld(e,t,"formEncType",a.formEncType,a,null),ld(e,t,"formMethod",a.formMethod,a,null),ld(e,t,"formTarget",a.formTarget,a,null)):(ld(e,t,"encType",a.encType,a,null),ld(e,t,"method",a.method,a,null),ld(e,t,"target",a.target,a,null))),null==r||"symbol"==typeof r||"boolean"==typeof r){e.removeAttribute(n);break}r=Ct(""+r),e.setAttribute(n,r);break;case"onClick":null!=r&&(e.onclick=Pt);break;case"onScroll":null!=r&&$u("scroll",e);break;case"onScrollEnd":null!=r&&$u("scrollend",e);break;case"dangerouslySetInnerHTML":if(null!=r){if("object"!=typeof r||!("__html"in r))throw Error(i(61));if(null!=(n=r.__html)){if(null!=a.children)throw Error(i(60));e.innerHTML=n}}break;case"multiple":e.multiple=r&&"function"!=typeof r&&"symbol"!=typeof r;break;case"muted":e.muted=r&&"function"!=typeof r&&"symbol"!=typeof r;break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":case"autoFocus":break;case"xlinkHref":if(null==r||"function"==typeof r||"boolean"==typeof r||"symbol"==typeof r){e.removeAttribute("xlink:href");break}n=Ct(""+r),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":null!=r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,""+r):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":!0===r?e.setAttribute(n,""):!1!==r&&null!=r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,r):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":null!=r&&"function"!=typeof r&&"symbol"!=typeof r&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case"rowSpan":case"start":null==r||"function"==typeof r||"symbol"==typeof r||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case"popover":$u("beforetoggle",e),$u("toggle",e),st(e,"popover",r);break;case"xlinkActuate":lt(e,"http://www.w3.org/1999/xlink","xlink:actuate",r);break;case"xlinkArcrole":lt(e,"http://www.w3.org/1999/xlink","xlink:arcrole",r);break;case"xlinkRole":lt(e,"http://www.w3.org/1999/xlink","xlink:role",r);break;case"xlinkShow":lt(e,"http://www.w3.org/1999/xlink","xlink:show",r);break;case"xlinkTitle":lt(e,"http://www.w3.org/1999/xlink","xlink:title",r);break;case"xlinkType":lt(e,"http://www.w3.org/1999/xlink","xlink:type",r);break;case"xmlBase":lt(e,"http://www.w3.org/XML/1998/namespace","xml:base",r);break;case"xmlLang":lt(e,"http://www.w3.org/XML/1998/namespace","xml:lang",r);break;case"xmlSpace":lt(e,"http://www.w3.org/XML/1998/namespace","xml:space",r);break;case"is":st(e,"is",r);break;case"innerText":case"textContent":break;default:(!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&&st(e,n=At.get(n)||n,r)}}function cd(e,t,n,r,a,s){switch(n){case"style":Et(e,r,s);break;case"dangerouslySetInnerHTML":if(null!=r){if("object"!=typeof r||!("__html"in r))throw Error(i(61));if(null!=(n=r.__html)){if(null!=a.children)throw Error(i(60));e.innerHTML=n}}break;case"children":"string"==typeof r?wt(e,r):("number"==typeof r||"bigint"==typeof r)&&wt(e,""+r);break;case"onScroll":null!=r&&$u("scroll",e);break;case"onScrollEnd":null!=r&&$u("scrollend",e);break;case"onClick":null!=r&&(e.onclick=Pt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:et.hasOwnProperty(n)||("o"!==n[0]||"n"!==n[1]||(a=n.endsWith("Capture"),t=n.slice(2,a?n.length-7:void 0),"function"==typeof(s=null!=(s=e[Be]||null)?s[n]:null)&&e.removeEventListener(t,s,a),"function"!=typeof r)?n in e?e[n]=r:!0===r?e.setAttribute(n,""):st(e,n,r):("function"!=typeof s&&null!==s&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a)))}}function ud(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":$u("error",e),$u("load",e);var r,a=!1,s=!1;for(r in n)if(n.hasOwnProperty(r)){var o=n[r];if(null!=o)switch(r){case"src":a=!0;break;case"srcSet":s=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,t));default:ld(e,t,r,o,n,null)}}return s&&ld(e,t,"srcSet",n.srcSet,n,null),void(a&&ld(e,t,"src",n.src,n,null));case"input":$u("invalid",e);var l=r=o=s=null,c=null,u=null;for(a in n)if(n.hasOwnProperty(a)){var d=n[a];if(null!=d)switch(a){case"name":s=d;break;case"type":o=d;break;case"checked":c=d;break;case"defaultChecked":u=d;break;case"value":r=d;break;case"defaultValue":l=d;break;case"children":case"dangerouslySetInnerHTML":if(null!=d)throw Error(i(137,t));break;default:ld(e,t,a,d,n,null)}}return void vt(e,r,l,c,u,o,s,!1);case"select":for(s in $u("invalid",e),a=o=r=null,n)if(n.hasOwnProperty(s)&&null!=(l=n[s]))switch(s){case"value":r=l;break;case"defaultValue":o=l;break;case"multiple":a=l;default:ld(e,t,s,l,n,null)}return t=r,n=o,e.multiple=!!a,void(null!=t?xt(e,!!a,t,!1):null!=n&&xt(e,!!a,n,!0));case"textarea":for(o in $u("invalid",e),r=s=a=null,n)if(n.hasOwnProperty(o)&&null!=(l=n[o]))switch(o){case"value":a=l;break;case"defaultValue":s=l;break;case"children":r=l;break;case"dangerouslySetInnerHTML":if(null!=l)throw Error(i(91));break;default:ld(e,t,o,l,n,null)}return void bt(e,a,s,r);case"option":for(c in n)n.hasOwnProperty(c)&&null!=(a=n[c])&&("selected"===c?e.selected=a&&"function"!=typeof a&&"symbol"!=typeof a:ld(e,t,c,a,n,null));return;case"dialog":$u("beforetoggle",e),$u("toggle",e),$u("cancel",e),$u("close",e);break;case"iframe":case"object":$u("load",e);break;case"video":case"audio":for(a=0;a<Wu.length;a++)$u(Wu[a],e);break;case"image":$u("error",e),$u("load",e);break;case"details":$u("toggle",e);break;case"embed":case"source":case"link":$u("error",e),$u("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(u in n)if(n.hasOwnProperty(u)&&null!=(a=n[u]))switch(u){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,t));default:ld(e,t,u,a,n,null)}return;default:if(Tt(t)){for(d in n)n.hasOwnProperty(d)&&void 0!==(a=n[d])&&cd(e,t,d,a,n,void 0);return}}for(l in n)n.hasOwnProperty(l)&&null!=(a=n[l])&&ld(e,t,l,a,n,null)}function dd(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}var hd=null,fd=null;function pd(e){return 9===e.nodeType?e:e.ownerDocument}function md(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function gd(e,t){if(0===e)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return 1===e&&"foreignObject"===t?0:e}function vd(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"bigint"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var yd=null,xd="function"==typeof setTimeout?setTimeout:void 0,_d="function"==typeof clearTimeout?clearTimeout:void 0,bd="function"==typeof Promise?Promise:void 0,wd="function"==typeof queueMicrotask?queueMicrotask:void 0!==bd?function(e){return bd.resolve(null).then(e).catch(Sd)}:xd;function Sd(e){setTimeout(function(){throw e})}function Md(e){return"head"===e}function Ed(e,t){var n=t,i=0;do{var r=n.nextSibling;if(e.removeChild(n),r&&8===r.nodeType)if("/$"===(n=r.data)||"/&"===n){if(0===i)return e.removeChild(r),void Hh(t);i--}else if("$"===n||"$?"===n||"$~"===n||"$!"===n||"&"===n)i++;else if("html"===n)kd(e.ownerDocument.documentElement);else if("head"===n){kd(n=e.ownerDocument.head);for(var a=n.firstChild;a;){var s=a.nextSibling,o=a.nodeName;a[Xe]||"SCRIPT"===o||"STYLE"===o||"LINK"===o&&"stylesheet"===a.rel.toLowerCase()||n.removeChild(a),a=s}}else"body"===n&&kd(e.ownerDocument.body);n=r}while(n);Hh(t)}function Td(e,t){var n=e;e=0;do{var i=n.nextSibling;if(1===n.nodeType?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",""===n.getAttribute("style")&&n.removeAttribute("style")):3===n.nodeType&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),i&&8===i.nodeType)if("/$"===(n=i.data)){if(0===e)break;e--}else"$"!==n&&"$?"!==n&&"$~"!==n&&"$!"!==n||e++;n=i}while(n)}function Ad(e){var t=e.firstChild;for(t&&10===t.nodeType&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":Ad(n),qe(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===n.rel.toLowerCase())continue}e.removeChild(n)}}function Rd(e,t){for(;8!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!t)return null;if(null===(e=Ld(e.nextSibling)))return null}return e}function Cd(e){return"$?"===e.data||"$~"===e.data}function Pd(e){return"$!"===e.data||"$?"===e.data&&"loading"!==e.ownerDocument.readyState}function Ld(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t||"$~"===t||"&"===t||"F!"===t||"F"===t)break;if("/$"===t||"/&"===t)return null}}return e}var Id=null;function Dd(e){e=e.nextSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("/$"===n||"/&"===n){if(0===t)return Ld(e.nextSibling);t--}else"$"!==n&&"$!"!==n&&"$?"!==n&&"$~"!==n&&"&"!==n||t++}e=e.nextSibling}return null}function Nd(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n||"$~"===n||"&"===n){if(0===t)return e;t--}else"/$"!==n&&"/&"!==n||t++}e=e.previousSibling}return null}function Od(e,t,n){switch(t=pd(n),e){case"html":if(!(e=t.documentElement))throw Error(i(452));return e;case"head":if(!(e=t.head))throw Error(i(453));return e;case"body":if(!(e=t.body))throw Error(i(454));return e;default:throw Error(i(451))}}function kd(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);qe(e)}var Ud=new Map,Fd=new Set;function zd(e){return"function"==typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var Bd=D.d;D.d={f:function(){var e=Bd.f(),t=Zc();return e||t},r:function(e){var t=Ye(e);null!==t&&5===t.tag&&"form"===t.type?eo(t):Bd.r(e)},D:function(e){Bd.D(e),Hd("dns-prefetch",e,null)},C:function(e,t){Bd.C(e,t),Hd("preconnect",e,t)},L:function(e,t,n){Bd.L(e,t,n);var i=Vd;if(i&&e&&t){var r='link[rel="preload"][as="'+mt(t)+'"]';"image"===t&&n&&n.imageSrcSet?(r+='[imagesrcset="'+mt(n.imageSrcSet)+'"]',"string"==typeof n.imageSizes&&(r+='[imagesizes="'+mt(n.imageSizes)+'"]')):r+='[href="'+mt(e)+'"]';var a=r;switch(t){case"style":a=jd(e);break;case"script":a=qd(e)}Ud.has(a)||(e=d({rel:"preload",href:"image"===t&&n&&n.imageSrcSet?void 0:e,as:t},n),Ud.set(a,e),null!==i.querySelector(r)||"style"===t&&i.querySelector(Wd(a))||"script"===t&&i.querySelector($d(a))||(ud(t=i.createElement("link"),"link",e),Qe(t),i.head.appendChild(t)))}},m:function(e,t){Bd.m(e,t);var n=Vd;if(n&&e){var i=t&&"string"==typeof t.as?t.as:"script",r='link[rel="modulepreload"][as="'+mt(i)+'"][href="'+mt(e)+'"]',a=r;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":a=qd(e)}if(!Ud.has(a)&&(e=d({rel:"modulepreload",href:e},t),Ud.set(a,e),null===n.querySelector(r))){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector($d(a)))return}ud(i=n.createElement("link"),"link",e),Qe(i),n.head.appendChild(i)}}},X:function(e,t){Bd.X(e,t);var n=Vd;if(n&&e){var i=Ze(n).hoistableScripts,r=qd(e),a=i.get(r);a||((a=n.querySelector($d(r)))||(e=d({src:e,async:!0},t),(t=Ud.get(r))&&Qd(e,t),Qe(a=n.createElement("script")),ud(a,"link",e),n.head.appendChild(a)),a={type:"script",instance:a,count:1,state:null},i.set(r,a))}},S:function(e,t,n){Bd.S(e,t,n);var i=Vd;if(i&&e){var r=Ze(i).hoistableStyles,a=jd(e);t=t||"default";var s=r.get(a);if(!s){var o={loading:0,preload:null};if(s=i.querySelector(Wd(a)))o.loading=5;else{e=d({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Ud.get(a))&&Zd(e,n);var l=s=i.createElement("link");Qe(l),ud(l,"link",e),l._p=new Promise(function(e,t){l.onload=e,l.onerror=t}),l.addEventListener("load",function(){o.loading|=1}),l.addEventListener("error",function(){o.loading|=2}),o.loading|=4,Kd(s,t,i)}s={type:"stylesheet",instance:s,count:1,state:o},r.set(a,s)}}},M:function(e,t){Bd.M(e,t);var n=Vd;if(n&&e){var i=Ze(n).hoistableScripts,r=qd(e),a=i.get(r);a||((a=n.querySelector($d(r)))||(e=d({src:e,async:!0,type:"module"},t),(t=Ud.get(r))&&Qd(e,t),Qe(a=n.createElement("script")),ud(a,"link",e),n.head.appendChild(a)),a={type:"script",instance:a,count:1,state:null},i.set(r,a))}}};var Vd="undefined"==typeof document?null:document;function Hd(e,t,n){var i=Vd;if(i&&"string"==typeof t&&t){var r=mt(t);r='link[rel="'+e+'"][href="'+r+'"]',"string"==typeof n&&(r+='[crossorigin="'+n+'"]'),Fd.has(r)||(Fd.add(r),e={rel:e,crossOrigin:n,href:t},null===i.querySelector(r)&&(ud(t=i.createElement("link"),"link",e),Qe(t),i.head.appendChild(t)))}}function Gd(e,t,n,r){var a,s,o,l,c=(c=j.current)?zd(c):null;if(!c)throw Error(i(446));switch(e){case"meta":case"title":return null;case"style":return"string"==typeof n.precedence&&"string"==typeof n.href?(t=jd(n.href),(r=(n=Ze(c).hoistableStyles).get(t))||(r={type:"style",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};case"link":if("stylesheet"===n.rel&&"string"==typeof n.href&&"string"==typeof n.precedence){e=jd(n.href);var u=Ze(c).hoistableStyles,d=u.get(e);if(d||(c=c.ownerDocument||c,d={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,d),(u=c.querySelector(Wd(e)))&&!u._p&&(d.instance=u,d.state.loading=5),Ud.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Ud.set(e,n),u||(a=c,s=e,o=n,l=d.state,a.querySelector('link[rel="preload"][as="style"]['+s+"]")?l.loading=1:(s=a.createElement("link"),l.preload=s,s.addEventListener("load",function(){return l.loading|=1}),s.addEventListener("error",function(){return l.loading|=2}),ud(s,"link",o),Qe(s),a.head.appendChild(s))))),t&&null===r)throw Error(i(528,""));return d}if(t&&null!==r)throw Error(i(529,""));return null;case"script":return t=n.async,"string"==typeof(n=n.src)&&t&&"function"!=typeof t&&"symbol"!=typeof t?(t=qd(n),(r=(n=Ze(c).hoistableScripts).get(t))||(r={type:"script",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,e))}}function jd(e){return'href="'+mt(e)+'"'}function Wd(e){return'link[rel="stylesheet"]['+e+"]"}function Xd(e){return d({},e,{"data-precedence":e.precedence,precedence:null})}function qd(e){return'[src="'+mt(e)+'"]'}function $d(e){return"script[async]"+e}function Yd(e,t,n){if(t.count++,null===t.instance)switch(t.type){case"style":var r=e.querySelector('style[data-href~="'+mt(n.href)+'"]');if(r)return t.instance=r,Qe(r),r;var a=d({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return Qe(r=(e.ownerDocument||e).createElement("style")),ud(r,"style",a),Kd(r,n.precedence,e),t.instance=r;case"stylesheet":a=jd(n.href);var s=e.querySelector(Wd(a));if(s)return t.state.loading|=4,t.instance=s,Qe(s),s;r=Xd(n),(a=Ud.get(a))&&Zd(r,a),Qe(s=(e.ownerDocument||e).createElement("link"));var o=s;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),ud(s,"link",r),t.state.loading|=4,Kd(s,n.precedence,e),t.instance=s;case"script":return s=qd(n.src),(a=e.querySelector($d(s)))?(t.instance=a,Qe(a),a):(r=n,(a=Ud.get(s))&&Qd(r=d({},n),a),Qe(a=(e=e.ownerDocument||e).createElement("script")),ud(a,"link",r),e.head.appendChild(a),t.instance=a);case"void":return null;default:throw Error(i(443,t.type))}else"stylesheet"===t.type&&!(4&t.state.loading)&&(r=t.instance,t.state.loading|=4,Kd(r,n.precedence,e));return t.instance}function Kd(e,t,n){for(var i=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=i.length?i[i.length-1]:null,a=r,s=0;s<i.length;s++){var o=i[s];if(o.dataset.precedence===t)a=o;else if(a!==r)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=9===n.nodeType?n.head:n).insertBefore(e,t.firstChild)}function Zd(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function Qd(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var Jd=null;function eh(e,t,n){if(null===Jd){var i=new Map,r=Jd=new Map;r.set(n,i)}else(i=(r=Jd).get(n))||(i=new Map,r.set(n,i));if(i.has(e))return i;for(i.set(e,null),n=n.getElementsByTagName(e),r=0;r<n.length;r++){var a=n[r];if(!(a[Xe]||a[ze]||"link"===e&&"stylesheet"===a.getAttribute("rel"))&&"http://www.w3.org/2000/svg"!==a.namespaceURI){var s=a.getAttribute(t)||"";s=e+s;var o=i.get(s);o?o.push(a):i.set(s,[a])}}return i}function th(e,t,n){(e=e.ownerDocument||e).head.insertBefore(n,"title"===t?e.querySelector("head > title"):null)}function nh(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var ih=0;function rh(){if(this.count--,0===this.count&&(0===this.imgCount||!this.waitingForImages))if(this.stylesheets)sh(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var ah=null;function sh(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,ah=new Map,t.forEach(oh,e),ah=null,rh.call(e))}function oh(e,t){if(!(4&t.state.loading)){var n=ah.get(e);if(n)var i=n.get(null);else{n=new Map,ah.set(e,n);for(var r=e.querySelectorAll("link[data-precedence],style[data-precedence]"),a=0;a<r.length;a++){var s=r[a];"LINK"!==s.nodeName&&"not all"===s.getAttribute("media")||(n.set(s.dataset.precedence,s),i=s)}i&&n.set(null,i)}s=(r=t.instance).getAttribute("data-precedence"),(a=n.get(s)||i)===i&&n.set(null,r),n.set(s,r),this.count++,i=rh.bind(this),r.addEventListener("load",i),r.addEventListener("error",i),a?a.parentNode.insertBefore(r,a.nextSibling):(e=9===e.nodeType?e.head:e).insertBefore(r,e.firstChild),t.state.loading|=4}}var lh={$$typeof:x,Provider:null,Consumer:null,_currentValue:N,_currentValue2:N,_threadCount:0};function ch(e,t,n,i,r,a,s,o,l){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ce(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ce(0),this.hiddenUpdates=Ce(null),this.identifierPrefix=i,this.onUncaughtError=r,this.onCaughtError=a,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function uh(e,t,n,i,r,a,s,o,l,c,u,d){return e=new ch(e,t,n,s,l,c,u,d,o),t=1,!0===a&&(t|=24),a=ki(3,null,null,t),e.current=a,a.stateNode=e,(t=Ur()).refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:i,isDehydrated:n,cache:t},pa(a),e}function dh(e){return e?e=Ni:Ni}function hh(e,t,n,i,r,a){r=dh(r),null===i.context?i.context=r:i.pendingContext=r,(i=ga(t)).payload={element:n},null!==(a=void 0===a?null:a)&&(i.callback=a),null!==(n=va(e,i,t))&&(Xc(n,0,t),ya(n,e,t))}function fh(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function ph(e,t){fh(e,t),(e=e.alternate)&&fh(e,t)}function mh(e){if(13===e.tag||31===e.tag){var t=Li(e,67108864);null!==t&&Xc(t,0,67108864),ph(e,67108864)}}function gh(e){if(13===e.tag||31===e.tag){var t=jc(),n=Li(e,t=Ne(t));null!==n&&Xc(n,0,t),ph(e,t)}}var vh=!0;function yh(e,t,n,i){var r=I.T;I.T=null;var a=D.p;try{D.p=2,_h(e,t,n,i)}finally{D.p=a,I.T=r}}function xh(e,t,n,i){var r=I.T;I.T=null;var a=D.p;try{D.p=8,_h(e,t,n,i)}finally{D.p=a,I.T=r}}function _h(e,t,n,i){if(vh){var r=bh(i);if(null===r)Ju(e,t,i,wh,n),Dh(e,i);else if(function(e,t,n,i,r){switch(t){case"focusin":return Th=Nh(Th,e,t,n,i,r),!0;case"dragenter":return Ah=Nh(Ah,e,t,n,i,r),!0;case"mouseover":return Rh=Nh(Rh,e,t,n,i,r),!0;case"pointerover":var a=r.pointerId;return Ch.set(a,Nh(Ch.get(a)||null,e,t,n,i,r)),!0;case"gotpointercapture":return a=r.pointerId,Ph.set(a,Nh(Ph.get(a)||null,e,t,n,i,r)),!0}return!1}(r,e,t,n,i))i.stopPropagation();else if(Dh(e,i),4&t&&-1<Ih.indexOf(e)){for(;null!==r;){var a=Ye(r);if(null!==a)switch(a.tag){case 3:if((a=a.stateNode).current.memoizedState.isDehydrated){var s=Me(a.pendingLanes);if(0!==s){var o=a;for(o.pendingLanes|=2,o.entangledLanes|=2;s;){var l=1<<31-ye(s);o.entanglements[1]|=l,s&=~l}Du(a),!(6&dc)&&(Ic=se()+500,Nu(0))}}break;case 31:case 13:null!==(o=Li(a,2))&&Xc(o,0,2),Zc(),ph(a,2)}if(null===(a=bh(i))&&Ju(e,t,i,wh,n),a===r)break;r=a}null!==r&&i.stopPropagation()}else Ju(e,t,i,null,n)}}function bh(e){return Sh(e=It(e))}var wh=null;function Sh(e){if(wh=null,null!==(e=$e(e))){var t=a(e);if(null===t)e=null;else{var n=t.tag;if(13===n){if(null!==(e=s(t)))return e;e=null}else if(31===n){if(null!==(e=l(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return wh=e,null}function Mh(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(oe()){case le:return 2;case ce:return 8;case ue:case de:return 32;case he:return 268435456;default:return 32}default:return 32}}var Eh=!1,Th=null,Ah=null,Rh=null,Ch=new Map,Ph=new Map,Lh=[],Ih="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Dh(e,t){switch(e){case"focusin":case"focusout":Th=null;break;case"dragenter":case"dragleave":Ah=null;break;case"mouseover":case"mouseout":Rh=null;break;case"pointerover":case"pointerout":Ch.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ph.delete(t.pointerId)}}function Nh(e,t,n,i,r,a){return null===e||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:i,nativeEvent:a,targetContainers:[r]},null!==t&&null!==(t=Ye(t))&&mh(t),e):(e.eventSystemFlags|=i,t=e.targetContainers,null!==r&&-1===t.indexOf(r)&&t.push(r),e)}function Oh(e){var t=$e(e.target);if(null!==t){var n=a(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=s(n)))return e.blockedOn=t,void Ue(e.priority,function(){gh(n)})}else if(31===t){if(null!==(t=l(n)))return e.blockedOn=t,void Ue(e.priority,function(){gh(n)})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function kh(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=bh(e.nativeEvent);if(null!==n)return null!==(t=Ye(n))&&mh(t),e.blockedOn=n,!1;var i=new(n=e.nativeEvent).constructor(n.type,n);Lt=i,n.target.dispatchEvent(i),Lt=null,t.shift()}return!0}function Uh(e,t,n){kh(e)&&n.delete(t)}function Fh(){Eh=!1,null!==Th&&kh(Th)&&(Th=null),null!==Ah&&kh(Ah)&&(Ah=null),null!==Rh&&kh(Rh)&&(Rh=null),Ch.forEach(Uh),Ph.forEach(Uh)}function zh(t,n){t.blockedOn===n&&(t.blockedOn=null,Eh||(Eh=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Fh)))}var Bh=null;function Vh(t){Bh!==t&&(Bh=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Bh===t&&(Bh=null);for(var e=0;e<t.length;e+=3){var n=t[e],i=t[e+1],r=t[e+2];if("function"!=typeof i){if(null===Sh(i||n))continue;break}var a=Ye(n);null!==a&&(t.splice(e,3),e-=3,Qs(a,{pending:!0,data:r,method:n.method,action:i},i,r))}}))}function Hh(e){function t(t){return zh(t,e)}null!==Th&&zh(Th,e),null!==Ah&&zh(Ah,e),null!==Rh&&zh(Rh,e),Ch.forEach(t),Ph.forEach(t);for(var n=0;n<Lh.length;n++){var i=Lh[n];i.blockedOn===e&&(i.blockedOn=null)}for(;0<Lh.length&&null===(n=Lh[0]).blockedOn;)Oh(n),null===n.blockedOn&&Lh.shift();if(null!=(n=(e.ownerDocument||e).$$reactFormReplay))for(i=0;i<n.length;i+=3){var r=n[i],a=n[i+1],s=r[Be]||null;if("function"==typeof a)s||Vh(n);else if(s){var o=null;if(a&&a.hasAttribute("formAction")){if(r=a,s=a[Be]||null)o=s.formAction;else if(null!==Sh(r))continue}else o=s.action;"function"==typeof o?n[i+1]=o:(n.splice(i,3),i-=3),Vh(n)}}}function Gh(){function e(e){e.canIntercept&&"react-transition"===e.info&&e.intercept({handler:function(){return new Promise(function(e){return r=e})},focusReset:"manual",scroll:"manual"})}function t(){null!==r&&(r(),r=null),i||setTimeout(n,20)}function n(){if(!i&&!navigation.transition){var e=navigation.currentEntry;e&&null!=e.url&&navigation.navigate(e.url,{state:e.getState(),info:"react-transition",history:"replace"})}}if("object"==typeof navigation){var i=!1,r=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),null!==r&&(r(),r=null)}}}function jh(e){this._internalRoot=e}function Wh(e){this._internalRoot=e}Wh.prototype.render=jh.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(i(409));hh(t.current,jc(),e,t,null,null)},Wh.prototype.unmount=jh.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;hh(e.current,2,null,e,null,null),Zc(),t[Ve]=null}},Wh.prototype.unstable_scheduleHydration=function(e){if(e){var t=ke();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Lh.length&&0!==t&&t<Lh[n].priority;n++);Lh.splice(n,0,e),0===n&&Oh(e)}};var Xh=t.version;if("19.2.0"!==Xh)throw Error(i(527,Xh,"19.2.0"));D.findDOMNode=function(e){var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(i(188));throw e=Object.keys(e).join(","),Error(i(268,e))}return e=function(e){var t=e.alternate;if(!t){if(null===(t=a(e)))throw Error(i(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(null===s)break;var o=s.alternate;if(null===o){if(null!==(r=s.return)){n=r;continue}break}if(s.child===o.child){for(o=s.child;o;){if(o===n)return c(s),e;if(o===r)return c(s),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=s,r=o;else{for(var l=!1,u=s.child;u;){if(u===n){l=!0,n=s,r=o;break}if(u===r){l=!0,r=s,n=o;break}u=u.sibling}if(!l){for(u=o.child;u;){if(u===n){l=!0,n=o,r=s;break}if(u===r){l=!0,r=o,n=s;break}u=u.sibling}if(!l)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(3!==n.tag)throw Error(i(188));return n.stateNode.current===n?e:t}(t),null===(e=null!==e?u(e):null)?null:e.stateNode};var qh={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:I,reconcilerVersion:"19.2.0"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var $h=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!$h.isDisabled&&$h.supportsFiber)try{me=$h.inject(qh),ge=$h}catch(e){}}return Cx.createRoot=function(e,t){if(!r(e))throw Error(i(299));var n=!1,a="",s=wo,o=So,l=Mo;return null!=t&&(!0===t.unstable_strictMode&&(n=!0),void 0!==t.identifierPrefix&&(a=t.identifierPrefix),void 0!==t.onUncaughtError&&(s=t.onUncaughtError),void 0!==t.onCaughtError&&(o=t.onCaughtError),void 0!==t.onRecoverableError&&(l=t.onRecoverableError)),t=uh(e,1,!1,null,0,n,a,null,s,o,l,Gh),e[Ve]=t.current,Zu(e),new jh(t)},Cx.hydrateRoot=function(e,t,n){if(!r(e))throw Error(i(299));var a=!1,s="",o=wo,l=So,c=Mo,u=null;return null!=n&&(!0===n.unstable_strictMode&&(a=!0),void 0!==n.identifierPrefix&&(s=n.identifierPrefix),void 0!==n.onUncaughtError&&(o=n.onUncaughtError),void 0!==n.onCaughtError&&(l=n.onCaughtError),void 0!==n.onRecoverableError&&(c=n.onRecoverableError),void 0!==n.formState&&(u=n.formState)),(t=uh(e,1,!0,t,0,a,s,u,o,l,c,Gh)).context=dh(null),n=t.current,(s=ga(a=Ne(a=jc()))).callback=null,va(n,s,a),n=a,t.current.lanes=n,Pe(t,n),Du(t),e[Ve]=t.current,Zu(e),new Wh(t)},Cx.version="19.2.0",Cx}();var zx=Rx.exports;class Bx{constructor(e){this.version="2.2.0",e.ipd=0,yo.getState().setInputMode(e.primaryInputMode),this.devUIContainer=document.createElement("div"),this.devUIContainer.style.position="fixed",this.devUIContainer.style.width="100vw",this.devUIContainer.style.height="100vh",this.devUIContainer.style.top="50vh",this.devUIContainer.style.left="50vw",this.devUIContainer.style.transform="translate(-50%, -50%)",this.devUIContainer.style.pointerEvents="none";const t=this.devUIContainer.attachShadow({mode:"open"});this.inputLayer=new Ex(e),this.unsubscribeControlMode=e.onControlModeChange(e=>{this.inputLayer.isInProgrammaticMode="programmatic"===e,"programmatic"===e?(this.inputLayer.syncFromDevice(),this.inputLayer.setInteractionsEnabled(!1)):this.inputLayer.setInteractionsEnabled(!0)}),this.unsubscribeStateChange=e.onStateChange(()=>{this.inputLayer.isInProgrammaticMode&&this.inputLayer.syncFromDevice()});zx.createRoot(t).render(c.jsx(Vx,{xrDevice:e,inputLayer:this.inputLayer,shadowRoot:t}));const n=()=>{const t=document.createElement("div");document.body.appendChild(t);const n=t.attachShadow({mode:"open"});zx.createRoot(n).render(c.jsx(Hx,{xrDevice:e,shadowRoot:n}))};document.body?n():window.onload=n}render(e){this.inputLayer.renderScene(e)}dispose(){this.unsubscribeControlMode(),this.unsubscribeStateChange(),this.inputLayer.dispose()}get devUICanvas(){return this.inputLayer.domElement}}const Vx=({xrDevice:e,inputLayer:t,shadowRoot:n})=>{const[i,r]=o.useState(!1),[a,s]=o.useState(e.controlMode);return o.useEffect(()=>{const t=()=>{const e=document.pointerLockElement||document.mozPointerLockElement||document.webkitPointerLockElement;r(!!e)};document.addEventListener("pointerlockchange",t,!1),document.addEventListener("mozpointerlockchange",t,!1),document.addEventListener("webkitpointerlockchange",t,!1);const n=e.onControlModeChange(e=>{s(e)});return()=>{document.removeEventListener("pointerlockchange",t,!1),document.removeEventListener("mozpointerlockchange",t,!1),document.removeEventListener("webkitpointerlockchange",t,!1),n()}},[e]),c.jsx(aa,{target:n,disableCSSOMInjection:!0,children:c.jsxs("div",{style:{width:"100vw",height:"100vh",display:"flex",flexDirection:"column",justifyContent:"space-between",pointerEvents:"none"},children:["programmatic"===a&&c.jsxs(c.Fragment,{children:[c.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:999,boxShadow:"inset 0 0 20px 5px rgba(59, 130, 246, 0.5)"}}),c.jsxs("div",{style:{position:"absolute",bottom:"8px",left:"50%",transform:"translateX(-50%)",backgroundColor:"rgba(59, 130, 246, 0.9)",color:"white",padding:"6px 16px",borderRadius:"16px",fontSize:"12px",fontFamily:"system-ui, sans-serif",fontWeight:500,zIndex:1e3,display:"flex",alignItems:"center",gap:"6px",boxShadow:"0 2px 8px rgba(0,0,0,0.3)"},children:[c.jsx("span",{style:{fontSize:"14px"},children:"●"}),"Remote Control Active"]})]}),"programmatic"!==a&&c.jsxs(c.Fragment,{children:[c.jsx(Mo,{xrDevice:e,inputLayer:t}),c.jsx(Ao,{xrDevice:e,inputLayer:t,pointerLocked:i}),c.jsx(xo,{xrDevice:e,inputLayer:t,pointerLocked:i})]})]})})},Hx=({xrDevice:e,shadowRoot:t})=>{const[n,i]=l.useState(e.sessionOffered&&!e.activeSession);return l.useEffect(()=>{setInterval(()=>{i(e.sessionOffered&&!e.activeSession)},1e3)},[]),c.jsx(aa,{target:t,disableCSSOMInjection:!0,children:c.jsxs(Wa,{style:{zIndex:899,position:"fixed",top:n?"8px":"-30px",display:"flex",flexDirection:"row",alignItems:"center",justifyItems:"space-between",left:"50vw",transform:"translateX(-50%)",transition:"all 0.2s ease-in-out",paddingLeft:"5px",gap:"3px"},children:[c.jsx(Ls,{size:24}),c.jsx(Xa,{onClick:()=>{e.grantOfferedSession()},style:{fontSize:"16px"},children:"Enter XR"})]})})};var Gx=1e-6,jx="undefined"!=typeof Float32Array?Float32Array:Array;function Wx(){var e=new jx(16);return jx!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Xx(e){var t=new jx(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function qx(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function $x(e,t){var n=t[0],i=t[1],r=t[2],a=t[3],s=t[4],o=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],f=t[11],p=t[12],m=t[13],g=t[14],v=t[15],y=n*o-i*s,x=n*l-r*s,_=n*c-a*s,b=i*l-r*o,w=i*c-a*o,S=r*c-a*l,M=u*m-d*p,E=u*g-h*p,T=u*v-f*p,A=d*g-h*m,R=d*v-f*m,C=h*v-f*g,P=y*C-x*R+_*A+b*T-w*E+S*M;return P?(P=1/P,e[0]=(o*C-l*R+c*A)*P,e[1]=(r*R-i*C-a*A)*P,e[2]=(m*S-g*w+v*b)*P,e[3]=(h*w-d*S-f*b)*P,e[4]=(l*T-s*C-c*E)*P,e[5]=(n*C-r*T+a*E)*P,e[6]=(g*_-p*S-v*x)*P,e[7]=(u*S-h*_+f*x)*P,e[8]=(s*R-o*T+c*M)*P,e[9]=(i*T-n*R-a*M)*P,e[10]=(p*w-m*_+v*y)*P,e[11]=(d*_-u*w-f*y)*P,e[12]=(o*E-s*A-l*M)*P,e[13]=(n*A-i*E+r*M)*P,e[14]=(m*x-p*b-g*y)*P,e[15]=(u*b-d*x+h*y)*P,e):null}function Yx(e,t,n){var i=t[0],r=t[1],a=t[2],s=t[3],o=t[4],l=t[5],c=t[6],u=t[7],d=t[8],h=t[9],f=t[10],p=t[11],m=t[12],g=t[13],v=t[14],y=t[15],x=n[0],_=n[1],b=n[2],w=n[3];return e[0]=x*i+_*o+b*d+w*m,e[1]=x*r+_*l+b*h+w*g,e[2]=x*a+_*c+b*f+w*v,e[3]=x*s+_*u+b*p+w*y,x=n[4],_=n[5],b=n[6],w=n[7],e[4]=x*i+_*o+b*d+w*m,e[5]=x*r+_*l+b*h+w*g,e[6]=x*a+_*c+b*f+w*v,e[7]=x*s+_*u+b*p+w*y,x=n[8],_=n[9],b=n[10],w=n[11],e[8]=x*i+_*o+b*d+w*m,e[9]=x*r+_*l+b*h+w*g,e[10]=x*a+_*c+b*f+w*v,e[11]=x*s+_*u+b*p+w*y,x=n[12],_=n[13],b=n[14],w=n[15],e[12]=x*i+_*o+b*d+w*m,e[13]=x*r+_*l+b*h+w*g,e[14]=x*a+_*c+b*f+w*v,e[15]=x*s+_*u+b*p+w*y,e}function Kx(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function Zx(e,t,n){var i,r,a,s=n[0],o=n[1],l=n[2],c=Math.sqrt(s*s+o*o+l*l);return c<Gx?null:(s*=c=1/c,o*=c,l*=c,i=Math.sin(t),a=1-(r=Math.cos(t)),e[0]=s*s*a+r,e[1]=o*s*a+l*i,e[2]=l*s*a-o*i,e[3]=0,e[4]=s*o*a-l*i,e[5]=o*o*a+r,e[6]=l*o*a+s*i,e[7]=0,e[8]=s*l*a+o*i,e[9]=o*l*a-s*i,e[10]=l*l*a+r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function Qx(e,t,n){var i=t[0],r=t[1],a=t[2],s=t[3],o=i+i,l=r+r,c=a+a,u=i*o,d=i*l,h=i*c,f=r*l,p=r*c,m=a*c,g=s*o,v=s*l,y=s*c;return e[0]=1-(f+m),e[1]=d+y,e[2]=h-v,e[3]=0,e[4]=d-y,e[5]=1-(u+m),e[6]=p+g,e[7]=0,e[8]=h+v,e[9]=p-g,e[10]=1-(u+f),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Jx(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function e_(e,t){var n=t[0],i=t[1],r=t[2],a=t[4],s=t[5],o=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.sqrt(n*n+i*i+r*r),e[1]=Math.sqrt(a*a+s*s+o*o),e[2]=Math.sqrt(l*l+c*c+u*u),e}function t_(e,t){var n=new jx(3);e_(n,t);var i=1/n[0],r=1/n[1],a=1/n[2],s=t[0]*i,o=t[1]*r,l=t[2]*a,c=t[4]*i,u=t[5]*r,d=t[6]*a,h=t[8]*i,f=t[9]*r,p=t[10]*a,m=s+u+p,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(d-f)/g,e[1]=(h-l)/g,e[2]=(o-c)/g):s>u&&s>p?(g=2*Math.sqrt(1+s-u-p),e[3]=(d-f)/g,e[0]=.25*g,e[1]=(o+c)/g,e[2]=(h+l)/g):u>p?(g=2*Math.sqrt(1+u-s-p),e[3]=(h-l)/g,e[0]=(o+c)/g,e[1]=.25*g,e[2]=(d+f)/g):(g=2*Math.sqrt(1+p-s-u),e[3]=(o-c)/g,e[0]=(h+l)/g,e[1]=(d+f)/g,e[2]=.25*g),e}var n_=function(e,t,n,i,r){var a=1/Math.tan(t/2);if(e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=r&&r!==1/0){var s=1/(i-r);e[10]=(r+i)*s,e[14]=2*r*i*s}else e[10]=-1,e[14]=-2*i;return e};function i_(){var e=new jx(3);return jx!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function r_(e,t,n){var i=new jx(3);return i[0]=e,i[1]=t,i[2]=n,i}function a_(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function s_(e,t,n,i){return e[0]=t,e[1]=n,e[2]=i,e}function o_(e,t){var n=t[0],i=t[1],r=t[2],a=n*n+i*i+r*r;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e}function l_(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function c_(e,t,n){var i=t[0],r=t[1],a=t[2],s=n[0],o=n[1],l=n[2];return e[0]=r*l-a*o,e[1]=a*s-i*l,e[2]=i*o-r*s,e}function u_(e,t,n,i){var r=t[0],a=t[1],s=t[2];return e[0]=r+i*(n[0]-r),e[1]=a+i*(n[1]-a),e[2]=s+i*(n[2]-s),e}function d_(){var e=new jx(4);return jx!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function h_(e,t,n,i,r){return e[0]=t,e[1]=n,e[2]=i,e[3]=r,e}function f_(e,t,n){var i=t[0],r=t[1],a=t[2],s=t[3];return e[0]=n[0]*i+n[4]*r+n[8]*a+n[12]*s,e[1]=n[1]*i+n[5]*r+n[9]*a+n[13]*s,e[2]=n[2]*i+n[6]*r+n[10]*a+n[14]*s,e[3]=n[3]*i+n[7]*r+n[11]*a+n[15]*s,e}function p_(){var e=new jx(4);return jx!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function m_(e,t,n){n*=.5;var i=Math.sin(n);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(n),e}function g_(e,t,n,i){var r,a,s,o,l,c=t[0],u=t[1],d=t[2],h=t[3],f=n[0],p=n[1],m=n[2],g=n[3];return(a=c*f+u*p+d*m+h*g)<0&&(a=-a,f=-f,p=-p,m=-m,g=-g),1-a>Gx?(r=Math.acos(a),s=Math.sin(r),o=Math.sin((1-i)*r)/s,l=Math.sin(i*r)/s):(o=1-i,l=i),e[0]=o*c+l*f,e[1]=o*u+l*p,e[2]=o*d+l*m,e[3]=o*h+l*g,e}i_(),function(){var e=d_()}();var v_,y_=function(e,t,n,i){var r=new jx(4);return r[0]=e,r[1]=t,r[2]=n,r[3]=i,r},x_=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},__=h_,b_=function(e,t){var n=t[0],i=t[1],r=t[2],a=t[3],s=n*n+i*i+r*r+a*a;return s>0&&(s=1/Math.sqrt(s)),e[0]=n*s,e[1]=i*s,e[2]=r*s,e[3]=a*s,e};i_(),r_(1,0,0),r_(0,1,0),p_(),p_(),v_=new jx(9),jx!=Float32Array&&(v_[1]=0,v_[2]=0,v_[3]=0,v_[5]=0,v_[6]=0,v_[7]=0),v_[0]=1,v_[4]=1,v_[8]=1;const w_=Symbol("@iwer/action-player"),S_=Symbol("@iwer/xr-anchor"),M_=Symbol("@iwer/xr-controller"),E_=Symbol("@iwer/xr-device"),T_=Symbol("@iwer/xr-hand-input"),A_=Symbol("@iwer/xr-tracked-input"),R_=Symbol("@iwer/xr-frame"),C_=Symbol("@iwer/gamepad"),P_=Symbol("@iwer/xr-system"),L_=Symbol("@iwer/xr-input-source"),I_=Symbol("@iwer/xr-webgl-layer"),D_=Symbol("@iwer/xr-mesh"),N_=Symbol("@iwer/xr-plane"),O_=Symbol("@iwer/xr-joint-pose"),k_=Symbol("@iwer/xr-pose"),U_=Symbol("@iwer/xr-viewer-pose"),F_=Symbol("@iwer/xr-rigid-transform"),z_=Symbol("@iwer/xr-render-state"),B_=Symbol("@iwer/xr-session"),V_=Symbol("@iwer/xr-joint-space"),H_=Symbol("@iwer/xr-reference-space"),G_=Symbol("@iwer/xr-space"),j_=Symbol("@iwer/xr-view"),W_=Symbol("@iwer/xr-viewport"),X_=Symbol("@iwer/xr-ray"),q_=Symbol("@iwer/xr-hit-test");class $_ extends EventTarget{constructor(e,t){super(),this[G_]={parentSpace:e,offsetMatrix:t?Xx(t):Wx(),emulated:!0}}}class Y_ extends $_{constructor(){super(void 0,Wx())}}class K_{static updateOffsetPosition(e,t){Kx(e[G_].offsetMatrix,t)}static updateOffsetQuaternion(e,t){const n=e[G_].offsetMatrix,i=i_();Jx(i,n),Qx(n,t,i)}static updateOffsetMatrix(e,t){qx(e[G_].offsetMatrix,t)}static calculateGlobalOffsetMatrix(e,t=Wx()){return Yx(t,e[G_].parentSpace?K_.calculateGlobalOffsetMatrix(e[G_].parentSpace):Wx(),e[G_].offsetMatrix),t}}let Z_=class e{constructor(e=0,t=0,n=0){this.vec3=r_(e,t,n),this.tempVec3=i_()}get x(){return this.vec3[0]}set x(e){this.vec3[0]=e}get y(){return this.vec3[1]}set y(e){this.vec3[1]=e}get z(){return this.vec3[2]}set z(e){this.vec3[2]=e}set(e,t,n){return s_(this.vec3,e,t,n),this}clone(){return new e(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}normalize(){return a_(this.tempVec3,this.vec3),o_(this.vec3,this.tempVec3),this}add(e){return a_(this.tempVec3,this.vec3),function(e,t,n){e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2]}(this.vec3,this.tempVec3,e.vec3),this}applyQuaternion(e){return a_(this.tempVec3,this.vec3),function(e,t,n){var i=n[0],r=n[1],a=n[2],s=n[3],o=t[0],l=t[1],c=t[2],u=r*c-a*l,d=a*o-i*c,h=i*l-r*o;u+=u,d+=d,h+=h,e[0]=o+s*u+r*h-a*d,e[1]=l+s*d+a*u-i*h,e[2]=c+s*h+i*d-r*u}(this.vec3,this.tempVec3,e.quat),this}},Q_=class e{constructor(e=0,t=0,n=0,i=1){this.quat=y_(e,t,n,i),this.tempQuat=p_()}get x(){return this.quat[0]}set x(e){this.quat[0]=e}get y(){return this.quat[1]}set y(e){this.quat[1]=e}get z(){return this.quat[2]}set z(e){this.quat[2]=e}get w(){return this.quat[3]}set w(e){this.quat[3]=e}set(e,t,n,i){return __(this.quat,e,t,n,i),this}clone(){return new e(this.x,this.y,this.z,this.w)}copy(e){return __(this.quat,e.x,e.y,e.z,e.w),this}normalize(){return x_(this.tempQuat,this.quat),b_(this.quat,this.tempQuat),this}invert(){return x_(this.tempQuat,this.quat),function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(this.quat,this.tempQuat),this}multiply(e){return x_(this.tempQuat,this.quat),function(e,t,n){var i=t[0],r=t[1],a=t[2],s=t[3],o=n[0],l=n[1],c=n[2],u=n[3];e[0]=i*u+s*o+r*c-a*l,e[1]=r*u+s*l+a*o-i*c,e[2]=a*u+s*c+i*l-r*o,e[3]=s*u-i*o-r*l-a*c}(this.quat,this.tempQuat,e.quat),this}setFromAxisAngle(e,t){return m_(this.quat,e.vec3,t),this}};function J_(e){return{x:e.x,y:e.y,z:e.z}}function eb(e){return{x:e.x,y:e.y,z:e.z,w:e.w}}function tb(e){const{x:t,y:n,z:i,w:r}=e,a=180/Math.PI,s=Math.max(-1,Math.min(1,2*(r*t-n*i)));let o;o=Math.abs(s)>=1?Math.sign(s)*Math.PI/2:Math.asin(s);const l=2*(r*n+t*i),c=1-2*(t*t+n*n),u=2*(r*i+t*n),d=1-2*(t*t+i*i);return{pitch:o*a,yaw:Math.atan2(l,c)*a,roll:Math.atan2(u,d)*a}}function nb(e){var t,n,i;const r=Math.PI/180,a=(null!==(t=e.pitch)&&void 0!==t?t:0)*r,s=(null!==(n=e.yaw)&&void 0!==n?n:0)*r,o=(null!==(i=e.roll)&&void 0!==i?i:0)*r,l=Math.cos(.5*a),c=Math.sin(.5*a),u=Math.cos(.5*s),d=Math.sin(.5*s),h=Math.cos(.5*o),f=Math.sin(.5*o);return{w:l*u*h+c*d*f,x:c*u*h+l*d*f,y:l*d*h-c*u*f,z:l*u*f-c*d*h}}function ib(e){return function(e){return"pitch"in e||"yaw"in e||"roll"in e}(e)?nb(e):e}function rb(e,t,n){return e+(t-e)*n}class ab{constructor(e){this.commandQueue=[],this._isCaptured=!1,this.releaseTimer=null,this.actionIdCounter=0,this.RELEASE_TIMEOUT_MS=3e4,this.device=e}generateActionId(){return"action_"+ ++this.actionIdCounter}get isCaptured(){return this._isCaptured}get queueLength(){return this.commandQueue.length}enqueueDiscrete(e,t){return new Promise((n,i)=>{const r={type:"discrete",id:this.generateActionId(),method:e,params:t,resolve:n,reject:i};this.commandQueue.push(r)})}enqueueDuration(e,t,n,i,r){return new Promise((a,s)=>{const o={type:"duration",id:this.generateActionId(),method:e,params:t,durationMs:n,elapsedMs:0,startState:i,targetState:r,resolve:a,reject:s};this.commandQueue.push(o)})}update(e){if(0!==this.commandQueue.length){for(this.cancelReleaseTimer(),this._isCaptured||(this._isCaptured=!0,this.device.controlMode="programmatic");this.commandQueue.length>0;){const t=this.commandQueue[0];if("discrete"===t.type){try{const e=this.executeDiscreteAction(t);t.resolve(e)}catch(e){t.reject(e)}this.commandQueue.shift()}else{if(t.elapsedMs+=e,!(t.elapsedMs>=t.durationMs)){const e=t.elapsedMs/t.durationMs;this.applyDurationLerpState(t,e);break}this.applyDurationFinalState(t),t.resolve(this.getDurationResult(t)),this.commandQueue.shift()}}this.device.notifyStateChange(),0===this.commandQueue.length&&this.startReleaseTimer()}}startReleaseTimer(){this.cancelReleaseTimer(),this.releaseTimer=setTimeout(()=>{this._isCaptured=!1,this.device.controlMode="manual",this.releaseTimer=null},this.RELEASE_TIMEOUT_MS)}cancelReleaseTimer(){null!==this.releaseTimer&&(clearTimeout(this.releaseTimer),this.releaseTimer=null)}getDeviceTransform(e){switch(e){case"headset":return{position:J_(this.device.position),orientation:eb(this.device.quaternion)};case"controller-left":{const e=this.device.controllers.left;if(!e)throw new Error("Left controller not available");return{position:J_(e.position),orientation:eb(e.quaternion)}}case"controller-right":{const e=this.device.controllers.right;if(!e)throw new Error("Right controller not available");return{position:J_(e.position),orientation:eb(e.quaternion)}}case"hand-left":{const e=this.device.hands.left;if(!e)throw new Error("Left hand not available");return{position:J_(e.position),orientation:eb(e.quaternion)}}case"hand-right":{const e=this.device.hands.right;if(!e)throw new Error("Right hand not available");return{position:J_(e.position),orientation:eb(e.quaternion)}}default:throw new Error(`Unknown device: ${e}`)}}setDeviceTransform(e,t,n){switch(e){case"headset":t&&this.device.position.set(t.x,t.y,t.z),n&&this.device.quaternion.set(n.x,n.y,n.z,n.w);break;case"controller-left":{const e=this.device.controllers.left;if(!e)throw new Error("Left controller not available");t&&e.position.set(t.x,t.y,t.z),n&&e.quaternion.set(n.x,n.y,n.z,n.w);break}case"controller-right":{const e=this.device.controllers.right;if(!e)throw new Error("Right controller not available");t&&e.position.set(t.x,t.y,t.z),n&&e.quaternion.set(n.x,n.y,n.z,n.w);break}case"hand-left":{const e=this.device.hands.left;if(!e)throw new Error("Left hand not available");t&&e.position.set(t.x,t.y,t.z),n&&e.quaternion.set(n.x,n.y,n.z,n.w);break}case"hand-right":{const e=this.device.hands.right;if(!e)throw new Error("Right hand not available");t&&e.position.set(t.x,t.y,t.z),n&&e.quaternion.set(n.x,n.y,n.z,n.w);break}default:throw new Error(`Unknown device: ${e}`)}}transformXROriginToGlobal(e){var t,n;const i=this.device.activeSession;if(!i)return e;const r=null===(t=i[B_])||void 0===t?void 0:t.referenceSpaces;if(!r||0===r.length)return e;const a=null===(n=r[0][G_])||void 0===n?void 0:n.offsetMatrix;if(!a)return e;const s=r_(e.x,e.y,e.z);return function(e,t,n){var i=t[0],r=t[1],a=t[2],s=n[3]*i+n[7]*r+n[11]*a+n[15];s=s||1,e[0]=(n[0]*i+n[4]*r+n[8]*a+n[12])/s,e[1]=(n[1]*i+n[5]*r+n[9]*a+n[13])/s,e[2]=(n[2]*i+n[6]*r+n[10]*a+n[14])/s}(s,s,a),{x:s[0],y:s[1],z:s[2]}}getDeviceSelectValue(e){var t,n,i,r,a,s,o,l;switch(e){case"controller-left":return null!==(n=null===(t=this.device.controllers.left)||void 0===t?void 0:t.getButtonValue("trigger"))&&void 0!==n?n:0;case"controller-right":return null!==(r=null===(i=this.device.controllers.right)||void 0===i?void 0:i.getButtonValue("trigger"))&&void 0!==r?r:0;case"hand-left":return null!==(s=null===(a=this.device.hands.left)||void 0===a?void 0:a.pinchValue)&&void 0!==s?s:0;case"hand-right":return null!==(l=null===(o=this.device.hands.right)||void 0===o?void 0:o.pinchValue)&&void 0!==l?l:0;default:throw new Error(`Unknown input device: ${e}`)}}setDeviceSelectValue(e,t){var n,i,r,a;switch(e){case"controller-left":null===(n=this.device.controllers.left)||void 0===n||n.updateButtonValue("trigger",t);break;case"controller-right":null===(i=this.device.controllers.right)||void 0===i||i.updateButtonValue("trigger",t);break;case"hand-left":null===(r=this.device.hands.left)||void 0===r||r.updatePinchValue(t);break;case"hand-right":null===(a=this.device.hands.right)||void 0===a||a.updatePinchValue(t);break;default:throw new Error(`Unknown input device: ${e}`)}}setDeviceConnected(e,t){switch(e){case"controller-left":this.device.controllers.left&&(this.device.controllers.left.connected=t);break;case"controller-right":this.device.controllers.right&&(this.device.controllers.right.connected=t);break;case"hand-left":this.device.hands.left&&(this.device.hands.left.connected=t);break;case"hand-right":this.device.hands.right&&(this.device.hands.right.connected=t);break;default:throw new Error(`Unknown input device: ${e}`)}}executeDiscreteAction(e){const{method:t,params:n}=e;switch(t){case"get_session_status":return this.executeGetSessionStatus();case"accept_session":return this.executeAcceptSession();case"end_session":return this.executeEndSession();case"get_transform":return this.executeGetTransform(n);case"set_transform":return this.executeSetTransform(n);case"look_at":return this.executeLookAt(n);case"set_input_mode":return this.executeSetInputMode(n);case"set_connected":return this.executeSetConnected(n);case"get_select_value":return this.executeGetSelectValue(n);case"set_select_value":return this.executeSetSelectValue(n);case"get_gamepad_state":return this.executeGetGamepadState(n);case"set_gamepad_state":return this.executeSetGamepadState(n);case"get_device_state":return this.executeGetDeviceState();case"set_device_state":return this.executeSetDeviceState(n);case"capture_canvas":return this.executeCaptureCanvas(n);case"_select_press":{const e=n.device;return void this.setDeviceSelectValue(e,1)}case"_select_release":{const e=n.device;return void this.setDeviceSelectValue(e,0)}default:throw new Error(`Unknown method: ${t}`)}}executeGetSessionStatus(){const e=this.device.activeSession;return{deviceName:this.device.name,isRuntimeInstalled:!0,sessionActive:!!e,sessionOffered:this.device.sessionOffered,sessionMode:e?e.mode:null,enabledFeatures:e?Array.from(e.enabledFeatures||[]):[],visibilityState:this.device.visibilityState}}executeAcceptSession(){if(!this.device.sessionOffered)throw new Error("No session has been offered");return this.device.grantOfferedSession(),{success:!0}}executeEndSession(){const e=this.device.activeSession;if(!e)throw new Error("No active session");return e.end(),{success:!0}}executeGetTransform(e){const{device:t}=e,n=this.getDeviceTransform(t);return{device:t,position:n.position,orientation:n.orientation,euler:tb(n.orientation)}}executeSetTransform(e){const{device:t,position:n,orientation:i}=e,r=i?ib(i):void 0;this.setDeviceTransform(t,n,r);const a=this.getDeviceTransform(t);return{device:t,position:a.position,orientation:a.orientation}}executeLookAt(e){const{device:t,target:n,moveToDistance:i}=e,r=this.getDeviceTransform(t),a=this.transformXROriginToGlobal(n),s=function(e,t){const n=t.x-e.x,i=t.y-e.y,r=t.z-e.z,a=Math.sqrt(n*n+i*i+r*r);return 0===a?{x:0,y:0,z:-1}:{x:n/a,y:i/a,z:r/a}}(r.position,a),o="headset"===t?function(e){const t=Math.sqrt(e.x*e.x+e.z*e.z);let n=0;t>1e-4&&(n=Math.atan2(-e.x,-e.z));const i=Math.atan2(e.y,t),r=180/Math.PI;return nb({pitch:i*r,yaw:n*r,roll:0})}(s):function(e,t={x:0,y:1,z:0}){const n=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);if(0===n)return{x:0,y:0,z:0,w:1};const i=e.x/n,r=e.y/n,a=e.z/n,s={x:r*t.z-a*t.y,y:a*t.x-i*t.z,z:i*t.y-r*t.x},o=Math.sqrt(s.x*s.x+s.y*s.y+s.z*s.z);if(0===o){const e={x:1,y:0,z:0};s.x=r*e.z-a*e.y,s.y=a*e.x-i*e.z,s.z=i*e.y-r*e.x;const t=Math.sqrt(s.x*s.x+s.y*s.y+s.z*s.z);s.x/=t,s.y/=t,s.z/=t}else s.x/=o,s.y/=o,s.z/=o;const l={x:s.y*a-s.z*r,y:s.z*i-s.x*a,z:s.x*r-s.y*i},c=s.x,u=l.x,d=-i,h=s.y,f=l.y,p=-r,m=s.z,g=l.z,v=-a,y=c+f+v;let x,_,b,w;if(y>0){const e=.5/Math.sqrt(y+1);x=.25/e,_=(g-p)*e,b=(d-m)*e,w=(h-u)*e}else if(c>f&&c>v){const e=2*Math.sqrt(1+c-f-v);x=(g-p)/e,_=.25*e,b=(u+h)/e,w=(d+m)/e}else if(f>v){const e=2*Math.sqrt(1+f-c-v);x=(d-m)/e,_=(u+h)/e,b=.25*e,w=(p+g)/e}else{const e=2*Math.sqrt(1+v-c-f);x=(h-u)/e,_=(d+m)/e,b=(p+g)/e,w=.25*e}const S=Math.sqrt(_*_+b*b+w*w+x*x);return S>0&&(_/=S,b/=S,w/=S,x/=S),{x:_,y:b,z:w,w:x}}(s);let l;void 0!==i&&(l={x:a.x-s.x*i,y:a.y-s.y*i,z:a.z-s.z*i}),this.setDeviceTransform(t,l,o);const c=this.getDeviceTransform(t);return{device:t,position:c.position,orientation:c.orientation}}executeSetInputMode(e){var t,n,i,r;const{mode:a}=e;this.device.primaryInputMode=a;const s=[];return"controller"===a?((null===(t=this.device.controllers.left)||void 0===t?void 0:t.connected)&&s.push("controller-left"),(null===(n=this.device.controllers.right)||void 0===n?void 0:n.connected)&&s.push("controller-right")):((null===(i=this.device.hands.left)||void 0===i?void 0:i.connected)&&s.push("hand-left"),(null===(r=this.device.hands.right)||void 0===r?void 0:r.connected)&&s.push("hand-right")),{mode:a,activeDevices:s}}executeSetConnected(e){const{device:t,connected:n}=e;return this.setDeviceConnected(t,n),{device:t,connected:n}}executeGetSelectValue(e){const{device:t}=e;return{device:t,value:this.getDeviceSelectValue(t)}}executeSetSelectValue(e){const{device:t,value:n}=e;return this.setDeviceSelectValue(t,n),{device:t,value:n}}executeGetGamepadState(e){const{device:t}=e,n="controller-left"===t?"left":"right",i=this.device.controllers[n];if(!i)throw new Error(`Controller ${n} not available`);const r=["trigger","squeeze","thumbstick","left"===n?"x-button":"a-button","left"===n?"y-button":"b-button","thumbrest"].map((e,t)=>({index:t,name:e.replace("x-button","x").replace("y-button","y").replace("a-button","a").replace("b-button","b"),value:i.getButtonValue(e),touched:i.getButtonTouched(e),pressed:i.getButtonValue(e)>.5})),a=i.getAxes(),s=[{index:0,name:"thumbstick-x",value:a.x},{index:1,name:"thumbstick-y",value:a.y}];return{device:t,connected:i.connected,buttons:r,axes:s}}executeSetGamepadState(e){const{device:t,buttons:n,axes:i}=e,r="controller-left"===t?"left":"right",a=this.device.controllers[r];if(!a)throw new Error(`Controller ${r} not available`);let s=0,o=0;const l=["trigger","squeeze","thumbstick","left"===r?"x-button":"a-button","left"===r?"y-button":"b-button","thumbrest"];if(n)for(const e of n){const t=l[e.index];t&&(a.updateButtonValue(t,e.value),void 0!==e.touched&&a.updateButtonTouch(t,e.touched),s++)}if(i){let e,t;for(const n of i)0===n.index?(e=n.value,o++):1===n.index&&(t=n.value,o++);if(void 0!==e||void 0!==t){const n=a.getAxes();a.updateAxes("thumbstick",null!=e?e:n.x,null!=t?t:n.y)}}return{device:t,buttonsSet:s,axesSet:o}}executeGetDeviceState(){var e,t,n,i,r,a,s,o,l,c,u,d,h,f,p,m,g,v,y,x,_,b,w,S;return{headset:{position:J_(this.device.position),orientation:eb(this.device.quaternion)},inputMode:this.device.primaryInputMode,controllers:{left:{connected:null!==(t=null===(e=this.device.controllers.left)||void 0===e?void 0:e.connected)&&void 0!==t&&t,position:J_(null!==(i=null===(n=this.device.controllers.left)||void 0===n?void 0:n.position)&&void 0!==i?i:{x:0,y:0,z:0}),orientation:eb(null!==(a=null===(r=this.device.controllers.left)||void 0===r?void 0:r.quaternion)&&void 0!==a?a:{x:0,y:0,z:0,w:1})},right:{connected:null!==(o=null===(s=this.device.controllers.right)||void 0===s?void 0:s.connected)&&void 0!==o&&o,position:J_(null!==(c=null===(l=this.device.controllers.right)||void 0===l?void 0:l.position)&&void 0!==c?c:{x:0,y:0,z:0}),orientation:eb(null!==(d=null===(u=this.device.controllers.right)||void 0===u?void 0:u.quaternion)&&void 0!==d?d:{x:0,y:0,z:0,w:1})}},hands:{left:{connected:null!==(f=null===(h=this.device.hands.left)||void 0===h?void 0:h.connected)&&void 0!==f&&f,position:J_(null!==(m=null===(p=this.device.hands.left)||void 0===p?void 0:p.position)&&void 0!==m?m:{x:0,y:0,z:0}),orientation:eb(null!==(v=null===(g=this.device.hands.left)||void 0===g?void 0:g.quaternion)&&void 0!==v?v:{x:0,y:0,z:0,w:1})},right:{connected:null!==(x=null===(y=this.device.hands.right)||void 0===y?void 0:y.connected)&&void 0!==x&&x,position:J_(null!==(b=null===(_=this.device.hands.right)||void 0===_?void 0:_.position)&&void 0!==b?b:{x:0,y:0,z:0}),orientation:eb(null!==(S=null===(w=this.device.hands.right)||void 0===w?void 0:w.quaternion)&&void 0!==S?S:{x:0,y:0,z:0,w:1})}},stereoEnabled:this.device.stereoEnabled,fov:this.device.fovy*(180/Math.PI)}}executeSetDeviceState(e){const{state:t}=e;return t?(t.headset&&(t.headset.position&&this.device.position.set(t.headset.position.x,t.headset.position.y,t.headset.position.z),t.headset.orientation&&this.device.quaternion.set(t.headset.orientation.x,t.headset.orientation.y,t.headset.orientation.z,t.headset.orientation.w)),void 0!==t.inputMode&&(this.device.primaryInputMode=t.inputMode),void 0!==t.stereoEnabled&&(this.device.stereoEnabled=t.stereoEnabled),void 0!==t.fov&&(this.device.fovy=t.fov*(Math.PI/180)),t.controllers&&(this.applyInputState("controller-left",t.controllers.left),this.applyInputState("controller-right",t.controllers.right)),t.hands&&(this.applyInputState("hand-left",t.hands.left),this.applyInputState("hand-right",t.hands.right))):(this.device.position.set(0,1.6,0),this.device.quaternion.set(0,0,0,1),this.device.primaryInputMode="controller",this.device.stereoEnabled=!1,this.device.controllers.left&&(this.device.controllers.left.position.set(-.2,1.4,-.3),this.device.controllers.left.quaternion.set(0,0,0,1),this.device.controllers.left.connected=!0),this.device.controllers.right&&(this.device.controllers.right.position.set(.2,1.4,-.3),this.device.controllers.right.quaternion.set(0,0,0,1),this.device.controllers.right.connected=!0),this.device.hands.left&&(this.device.hands.left.position.set(-.15,1.3,-.4),this.device.hands.left.quaternion.set(0,0,0,1),this.device.hands.left.connected=!0),this.device.hands.right&&(this.device.hands.right.position.set(.15,1.3,-.4),this.device.hands.right.quaternion.set(0,0,0,1),this.device.hands.right.connected=!0)),{state:this.executeGetDeviceState()}}applyInputState(e,t){t&&(void 0!==t.connected&&this.setDeviceConnected(e,t.connected),(t.position||t.orientation)&&this.setDeviceTransform(e,t.position,t.orientation))}executeCaptureCanvas(e){const{maxWidth:t=800,format:n="png",quality:i=.92}=e;let r=this.device.appCanvas;if(!r){const e=document.querySelectorAll("canvas");if(1===e.length)r=e[0];else if(e.length>1){let t=null,n=0;e.forEach(e=>{const i=e.getBoundingClientRect(),r=i.width*i.height;r>n&&i.width>0&&i.height>0&&(n=r,t=e)}),r=t}}if(!r)throw new Error("No canvas available. Either start an XR session or ensure an app canvas is in the DOM.");const a=document.createElement("canvas"),s=a.getContext("2d");if(!s)throw new Error("Failed to create canvas context");const o=r.height/r.width,l=Math.min(r.width,t),c=Math.round(l*o);a.width=l,a.height=c,s.drawImage(r,0,0,l,c);const u=`image/${n}`;return{imageData:a.toDataURL(u,i).split(",")[1],width:l,height:c,format:n,timestamp:Date.now()}}applyDurationLerpState(e,t){const{startState:n,targetState:i,params:r}=e,a=r.device;let s,o;n.position&&i.position&&(s=function(e,t,n){return{x:rb(e.x,t.x,n),y:rb(e.y,t.y,n),z:rb(e.z,t.z,n)}}(n.position,i.position,t)),n.orientation&&i.orientation&&(o=function(e,t,n){let i=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,r=t.x,a=t.y,s=t.z,o=t.w;if(i<0&&(i=-i,r=-r,a=-a,s=-s,o=-o),i>.9995){const t={x:rb(e.x,r,n),y:rb(e.y,a,n),z:rb(e.z,s,n),w:rb(e.w,o,n)},i=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w);return{x:t.x/i,y:t.y/i,z:t.z/i,w:t.w/i}}const l=Math.acos(i),c=l*n,u=Math.sin(c),d=Math.sin(l),h=Math.cos(c)-i*u/d,f=u/d;return{x:h*e.x+f*r,y:h*e.y+f*a,z:h*e.z+f*s,w:h*e.w+f*o}}(n.orientation,i.orientation,t)),this.setDeviceTransform(a,s,o)}applyDurationFinalState(e){const{targetState:t,params:n}=e,i=n.device;this.setDeviceTransform(i,t.position,t.orientation)}getDurationResult(e){const{params:t,elapsedMs:n}=e,i=t.device,r=this.getDeviceTransform(i);return{device:i,position:r.position,orientation:r.orientation,actualDuration:n/1e3}}activateCaptureMode(){this._isCaptured||(this._isCaptured=!0,this.cancelReleaseTimer(),this.device.controlMode="programmatic"),this.startReleaseTimer()}async dispatch(e,t={}){var n;if(ab.IMMEDIATE_METHODS.has(e))return ab.ACTIVE_IMMEDIATE_METHODS.has(e)&&this.activateCaptureMode(),this.executeImmediateMethod(e,t);if(ab.SESSION_REQUIRED_METHODS.has(e)&&!this.device.activeSession)throw new Error(`Cannot execute '${e}': No active XR session. Use 'get_session_status' to check session state, and 'accept_session' to start a session.`);if("animate_to"===e){const i=t,r=this.getDeviceTransform(i.device),a=1e3*(null!==(n=i.duration)&&void 0!==n?n:.5),s=i.orientation?ib(i.orientation):void 0,o=i.position?this.transformXROriginToGlobal(i.position):void 0;return this.enqueueDuration(e,t,a,{position:i.position?r.position:void 0,orientation:s?r.orientation:void 0},{position:o,orientation:s})}if("select"===e){const e=t;return this.executeSelectSequence(e)}return this.enqueueDiscrete(e,t)}executeImmediateMethod(e,t){switch(e){case"get_session_status":return this.executeGetSessionStatus();case"accept_session":return this.executeAcceptSession();case"end_session":return this.executeEndSession();case"get_transform":return this.executeGetTransform(t);case"get_select_value":return this.executeGetSelectValue(t);case"get_gamepad_state":return this.executeGetGamepadState(t);case"get_device_state":return this.executeGetDeviceState();case"capture_canvas":return this.executeCaptureCanvas(t);default:throw new Error(`Unknown immediate method: ${e}`)}}executeSelectSequence(e){const{device:t,duration:n=.15}=e;return new Promise((e,i)=>{let r=0;const a=()=>{r++,3===r&&e({device:t,duration:n})},s={type:"discrete",id:this.generateActionId(),method:"_select_press",params:{device:t},resolve:a,reject:i},o={type:"duration",id:this.generateActionId(),method:"_select_wait",params:{device:t},durationMs:1e3*n,elapsedMs:0,startState:{},targetState:{},resolve:a,reject:i},l={type:"discrete",id:this.generateActionId(),method:"_select_release",params:{device:t},resolve:a,reject:i};this.commandQueue.push(s,o,l)})}async acceptSession(){if(!this.device.sessionOffered)throw new Error("No session has been offered");return this.device.grantOfferedSession(),await function(e,t=5e3){return new Promise((n,i)=>{const r=Date.now(),a=()=>{e()?n():Date.now()-r>t?i(new Error("Timeout waiting for condition")):requestAnimationFrame(a)};a()})}(()=>!!this.device.activeSession,5e3),{success:!0}}forceRelease(){this.cancelReleaseTimer(),this._isCaptured=!1,this.device.controlMode="manual";for(const e of this.commandQueue)e.reject(new Error("Capture released"));this.commandQueue=[];for(const e of["left","right"]){const t=this.device.controllers[e];t&&(t.updateButtonValue("trigger",0),t.updateButtonValue("squeeze",0))}}}var sb,ob,lb;ab.IMMEDIATE_METHODS=new Set(["get_session_status","accept_session","end_session","get_transform","get_select_value","get_gamepad_state","get_device_state","capture_canvas"]),ab.ACTIVE_IMMEDIATE_METHODS=new Set(["accept_session","end_session"]),ab.SESSION_REQUIRED_METHODS=new Set(["set_transform","look_at","animate_to","set_input_mode","set_connected","set_select_value","select","set_gamepad_state","set_device_state"]),function(e){e.None="",e.Standard="standard",e.XRStandard="xr-standard"}(sb||(sb={}));class cb{constructor(e,t){this[C_]={type:e,eventTrigger:t,pressed:!1,touched:!1,value:0,lastFrameValue:0,pendingValue:null}}get pressed(){return"manual"===this[C_].type?this[C_].pressed:this[C_].value>0}get touched(){return"manual"===this[C_].type?this[C_].touched:this[C_].touched||this.pressed}get value(){return this[C_].value}}class ub{constructor(){this.pressed=!1,this.touched=!1,this.value=0}}class db{constructor(e,t="",n=-1){this[C_]={id:t,index:n,connected:!1,timestamp:performance.now(),mapping:e.mapping,buttonsMap:{},buttonsSequence:[],axesMap:{},axesSequence:[],hapticActuators:[]},e.buttons.forEach(e=>{var t;null===e?this[C_].buttonsSequence.push(null):(this[C_].buttonsSequence.push(e.id),this[C_].buttonsMap[e.id]=new cb(e.type,null!==(t=e.eventTrigger)&&void 0!==t?t:null))}),e.axes.forEach(e=>{null===e?this[C_].axesSequence.push(null):(this[C_].axesSequence.push(e.id+e.type),this[C_].axesMap[e.id]||(this[C_].axesMap[e.id]={x:0,y:0}))})}get id(){return this[C_].id}get index(){return this[C_].index}get connected(){return this[C_].connected}get timestamp(){return this[C_].timestamp}get mapping(){return this[C_].mapping}get axes(){const e=[];return this[C_].axesSequence.forEach(t=>{if(null===t)e.push(null);else{const n=t.substring(0,t.length-6),i=t.substring(t.length-6);e.push("y-axis"===i?this[C_].axesMap[n].y:this[C_].axesMap[n].x)}}),e}get buttons(){return this[C_].buttonsSequence.map(e=>null===e?new ub:this[C_].buttonsMap[e])}get hapticActuators(){return this[C_].hapticActuators}get vibrationActuator(){return null}}!function(e){e.None="none",e.Left="left",e.Right="right"}(ob||(ob={})),function(e){e.Gaze="gaze",e.TrackedPointer="tracked-pointer",e.Screen="screen",e.TransientPointer="transient-pointer"}(lb||(lb={}));class hb extends Array{}class fb{constructor(e,t,n,i,r,a,s){this[L_]={handedness:e,targetRayMode:t,targetRaySpace:i,gripSpace:a,profiles:n,gamepad:r,hand:s}}get handedness(){return this[L_].handedness}get targetRayMode(){return this[L_].targetRayMode}get targetRaySpace(){return this[L_].targetRaySpace}get gripSpace(){return this[L_].gripSpace}get profiles(){return this[L_].profiles}get gamepad(){return this[L_].gamepad}get hand(){return this[L_].hand}}class pb extends Event{constructor(e,t){if(super(e,t),!t.frame)throw new Error("XRInputSourceEventInit.frame is required");if(!t.inputSource)throw new Error("XRInputSourceEventInit.inputSource is required");this.frame=t.frame,this.inputSource=t.inputSource}}const mb={[ob.Left]:{position:new Z_(-.25,1.5,-.4),quaternion:new Q_},[ob.Right]:{position:new Z_(.25,1.5,-.4),quaternion:new Q_},[ob.None]:{position:new Z_(.25,1.5,-.4),quaternion:new Q_}};class gb{constructor(e){this[A_]={inputSource:e,position:mb[e.handedness].position.clone(),quaternion:mb[e.handedness].quaternion.clone(),connected:!0,lastFrameConnected:!1,inputSourceChanged:!0}}get position(){return this[A_].position}get quaternion(){return this[A_].quaternion}get inputSource(){return this[A_].inputSource}get connected(){return this[A_].connected}set connected(e){this[A_].connected=e,this[A_].inputSource.gamepad[C_].connected=e}onFrameStart(e){Qx(this[A_].inputSource.targetRaySpace[G_].offsetMatrix,this[A_].quaternion.quat,this[A_].position.vec3);const t=e.session;this[A_].inputSource.gamepad.buttons.forEach(n=>{n instanceof cb&&(n[C_].lastFrameValue=n[C_].value,null!=n[C_].pendingValue&&(n[C_].value=n[C_].pendingValue,n[C_].pendingValue=null),null!=n[C_].eventTrigger&&(0===n[C_].lastFrameValue&&n[C_].value>0?(t.dispatchEvent(new pb(n[C_].eventTrigger,{frame:e,inputSource:this[A_].inputSource})),t.dispatchEvent(new pb(n[C_].eventTrigger+"start",{frame:e,inputSource:this[A_].inputSource}))):n[C_].lastFrameValue>0&&0===n[C_].value&&t.dispatchEvent(new pb(n[C_].eventTrigger+"end",{frame:e,inputSource:this[A_].inputSource}))))}),this[A_].inputSourceChanged=this.connected!==this[A_].lastFrameConnected,this[A_].lastFrameConnected=this.connected}}class vb extends gb{constructor(e,t,n){if(!e.layout[t])throw new DOMException("Handedness not supported","InvalidStateError");const i=new $_(n),r=e.layout[t].gripOffsetMatrix?new $_(i,e.layout[t].gripOffsetMatrix):void 0,a=[e.profileId,...e.fallbackProfileIds];super(new fb(t,lb.TrackedPointer,a,i,new db(e.layout[t].gamepad),r)),this[M_]={profileId:e.profileId,gamepadConfig:e.layout[t].gamepad}}get gamepadConfig(){return this[M_].gamepadConfig}get profileId(){return this[M_].profileId}updateButtonValue(e,t){if(t>1||t<0)return void console.warn(`Out-of-range value ${t} provided for button ${e}.`);const n=this[A_].inputSource.gamepad[C_].buttonsMap[e];if(n){if("binary"===n[C_].type&&1!=t&&0!=t)return void console.warn(`Non-binary value ${t} provided for binary button ${e}.`);n[C_].pendingValue=t}else console.warn(`Current controller does not have button ${e}.`)}setButtonValueImmediate(e,t){if(t>1||t<0)return void console.warn(`Out-of-range value ${t} provided for button ${e}.`);const n=this[A_].inputSource.gamepad[C_].buttonsMap[e];if(n){if("binary"===n[C_].type&&1!=t&&0!=t)return void console.warn(`Non-binary value ${t} provided for binary button ${e}.`);n[C_].value=t,n[C_].pendingValue=t}else console.warn(`Current controller does not have button ${e}.`)}updateButtonTouch(e,t){const n=this[A_].inputSource.gamepad[C_].buttonsMap[e];n?n[C_].touched=t:console.warn(`Current controller does not have button ${e}.`)}updateAxis(e,t,n){if(n>1||n<-1)return void console.warn(`Out-of-range value ${n} provided for ${e} axes.`);const i=this[A_].inputSource.gamepad[C_].axesMap[e];i?"x-axis"===t?i.x=n:"y-axis"===t&&(i.y=n):console.warn(`Current controller does not have ${e} axes.`)}updateAxes(e,t,n){if(t>1||t<-1||n>1||n<-1)return void console.warn(`Out-of-range value x:${t}, y:${n} provided for ${e} axes.`);const i=this[A_].inputSource.gamepad[C_].axesMap[e];i?(i.x=t,i.y=n):console.warn(`Current controller does not have ${e} axes.`)}getButtonValue(e){var t;const n=this[A_].inputSource.gamepad[C_].buttonsMap[e];return n?null!==(t=n[C_].pendingValue)&&void 0!==t?t:n.value:0}getButtonTouched(e){const t=this[A_].inputSource.gamepad[C_].buttonsMap[e];return!!t&&t.touched}getAxes(e="thumbstick"){const t=this[A_].inputSource.gamepad[C_].axesMap[e];return t?{x:t.x,y:t.y}:{x:0,y:0}}}class yb{constructor(e,t,n,i,r){this[D_]={nativeMesh:e,frame:void 0,meshSpace:t,vertices:n,indices:i,lastChangedTime:performance.now(),semanticLabel:r}}get meshSpace(){return this[D_].meshSpace}get vertices(){return this[D_].vertices}get indices(){return this[D_].indices}get lastChangedTime(){return this[D_].lastChangedTime}get semanticLabel(){return this[D_].semanticLabel}}class xb extends Set{}class _b{constructor(e,t,n,i){this.transform=e,this.vertices=t,this.indices=n,this.semanticLabel=i}}var bb,wb;!function(e){e.Desk="desk",e.Couch="couch",e.Floor="floor",e.Ceiling="ceiling",e.Wall="wall",e.Door="door",e.Window="window",e.Table="table",e.Shelf="shelf",e.Bed="bed",e.Screen="screen",e.Lamp="lamp",e.Plant="plant",e.WallArt="wall art",e.GlobalMesh="global mesh",e.Other="other"}(bb||(bb={})),function(e){e.Horizontal="horizontal",e.Vertical="vertical"}(wb||(wb={}));const Sb={[bb.Desk]:wb.Horizontal,[bb.Couch]:wb.Horizontal,[bb.Floor]:wb.Horizontal,[bb.Ceiling]:wb.Horizontal,[bb.Wall]:wb.Vertical,[bb.Door]:wb.Vertical,[bb.Window]:wb.Vertical,[bb.Table]:wb.Horizontal,[bb.Shelf]:wb.Horizontal,[bb.Bed]:wb.Horizontal,[bb.Screen]:wb.Horizontal,[bb.Lamp]:wb.Horizontal,[bb.Plant]:wb.Horizontal,[bb.WallArt]:wb.Vertical};class Mb{constructor(e,t,n,i){this[N_]={nativePlane:e,frame:void 0,planeSpace:t,polygon:n,lastChangedTime:performance.now(),semanticLabel:i,orientation:i?Sb[i]:void 0}}get planeSpace(){return this[N_].planeSpace}get polygon(){return this[N_].polygon}get orientation(){return this[N_].orientation}get lastChangedTime(){return this[N_].lastChangedTime}get semanticLabel(){return this[N_].semanticLabel}}class Eb extends Set{}class Tb{constructor(e,t,n){this.transform=e,this.polygon=t,this.semanticLabel=n}}class Ab{constructor(e,t){this[S_]={anchorSpace:e,session:t,deleted:!1},t[B_].trackedAnchors.add(this)}get anchorSpace(){if(this[S_].deleted)throw new DOMException("XRAnchor has already been deleted.","InvalidStateError");return this[S_].anchorSpace}requestPersistentHandle(){return new Promise((e,t)=>{if(this[S_].deleted)t(new DOMException("XRAnchor has already been deleted.","InvalidStateError"));else{const t=this[S_].session[B_].persistentAnchors;for(const[n,i]of t.entries())if(i===this)return void e(n);const n=crypto.randomUUID();Pb.createPersistentAnchor(this[S_].session,this,n),e(n)}})}delete(){this[S_].deleted||(this[S_].anchorSpace=null,this[S_].deleted=!0,this[S_].session[B_].trackedAnchors.delete(this))}}class Rb extends Set{}const Cb="@immersive-web-emulation-runtime/persistent-anchors";class Pb{static recoverPersistentAnchorsFromStorage(e){const t=JSON.parse(localStorage.getItem(Cb)||"{}");Object.entries(t).forEach(([t,n])=>{const i=e[B_].device[E_].globalSpace,r=new $_(i,n),a=new Ab(r,e);e[B_].persistentAnchors.set(t,a)})}static createPersistentAnchor(e,t,n){e[B_].trackedAnchors.add(t),e[B_].persistentAnchors.set(n,t);const i=JSON.parse(localStorage.getItem(Cb)||"{}");i[n]=Array.from(t[S_].anchorSpace[G_].offsetMatrix),localStorage.setItem(Cb,JSON.stringify(i))}}class Lb{constructor(e,t){const n=r_(0,0,0),i=p_();this[F_]={matrix:Wx(),position:e?r_(e.x,e.y,e.z):n,orientation:t?b_(p_(),y_(t.x,t.y,t.z,t.w)):i,inverse:null},this.updateMatrix()}updateMatrix(){Qx(this[F_].matrix,this[F_].orientation,this[F_].position)}get matrix(){return this[F_].matrix}get position(){const e=this[F_].position;return new DOMPointReadOnly(e[0],e[1],e[2],1)}get orientation(){const e=this[F_].orientation;return new DOMPointReadOnly(e[0],e[1],e[2],e[3])}get inverse(){if(!this[F_].inverse){const e=Wx();if(!$x(e,this[F_].matrix))throw new Error("Matrix is not invertible.");let t=i_();Jx(t,e);let n=p_();t_(n,e),this[F_].inverse=new Lb(new DOMPointReadOnly(t[0],t[1],t[2],1),new DOMPointReadOnly(n[0],n[1],n[2],n[3])),this[F_].inverse[F_].inverse=this}return this[F_].inverse}}let Ib=class{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}};class Db{constructor(e,t){const n={x:0,y:0,z:0,w:1},i={x:0,y:0,z:-1,w:0};if(e instanceof Lb){const t=e.matrix,r=h_(d_(),n.x,n.y,n.z,n.w),a=h_(d_(),i.x,i.y,i.z,i.w);f_(r,r,t),f_(a,a,t),n.x=r[0],n.y=r[1],n.z=r[2],n.w=r[3],i.x=a[0],i.y=a[1],i.z=a[2],i.w=a[3]}else if(e&&(n.x=e.x,n.y=e.y,n.z=e.z,n.w=e.w),t){if(0===t.x&&0===t.y&&0===t.z||0!==t.w)throw new DOMException("Invalid direction value to construct XRRay","TypeError");i.x=t.x,i.y=t.y,i.z=t.z,i.w=t.w}const r=Math.sqrt(i.x*i.x+i.y*i.y+i.z*i.z)||1;i.x=i.x/r,i.y=i.y/r,i.z=i.z/r,this[X_]={origin:new Ib(n.x,n.y,n.z,n.w),direction:new Ib(i.x,i.y,i.z,i.w),matrix:null}}get origin(){return this[X_].origin}get direction(){return this[X_].direction}get matrix(){if(this[X_].matrix)return this[X_].matrix;const e=s_(i_(),0,0,-1),t=s_(i_(),this[X_].origin.x,this[X_].origin.y,this[X_].origin.z),n=s_(i_(),this[X_].direction.x,this[X_].direction.y,this[X_].direction.z),i=c_(i_(),n,e),r=l_(n,e),a=Wx();r>-1&&r<1?Zx(a,Math.acos(r),i):-1===r?Zx(a,Math.acos(r),s_(i_(),1,0,0)):function(e){e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(a);const s=Kx(Wx(),t),o=Yx(Wx(),s,a);return this[X_].matrix=new Float32Array(o),this[X_].matrix}}class Nb{constructor(e,t){var n;this[q_]={session:e,space:t.space,offsetRay:null!==(n=t.offsetRay)&&void 0!==n?n:new Db}}cancel(){this[q_].session[B_].hitTestSources.delete(this)}}class Ob{constructor(e,t){this[q_]={frame:e,offsetSpace:t}}getPose(e){return this[q_].frame.getPose(this[q_].offsetSpace,e)}createAnchor(){return this[q_].frame.createAnchor(new Lb,this[q_].offsetSpace)}}class kb extends Event{constructor(e,t){if(super(e,t),!t.session)throw new Error("XRInputSourcesChangeEventInit.session is required");if(!t.added)throw new Error("XRInputSourcesChangeEventInit.added is required");if(!t.removed)throw new Error("XRInputSourcesChangeEventInit.removed is required");this.session=t.session,this.added=t.added,this.removed=t.removed}}var Ub,Fb,zb;!function(e){e.Viewer="viewer",e.Local="local",e.LocalFloor="local-floor",e.BoundedFloor="bounded-floor",e.Unbounded="unbounded"}(Fb||(Fb={}));class Bb extends $_{constructor(e,t,n){super(t,n),this[Ub]={type:null,onreset:()=>{}},this[H_].type=e}get onreset(){var e;return null!==(e=this[H_].onreset)&&void 0!==e?e:()=>{}}set onreset(e){this[H_].onreset&&this.removeEventListener("reset",this[H_].onreset),this[H_].onreset=e,e&&this.addEventListener("reset",e)}getOffsetReferenceSpace(e){return new Bb(this[H_].type,this,e)}}Ub=H_;class Vb{constructor(e={},t){this[z_]={depthNear:e.depthNear||(null==t?void 0:t.depthNear)||.1,depthFar:e.depthFar||(null==t?void 0:t.depthFar)||1e3,inlineVerticalFieldOfView:e.inlineVerticalFieldOfView||(null==t?void 0:t.inlineVerticalFieldOfView)||null,baseLayer:e.baseLayer||(null==t?void 0:t.baseLayer)||null}}get depthNear(){return this[z_].depthNear}get depthFar(){return this[z_].depthFar}get inlineVerticalFieldOfView(){return this[z_].inlineVerticalFieldOfView}get baseLayer(){return this[z_].baseLayer}}class Hb extends Event{constructor(e,t){if(super(e,t),!t.session)throw new Error("XRSessionEventInit.session is required");this.session=t.session}}!function(e){e.None="none",e.Left="left",e.Right="right"}(zb||(zb={}));class Gb{constructor(e,t,n,i){this[j_]={eye:e,projectionMatrix:t,transform:n,recommendedViewportScale:null,requestedViewportScale:1,session:i}}get eye(){return this[j_].eye}get projectionMatrix(){return this[j_].projectionMatrix}get transform(){return this[j_].transform}get recommendedViewportScale(){return this[j_].recommendedViewportScale}requestViewportScale(e){null===e||e<=0||e>1?console.warn("Invalid scale value. Scale must be > 0 and <= 1."):this[j_].requestedViewportScale=e}}class jb{constructor(e,t=!1,n=void 0,i=void 0){this[k_]={transform:e,emulatedPosition:t,linearVelocity:n,angularVelocity:i}}get transform(){return this[k_].transform}get emulatedPosition(){return this[k_].emulatedPosition}get linearVelocity(){return this[k_].linearVelocity}get angularVelocity(){return this[k_].angularVelocity}}class Wb extends jb{constructor(e,t,n=!1,i=void 0,r=void 0){super(e,n,i,r),this[O_]={radius:t}}get radius(){return this[O_].radius}}class Xb extends jb{constructor(e,t,n=!1,i=void 0,r=void 0){super(e,n,i,r),this[U_]={views:Object.freeze(t)}}get views(){return this[U_].views}}const qb=Wx(),$b=Wx(),Yb=Wx(),Kb=(e,t,n)=>{K_.calculateGlobalOffsetMatrix(t,qb),K_.calculateGlobalOffsetMatrix(n,$b),$x(Yb,$b),Yx(e,Yb,qb)};class Zb{constructor(e,t,n,i,r){this[R_]={session:e,id:t,active:n,animationFrame:i,predictedDisplayTime:r,tempMat4:Wx(),detectedPlanes:new Eb,detectedMeshes:new xb,trackedAnchors:e[B_].frameTrackedAnchors,hitTestResultsMap:new Map}}get session(){return this[R_].session}get predictedDisplayTime(){return this[R_].predictedDisplayTime}getPose(e,t){if(!this[R_].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");Kb(this[R_].tempMat4,e,t);const n=i_();Jx(n,this[R_].tempMat4);const i=p_();return t_(i,this[R_].tempMat4),new jb(new Lb({x:n[0],y:n[1],z:n[2],w:1},{x:i[0],y:i[1],z:i[2],w:i[3]}),e[G_].emulated)}getViewerPose(e){if(!this[R_].animationFrame)throw new DOMException("getViewerPose can only be called on XRFrame objects passed to XRSession.requestAnimationFrame callbacks.","InvalidStateError");const t=this[R_].session,n=t[B_].device,i=this.getPose(n.viewerSpace,e),r="inline"===t[B_].mode?[zb.None]:[zb.Left,zb.Right],a=[];return r.forEach(i=>{const r=n.viewSpaces[i],s=this.getPose(r,e),o=t[B_].getProjectionMatrix(i),l=new Gb(i,new Float32Array(o),s.transform,t);a.push(l)}),new Xb(i.transform,a,!1)}getJointPose(e,t){const n=this.getPose(e,t),i=e[V_].radius;return new Wb(n.transform,i,!1)}fillJointRadii(e,t){if(e=Array.from(e),!this[R_].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");if(e.length>t.length)throw new DOMException("The length of jointSpaces is larger than the number of elements in radii","TypeError");let n=!0;for(let i=0;i<e.length;i++)e[i][V_].radius?t[i]=e[i][V_].radius:(t[i]=NaN,n=!1);return n}fillPoses(e,t,n){if(e=Array.from(e),!this[R_].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");if(16*e.length>n.length)throw new DOMException("The length of spaces multiplied by 16 is larger than the number of elements in transforms","TypeError");return e.forEach((e,i)=>{Kb(this[R_].tempMat4,e,t);for(let e=0;e<16;e++)n[16*i+e]=this[R_].tempMat4[e]}),!0}get detectedPlanes(){if(!this[R_].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");return this[R_].detectedPlanes}get detectedMeshes(){if(!this[R_].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");return this[R_].detectedMeshes}get trackedAnchors(){if(!this[R_].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");return this[R_].trackedAnchors}createAnchor(e,t){return new Promise((n,i)=>{if(this[R_].active){const r=this[R_].session[B_].device[E_].globalSpace,a=new $_(t,e.matrix),s=K_.calculateGlobalOffsetMatrix(a),o=new $_(r,s),l=new Ab(o,this[R_].session);this[R_].session[B_].trackedAnchors.add(l),this[R_].session[B_].newAnchors.set(l,{resolve:n,reject:i})}else i(new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError"))})}getHitTestResults(e){if(this[R_].active){if(this[R_].hitTestResultsMap.has(e))return[...this[R_].hitTestResultsMap.get(e)];throw new DOMException("Requested hit test results are not available for current frame.","InvalidStateError")}throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError")}}var Qb,Jb,ew;!function(e){e.Opaque="opaque",e.AlphaBlend="alpha-blend",e.Additive="additive"}(Qb||(Qb={})),function(e){e.ScreenSpace="screen-space",e.WorldSpace="world-space"}(Jb||(Jb={}));class tw extends EventTarget{constructor(e,t,n){super(),this[B_]={device:e,mode:t,renderState:new Vb,pendingRenderState:null,enabledFeatures:n,isSystemKeyboardSupported:!1,ended:!1,projectionMatrices:{[zb.Left]:Wx(),[zb.Right]:Wx(),[zb.None]:Wx()},getProjectionMatrix:e=>this[B_].projectionMatrices[e],referenceSpaceIsSupported:e=>{if(!this[B_].enabledFeatures.includes(e))return!1;switch(e){case Fb.Viewer:return!0;case Fb.Local:case Fb.LocalFloor:case Fb.BoundedFloor:case Fb.Unbounded:return"inline"!=this[B_].mode}},frameHandle:0,frameCallbacks:[],currentFrameCallbacks:null,onDeviceFrame:()=>{if(this[B_].ended)return;this[B_].deviceFrameHandle=globalThis.requestAnimationFrame(this[B_].onDeviceFrame),null!=this[B_].pendingRenderState&&(this[B_].renderState=this[B_].pendingRenderState,this[B_].pendingRenderState=null,this[B_].device[E_].onBaseLayerSet(this[B_].renderState.baseLayer));const e=this[B_].renderState.baseLayer;if(null===e)return;const t=e.context,n=t.canvas;if("inline"!=this[B_].mode){const e=t.getParameter(t.COLOR_CLEAR_VALUE),n=t.getParameter(t.DEPTH_CLEAR_VALUE),i=t.getParameter(t.STENCIL_CLEAR_VALUE);t.clearColor(0,0,0,0),t.clearDepth(1),t.clearStencil(0),t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),t.clearColor(e[0],e[1],e[2],e[3]),t.clearDepth(n),t.clearStencil(i)}const{depthNear:i,depthFar:r}=this[B_].renderState,{width:a,height:s}=n;if("inline"!==this[B_].mode){const e=a*(this[B_].device.stereoEnabled?.5:1)/s;n_(this[B_].projectionMatrices[zb.Left],this[B_].device.fovy,e,i,r),qx(this[B_].projectionMatrices[zb.Right],this[B_].projectionMatrices[zb.Left])}else{const e=a/s;n_(this[B_].projectionMatrices[zb.None],this[B_].renderState.inlineVerticalFieldOfView,e,i,r)}const o=new Zb(this,this[B_].frameHandle,!0,!0,performance.now()),l=performance.now(),c=this[B_].device[E_].devui;if(c&&c.render(l),"immersive-ar"===this[B_].mode){const e=this[B_].device[E_].sem;e&&e.render(l)}this[B_].enabledFeatures.includes("anchors")&&this[B_].updateTrackedAnchors(),this[B_].enabledFeatures.includes("plane-detection")&&this[B_].updateTrackedPlanes(o),this[B_].enabledFeatures.includes("mesh-detection")&&this[B_].updateTrackedMeshes(o),this[B_].enabledFeatures.includes("hit-test")&&this[B_].computeHitTestResults(o),this[B_].device[E_].onFrameStart(o),this[B_].updateActiveInputSources();const u=this[B_].currentFrameCallbacks=this[B_].frameCallbacks;this[B_].frameCallbacks=[];const d=performance.now();for(let e=0;e<u.length;e++)try{u[e].cancelled||u[e].callback(d,o)}catch(e){console.error(e)}this[B_].currentFrameCallbacks=null,o[R_].active=!1},nominalFrameRate:e.internalNominalFrameRate,referenceSpaces:[],inputSourceArray:[],activeInputSources:[],updateActiveInputSources:()=>{const e=this[B_].enabledFeatures.includes("hand-tracking"),t=this[B_].activeInputSources,n=this[B_].device.inputSources.filter(t=>!t.hand||e),i=n.filter(e=>!t.includes(e)),r=t.filter(e=>!n.includes(e));this[B_].activeInputSources=n,(i.length>0||r.length>0)&&this.dispatchEvent(new kb("inputsourceschange",{session:this,added:i,removed:r}))},trackedAnchors:new Rb,persistentAnchors:new Map,newAnchors:new Map,frameTrackedAnchors:new Rb,updateTrackedAnchors:()=>{this[B_].enabledFeatures.includes("anchors")&&(this[B_].frameTrackedAnchors.clear(),Array.from(this[B_].trackedAnchors).forEach(e=>{if(e[S_].deleted){if(this[B_].trackedAnchors.delete(e),this[B_].newAnchors.has(e)){const{reject:t}=this[B_].newAnchors.get(e);t(new DOMException("Anchor is no longer tracked","InvalidStateError"))}}else if(this[B_].frameTrackedAnchors.add(e),this[B_].newAnchors.has(e)){const{resolve:t}=this[B_].newAnchors.get(e);t(e),this[B_].newAnchors.delete(e)}}))},trackedPlanes:new Map,updateTrackedPlanes:e=>{const t=this[B_].device[E_].sem;if(!t)return;Array.from(this[B_].trackedPlanes.keys()).forEach(e=>{t.trackedPlanes.has(e)||this[B_].trackedPlanes.delete(e)}),t.trackedPlanes.forEach(t=>{let n=this[B_].trackedPlanes.get(t);if(!n){const e=new $_(this[B_].device[E_].globalSpace,t.transform.matrix);n=new Mb(t,e,t.polygon,t.semanticLabel),this[B_].trackedPlanes.set(t,n)}n[N_].lastChangedTime=e.predictedDisplayTime,n[N_].frame=e,e[R_].detectedPlanes.add(n)})},trackedMeshes:new Map,updateTrackedMeshes:e=>{const t=this[B_].device[E_].sem;if(!t)return;Array.from(this[B_].trackedMeshes.keys()).forEach(e=>{t.trackedMeshes.has(e)||this[B_].trackedMeshes.delete(e)}),t.trackedMeshes.forEach(t=>{let n=this[B_].trackedMeshes.get(t);if(!n){const e=new $_(this[B_].device[E_].globalSpace,t.transform.matrix);n=new yb(t,e,t.vertices,t.indices,t.semanticLabel),this[B_].trackedMeshes.set(t,n)}n[D_].lastChangedTime=e.predictedDisplayTime,n[D_].frame=e,e[R_].detectedMeshes.add(n)})},hitTestSources:new Set,computeHitTestResults:e=>{const t=this[B_].device[E_].sem;if(!t)return;const n=this[B_].device[E_].globalSpace;this[B_].hitTestSources.forEach(i=>{const r=i[q_].space,a=K_.calculateGlobalOffsetMatrix(r),s=i[q_].offsetRay.matrix,o=Wx();Yx(o,a,s);const l=[];t.computeHitTestResults(o).forEach(t=>{const i=new $_(n,t),r=new Ob(e,i);l.push(r)}),e[R_].hitTestResultsMap.set(i,l)})},onend:null,oninputsourceschange:null,onselect:null,onselectstart:null,onselectend:null,onsqueeze:null,onsqueezestart:null,onsqueezeend:null,onvisibilitychange:null,onframeratechange:null},Pb.recoverPersistentAnchorsFromStorage(this),this[B_].onDeviceFrame()}get visibilityState(){return this[B_].device.visibilityState}get frameRate(){return this[B_].nominalFrameRate}get supportedFrameRates(){return new Float32Array(this[B_].device.supportedFrameRates)}get renderState(){return this[B_].renderState}get inputSources(){return this[B_].inputSourceArray.length=0,this[B_].ended||"inline"===this[B_].mode||this[B_].inputSourceArray.push(...this[B_].activeInputSources),this[B_].inputSourceArray}get enabledFeatures(){return this[B_].enabledFeatures}get isSystemKeyboardSupported(){return this[B_].isSystemKeyboardSupported}get environmentBlendMode(){var e;return null!==(e=this[B_].device[E_].environmentBlendModes[this[B_].mode])&&void 0!==e?e:Qb.Opaque}get interactionMode(){return this[B_].device[E_].interactionMode}updateRenderState(e={}){var t,n,i,r;if(this[B_].ended)throw new DOMException("XRSession has already ended.","InvalidStateError");if(e.baseLayer&&e.baseLayer[I_].session!==this)throw new DOMException("Base layer was created by a different XRSession","InvalidStateError");if(null!=e.inlineVerticalFieldOfView&&"inline"!==this[B_].mode)throw new DOMException("InlineVerticalFieldOfView must not be set for an immersive session","InvalidStateError");const a={baseLayer:e.baseLayer||(null===(t=this[B_].pendingRenderState)||void 0===t?void 0:t.baseLayer)||void 0,depthFar:e.depthFar||(null===(n=this[B_].pendingRenderState)||void 0===n?void 0:n.depthFar)||void 0,depthNear:e.depthNear||(null===(i=this[B_].pendingRenderState)||void 0===i?void 0:i.depthNear)||void 0,inlineVerticalFieldOfView:e.inlineVerticalFieldOfView||(null===(r=this[B_].pendingRenderState)||void 0===r?void 0:r.inlineVerticalFieldOfView)||void 0};this[B_].pendingRenderState=new Vb(a,this[B_].renderState)}async updateTargetFrameRate(e){return new Promise((t,n)=>{this[B_].ended?n(new DOMException("XRSession has already ended.","InvalidStateError")):this[B_].device.supportedFrameRates.includes(e)?(this[B_].nominalFrameRate===e?console.log("Requested frame rate is the same as the current nominal frame rate, no update made"):(this[B_].nominalFrameRate=e,this.dispatchEvent(new Hb("frameratechange",{session:this})),console.log(`Nominal frame rate updated to ${e}`)),t()):n(new DOMException("Requested frame rate not supported.","InvalidStateError"))})}async requestReferenceSpace(e){return new Promise((t,n)=>{if(this[B_].ended||!this[B_].referenceSpaceIsSupported(e))return void n(new DOMException("The requested reference space type is not supported.","NotSupportedError"));let i;switch(e){case Fb.Viewer:i=this[B_].device.viewerSpace;break;case Fb.Local:i=new Bb(e,this[B_].device[E_].globalSpace,this[B_].device.viewerSpace[G_].offsetMatrix);break;case Fb.LocalFloor:case Fb.BoundedFloor:case Fb.Unbounded:i=new Bb(e,this[B_].device[E_].globalSpace)}this[B_].referenceSpaces.push(i),t(i)})}requestAnimationFrame(e){if(this[B_].ended)return 0;const t=++this[B_].frameHandle;return this[B_].frameCallbacks.push({handle:t,callback:e,cancelled:!1}),t}cancelAnimationFrame(e){let t=this[B_].frameCallbacks,n=t.findIndex(t=>t&&t.handle===e);n>-1&&(t[n].cancelled=!0,t.splice(n,1)),t=this[B_].currentFrameCallbacks,t&&(n=t.findIndex(t=>t&&t.handle===e),n>-1&&(t[n].cancelled=!0))}async end(){return new Promise((e,t)=>{this[B_].ended||null===this[B_].deviceFrameHandle?t(new DOMException("XRSession has already ended.","InvalidStateError")):(globalThis.cancelAnimationFrame(this[B_].deviceFrameHandle),this[B_].device[E_].onSessionEnd(),this.dispatchEvent(new Hb("end",{session:this})),e())})}get persistentAnchors(){return Array.from(this[B_].persistentAnchors.keys())}restorePersistentAnchor(e){return new Promise((t,n)=>{if(this[B_].persistentAnchors.has(e))if(this[B_].ended)n(new DOMException("XRSession has already ended.","InvalidStateError"));else{const i=this[B_].persistentAnchors.get(e);this[B_].newAnchors.has(i)?n(new DOMException(`Multiple concurrent attempts detected to restore the anchor with UUID: ${e}.`,"InvalidStateError")):(this[B_].trackedAnchors.add(i),this[B_].newAnchors.set(i,{resolve:t,reject:n}))}else n(new DOMException(`Persistent anchor with uuid ${e} not found.`,"InvalidStateError"))})}deletePersistentAnchor(e){return new Promise((t,n)=>{if(this[B_].persistentAnchors.has(e)){const n=this[B_].persistentAnchors.get(e);this[B_].persistentAnchors.delete(e),n.delete(),t(void 0)}else n(new DOMException(`Persistent anchor with uuid ${e} not found.`,"InvalidStateError"))})}requestHitTestSource(e){return new Promise((t,n)=>{if(this[B_].enabledFeatures.includes("hit-test"))if(this[B_].ended)n(new DOMException("XRSession has already ended.","InvalidStateError"));else if(this[B_].device[E_].sem){const n=new Nb(this,e);this[B_].hitTestSources.add(n),t(n)}else n(new DOMException("Synthethic Environment Module required for emulating hit-test","OperationError"));else n(new DOMException('WebXR feature "hit-test" is not supported by current session',"NotSupportedError"))})}get onend(){var e;return null!==(e=this[B_].onend)&&void 0!==e?e:()=>{}}set onend(e){this[B_].onend&&this.removeEventListener("end",this[B_].onend),this[B_].onend=e,e&&this.addEventListener("end",e)}get oninputsourceschange(){var e;return null!==(e=this[B_].oninputsourceschange)&&void 0!==e?e:()=>{}}set oninputsourceschange(e){this[B_].oninputsourceschange&&this.removeEventListener("inputsourceschange",this[B_].oninputsourceschange),this[B_].oninputsourceschange=e,e&&this.addEventListener("inputsourceschange",e)}get onselect(){var e;return null!==(e=this[B_].onselect)&&void 0!==e?e:()=>{}}set onselect(e){this[B_].onselect&&this.removeEventListener("select",this[B_].onselect),this[B_].onselect=e,e&&this.addEventListener("select",e)}get onselectstart(){var e;return null!==(e=this[B_].onselectstart)&&void 0!==e?e:()=>{}}set onselectstart(e){this[B_].onselectstart&&this.removeEventListener("selectstart",this[B_].onselectstart),this[B_].onselectstart=e,e&&this.addEventListener("selectstart",e)}get onselectend(){var e;return null!==(e=this[B_].onselectend)&&void 0!==e?e:()=>{}}set onselectend(e){this[B_].onselectend&&this.removeEventListener("selectend",this[B_].onselectend),this[B_].onselectend=e,e&&this.addEventListener("selectend",e)}get onsqueeze(){var e;return null!==(e=this[B_].onsqueeze)&&void 0!==e?e:()=>{}}set onsqueeze(e){this[B_].onsqueeze&&this.removeEventListener("squeeze",this[B_].onsqueeze),this[B_].onsqueeze=e,e&&this.addEventListener("squeeze",e)}get onsqueezestart(){var e;return null!==(e=this[B_].onsqueezestart)&&void 0!==e?e:()=>{}}set onsqueezestart(e){this[B_].onsqueezestart&&this.removeEventListener("squeezestart",this[B_].onsqueezestart),this[B_].onsqueezestart=e,e&&this.addEventListener("squeezestart",e)}get onsqueezeend(){var e;return null!==(e=this[B_].onsqueezeend)&&void 0!==e?e:()=>{}}set onsqueezeend(e){this[B_].onsqueezeend&&this.removeEventListener("squeezeend",this[B_].onsqueezeend),this[B_].onsqueezeend=e,e&&this.addEventListener("squeezeend",e)}get onvisibilitychange(){var e;return null!==(e=this[B_].onvisibilitychange)&&void 0!==e?e:()=>{}}set onvisibilitychange(e){this[B_].onvisibilitychange&&this.removeEventListener("visibilitychange",this[B_].onvisibilitychange),this[B_].onvisibilitychange=e,e&&this.addEventListener("visibilitychange",e)}get onframeratechange(){var e;return null!==(e=this[B_].onframeratechange)&&void 0!==e?e:()=>{}}set onframeratechange(e){this[B_].onframeratechange&&this.removeEventListener("frameratechange",this[B_].onframeratechange),this[B_].onframeratechange=e,e&&this.addEventListener("frameratechange",e)}}!function(e){e.Wrist="wrist",e.ThumbMetacarpal="thumb-metacarpal",e.ThumbPhalanxProximal="thumb-phalanx-proximal",e.ThumbPhalanxDistal="thumb-phalanx-distal",e.ThumbTip="thumb-tip",e.IndexFingerMetacarpal="index-finger-metacarpal",e.IndexFingerPhalanxProximal="index-finger-phalanx-proximal",e.IndexFingerPhalanxIntermediate="index-finger-phalanx-intermediate",e.IndexFingerPhalanxDistal="index-finger-phalanx-distal",e.IndexFingerTip="index-finger-tip",e.MiddleFingerMetacarpal="middle-finger-metacarpal",e.MiddleFingerPhalanxProximal="middle-finger-phalanx-proximal",e.MiddleFingerPhalanxIntermediate="middle-finger-phalanx-intermediate",e.MiddleFingerPhalanxDistal="middle-finger-phalanx-distal",e.MiddleFingerTip="middle-finger-tip",e.RingFingerMetacarpal="ring-finger-metacarpal",e.RingFingerPhalanxProximal="ring-finger-phalanx-proximal",e.RingFingerPhalanxIntermediate="ring-finger-phalanx-intermediate",e.RingFingerPhalanxDistal="ring-finger-phalanx-distal",e.RingFingerTip="ring-finger-tip",e.PinkyFingerMetacarpal="pinky-finger-metacarpal",e.PinkyFingerPhalanxProximal="pinky-finger-phalanx-proximal",e.PinkyFingerPhalanxIntermediate="pinky-finger-phalanx-intermediate",e.PinkyFingerPhalanxDistal="pinky-finger-phalanx-distal",e.PinkyFingerTip="pinky-finger-tip"}(ew||(ew={}));class nw extends Map{}class iw extends $_{constructor(e,t,n){super(t,n),this[V_]={jointName:e,radius:0}}get jointName(){return this[V_].jointName}}const rw={profileId:"oculus-hand",fallbackProfileIds:["generic-hand","generic-hand-select","generic-trigger"],poses:{default:{jointTransforms:{wrist:{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.04913589730858803,.0021463718730956316,.11701996624469757,1],radius:.021460847929120064},"thumb-metacarpal":{offsetMatrix:[-.07536252588033676,-.9959676265716553,-.04867160692811012,0,.5877083539962769,-.08379616588354111,.8047218918800354,0,-.8055551648139954,.032041035592556,.5916536450386047,0,-.010643752291798592,.0006936835707165301,.08736639469861984,1],radius:.019382517784833908},"thumb-phalanx-proximal":{offsetMatrix:[.1374533325433731,-.9904957413673401,.004982374142855406,0,.5534393787384033,.08097179979085922,.8289443850517273,0,-.8214688897132874,-.11118389666080475,.559309184551239,0,.015547193586826324,-.0003480653394944966,.0681300163269043,1],radius:.01228295173496008},"thumb-phalanx-distal":{offsetMatrix:[-.04659227654337883,-.9974699020385742,-.05369402840733528,0,.6812446117401123,-.07104194164276123,.728600800037384,0,-.7305715084075928,-.002631746232509613,.6828309893608093,0,.04330715537071228,.003409178927540779,.0492292083799839,1],radius:.009768804535269737},"thumb-tip":{offsetMatrix:[-.04659227654337883,-.9974699020385742,-.05369402840733528,0,.6812446117401123,-.07104194164276123,.728600800037384,0,-.7305715084075928,-.002631746232509613,.6828309893608093,0,.062003348022699356,.004069602582603693,.03322213143110275,1],radius:.008768804371356964},"index-finger-metacarpal":{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.02009812369942665,.008770795539021492,.08660387247800827,1],radius:.021228281781077385},"index-finger-phalanx-proximal":{offsetMatrix:[.9001791477203369,-.2598813474178314,.3494834005832672,0,.06073702871799469,.8695210218429565,.490146666765213,0,-.4312632381916046,-.41999316215515137,.7985095381736755,0,-.00017739279428496957,.03890012577176094,.039073407649993896,1],radius:.010295259766280651},"index-finger-phalanx-intermediate":{offsetMatrix:[.9082008600234985,-.20898112654685974,.36262574791908264,0,.11045389622449875,.9553793668746948,.27395179867744446,0,-.40369608998298645,-.20874978601932526,.8907597661018372,0,.01617925800383091,.05482936650514603,.008788082748651505,1],radius:.00853810179978609},"index-finger-phalanx-distal":{offsetMatrix:[.9309692978858948,-.16783711314201355,.32423174381256104,0,.1080828532576561,.9749603867530823,.1943446695804596,0,-.34873148798942566,-.14588497579097748,.9257990717887878,0,.02599053829908371,.059902746230363846,-.012860597111284733,1],radius:.007636196445673704},"index-finger-tip":{offsetMatrix:[.9309692978858948,-.16783711314201355,.32423174381256104,0,.1080828532576561,.9749603867530823,.1943446695804596,0,-.34873148798942566,-.14588497579097748,.9257990717887878,0,.03362493962049484,.06421422213315964,-.033461250364780426,1],radius:.006636196281760931},"middle-finger-metacarpal":{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.03627845644950867,.011579737067222595,.08550142496824265,1],radius:.021231964230537415},"middle-finger-phalanx-proximal":{offsetMatrix:[.9876697659492493,-.06786545366048813,.1410750150680542,0,-.015095947310328484,.855663537979126,.5173118710517883,0,-.15582047402858734,-.5130629539489746,.8440889716148376,0,-.021259509027004242,.04587256908416748,.03659208118915558,1],radius:.01117393933236599},"middle-finger-phalanx-intermediate":{offsetMatrix:[.988391637802124,-.04354291781783104,.14555205404758453,0,.008894841186702251,.9729899168014526,.23067504167556763,0,-.15166506171226501,-.22670257091522217,.9620829224586487,0,-.014570588245987892,.06789684295654297,.0003578895702958107,1],radius:.008030958473682404},"middle-finger-phalanx-distal":{offsetMatrix:[.9853697419166565,.044260796159505844,.16458062827587128,0,-.0757969319820404,.9787378311157227,.19059516489505768,0,-.1526455283164978,-.20028135180473328,.9677740931510925,0,-.010392282158136368,.07414241135120392,-.026147106662392616,1],radius:.007629410829395056},"middle-finger-tip":{offsetMatrix:[.9853697419166565,.044260796159505844,.16458062827587128,0,-.0757969319820404,.9787378311157227,.19059516489505768,0,-.1526455283164978,-.20028135180473328,.9677740931510925,0,-.0069718430750072,.08024183660745621,-.05014154314994812,1],radius:.006629410665482283},"ring-finger-metacarpal":{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.05402477830648422,.015797706320881844,.08152295649051666,1],radius:.019088275730609894},"ring-finger-phalanx-proximal":{offsetMatrix:[.9940828680992126,.05735103040933609,.09224652498960495,0,-.10022822767496109,.8116500377655029,.5754809379577637,0,-.041867565363645554,-.5813214182853699,.8125960826873779,0,-.041623555123806,.04171867296099663,.03582974523305893,1],radius:.00992213748395443},"ring-finger-phalanx-intermediate":{offsetMatrix:[.9843675494194031,.12044742703437805,.12850022315979004,0,-.15629759430885315,.9337108135223389,.3221098482608795,0,-.08118485659360886,-.3371586799621582,.937940776348114,0,-.039990875869989395,.06438793987035751,.004141641780734062,1],radius:.007611672393977642},"ring-finger-phalanx-distal":{offsetMatrix:[.9748351573944092,.11857274919748306,.18877571821212769,0,-.15575434267520905,.9681083559989929,.19623035192489624,0,-.15948788821697235,-.22069483995437622,.9622148275375366,0,-.03783353418111801,.07334739714860916,-.020782606676220894,1],radius:.007231088820844889},"ring-finger-tip":{offsetMatrix:[.9748351573944092,.11857274919748306,.18877571821212769,0,-.15575434267520905,.9681083559989929,.19623035192489624,0,-.15948788821697235,-.22069483995437622,.9622148275375366,0,-.03445569798350334,.0802423357963562,-.04392268508672714,1],radius:.0062310886569321156},"pinky-finger-metacarpal":{offsetMatrix:[.9181402921676636,.35625091195106506,.17350243031978607,0,-.39615097641944885,.8352503180503845,.38134080171585083,0,-.009065053425729275,-.41885748505592346,.9080066680908203,0,-.06191859766840935,.013620133511722088,.07850203663110733,1],radius:.01808827556669712},"pinky-finger-phalanx-proximal":{offsetMatrix:[.9714386463165283,.236698180437088,-.016745081171393394,0,-.18462024629116058,.7982627749443054,.5733163952827454,0,.14906984567642212,-.5538501739501953,.8191629648208618,0,-.061502378433942795,.032741155475378036,.03705105185508728,1],radius:.008483353070914745},"pinky-finger-phalanx-intermediate":{offsetMatrix:[.9337416291236877,.35620439052581787,-.03527557849884033,0,-.33203884959220886,.8987522721290588,.28634607791900635,0,.13370157778263092,-.2556603252887726,.9574766755104065,0,-.06608185172080994,.049755651503801346,.011886020191013813,1],radius:.0067641944624483585},"pinky-finger-phalanx-distal":{offsetMatrix:[.9419984817504883,.3303581774234772,.059175245463848114,0,-.33483216166496277,.9130291938781738,.23294763267040253,0,.02292730286717415,-.2392500638961792,.970687210559845,0,-.0687975287437439,.054948460310697556,-.007561664097011089,1],radius:.0064259846694767475},"pinky-finger-tip":{offsetMatrix:[.9419984817504883,.3303581774234772,.059175245463848114,0,-.33483216166496277,.9130291938781738,.23294763267040253,0,.02292730286717415,-.2392500638961792,.970687210559845,0,-.06947512179613113,.0613851435482502,-.028543535619974136,1],radius:.005425984505563974}},gripOffsetMatrix:[-.0005348679260350764,-.8648636937141418,-.5020061135292053,0,-.2741127908229828,-.48265108466148376,.8318111896514893,0,-.9616971015930176,.13805119693279266,-.2368120402097702,0,-.02878567762672901,.0017147823236882687,.04536811262369156,1]},pinch:{jointTransforms:{wrist:{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.06867414712905884,-.009423808194696903,.10627774149179459,1],radius:.021460847929120064},"thumb-metacarpal":{offsetMatrix:[-.5012241005897522,-.8650535345077515,-.0213695727288723,0,.7415963411331177,-.4421543478965759,.5045139193534851,0,-.44587990641593933,.23702676594257355,.8631392121315002,0,-.032122574746608734,-.01196830440312624,.07194234430789948,1],radius:.019382517784833908},"thumb-phalanx-proximal":{offsetMatrix:[-.3175753057003021,-.9460570216178894,-.06419729441404343,0,.8958902955055237,-.32153913378715515,.30658137798309326,0,-.3106854259967804,.03984907269477844,.9496771097183228,0,-.017625702545046806,-.01967475935816765,.04387917369604111,1],radius:.01228295173496008},"thumb-phalanx-distal":{offsetMatrix:[-.4944636821746826,-.8691971898078918,.001086252392269671,0,.8307800889015198,-.4722411036491394,.2946045398712158,0,-.25555649399757385,.14657381176948547,.9556186199188232,0,-.007126678712666035,-.021021386608481407,.011786630377173424,1],radius:.009768804535269737},"thumb-tip":{offsetMatrix:[-.4944636821746826,-.8691971898078918,.001086252392269671,0,.8307800889015198,-.4722411036491394,.2946045398712158,0,-.25555649399757385,.14657381176948547,.9556186199188232,0,.0003423091256991029,-.024528030306100845,-.011410919018089771,1],radius:.008768804371356964},"index-finger-metacarpal":{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.038037415593862534,-.0020236473064869642,.07626739144325256,1],radius:.021228281781077385},"index-finger-phalanx-proximal":{offsetMatrix:[.7986818552017212,-.35985732078552246,.48229536414146423,0,.538311243057251,.7854709625244141,-.30537736415863037,0,-.2689369022846222,.5035246014595032,.8210577368736267,0,-.006869405973702669,.033938243985176086,.04206443578004837,1],radius:.010295259766280651},"index-finger-phalanx-intermediate":{offsetMatrix:[.8285930156707764,-.32672837376594543,.4546217918395996,0,.5577570199966431,.4116027057170868,-.7207564115524292,0,.04836784675717354,.8507823944091797,.5232869386672974,0,.0033306588884443045,.014840902760624886,.010923954658210278,1],radius:.00853810179978609},"index-finger-phalanx-distal":{offsetMatrix:[.8412464261054993,-.35794928669929504,.4051857888698578,0,.5139996409416199,.29711154103279114,-.8046918511390686,0,.16765329241752625,.8852096796035767,.4339304566383362,0,.0021551470272243023,-.0058362227864563465,-.0017938464879989624,1],radius:.007636196445673704},"index-finger-tip":{offsetMatrix:[.8412464261054993,-.35794928669929504,.4051857888698578,0,.5139996409416199,.29711154103279114,-.8046918511390686,0,.16765329241752625,.8852096796035767,.4339304566383362,0,-.00131594471167773,-.025222131982445717,-.012442642822861671,1],radius:.006636196281760931},"middle-finger-metacarpal":{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.05395089089870453,.003063359996303916,.07402937114238739,1],radius:.021231964230537415},"middle-finger-phalanx-proximal":{offsetMatrix:[.9187911748886108,-.1530158370733261,.36387869715690613,0,.038666240870952606,.9522662162780762,.302808940410614,0,-.3928440511226654,-.26414817571640015,.8808513283729553,0,-.02717282809317112,.04162866622209549,.03678669035434723,1],radius:.01117393933236599},"middle-finger-phalanx-intermediate":{offsetMatrix:[.9228746294975281,-.12856416404247284,.36300456523895264,0,.14524033665657043,.9892153143882751,-.01890045404434204,0,-.3566599190235138,.07016586512327194,.9315956234931946,0,-.01030921470373869,.05296773463487625,-.0010256498353555799,1],radius:.008030958473682404},"middle-finger-phalanx-distal":{offsetMatrix:[.9325166344642639,-.040404170751571655,.35885775089263916,0,.06836572289466858,.995502769947052,-.0655682161450386,0,-.3545948565006256,.08567725121974945,.9310863614082336,0,-.0004833847051486373,.05103470757603645,-.026690717786550522,1],radius:.007629410829395056},"middle-finger-tip":{offsetMatrix:[.9325166344642639,-.040404170751571655,.35885775089263916,0,.06836572289466858,.995502769947052,-.0655682161450386,0,-.3545948565006256,.08567725121974945,.9310863614082336,0,.008158999495208263,.05004044249653816,-.050120558589696884,1],radius:.006629410665482283},"ring-finger-metacarpal":{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.06732909381389618,.007902119308710098,.07209732383489609,1],radius:.019088275730609894},"ring-finger-phalanx-proximal":{offsetMatrix:[.9391821026802063,-.027994679287075996,.34227466583251953,0,-.18282271921634674,.8029410243034363,.5673282742500305,0,-.2907087206840515,-.5954000353813171,.7489906549453735,0,-.047129884362220764,.03806127607822418,.032147664576768875,1],radius:.00992213748395443},"ring-finger-phalanx-intermediate":{offsetMatrix:[.9249380826950073,.03699534013867378,.3783116042613983,0,-.12898847460746765,.9667453765869141,.2208271026611328,0,-.3575615882873535,-.25304901599884033,.8989526629447937,0,-.03579339757561684,.06127955764532089,.002939916681498289,1],radius:.007611672393977642},"ring-finger-phalanx-distal":{offsetMatrix:[.9001164436340332,.03983335196971893,.4338230490684509,0,-.09662467986345291,.9892624020576477,.10964841395616531,0,-.4247973561286926,-.14061418175697327,.8943013548851013,0,-.026291755959391594,.06800390034914017,-.02094830758869648,1],radius:.007231088820844889},"ring-finger-tip":{offsetMatrix:[.9001164436340332,.03983335196971893,.4338230490684509,0,-.09662467986345291,.9892624020576477,.10964841395616531,0,-.4247973561286926,-.14061418175697327,.8943013548851013,0,-.016345610842108727,.07300511747598648,-.04263874143362045,1],radius:.0062310886569321156},"pinky-finger-metacarpal":{offsetMatrix:[.8769711852073669,.31462907791137695,.36322021484375,0,-.4506046175956726,.801031768321991,.39408499002456665,0,-.16696058213710785,-.5092697143554688,.8442559838294983,0,-.07460174709558487,.0062340241856873035,.06756893545389175,1],radius:.01808827556669712},"pinky-finger-phalanx-proximal":{offsetMatrix:[.9498357176780701,.1553308218717575,.2714462876319885,0,-.3019258379936218,.6817675232887268,.6663586497306824,0,-.08155745267868042,-.7148879170417786,.694466233253479,0,-.06697750836610794,.029482364654541016,.02902858518064022,1],radius:.008483353070914745},"pinky-finger-phalanx-intermediate":{offsetMatrix:[.9214097261428833,.27928245067596436,.2701927423477173,0,-.3670244514942169,.8538867831230164,.36901235580444336,0,-.12765564024448395,-.43917882442474365,.8892839550971985,0,-.06447203457355499,.05144399777054787,.0076942890882492065,1],radius:.0067641944624483585},"pinky-finger-phalanx-distal":{offsetMatrix:[.9038633704185486,.23618005216121674,.3567195236682892,0,-.3532794713973999,.8823202252388,.3109731376171112,0,-.24129553139209747,-.4070987403392792,.8809353709220886,0,-.06187915802001953,.060364335775375366,-.010368337854743004,1],radius:.0064259846694767475},"pinky-finger-tip":{offsetMatrix:[.9038633704185486,.23618005216121674,.3567195236682892,0,-.3532794713973999,.8823202252388,.3109731376171112,0,-.24129553139209747,-.4070987403392792,.8809353709220886,0,-.056796226650476456,.07042007893323898,-.02921444922685623,1],radius:.005425984505563974}},gripOffsetMatrix:[.08027800917625427,-.8086723685264587,-.5827556252479553,0,-.4154181480407715,-.5585916638374329,.7179154753684998,0,-.9060805439949036,.1844543218612671,-.3807799518108368,0,-.038054611533880234,-.002910431008785963,.03720742464065552,1]},point:{jointTransforms:{wrist:{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.05789132043719292,.01670890860259533,.11183350533246994,1],radius:.021460847929120064},"thumb-metacarpal":{offsetMatrix:[.02145560085773468,-.9978390336036682,.0621047280728817,0,.41311800479888916,.06541631370782852,.9083252549171448,0,-.9104245901107788,.006167683284729719,.4136286973953247,0,-.016488194465637207,.012708572670817375,.08862338215112686,1],radius:.019382517784833908},"thumb-phalanx-proximal":{offsetMatrix:[.21270370483398438,-.966137707233429,.14606566727161407,0,.49890995025634766,.2359165996313095,.8339261412620544,0,-.8401462435722351,-.10450579971075058,.5321959853172302,0,.013112368993461132,.012508046813309193,.07517509907484055,1],radius:.01228295173496008},"thumb-phalanx-distal":{offsetMatrix:[.01653280481696129,-.9986647963523865,.048943229019641876,0,.26313456892967224,.051570065319538116,.9633802771568298,0,-.9646173715591431,-.0030490627977997065,.26363563537597656,0,.04150351136922836,.016039609909057617,.05719054117798805,1],radius:.009768804535269737},"thumb-tip":{offsetMatrix:[.01653280481696129,-.9986647963523865,.048943229019641876,0,.26313456892967224,.051570065319538116,.9633802771568298,0,-.9646173715591431,-.0030490627977997065,.26363563537597656,0,.06548332422971725,.01683700829744339,.0516640841960907,1],radius:.008768804371356964},"index-finger-metacarpal":{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.02592567168176174,.019982583820819855,.08479326963424683,1],radius:.021228281781077385},"index-finger-phalanx-proximal":{offsetMatrix:[.9063700437545776,-.21756279468536377,.3621589243412018,0,.0970839336514473,.9415287375450134,.3226419687271118,0,-.41117796301841736,-.2572731077671051,.8744958639144897,0,-.0015709538711234927,.043078210204839706,.034657616168260574,1],radius:.010295259766280651},"index-finger-phalanx-intermediate":{offsetMatrix:[.9159826040267944,-.1651475727558136,.36565208435058594,0,.09755707532167435,.9756820797920227,.1962820291519165,0,-.3891757130622864,-.14411886036396027,.9098196625709534,0,.014023927971720695,.052835866808891296,.0014903299743309617,1],radius:.00853810179978609},"index-finger-phalanx-distal":{offsetMatrix:[.9378057718276978,-.12329639494419098,.3245268166065216,0,.032558172941207886,.9619227051734924,.2713746726512909,0,-.3456292748451233,-.2439306229352951,.9061115384101868,0,.023482320830225945,.05633850023150444,-.020621655508875847,1],radius:.007636196445673704},"index-finger-tip":{offsetMatrix:[.9378057718276978,-.12329639494419098,.3245268166065216,0,.032558172941207886,.9619227051734924,.2713746726512909,0,-.3456292748451233,-.2439306229352951,.9061115384101868,0,.03096788562834263,.06281610578298569,-.040703095495700836,1],radius:.006636196281760931},"middle-finger-metacarpal":{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.04184452444314957,.022474845871329308,.08177298307418823,1],radius:.021231964230537415},"middle-finger-phalanx-proximal":{offsetMatrix:[.9720265865325928,-.08313076198101044,.21966552734375,0,.20477405190467834,.7580050826072693,-.6192700862884521,0,-.11502730846405029,.6469289064407349,.7538246512413025,0,-.022107340395450592,.05035499855875969,.02970452979207039,1],radius:.01117393933236599},"middle-finger-phalanx-intermediate":{offsetMatrix:[.9779140949249268,-.07129573822021484,.19646917283535004,0,.1287083923816681,-.5352076292037964,-.8348574042320251,0,.1646735966205597,.8417060971260071,-.5142109394073486,0,-.017169542610645294,.022584279999136925,-.00265491777099669,1],radius:.008030958473682404},"middle-finger-phalanx-distal":{offsetMatrix:[.9774913787841797,-.19657190144062042,.07661263644695282,0,-.1924918293952942,-.9796126484870911,-.05749811604619026,0,.08635343611240387,.041456472128629684,-.995401918888092,0,-.02170622907578945,-.0006043742760084569,.011511396616697311,1],radius:.007629410829395056},"middle-finger-tip":{offsetMatrix:[.9774913787841797,-.19657190144062042,.07661263644695282,0,-.1924918293952942,-.9796126484870911,-.05749811604619026,0,.08635343611240387,.041456472128629684,-.995401918888092,0,-.02438267692923546,-.0026927536819130182,.03627248480916023,1],radius:.006629410665482283},"ring-finger-metacarpal":{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.05944233387708664,.0264605600386858,.07478221505880356,1],radius:.019088275730609894},"ring-finger-phalanx-proximal":{offsetMatrix:[.9842101335525513,.024470895528793335,.1753024309873581,0,.12200043350458145,.6237703561782837,-.7720272541046143,0,-.12824076414108276,.7812241315841675,.610936164855957,0,-.04249368980526924,.0467497780919075,.027722163125872612,1],radius:.00992213748395443},"ring-finger-phalanx-intermediate":{offsetMatrix:[.9941774606704712,.05949164181947708,.08983955532312393,0,.10504482686519623,-.7208291888237,-.6851072907447815,0,.024001073092222214,.6905553936958313,-.7228817939758301,0,-.0374927744269371,.016285063698887825,.0038980208337306976,1],radius:.007611672393977642},"ring-finger-phalanx-distal":{offsetMatrix:[.9995742440223694,.01638498157262802,.02412819117307663,0,.007813597097992897,-.9474818110466003,.31971633434295654,0,.028100071474909782,-.31939181685447693,-.9472070932388306,0,-.038130562752485275,-.0020653479732573032,.02310742810368538,1],radius:.007231088820844889},"ring-finger-tip":{offsetMatrix:[.9995742440223694,.01638498157262802,.02412819117307663,0,.007813597097992897,-.9474818110466003,.31971633434295654,0,.028100071474909782,-.31939181685447693,-.9472070932388306,0,-.0390593595802784,.004176302347332239,.0466572530567646,1],radius:.0062310886569321156},"pinky-finger-metacarpal":{offsetMatrix:[.9147363901138306,.3458845317363739,.20885537564754486,0,-.3923271894454956,.8839452862739563,.2544005811214447,0,-.09662359952926636,-.3146490156650543,.9442773461341858,0,-.06715242564678192,.024195827543735504,.07137546688318253,1],radius:.01808827556669712},"pinky-finger-phalanx-proximal":{offsetMatrix:[.9613109827041626,.22439135611057281,.15977802872657776,0,.01002211682498455,.5511574745178223,-.8343409299850464,0,-.27528178691864014,.8036624789237976,.5275853276252747,0,-.06273911893367767,.038559623062610626,.028268879279494286,1],radius:.008483353070914745},"pinky-finger-phalanx-intermediate":{offsetMatrix:[.9820972084999084,.18811029195785522,-.00995189044624567,0,.14063723385334015,-.7673450708389282,-.6256227493286133,0,-.12532226741313934,.6130226850509644,-.7800630927085876,0,-.05428232625126839,.013870777562260628,.012061242014169693,1],radius:.0067641944624483585},"pinky-finger-phalanx-distal":{offsetMatrix:[.9744614362716675,.20454788208007812,-.09265263378620148,0,.22429193556308746,-.9065253138542175,.35764020681381226,0,-.010836843401193619,-.3692878782749176,-.9292529225349426,0,-.05173685774207115,.0014194445684552193,.02790539152920246,1],radius:.0064259846694767475},"pinky-finger-tip":{offsetMatrix:[.9744614362716675,.20454788208007812,-.09265263378620148,0,.22429193556308746,-.9065253138542175,.35764020681381226,0,-.010836843401193619,-.3692878782749176,-.9292529225349426,0,-.05098633095622063,.008463085629045963,.048688892275094986,1],radius:.005425984505563974}},gripOffsetMatrix:[.005510995630174875,-.9149997234344482,-.40341615676879883,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.9340395331382751,.13936474919319153,-.32885703444480896,0,-.031803809106349945,.007837686687707901,.04313928261399269,1]}}},aw={mapping:sb.None,buttons:[{id:"pinch",type:"analog",eventTrigger:"select"}],axes:[]},sw=i_(),ow=p_(),lw=i_(),cw=i_(),uw=p_(),dw=i_(),hw=i_(),fw=p_(),pw=i_(),mw=(e,t,n,i)=>(Jx(sw,t),t_(ow,t),e_(lw,t),Jx(cw,n),t_(uw,n),e_(dw,n),u_(hw,sw,cw,i),g_(fw,ow,uw,i),u_(pw,lw,dw,i),function(e,t,n,i){var r=t[0],a=t[1],s=t[2],o=t[3],l=r+r,c=a+a,u=s+s,d=r*l,h=r*c,f=r*u,p=a*c,m=a*u,g=s*u,v=o*l,y=o*c,x=o*u,_=i[0],b=i[1],w=i[2];e[0]=(1-(p+g))*_,e[1]=(h+x)*_,e[2]=(f-y)*_,e[3]=0,e[4]=(h-x)*b,e[5]=(1-(d+g))*b,e[6]=(m+v)*b,e[7]=0,e[8]=(f+y)*w,e[9]=(m-v)*w,e[10]=(1-(d+p))*w,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1}(e,fw,hw,pw),e),gw=[1,-1,-1,0,-1,1,1,0,-1,1,1,0,-1,1,1,1];class vw extends gb{constructor(e,t,n){if(t!==ob.Left&&t!==ob.Right)throw new DOMException('handedness for XRHandInput must be either "left" or "right"',"InvalidStateError");if(!e.poses.default||!e.poses.pinch)throw new DOMException('"default" and "pinch" hand pose configs are required',"InvalidStateError");const i=new $_(n),r=new $_(i),a=[e.profileId,...e.fallbackProfileIds],s=new nw;Object.values(ew).forEach(e=>{s.set(e,new iw(e,i))});super(new fb(t,lb.TrackedPointer,a,i,new db(aw),r,s)),this[T_]={poseId:"default",poses:e.poses},this.updateHandPose()}get poseId(){return this[T_].poseId}set poseId(e){this[T_].poses[e]?this[T_].poseId=e:console.warn(`Pose config ${e} not found`)}updateHandPose(){const e=this[T_].poses[this[T_].poseId],t=this[T_].poses.pinch;Object.values(ew).forEach(n=>{const i=e.jointTransforms[n].offsetMatrix,r=t.jointTransforms[n].offsetMatrix,a=this.inputSource.hand.get(n);mw(a[G_].offsetMatrix,i,r,this.pinchValue),this.inputSource.handedness===ob.Right&&(e=>{for(let t=0;t<16;t++)e[t]*=gw[t]})(a[G_].offsetMatrix),a[V_].radius=(1-this.pinchValue)*e.jointTransforms[n].radius+this.pinchValue*t.jointTransforms[n].radius}),e.gripOffsetMatrix&&t.gripOffsetMatrix&&mw(this.inputSource.gripSpace[G_].offsetMatrix,e.gripOffsetMatrix,t.gripOffsetMatrix,this.pinchValue)}get pinchValue(){return this[A_].inputSource.gamepad[C_].buttonsMap.pinch.value}updatePinchValue(e){if(e>1||e<0)return void console.warn(`Out-of-range value ${e} provided for pinch`);this[A_].inputSource.gamepad[C_].buttonsMap.pinch[C_].pendingValue=e}onFrameStart(e){super.onFrameStart(e),this.updateHandPose()}}class yw extends EventTarget{}const xw={antialias:!0,depth:!0,stencil:!1,alpha:!0,ignoreDepthValues:!1,framebufferScaleFactor:1};let _w=class extends yw{constructor(e,t,n={}){if(super(),e[B_].ended)throw new DOMException("Session has ended","InvalidStateError");const i={...xw,...n};this[I_]={session:e,context:t,antialias:i.antialias}}get context(){return this[I_].context}get antialias(){return this[I_].antialias}get ignoreDepthValues(){return!0}get framebuffer(){return null}get framebufferWidth(){return this[I_].context.drawingBufferWidth}get framebufferHeight(){return this[I_].context.drawingBufferHeight}getViewport(e){if(e[j_].session!==this[I_].session)throw new DOMException("View's session differs from Layer's session","InvalidStateError");return this[I_].session[B_].device[E_].getViewport(this,e)}static getNativeFramebufferScaleFactor(e){if(!(e instanceof tw))throw new TypeError("getNativeFramebufferScaleFactor must be passed a session.");return e[B_].ended?0:1}};class bw{constructor(e,t,n){const{schema:i,frames:r}=t;if(!r||!i||0===r.length)throw new DOMException("wrong recording format","NotSupportedError");const a=new Bb(Fb.Viewer,e),s={[zb.Left]:new $_(a),[zb.Right]:new $_(a),[zb.None]:new $_(a)};this[w_]={refSpace:e,inputSources:new Map,inputSchemas:new Map,frames:r,recordedFramePointer:0,startingTimeStamp:r[0][0],endingTimeStamp:r[r.length-1][0],playbackTime:r[0][0],playing:!1,viewerSpace:a,viewSpaces:s,vec3:i_(),quat:p_()},Kx(this[w_].viewSpaces[zb.Left][G_].offsetMatrix,r_(-n/2,0,0)),Kx(this[w_].viewSpaces[zb.Right][G_].offsetMatrix,r_(n/2,0,0)),i.forEach(t=>{const n=t[0],i=t[1];let r;if(i.hasGamepad){const e=[];for(let t=0;t<i.numButtons;t++)e.push({id:t.toString(),type:"manual"});const t=[];for(let e=0;e<i.numAxes;e++)t.push({id:e.toString(),type:"manual"});r=new db({mapping:i.mapping,buttons:e,axes:t})}const a=new $_(e);let s;i.hasHand&&(s=new nw,Object.values(ew).forEach(e=>{s.set(e,new iw(e,a))}));const o=new fb(i.handedness,i.targetRayMode,i.profiles,a,r,i.hasGrip?new $_(e):void 0,i.hasHand?s:void 0);this[w_].inputSources.set(n,{active:!1,source:o}),this[w_].inputSchemas.set(n,i)})}play(){this[w_].recordedFramePointer=0,this[w_].playbackTime=this[w_].startingTimeStamp,this[w_].playing=!0,this[w_].actualTimeStamp=performance.now()}stop(){this[w_].playing=!1}get playing(){return this[w_].playing}get viewerSpace(){return this[w_].viewerSpace}get viewSpaces(){return this[w_].viewSpaces}get inputSources(){return Array.from(this[w_].inputSources.values()).filter(e=>e.active).map(e=>e.source)}playFrame(){const e=performance.now(),t=e-this[w_].actualTimeStamp;if(this[w_].actualTimeStamp=e,this[w_].playbackTime+=t,this[w_].playbackTime>this[w_].endingTimeStamp)return void this.stop();for(;this[w_].frames[this[w_].recordedFramePointer+1][0]<this[w_].playbackTime;)this[w_].recordedFramePointer++;const n=this[w_].frames[this[w_].recordedFramePointer],i=this[w_].frames[this[w_].recordedFramePointer+1],r=(this[w_].playbackTime-n[0])/(i[0]-n[0]);this.updateXRSpaceFromMergedFrames(this[w_].viewerSpace,n.slice(1,8),i.slice(1,8),r);const a=new Map;for(let e=8;e<n.length;e++){const{index:t,inputData:i}=this.processRawInputData(n[e]);a.set(t,i)}const s=new Map;for(let e=8;e<i.length;e++){const{index:t,inputData:n}=this.processRawInputData(i[e]);s.set(t,n)}this[w_].inputSources.forEach(e=>{e.active=!1}),s.forEach((e,t)=>{this[w_].inputSources.get(t).active=!0;const n=this[w_].inputSources.get(t).source,i=this[w_].inputSchemas.get(t);this.updateInputSource(n,i,a.has(t)?a.get(t):e,e,r)})}updateInputSource(e,t,n,i,r){if(this.updateXRSpaceFromMergedFrames(e.targetRaySpace,n.targetRayTransform,i.targetRayTransform,r),t.hasGrip&&this.updateXRSpaceFromMergedFrames(e.gripSpace,n.gripTransform,i.gripTransform,r),t.hasHand)for(let a=0;a<25;a++){const s=n.handTransforms.slice(8*a,8*a+7),o=i.handTransforms.slice(8*a,8*a+7),l=n.handTransforms[8*a+7],c=i.handTransforms[8*a+7],u=e.hand.get(t.jointSequence[a]);this.updateXRSpaceFromMergedFrames(u,s,o,r),u[V_].radius=(c-l)*r+l}if(t.hasGamepad){const t=e.gamepad;i.buttons.forEach((e,i)=>{const a=t.buttons[i];a[C_].pressed=1===e[0],a[C_].touched=1===e[1];const s=n.buttons[i][2],o=e[2];a[C_].value=(o-s)*r+s}),i.axes.forEach((e,i)=>{const a=n.axes[i];t[C_].axesMap[i.toString()].x=(e-a)*r+a})}}updateXRSpaceFromMergedFrames(e,t,n,i){const r=r_(t[0],t[1],t[2]),a=y_(t[3],t[4],t[5],t[6]),s=r_(n[0],n[1],n[2]),o=y_(n[3],n[4],n[5],n[6]);u_(this[w_].vec3,r,s,i),g_(this[w_].quat,a,o,i),Qx(e[G_].offsetMatrix,this[w_].quat,this[w_].vec3)}processRawInputData(e){const t=e[0],n=this[w_].inputSchemas.get(t),i={targetRayTransform:e.slice(1,8)};let r=8;if(n.hasGrip&&(i.gripTransform=e[r++]),n.hasHand&&(i.handTransforms=e[r++]),n.hasGamepad){const t=e[r];i.buttons=t.slice(0,n.numButtons),i.axes=t.slice(n.numButtons)}return{index:t,inputData:i}}}const ww="2.2.0";class Sw extends Event{constructor(e,t){if(super(e,t),!t.referenceSpace)throw new Error("XRReferenceSpaceEventInit.referenceSpace is required");this.referenceSpace=t.referenceSpace,this.transform=t.transform}}class Mw extends EventTarget{constructor(e){super(),this[P_]={device:e,grantSession:({resolve:e,reject:t,mode:n,options:i})=>{if(this[P_].activeSession)return void t(new DOMException("An active XRSession already exists.","InvalidStateError"));const{requiredFeatures:r=[],optionalFeatures:a=[]}=i,{supportedFeatures:s}=this[P_].device;if(!r.every(e=>s.includes(e)))return void t(new Error("One or more required features are not supported by the device."));const o=a.filter(e=>s.includes(e)),l=Array.from(new Set([...r,...o,"viewer","local"])),c=new tw(this[P_].device,n,l);this[P_].activeSession=c,c.addEventListener("end",()=>{this[P_].activeSession=void 0}),e(c)}}}isSessionSupported(e){return new Promise((t,n)=>{t("inline"===e||this[P_].device.supportedSessionModes.includes(e))})}requestSession(e,t={}){return new Promise((n,i)=>{this.isSessionSupported(e).then(r=>{if(!r)return void i(new DOMException("The requested XRSession mode is not supported.","NotSupportedError"));const a={resolve:n,reject:i,mode:e,options:t};this[P_].grantSession(a)}).catch(i)})}offerSession(e,t={}){return new Promise((n,i)=>{this.isSessionSupported(e).then(r=>{r?this[P_].offeredSessionConfig={resolve:n,reject:i,mode:e,options:t}:i(new DOMException("The requested XRSession mode is not supported.","NotSupportedError"))}).catch(i)})}}class Ew{constructor(e,t,n,i){this[W_]={x:e,y:t,width:n,height:i}}get x(){return this[W_].x}get y(){return this[W_].y}get width(){return this[W_].width}get height(){return this[W_].height}}
|
|
396
396
|
/**
|
|
397
397
|
* @license
|
|
398
398
|
* webxr-layers-polyfill
|
|
@@ -595,4 +595,4 @@ uniform samplerCube u_texture;
|
|
|
595
595
|
void main() {
|
|
596
596
|
gl_FragColor = textureCube(u_texture, normalize(v_normal));
|
|
597
597
|
}
|
|
598
|
-
`;class bS{constructor(e,t){this.savedVaoState={vao:null,arrayBuffer:null},this.hasMipmap=!1,this.layer=e,this.gl=t,this.transformMatrix=iS(),this.program=Xw(t,xS,_S),this.programInfo={attribLocations:{a_position:t.getAttribLocation(this.program,"a_position")},uniformLocations:{u_matrix:t.getUniformLocation(this.program,"u_matrix"),u_texture:t.getUniformLocation(this.program,"u_texture"),u_projectionMatrix:t.getUniformLocation(this.program,"u_projectionMatrix")}},this._createVAOs()}saveVaoState(){this.savedVaoState.vao=this.gl.getParameter(this.vaoGl.VERTEX_ARRAY_BINDING),this.savedVaoState.arrayBuffer=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING)}restoreVaoState(){this.vaoGl.bindVertexArray(this.savedVaoState.vao),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.savedVaoState.arrayBuffer),this.savedVaoState.vao=this.savedVaoState.arrayBuffer=null}render(e,t){this.saveVaoState();let n=this.gl,i=e.getBaseLayer(),r=t.getViewerPose(e.getReferenceSpace());const a=n.getParameter(n.ACTIVE_TEXTURE);for(let e of r.views){let t=i.getViewport(e);n.viewport(t.x,t.y,t.width,t.height),n.activeTexture(n.TEXTURE0);const r=n.getParameter(n.TEXTURE_BINDING_CUBE_MAP);if(this.layer.layout===Aw.stereo){const t="right"===e.eye?1:0;n.bindTexture(n.TEXTURE_CUBE_MAP,this.layer.colorTextures[t])}else n.bindTexture(n.TEXTURE_CUBE_MAP,this.layer.colorTextures[0]);this.layer.isStatic?(!0===this.layer.needsRedraw&&n.generateMipmap(n.TEXTURE_CUBE_MAP),this.hasMipmap=!0):this.hasMipmap=this.layer.mipLevels>0,n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR),this._renderInternal(this.layer.orientation,e),n.activeTexture(a),n.bindTexture(n.TEXTURE_CUBE_MAP,r)}this.restoreVaoState()}createPositionPoints(){const e=.5;return new Float32Array([-e,-e,-e,-e,e,-e,e,-e,-e,-e,e,-e,e,e,-e,e,-e,-e,-e,-e,e,e,-e,e,-e,e,e,-e,e,e,e,-e,e,e,e,e,-e,e,-e,-e,e,e,e,e,-e,-e,e,e,e,e,e,e,e,-e,-e,-e,-e,e,-e,-e,-e,-e,e,-e,-e,e,e,-e,-e,e,-e,e,-e,-e,-e,-e,-e,e,-e,e,-e,-e,-e,e,-e,e,e,-e,e,-e,e,-e,-e,e,e,-e,e,-e,e,e,-e,e,e,e,-e,e,e,e])}_renderInternal(e,t){let n=this.gl;const i=n.getParameter(n.CURRENT_PROGRAM);n.useProgram(this.program),this.vaoGl.bindVertexArray(this.vao),aS(this.transformMatrix,[e.x,e.y,e.z,e.w]),this._poseOrientationMatrix||(this._poseOrientationMatrix=iS()),aS(this._poseOrientationMatrix,[t.transform.inverse.orientation.x,t.transform.inverse.orientation.y,t.transform.inverse.orientation.z,t.transform.inverse.orientation.w]),rS(this.transformMatrix,this.transformMatrix,this._poseOrientationMatrix),n.uniformMatrix4fv(this.programInfo.uniformLocations.u_matrix,!1,this.transformMatrix),n.uniformMatrix4fv(this.programInfo.uniformLocations.u_projectionMatrix,!1,t.projectionMatrix),n.uniform1i(this.programInfo.uniformLocations.u_texture,0);var r=n.TRIANGLES,a=this.positionPoints.length/3;n.drawArrays(r,0,a),this.vaoGl.bindVertexArray(null),n.useProgram(i)}_recalculateVertices(){this.positionPoints=this.createPositionPoints()}_createVAOs(){this._recalculateVertices();let e=this.gl;this.vaoGl=qw(e),this.saveVaoState();let t=e.createBuffer();this.vao=this.vaoGl.createVertexArray(),this.vaoGl.bindVertexArray(this.vao),e.enableVertexAttribArray(this.programInfo.attribLocations.a_position),e.bindBuffer(e.ARRAY_BUFFER,t);const n=this.positionPoints;e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW);var i=e.FLOAT;e.vertexAttribPointer(this.programInfo.attribLocations.a_position,3,i,!1,0,0),this.restoreVaoState()}}class wS{constructor(){this.mode="inline",this.layers=[],this.views=[],this.initializedViews=!1,this.isPolyfillActive=!1,this.taskQueue=[]}requestAnimationFrame(e){this.injectedFrameCallback||(this.injectedFrameCallback=(t,n)=>{let i=this.context;if(!this.initializedViews&&this.referenceSpace){let e=n.getViewerPose(this.referenceSpace);e&&(this.views=e.views,this.initializedViews=!0)}if(this.isPolyfillActive&&this.initializedViews){this.tempFramebuffer||(this.tempFramebuffer=i.createFramebuffer()),i.bindFramebuffer(i.FRAMEBUFFER,this.tempFramebuffer);const e=i.getParameter(i.COLOR_CLEAR_VALUE),t=i.getParameter(i.FRAMEBUFFER_BINDING);i.clearColor(0,0,0,0);for(let e of this.layers)if(e instanceof Gw)for(let t=0;t<e.colorTextures.length;t++){e.colorTexturesMeta[t].type===Tw["texture-array"]||(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e.colorTextures[t],0),e.depthStencilTextures&&t<e.depthStencilTextures.length?i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,e.depthStencilTextures[t],0):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,null,0),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT))}i.bindFramebuffer(i.FRAMEBUFFER,t),i.clearColor(e[0],e[1],e[2],e[3])}if(e(t,n),this.isPolyfillActive&&this.initializedViews){let e=i.isEnabled(i.BLEND),t=i.isEnabled(i.DEPTH_TEST),r=i.isEnabled(i.CULL_FACE);const a=i.getParameter(i.FRAMEBUFFER_BINDING),s=i.getParameter(i.COLOR_CLEAR_VALUE);i.bindFramebuffer(i.FRAMEBUFFER,this.getBaseLayer().framebuffer),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.clearColor(s[0],s[1],s[2],s[3]),i.enable(i.BLEND),i.disable(i.DEPTH_TEST),i.disable(i.CULL_FACE);let o=i.getParameter(i.BLEND_SRC_RGB),l=i.getParameter(i.BLEND_SRC_ALPHA),c=i.getParameter(i.BLEND_DST_RGB),u=i.getParameter(i.BLEND_DST_ALPHA);i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA);for(let e of this.layers)if(this.renderers||(this.renderers=new WeakMap),e instanceof Gw){this.renderers.has(e)||this.renderers.set(e,tS(e,this.context));this.renderers.get(e).render(this)}else if(e instanceof Bw){this.renderers.has(e)||this.renderers.set(e,new fS(e,this.context));this.renderers.get(e).render(this,n)}else if(e instanceof Nw){this.renderers.has(e)||this.renderers.set(e,new pS(e,this.context));this.renderers.get(e).render(this,n)}else if(e instanceof Uw){this.renderers.has(e)||this.renderers.set(e,new mS(e,this.context));this.renderers.get(e).render(this,n)}else if(e instanceof vS){this.renderers.has(e)||this.renderers.set(e,new bS(e,this.context));this.renderers.get(e).render(this,n)}else{const t=e;if(null===t.framebuffer)continue;i instanceof WebGL2RenderingContext?(i.bindFramebuffer(i.READ_FRAMEBUFFER,t.framebuffer),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,this.getBaseLayer().framebuffer),i.blitFramebuffer(0,0,t.framebufferWidth,t.framebufferHeight,0,0,this.getBaseLayer().framebufferWidth,this.getBaseLayer().framebufferHeight,i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT,i.LINEAR)):console.warn("GL blitFramebuffer is not supported on WebGL1, so XRWebGLLayers may not show up properly when polyfilled.")}for(e||i.disable(i.BLEND),t&&i.enable(i.DEPTH_TEST),r&&i.enable(i.CULL_FACE),i.blendFuncSeparate(o,c,l,u),i.bindFramebuffer(i.FRAMEBUFFER,a);this.taskQueue.length>0;){this.taskQueue.shift()()}}}),this._requestAnimationFrame(this.injectedFrameCallback)}updateRenderState(e){if(this.existingBaseLayer=e.baseLayer,e.layers&&(this.layers=e.layers),this.activeRenderState||this.createActiveRenderState(),this.activeRenderState=Object.assign(Object.assign({},this.activeRenderState),e),!e.layers)return void this._updateRenderState(e);let t,n=Object.assign({},e);delete n.layers;for(let i of this.layers)if(i instanceof Lw){t=i.getContext();break}if(!t&&!this.context){console.log("No existing context! Have the session make one");const r=document.createElement("canvas");if(t=r.getContext("webgl2",{xrCompatible:!0}),t||(t=r.getContext("webgl",{xrCompatible:!0})),!t)throw new Error("No webGL support detected.");function a(){t.canvas.width=t.canvas.clientWidth*window.devicePixelRatio,t.canvas.height=t.canvas.clientHeight*window.devicePixelRatio}document.body.appendChild(t.canvas),window.addEventListener("resize",a),a()}this.createInternalLayer(t),this.isPolyfillActive=!0,this._updateRenderState(Object.assign(Object.assign({},n),{baseLayer:this.internalLayer}))}initializeSession(e){this.mode=e,this.requestReferenceSpace("local").then(e=>{this.referenceSpace=e}).catch(e=>{}),this.requestReferenceSpace("viewer").then(e=>{this.viewerSpace=e})}getBaseLayer(e){return this.internalLayer||this.existingBaseLayer||!e||this.createInternalLayer(e),this.internalLayer||this.existingBaseLayer}getReferenceSpace(){return this.referenceSpace?this.referenceSpace:this.viewerSpace}getViewerSpace(){return this.viewerSpace}queueTask(e){this.taskQueue.push(e)}get renderState(){return this.activeRenderState||this.createActiveRenderState(),this.activeRenderState}get internalViews(){return this.views}getViewIndex(e){for(let t=0;t<this.views.length;t++){let n=this.views[t];if(e.eye===n.eye&&e.recommendedViewportScale===n.recommendedViewportScale)return t}return-1}createInternalLayer(e){if(!e&&this.internalLayer)return this.internalLayer;if(e===this.context&&this.internalLayer)return this.internalLayer;const t=Cw();return this.internalLayer=new t.XRWebGLLayer(this,e),this.setContext(e),this.internalLayer}setContext(e){this.context=e,this.tempFramebuffer=e.createFramebuffer(),this.renderers=new WeakMap}createActiveRenderState(){const e=Cw();let t=Object.getOwnPropertyNames(e.XRRenderState.prototype);const n={};for(let e of t)n[e]=this._renderState[e];n.layers=[],this.activeRenderState=n}}class SS{constructor(){this.viewport={x:0,y:0,width:0,height:0}}}class MS{constructor(e,t){this.session=e,this.context=t,this.subImageCache=new ES}createProjectionLayer(e=Hw){const t=new Gw(e);if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");return t.initialize(this.session,this.context),t}createQuadLayer(e=Fw){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(e.layout===Aw.default)throw new TypeError("Trying to create a quad layer with default layout");const t=new Bw(e);return t.initialize(this.session,this.context),t}createCylinderLayer(e=Iw){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(e.layout===Aw.default)throw new TypeError("Cylinder Layer cannot have a default layout");const t=new Nw(e);return t.initialize(this.session,this.context),t}createEquirectLayer(e=Ow){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(e.layout===Aw.default)throw new TypeError("Equirect Layer cannot have a default layout");if(!Rw(e.space))throw new TypeError("Equirect layer requires an XRReferenceSpace");let t=new Uw(e);return t.initialize(this.session,this.context),t}createCubeLayer(e){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(!(this.context instanceof WebGL2RenderingContext))throw new Error("XRCubeLayer only work on WebGL2");if(!Rw(e.space))throw new TypeError("XRCubeLayer requires a space of type XRReferenceSpace");let t=new vS(e);return t.initialize(this.session,this.context),t}getSubImage(e,t,n="none"){if(e.isStatic&&!1===e.needsRedraw)throw new Error("Invalid state for subimage creation");let i=this.subImageCache.tryGetCachedSubImage(this.context,e,n);if(i)return i;let r=new SS;if(e instanceof Gw)throw new TypeError;if(e.layout===Aw.default)throw new TypeError;if(!this.validateStateofSubImageCreation(e,t))throw new Error("Invalid state for subimage creation");let a=0;if(e.layout===Aw.stereo){if("none"===n)throw new TypeError;"right"===n&&(a=1)}e.getTextureType()===Tw["texture-array"]?r.imageIndex=a:r.imageIndex=0;let s=0;e.getTextureType()===Tw.texture?(r.colorTexture=e.colorTextures[a],s=a):(r.colorTexture=e.colorTextures[0],s=0),e.depthStencilTextures&&e.depthStencilTextures.length?e.getTextureType()===Tw.texture?r.depthStencilTexture=e.depthStencilTextures[a]:r.depthStencilTexture=e.depthStencilTextures[0]:r.depthStencilTexture=null;const o=e.colorTexturesMeta[s];r.textureWidth=o.width,r.textureHeight=o.height;let l=1;return e.layout!==Aw["stereo-left-right"]&&e.layout!==Aw["stereo-top-bottom"]||(l=2),jw(r.viewport,o,e.layout,a,l),this.session.queueTask(()=>{e.needsRedraw=!1}),this.subImageCache.cacheSubImage(r,this.context,e,n),r}getViewSubImage(e,t){let n=this.subImageCache.tryGetCachedViewSubImage(this.context,e,t);if(n)return n;let i=new SS,r=this.session;if(!r.internalViews||!r.internalViews.length)return console.warn("Tried to get view sub image before we have any views"),i;let a=r.getViewIndex(t),s=0;return e.getTextureType()===Tw["texture-array"]?i.imageIndex=a:i.imageIndex=0,e.layout===Aw.default&&e.getTextureType()===Tw.texture?(i.colorTexture=e.colorTextures[a],s=a):(i.colorTexture=e.colorTextures[0],s=0),0===e.depthStencilTextures.length?i.depthStencilTexture=null:e.layout===Aw.default&&e.getTextureType()===Tw.texture?i.depthStencilTexture=e.depthStencilTextures[a]:i.depthStencilTexture=e.depthStencilTextures[0],i.textureWidth=e.colorTexturesMeta[s].width,i.textureHeight=e.colorTexturesMeta[s].height,jw(i.viewport,e.colorTexturesMeta[s],e.layout,a,r.internalViews.length),e.needsRedraw=!1,this.subImageCache.cacheViewSubImage(i,this.context,e,t),i}validateStateofSubImageCreation(e,t){return t.session===e.session&&(this.session===e.session&&(this.context===e.context&&(!(!e.colorTextures||!e.colorTextures.length)&&(!e.isStatic||!1!==e.needsRedraw))))}}class ES{constructor(){this.cache=new Map,this.viewCache=new Map}cacheSubImage(e,t,n,i){let r=new Map;r.set(i,e);let a=new Map;a.set(n,r),this.cache.set(t,a)}tryGetCachedSubImage(e,t,n){var i,r;return null===(r=null===(i=this.cache.get(e))||void 0===i?void 0:i.get(t))||void 0===r?void 0:r.get(n)}cacheViewSubImage(e,t,n,i){let r=new Map;r.set(i,e);let a=new Map;a.set(n,r),this.viewCache.set(t,a)}tryGetCachedViewSubImage(e,t,n){var i,r;return null===(r=null===(i=this.viewCache.get(e))||void 0===i?void 0:i.get(t))||void 0===r?void 0:r.get(n)}}class TS{constructor(){this.injected=!1;const e=Cw();this._injectPolyfill(e)}_injectPolyfill(e){if(!("xr"in e.navigator))throw new Error("WebXR Layers polyfill requires WebXR support.");!0===this.injected&&console.warn("Polyfill has already been injected..."),(e=>!!e.navigator.xr&&!(!e.XRMediaBinding||!e.XRWebGLBinding))(e)||(this._polyfillRequiredLayersFeature(e),this._polyfillXRSession(e),e.XRWebGLBinding=MS,e.XRMediaBinding=Vw,this.injected=!0,console.log("Injected Layers Polyfill"))}_polyfillXRSession(e){e.XRSession.prototype._updateRenderState=e.XRSession.prototype.updateRenderState,e.XRSession.prototype._requestAnimationFrame=e.XRSession.prototype.requestAnimationFrame;let t=Object.getOwnPropertyDescriptor(e.XRSession.prototype,"renderState");Object.defineProperty(e.XRSession.prototype,"_renderState",t);let n=Object.getOwnPropertyDescriptor(wS.prototype,"renderState");Object.defineProperty(e.XRSession.prototype,"renderState",n);let i=Object.getOwnPropertyNames(wS.prototype);for(let t of i){let n=Object.getOwnPropertyDescriptor(wS.prototype,t);Object.defineProperty(e.XRSession.prototype,t,n)}}_polyfillRequiredLayersFeature(e){const t=e.navigator.xr.requestSession;Object.defineProperty(e.navigator.xr,"requestSessionInternal",{writable:!0}),e.navigator.xr.requestSessionInternal=t;Object.defineProperty(e.navigator.xr,"requestSession",{writable:!0}),e.navigator.xr.requestSession=(t,n)=>{const i=(n,i)=>e.navigator.xr.requestSessionInternal(n,i).then(e=>{Object.assign(e,new wS);let n=e;return n.initializeSession(t),Promise.resolve(n)});if("immersive-vr"!==t)return i(t,n);if(!n)return i(t,n);if(n.requiredFeatures&&n.requiredFeatures.indexOf("layers")>-1){const e=Object.assign({},n),r=[...n.requiredFeatures],a=r.indexOf("layers");return r.splice(a,1),e.requiredFeatures=r,i(t,e)}return i(t,n)}}}const AS={ipd:.063,fovy:Math.PI/2,headsetPosition:new Z_(0,1.6,0),headsetQuaternion:new Q_,stereoEnabled:!1};class RS{constructor(e,t={}){var n,i,r,a,s,o;this.version=ww;const l=new Y_,c=new Bb(Fb.Viewer,l),u={[zb.Left]:new $_(c),[zb.Right]:new $_(c),[zb.None]:new $_(c)},d=e.controllerConfig,h={};d&&Object.values(ob).forEach(e=>{d.layout[e]&&(h[e]=new vb(d,e,l))});const f={[ob.Left]:new vw(rw,ob.Left,l),[ob.Right]:new vw(rw,ob.Right,l)},p=null!==(n=t.canvasContainer)&&void 0!==n?n:document.createElement("div");p.dataset.webxr_runtime=`Immersive Web Emulation Runtime v${ww}`,p.style.position="fixed",p.style.width="100%",p.style.height="100%",p.style.top="0",p.style.left="0",p.style.display="flex",p.style.justifyContent="center",p.style.alignItems="center",p.style.overflow="hidden",p.style.zIndex="999",this[E_]={name:e.name,supportedSessionModes:e.supportedSessionModes,supportedFeatures:e.supportedFeatures,supportedFrameRates:e.supportedFrameRates,isSystemKeyboardSupported:e.isSystemKeyboardSupported,internalNominalFrameRate:e.internalNominalFrameRate,environmentBlendModes:e.environmentBlendModes,interactionMode:e.interactionMode,userAgent:e.userAgent,position:null!==(i=t.headsetPosition)&&void 0!==i?i:AS.headsetPosition.clone(),quaternion:null!==(r=t.headsetQuaternion)&&void 0!==r?r:AS.headsetQuaternion.clone(),stereoEnabled:null!==(a=t.stereoEnabled)&&void 0!==a?a:AS.stereoEnabled,ipd:null!==(s=t.ipd)&&void 0!==s?s:AS.ipd,fovy:null!==(o=t.fovy)&&void 0!==o?o:AS.fovy,controllers:h,hands:f,primaryInputMode:"controller",pendingReferenceSpaceReset:!1,visibilityState:"visible",pendingVisibilityState:null,xrSystem:null,matrix:Wx(),globalSpace:l,viewerSpace:c,viewSpaces:u,canvasContainer:p,getViewport:(e,t)=>{const n=e.context.canvas,{width:i,height:r}=n;switch(t.eye){case zb.None:return new Ew(0,0,i,r);case zb.Left:return new Ew(0,0,this[E_].stereoEnabled?i/2:i,r);case zb.Right:return new Ew(i/2,0,this[E_].stereoEnabled?i/2:0,r)}},updateViews:()=>{Qx(this[E_].viewerSpace[G_].offsetMatrix,this[E_].quaternion.quat,this[E_].position.vec3),Kx(this[E_].viewSpaces[zb.Left][G_].offsetMatrix,r_(-this[E_].ipd/2,0,0)),Kx(this[E_].viewSpaces[zb.Right][G_].offsetMatrix,r_(this[E_].ipd/2,0,0))},onBaseLayerSet:e=>{if(!e)return;const t=e.context.canvas;if(t.parentElement!==this[E_].canvasContainer){const e=this[E_].devui;if(e){const{devUICanvas:t,devUIContainer:n}=e;t.style.zIndex=3..toString(),n.style.zIndex=4..toString(),this[E_].canvasContainer.appendChild(e.devUICanvas),this[E_].canvasContainer.appendChild(e.devUIContainer)}const n=this[E_].sem;n&&(n.environmentCanvas.style.zIndex=1..toString(),this[E_].canvasContainer.appendChild(n.environmentCanvas)),this[E_].canvasData={canvas:t,parent:t.parentElement,width:t.width,height:t.height,zIndex:t.style.zIndex},t.style.zIndex=2..toString(),this[E_].canvasContainer.appendChild(t),document.body.appendChild(this[E_].canvasContainer)}t.width=window.innerWidth,t.height=window.innerHeight},onSessionEnd:()=>{if(this[E_].canvasData){const{canvas:e,parent:t,width:n,height:i,zIndex:r}=this[E_].canvasData;e.width=n,e.height=i,e.style.zIndex=r,t?t.appendChild(e):this[E_].canvasContainer.removeChild(e);const a=this[E_].devui;a&&(this[E_].canvasContainer.removeChild(a.devUICanvas),this[E_].canvasContainer.removeChild(a.devUIContainer));const s=this[E_].sem;s&&this[E_].canvasContainer.removeChild(s.environmentCanvas),document.body.removeChild(this[E_].canvasContainer),this[E_].canvasData=void 0,window.dispatchEvent(new Event("resize"))}},onFrameStart:e=>{var t;const n=performance.now(),i=this[E_].lastFrameTime>0?n-this[E_].lastFrameTime:16.67;if(this[E_].lastFrameTime=n,this[E_].remote&&this[E_].remote.update(i),null===(t=this[E_].actionPlayer)||void 0===t?void 0:t.playing)this[E_].actionPlayer.playFrame();else{const t=e.session;this[E_].updateViews(),this[E_].pendingVisibilityState&&(this[E_].visibilityState=this[E_].pendingVisibilityState,this[E_].pendingVisibilityState=null,t.dispatchEvent(new Hb("visibilitychange",{session:t}))),"visible"===this[E_].visibilityState&&this.activeInputs.forEach(t=>{t.onFrameStart(e)}),this[E_].pendingReferenceSpaceReset&&(t[B_].referenceSpaces.forEach(e=>{switch(e[H_].type){case Fb.Local:case Fb.LocalFloor:case Fb.BoundedFloor:case Fb.Unbounded:e.dispatchEvent(new Sw("reset",{referenceSpace:e}))}}),this[E_].pendingReferenceSpaceReset=!1)}this[E_].updateViews()},controlMode:"manual",controlModeListeners:new Set,stateChangeListeners:new Set,remote:null,lastFrameTime:0},this[E_].remote=new ab(this),this[E_].updateViews()}installRuntime(e){var t;const n=null!==(t=null==e?void 0:e.globalObject)&&void 0!==t?t:globalThis,i=null==e?void 0:e.polyfillLayers;Object.defineProperty(WebGL2RenderingContext.prototype,"makeXRCompatible",{value:function(){return new Promise((e,t)=>{e(!0)})},configurable:!0}),this[E_].xrSystem=new Mw(this),Object.defineProperty(globalThis.navigator,"xr",{value:this[E_].xrSystem,configurable:!0}),Object.defineProperty(navigator,"userAgent",{value:this[E_].userAgent,writable:!1,configurable:!1,enumerable:!0}),n.XRSystem=Mw,n.XRSession=tw,n.XRRenderState=Vb,n.XRFrame=Zb,n.XRSpace=$_,n.XRReferenceSpace=Bb,n.XRJointSpace=iw,n.XRView=Gb,n.XRViewport=Ew,n.XRRigidTransform=Lb,n.XRPose=jb,n.XRViewerPose=Xb,n.XRJointPose=Wb,n.XRInputSource=fb,n.XRInputSourceArray=hb,n.XRHand=nw,n.XRLayer=yw,n.XRWebGLLayer=_w,n.XRSessionEvent=Hb,n.XRInputSourceEvent=pb,n.XRInputSourcesChangeEvent=kb,n.XRReferenceSpaceEvent=Sw,i?new TS:(n.XRMediaBinding=void 0,n.XRWebGLBinding=void 0)}installDevUI(e){this[E_].devui=new e(this)}installSEM(e){this[E_].sem=new e(this)}get supportedSessionModes(){return this[E_].supportedSessionModes}get supportedFeatures(){return this[E_].supportedFeatures}get supportedFrameRates(){return this[E_].supportedFrameRates}get isSystemKeyboardSupported(){return this[E_].isSystemKeyboardSupported}get internalNominalFrameRate(){return this[E_].internalNominalFrameRate}get stereoEnabled(){return this[E_].stereoEnabled}set stereoEnabled(e){this[E_].stereoEnabled=e}get ipd(){return this[E_].ipd}set ipd(e){this[E_].ipd=e}get fovy(){return this[E_].fovy}set fovy(e){this[E_].fovy=e}get position(){return this[E_].position}get quaternion(){return this[E_].quaternion}get viewerSpace(){var e;return(null===(e=this[E_].actionPlayer)||void 0===e?void 0:e.playing)?this[E_].actionPlayer.viewerSpace:this[E_].viewerSpace}get viewSpaces(){var e;return(null===(e=this[E_].actionPlayer)||void 0===e?void 0:e.playing)?this[E_].actionPlayer.viewSpaces:this[E_].viewSpaces}get controllers(){return this[E_].controllers}get hands(){return this[E_].hands}get primaryInputMode(){return this[E_].primaryInputMode}set primaryInputMode(e){"controller"===e||"hand"===e?this[E_].primaryInputMode=e:console.warn('primary input mode can only be "controller" or "hand"')}get activeInputs(){if("visible"!==this[E_].visibilityState)return[];return("controller"===this[E_].primaryInputMode?Object.values(this[E_].controllers):Object.values(this[E_].hands)).filter(e=>e.connected)}get inputSources(){var e;return(null===(e=this[E_].actionPlayer)||void 0===e?void 0:e.playing)?this[E_].actionPlayer.inputSources:this.activeInputs.map(e=>e.inputSource)}get canvasContainer(){return this[E_].canvasContainer}get canvasDimensions(){if(this[E_].canvasData){const{width:e,height:t}=this[E_].canvasData.canvas;return{width:e,height:t}}}get appCanvas(){var e;return null===(e=this[E_].canvasData)||void 0===e?void 0:e.canvas}get activeSession(){var e;return null===(e=this[E_].xrSystem)||void 0===e?void 0:e[P_].activeSession}get sessionOffered(){var e;return Boolean(null===(e=this[E_].xrSystem)||void 0===e?void 0:e[P_].offeredSessionConfig)}get name(){return this[E_].name}grantOfferedSession(){const e=this[E_].xrSystem,t=null==e?void 0:e[P_];if(t&&t.offeredSessionConfig){const{resolve:n,reject:i,mode:r,options:a}=t.offeredSessionConfig;t.offeredSessionConfig=void 0,e.requestSession(r,a).then(n).catch(i)}}recenter(){const e=new Z_(-this.position.x,0,-this.position.z),t=new Z_(0,0,-1).applyQuaternion(this.quaternion);t.y=0,t.normalize();const n=Math.atan2(t.x,-t.z),i=(new Q_).setFromAxisAngle(new Z_(0,1,0),n);this.position.add(e),this.quaternion.multiply(i),[...Object.values(this[E_].controllers),...Object.values(this[E_].hands)].forEach(t=>{t.position.add(e),t.quaternion.multiply(i),t.position.applyQuaternion(i)}),this[E_].pendingReferenceSpaceReset=!0}get visibilityState(){return this[E_].visibilityState}updateVisibilityState(e){if(!Object.values(["visible","visible-blurred","hidden"]).includes(e))throw new DOMException("Invalid XRVisibilityState value","NotSupportedError");e!==this[E_].visibilityState&&(this[E_].pendingVisibilityState=e)}createActionPlayer(e,t){return this[E_].actionPlayer=new bw(e,t,this[E_].ipd),this[E_].actionPlayer}get devui(){return this[E_].devui}get sem(){return this[E_].sem}get remote(){return this[E_].remote}get controlMode(){return this[E_].controlMode}set controlMode(e){if("manual"!==e&&"programmatic"!==e)return void console.warn('control mode can only be "manual" or "programmatic"');this[E_].controlMode!==e&&(this[E_].controlMode=e,this[E_].controlModeListeners.forEach(t=>t(e)))}onControlModeChange(e){return this[E_].controlModeListeners.add(e),()=>{this[E_].controlModeListeners.delete(e)}}onStateChange(e){return this[E_].stateChangeListeners.add(e),()=>{this[E_].stateChangeListeners.delete(e)}}notifyStateChange(){this[E_].stateChangeListeners.forEach(e=>e())}}const CS={mapping:sb.XRStandard,buttons:[{id:"trigger",type:"analog",eventTrigger:"select"},{id:"squeeze",type:"analog",eventTrigger:"squeeze"},null,{id:"thumbstick",type:"binary"},{id:"x-button",type:"binary"},{id:"y-button",type:"binary"},{id:"thumbrest",type:"binary"}],axes:[null,null,{id:"thumbstick",type:"x-axis"},{id:"thumbstick",type:"y-axis"}]},PS={mapping:sb.XRStandard,buttons:[{id:"trigger",type:"analog",eventTrigger:"select"},{id:"squeeze",type:"analog",eventTrigger:"squeeze"},null,{id:"thumbstick",type:"binary"},{id:"a-button",type:"binary"},{id:"b-button",type:"binary"},{id:"thumbrest",type:"binary"}],axes:[null,null,{id:"thumbstick",type:"x-axis"},{id:"thumbstick",type:"y-axis"}]},LS={profileId:"oculus-touch-v3",fallbackProfileIds:["oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:CS,gripOffsetMatrix:[.9925461411476135,2.0823669899527886e-8,-.12186937034130096,0,.08617465198040009,.7071067094802856,.701836109161377,0,.08617466688156128,-.7071067690849304,.7018360495567322,0,-.003979838453233242,-.015857907012104988,.04964181408286095,1],numHapticActuators:1},right:{gamepad:PS,gripOffsetMatrix:[.9925461411476135,-8.329467959811154e-8,.12186941504478455,0,-.08617465943098068,.7071066498756409,.7018361687660217,0,-.08617471158504486,-.7071068286895752,.7018359303474426,0,.003979798872023821,-.015857888385653496,.049641866236925125,1],numHapticActuators:1}}},IS={profileId:"meta-quest-touch-pro",fallbackProfileIds:["oculus-touch-v2","oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:CS,gripOffsetMatrix:[.9925461411476135,-1.5779937356796836e-8,-.12186935544013977,0,.08617467433214188,.7071067094802856,.701836109161377,0,.0861746296286583,-.7071067690849304,.7018360495567322,0,-.003979836590588093,-.015857847407460213,.049641840159893036,1],numHapticActuators:3},right:{gamepad:PS,gripOffsetMatrix:[.9925461411476135,9267653311439972e-26,.12186937034130096,0,-.08617467433214188,.7071067094802856,.7018361687660217,0,-.08617464452981949,-.7071067690849304,.7018360495567322,0,.003979847766458988,-.01585782691836357,.04964186251163483,1],numHapticActuators:3}}},DS={profileId:"meta-quest-touch-plus",fallbackProfileIds:["oculus-touch-v3","oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:CS,gripOffsetMatrix:[.9925461411476135,1.0736208366779465e-8,-.12186933308839798,0,.08617459982633591,.70710688829422,.7018360495567322,0,.08617466688156128,-.7071067094802856,.7018362283706665,0,-.003979803062975407,-.015857873484492302,.04964187368750572,1],numHapticActuators:1},right:{gamepad:PS,gripOffsetMatrix:[.9925461411476135,-2.6238110351073374e-8,.12186934053897858,0,-.0861746147274971,.7071067690849304,.7018360495567322,0,-.08617465943098068,-.7071067094802856,.701836109161377,0,.003979838453233242,-.015857869759202003,.04964182525873184,1],numHapticActuators:1}}},NS={name:"Oculus Quest 1",controllerConfig:{profileId:"oculus-touch-v2",fallbackProfileIds:["oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:CS,gripOffsetMatrix:[.9925461411476135,4.673031295254759e-9,-.12186938524246216,0,.08617470413446426,.7071065306663513,.7018362283706665,0,.0861746296286583,-.70710688829422,.7018358707427979,0,-.003979847766458988,-.01585787907242775,.04964185878634453,1],numHapticActuators:1},right:{gamepad:PS,gripOffsetMatrix:[.9925461411476135,3.688163374704345e-8,.12186937034130096,0,-.08617469668388367,.7071066498756409,.7018361687660217,0,-.0861746147274971,-.7071068286895752,.7018359899520874,0,.003979853354394436,-.01585787907242775,.04964182525873184,1],numHapticActuators:1}}},supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","hand-tracking"],supportedFrameRates:[72,80,90],isSystemKeyboardSupported:!0,internalNominalFrameRate:72,environmentBlendModes:{"immersive-vr":Qb.Opaque,"immersive-ar":Qb.AlphaBlend},interactionMode:Jb.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest 1) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"},OS={name:"Meta Quest 2",controllerConfig:LS,supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","mesh-detection","hit-test","hand-tracking"],supportedFrameRates:[72,80,90,120],isSystemKeyboardSupported:!0,internalNominalFrameRate:72,environmentBlendModes:{"immersive-vr":Qb.Opaque,"immersive-ar":Qb.AlphaBlend},interactionMode:Jb.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest 2) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"},kS={name:"Meta Quest Pro",controllerConfig:IS,supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","mesh-detection","hit-test","hand-tracking"],supportedFrameRates:[72,80,90,120],isSystemKeyboardSupported:!0,internalNominalFrameRate:90,environmentBlendModes:{"immersive-vr":Qb.Opaque,"immersive-ar":Qb.AlphaBlend},interactionMode:Jb.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest Pro) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"},US={name:"Meta Quest 3",controllerConfig:DS,supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","mesh-detection","hit-test","hand-tracking","depth-sensing"],supportedFrameRates:[72,80,90,120],isSystemKeyboardSupported:!0,internalNominalFrameRate:90,environmentBlendModes:{"immersive-vr":Qb.Opaque,"immersive-ar":Qb.AlphaBlend},interactionMode:Jb.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest 3) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"};function FS(){let e=0,t=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(e|=(127&i)<<n,!(128&i))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(15&n)<<28,t=(112&n)>>4,!(128&n))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(t|=(127&i)<<n,!(128&i))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function zS(e,t,n){for(let i=0;i<28;i+=7){const r=e>>>i,a=!(r>>>7==0&&0==t),s=255&(a?128|r:r);if(n.push(s),!a)return}const i=e>>>28&15|(7&t)<<4,r=!!(t>>3);if(n.push(255&(r?128|i:i)),r){for(let e=3;e<31;e+=7){const i=t>>>e,r=!(i>>>7==0),a=255&(r?128|i:i);if(n.push(a),!r)return}n.push(t>>>31&1)}}const BS=4294967296;function VS(e){const t="-"===e[0];t&&(e=e.slice(1));const n=1e6;let i=0,r=0;function a(t,a){const s=Number(e.slice(t,a));r*=n,i=i*n+s,i>=BS&&(r+=i/BS|0,i%=BS)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?jS(i,r):GS(i,r)}function HS(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(BS*t+e);const n=16777215&(e>>>24|t<<8),i=t>>16&65535;let r=(16777215&e)+6777216*n+6710656*i,a=n+8147497*i,s=2*i;const o=1e7;return r>=o&&(a+=Math.floor(r/o),r%=o),a>=o&&(s+=Math.floor(a/o),a%=o),s.toString()+WS(a)+WS(r)}function GS(e,t){return{lo:0|e,hi:0|t}}function jS(e,t){return t=~t,e?e=1+~e:t+=1,GS(e,t)}const WS=e=>{const t=String(e);return"0000000".slice(t.length)+t};function XS(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function qS(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let t=5;128&e&&t<10;t++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}const $S=YS();function YS(){const e=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64&&(!!globalThis.Deno||"object"!=typeof process||"object"!=typeof process.env||"1"!==process.env.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),i=BigInt("0"),r=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const i="bigint"==typeof e?e:BigInt(e);if(i>n||i<t)throw new Error(`invalid int64: ${e}`);return i},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>r||t<i)throw new Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)),uDec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0))}}return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),KS(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),ZS(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),KS(e),VS(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),ZS(e),VS(e)),dec:(e,t)=>function(e,t){let n=GS(e,t);const i=2147483648&n.hi;i&&(n=jS(n.lo,n.hi));const r=HS(n.lo,n.hi);return i?"-"+r:r}(e,t),uDec:(e,t)=>HS(e,t)}}function KS(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function ZS(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}const QS=Symbol.for("@bufbuild/protobuf/text-encoding");function JS(){if(null==globalThis[QS]){const e=new globalThis.TextEncoder,t=new globalThis.TextDecoder;globalThis[QS]={encodeUtf8:t=>e.encode(t),decodeUtf8:e=>t.decode(e),checkUtf8(e){try{return encodeURIComponent(e),!0}catch(e){return!1}}}}return globalThis[QS]}var eM;!function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"}(eM||(eM={}));const tM=34028234663852886e22,nM=-34028234663852886e22;class iM{constructor(e=JS().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(sM(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return aM(e),XS(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.encodeUtf8(e);return this.uint32(t.byteLength),this.raw(t)}float(e){!function(e){if("string"==typeof e){const t=e;if(e=Number(e),Number.isNaN(e)&&"NaN"!==t)throw new Error("invalid float32: "+t)}else if("number"!=typeof e)throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>tM||e<nM))throw new Error("invalid float32: "+e)}(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){sM(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){aM(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return aM(e),XS(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=$S.enc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=$S.uEnc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=$S.enc(e);return zS(t.lo,t.hi,this.buf),this}sint64(e){const t=$S.enc(e),n=t.hi>>31;return zS(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){const t=$S.uEnc(e);return zS(t.lo,t.hi,this.buf),this}}class rM{constructor(e,t=JS().decodeUtf8){this.decodeUtf8=t,this.varint64=FS,this.uint32=qS,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.uint32(),t=e>>>3,n=7&e;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case eM.Varint:for(;128&this.buf[this.pos++];);break;case eM.Bit64:this.pos+=4;case eM.Bit32:this.pos+=4;break;case eM.LengthDelimited:let n=this.uint32();this.pos+=n;break;case eM.StartGroup:for(;;){const[e,n]=this.tag();if(n===eM.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(n,e)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return $S.dec(...this.varint64())}uint64(){return $S.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,$S.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return $S.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return $S.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.decodeUtf8(this.bytes())}}function aM(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int32: "+e)}function sM(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint32: "+e)}const oM={encode:(e,t=new iM)=>(0!==e.x&&t.uint32(13).float(e.x),0!==e.y&&t.uint32(21).float(e.y),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={x:0,y:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.x=n.float();continue;case 2:if(21!==e)break;r.y=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({x:mM(e.x)?globalThis.Number(e.x):0,y:mM(e.y)?globalThis.Number(e.y):0}),toJSON(e){const t={};return 0!==e.x&&(t.x=e.x),0!==e.y&&(t.y=e.y),t},create:e=>oM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i={x:0,y:0};return i.x=null!==(t=e.x)&&void 0!==t?t:0,i.y=null!==(n=e.y)&&void 0!==n?n:0,i}};const lM={encode:(e,t=new iM)=>(0!==e.width&&t.uint32(13).float(e.width),0!==e.height&&t.uint32(21).float(e.height),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={width:0,height:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.width=n.float();continue;case 2:if(21!==e)break;r.height=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({width:mM(e.width)?globalThis.Number(e.width):0,height:mM(e.height)?globalThis.Number(e.height):0}),toJSON(e){const t={};return 0!==e.width&&(t.width=e.width),0!==e.height&&(t.height=e.height),t},create:e=>lM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i={width:0,height:0};return i.width=null!==(t=e.width)&&void 0!==t?t:0,i.height=null!==(n=e.height)&&void 0!==n?n:0,i}};const cM={encode:(e,t=new iM)=>(0!==e.x&&t.uint32(13).float(e.x),0!==e.y&&t.uint32(21).float(e.y),0!==e.z&&t.uint32(29).float(e.z),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={x:0,y:0,z:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.x=n.float();continue;case 2:if(21!==e)break;r.y=n.float();continue;case 3:if(29!==e)break;r.z=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({x:mM(e.x)?globalThis.Number(e.x):0,y:mM(e.y)?globalThis.Number(e.y):0,z:mM(e.z)?globalThis.Number(e.z):0}),toJSON(e){const t={};return 0!==e.x&&(t.x=e.x),0!==e.y&&(t.y=e.y),0!==e.z&&(t.z=e.z),t},create:e=>cM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i;const r={x:0,y:0,z:0};return r.x=null!==(t=e.x)&&void 0!==t?t:0,r.y=null!==(n=e.y)&&void 0!==n?n:0,r.z=null!==(i=e.z)&&void 0!==i?i:0,r}};const uM={encode:(e,t=new iM)=>(0!==e.width&&t.uint32(13).float(e.width),0!==e.height&&t.uint32(21).float(e.height),0!==e.depth&&t.uint32(29).float(e.depth),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={width:0,height:0,depth:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.width=n.float();continue;case 2:if(21!==e)break;r.height=n.float();continue;case 3:if(29!==e)break;r.depth=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({width:mM(e.width)?globalThis.Number(e.width):0,height:mM(e.height)?globalThis.Number(e.height):0,depth:mM(e.depth)?globalThis.Number(e.depth):0}),toJSON(e){const t={};return 0!==e.width&&(t.width=e.width),0!==e.height&&(t.height=e.height),0!==e.depth&&(t.depth=e.depth),t},create:e=>uM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i;const r={width:0,height:0,depth:0};return r.width=null!==(t=e.width)&&void 0!==t?t:0,r.height=null!==(n=e.height)&&void 0!==n?n:0,r.depth=null!==(i=e.depth)&&void 0!==i?i:0,r}};const dM={encode:(e,t=new iM)=>(0!==e.x&&t.uint32(13).float(e.x),0!==e.y&&t.uint32(21).float(e.y),0!==e.z&&t.uint32(29).float(e.z),0!==e.w&&t.uint32(37).float(e.w),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={x:0,y:0,z:0,w:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.x=n.float();continue;case 2:if(21!==e)break;r.y=n.float();continue;case 3:if(29!==e)break;r.z=n.float();continue;case 4:if(37!==e)break;r.w=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({x:mM(e.x)?globalThis.Number(e.x):0,y:mM(e.y)?globalThis.Number(e.y):0,z:mM(e.z)?globalThis.Number(e.z):0,w:mM(e.w)?globalThis.Number(e.w):0}),toJSON(e){const t={};return 0!==e.x&&(t.x=e.x),0!==e.y&&(t.y=e.y),0!==e.z&&(t.z=e.z),0!==e.w&&(t.w=e.w),t},create:e=>dM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i,r;const a={x:0,y:0,z:0,w:0};return a.x=null!==(t=e.x)&&void 0!==t?t:0,a.y=null!==(n=e.y)&&void 0!==n?n:0,a.z=null!==(i=e.z)&&void 0!==i?i:0,a.w=null!==(r=e.w)&&void 0!==r?r:0,a}};const hM={encode:(e,t=new iM)=>(void 0!==e.offset&&oM.encode(e.offset,t.uint32(10).fork()).join(),void 0!==e.extent&&lM.encode(e.extent,t.uint32(18).fork()).join(),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={offset:void 0,extent:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.offset=oM.decode(n,n.uint32());continue;case 2:if(18!==e)break;r.extent=lM.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({offset:mM(e.offset)?oM.fromJSON(e.offset):void 0,extent:mM(e.extent)?lM.fromJSON(e.extent):void 0}),toJSON(e){const t={};return void 0!==e.offset&&(t.offset=oM.toJSON(e.offset)),void 0!==e.extent&&(t.extent=lM.toJSON(e.extent)),t},create:e=>hM.fromPartial(null!=e?e:{}),fromPartial(e){const t={offset:void 0,extent:void 0};return t.offset=void 0!==e.offset&&null!==e.offset?oM.fromPartial(e.offset):void 0,t.extent=void 0!==e.extent&&null!==e.extent?lM.fromPartial(e.extent):void 0,t}};const fM={encode:(e,t=new iM)=>(void 0!==e.offset&&cM.encode(e.offset,t.uint32(10).fork()).join(),void 0!==e.extent&&uM.encode(e.extent,t.uint32(18).fork()).join(),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={offset:void 0,extent:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.offset=cM.decode(n,n.uint32());continue;case 2:if(18!==e)break;r.extent=uM.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({offset:mM(e.offset)?cM.fromJSON(e.offset):void 0,extent:mM(e.extent)?uM.fromJSON(e.extent):void 0}),toJSON(e){const t={};return void 0!==e.offset&&(t.offset=cM.toJSON(e.offset)),void 0!==e.extent&&(t.extent=uM.toJSON(e.extent)),t},create:e=>fM.fromPartial(null!=e?e:{}),fromPartial(e){const t={offset:void 0,extent:void 0};return t.offset=void 0!==e.offset&&null!==e.offset?cM.fromPartial(e.offset):void 0,t.extent=void 0!==e.extent&&null!==e.extent?uM.fromPartial(e.extent):void 0,t}};const pM={encode:(e,t=new iM)=>(void 0!==e.orientation&&dM.encode(e.orientation,t.uint32(10).fork()).join(),void 0!==e.position&&cM.encode(e.position,t.uint32(18).fork()).join(),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={orientation:void 0,position:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.orientation=dM.decode(n,n.uint32());continue;case 2:if(18!==e)break;r.position=cM.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({orientation:mM(e.orientation)?dM.fromJSON(e.orientation):void 0,position:mM(e.position)?cM.fromJSON(e.position):void 0}),toJSON(e){const t={};return void 0!==e.orientation&&(t.orientation=dM.toJSON(e.orientation)),void 0!==e.position&&(t.position=cM.toJSON(e.position)),t},create:e=>pM.fromPartial(null!=e?e:{}),fromPartial(e){const t={orientation:void 0,position:void 0};return t.orientation=void 0!==e.orientation&&null!==e.orientation?dM.fromPartial(e.orientation):void 0,t.position=void 0!==e.position&&null!==e.position?cM.fromPartial(e.position):void 0,t}};function mM(e){return null!=e}var gM,vM;function yM(e){switch(e){case 0:case"Keyboard":return gM.Keyboard;default:return gM.UNRECOGNIZED}}function xM(e){switch(e){case 0:case"UNKNOWN":return vM.UNKNOWN;case 1:case"FLOOR":return vM.FLOOR;case 2:case"CEILING":return vM.CEILING;case 3:case"WALL_FACE":return vM.WALL_FACE;case 4:case"TABLE":return vM.TABLE;case 5:case"COUCH":return vM.COUCH;case 6:case"DOOR_FRAME":return vM.DOOR_FRAME;case 7:case"WINDOW_FRAME":return vM.WINDOW_FRAME;case 8:case"OTHER":return vM.OTHER;case 9:case"STORAGE":return vM.STORAGE;case 10:case"BED":return vM.BED;case 11:case"SCREEN":return vM.SCREEN;case 12:case"LAMP":return vM.LAMP;case 13:case"PLANT":return vM.PLANT;case 14:case"WALL_ART":return vM.WALL_ART;case 15:case"GLOBAL_MESH":return vM.GLOBAL_MESH;case 16:case"INVISIBLE_WALL_FACE":return vM.INVISIBLE_WALL_FACE;case 17:case"CHAIR":return vM.CHAIR;case 18:case"INNER_WALL_FACE":return vM.INNER_WALL_FACE;case 19:case"OTHER_ROOM_FACE":return vM.OTHER_ROOM_FACE;case 20:case"OPENING":return vM.OPENING;default:return vM.UNRECOGNIZED}}function _M(e){switch(e){case vM.UNKNOWN:return"UNKNOWN";case vM.FLOOR:return"FLOOR";case vM.CEILING:return"CEILING";case vM.WALL_FACE:return"WALL_FACE";case vM.TABLE:return"TABLE";case vM.COUCH:return"COUCH";case vM.DOOR_FRAME:return"DOOR_FRAME";case vM.WINDOW_FRAME:return"WINDOW_FRAME";case vM.OTHER:return"OTHER";case vM.STORAGE:return"STORAGE";case vM.BED:return"BED";case vM.SCREEN:return"SCREEN";case vM.LAMP:return"LAMP";case vM.PLANT:return"PLANT";case vM.WALL_ART:return"WALL_ART";case vM.GLOBAL_MESH:return"GLOBAL_MESH";case vM.INVISIBLE_WALL_FACE:return"INVISIBLE_WALL_FACE";case vM.CHAIR:return"CHAIR";case vM.INNER_WALL_FACE:return"INNER_WALL_FACE";case vM.OTHER_ROOM_FACE:return"OTHER_ROOM_FACE";case vM.OPENING:return"OPENING";case vM.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.Keyboard=0]="Keyboard",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(gM||(gM={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.FLOOR=1]="FLOOR",e[e.CEILING=2]="CEILING",e[e.WALL_FACE=3]="WALL_FACE",e[e.TABLE=4]="TABLE",e[e.COUCH=5]="COUCH",e[e.DOOR_FRAME=6]="DOOR_FRAME",e[e.WINDOW_FRAME=7]="WINDOW_FRAME",e[e.OTHER=8]="OTHER",e[e.STORAGE=9]="STORAGE",e[e.BED=10]="BED",e[e.SCREEN=11]="SCREEN",e[e.LAMP=12]="LAMP",e[e.PLANT=13]="PLANT",e[e.WALL_ART=14]="WALL_ART",e[e.GLOBAL_MESH=15]="GLOBAL_MESH",e[e.INVISIBLE_WALL_FACE=16]="INVISIBLE_WALL_FACE",e[e.CHAIR=17]="CHAIR",e[e.INNER_WALL_FACE=18]="INNER_WALL_FACE",e[e.OTHER_ROOM_FACE=19]="OTHER_ROOM_FACE",e[e.OPENING=20]="OPENING",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(vM||(vM={}));const bM={encode(e,t=new iM){""!==e.floorUuid&&t.uint32(10).string(e.floorUuid),""!==e.ceilingUuid&&t.uint32(18).string(e.ceilingUuid);for(const n of e.wallUuids)t.uint32(26).string(n);return t},decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={floorUuid:"",ceilingUuid:"",wallUuids:[]};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.floorUuid=n.string();continue;case 2:if(18!==e)break;r.ceilingUuid=n.string();continue;case 3:if(26!==e)break;r.wallUuids.push(n.string());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({floorUuid:LM(e.floorUuid)?globalThis.String(e.floorUuid):"",ceilingUuid:LM(e.ceilingUuid)?globalThis.String(e.ceilingUuid):"",wallUuids:globalThis.Array.isArray(null==e?void 0:e.wallUuids)?e.wallUuids.map(e=>globalThis.String(e)):[]}),toJSON(e){var t;const n={};return""!==e.floorUuid&&(n.floorUuid=e.floorUuid),""!==e.ceilingUuid&&(n.ceilingUuid=e.ceilingUuid),(null===(t=e.wallUuids)||void 0===t?void 0:t.length)&&(n.wallUuids=e.wallUuids),n},create:e=>bM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i;const r={floorUuid:"",ceilingUuid:"",wallUuids:[]};return r.floorUuid=null!==(t=e.floorUuid)&&void 0!==t?t:"",r.ceilingUuid=null!==(n=e.ceilingUuid)&&void 0!==n?n:"",r.wallUuids=(null===(i=e.wallUuids)||void 0===i?void 0:i.map(e=>e))||[],r}};const wM={encode(e,t=new iM){for(const n of e.uuids)t.uint32(10).string(n);return t},decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={uuids:[]};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.uuids.push(n.string());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({uuids:globalThis.Array.isArray(null==e?void 0:e.uuids)?e.uuids.map(e=>globalThis.String(e)):[]}),toJSON(e){var t;const n={};return(null===(t=e.uuids)||void 0===t?void 0:t.length)&&(n.uuids=e.uuids),n},create:e=>wM.fromPartial(null!=e?e:{}),fromPartial(e){var t;const n={uuids:[]};return n.uuids=(null===(t=e.uuids)||void 0===t?void 0:t.map(e=>e))||[],n}};function SM(){return{vertices:new Uint8Array(0)}}const MM={encode:(e,t=new iM)=>(0!==e.vertices.length&&t.uint32(10).bytes(e.vertices),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r=SM();for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.vertices=n.bytes();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({vertices:LM(e.vertices)?CM(e.vertices):new Uint8Array(0)}),toJSON(e){const t={};return 0!==e.vertices.length&&(t.vertices=PM(e.vertices)),t},create:e=>MM.fromPartial(null!=e?e:{}),fromPartial(e){var t;const n=SM();return n.vertices=null!==(t=e.vertices)&&void 0!==t?t:new Uint8Array(0),n}};function EM(){return{vertices:new Uint8Array(0),indices:new Uint8Array(0)}}const TM={encode:(e,t=new iM)=>(0!==e.vertices.length&&t.uint32(10).bytes(e.vertices),0!==e.indices.length&&t.uint32(18).bytes(e.indices),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r=EM();for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.vertices=n.bytes();continue;case 2:if(18!==e)break;r.indices=n.bytes();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({vertices:LM(e.vertices)?CM(e.vertices):new Uint8Array(0),indices:LM(e.indices)?CM(e.indices):new Uint8Array(0)}),toJSON(e){const t={};return 0!==e.vertices.length&&(t.vertices=PM(e.vertices)),0!==e.indices.length&&(t.indices=PM(e.indices)),t},create:e=>TM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i=EM();return i.vertices=null!==(t=e.vertices)&&void 0!==t?t:new Uint8Array(0),i.indices=null!==(n=e.indices)&&void 0!==n?n:new Uint8Array(0),i}};const AM={encode:(e,t=new iM)=>(0!==e.classType&&t.uint32(8).int32(e.classType),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={classType:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(8!==e)break;r.classType=n.int32();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({classType:LM(e.classType)?yM(e.classType):0}),toJSON(e){const t={};return 0!==e.classType&&(t.classType=function(e){switch(e){case gM.Keyboard:return"Keyboard";case gM.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.classType)),t},create:e=>AM.fromPartial(null!=e?e:{}),fromPartial(e){var t;const n={classType:0};return n.classType=null!==(t=e.classType)&&void 0!==t?t:0,n}};const RM={encode:(e,t=new iM)=>(""!==e.uuid&&t.uint32(10).string(e.uuid),void 0!==e.semanticLabel_META&&t.uint32(16).int32(e.semanticLabel_META),void 0!==e.locatable_META&&pM.encode(e.locatable_META,t.uint32(26).fork()).join(),void 0!==e.boundary2D_META&&MM.encode(e.boundary2D_META,t.uint32(34).fork()).join(),void 0!==e.bounded2D_META&&hM.encode(e.bounded2D_META,t.uint32(42).fork()).join(),void 0!==e.bounded3D_META&&fM.encode(e.bounded3D_META,t.uint32(50).fork()).join(),void 0!==e.roomLayout_META&&bM.encode(e.roomLayout_META,t.uint32(58).fork()).join(),void 0!==e.spaceContainer_META&&wM.encode(e.spaceContainer_META,t.uint32(66).fork()).join(),void 0!==e.triangleMesh_META&&TM.encode(e.triangleMesh_META,t.uint32(74).fork()).join(),void 0!==e.dynamicObject_META&&AM.encode(e.dynamicObject_META,t.uint32(82).fork()).join(),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={uuid:"",semanticLabel_META:void 0,locatable_META:void 0,boundary2D_META:void 0,bounded2D_META:void 0,bounded3D_META:void 0,roomLayout_META:void 0,spaceContainer_META:void 0,triangleMesh_META:void 0,dynamicObject_META:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.uuid=n.string();continue;case 2:if(16!==e)break;r.semanticLabel_META=n.int32();continue;case 3:if(26!==e)break;r.locatable_META=pM.decode(n,n.uint32());continue;case 4:if(34!==e)break;r.boundary2D_META=MM.decode(n,n.uint32());continue;case 5:if(42!==e)break;r.bounded2D_META=hM.decode(n,n.uint32());continue;case 6:if(50!==e)break;r.bounded3D_META=fM.decode(n,n.uint32());continue;case 7:if(58!==e)break;r.roomLayout_META=bM.decode(n,n.uint32());continue;case 8:if(66!==e)break;r.spaceContainer_META=wM.decode(n,n.uint32());continue;case 9:if(74!==e)break;r.triangleMesh_META=TM.decode(n,n.uint32());continue;case 10:if(82!==e)break;r.dynamicObject_META=AM.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({uuid:LM(e.uuid)?globalThis.String(e.uuid):"",semanticLabel_META:LM(e.semanticLabel_META)?xM(e.semanticLabel_META):void 0,locatable_META:LM(e.locatable_META)?pM.fromJSON(e.locatable_META):void 0,boundary2D_META:LM(e.boundary2D_META)?MM.fromJSON(e.boundary2D_META):void 0,bounded2D_META:LM(e.bounded2D_META)?hM.fromJSON(e.bounded2D_META):void 0,bounded3D_META:LM(e.bounded3D_META)?fM.fromJSON(e.bounded3D_META):void 0,roomLayout_META:LM(e.roomLayout_META)?bM.fromJSON(e.roomLayout_META):void 0,spaceContainer_META:LM(e.spaceContainer_META)?wM.fromJSON(e.spaceContainer_META):void 0,triangleMesh_META:LM(e.triangleMesh_META)?TM.fromJSON(e.triangleMesh_META):void 0,dynamicObject_META:LM(e.dynamicObject_META)?AM.fromJSON(e.dynamicObject_META):void 0}),toJSON(e){const t={};return""!==e.uuid&&(t.uuid=e.uuid),void 0!==e.semanticLabel_META&&(t.semanticLabel_META=_M(e.semanticLabel_META)),void 0!==e.locatable_META&&(t.locatable_META=pM.toJSON(e.locatable_META)),void 0!==e.boundary2D_META&&(t.boundary2D_META=MM.toJSON(e.boundary2D_META)),void 0!==e.bounded2D_META&&(t.bounded2D_META=hM.toJSON(e.bounded2D_META)),void 0!==e.bounded3D_META&&(t.bounded3D_META=fM.toJSON(e.bounded3D_META)),void 0!==e.roomLayout_META&&(t.roomLayout_META=bM.toJSON(e.roomLayout_META)),void 0!==e.spaceContainer_META&&(t.spaceContainer_META=wM.toJSON(e.spaceContainer_META)),void 0!==e.triangleMesh_META&&(t.triangleMesh_META=TM.toJSON(e.triangleMesh_META)),void 0!==e.dynamicObject_META&&(t.dynamicObject_META=AM.toJSON(e.dynamicObject_META)),t},create:e=>RM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i={uuid:"",semanticLabel_META:void 0,locatable_META:void 0,boundary2D_META:void 0,bounded2D_META:void 0,bounded3D_META:void 0,roomLayout_META:void 0,spaceContainer_META:void 0,triangleMesh_META:void 0,dynamicObject_META:void 0};return i.uuid=null!==(t=e.uuid)&&void 0!==t?t:"",i.semanticLabel_META=null!==(n=e.semanticLabel_META)&&void 0!==n?n:void 0,i.locatable_META=void 0!==e.locatable_META&&null!==e.locatable_META?pM.fromPartial(e.locatable_META):void 0,i.boundary2D_META=void 0!==e.boundary2D_META&&null!==e.boundary2D_META?MM.fromPartial(e.boundary2D_META):void 0,i.bounded2D_META=void 0!==e.bounded2D_META&&null!==e.bounded2D_META?hM.fromPartial(e.bounded2D_META):void 0,i.bounded3D_META=void 0!==e.bounded3D_META&&null!==e.bounded3D_META?fM.fromPartial(e.bounded3D_META):void 0,i.roomLayout_META=void 0!==e.roomLayout_META&&null!==e.roomLayout_META?bM.fromPartial(e.roomLayout_META):void 0,i.spaceContainer_META=void 0!==e.spaceContainer_META&&null!==e.spaceContainer_META?wM.fromPartial(e.spaceContainer_META):void 0,i.triangleMesh_META=void 0!==e.triangleMesh_META&&null!==e.triangleMesh_META?TM.fromPartial(e.triangleMesh_META):void 0,i.dynamicObject_META=void 0!==e.dynamicObject_META&&null!==e.dynamicObject_META?AM.fromPartial(e.dynamicObject_META):void 0,i}};function CM(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{const t=globalThis.atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}}function PM(e){if(globalThis.Buffer)return globalThis.Buffer.from(e).toString("base64");{const t=[];return e.forEach(e=>{t.push(globalThis.String.fromCharCode(e))}),globalThis.btoa(t.join(""))}}function LM(e){return null!=e}var IM,DM;!function(e){e.Locatable="locatable",e.Bounded3D="bounded3D",e.Bounded2D="bounded2D",e.TriangleMesh="triangleMesh",e.SemanticLabel="semanticLabel"}(IM||(IM={}));class NM extends EventTarget{constructor(e){super(),this._spatialEntity=e}}class OM extends NM{constructor(e,t){super(e),this._offset=new $c,this._extent=new $c,this.type=IM.Bounded2D;const{offset:n,extent:i}=t;this._offset.set(n.x,n.y),this._extent.set(i.width,i.height),this.buildGeometry()}buildGeometry(){var e;const t=new df(this._extent.x,this._extent.y);t.translate(this._offset.x+this._extent.x/2,this._offset.y+this._extent.y/2,0),t.rotateX(Math.PI/2),null===(e=this._spatialEntity.geometry)||void 0===e||e.dispose(),this._spatialEntity.geometry=t}get offset(){return this._offset}get extent(){return this._extent}get initData(){return{offset:this.offset,extent:this.extent}}get pbData(){return{offset:{x:this._offset.x,y:this._offset.y},extent:{width:this._extent.x,height:this._extent.y}}}}class kM extends NM{constructor(e,t){super(e),this._offset=new Kc,this._extent=new Kc,this.type=IM.Bounded3D;const{offset:n,extent:i}=t;this._offset.set(n.x,n.y,n.z),this._extent.set(i.width,i.height,i.depth),this.buildGeometry()}buildGeometry(){var e;const t=new yh(this._extent.x,this._extent.y,this._extent.z);t.translate(this._offset.x+this._extent.x/2,this._offset.y+this._extent.y/2,this._offset.z+this._extent.z/2),null===(e=this._spatialEntity.geometry)||void 0===e||e.dispose(),this._spatialEntity.geometry=t}get offset(){return this._offset}get extent(){return this._extent}get initData(){return{offset:this.offset,extent:this.extent}}get pbData(){return{offset:{x:this._offset.x,y:this._offset.y,z:this._offset.z},extent:{width:this._extent.x,height:this._extent.y,depth:this._extent.z}}}}class UM extends NM{constructor(e,t){super(e),this.type=IM.Locatable,t.position&&this.position.copy(t.position),t.orientation&&this.orientation.copy(t.orientation)}get position(){return this._spatialEntity.position}get rotation(){return this._spatialEntity.rotation}get orientation(){return this._spatialEntity.quaternion}get initData(){return{position:{x:this.position.x,y:this.position.y,z:this.position.z},orientation:{x:this.orientation.x,y:this.orientation.y,z:this.orientation.z,w:this.orientation.w}}}get pbData(){return{position:{x:this._spatialEntity.position.x,y:this._spatialEntity.position.y,z:this._spatialEntity.position.z},orientation:{x:this._spatialEntity.quaternion.x,y:this._spatialEntity.quaternion.y,z:this._spatialEntity.quaternion.z,w:this._spatialEntity.quaternion.w}}}}function FM(e){return e.toLowerCase().replace(/_/g," ").trim()}class zM extends NM{constructor(e,t){super(e),this._semanticLabel=t,this.type=IM.SemanticLabel,this._spatialEntity.name=FM(_M(t))}get semanticLabel(){return this._semanticLabel}set semanticLabel(e){Object.values(vM).includes(e)?this._semanticLabel=e:this._semanticLabel=vM.UNRECOGNIZED,this._spatialEntity.name=FM(_M(this._semanticLabel))}get initData(){return this._semanticLabel}get pbData(){return this._semanticLabel}}function BM(e){const t=new Float32Array(3*e.length);let n=0;for(const i of e)t[n++]=i.x,t[n++]=i.y,t[n++]=i.z;return t}class VM extends NM{constructor(e,t){super(e),this._polygonCount=0,this._vertexCount=0,this._dimensions={x:0,y:0,z:0},this.type=IM.TriangleMesh;const{vertices:n,indices:i}=t,r=new Float32Array(n.buffer),a=new Uint32Array(i.buffer),s=[];for(let e=0;e<r.length/3;e++)s.push({x:r[3*e],y:r[3*e+1],z:r[3*e+2]});this._vertices=s,this._indices=[...a],this.buildGeometry();const o=e.material;o.polygonOffset=!0,o.polygonOffsetFactor=1,o.polygonOffsetUnits=.005,o.color.setHex(13948116),e.renderOrder=999}buildGeometry(){var e;const t=new rh,n=BM(this._vertices);t.setAttribute("position",new qd(n,3)),t.setIndex(new qd(new Uint16Array(this._indices),1)),null===(e=this._spatialEntity.geometry)||void 0===e||e.dispose(),this._spatialEntity.geometry=t,t.computeVertexNormals(),this._vertexCount=t.attributes.position.count,this._polygonCount=t.index?t.index.count/3:this._vertexCount/3,t.computeBoundingBox();const i=t.boundingBox;this._dimensions={x:i.max.x-i.min.x,y:i.max.y-i.min.y,z:i.max.z-i.min.z}}get vertexCount(){return this._vertexCount}get polygonCount(){return this._polygonCount}get dimensions(){return this._dimensions}get initData(){return{vertices:this._vertices,indices:this._indices}}get pbData(){const e=BM(this._vertices),t=new Uint32Array(this._indices);return{vertices:new Uint8Array(e.buffer),indices:new Uint8Array(t.buffer)}}}!function(e){e.Plane="plane",e.Box="box",e.Mesh="mesh"}(DM||(DM={}));const HM={[vM.OTHER]:bb.Other,[vM.TABLE]:bb.Table,[vM.COUCH]:bb.Couch,[vM.FLOOR]:bb.Floor,[vM.CEILING]:bb.Ceiling,[vM.WALL_FACE]:bb.Wall,[vM.INVISIBLE_WALL_FACE]:bb.Window,[vM.INNER_WALL_FACE]:bb.Wall,[vM.DOOR_FRAME]:bb.Door,[vM.WINDOW_FRAME]:bb.Window,[vM.WALL_ART]:bb.WallArt,[vM.STORAGE]:bb.Shelf,[vM.BED]:bb.Bed,[vM.LAMP]:bb.Lamp,[vM.SCREEN]:bb.Screen,[vM.PLANT]:bb.Plant,[vM.GLOBAL_MESH]:bb.GlobalMesh,[vM.CHAIR]:bb.Couch,[vM.UNKNOWN]:bb.Other,[vM.OTHER_ROOM_FACE]:bb.Other,[vM.OPENING]:bb.Other,[vM.UNRECOGNIZED]:bb.Other};class GM extends gh{constructor(e=function(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(vg[255&e]+vg[e>>8&255]+vg[e>>16&255]+vg[e>>24&255]+"-"+vg[255&t]+vg[t>>8&255]+"-"+vg[t>>16&15|64]+vg[t>>24&255]+"-"+vg[63&n|128]+vg[n>>8&255]+"-"+vg[n>>16&255]+vg[n>>24&255]+vg[255&i]+vg[i>>8&255]+vg[i>>16&255]+vg[i>>24&255]).toLowerCase()}()){super(void 0,new vf({color:16777215*Math.random(),flatShading:!0})),this.name="generic spatial entity",this.isSpatialEntity=!0,this._componentMap=new Map,this._spatialUUID=e}get spatialUUID(){return this._spatialUUID}updateMatrixWorld(e){super.updateMatrixWorld(e)}addComponent(e,t){let n=null;switch(e){case IM.Locatable:n=new UM(this,t);break;case IM.Bounded3D:n=new kM(this,t);break;case IM.Bounded2D:n=new OM(this,t);break;case IM.TriangleMesh:n=new VM(this,t);break;case IM.SemanticLabel:n=new zM(this,t)}n&&this._componentMap.set(e,n)}getComponent(e){return this._componentMap.get(e)}duplicate(){const e=new GM;return this._componentMap.forEach((t,n,i)=>{e.addComponent(t.type,t.initData)}),e}get nativeEntity(){if(!this._nativeEntity){const e=new Lb({x:this.position.x,y:this.position.y,z:this.position.z,w:1},{x:this.quaternion.x,y:this.quaternion.y,z:this.quaternion.z,w:this.quaternion.w}),t=HM[this.getComponent(IM.SemanticLabel).semanticLabel];if(this.entityType===DM.Plane){const{offset:n,extent:i}=this.getComponent(IM.Bounded2D),r=[new DOMPointReadOnly(n.x,0,n.y),new DOMPointReadOnly(n.x+i.x,0,n.y),new DOMPointReadOnly(n.x+i.x,0,n.y+i.y),new DOMPointReadOnly(n.x,0,n.y+i.y),new DOMPointReadOnly(n.x,0,n.y)];this._nativeEntity=new Tb(e,r,t)}else if(this.entityType===DM.Box||this.entityType===DM.Mesh){const n=this.geometry.getAttribute("position").array,i=new Uint32Array(this.geometry.index.array);this._nativeEntity=new _b(e,n,i,t)}}return this._nativeEntity}static fromPBJSON(e){const t=RM.fromJSON(e);if(t.locatable_META){const e=new GM(t.uuid);return e.addComponent(IM.Locatable,t.locatable_META),t.semanticLabel_META&&e.addComponent(IM.SemanticLabel,t.semanticLabel_META),t.bounded2D_META?e.addComponent(IM.Bounded2D,t.bounded2D_META):t.bounded3D_META?e.addComponent(IM.Bounded3D,t.bounded3D_META):t.triangleMesh_META&&e.addComponent(IM.TriangleMesh,t.triangleMesh_META),e}}get entityType(){return this.getComponent(IM.Bounded2D)?DM.Plane:this.getComponent(IM.Bounded3D)?DM.Box:this.getComponent(IM.TriangleMesh)?DM.Mesh:void 0}static toPBJSON(e){var t,n,i,r,a;return{uuid:e.spatialUUID,locatable_META:null===(t=e.getComponent(IM.Locatable))||void 0===t?void 0:t.pbData,boundary2D_META:void 0,bounded2D_META:null===(n=e.getComponent(IM.Bounded2D))||void 0===n?void 0:n.pbData,bounded3D_META:null===(i=e.getComponent(IM.Bounded3D))||void 0===i?void 0:i.pbData,semanticLabel_META:null===(r=e.getComponent(IM.SemanticLabel))||void 0===r?void 0:r.pbData,roomLayout_META:void 0,spaceContainer_META:void 0,triangleMesh_META:null===(a=e.getComponent(IM.TriangleMesh))||void 0===a?void 0:a.pbData,dynamicObject_META:void 0}}}const jM="0.2.4",WM=new Kc(0,0,-1);class XM extends EventTarget{constructor(e){super(),this.xrDevice=e,this.trackedPlanes=new Set,this.trackedMeshes=new Set,this.version=jM,this.objectMap=new Map,this.planes=new Dh,this.boxes=new Dh,this.meshes=new Dh,this.tempPosition=new Kc,this.tempQuaternion=new Yc,this.tempDirection=new Kc,this.tempScale=new Kc,this.tempMatrix=new qu,this.raycaster=new bf,this.hitTestTarget=new Dh,this.hitTestMarker=new _d,this.worldNormal=new Kc,this.normalMatrix=new Jc,this.scene=new kh,this.scene.background=new zd(4079166),this.camera=new Rh(50,window.innerWidth/window.innerHeight,.1,40),this.camera.position.set(0,1.6,5);const t=new Lf(50,50);this.scene.add(t),this.scene.add(this.planes,this.boxes,this.meshes),this.planes.renderOrder=1,this.boxes.renderOrder=2,this.meshes.renderOrder=3,this.planes.visible=!1,this.boxes.visible=!1,this.renderer=new gg({antialias:!0,alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(window.innerWidth,window.innerHeight),this.renderer.domElement.style.position="fixed",this.renderer.domElement.style.top="50vh",this.renderer.domElement.style.left="50vw",this.renderer.domElement.style.transform="translate(-50%, -50%)",this.hitTestTarget.add(this.hitTestMarker),this.hitTestMarker.rotateX(Math.PI/2)}get environmentCanvas(){return this.renderer.domElement}get planesVisible(){return this.planes.visible}set planesVisible(e){this.planes.visible=e}get boundingBoxesVisible(){return this.boxes.visible}set boundingBoxesVisible(e){this.boxes.visible=e}get meshesVisible(){return this.meshes.visible}set meshesVisible(e){this.meshes.visible=e}render(){this.camera.position.copy(this.xrDevice.position),this.camera.quaternion.copy(this.xrDevice.quaternion);const e=this.xrDevice.fovy/Math.PI*180;let t=!1;this.camera.fov!==e&&(this.camera.fov=e,t=!0);const n=this.xrDevice.canvasDimensions;if(n){const e=this.renderer.domElement;(e.width!==n.width||e.height!==n.height)&&(this.camera.aspect=n.width/n.height,this.renderer.setSize(n.width,n.height),t=!0)}t&&this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera)}deleteAll(){[...this.objectMap.values()].forEach(e=>{e.removeFromParent()}),this.objectMap.clear(),this.trackedMeshes.clear(),this.trackedPlanes.clear()}loadEnvironment(e){this.deleteAll(),e.spatialEntities.forEach(e=>{const t=GM.fromPBJSON(e);if(t){switch(t.entityType){case DM.Box:this.boxes.add(t),this.trackedMeshes.add(t.nativeEntity);break;case DM.Plane:this.planes.add(t),this.trackedPlanes.add(t.nativeEntity);break;case DM.Mesh:this.meshes.add(t),this.trackedMeshes.add(t.nativeEntity)}const n=this.objectMap.get(e.uuid);n&&n.removeFromParent(),this.objectMap.set(e.uuid,t)}})}loadDefaultEnvironment(e){fetch(`https://www.unpkg.com/@iwer/sem@${jM}/captures/${e}.json`).then(e=>{if(!e.ok)throw new Error(`Network response was not ok: ${e.statusText}`);return e.json()}).then(e=>{this.loadEnvironment(e)}).catch(t=>{console.error(`Error loading environment ${e} from CDN`,t)})}computeHitTestResults(e){this.tempMatrix.fromArray(e),this.tempMatrix.decompose(this.tempPosition,this.tempQuaternion,this.tempScale),this.tempDirection.copy(WM).applyQuaternion(this.tempQuaternion).normalize(),this.raycaster.set(this.tempPosition,this.tempDirection);const t=this.raycaster.intersectObject(this.meshes,!0).map(e=>{var t;const n=e.point;if(this.hitTestTarget.position.copy(n),null===(t=e.face)||void 0===t?void 0:t.normal){this.worldNormal.copy(e.face.normal);const t=e.object;this.worldNormal.applyMatrix3(this.normalMatrix.getNormalMatrix(t.matrixWorld)).normalize(),this.hitTestTarget.lookAt(this.tempPosition.addVectors(n,this.worldNormal))}else this.hitTestTarget.quaternion.set(0,0,0,1);return this.hitTestTarget.updateMatrixWorld(!0),this.hitTestMarker.matrixWorld.toArray()});return t}}class qM{constructor(e,t={}){this.ws=null,this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectDelay=1e3,this.reconnectTimer=null,this.intentionalDisconnect=!1,this.device=e,this.verbose=t.verbose??!1;let n="undefined"!=typeof sessionStorage?sessionStorage.getItem("iwer-mcp-tab-id"):null;n||(n=`tab-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iwer-mcp-tab-id",n)),this.tabId=n;const i="undefined"!=typeof sessionStorage?parseInt(sessionStorage.getItem("iwer-mcp-gen")||"0",10)+1:1;"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iwer-mcp-gen",String(i)),this.tabGeneration=i}connect(e){if(null!==this.ws)return;this.intentionalDisconnect=!1;const t=e??this.getVitePort(),n=`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.hostname||"localhost"}:${t}/__iwer_mcp`;this.verbose&&console.log("[IWSDK-MCP] Connecting to:",n);try{this.ws=new WebSocket(n),this.setupEventHandlers()}catch(e){console.error("[IWSDK-MCP] Failed to create WebSocket:",e),this.ws=null,this.scheduleReconnect()}}disconnect(){this.intentionalDisconnect=!0,null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}getVitePort(){return parseInt(window.location.port,10)||5173}setupEventHandlers(){this.ws&&(this.ws.onopen=()=>{this.verbose&&console.log("[IWSDK-MCP] Connected"),this.reconnectAttempts=0},this.ws.onclose=e=>{this.verbose&&console.log("[IWSDK-MCP] Disconnected:",e.reason||"Connection closed"),this.ws=null,this.intentionalDisconnect||this.scheduleReconnect()},this.ws.onerror=e=>{console.error("[IWSDK-MCP] WebSocket error:",e)},this.ws.onmessage=async e=>{await this.handleMessage(e.data)})}async handleMessage(e){let t;try{t=JSON.parse(e)}catch{return void console.error("[IWSDK-MCP] Invalid JSON received:",e)}if("string"!=typeof t.id||"string"!=typeof t.method)return void console.error("[IWSDK-MCP] Malformed request (missing id or method):",t);this.verbose&&console.debug("[IWSDK-MCP] Received:",t.method,t.params);const n={id:t.id};try{n.result=await this.dispatch(t.method,t.params??{})}catch(e){n.error={code:-32e3,message:e instanceof Error?e.message:String(e)}}this.verbose&&(n.error?console.debug("[IWSDK-MCP] Error:",n.error.message):console.debug("[IWSDK-MCP] Result:",n.result)),this.send(n)}async dispatch(e,t){return"reload_page"===e?(setTimeout(()=>window.location.reload(),50),{success:!0,message:"Page reload initiated"}):window.FRAMEWORK_MCP_RUNTIME?.handles(e)?window.FRAMEWORK_MCP_RUNTIME.dispatch(e,t):this.device.remote.dispatch(e,t)}send(e){if(this.ws&&this.ws.readyState===WebSocket.OPEN){const t={...e,_tabId:this.tabId,_tabGeneration:this.tabGeneration};this.ws.send(JSON.stringify(t))}}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)return void(this.verbose&&console.debug("[IWSDK-MCP] Max reconnect attempts reached"));this.reconnectAttempts++;const e=this.reconnectDelay*this.reconnectAttempts;this.verbose&&console.debug(`[IWSDK-MCP] Reconnecting in ${e}ms (attempt ${this.reconnectAttempts})`),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}}const $M={metaQuest2:OS,metaQuest3:US,metaQuestPro:kS,oculusQuest1:NS};!function(e){if(console.log("[IWSDK Dev] Configuration:",e),function(e,t){if(t){const e=navigator.userAgent||"";if(t instanceof RegExp){if(t.test(e))return!1}else if("string"==typeof t&&t.startsWith("/")&&t.endsWith("/")){const n=t.slice(1,-1);try{if(new RegExp(n).test(e))return!1}catch{}}}if("always"===e)return!0;if("localhost"===e)return"localhost"===location.hostname||"127.0.0.1"===location.hostname;if(e instanceof RegExp)return e.test(location.hostname);if("string"==typeof e&&e.startsWith("/")&&e.endsWith("/")){const t=e.slice(1,-1);return new RegExp(t).test(location.hostname)}return!1}(e.activation,e.userAgentException)){e.verbose&&console.log("[IWSDK Dev] 🎯 Activating IWER runtime...");try{const t=$M[e.device];if(!t){const t=Object.keys($M).join(", ");console.error(`[IWSDK Dev] ❌ Invalid device configuration: "${e.device}"\nAvailable devices: ${t}\nFalling back to default device: metaQuest3`)}const n=new RS(t||US);e.verbose&&console.log("[IWSDK Dev] 📱 Using device configuration:",t?e.device:"metaQuest3 (fallback)"),n.installRuntime();const i=window.__IWER_MCP_MANAGED;if(e.ai&&i&&!e.ai.devUI||n.installDevUI(Bx),e.sem&&(e.verbose&&console.log("[IWSDK Dev] 🌐 Installing SEM with scene:",e.sem.defaultScene),n.installSEM(XM),e.verbose&&console.log("[IWSDK Dev] 📍 Loading default environment from CDN:",e.sem.defaultScene),n.sem?.loadDefaultEnvironment(e.sem.defaultScene)),e.ai&&window.__IWER_MCP_MANAGED){e.verbose&&console.log("[IWSDK Dev] 🔌 Initializing MCP client...");const t=function(e,t={}){const n=new qM(e,{verbose:t.verbose});return n.connect(t.port),n}(n,{verbose:e.verbose});window.IWER_MCP=t,e.verbose&&console.log("[IWSDK Dev] ✅ MCP client initialized")}e.verbose&&console.log("[IWSDK Dev] ✅ Runtime activated successfully!"),window.IWER_DEVICE=n}catch(e){console.error("[IWSDK Dev] ❌ Failed to activate runtime:",e)}}else e.verbose&&console.log("[IWSDK Dev] Skipping activation - not on localhost")}("__IWSDK_DEV_CONFIG__")}();
|
|
598
|
+
`;class bS{constructor(e,t){this.savedVaoState={vao:null,arrayBuffer:null},this.hasMipmap=!1,this.layer=e,this.gl=t,this.transformMatrix=iS(),this.program=Xw(t,xS,_S),this.programInfo={attribLocations:{a_position:t.getAttribLocation(this.program,"a_position")},uniformLocations:{u_matrix:t.getUniformLocation(this.program,"u_matrix"),u_texture:t.getUniformLocation(this.program,"u_texture"),u_projectionMatrix:t.getUniformLocation(this.program,"u_projectionMatrix")}},this._createVAOs()}saveVaoState(){this.savedVaoState.vao=this.gl.getParameter(this.vaoGl.VERTEX_ARRAY_BINDING),this.savedVaoState.arrayBuffer=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING)}restoreVaoState(){this.vaoGl.bindVertexArray(this.savedVaoState.vao),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.savedVaoState.arrayBuffer),this.savedVaoState.vao=this.savedVaoState.arrayBuffer=null}render(e,t){this.saveVaoState();let n=this.gl,i=e.getBaseLayer(),r=t.getViewerPose(e.getReferenceSpace());const a=n.getParameter(n.ACTIVE_TEXTURE);for(let e of r.views){let t=i.getViewport(e);n.viewport(t.x,t.y,t.width,t.height),n.activeTexture(n.TEXTURE0);const r=n.getParameter(n.TEXTURE_BINDING_CUBE_MAP);if(this.layer.layout===Aw.stereo){const t="right"===e.eye?1:0;n.bindTexture(n.TEXTURE_CUBE_MAP,this.layer.colorTextures[t])}else n.bindTexture(n.TEXTURE_CUBE_MAP,this.layer.colorTextures[0]);this.layer.isStatic?(!0===this.layer.needsRedraw&&n.generateMipmap(n.TEXTURE_CUBE_MAP),this.hasMipmap=!0):this.hasMipmap=this.layer.mipLevels>0,n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR),this._renderInternal(this.layer.orientation,e),n.activeTexture(a),n.bindTexture(n.TEXTURE_CUBE_MAP,r)}this.restoreVaoState()}createPositionPoints(){const e=.5;return new Float32Array([-e,-e,-e,-e,e,-e,e,-e,-e,-e,e,-e,e,e,-e,e,-e,-e,-e,-e,e,e,-e,e,-e,e,e,-e,e,e,e,-e,e,e,e,e,-e,e,-e,-e,e,e,e,e,-e,-e,e,e,e,e,e,e,e,-e,-e,-e,-e,e,-e,-e,-e,-e,e,-e,-e,e,e,-e,-e,e,-e,e,-e,-e,-e,-e,-e,e,-e,e,-e,-e,-e,e,-e,e,e,-e,e,-e,e,-e,-e,e,e,-e,e,-e,e,e,-e,e,e,e,-e,e,e,e])}_renderInternal(e,t){let n=this.gl;const i=n.getParameter(n.CURRENT_PROGRAM);n.useProgram(this.program),this.vaoGl.bindVertexArray(this.vao),aS(this.transformMatrix,[e.x,e.y,e.z,e.w]),this._poseOrientationMatrix||(this._poseOrientationMatrix=iS()),aS(this._poseOrientationMatrix,[t.transform.inverse.orientation.x,t.transform.inverse.orientation.y,t.transform.inverse.orientation.z,t.transform.inverse.orientation.w]),rS(this.transformMatrix,this.transformMatrix,this._poseOrientationMatrix),n.uniformMatrix4fv(this.programInfo.uniformLocations.u_matrix,!1,this.transformMatrix),n.uniformMatrix4fv(this.programInfo.uniformLocations.u_projectionMatrix,!1,t.projectionMatrix),n.uniform1i(this.programInfo.uniformLocations.u_texture,0);var r=n.TRIANGLES,a=this.positionPoints.length/3;n.drawArrays(r,0,a),this.vaoGl.bindVertexArray(null),n.useProgram(i)}_recalculateVertices(){this.positionPoints=this.createPositionPoints()}_createVAOs(){this._recalculateVertices();let e=this.gl;this.vaoGl=qw(e),this.saveVaoState();let t=e.createBuffer();this.vao=this.vaoGl.createVertexArray(),this.vaoGl.bindVertexArray(this.vao),e.enableVertexAttribArray(this.programInfo.attribLocations.a_position),e.bindBuffer(e.ARRAY_BUFFER,t);const n=this.positionPoints;e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW);var i=e.FLOAT;e.vertexAttribPointer(this.programInfo.attribLocations.a_position,3,i,!1,0,0),this.restoreVaoState()}}class wS{constructor(){this.mode="inline",this.layers=[],this.views=[],this.initializedViews=!1,this.isPolyfillActive=!1,this.taskQueue=[]}requestAnimationFrame(e){this.injectedFrameCallback||(this.injectedFrameCallback=(t,n)=>{let i=this.context;if(!this.initializedViews&&this.referenceSpace){let e=n.getViewerPose(this.referenceSpace);e&&(this.views=e.views,this.initializedViews=!0)}if(this.isPolyfillActive&&this.initializedViews){this.tempFramebuffer||(this.tempFramebuffer=i.createFramebuffer()),i.bindFramebuffer(i.FRAMEBUFFER,this.tempFramebuffer);const e=i.getParameter(i.COLOR_CLEAR_VALUE),t=i.getParameter(i.FRAMEBUFFER_BINDING);i.clearColor(0,0,0,0);for(let e of this.layers)if(e instanceof Gw)for(let t=0;t<e.colorTextures.length;t++){e.colorTexturesMeta[t].type===Tw["texture-array"]||(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e.colorTextures[t],0),e.depthStencilTextures&&t<e.depthStencilTextures.length?i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,e.depthStencilTextures[t],0):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,null,0),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT))}i.bindFramebuffer(i.FRAMEBUFFER,t),i.clearColor(e[0],e[1],e[2],e[3])}if(e(t,n),this.isPolyfillActive&&this.initializedViews){let e=i.isEnabled(i.BLEND),t=i.isEnabled(i.DEPTH_TEST),r=i.isEnabled(i.CULL_FACE);const a=i.getParameter(i.FRAMEBUFFER_BINDING),s=i.getParameter(i.COLOR_CLEAR_VALUE);i.bindFramebuffer(i.FRAMEBUFFER,this.getBaseLayer().framebuffer),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.clearColor(s[0],s[1],s[2],s[3]),i.enable(i.BLEND),i.disable(i.DEPTH_TEST),i.disable(i.CULL_FACE);let o=i.getParameter(i.BLEND_SRC_RGB),l=i.getParameter(i.BLEND_SRC_ALPHA),c=i.getParameter(i.BLEND_DST_RGB),u=i.getParameter(i.BLEND_DST_ALPHA);i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA);for(let e of this.layers)if(this.renderers||(this.renderers=new WeakMap),e instanceof Gw){this.renderers.has(e)||this.renderers.set(e,tS(e,this.context));this.renderers.get(e).render(this)}else if(e instanceof Bw){this.renderers.has(e)||this.renderers.set(e,new fS(e,this.context));this.renderers.get(e).render(this,n)}else if(e instanceof Nw){this.renderers.has(e)||this.renderers.set(e,new pS(e,this.context));this.renderers.get(e).render(this,n)}else if(e instanceof Uw){this.renderers.has(e)||this.renderers.set(e,new mS(e,this.context));this.renderers.get(e).render(this,n)}else if(e instanceof vS){this.renderers.has(e)||this.renderers.set(e,new bS(e,this.context));this.renderers.get(e).render(this,n)}else{const t=e;if(null===t.framebuffer)continue;i instanceof WebGL2RenderingContext?(i.bindFramebuffer(i.READ_FRAMEBUFFER,t.framebuffer),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,this.getBaseLayer().framebuffer),i.blitFramebuffer(0,0,t.framebufferWidth,t.framebufferHeight,0,0,this.getBaseLayer().framebufferWidth,this.getBaseLayer().framebufferHeight,i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT,i.LINEAR)):console.warn("GL blitFramebuffer is not supported on WebGL1, so XRWebGLLayers may not show up properly when polyfilled.")}for(e||i.disable(i.BLEND),t&&i.enable(i.DEPTH_TEST),r&&i.enable(i.CULL_FACE),i.blendFuncSeparate(o,c,l,u),i.bindFramebuffer(i.FRAMEBUFFER,a);this.taskQueue.length>0;){this.taskQueue.shift()()}}}),this._requestAnimationFrame(this.injectedFrameCallback)}updateRenderState(e){if(this.existingBaseLayer=e.baseLayer,e.layers&&(this.layers=e.layers),this.activeRenderState||this.createActiveRenderState(),this.activeRenderState=Object.assign(Object.assign({},this.activeRenderState),e),!e.layers)return void this._updateRenderState(e);let t,n=Object.assign({},e);delete n.layers;for(let i of this.layers)if(i instanceof Lw){t=i.getContext();break}if(!t&&!this.context){console.log("No existing context! Have the session make one");const r=document.createElement("canvas");if(t=r.getContext("webgl2",{xrCompatible:!0}),t||(t=r.getContext("webgl",{xrCompatible:!0})),!t)throw new Error("No webGL support detected.");function a(){t.canvas.width=t.canvas.clientWidth*window.devicePixelRatio,t.canvas.height=t.canvas.clientHeight*window.devicePixelRatio}document.body.appendChild(t.canvas),window.addEventListener("resize",a),a()}this.createInternalLayer(t),this.isPolyfillActive=!0,this._updateRenderState(Object.assign(Object.assign({},n),{baseLayer:this.internalLayer}))}initializeSession(e){this.mode=e,this.requestReferenceSpace("local").then(e=>{this.referenceSpace=e}).catch(e=>{}),this.requestReferenceSpace("viewer").then(e=>{this.viewerSpace=e})}getBaseLayer(e){return this.internalLayer||this.existingBaseLayer||!e||this.createInternalLayer(e),this.internalLayer||this.existingBaseLayer}getReferenceSpace(){return this.referenceSpace?this.referenceSpace:this.viewerSpace}getViewerSpace(){return this.viewerSpace}queueTask(e){this.taskQueue.push(e)}get renderState(){return this.activeRenderState||this.createActiveRenderState(),this.activeRenderState}get internalViews(){return this.views}getViewIndex(e){for(let t=0;t<this.views.length;t++){let n=this.views[t];if(e.eye===n.eye&&e.recommendedViewportScale===n.recommendedViewportScale)return t}return-1}createInternalLayer(e){if(!e&&this.internalLayer)return this.internalLayer;if(e===this.context&&this.internalLayer)return this.internalLayer;const t=Cw();return this.internalLayer=new t.XRWebGLLayer(this,e),this.setContext(e),this.internalLayer}setContext(e){this.context=e,this.tempFramebuffer=e.createFramebuffer(),this.renderers=new WeakMap}createActiveRenderState(){const e=Cw();let t=Object.getOwnPropertyNames(e.XRRenderState.prototype);const n={};for(let e of t)n[e]=this._renderState[e];n.layers=[],this.activeRenderState=n}}class SS{constructor(){this.viewport={x:0,y:0,width:0,height:0}}}class MS{constructor(e,t){this.session=e,this.context=t,this.subImageCache=new ES}createProjectionLayer(e=Hw){const t=new Gw(e);if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");return t.initialize(this.session,this.context),t}createQuadLayer(e=Fw){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(e.layout===Aw.default)throw new TypeError("Trying to create a quad layer with default layout");const t=new Bw(e);return t.initialize(this.session,this.context),t}createCylinderLayer(e=Iw){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(e.layout===Aw.default)throw new TypeError("Cylinder Layer cannot have a default layout");const t=new Nw(e);return t.initialize(this.session,this.context),t}createEquirectLayer(e=Ow){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(e.layout===Aw.default)throw new TypeError("Equirect Layer cannot have a default layout");if(!Rw(e.space))throw new TypeError("Equirect layer requires an XRReferenceSpace");let t=new Uw(e);return t.initialize(this.session,this.context),t}createCubeLayer(e){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(!(this.context instanceof WebGL2RenderingContext))throw new Error("XRCubeLayer only work on WebGL2");if(!Rw(e.space))throw new TypeError("XRCubeLayer requires a space of type XRReferenceSpace");let t=new vS(e);return t.initialize(this.session,this.context),t}getSubImage(e,t,n="none"){if(e.isStatic&&!1===e.needsRedraw)throw new Error("Invalid state for subimage creation");let i=this.subImageCache.tryGetCachedSubImage(this.context,e,n);if(i)return i;let r=new SS;if(e instanceof Gw)throw new TypeError;if(e.layout===Aw.default)throw new TypeError;if(!this.validateStateofSubImageCreation(e,t))throw new Error("Invalid state for subimage creation");let a=0;if(e.layout===Aw.stereo){if("none"===n)throw new TypeError;"right"===n&&(a=1)}e.getTextureType()===Tw["texture-array"]?r.imageIndex=a:r.imageIndex=0;let s=0;e.getTextureType()===Tw.texture?(r.colorTexture=e.colorTextures[a],s=a):(r.colorTexture=e.colorTextures[0],s=0),e.depthStencilTextures&&e.depthStencilTextures.length?e.getTextureType()===Tw.texture?r.depthStencilTexture=e.depthStencilTextures[a]:r.depthStencilTexture=e.depthStencilTextures[0]:r.depthStencilTexture=null;const o=e.colorTexturesMeta[s];r.textureWidth=o.width,r.textureHeight=o.height;let l=1;return e.layout!==Aw["stereo-left-right"]&&e.layout!==Aw["stereo-top-bottom"]||(l=2),jw(r.viewport,o,e.layout,a,l),this.session.queueTask(()=>{e.needsRedraw=!1}),this.subImageCache.cacheSubImage(r,this.context,e,n),r}getViewSubImage(e,t){let n=this.subImageCache.tryGetCachedViewSubImage(this.context,e,t);if(n)return n;let i=new SS,r=this.session;if(!r.internalViews||!r.internalViews.length)return console.warn("Tried to get view sub image before we have any views"),i;let a=r.getViewIndex(t),s=0;return e.getTextureType()===Tw["texture-array"]?i.imageIndex=a:i.imageIndex=0,e.layout===Aw.default&&e.getTextureType()===Tw.texture?(i.colorTexture=e.colorTextures[a],s=a):(i.colorTexture=e.colorTextures[0],s=0),0===e.depthStencilTextures.length?i.depthStencilTexture=null:e.layout===Aw.default&&e.getTextureType()===Tw.texture?i.depthStencilTexture=e.depthStencilTextures[a]:i.depthStencilTexture=e.depthStencilTextures[0],i.textureWidth=e.colorTexturesMeta[s].width,i.textureHeight=e.colorTexturesMeta[s].height,jw(i.viewport,e.colorTexturesMeta[s],e.layout,a,r.internalViews.length),e.needsRedraw=!1,this.subImageCache.cacheViewSubImage(i,this.context,e,t),i}validateStateofSubImageCreation(e,t){return t.session===e.session&&(this.session===e.session&&(this.context===e.context&&(!(!e.colorTextures||!e.colorTextures.length)&&(!e.isStatic||!1!==e.needsRedraw))))}}class ES{constructor(){this.cache=new Map,this.viewCache=new Map}cacheSubImage(e,t,n,i){let r=new Map;r.set(i,e);let a=new Map;a.set(n,r),this.cache.set(t,a)}tryGetCachedSubImage(e,t,n){var i,r;return null===(r=null===(i=this.cache.get(e))||void 0===i?void 0:i.get(t))||void 0===r?void 0:r.get(n)}cacheViewSubImage(e,t,n,i){let r=new Map;r.set(i,e);let a=new Map;a.set(n,r),this.viewCache.set(t,a)}tryGetCachedViewSubImage(e,t,n){var i,r;return null===(r=null===(i=this.viewCache.get(e))||void 0===i?void 0:i.get(t))||void 0===r?void 0:r.get(n)}}class TS{constructor(){this.injected=!1;const e=Cw();this._injectPolyfill(e)}_injectPolyfill(e){if(!("xr"in e.navigator))throw new Error("WebXR Layers polyfill requires WebXR support.");!0===this.injected&&console.warn("Polyfill has already been injected..."),(e=>!!e.navigator.xr&&!(!e.XRMediaBinding||!e.XRWebGLBinding))(e)||(this._polyfillRequiredLayersFeature(e),this._polyfillXRSession(e),e.XRWebGLBinding=MS,e.XRMediaBinding=Vw,this.injected=!0,console.log("Injected Layers Polyfill"))}_polyfillXRSession(e){e.XRSession.prototype._updateRenderState=e.XRSession.prototype.updateRenderState,e.XRSession.prototype._requestAnimationFrame=e.XRSession.prototype.requestAnimationFrame;let t=Object.getOwnPropertyDescriptor(e.XRSession.prototype,"renderState");Object.defineProperty(e.XRSession.prototype,"_renderState",t);let n=Object.getOwnPropertyDescriptor(wS.prototype,"renderState");Object.defineProperty(e.XRSession.prototype,"renderState",n);let i=Object.getOwnPropertyNames(wS.prototype);for(let t of i){let n=Object.getOwnPropertyDescriptor(wS.prototype,t);Object.defineProperty(e.XRSession.prototype,t,n)}}_polyfillRequiredLayersFeature(e){const t=e.navigator.xr.requestSession;Object.defineProperty(e.navigator.xr,"requestSessionInternal",{writable:!0}),e.navigator.xr.requestSessionInternal=t;Object.defineProperty(e.navigator.xr,"requestSession",{writable:!0}),e.navigator.xr.requestSession=(t,n)=>{const i=(n,i)=>e.navigator.xr.requestSessionInternal(n,i).then(e=>{Object.assign(e,new wS);let n=e;return n.initializeSession(t),Promise.resolve(n)});if("immersive-vr"!==t)return i(t,n);if(!n)return i(t,n);if(n.requiredFeatures&&n.requiredFeatures.indexOf("layers")>-1){const e=Object.assign({},n),r=[...n.requiredFeatures],a=r.indexOf("layers");return r.splice(a,1),e.requiredFeatures=r,i(t,e)}return i(t,n)}}}const AS={ipd:.063,fovy:Math.PI/2,headsetPosition:new Z_(0,1.6,0),headsetQuaternion:new Q_,stereoEnabled:!1};class RS{constructor(e,t={}){var n,i,r,a,s,o;this.version=ww;const l=new Y_,c=new Bb(Fb.Viewer,l),u={[zb.Left]:new $_(c),[zb.Right]:new $_(c),[zb.None]:new $_(c)},d=e.controllerConfig,h={};d&&Object.values(ob).forEach(e=>{d.layout[e]&&(h[e]=new vb(d,e,l))});const f={[ob.Left]:new vw(rw,ob.Left,l),[ob.Right]:new vw(rw,ob.Right,l)},p=null!==(n=t.canvasContainer)&&void 0!==n?n:document.createElement("div");p.dataset.webxr_runtime=`Immersive Web Emulation Runtime v${ww}`,p.style.position="fixed",p.style.width="100%",p.style.height="100%",p.style.top="0",p.style.left="0",p.style.display="flex",p.style.justifyContent="center",p.style.alignItems="center",p.style.overflow="hidden",p.style.zIndex="999",this[E_]={name:e.name,supportedSessionModes:e.supportedSessionModes,supportedFeatures:e.supportedFeatures,supportedFrameRates:e.supportedFrameRates,isSystemKeyboardSupported:e.isSystemKeyboardSupported,internalNominalFrameRate:e.internalNominalFrameRate,environmentBlendModes:e.environmentBlendModes,interactionMode:e.interactionMode,userAgent:e.userAgent,position:null!==(i=t.headsetPosition)&&void 0!==i?i:AS.headsetPosition.clone(),quaternion:null!==(r=t.headsetQuaternion)&&void 0!==r?r:AS.headsetQuaternion.clone(),stereoEnabled:null!==(a=t.stereoEnabled)&&void 0!==a?a:AS.stereoEnabled,ipd:null!==(s=t.ipd)&&void 0!==s?s:AS.ipd,fovy:null!==(o=t.fovy)&&void 0!==o?o:AS.fovy,controllers:h,hands:f,primaryInputMode:"controller",pendingReferenceSpaceReset:!1,visibilityState:"visible",pendingVisibilityState:null,xrSystem:null,matrix:Wx(),globalSpace:l,viewerSpace:c,viewSpaces:u,canvasContainer:p,getViewport:(e,t)=>{const n=e.context.canvas,{width:i,height:r}=n;switch(t.eye){case zb.None:return new Ew(0,0,i,r);case zb.Left:return new Ew(0,0,this[E_].stereoEnabled?i/2:i,r);case zb.Right:return new Ew(i/2,0,this[E_].stereoEnabled?i/2:0,r)}},updateViews:()=>{Qx(this[E_].viewerSpace[G_].offsetMatrix,this[E_].quaternion.quat,this[E_].position.vec3),Kx(this[E_].viewSpaces[zb.Left][G_].offsetMatrix,r_(-this[E_].ipd/2,0,0)),Kx(this[E_].viewSpaces[zb.Right][G_].offsetMatrix,r_(this[E_].ipd/2,0,0))},onBaseLayerSet:e=>{if(!e)return;const t=e.context.canvas;if(t.parentElement!==this[E_].canvasContainer){const e=this[E_].devui;if(e){const{devUICanvas:t,devUIContainer:n}=e;t.style.zIndex=3..toString(),n.style.zIndex=4..toString(),this[E_].canvasContainer.appendChild(e.devUICanvas),this[E_].canvasContainer.appendChild(e.devUIContainer)}const n=this[E_].sem;n&&(n.environmentCanvas.style.zIndex=1..toString(),this[E_].canvasContainer.appendChild(n.environmentCanvas)),this[E_].canvasData={canvas:t,parent:t.parentElement,width:t.width,height:t.height,zIndex:t.style.zIndex},t.style.zIndex=2..toString(),this[E_].canvasContainer.appendChild(t),document.body.appendChild(this[E_].canvasContainer)}t.width=window.innerWidth,t.height=window.innerHeight},onSessionEnd:()=>{if(this[E_].canvasData){const{canvas:e,parent:t,width:n,height:i,zIndex:r}=this[E_].canvasData;e.width=n,e.height=i,e.style.zIndex=r,t?t.appendChild(e):this[E_].canvasContainer.removeChild(e);const a=this[E_].devui;a&&(this[E_].canvasContainer.removeChild(a.devUICanvas),this[E_].canvasContainer.removeChild(a.devUIContainer));const s=this[E_].sem;s&&this[E_].canvasContainer.removeChild(s.environmentCanvas),document.body.removeChild(this[E_].canvasContainer),this[E_].canvasData=void 0,window.dispatchEvent(new Event("resize"))}},onFrameStart:e=>{var t;const n=performance.now(),i=this[E_].lastFrameTime>0?n-this[E_].lastFrameTime:16.67;if(this[E_].lastFrameTime=n,this[E_].remote&&this[E_].remote.update(i),null===(t=this[E_].actionPlayer)||void 0===t?void 0:t.playing)this[E_].actionPlayer.playFrame();else{const t=e.session;this[E_].updateViews(),this[E_].pendingVisibilityState&&(this[E_].visibilityState=this[E_].pendingVisibilityState,this[E_].pendingVisibilityState=null,t.dispatchEvent(new Hb("visibilitychange",{session:t}))),"visible"===this[E_].visibilityState&&this.activeInputs.forEach(t=>{t.onFrameStart(e)}),this[E_].pendingReferenceSpaceReset&&(t[B_].referenceSpaces.forEach(e=>{switch(e[H_].type){case Fb.Local:case Fb.LocalFloor:case Fb.BoundedFloor:case Fb.Unbounded:e.dispatchEvent(new Sw("reset",{referenceSpace:e}))}}),this[E_].pendingReferenceSpaceReset=!1)}this[E_].updateViews()},controlMode:"manual",controlModeListeners:new Set,stateChangeListeners:new Set,remote:null,lastFrameTime:0},this[E_].remote=new ab(this),this[E_].updateViews()}installRuntime(e){var t;const n=null!==(t=null==e?void 0:e.globalObject)&&void 0!==t?t:globalThis,i=null==e?void 0:e.polyfillLayers;Object.defineProperty(WebGL2RenderingContext.prototype,"makeXRCompatible",{value:function(){return new Promise((e,t)=>{e(!0)})},configurable:!0}),this[E_].xrSystem=new Mw(this),Object.defineProperty(globalThis.navigator,"xr",{value:this[E_].xrSystem,configurable:!0}),Object.defineProperty(navigator,"userAgent",{value:this[E_].userAgent,writable:!1,configurable:!1,enumerable:!0}),n.XRSystem=Mw,n.XRSession=tw,n.XRRenderState=Vb,n.XRFrame=Zb,n.XRSpace=$_,n.XRReferenceSpace=Bb,n.XRJointSpace=iw,n.XRView=Gb,n.XRViewport=Ew,n.XRRigidTransform=Lb,n.XRPose=jb,n.XRViewerPose=Xb,n.XRJointPose=Wb,n.XRInputSource=fb,n.XRInputSourceArray=hb,n.XRHand=nw,n.XRLayer=yw,n.XRWebGLLayer=_w,n.XRSessionEvent=Hb,n.XRInputSourceEvent=pb,n.XRInputSourcesChangeEvent=kb,n.XRReferenceSpaceEvent=Sw,i?new TS:(n.XRMediaBinding=void 0,n.XRWebGLBinding=void 0)}installDevUI(e){this[E_].devui=new e(this)}installSEM(e){this[E_].sem=new e(this)}get supportedSessionModes(){return this[E_].supportedSessionModes}get supportedFeatures(){return this[E_].supportedFeatures}get supportedFrameRates(){return this[E_].supportedFrameRates}get isSystemKeyboardSupported(){return this[E_].isSystemKeyboardSupported}get internalNominalFrameRate(){return this[E_].internalNominalFrameRate}get stereoEnabled(){return this[E_].stereoEnabled}set stereoEnabled(e){this[E_].stereoEnabled=e}get ipd(){return this[E_].ipd}set ipd(e){this[E_].ipd=e}get fovy(){return this[E_].fovy}set fovy(e){this[E_].fovy=e}get position(){return this[E_].position}get quaternion(){return this[E_].quaternion}get viewerSpace(){var e;return(null===(e=this[E_].actionPlayer)||void 0===e?void 0:e.playing)?this[E_].actionPlayer.viewerSpace:this[E_].viewerSpace}get viewSpaces(){var e;return(null===(e=this[E_].actionPlayer)||void 0===e?void 0:e.playing)?this[E_].actionPlayer.viewSpaces:this[E_].viewSpaces}get controllers(){return this[E_].controllers}get hands(){return this[E_].hands}get primaryInputMode(){return this[E_].primaryInputMode}set primaryInputMode(e){"controller"===e||"hand"===e?this[E_].primaryInputMode=e:console.warn('primary input mode can only be "controller" or "hand"')}get activeInputs(){if("visible"!==this[E_].visibilityState)return[];return("controller"===this[E_].primaryInputMode?Object.values(this[E_].controllers):Object.values(this[E_].hands)).filter(e=>e.connected)}get inputSources(){var e;return(null===(e=this[E_].actionPlayer)||void 0===e?void 0:e.playing)?this[E_].actionPlayer.inputSources:this.activeInputs.map(e=>e.inputSource)}get canvasContainer(){return this[E_].canvasContainer}get canvasDimensions(){if(this[E_].canvasData){const{width:e,height:t}=this[E_].canvasData.canvas;return{width:e,height:t}}}get appCanvas(){var e;return null===(e=this[E_].canvasData)||void 0===e?void 0:e.canvas}get activeSession(){var e;return null===(e=this[E_].xrSystem)||void 0===e?void 0:e[P_].activeSession}get sessionOffered(){var e;return Boolean(null===(e=this[E_].xrSystem)||void 0===e?void 0:e[P_].offeredSessionConfig)}get name(){return this[E_].name}grantOfferedSession(){const e=this[E_].xrSystem,t=null==e?void 0:e[P_];if(t&&t.offeredSessionConfig){const{resolve:n,reject:i,mode:r,options:a}=t.offeredSessionConfig;t.offeredSessionConfig=void 0,e.requestSession(r,a).then(n).catch(i)}}recenter(){const e=new Z_(-this.position.x,0,-this.position.z),t=new Z_(0,0,-1).applyQuaternion(this.quaternion);t.y=0,t.normalize();const n=Math.atan2(t.x,-t.z),i=(new Q_).setFromAxisAngle(new Z_(0,1,0),n);this.position.add(e),this.quaternion.multiply(i),[...Object.values(this[E_].controllers),...Object.values(this[E_].hands)].forEach(t=>{t.position.add(e),t.quaternion.multiply(i),t.position.applyQuaternion(i)}),this[E_].pendingReferenceSpaceReset=!0}get visibilityState(){return this[E_].visibilityState}updateVisibilityState(e){if(!Object.values(["visible","visible-blurred","hidden"]).includes(e))throw new DOMException("Invalid XRVisibilityState value","NotSupportedError");e!==this[E_].visibilityState&&(this[E_].pendingVisibilityState=e)}createActionPlayer(e,t){return this[E_].actionPlayer=new bw(e,t,this[E_].ipd),this[E_].actionPlayer}get devui(){return this[E_].devui}get sem(){return this[E_].sem}get remote(){return this[E_].remote}get controlMode(){return this[E_].controlMode}set controlMode(e){if("manual"!==e&&"programmatic"!==e)return void console.warn('control mode can only be "manual" or "programmatic"');this[E_].controlMode!==e&&(this[E_].controlMode=e,this[E_].controlModeListeners.forEach(t=>t(e)))}onControlModeChange(e){return this[E_].controlModeListeners.add(e),()=>{this[E_].controlModeListeners.delete(e)}}onStateChange(e){return this[E_].stateChangeListeners.add(e),()=>{this[E_].stateChangeListeners.delete(e)}}notifyStateChange(){this[E_].stateChangeListeners.forEach(e=>e())}}const CS={mapping:sb.XRStandard,buttons:[{id:"trigger",type:"analog",eventTrigger:"select"},{id:"squeeze",type:"analog",eventTrigger:"squeeze"},null,{id:"thumbstick",type:"binary"},{id:"x-button",type:"binary"},{id:"y-button",type:"binary"},{id:"thumbrest",type:"binary"}],axes:[null,null,{id:"thumbstick",type:"x-axis"},{id:"thumbstick",type:"y-axis"}]},PS={mapping:sb.XRStandard,buttons:[{id:"trigger",type:"analog",eventTrigger:"select"},{id:"squeeze",type:"analog",eventTrigger:"squeeze"},null,{id:"thumbstick",type:"binary"},{id:"a-button",type:"binary"},{id:"b-button",type:"binary"},{id:"thumbrest",type:"binary"}],axes:[null,null,{id:"thumbstick",type:"x-axis"},{id:"thumbstick",type:"y-axis"}]},LS={profileId:"oculus-touch-v3",fallbackProfileIds:["oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:CS,gripOffsetMatrix:[.9925461411476135,2.0823669899527886e-8,-.12186937034130096,0,.08617465198040009,.7071067094802856,.701836109161377,0,.08617466688156128,-.7071067690849304,.7018360495567322,0,-.003979838453233242,-.015857907012104988,.04964181408286095,1],numHapticActuators:1},right:{gamepad:PS,gripOffsetMatrix:[.9925461411476135,-8.329467959811154e-8,.12186941504478455,0,-.08617465943098068,.7071066498756409,.7018361687660217,0,-.08617471158504486,-.7071068286895752,.7018359303474426,0,.003979798872023821,-.015857888385653496,.049641866236925125,1],numHapticActuators:1}}},IS={profileId:"meta-quest-touch-pro",fallbackProfileIds:["oculus-touch-v2","oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:CS,gripOffsetMatrix:[.9925461411476135,-1.5779937356796836e-8,-.12186935544013977,0,.08617467433214188,.7071067094802856,.701836109161377,0,.0861746296286583,-.7071067690849304,.7018360495567322,0,-.003979836590588093,-.015857847407460213,.049641840159893036,1],numHapticActuators:3},right:{gamepad:PS,gripOffsetMatrix:[.9925461411476135,9267653311439972e-26,.12186937034130096,0,-.08617467433214188,.7071067094802856,.7018361687660217,0,-.08617464452981949,-.7071067690849304,.7018360495567322,0,.003979847766458988,-.01585782691836357,.04964186251163483,1],numHapticActuators:3}}},DS={profileId:"meta-quest-touch-plus",fallbackProfileIds:["oculus-touch-v3","oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:CS,gripOffsetMatrix:[.9925461411476135,1.0736208366779465e-8,-.12186933308839798,0,.08617459982633591,.70710688829422,.7018360495567322,0,.08617466688156128,-.7071067094802856,.7018362283706665,0,-.003979803062975407,-.015857873484492302,.04964187368750572,1],numHapticActuators:1},right:{gamepad:PS,gripOffsetMatrix:[.9925461411476135,-2.6238110351073374e-8,.12186934053897858,0,-.0861746147274971,.7071067690849304,.7018360495567322,0,-.08617465943098068,-.7071067094802856,.701836109161377,0,.003979838453233242,-.015857869759202003,.04964182525873184,1],numHapticActuators:1}}},NS={name:"Oculus Quest 1",controllerConfig:{profileId:"oculus-touch-v2",fallbackProfileIds:["oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:CS,gripOffsetMatrix:[.9925461411476135,4.673031295254759e-9,-.12186938524246216,0,.08617470413446426,.7071065306663513,.7018362283706665,0,.0861746296286583,-.70710688829422,.7018358707427979,0,-.003979847766458988,-.01585787907242775,.04964185878634453,1],numHapticActuators:1},right:{gamepad:PS,gripOffsetMatrix:[.9925461411476135,3.688163374704345e-8,.12186937034130096,0,-.08617469668388367,.7071066498756409,.7018361687660217,0,-.0861746147274971,-.7071068286895752,.7018359899520874,0,.003979853354394436,-.01585787907242775,.04964182525873184,1],numHapticActuators:1}}},supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","hand-tracking"],supportedFrameRates:[72,80,90],isSystemKeyboardSupported:!0,internalNominalFrameRate:72,environmentBlendModes:{"immersive-vr":Qb.Opaque,"immersive-ar":Qb.AlphaBlend},interactionMode:Jb.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest 1) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"},OS={name:"Meta Quest 2",controllerConfig:LS,supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","mesh-detection","hit-test","hand-tracking"],supportedFrameRates:[72,80,90,120],isSystemKeyboardSupported:!0,internalNominalFrameRate:72,environmentBlendModes:{"immersive-vr":Qb.Opaque,"immersive-ar":Qb.AlphaBlend},interactionMode:Jb.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest 2) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"},kS={name:"Meta Quest Pro",controllerConfig:IS,supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","mesh-detection","hit-test","hand-tracking"],supportedFrameRates:[72,80,90,120],isSystemKeyboardSupported:!0,internalNominalFrameRate:90,environmentBlendModes:{"immersive-vr":Qb.Opaque,"immersive-ar":Qb.AlphaBlend},interactionMode:Jb.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest Pro) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"},US={name:"Meta Quest 3",controllerConfig:DS,supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","mesh-detection","hit-test","hand-tracking","depth-sensing"],supportedFrameRates:[72,80,90,120],isSystemKeyboardSupported:!0,internalNominalFrameRate:90,environmentBlendModes:{"immersive-vr":Qb.Opaque,"immersive-ar":Qb.AlphaBlend},interactionMode:Jb.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest 3) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"};function FS(){let e=0,t=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(e|=(127&i)<<n,!(128&i))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(15&n)<<28,t=(112&n)>>4,!(128&n))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(t|=(127&i)<<n,!(128&i))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function zS(e,t,n){for(let i=0;i<28;i+=7){const r=e>>>i,a=!(r>>>7==0&&0==t),s=255&(a?128|r:r);if(n.push(s),!a)return}const i=e>>>28&15|(7&t)<<4,r=!!(t>>3);if(n.push(255&(r?128|i:i)),r){for(let e=3;e<31;e+=7){const i=t>>>e,r=!(i>>>7==0),a=255&(r?128|i:i);if(n.push(a),!r)return}n.push(t>>>31&1)}}const BS=4294967296;function VS(e){const t="-"===e[0];t&&(e=e.slice(1));const n=1e6;let i=0,r=0;function a(t,a){const s=Number(e.slice(t,a));r*=n,i=i*n+s,i>=BS&&(r+=i/BS|0,i%=BS)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?jS(i,r):GS(i,r)}function HS(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(BS*t+e);const n=16777215&(e>>>24|t<<8),i=t>>16&65535;let r=(16777215&e)+6777216*n+6710656*i,a=n+8147497*i,s=2*i;const o=1e7;return r>=o&&(a+=Math.floor(r/o),r%=o),a>=o&&(s+=Math.floor(a/o),a%=o),s.toString()+WS(a)+WS(r)}function GS(e,t){return{lo:0|e,hi:0|t}}function jS(e,t){return t=~t,e?e=1+~e:t+=1,GS(e,t)}const WS=e=>{const t=String(e);return"0000000".slice(t.length)+t};function XS(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function qS(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let t=5;128&e&&t<10;t++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}const $S=YS();function YS(){const e=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64&&(!!globalThis.Deno||"object"!=typeof process||"object"!=typeof process.env||"1"!==process.env.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),i=BigInt("0"),r=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const i="bigint"==typeof e?e:BigInt(e);if(i>n||i<t)throw new Error(`invalid int64: ${e}`);return i},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>r||t<i)throw new Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)),uDec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0))}}return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),KS(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),ZS(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),KS(e),VS(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),ZS(e),VS(e)),dec:(e,t)=>function(e,t){let n=GS(e,t);const i=2147483648&n.hi;i&&(n=jS(n.lo,n.hi));const r=HS(n.lo,n.hi);return i?"-"+r:r}(e,t),uDec:(e,t)=>HS(e,t)}}function KS(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function ZS(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}const QS=Symbol.for("@bufbuild/protobuf/text-encoding");function JS(){if(null==globalThis[QS]){const e=new globalThis.TextEncoder,t=new globalThis.TextDecoder;globalThis[QS]={encodeUtf8:t=>e.encode(t),decodeUtf8:e=>t.decode(e),checkUtf8(e){try{return encodeURIComponent(e),!0}catch(e){return!1}}}}return globalThis[QS]}var eM;!function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"}(eM||(eM={}));const tM=34028234663852886e22,nM=-34028234663852886e22;class iM{constructor(e=JS().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(sM(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return aM(e),XS(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.encodeUtf8(e);return this.uint32(t.byteLength),this.raw(t)}float(e){!function(e){if("string"==typeof e){const t=e;if(e=Number(e),Number.isNaN(e)&&"NaN"!==t)throw new Error("invalid float32: "+t)}else if("number"!=typeof e)throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>tM||e<nM))throw new Error("invalid float32: "+e)}(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){sM(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){aM(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return aM(e),XS(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=$S.enc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=$S.uEnc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=$S.enc(e);return zS(t.lo,t.hi,this.buf),this}sint64(e){const t=$S.enc(e),n=t.hi>>31;return zS(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){const t=$S.uEnc(e);return zS(t.lo,t.hi,this.buf),this}}class rM{constructor(e,t=JS().decodeUtf8){this.decodeUtf8=t,this.varint64=FS,this.uint32=qS,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.uint32(),t=e>>>3,n=7&e;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case eM.Varint:for(;128&this.buf[this.pos++];);break;case eM.Bit64:this.pos+=4;case eM.Bit32:this.pos+=4;break;case eM.LengthDelimited:let n=this.uint32();this.pos+=n;break;case eM.StartGroup:for(;;){const[e,n]=this.tag();if(n===eM.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(n,e)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return $S.dec(...this.varint64())}uint64(){return $S.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,$S.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return $S.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return $S.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.decodeUtf8(this.bytes())}}function aM(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int32: "+e)}function sM(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint32: "+e)}const oM={encode:(e,t=new iM)=>(0!==e.x&&t.uint32(13).float(e.x),0!==e.y&&t.uint32(21).float(e.y),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={x:0,y:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.x=n.float();continue;case 2:if(21!==e)break;r.y=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({x:mM(e.x)?globalThis.Number(e.x):0,y:mM(e.y)?globalThis.Number(e.y):0}),toJSON(e){const t={};return 0!==e.x&&(t.x=e.x),0!==e.y&&(t.y=e.y),t},create:e=>oM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i={x:0,y:0};return i.x=null!==(t=e.x)&&void 0!==t?t:0,i.y=null!==(n=e.y)&&void 0!==n?n:0,i}};const lM={encode:(e,t=new iM)=>(0!==e.width&&t.uint32(13).float(e.width),0!==e.height&&t.uint32(21).float(e.height),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={width:0,height:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.width=n.float();continue;case 2:if(21!==e)break;r.height=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({width:mM(e.width)?globalThis.Number(e.width):0,height:mM(e.height)?globalThis.Number(e.height):0}),toJSON(e){const t={};return 0!==e.width&&(t.width=e.width),0!==e.height&&(t.height=e.height),t},create:e=>lM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i={width:0,height:0};return i.width=null!==(t=e.width)&&void 0!==t?t:0,i.height=null!==(n=e.height)&&void 0!==n?n:0,i}};const cM={encode:(e,t=new iM)=>(0!==e.x&&t.uint32(13).float(e.x),0!==e.y&&t.uint32(21).float(e.y),0!==e.z&&t.uint32(29).float(e.z),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={x:0,y:0,z:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.x=n.float();continue;case 2:if(21!==e)break;r.y=n.float();continue;case 3:if(29!==e)break;r.z=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({x:mM(e.x)?globalThis.Number(e.x):0,y:mM(e.y)?globalThis.Number(e.y):0,z:mM(e.z)?globalThis.Number(e.z):0}),toJSON(e){const t={};return 0!==e.x&&(t.x=e.x),0!==e.y&&(t.y=e.y),0!==e.z&&(t.z=e.z),t},create:e=>cM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i;const r={x:0,y:0,z:0};return r.x=null!==(t=e.x)&&void 0!==t?t:0,r.y=null!==(n=e.y)&&void 0!==n?n:0,r.z=null!==(i=e.z)&&void 0!==i?i:0,r}};const uM={encode:(e,t=new iM)=>(0!==e.width&&t.uint32(13).float(e.width),0!==e.height&&t.uint32(21).float(e.height),0!==e.depth&&t.uint32(29).float(e.depth),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={width:0,height:0,depth:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.width=n.float();continue;case 2:if(21!==e)break;r.height=n.float();continue;case 3:if(29!==e)break;r.depth=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({width:mM(e.width)?globalThis.Number(e.width):0,height:mM(e.height)?globalThis.Number(e.height):0,depth:mM(e.depth)?globalThis.Number(e.depth):0}),toJSON(e){const t={};return 0!==e.width&&(t.width=e.width),0!==e.height&&(t.height=e.height),0!==e.depth&&(t.depth=e.depth),t},create:e=>uM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i;const r={width:0,height:0,depth:0};return r.width=null!==(t=e.width)&&void 0!==t?t:0,r.height=null!==(n=e.height)&&void 0!==n?n:0,r.depth=null!==(i=e.depth)&&void 0!==i?i:0,r}};const dM={encode:(e,t=new iM)=>(0!==e.x&&t.uint32(13).float(e.x),0!==e.y&&t.uint32(21).float(e.y),0!==e.z&&t.uint32(29).float(e.z),0!==e.w&&t.uint32(37).float(e.w),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={x:0,y:0,z:0,w:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.x=n.float();continue;case 2:if(21!==e)break;r.y=n.float();continue;case 3:if(29!==e)break;r.z=n.float();continue;case 4:if(37!==e)break;r.w=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({x:mM(e.x)?globalThis.Number(e.x):0,y:mM(e.y)?globalThis.Number(e.y):0,z:mM(e.z)?globalThis.Number(e.z):0,w:mM(e.w)?globalThis.Number(e.w):0}),toJSON(e){const t={};return 0!==e.x&&(t.x=e.x),0!==e.y&&(t.y=e.y),0!==e.z&&(t.z=e.z),0!==e.w&&(t.w=e.w),t},create:e=>dM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i,r;const a={x:0,y:0,z:0,w:0};return a.x=null!==(t=e.x)&&void 0!==t?t:0,a.y=null!==(n=e.y)&&void 0!==n?n:0,a.z=null!==(i=e.z)&&void 0!==i?i:0,a.w=null!==(r=e.w)&&void 0!==r?r:0,a}};const hM={encode:(e,t=new iM)=>(void 0!==e.offset&&oM.encode(e.offset,t.uint32(10).fork()).join(),void 0!==e.extent&&lM.encode(e.extent,t.uint32(18).fork()).join(),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={offset:void 0,extent:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.offset=oM.decode(n,n.uint32());continue;case 2:if(18!==e)break;r.extent=lM.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({offset:mM(e.offset)?oM.fromJSON(e.offset):void 0,extent:mM(e.extent)?lM.fromJSON(e.extent):void 0}),toJSON(e){const t={};return void 0!==e.offset&&(t.offset=oM.toJSON(e.offset)),void 0!==e.extent&&(t.extent=lM.toJSON(e.extent)),t},create:e=>hM.fromPartial(null!=e?e:{}),fromPartial(e){const t={offset:void 0,extent:void 0};return t.offset=void 0!==e.offset&&null!==e.offset?oM.fromPartial(e.offset):void 0,t.extent=void 0!==e.extent&&null!==e.extent?lM.fromPartial(e.extent):void 0,t}};const fM={encode:(e,t=new iM)=>(void 0!==e.offset&&cM.encode(e.offset,t.uint32(10).fork()).join(),void 0!==e.extent&&uM.encode(e.extent,t.uint32(18).fork()).join(),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={offset:void 0,extent:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.offset=cM.decode(n,n.uint32());continue;case 2:if(18!==e)break;r.extent=uM.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({offset:mM(e.offset)?cM.fromJSON(e.offset):void 0,extent:mM(e.extent)?uM.fromJSON(e.extent):void 0}),toJSON(e){const t={};return void 0!==e.offset&&(t.offset=cM.toJSON(e.offset)),void 0!==e.extent&&(t.extent=uM.toJSON(e.extent)),t},create:e=>fM.fromPartial(null!=e?e:{}),fromPartial(e){const t={offset:void 0,extent:void 0};return t.offset=void 0!==e.offset&&null!==e.offset?cM.fromPartial(e.offset):void 0,t.extent=void 0!==e.extent&&null!==e.extent?uM.fromPartial(e.extent):void 0,t}};const pM={encode:(e,t=new iM)=>(void 0!==e.orientation&&dM.encode(e.orientation,t.uint32(10).fork()).join(),void 0!==e.position&&cM.encode(e.position,t.uint32(18).fork()).join(),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={orientation:void 0,position:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.orientation=dM.decode(n,n.uint32());continue;case 2:if(18!==e)break;r.position=cM.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({orientation:mM(e.orientation)?dM.fromJSON(e.orientation):void 0,position:mM(e.position)?cM.fromJSON(e.position):void 0}),toJSON(e){const t={};return void 0!==e.orientation&&(t.orientation=dM.toJSON(e.orientation)),void 0!==e.position&&(t.position=cM.toJSON(e.position)),t},create:e=>pM.fromPartial(null!=e?e:{}),fromPartial(e){const t={orientation:void 0,position:void 0};return t.orientation=void 0!==e.orientation&&null!==e.orientation?dM.fromPartial(e.orientation):void 0,t.position=void 0!==e.position&&null!==e.position?cM.fromPartial(e.position):void 0,t}};function mM(e){return null!=e}var gM,vM;function yM(e){switch(e){case 0:case"Keyboard":return gM.Keyboard;default:return gM.UNRECOGNIZED}}function xM(e){switch(e){case 0:case"UNKNOWN":return vM.UNKNOWN;case 1:case"FLOOR":return vM.FLOOR;case 2:case"CEILING":return vM.CEILING;case 3:case"WALL_FACE":return vM.WALL_FACE;case 4:case"TABLE":return vM.TABLE;case 5:case"COUCH":return vM.COUCH;case 6:case"DOOR_FRAME":return vM.DOOR_FRAME;case 7:case"WINDOW_FRAME":return vM.WINDOW_FRAME;case 8:case"OTHER":return vM.OTHER;case 9:case"STORAGE":return vM.STORAGE;case 10:case"BED":return vM.BED;case 11:case"SCREEN":return vM.SCREEN;case 12:case"LAMP":return vM.LAMP;case 13:case"PLANT":return vM.PLANT;case 14:case"WALL_ART":return vM.WALL_ART;case 15:case"GLOBAL_MESH":return vM.GLOBAL_MESH;case 16:case"INVISIBLE_WALL_FACE":return vM.INVISIBLE_WALL_FACE;case 17:case"CHAIR":return vM.CHAIR;case 18:case"INNER_WALL_FACE":return vM.INNER_WALL_FACE;case 19:case"OTHER_ROOM_FACE":return vM.OTHER_ROOM_FACE;case 20:case"OPENING":return vM.OPENING;default:return vM.UNRECOGNIZED}}function _M(e){switch(e){case vM.UNKNOWN:return"UNKNOWN";case vM.FLOOR:return"FLOOR";case vM.CEILING:return"CEILING";case vM.WALL_FACE:return"WALL_FACE";case vM.TABLE:return"TABLE";case vM.COUCH:return"COUCH";case vM.DOOR_FRAME:return"DOOR_FRAME";case vM.WINDOW_FRAME:return"WINDOW_FRAME";case vM.OTHER:return"OTHER";case vM.STORAGE:return"STORAGE";case vM.BED:return"BED";case vM.SCREEN:return"SCREEN";case vM.LAMP:return"LAMP";case vM.PLANT:return"PLANT";case vM.WALL_ART:return"WALL_ART";case vM.GLOBAL_MESH:return"GLOBAL_MESH";case vM.INVISIBLE_WALL_FACE:return"INVISIBLE_WALL_FACE";case vM.CHAIR:return"CHAIR";case vM.INNER_WALL_FACE:return"INNER_WALL_FACE";case vM.OTHER_ROOM_FACE:return"OTHER_ROOM_FACE";case vM.OPENING:return"OPENING";case vM.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.Keyboard=0]="Keyboard",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(gM||(gM={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.FLOOR=1]="FLOOR",e[e.CEILING=2]="CEILING",e[e.WALL_FACE=3]="WALL_FACE",e[e.TABLE=4]="TABLE",e[e.COUCH=5]="COUCH",e[e.DOOR_FRAME=6]="DOOR_FRAME",e[e.WINDOW_FRAME=7]="WINDOW_FRAME",e[e.OTHER=8]="OTHER",e[e.STORAGE=9]="STORAGE",e[e.BED=10]="BED",e[e.SCREEN=11]="SCREEN",e[e.LAMP=12]="LAMP",e[e.PLANT=13]="PLANT",e[e.WALL_ART=14]="WALL_ART",e[e.GLOBAL_MESH=15]="GLOBAL_MESH",e[e.INVISIBLE_WALL_FACE=16]="INVISIBLE_WALL_FACE",e[e.CHAIR=17]="CHAIR",e[e.INNER_WALL_FACE=18]="INNER_WALL_FACE",e[e.OTHER_ROOM_FACE=19]="OTHER_ROOM_FACE",e[e.OPENING=20]="OPENING",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(vM||(vM={}));const bM={encode(e,t=new iM){""!==e.floorUuid&&t.uint32(10).string(e.floorUuid),""!==e.ceilingUuid&&t.uint32(18).string(e.ceilingUuid);for(const n of e.wallUuids)t.uint32(26).string(n);return t},decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={floorUuid:"",ceilingUuid:"",wallUuids:[]};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.floorUuid=n.string();continue;case 2:if(18!==e)break;r.ceilingUuid=n.string();continue;case 3:if(26!==e)break;r.wallUuids.push(n.string());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({floorUuid:LM(e.floorUuid)?globalThis.String(e.floorUuid):"",ceilingUuid:LM(e.ceilingUuid)?globalThis.String(e.ceilingUuid):"",wallUuids:globalThis.Array.isArray(null==e?void 0:e.wallUuids)?e.wallUuids.map(e=>globalThis.String(e)):[]}),toJSON(e){var t;const n={};return""!==e.floorUuid&&(n.floorUuid=e.floorUuid),""!==e.ceilingUuid&&(n.ceilingUuid=e.ceilingUuid),(null===(t=e.wallUuids)||void 0===t?void 0:t.length)&&(n.wallUuids=e.wallUuids),n},create:e=>bM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i;const r={floorUuid:"",ceilingUuid:"",wallUuids:[]};return r.floorUuid=null!==(t=e.floorUuid)&&void 0!==t?t:"",r.ceilingUuid=null!==(n=e.ceilingUuid)&&void 0!==n?n:"",r.wallUuids=(null===(i=e.wallUuids)||void 0===i?void 0:i.map(e=>e))||[],r}};const wM={encode(e,t=new iM){for(const n of e.uuids)t.uint32(10).string(n);return t},decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={uuids:[]};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.uuids.push(n.string());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({uuids:globalThis.Array.isArray(null==e?void 0:e.uuids)?e.uuids.map(e=>globalThis.String(e)):[]}),toJSON(e){var t;const n={};return(null===(t=e.uuids)||void 0===t?void 0:t.length)&&(n.uuids=e.uuids),n},create:e=>wM.fromPartial(null!=e?e:{}),fromPartial(e){var t;const n={uuids:[]};return n.uuids=(null===(t=e.uuids)||void 0===t?void 0:t.map(e=>e))||[],n}};function SM(){return{vertices:new Uint8Array(0)}}const MM={encode:(e,t=new iM)=>(0!==e.vertices.length&&t.uint32(10).bytes(e.vertices),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r=SM();for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.vertices=n.bytes();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({vertices:LM(e.vertices)?CM(e.vertices):new Uint8Array(0)}),toJSON(e){const t={};return 0!==e.vertices.length&&(t.vertices=PM(e.vertices)),t},create:e=>MM.fromPartial(null!=e?e:{}),fromPartial(e){var t;const n=SM();return n.vertices=null!==(t=e.vertices)&&void 0!==t?t:new Uint8Array(0),n}};function EM(){return{vertices:new Uint8Array(0),indices:new Uint8Array(0)}}const TM={encode:(e,t=new iM)=>(0!==e.vertices.length&&t.uint32(10).bytes(e.vertices),0!==e.indices.length&&t.uint32(18).bytes(e.indices),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r=EM();for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.vertices=n.bytes();continue;case 2:if(18!==e)break;r.indices=n.bytes();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({vertices:LM(e.vertices)?CM(e.vertices):new Uint8Array(0),indices:LM(e.indices)?CM(e.indices):new Uint8Array(0)}),toJSON(e){const t={};return 0!==e.vertices.length&&(t.vertices=PM(e.vertices)),0!==e.indices.length&&(t.indices=PM(e.indices)),t},create:e=>TM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i=EM();return i.vertices=null!==(t=e.vertices)&&void 0!==t?t:new Uint8Array(0),i.indices=null!==(n=e.indices)&&void 0!==n?n:new Uint8Array(0),i}};const AM={encode:(e,t=new iM)=>(0!==e.classType&&t.uint32(8).int32(e.classType),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={classType:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(8!==e)break;r.classType=n.int32();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({classType:LM(e.classType)?yM(e.classType):0}),toJSON(e){const t={};return 0!==e.classType&&(t.classType=function(e){switch(e){case gM.Keyboard:return"Keyboard";case gM.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.classType)),t},create:e=>AM.fromPartial(null!=e?e:{}),fromPartial(e){var t;const n={classType:0};return n.classType=null!==(t=e.classType)&&void 0!==t?t:0,n}};const RM={encode:(e,t=new iM)=>(""!==e.uuid&&t.uint32(10).string(e.uuid),void 0!==e.semanticLabel_META&&t.uint32(16).int32(e.semanticLabel_META),void 0!==e.locatable_META&&pM.encode(e.locatable_META,t.uint32(26).fork()).join(),void 0!==e.boundary2D_META&&MM.encode(e.boundary2D_META,t.uint32(34).fork()).join(),void 0!==e.bounded2D_META&&hM.encode(e.bounded2D_META,t.uint32(42).fork()).join(),void 0!==e.bounded3D_META&&fM.encode(e.bounded3D_META,t.uint32(50).fork()).join(),void 0!==e.roomLayout_META&&bM.encode(e.roomLayout_META,t.uint32(58).fork()).join(),void 0!==e.spaceContainer_META&&wM.encode(e.spaceContainer_META,t.uint32(66).fork()).join(),void 0!==e.triangleMesh_META&&TM.encode(e.triangleMesh_META,t.uint32(74).fork()).join(),void 0!==e.dynamicObject_META&&AM.encode(e.dynamicObject_META,t.uint32(82).fork()).join(),t),decode(e,t){const n=e instanceof rM?e:new rM(e);let i=void 0===t?n.len:n.pos+t;const r={uuid:"",semanticLabel_META:void 0,locatable_META:void 0,boundary2D_META:void 0,bounded2D_META:void 0,bounded3D_META:void 0,roomLayout_META:void 0,spaceContainer_META:void 0,triangleMesh_META:void 0,dynamicObject_META:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.uuid=n.string();continue;case 2:if(16!==e)break;r.semanticLabel_META=n.int32();continue;case 3:if(26!==e)break;r.locatable_META=pM.decode(n,n.uint32());continue;case 4:if(34!==e)break;r.boundary2D_META=MM.decode(n,n.uint32());continue;case 5:if(42!==e)break;r.bounded2D_META=hM.decode(n,n.uint32());continue;case 6:if(50!==e)break;r.bounded3D_META=fM.decode(n,n.uint32());continue;case 7:if(58!==e)break;r.roomLayout_META=bM.decode(n,n.uint32());continue;case 8:if(66!==e)break;r.spaceContainer_META=wM.decode(n,n.uint32());continue;case 9:if(74!==e)break;r.triangleMesh_META=TM.decode(n,n.uint32());continue;case 10:if(82!==e)break;r.dynamicObject_META=AM.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({uuid:LM(e.uuid)?globalThis.String(e.uuid):"",semanticLabel_META:LM(e.semanticLabel_META)?xM(e.semanticLabel_META):void 0,locatable_META:LM(e.locatable_META)?pM.fromJSON(e.locatable_META):void 0,boundary2D_META:LM(e.boundary2D_META)?MM.fromJSON(e.boundary2D_META):void 0,bounded2D_META:LM(e.bounded2D_META)?hM.fromJSON(e.bounded2D_META):void 0,bounded3D_META:LM(e.bounded3D_META)?fM.fromJSON(e.bounded3D_META):void 0,roomLayout_META:LM(e.roomLayout_META)?bM.fromJSON(e.roomLayout_META):void 0,spaceContainer_META:LM(e.spaceContainer_META)?wM.fromJSON(e.spaceContainer_META):void 0,triangleMesh_META:LM(e.triangleMesh_META)?TM.fromJSON(e.triangleMesh_META):void 0,dynamicObject_META:LM(e.dynamicObject_META)?AM.fromJSON(e.dynamicObject_META):void 0}),toJSON(e){const t={};return""!==e.uuid&&(t.uuid=e.uuid),void 0!==e.semanticLabel_META&&(t.semanticLabel_META=_M(e.semanticLabel_META)),void 0!==e.locatable_META&&(t.locatable_META=pM.toJSON(e.locatable_META)),void 0!==e.boundary2D_META&&(t.boundary2D_META=MM.toJSON(e.boundary2D_META)),void 0!==e.bounded2D_META&&(t.bounded2D_META=hM.toJSON(e.bounded2D_META)),void 0!==e.bounded3D_META&&(t.bounded3D_META=fM.toJSON(e.bounded3D_META)),void 0!==e.roomLayout_META&&(t.roomLayout_META=bM.toJSON(e.roomLayout_META)),void 0!==e.spaceContainer_META&&(t.spaceContainer_META=wM.toJSON(e.spaceContainer_META)),void 0!==e.triangleMesh_META&&(t.triangleMesh_META=TM.toJSON(e.triangleMesh_META)),void 0!==e.dynamicObject_META&&(t.dynamicObject_META=AM.toJSON(e.dynamicObject_META)),t},create:e=>RM.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i={uuid:"",semanticLabel_META:void 0,locatable_META:void 0,boundary2D_META:void 0,bounded2D_META:void 0,bounded3D_META:void 0,roomLayout_META:void 0,spaceContainer_META:void 0,triangleMesh_META:void 0,dynamicObject_META:void 0};return i.uuid=null!==(t=e.uuid)&&void 0!==t?t:"",i.semanticLabel_META=null!==(n=e.semanticLabel_META)&&void 0!==n?n:void 0,i.locatable_META=void 0!==e.locatable_META&&null!==e.locatable_META?pM.fromPartial(e.locatable_META):void 0,i.boundary2D_META=void 0!==e.boundary2D_META&&null!==e.boundary2D_META?MM.fromPartial(e.boundary2D_META):void 0,i.bounded2D_META=void 0!==e.bounded2D_META&&null!==e.bounded2D_META?hM.fromPartial(e.bounded2D_META):void 0,i.bounded3D_META=void 0!==e.bounded3D_META&&null!==e.bounded3D_META?fM.fromPartial(e.bounded3D_META):void 0,i.roomLayout_META=void 0!==e.roomLayout_META&&null!==e.roomLayout_META?bM.fromPartial(e.roomLayout_META):void 0,i.spaceContainer_META=void 0!==e.spaceContainer_META&&null!==e.spaceContainer_META?wM.fromPartial(e.spaceContainer_META):void 0,i.triangleMesh_META=void 0!==e.triangleMesh_META&&null!==e.triangleMesh_META?TM.fromPartial(e.triangleMesh_META):void 0,i.dynamicObject_META=void 0!==e.dynamicObject_META&&null!==e.dynamicObject_META?AM.fromPartial(e.dynamicObject_META):void 0,i}};function CM(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{const t=globalThis.atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}}function PM(e){if(globalThis.Buffer)return globalThis.Buffer.from(e).toString("base64");{const t=[];return e.forEach(e=>{t.push(globalThis.String.fromCharCode(e))}),globalThis.btoa(t.join(""))}}function LM(e){return null!=e}var IM,DM;!function(e){e.Locatable="locatable",e.Bounded3D="bounded3D",e.Bounded2D="bounded2D",e.TriangleMesh="triangleMesh",e.SemanticLabel="semanticLabel"}(IM||(IM={}));class NM extends EventTarget{constructor(e){super(),this._spatialEntity=e}}class OM extends NM{constructor(e,t){super(e),this._offset=new $c,this._extent=new $c,this.type=IM.Bounded2D;const{offset:n,extent:i}=t;this._offset.set(n.x,n.y),this._extent.set(i.width,i.height),this.buildGeometry()}buildGeometry(){var e;const t=new df(this._extent.x,this._extent.y);t.translate(this._offset.x+this._extent.x/2,this._offset.y+this._extent.y/2,0),t.rotateX(Math.PI/2),null===(e=this._spatialEntity.geometry)||void 0===e||e.dispose(),this._spatialEntity.geometry=t}get offset(){return this._offset}get extent(){return this._extent}get initData(){return{offset:this.offset,extent:this.extent}}get pbData(){return{offset:{x:this._offset.x,y:this._offset.y},extent:{width:this._extent.x,height:this._extent.y}}}}class kM extends NM{constructor(e,t){super(e),this._offset=new Kc,this._extent=new Kc,this.type=IM.Bounded3D;const{offset:n,extent:i}=t;this._offset.set(n.x,n.y,n.z),this._extent.set(i.width,i.height,i.depth),this.buildGeometry()}buildGeometry(){var e;const t=new yh(this._extent.x,this._extent.y,this._extent.z);t.translate(this._offset.x+this._extent.x/2,this._offset.y+this._extent.y/2,this._offset.z+this._extent.z/2),null===(e=this._spatialEntity.geometry)||void 0===e||e.dispose(),this._spatialEntity.geometry=t}get offset(){return this._offset}get extent(){return this._extent}get initData(){return{offset:this.offset,extent:this.extent}}get pbData(){return{offset:{x:this._offset.x,y:this._offset.y,z:this._offset.z},extent:{width:this._extent.x,height:this._extent.y,depth:this._extent.z}}}}class UM extends NM{constructor(e,t){super(e),this.type=IM.Locatable,t.position&&this.position.copy(t.position),t.orientation&&this.orientation.copy(t.orientation)}get position(){return this._spatialEntity.position}get rotation(){return this._spatialEntity.rotation}get orientation(){return this._spatialEntity.quaternion}get initData(){return{position:{x:this.position.x,y:this.position.y,z:this.position.z},orientation:{x:this.orientation.x,y:this.orientation.y,z:this.orientation.z,w:this.orientation.w}}}get pbData(){return{position:{x:this._spatialEntity.position.x,y:this._spatialEntity.position.y,z:this._spatialEntity.position.z},orientation:{x:this._spatialEntity.quaternion.x,y:this._spatialEntity.quaternion.y,z:this._spatialEntity.quaternion.z,w:this._spatialEntity.quaternion.w}}}}function FM(e){return e.toLowerCase().replace(/_/g," ").trim()}class zM extends NM{constructor(e,t){super(e),this._semanticLabel=t,this.type=IM.SemanticLabel,this._spatialEntity.name=FM(_M(t))}get semanticLabel(){return this._semanticLabel}set semanticLabel(e){Object.values(vM).includes(e)?this._semanticLabel=e:this._semanticLabel=vM.UNRECOGNIZED,this._spatialEntity.name=FM(_M(this._semanticLabel))}get initData(){return this._semanticLabel}get pbData(){return this._semanticLabel}}function BM(e){const t=new Float32Array(3*e.length);let n=0;for(const i of e)t[n++]=i.x,t[n++]=i.y,t[n++]=i.z;return t}class VM extends NM{constructor(e,t){super(e),this._polygonCount=0,this._vertexCount=0,this._dimensions={x:0,y:0,z:0},this.type=IM.TriangleMesh;const{vertices:n,indices:i}=t,r=new Float32Array(n.buffer),a=new Uint32Array(i.buffer),s=[];for(let e=0;e<r.length/3;e++)s.push({x:r[3*e],y:r[3*e+1],z:r[3*e+2]});this._vertices=s,this._indices=[...a],this.buildGeometry();const o=e.material;o.polygonOffset=!0,o.polygonOffsetFactor=1,o.polygonOffsetUnits=.005,o.color.setHex(13948116),e.renderOrder=999}buildGeometry(){var e;const t=new rh,n=BM(this._vertices);t.setAttribute("position",new qd(n,3)),t.setIndex(new qd(new Uint16Array(this._indices),1)),null===(e=this._spatialEntity.geometry)||void 0===e||e.dispose(),this._spatialEntity.geometry=t,t.computeVertexNormals(),this._vertexCount=t.attributes.position.count,this._polygonCount=t.index?t.index.count/3:this._vertexCount/3,t.computeBoundingBox();const i=t.boundingBox;this._dimensions={x:i.max.x-i.min.x,y:i.max.y-i.min.y,z:i.max.z-i.min.z}}get vertexCount(){return this._vertexCount}get polygonCount(){return this._polygonCount}get dimensions(){return this._dimensions}get initData(){return{vertices:this._vertices,indices:this._indices}}get pbData(){const e=BM(this._vertices),t=new Uint32Array(this._indices);return{vertices:new Uint8Array(e.buffer),indices:new Uint8Array(t.buffer)}}}!function(e){e.Plane="plane",e.Box="box",e.Mesh="mesh"}(DM||(DM={}));const HM={[vM.OTHER]:bb.Other,[vM.TABLE]:bb.Table,[vM.COUCH]:bb.Couch,[vM.FLOOR]:bb.Floor,[vM.CEILING]:bb.Ceiling,[vM.WALL_FACE]:bb.Wall,[vM.INVISIBLE_WALL_FACE]:bb.Window,[vM.INNER_WALL_FACE]:bb.Wall,[vM.DOOR_FRAME]:bb.Door,[vM.WINDOW_FRAME]:bb.Window,[vM.WALL_ART]:bb.WallArt,[vM.STORAGE]:bb.Shelf,[vM.BED]:bb.Bed,[vM.LAMP]:bb.Lamp,[vM.SCREEN]:bb.Screen,[vM.PLANT]:bb.Plant,[vM.GLOBAL_MESH]:bb.GlobalMesh,[vM.CHAIR]:bb.Couch,[vM.UNKNOWN]:bb.Other,[vM.OTHER_ROOM_FACE]:bb.Other,[vM.OPENING]:bb.Other,[vM.UNRECOGNIZED]:bb.Other};class GM extends gh{constructor(e=function(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(vg[255&e]+vg[e>>8&255]+vg[e>>16&255]+vg[e>>24&255]+"-"+vg[255&t]+vg[t>>8&255]+"-"+vg[t>>16&15|64]+vg[t>>24&255]+"-"+vg[63&n|128]+vg[n>>8&255]+"-"+vg[n>>16&255]+vg[n>>24&255]+vg[255&i]+vg[i>>8&255]+vg[i>>16&255]+vg[i>>24&255]).toLowerCase()}()){super(void 0,new vf({color:16777215*Math.random(),flatShading:!0})),this.name="generic spatial entity",this.isSpatialEntity=!0,this._componentMap=new Map,this._spatialUUID=e}get spatialUUID(){return this._spatialUUID}updateMatrixWorld(e){super.updateMatrixWorld(e)}addComponent(e,t){let n=null;switch(e){case IM.Locatable:n=new UM(this,t);break;case IM.Bounded3D:n=new kM(this,t);break;case IM.Bounded2D:n=new OM(this,t);break;case IM.TriangleMesh:n=new VM(this,t);break;case IM.SemanticLabel:n=new zM(this,t)}n&&this._componentMap.set(e,n)}getComponent(e){return this._componentMap.get(e)}duplicate(){const e=new GM;return this._componentMap.forEach((t,n,i)=>{e.addComponent(t.type,t.initData)}),e}get nativeEntity(){if(!this._nativeEntity){const e=new Lb({x:this.position.x,y:this.position.y,z:this.position.z,w:1},{x:this.quaternion.x,y:this.quaternion.y,z:this.quaternion.z,w:this.quaternion.w}),t=HM[this.getComponent(IM.SemanticLabel).semanticLabel];if(this.entityType===DM.Plane){const{offset:n,extent:i}=this.getComponent(IM.Bounded2D),r=[new DOMPointReadOnly(n.x,0,n.y),new DOMPointReadOnly(n.x+i.x,0,n.y),new DOMPointReadOnly(n.x+i.x,0,n.y+i.y),new DOMPointReadOnly(n.x,0,n.y+i.y),new DOMPointReadOnly(n.x,0,n.y)];this._nativeEntity=new Tb(e,r,t)}else if(this.entityType===DM.Box||this.entityType===DM.Mesh){const n=this.geometry.getAttribute("position").array,i=new Uint32Array(this.geometry.index.array);this._nativeEntity=new _b(e,n,i,t)}}return this._nativeEntity}static fromPBJSON(e){const t=RM.fromJSON(e);if(t.locatable_META){const e=new GM(t.uuid);return e.addComponent(IM.Locatable,t.locatable_META),t.semanticLabel_META&&e.addComponent(IM.SemanticLabel,t.semanticLabel_META),t.bounded2D_META?e.addComponent(IM.Bounded2D,t.bounded2D_META):t.bounded3D_META?e.addComponent(IM.Bounded3D,t.bounded3D_META):t.triangleMesh_META&&e.addComponent(IM.TriangleMesh,t.triangleMesh_META),e}}get entityType(){return this.getComponent(IM.Bounded2D)?DM.Plane:this.getComponent(IM.Bounded3D)?DM.Box:this.getComponent(IM.TriangleMesh)?DM.Mesh:void 0}static toPBJSON(e){var t,n,i,r,a;return{uuid:e.spatialUUID,locatable_META:null===(t=e.getComponent(IM.Locatable))||void 0===t?void 0:t.pbData,boundary2D_META:void 0,bounded2D_META:null===(n=e.getComponent(IM.Bounded2D))||void 0===n?void 0:n.pbData,bounded3D_META:null===(i=e.getComponent(IM.Bounded3D))||void 0===i?void 0:i.pbData,semanticLabel_META:null===(r=e.getComponent(IM.SemanticLabel))||void 0===r?void 0:r.pbData,roomLayout_META:void 0,spaceContainer_META:void 0,triangleMesh_META:null===(a=e.getComponent(IM.TriangleMesh))||void 0===a?void 0:a.pbData,dynamicObject_META:void 0}}}const jM="0.2.4",WM=new Kc(0,0,-1);class XM extends EventTarget{constructor(e){super(),this.xrDevice=e,this.trackedPlanes=new Set,this.trackedMeshes=new Set,this.version=jM,this.objectMap=new Map,this.planes=new Dh,this.boxes=new Dh,this.meshes=new Dh,this.tempPosition=new Kc,this.tempQuaternion=new Yc,this.tempDirection=new Kc,this.tempScale=new Kc,this.tempMatrix=new qu,this.raycaster=new bf,this.hitTestTarget=new Dh,this.hitTestMarker=new _d,this.worldNormal=new Kc,this.normalMatrix=new Jc,this.scene=new kh,this.scene.background=new zd(4079166),this.camera=new Rh(50,window.innerWidth/window.innerHeight,.1,40),this.camera.position.set(0,1.6,5);const t=new Lf(50,50);this.scene.add(t),this.scene.add(this.planes,this.boxes,this.meshes),this.planes.renderOrder=1,this.boxes.renderOrder=2,this.meshes.renderOrder=3,this.planes.visible=!1,this.boxes.visible=!1,this.renderer=new gg({antialias:!0,alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(window.innerWidth,window.innerHeight),this.renderer.domElement.style.position="fixed",this.renderer.domElement.style.top="50vh",this.renderer.domElement.style.left="50vw",this.renderer.domElement.style.transform="translate(-50%, -50%)",this.hitTestTarget.add(this.hitTestMarker),this.hitTestMarker.rotateX(Math.PI/2)}get environmentCanvas(){return this.renderer.domElement}get planesVisible(){return this.planes.visible}set planesVisible(e){this.planes.visible=e}get boundingBoxesVisible(){return this.boxes.visible}set boundingBoxesVisible(e){this.boxes.visible=e}get meshesVisible(){return this.meshes.visible}set meshesVisible(e){this.meshes.visible=e}render(){this.camera.position.copy(this.xrDevice.position),this.camera.quaternion.copy(this.xrDevice.quaternion);const e=this.xrDevice.fovy/Math.PI*180;let t=!1;this.camera.fov!==e&&(this.camera.fov=e,t=!0);const n=this.xrDevice.canvasDimensions;if(n){const e=this.renderer.domElement;(e.width!==n.width||e.height!==n.height)&&(this.camera.aspect=n.width/n.height,this.renderer.setSize(n.width,n.height),t=!0)}t&&this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera)}deleteAll(){[...this.objectMap.values()].forEach(e=>{e.removeFromParent()}),this.objectMap.clear(),this.trackedMeshes.clear(),this.trackedPlanes.clear()}loadEnvironment(e){this.deleteAll(),e.spatialEntities.forEach(e=>{const t=GM.fromPBJSON(e);if(t){switch(t.entityType){case DM.Box:this.boxes.add(t),this.trackedMeshes.add(t.nativeEntity);break;case DM.Plane:this.planes.add(t),this.trackedPlanes.add(t.nativeEntity);break;case DM.Mesh:this.meshes.add(t),this.trackedMeshes.add(t.nativeEntity)}const n=this.objectMap.get(e.uuid);n&&n.removeFromParent(),this.objectMap.set(e.uuid,t)}})}loadDefaultEnvironment(e){fetch(`https://www.unpkg.com/@iwer/sem@${jM}/captures/${e}.json`).then(e=>{if(!e.ok)throw new Error(`Network response was not ok: ${e.statusText}`);return e.json()}).then(e=>{this.loadEnvironment(e)}).catch(t=>{console.error(`Error loading environment ${e} from CDN`,t)})}computeHitTestResults(e){this.tempMatrix.fromArray(e),this.tempMatrix.decompose(this.tempPosition,this.tempQuaternion,this.tempScale),this.tempDirection.copy(WM).applyQuaternion(this.tempQuaternion).normalize(),this.raycaster.set(this.tempPosition,this.tempDirection);const t=this.raycaster.intersectObject(this.meshes,!0).map(e=>{var t;const n=e.point;if(this.hitTestTarget.position.copy(n),null===(t=e.face)||void 0===t?void 0:t.normal){this.worldNormal.copy(e.face.normal);const t=e.object;this.worldNormal.applyMatrix3(this.normalMatrix.getNormalMatrix(t.matrixWorld)).normalize(),this.hitTestTarget.lookAt(this.tempPosition.addVectors(n,this.worldNormal))}else this.hitTestTarget.quaternion.set(0,0,0,1);return this.hitTestTarget.updateMatrixWorld(!0),this.hitTestMarker.matrixWorld.toArray()});return t}}class qM{constructor(e,t={}){this.ws=null,this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectDelay=1e3,this.reconnectTimer=null,this.intentionalDisconnect=!1,this.device=e,this.verbose=t.verbose??!1;let n="undefined"!=typeof sessionStorage?sessionStorage.getItem("iwer-mcp-tab-id"):null;n||(n=`tab-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iwer-mcp-tab-id",n)),this.tabId=n;const i="undefined"!=typeof sessionStorage?parseInt(sessionStorage.getItem("iwer-mcp-gen")||"0",10)+1:1;"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iwer-mcp-gen",String(i)),this.tabGeneration=i}isTraceEnabled(){return this.verbose||"undefined"!=typeof window&&!0===window.__IWSDK_MCP_TRACE}trace(e,t={}){this.isTraceEnabled()&&console.log(`[IWSDK-MCP-TRACE] ${e} ${JSON.stringify({...t,tabId:this.tabId,tabGeneration:this.tabGeneration})}`)}connect(e){if(null!==this.ws)return;this.intentionalDisconnect=!1;const t=e??this.getVitePort(),n=`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.hostname||"localhost"}:${t}/__iwer_mcp`;this.verbose&&console.log("[IWSDK-MCP] Connecting to:",n),this.trace("client_connect_start",{wsUrl:n,reconnectAttempts:this.reconnectAttempts});try{this.ws=new WebSocket(n),this.setupEventHandlers()}catch(e){console.error("[IWSDK-MCP] Failed to create WebSocket:",e),this.ws=null,this.scheduleReconnect()}}disconnect(){this.intentionalDisconnect=!0,null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}getVitePort(){return parseInt(window.location.port,10)||5173}setupEventHandlers(){this.ws&&(this.ws.onopen=()=>{this.verbose&&console.log("[IWSDK-MCP] Connected"),this.trace("client_open"),this.reconnectAttempts=0,this.ws?.send(JSON.stringify({type:"iwsdk_browser_hello",tabId:this.tabId,tabGeneration:this.tabGeneration})),this.trace("client_hello_sent")},this.ws.onclose=e=>{this.verbose&&console.log("[IWSDK-MCP] Disconnected:",e.reason||"Connection closed"),this.trace("client_close",{code:e.code,reason:e.reason||"Connection closed",intentional:this.intentionalDisconnect}),this.ws=null,this.intentionalDisconnect||this.scheduleReconnect()},this.ws.onerror=e=>{this.trace("client_error",{message:e instanceof ErrorEvent&&e.message?e.message:"WebSocket error"}),console.error("[IWSDK-MCP] WebSocket error:",e)},this.ws.onmessage=async e=>{await this.handleMessage(e.data)})}async handleMessage(e){let t;try{t=JSON.parse(e)}catch{return void console.error("[IWSDK-MCP] Invalid JSON received:",e)}if("string"!=typeof t.id||"string"!=typeof t.method)return void console.error("[IWSDK-MCP] Malformed request (missing id or method):",t);this.verbose&&console.debug("[IWSDK-MCP] Received:",t.method,t.params),this.trace("client_request_received",{id:t.id,method:t.method});const n={id:t.id};try{n.result=await this.dispatch(t.method,t.params??{})}catch(e){n.error={code:-32e3,message:e instanceof Error?e.message:String(e)}}this.verbose&&(n.error?console.debug("[IWSDK-MCP] Error:",n.error.message):console.debug("[IWSDK-MCP] Result:",n.result)),this.send(n)}async dispatch(e,t){return"reload_page"===e?(setTimeout(()=>window.location.reload(),50),{success:!0,message:"Page reload initiated"}):window.FRAMEWORK_MCP_RUNTIME?.handles(e)?window.FRAMEWORK_MCP_RUNTIME.dispatch(e,t):this.device.remote.dispatch(e,t)}send(e){if(this.ws&&this.ws.readyState===WebSocket.OPEN){const t={...e,_tabId:this.tabId,_tabGeneration:this.tabGeneration};this.trace("client_response_sent",{id:e.id,hasError:Boolean(e.error)}),this.ws.send(JSON.stringify(t))}}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)return void(this.verbose&&console.debug("[IWSDK-MCP] Max reconnect attempts reached"));this.reconnectAttempts++;const e=this.reconnectDelay*this.reconnectAttempts;this.verbose&&console.debug(`[IWSDK-MCP] Reconnecting in ${e}ms (attempt ${this.reconnectAttempts})`),this.trace("client_reconnect_scheduled",{delay:e,attempt:this.reconnectAttempts}),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}}const $M={metaQuest2:OS,metaQuest3:US,metaQuestPro:kS,oculusQuest1:NS};!function(e){if(console.log("[IWSDK Dev] Configuration:",e),function(e,t){if(t){const e=navigator.userAgent||"";if(t instanceof RegExp){if(t.test(e))return!1}else if("string"==typeof t&&t.startsWith("/")&&t.endsWith("/")){const n=t.slice(1,-1);try{if(new RegExp(n).test(e))return!1}catch{}}}if("always"===e)return!0;if("localhost"===e)return"localhost"===location.hostname||"127.0.0.1"===location.hostname;if(e instanceof RegExp)return e.test(location.hostname);if("string"==typeof e&&e.startsWith("/")&&e.endsWith("/")){const t=e.slice(1,-1);return new RegExp(t).test(location.hostname)}return!1}(e.activation,e.userAgentException)){e.verbose&&console.log("[IWSDK Dev] 🎯 Activating IWER runtime...");try{const t=$M[e.device];if(!t){const t=Object.keys($M).join(", ");console.error(`[IWSDK Dev] ❌ Invalid device configuration: "${e.device}"\nAvailable devices: ${t}\nFalling back to default device: metaQuest3`)}const n=new RS(t||US);e.verbose&&console.log("[IWSDK Dev] 📱 Using device configuration:",t?e.device:"metaQuest3 (fallback)"),n.installRuntime();const i=window.__IWER_MCP_MANAGED;if(e.ai&&i&&!e.ai.devUI||n.installDevUI(Bx),e.sem&&(e.verbose&&console.log("[IWSDK Dev] 🌐 Installing SEM with scene:",e.sem.defaultScene),n.installSEM(XM),e.verbose&&console.log("[IWSDK Dev] 📍 Loading default environment from CDN:",e.sem.defaultScene),n.sem?.loadDefaultEnvironment(e.sem.defaultScene)),e.ai&&window.__IWER_MCP_MANAGED){e.verbose&&console.log("[IWSDK Dev] 🔌 Initializing MCP client...");const t=function(e,t={}){const n=new qM(e,{verbose:t.verbose});return n.connect(t.port),n}(n,{verbose:e.verbose});window.IWER_MCP=t,e.verbose&&console.log("[IWSDK Dev] ✅ MCP client initialized")}e.verbose&&console.log("[IWSDK Dev] ✅ Runtime activated successfully!"),window.IWER_DEVICE=n}catch(e){console.error("[IWSDK Dev] ❌ Failed to activate runtime:",e)}}else e.verbose&&console.log("[IWSDK Dev] Skipping activation - not on localhost")}("__IWSDK_DEV_CONFIG__")}();
|