@inweb/viewer-three 26.7.1 → 26.7.6
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/viewer-three.js +21 -18
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +1 -1
- package/dist/viewer-three.module.js +5 -2
- package/dist/viewer-three.module.js.map +1 -1
- package/package.json +5 -5
- package/src/Viewer/Viewer.ts +6 -1
- package/src/Viewer/components/CameraComponent.ts +0 -1
package/dist/viewer-three.min.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* Copyright 2010-2025 Three.js Authors
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
6
|
*/
|
|
7
|
-
function Uc(){let t=null,e=!1,i=null,n=null;function r(e,s){i(e,s),n=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function Fc(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(i){i.isInterleavedBufferAttribute&&(i=i.data);const n=e.get(i);n&&(t.deleteBuffer(n.buffer),e.delete(i))},update:function(i,n){if(i.isInterleavedBufferAttribute&&(i=i.data),i.isGLBufferAttribute){const t=e.get(i);return void((!t||t.version<i.version)&&e.set(i,{buffer:i.buffer,type:i.type,bytesPerElement:i.elementSize,version:i.version}))}const r=e.get(i);if(void 0===r)e.set(i,function(e,i){const n=e.array,r=e.usage,s=n.byteLength,a=t.createBuffer();let o;if(t.bindBuffer(i,a),t.bufferData(i,n,r),e.onUploadCallback(),n instanceof Float32Array)o=t.FLOAT;else if(n instanceof Uint16Array)o=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(n instanceof Int16Array)o=t.SHORT;else if(n instanceof Uint32Array)o=t.UNSIGNED_INT;else if(n instanceof Int32Array)o=t.INT;else if(n instanceof Int8Array)o=t.BYTE;else if(n instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(n instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+n);o=t.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version,size:s}}(i,n));else if(r.version<i.version){if(r.size!==i.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(e,i,n){const r=i.array,s=i.updateRanges;if(t.bindBuffer(n,e),0===s.length)t.bufferSubData(n,0,r);else{s.sort(((t,e)=>t.start-e.start));let e=0;for(let t=1;t<s.length;t++){const i=s[e],n=s[t];n.start<=i.start+i.count+1?i.count=Math.max(i.count,n.start+n.count-i.start):(++e,s[e]=n)}s.length=e+1;for(let e=0,i=s.length;e<i;e++){const i=s[e];t.bufferSubData(n,i.start*r.BYTES_PER_ELEMENT,r,i.start,i.count)}i.clearUpdateRanges()}i.onUploadCallback()}(r.buffer,i,n),r.version=i.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:_}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=_);const kc={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}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\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\t\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, roughness * 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:"struct 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 * transposeMat3( 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\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\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}\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( 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_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\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\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\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\tfloat hard_shadow = step( compare , distribution.x );\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\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\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}"},Bc={common:{diffuse:{value:new Jn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ti},alphaMap:{value:null},alphaMapTransform:{value:new ti},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ti}},envmap:{envMap:{value:null},envMapRotation:{value:new ti},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ti}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ti}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ti},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ti},normalScale:{value:new $e(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ti},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ti}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ti}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ti}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Jn(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 Jn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ti},alphaTest:{value:0},uvTransform:{value:new ti}},sprite:{diffuse:{value:new Jn(16777215)},opacity:{value:1},center:{value:new $e(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ti},alphaMap:{value:null},alphaMapTransform:{value:new ti},alphaTest:{value:0}}},zc={basic:{uniforms:Fr([Bc.common,Bc.specularmap,Bc.envmap,Bc.aomap,Bc.lightmap,Bc.fog]),vertexShader:kc.meshbasic_vert,fragmentShader:kc.meshbasic_frag},lambert:{uniforms:Fr([Bc.common,Bc.specularmap,Bc.envmap,Bc.aomap,Bc.lightmap,Bc.emissivemap,Bc.bumpmap,Bc.normalmap,Bc.displacementmap,Bc.fog,Bc.lights,{emissive:{value:new Jn(0)}}]),vertexShader:kc.meshlambert_vert,fragmentShader:kc.meshlambert_frag},phong:{uniforms:Fr([Bc.common,Bc.specularmap,Bc.envmap,Bc.aomap,Bc.lightmap,Bc.emissivemap,Bc.bumpmap,Bc.normalmap,Bc.displacementmap,Bc.fog,Bc.lights,{emissive:{value:new Jn(0)},specular:{value:new Jn(1118481)},shininess:{value:30}}]),vertexShader:kc.meshphong_vert,fragmentShader:kc.meshphong_frag},standard:{uniforms:Fr([Bc.common,Bc.envmap,Bc.aomap,Bc.lightmap,Bc.emissivemap,Bc.bumpmap,Bc.normalmap,Bc.displacementmap,Bc.roughnessmap,Bc.metalnessmap,Bc.fog,Bc.lights,{emissive:{value:new Jn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:kc.meshphysical_vert,fragmentShader:kc.meshphysical_frag},toon:{uniforms:Fr([Bc.common,Bc.aomap,Bc.lightmap,Bc.emissivemap,Bc.bumpmap,Bc.normalmap,Bc.displacementmap,Bc.gradientmap,Bc.fog,Bc.lights,{emissive:{value:new Jn(0)}}]),vertexShader:kc.meshtoon_vert,fragmentShader:kc.meshtoon_frag},matcap:{uniforms:Fr([Bc.common,Bc.bumpmap,Bc.normalmap,Bc.displacementmap,Bc.fog,{matcap:{value:null}}]),vertexShader:kc.meshmatcap_vert,fragmentShader:kc.meshmatcap_frag},points:{uniforms:Fr([Bc.points,Bc.fog]),vertexShader:kc.points_vert,fragmentShader:kc.points_frag},dashed:{uniforms:Fr([Bc.common,Bc.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:kc.linedashed_vert,fragmentShader:kc.linedashed_frag},depth:{uniforms:Fr([Bc.common,Bc.displacementmap]),vertexShader:kc.depth_vert,fragmentShader:kc.depth_frag},normal:{uniforms:Fr([Bc.common,Bc.bumpmap,Bc.normalmap,Bc.displacementmap,{opacity:{value:1}}]),vertexShader:kc.meshnormal_vert,fragmentShader:kc.meshnormal_frag},sprite:{uniforms:Fr([Bc.sprite,Bc.fog]),vertexShader:kc.sprite_vert,fragmentShader:kc.sprite_frag},background:{uniforms:{uvTransform:{value:new ti},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:kc.background_vert,fragmentShader:kc.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ti}},vertexShader:kc.backgroundCube_vert,fragmentShader:kc.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:kc.cube_vert,fragmentShader:kc.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:kc.equirect_vert,fragmentShader:kc.equirect_frag},distanceRGBA:{uniforms:Fr([Bc.common,Bc.displacementmap,{referencePosition:{value:new Ci},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:kc.distanceRGBA_vert,fragmentShader:kc.distanceRGBA_frag},shadow:{uniforms:Fr([Bc.lights,Bc.fog,{color:{value:new Jn(0)},opacity:{value:1}}]),vertexShader:kc.shadow_vert,fragmentShader:kc.shadow_frag}};zc.physical={uniforms:Fr([zc.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ti},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ti},clearcoatNormalScale:{value:new $e(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ti},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ti},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ti},sheen:{value:0},sheenColor:{value:new Jn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ti},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ti},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ti},transmissionSamplerSize:{value:new $e},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ti},attenuationDistance:{value:0},attenuationColor:{value:new Jn(0)},specularColor:{value:new Jn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ti},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ti},anisotropyVector:{value:new $e},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ti}}]),vertexShader:kc.meshphysical_vert,fragmentShader:kc.meshphysical_frag};const Gc={r:0,b:0,g:0},Hc=new fn,Vc=new sn;function Wc(t,e,i,n,r,s,a){const o=new Jn(0);let h,l,c=!0===s?0:1,d=null,u=0,p=null;function m(t){let n=!0===t.isScene?t.background:null;if(n&&n.isTexture){n=(t.backgroundBlurriness>0?i:e).get(n)}return n}function f(e,i){e.getRGB(Gc,kr(t)),n.buffers.color.setClear(Gc.r,Gc.g,Gc.b,i,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),c=e,f(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(t){c=t,f(o,c)},render:function(e){let i=!1;const r=m(e);null===r?f(o,c):r&&r.isColor&&(f(r,1),i=!0);const s=t.xr.getEnvironmentBlendMode();"additive"===s?n.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===s&&n.buffers.color.setClear(0,0,0,0,a),(t.autoClear||i)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,i){const n=m(i);n&&(n.isCubeTexture||n.mapping===nt)?(void 0===l&&(l=new Dr(new Nr(1,1,1),new zr({name:"BackgroundCubeMaterial",uniforms:Ur(zc.backgroundCube.uniforms),vertexShader:zc.backgroundCube.vertexShader,fragmentShader:zc.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),Hc.copy(i.backgroundRotation),Hc.x*=-1,Hc.y*=-1,Hc.z*=-1,n.isCubeTexture&&!1===n.isRenderTargetTexture&&(Hc.y*=-1,Hc.z*=-1),l.material.uniforms.envMap.value=n,l.material.uniforms.flipEnvMap.value=n.isCubeTexture&&!1===n.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=i.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Vc.makeRotationFromEuler(Hc)),l.material.toneMapped=ui.getTransfer(n.colorSpace)!==Ae,d===n&&u===n.version&&p===t.toneMapping||(l.material.needsUpdate=!0,d=n,u=n.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null)):n&&n.isTexture&&(void 0===h&&(h=new Dr(new rh(2,2),new zr({name:"BackgroundMaterial",uniforms:Ur(zc.background.uniforms),vertexShader:zc.background.vertexShader,fragmentShader:zc.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=n,h.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,h.material.toneMapped=ui.getTransfer(n.colorSpace)!==Ae,!0===n.matrixAutoUpdate&&n.updateMatrix(),h.material.uniforms.uvTransform.value.copy(n.matrix),d===n&&u===n.version&&p===t.toneMapping||(h.material.needsUpdate=!0,d=n,u=n.version,p=t.toneMapping),h.layers.enableAll(),e.unshift(h,h.geometry,h.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==h&&(h.geometry.dispose(),h.material.dispose(),h=void 0)}}}function jc(t,e){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),n={},r=l(null);let s=r,a=!1;function o(e){return t.bindVertexArray(e)}function h(e){return t.deleteVertexArray(e)}function l(t){const e=[],n=[],r=[];for(let t=0;t<i;t++)e[t]=0,n[t]=0,r[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:n,attributeDivisors:r,object:t,attributes:{},index:null}}function c(){const t=s.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function d(t){u(t,0)}function u(e,i){const n=s.newAttributes,r=s.enabledAttributes,a=s.attributeDivisors;n[e]=1,0===r[e]&&(t.enableVertexAttribArray(e),r[e]=1),a[e]!==i&&(t.vertexAttribDivisor(e,i),a[e]=i)}function p(){const e=s.newAttributes,i=s.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function m(e,i,n,r,s,a,o){!0===o?t.vertexAttribIPointer(e,i,n,s,a):t.vertexAttribPointer(e,i,n,r,s,a)}function f(){g(),a=!0,s!==r&&(s=r,o(s.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(i,r,h,f,g){let v=!1;const _=function(e,i,r){const s=!0===r.wireframe;let a=n[e.id];void 0===a&&(a={},n[e.id]=a);let o=a[i.id];void 0===o&&(o={},a[i.id]=o);let h=o[s];void 0===h&&(h=l(t.createVertexArray()),o[s]=h);return h}(f,h,r);s!==_&&(s=_,o(s.object)),v=function(t,e,i,n){const r=s.attributes,a=e.attributes;let o=0;const h=i.getAttributes();for(const e in h){if(h[e].location>=0){const i=r[e];let n=a[e];if(void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor)),void 0===i)return!0;if(i.attribute!==n)return!0;if(n&&i.data!==n.data)return!0;o++}}return s.attributesNum!==o||s.index!==n}(i,f,h,g),v&&function(t,e,i,n){const r={},a=e.attributes;let o=0;const h=i.getAttributes();for(const e in h){if(h[e].location>=0){let i=a[e];void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor));const n={};n.attribute=i,i&&i.data&&(n.data=i.data),r[e]=n,o++}}s.attributes=r,s.attributesNum=o,s.index=n}(i,f,h,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(v||a)&&(a=!1,function(i,n,r,s){c();const a=s.attributes,o=r.getAttributes(),h=n.defaultAttributeValues;for(const n in o){const r=o[n];if(r.location>=0){let o=a[n];if(void 0===o&&("instanceMatrix"===n&&i.instanceMatrix&&(o=i.instanceMatrix),"instanceColor"===n&&i.instanceColor&&(o=i.instanceColor)),void 0!==o){const n=o.normalized,a=o.itemSize,h=e.get(o);if(void 0===h)continue;const l=h.buffer,c=h.type,p=h.bytesPerElement,f=c===t.INT||c===t.UNSIGNED_INT||o.gpuType===vt;if(o.isInterleavedBufferAttribute){const e=o.data,h=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t<r.locationSize;t++)u(r.location+t,e.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,l);for(let t=0;t<r.locationSize;t++)m(r.location+t,a/r.locationSize,c,n,h*p,(g+a/r.locationSize*t)*p,f)}else{if(o.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)u(r.location+t,o.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,l);for(let t=0;t<r.locationSize;t++)m(r.location+t,a/r.locationSize,c,n,a*p,a/r.locationSize*t*p,f)}}else if(void 0!==h){const e=h[n];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(r.location,e);break;case 3:t.vertexAttrib3fv(r.location,e);break;case 4:t.vertexAttrib4fv(r.location,e);break;default:t.vertexAttrib1fv(r.location,e)}}}}p()}(i,r,h,f),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:f,resetDefaultState:g,dispose:function(){f();for(const t in n){const e=n[t];for(const t in e){const i=e[t];for(const t in i)h(i[t].object),delete i[t];delete e[t]}delete n[t]}},releaseStatesOfGeometry:function(t){if(void 0===n[t.id])return;const e=n[t.id];for(const t in e){const i=e[t];for(const t in i)h(i[t].object),delete i[t];delete e[t]}delete n[t.id]},releaseStatesOfProgram:function(t){for(const e in n){const i=n[e];if(void 0===i[t.id])continue;const r=i[t.id];for(const t in r)h(r[t].object),delete r[t];delete i[t.id]}},initAttributes:c,enableAttribute:d,disableUnusedAttributes:p}}function Xc(t,e,i){let n;function r(e,r,s){0!==s&&(t.drawArraysInstanced(n,e,r,s),i.update(r,n,s))}this.setMode=function(t){n=t},this.render=function(e,r){t.drawArrays(n,e,r),i.update(r,n,1)},this.renderInstances=r,this.renderMultiDraw=function(t,r,s){if(0===s)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,t,0,r,0,s);let a=0;for(let t=0;t<s;t++)a+=r[t];i.update(a,n,1)},this.renderMultiDrawInstances=function(t,s,a,o){if(0===a)return;const h=e.get("WEBGL_multi_draw");if(null===h)for(let e=0;e<t.length;e++)r(t[e],s[e],o[e]);else{h.multiDrawArraysInstancedWEBGL(n,t,0,s,0,o,0,a);let e=0;for(let t=0;t<a;t++)e+=s[t]*o[t];i.update(e,n,1)}}}function Yc(t,e,i,n){let r;function s(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==i.precision?i.precision:"highp";const o=s(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const h=!0===i.logarithmicDepthBuffer,l=!0===i.reverseDepthBuffer&&e.has("EXT_clip_control"),c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),d=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(e){return e===At||n.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(i){const r=i===xt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(i!==pt&&n.convert(i)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&i!==yt&&!r)},precision:a,logarithmicDepthBuffer:h,reverseDepthBuffer:l,maxTextures:c,maxVertexTextures:d,maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:d>0,maxSamples:t.getParameter(t.MAX_SAMPLES)}}function qc(t){const e=this;let i=null,n=0,r=!1,s=!1;const a=new Js,o=new ti,h={value:null,needsUpdate:!1};function l(t,i,n,r){const s=null!==t?t.length:0;let l=null;if(0!==s){if(l=h.value,!0!==r||null===l){const e=n+4*s,r=i.matrixWorldInverse;o.getNormalMatrix(r),(null===l||l.length<e)&&(l=new Float32Array(e));for(let e=0,i=n;e!==s;++e,i+=4)a.copy(t[e]).applyMatrix4(r,o),a.normal.toArray(l,i),l[i+3]=a.constant}h.value=l,h.needsUpdate=!0}return e.numPlanes=s,e.numIntersection=0,l}this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const i=0!==t.length||e||0!==n||r;return r=e,n=t.length,i},this.beginShadows=function(){s=!0,l(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(t,e){i=l(t,e,0)},this.setState=function(a,o,c){const d=a.clippingPlanes,u=a.clipIntersection,p=a.clipShadows,m=t.get(a);if(!r||null===d||0===d.length||s&&!p)s?l(null):function(){h.value!==i&&(h.value=i,h.needsUpdate=n>0);e.numPlanes=n,e.numIntersection=0}();else{const t=s?0:n,e=4*t;let r=m.clippingState||null;h.value=r,r=l(d,o,e,c);for(let t=0;t!==e;++t)r[t]=i[t];m.clippingState=r,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=t}}}function Kc(t){let e=new WeakMap;function i(t,e){return e===et?t.mapping=$:e===it&&(t.mapping=tt),t}function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(s===et||s===it){if(e.has(r)){return i(e.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=new Kr(s.height);return a.fromEquirectangularTexture(t,r),e.set(r,a),r.addEventListener("dispose",n),i(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}const Zc=[.125,.215,.35,.446,.526,.582],Jc=20,Qc=new fl,$c=new Jn;let td=null,ed=0,id=0,nd=!1;const rd=(1+Math.sqrt(5))/2,sd=1/rd,ad=[new Ci(-rd,sd,0),new Ci(rd,sd,0),new Ci(-sd,0,rd),new Ci(sd,0,rd),new Ci(0,rd,-sd),new Ci(0,rd,sd),new Ci(-1,1,-1),new Ci(1,1,-1),new Ci(-1,1,1),new Ci(1,1,1)];class od{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,i=.1,n=100){td=this._renderer.getRenderTarget(),ed=this._renderer.getActiveCubeFace(),id=this._renderer.getActiveMipmapLevel(),nd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,i,n,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=dd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=cd(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(td,ed,id),this._renderer.xr.enabled=nd,t.scissorTest=!1,ld(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===$||t.mapping===tt?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),td=this._renderer.getRenderTarget(),ed=this._renderer.getActiveCubeFace(),id=this._renderer.getActiveMipmapLevel(),nd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:ct,minFilter:ct,generateMipmaps:!1,type:xt,format:At,colorSpace:Te,depthBuffer:!1},n=hd(t,e,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=hd(t,e,i);const{_lodMax:n}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(t){const e=[],i=[],n=[];let r=t;const s=t-4+1+Zc.length;for(let a=0;a<s;a++){const s=Math.pow(2,r);i.push(s);let o=1/s;a>t-4?o=Zc[a-t+4-1]:0===a&&(o=0),n.push(o);const h=1/(s-2),l=-h,c=1+h,d=[l,l,c,l,c,c,l,l,c,c,l,c],u=6,p=6,m=3,f=2,g=1,v=new Float32Array(m*p*u),_=new Float32Array(f*p*u),y=new Float32Array(g*p*u);for(let t=0;t<u;t++){const e=t%3*2/3-1,i=t>2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];v.set(n,m*p*t),_.set(d,f*p*t);const r=[t,t,t,t,t,t];y.set(r,g*p*t)}const x=new br;x.setAttribute("position",new cr(v,m)),x.setAttribute("uv",new cr(_,f)),x.setAttribute("faceIndex",new cr(y,g)),e.push(x),r>4&&r--}return{lodPlanes:e,sizeLods:i,sigmas:n}}(n)),this._blurMaterial=function(t,e,i){const n=new Float32Array(Jc),r=new Ci(0,1,0),s=new zr({name:"SphericalGaussianBlur",defines:{n:Jc,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:ud(),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 s}(n,t,e)}return n}_compileMaterial(t){const e=new Dr(this._lodPlanes[0],t);this._renderer.compile(e,Qc)}_sceneToCubeUV(t,e,i,n){const r=new jr(90,1,e,i),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,h=o.autoClear,l=o.toneMapping;o.getClearColor($c),o.toneMapping=0,o.autoClear=!1;const c=new er({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),d=new Dr(new Nr,c);let u=!1;const p=t.background;p?p.isColor&&(c.color.copy(p),t.background=null,u=!0):(c.color.copy($c),u=!0);for(let e=0;e<6;e++){const i=e%3;0===i?(r.up.set(0,s[e],0),r.lookAt(a[e],0,0)):1===i?(r.up.set(0,0,s[e]),r.lookAt(0,a[e],0)):(r.up.set(0,s[e],0),r.lookAt(0,0,a[e]));const h=this._cubeSize;ld(n,i*h,e>2?h:0,h,h),o.setRenderTarget(n),u&&o.render(d,r),o.render(t,r)}d.geometry.dispose(),d.material.dispose(),o.toneMapping=l,o.autoClear=h,t.background=p}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===$||t.mapping===tt;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=dd()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=cd());const r=n?this._cubemapMaterial:this._equirectMaterial,s=new Dr(this._lodPlanes[0],r);r.uniforms.envMap.value=t;const a=this._cubeSize;ld(e,0,0,3*a,2*a),i.setRenderTarget(e),i.render(s,Qc)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;const n=this._lodPlanes.length;for(let e=1;e<n;e++){const i=Math.sqrt(this._sigmas[e]*this._sigmas[e]-this._sigmas[e-1]*this._sigmas[e-1]),r=ad[(n-e-1)%ad.length];this._blur(t,e-1,e,i,r)}e.autoClear=i}_blur(t,e,i,n,r){const s=this._pingPongRenderTarget;this._halfBlur(t,s,e,i,n,"latitudinal",r),this._halfBlur(s,t,i,i,n,"longitudinal",r)}_halfBlur(t,e,i,n,r,s,a){const o=this._renderer,h=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&console.error("blur direction must be either latitudinal or longitudinal!");const l=new Dr(this._lodPlanes[n],h),c=h.uniforms,d=this._sizeLods[i]-1,u=isFinite(r)?Math.PI/(2*d):2*Math.PI/39,p=r/u,m=isFinite(r)?1+Math.floor(3*p):Jc;m>Jc&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let t=0;t<Jc;++t){const e=t/p,i=Math.exp(-e*e/2);f.push(i),0===t?g+=i:t<m&&(g+=2*i)}for(let t=0;t<f.length;t++)f[t]=f[t]/g;c.envMap.value=t.texture,c.samples.value=m,c.weights.value=f,c.latitudinal.value="latitudinal"===s,a&&(c.poleAxis.value=a);const{_lodMax:v}=this;c.dTheta.value=u,c.mipInt.value=v-i;const _=this._sizeLods[n];ld(e,3*_*(n>v-4?n-v+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(e),o.render(l,Qc)}}function hd(t,e,i){const n=new Mi(t,e,i);return n.texture.mapping=nt,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ld(t,e,i,n,r){t.viewport.set(e,i,n,r),t.scissor.set(e,i,n,r)}function cd(){return new zr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ud(),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 dd(){return new zr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ud(),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 ud(){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 pd(t){let e=new WeakMap,i=null;function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===et||s===it,o=s===$||s===tt;if(a||o){let s=e.get(r);const h=void 0!==s?s.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==h)return null===i&&(i=new od(t)),s=a?i.fromEquirectangular(r,s):i.fromCubemap(r,s),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),s.texture;if(void 0!==s)return s.texture;{const h=r.image;return a&&h&&h.height>0||o&&h&&function(t){let e=0;const i=6;for(let n=0;n<i;n++)void 0!==t[n]&&e++;return e===i}(h)?(null===i&&(i=new od(t)),s=a?i.fromEquirectangular(r):i.fromCubemap(r),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),r.addEventListener("dispose",n),s.texture):null}}}return r},dispose:function(){e=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function md(t){const e={};function i(i){if(void 0!==e[i])return e[i];let n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=t.getExtension(i)}return e[i]=n,n}return{has:function(t){return null!==i(t)},init:function(){i("EXT_color_buffer_float"),i("WEBGL_clip_cull_distance"),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture"),i("WEBGL_render_shared_exponent")},get:function(t){const e=i(t);return null===e&&hi("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function fd(t,e,i,n){const r={},s=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);o.removeEventListener("dispose",a),delete r[o.id];const h=s.get(o);h&&(e.remove(h),s.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(t){const i=[],n=t.index,r=t.attributes.position;let a=0;if(null!==n){const t=n.array;a=n.version;for(let e=0,n=t.length;e<n;e+=3){const n=t[e+0],r=t[e+1],s=t[e+2];i.push(n,r,r,s,s,n)}}else{if(void 0===r)return;{const t=r.array;a=r.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,r=e+2;i.push(t,n,n,r,r,t)}}}const o=new(ii(i)?ur:dr)(i,1);o.version=a;const h=s.get(t);h&&e.remove(h),s.set(t,o)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",a),r[e.id]=!0,i.memory.geometries++),e},update:function(i){const n=i.attributes;for(const i in n)e.update(n[i],t.ARRAY_BUFFER)},getWireframeAttribute:function(t){const e=s.get(t);if(e){const i=t.index;null!==i&&e.version<i.version&&o(t)}else o(t);return s.get(t)}}}function gd(t,e,i){let n,r,s;function a(e,a,o){0!==o&&(t.drawElementsInstanced(n,a,r,e*s,o),i.update(a,n,o))}this.setMode=function(t){n=t},this.setIndex=function(t){r=t.type,s=t.bytesPerElement},this.render=function(e,a){t.drawElements(n,a,r,e*s),i.update(a,n,1)},this.renderInstances=a,this.renderMultiDraw=function(t,s,a){if(0===a)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,s,0,r,t,0,a);let o=0;for(let t=0;t<a;t++)o+=s[t];i.update(o,n,1)},this.renderMultiDrawInstances=function(t,o,h,l){if(0===h)return;const c=e.get("WEBGL_multi_draw");if(null===c)for(let e=0;e<t.length;e++)a(t[e]/s,o[e],l[e]);else{c.multiDrawElementsInstancedWEBGL(n,o,0,r,t,0,l,0,h);let e=0;for(let t=0;t<h;t++)e+=o[t]*l[t];i.update(e,n,1)}}}function vd(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(i,n,r){switch(e.calls++,n){case t.TRIANGLES:e.triangles+=r*(i/3);break;case t.LINES:e.lines+=r*(i/2);break;case t.LINE_STRIP:e.lines+=r*(i-1);break;case t.LINE_LOOP:e.lines+=r*i;break;case t.POINTS:e.points+=r*i;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function _d(t,e,i){const n=new WeakMap,r=new wi;return{update:function(s,a,o){const h=s.morphTargetInfluences,l=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,c=void 0!==l?l.length:0;let d=n.get(a);if(void 0===d||d.count!==c){void 0!==d&&d.texture.dispose();const u=void 0!==a.morphAttributes.position,p=void 0!==a.morphAttributes.normal,m=void 0!==a.morphAttributes.color,f=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],v=a.morphAttributes.color||[];let _=0;!0===u&&(_=1),!0===p&&(_=2),!0===m&&(_=3);let y=a.attributes.position.count*_,x=1;y>e.maxTextureSize&&(x=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const b=new Float32Array(y*x*4*c),w=new Ti(b,y,x,c);w.type=yt,w.needsUpdate=!0;const S=4*_;for(let T=0;T<c;T++){const E=f[T],A=g[T],C=v[T],R=y*x*4*T;for(let P=0;P<E.count;P++){const L=P*S;!0===u&&(r.fromBufferAttribute(E,P),b[R+L+0]=r.x,b[R+L+1]=r.y,b[R+L+2]=r.z,b[R+L+3]=0),!0===p&&(r.fromBufferAttribute(A,P),b[R+L+4]=r.x,b[R+L+5]=r.y,b[R+L+6]=r.z,b[R+L+7]=0),!0===m&&(r.fromBufferAttribute(C,P),b[R+L+8]=r.x,b[R+L+9]=r.y,b[R+L+10]=r.z,b[R+L+11]=4===C.itemSize?r.w:1)}}function M(){w.dispose(),n.delete(a),a.removeEventListener("dispose",M)}d={count:c,texture:w,size:new $e(y,x)},n.set(a,d),a.addEventListener("dispose",M)}if(!0===s.isInstancedMesh&&null!==s.morphTexture)o.getUniforms().setValue(t,"morphTexture",s.morphTexture,i);else{let I=0;for(let O=0;O<h.length;O++)I+=h[O];const D=a.morphTargetsRelative?1:1-I;o.getUniforms().setValue(t,"morphTargetBaseInfluence",D),o.getUniforms().setValue(t,"morphTargetInfluences",h)}o.getUniforms().setValue(t,"morphTargetsTexture",d.texture,i),o.getUniforms().setValue(t,"morphTargetsTextureSize",d.size)}}}function yd(t,e,i,n){let r=new WeakMap;function s(t){const e=t.target;e.removeEventListener("dispose",s),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update:function(a){const o=n.render.frame,h=a.geometry,l=e.get(a,h);if(r.get(l)!==o&&(e.update(l),r.set(l,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",s)&&a.addEventListener("dispose",s),r.get(a)!==o&&(i.update(a.instanceMatrix,t.ARRAY_BUFFER),null!==a.instanceColor&&i.update(a.instanceColor,t.ARRAY_BUFFER),r.set(a,o))),a.isSkinnedMesh){const t=a.skeleton;r.get(t)!==o&&(t.update(),r.set(t,o))}return l},dispose:function(){r=new WeakMap}}}const xd=new bi,bd=new Va(1,1),wd=new Ti,Sd=new Ei,Md=new qr,Td=[],Ed=[],Ad=new Float32Array(16),Cd=new Float32Array(9),Rd=new Float32Array(4);function Pd(t,e,i){const n=t[0];if(n<=0||n>0)return t;const r=e*i;let s=Td[r];if(void 0===s&&(s=new Float32Array(r),Td[r]=s),0!==e){n.toArray(s,0);for(let n=1,r=0;n!==e;++n)r+=i,t[n].toArray(s,r)}return s}function Ld(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function Id(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function Dd(t,e){let i=Ed[e];void 0===i&&(i=new Int32Array(e),Ed[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function Od(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function Nd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Ld(i,e))return;t.uniform2fv(this.addr,e),Id(i,e)}}function Ud(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(Ld(i,e))return;t.uniform3fv(this.addr,e),Id(i,e)}}function Fd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Ld(i,e))return;t.uniform4fv(this.addr,e),Id(i,e)}}function kd(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Ld(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),Id(i,e)}else{if(Ld(i,n))return;Rd.set(n),t.uniformMatrix2fv(this.addr,!1,Rd),Id(i,n)}}function Bd(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Ld(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),Id(i,e)}else{if(Ld(i,n))return;Cd.set(n),t.uniformMatrix3fv(this.addr,!1,Cd),Id(i,n)}}function zd(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Ld(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),Id(i,e)}else{if(Ld(i,n))return;Ad.set(n),t.uniformMatrix4fv(this.addr,!1,Ad),Id(i,n)}}function Gd(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function Hd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Ld(i,e))return;t.uniform2iv(this.addr,e),Id(i,e)}}function Vd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(Ld(i,e))return;t.uniform3iv(this.addr,e),Id(i,e)}}function Wd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Ld(i,e))return;t.uniform4iv(this.addr,e),Id(i,e)}}function jd(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function Xd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Ld(i,e))return;t.uniform2uiv(this.addr,e),Id(i,e)}}function Yd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(Ld(i,e))return;t.uniform3uiv(this.addr,e),Id(i,e)}}function qd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Ld(i,e))return;t.uniform4uiv(this.addr,e),Id(i,e)}}function Kd(t,e,i){const n=this.cache,r=i.allocateTextureUnit();let s;n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),this.type===t.SAMPLER_2D_SHADOW?(bd.compareFunction=515,s=bd):s=xd,i.setTexture2D(e||s,r)}function Zd(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(e||Sd,r)}function Jd(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTextureCube(e||Md,r)}function Qd(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(e||wd,r)}function $d(t,e){t.uniform1fv(this.addr,e)}function tu(t,e){const i=Pd(e,this.size,2);t.uniform2fv(this.addr,i)}function eu(t,e){const i=Pd(e,this.size,3);t.uniform3fv(this.addr,i)}function iu(t,e){const i=Pd(e,this.size,4);t.uniform4fv(this.addr,i)}function nu(t,e){const i=Pd(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function ru(t,e){const i=Pd(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function su(t,e){const i=Pd(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function au(t,e){t.uniform1iv(this.addr,e)}function ou(t,e){t.uniform2iv(this.addr,e)}function hu(t,e){t.uniform3iv(this.addr,e)}function lu(t,e){t.uniform4iv(this.addr,e)}function cu(t,e){t.uniform1uiv(this.addr,e)}function du(t,e){t.uniform2uiv(this.addr,e)}function uu(t,e){t.uniform3uiv(this.addr,e)}function pu(t,e){t.uniform4uiv(this.addr,e)}function mu(t,e,i){const n=this.cache,r=e.length,s=Dd(i,r);Ld(n,s)||(t.uniform1iv(this.addr,s),Id(n,s));for(let t=0;t!==r;++t)i.setTexture2D(e[t]||xd,s[t])}function fu(t,e,i){const n=this.cache,r=e.length,s=Dd(i,r);Ld(n,s)||(t.uniform1iv(this.addr,s),Id(n,s));for(let t=0;t!==r;++t)i.setTexture3D(e[t]||Sd,s[t])}function gu(t,e,i){const n=this.cache,r=e.length,s=Dd(i,r);Ld(n,s)||(t.uniform1iv(this.addr,s),Id(n,s));for(let t=0;t!==r;++t)i.setTextureCube(e[t]||Md,s[t])}function vu(t,e,i){const n=this.cache,r=e.length,s=Dd(i,r);Ld(n,s)||(t.uniform1iv(this.addr,s),Id(n,s));for(let t=0;t!==r;++t)i.setTexture2DArray(e[t]||wd,s[t])}class _u{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return Od;case 35664:return Nd;case 35665:return Ud;case 35666:return Fd;case 35674:return kd;case 35675:return Bd;case 35676:return zd;case 5124:case 35670:return Gd;case 35667:case 35671:return Hd;case 35668:case 35672:return Vd;case 35669:case 35673:return Wd;case 5125:return jd;case 36294:return Xd;case 36295:return Yd;case 36296:return qd;case 35678:case 36198:case 36298:case 36306:case 35682:return Kd;case 35679:case 36299:case 36307:return Zd;case 35680:case 36300:case 36308:case 36293:return Jd;case 36289:case 36303:case 36311:case 36292:return Qd}}(e.type)}}class yu{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return $d;case 35664:return tu;case 35665:return eu;case 35666:return iu;case 35674:return nu;case 35675:return ru;case 35676:return su;case 5124:case 35670:return au;case 35667:case 35671:return ou;case 35668:case 35672:return hu;case 35669:case 35673:return lu;case 5125:return cu;case 36294:return du;case 36295:return uu;case 36296:return pu;case 35678:case 36198:case 36298:case 36306:case 35682:return mu;case 35679:case 36299:case 36307:return fu;case 35680:case 36300:case 36308:case 36293:return gu;case 36289:case 36303:case 36311:case 36292:return vu}}(e.type)}}class xu{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,i){const n=this.seq;for(let r=0,s=n.length;r!==s;++r){const s=n[r];s.setValue(t,e[s.id],i)}}}const bu=/(\w+)(\])?(\[|\.)?/g;function wu(t,e){t.seq.push(e),t.map[e.id]=e}function Su(t,e,i){const n=t.name,r=n.length;for(bu.lastIndex=0;;){const s=bu.exec(n),a=bu.lastIndex;let o=s[1];const h="]"===s[2],l=s[3];if(h&&(o|=0),void 0===l||"["===l&&a+2===r){wu(i,void 0===l?new _u(o,t,e):new yu(o,t,e));break}{let t=i.map[o];void 0===t&&(t=new xu(o),wu(i,t)),i=t}}}class Mu{constructor(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);Su(i,t.getUniformLocation(e,i.name),this)}}setValue(t,e,i,n){const r=this.map[e];void 0!==r&&r.setValue(t,i,n)}setOptional(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)}static upload(t,e,i,n){for(let r=0,s=e.length;r!==s;++r){const s=e[r],a=i[s.id];!1!==a.needsUpdate&&s.setValue(t,a.value,n)}}static seqWithValue(t,e){const i=[];for(let n=0,r=t.length;n!==r;++n){const r=t[n];r.id in e&&i.push(r)}return i}}function Tu(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}let Eu=0;const Au=new ti;function Cu(t,e,i){const n=t.getShaderParameter(e,t.COMPILE_STATUS),r=t.getShaderInfoLog(e).trim();if(n&&""===r)return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const n=parseInt(s[1]);return i.toUpperCase()+"\n\n"+r+"\n\n"+function(t,e){const i=t.split("\n"),n=[],r=Math.max(e-6,0),s=Math.min(e+6,i.length);for(let t=r;t<s;t++){const r=t+1;n.push(`${r===e?">":" "} ${r}: ${i[t]}`)}return n.join("\n")}(t.getShaderSource(e),n)}return r}function Ru(t,e){const i=function(t){ui._getMatrix(Au,ui.workingColorSpace,t);const e=`mat3( ${Au.elements.map((t=>t.toFixed(4)))} )`;switch(ui.getTransfer(t)){case Ee:return[e,"LinearTransferOETF"];case Ae:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${i[1]}( vec4( value.rgb * ${i[0]}, value.a ) );`,"}"].join("\n")}function Pu(t,e){let i;switch(e){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="Cineon";break;case 4:i="ACESFilmic";break;case 6:i="AgX";break;case 7:i="Neutral";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),i="Linear"}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}const Lu=new Ci;function Iu(){ui.getLuminanceCoefficients(Lu);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${Lu.x.toFixed(4)}, ${Lu.y.toFixed(4)}, ${Lu.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function Du(t){return""!==t}function Ou(t,e){const i=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Nu(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Uu=/^[ \t]*#include +<([\w\d./]+)>/gm;function Fu(t){return t.replace(Uu,Bu)}const ku=new Map;function Bu(t,e){let i=kc[e];if(void 0===i){const t=ku.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");i=kc[t],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return Fu(i)}const zu=/#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 Gu(t){return t.replace(zu,Hu)}function Hu(t,e,i,n){let r="";for(let t=parseInt(e);t<parseInt(i);t++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function Vu(t){let e=`precision ${t.precision} float;\n\tprecision ${t.precision} int;\n\tprecision ${t.precision} sampler2D;\n\tprecision ${t.precision} samplerCube;\n\tprecision ${t.precision} sampler3D;\n\tprecision ${t.precision} sampler2DArray;\n\tprecision ${t.precision} sampler2DShadow;\n\tprecision ${t.precision} samplerCubeShadow;\n\tprecision ${t.precision} sampler2DArrayShadow;\n\tprecision ${t.precision} isampler2D;\n\tprecision ${t.precision} isampler3D;\n\tprecision ${t.precision} isamplerCube;\n\tprecision ${t.precision} isampler2DArray;\n\tprecision ${t.precision} usampler2D;\n\tprecision ${t.precision} usampler3D;\n\tprecision ${t.precision} usamplerCube;\n\tprecision ${t.precision} usampler2DArray;\n\t`;return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function Wu(t,e,i,n){const r=t.getContext(),s=i.defines;let a=i.vertexShader,o=i.fragmentShader;const h=function(t){let e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(i),l=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case $:case tt:e="ENVMAP_TYPE_CUBE";break;case nt:e="ENVMAP_TYPE_CUBE_UV"}return e}(i),c=function(t){let e="ENVMAP_MODE_REFLECTION";t.envMap&&t.envMapMode===tt&&(e="ENVMAP_MODE_REFRACTION");return e}(i),d=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(i),u=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const i=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}(i),p=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Du).join("\n")}(i),m=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(s),f=r.createProgram();let g,v,_=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(g=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m].filter(Du).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m].filter(Du).join("\n"),v.length>0&&(v+="\n")):(g=[Vu(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m,i.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",i.batching?"#define USE_BATCHING":"",i.batchingColor?"#define USE_BATCHING_COLOR":"",i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.instancingMorph?"#define USE_INSTANCING_MORPH":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","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(Du).join("\n"),v=[Vu(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+l:"",i.envMap?"#define "+c:"",i.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.dispersion?"#define USE_DISPERSION":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor||i.batchingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?kc.tonemapping_pars_fragment:"",0!==i.toneMapping?Pu("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",kc.colorspace_pars_fragment,Ru("linearToOutputTexel",i.outputColorSpace),Iu(),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(Du).join("\n")),a=Fu(a),a=Ou(a,i),a=Nu(a,i),o=Fu(o),o=Ou(o,i),o=Nu(o,i),a=Gu(a),o=Gu(o),!0!==i.isRawShaderMaterial&&(_="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",i.glslVersion===ke?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===ke?"":"#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);const y=_+g+a,x=_+v+o,b=Tu(r,r.VERTEX_SHADER,y),w=Tu(r,r.FRAGMENT_SHADER,x);function S(e){if(t.debug.checkShaderErrors){const i=r.getProgramInfoLog(f).trim(),n=r.getShaderInfoLog(b).trim(),s=r.getShaderInfoLog(w).trim();let a=!0,o=!0;if(!1===r.getProgramParameter(f,r.LINK_STATUS))if(a=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,f,b,w);else{const t=Cu(r,b,"vertex"),n=Cu(r,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(f,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+i+"\n"+t+"\n"+n)}else""!==i?console.warn("THREE.WebGLProgram: Program Info Log:",i):""!==n&&""!==s||(o=!1);o&&(e.diagnostics={runnable:a,programLog:i,vertexShader:{log:n,prefix:g},fragmentShader:{log:s,prefix:v}})}r.deleteShader(b),r.deleteShader(w),M=new Mu(r,f),T=function(t,e){const i={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const n=t.getActiveAttrib(e,r),s=n.name;let a=1;n.type===t.FLOAT_MAT2&&(a=2),n.type===t.FLOAT_MAT3&&(a=3),n.type===t.FLOAT_MAT4&&(a=4),i[s]={type:n.type,location:t.getAttribLocation(e,s),locationSize:a}}return i}(r,f)}let M,T;r.attachShader(f,b),r.attachShader(f,w),void 0!==i.index0AttributeName?r.bindAttribLocation(f,0,i.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),this.getUniforms=function(){return void 0===M&&S(this),M},this.getAttributes=function(){return void 0===T&&S(this),T};let E=!1===i.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===E&&(E=r.getProgramParameter(f,37297)),E},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(f),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=Eu++,this.cacheKey=e,this.usedTimes=1,this.program=f,this.vertexShader=b,this.fragmentShader=w,this}let ju=0;class Xu{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,i=t.fragmentShader,n=this._getShaderStage(e),r=this._getShaderStage(i),s=this._getShaderCacheForMaterial(t);return!1===s.has(n)&&(s.add(n),n.usedTimes++),!1===s.has(r)&&(s.add(r),r.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let i=e.get(t);return void 0===i&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return void 0===i&&(i=new Yu(t),e.set(t,i)),i}}class Yu{constructor(t){this.id=ju++,this.code=t,this.usedTimes=0}}function qu(t,e,i,n,r,s,a){const o=new gn,h=new Xu,l=new Set,c=[],d=r.logarithmicDepthBuffer,u=r.vertexTextures;let p=r.precision;const m={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 f(t){return l.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(s,o,c,g,v){const _=g.fog,y=v.geometry,x=s.isMeshStandardMaterial?g.environment:null,b=(s.isMeshStandardMaterial?i:e).get(s.envMap||x),w=b&&b.mapping===nt?b.image.height:null,S=m[s.type];null!==s.precision&&(p=r.getMaxPrecision(s.precision),p!==s.precision&&console.warn("THREE.WebGLProgram.getParameters:",s.precision,"not supported, using",p,"instead."));const M=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,T=void 0!==M?M.length:0;let E,A,C,R,P=0;if(void 0!==y.morphAttributes.position&&(P=1),void 0!==y.morphAttributes.normal&&(P=2),void 0!==y.morphAttributes.color&&(P=3),S){const t=zc[S];E=t.vertexShader,A=t.fragmentShader}else E=s.vertexShader,A=s.fragmentShader,h.update(s),C=h.getVertexShaderID(s),R=h.getFragmentShaderID(s);const L=t.getRenderTarget(),I=t.state.buffers.depth.getReversed(),D=!0===v.isInstancedMesh,O=!0===v.isBatchedMesh,N=!!s.map,U=!!s.matcap,F=!!b,k=!!s.aoMap,B=!!s.lightMap,z=!!s.bumpMap,G=!!s.normalMap,H=!!s.displacementMap,V=!!s.emissiveMap,W=!!s.metalnessMap,j=!!s.roughnessMap,X=s.anisotropy>0,Y=s.clearcoat>0,q=s.dispersion>0,K=s.iridescence>0,Z=s.sheen>0,J=s.transmission>0,Q=X&&!!s.anisotropyMap,$=Y&&!!s.clearcoatMap,tt=Y&&!!s.clearcoatNormalMap,et=Y&&!!s.clearcoatRoughnessMap,it=K&&!!s.iridescenceMap,rt=K&&!!s.iridescenceThicknessMap,st=Z&&!!s.sheenColorMap,at=Z&&!!s.sheenRoughnessMap,ot=!!s.specularMap,ht=!!s.specularColorMap,lt=!!s.specularIntensityMap,ct=J&&!!s.transmissionMap,dt=J&&!!s.thicknessMap,ut=!!s.gradientMap,pt=!!s.alphaMap,mt=s.alphaTest>0,ft=!!s.alphaHash,gt=!!s.extensions;let vt=0;s.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(vt=t.toneMapping));const _t={shaderID:S,shaderType:s.type,shaderName:s.name,vertexShader:E,fragmentShader:A,defines:s.defines,customVertexShaderID:C,customFragmentShaderID:R,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,batching:O,batchingColor:O&&null!==v._colorsTexture,instancing:D,instancingColor:D&&null!==v.instanceColor,instancingMorph:D&&null!==v.morphTexture,supportsVertexTextures:u,outputColorSpace:null===L?t.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:Te,alphaToCoverage:!!s.alphaToCoverage,map:N,matcap:U,envMap:F,envMapMode:F&&b.mapping,envMapCubeUVHeight:w,aoMap:k,lightMap:B,bumpMap:z,normalMap:G,displacementMap:u&&H,emissiveMap:V,normalMapObjectSpace:G&&1===s.normalMapType,normalMapTangentSpace:G&&0===s.normalMapType,metalnessMap:W,roughnessMap:j,anisotropy:X,anisotropyMap:Q,clearcoat:Y,clearcoatMap:$,clearcoatNormalMap:tt,clearcoatRoughnessMap:et,dispersion:q,iridescence:K,iridescenceMap:it,iridescenceThicknessMap:rt,sheen:Z,sheenColorMap:st,sheenRoughnessMap:at,specularMap:ot,specularColorMap:ht,specularIntensityMap:lt,transmission:J,transmissionMap:ct,thicknessMap:dt,gradientMap:ut,opaque:!1===s.transparent&&1===s.blending&&!1===s.alphaToCoverage,alphaMap:pt,alphaTest:mt,alphaHash:ft,combine:s.combine,mapUv:N&&f(s.map.channel),aoMapUv:k&&f(s.aoMap.channel),lightMapUv:B&&f(s.lightMap.channel),bumpMapUv:z&&f(s.bumpMap.channel),normalMapUv:G&&f(s.normalMap.channel),displacementMapUv:H&&f(s.displacementMap.channel),emissiveMapUv:V&&f(s.emissiveMap.channel),metalnessMapUv:W&&f(s.metalnessMap.channel),roughnessMapUv:j&&f(s.roughnessMap.channel),anisotropyMapUv:Q&&f(s.anisotropyMap.channel),clearcoatMapUv:$&&f(s.clearcoatMap.channel),clearcoatNormalMapUv:tt&&f(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:et&&f(s.clearcoatRoughnessMap.channel),iridescenceMapUv:it&&f(s.iridescenceMap.channel),iridescenceThicknessMapUv:rt&&f(s.iridescenceThicknessMap.channel),sheenColorMapUv:st&&f(s.sheenColorMap.channel),sheenRoughnessMapUv:at&&f(s.sheenRoughnessMap.channel),specularMapUv:ot&&f(s.specularMap.channel),specularColorMapUv:ht&&f(s.specularColorMap.channel),specularIntensityMapUv:lt&&f(s.specularIntensityMap.channel),transmissionMapUv:ct&&f(s.transmissionMap.channel),thicknessMapUv:dt&&f(s.thicknessMap.channel),alphaMapUv:pt&&f(s.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(G||X),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,pointsUvs:!0===v.isPoints&&!!y.attributes.uv&&(N||pt),fog:!!_,useFog:!0===s.fog,fogExp2:!!_&&_.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:d,reverseDepthBuffer:I,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:T,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:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:t.shadowMap.enabled&&c.length>0,shadowMapType:t.shadowMap.type,toneMapping:vt,decodeVideoTexture:N&&!0===s.map.isVideoTexture&&ui.getTransfer(s.map.colorSpace)===Ae,decodeVideoTextureEmissive:V&&!0===s.emissiveMap.isVideoTexture&&ui.getTransfer(s.emissiveMap.colorSpace)===Ae,premultipliedAlpha:s.premultipliedAlpha,doubleSided:2===s.side,flipSided:1===s.side,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionClipCullDistance:gt&&!0===s.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(gt&&!0===s.extensions.multiDraw||O)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};return _t.vertexUv1s=l.has(1),_t.vertexUv2s=l.has(2),_t.vertexUv3s=l.has(3),l.clear(),_t},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.customVertexShaderID),i.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(i,e),function(t,e){o.disableAll(),e.supportsVertexTextures&&o.enable(0);e.instancing&&o.enable(1);e.instancingColor&&o.enable(2);e.instancingMorph&&o.enable(3);e.matcap&&o.enable(4);e.envMap&&o.enable(5);e.normalMapObjectSpace&&o.enable(6);e.normalMapTangentSpace&&o.enable(7);e.clearcoat&&o.enable(8);e.iridescence&&o.enable(9);e.alphaTest&&o.enable(10);e.vertexColors&&o.enable(11);e.vertexAlphas&&o.enable(12);e.vertexUv1s&&o.enable(13);e.vertexUv2s&&o.enable(14);e.vertexUv3s&&o.enable(15);e.vertexTangents&&o.enable(16);e.anisotropy&&o.enable(17);e.alphaHash&&o.enable(18);e.batching&&o.enable(19);e.dispersion&&o.enable(20);e.batchingColor&&o.enable(21);t.push(o.mask),o.disableAll(),e.fog&&o.enable(0);e.useFog&&o.enable(1);e.flatShading&&o.enable(2);e.logarithmicDepthBuffer&&o.enable(3);e.reverseDepthBuffer&&o.enable(4);e.skinning&&o.enable(5);e.morphTargets&&o.enable(6);e.morphNormals&&o.enable(7);e.morphColors&&o.enable(8);e.premultipliedAlpha&&o.enable(9);e.shadowMapEnabled&&o.enable(10);e.doubleSided&&o.enable(11);e.flipSided&&o.enable(12);e.useDepthPacking&&o.enable(13);e.dithering&&o.enable(14);e.transmission&&o.enable(15);e.sheen&&o.enable(16);e.opaque&&o.enable(17);e.pointsUvs&&o.enable(18);e.decodeVideoTexture&&o.enable(19);e.decodeVideoTextureEmissive&&o.enable(20);e.alphaToCoverage&&o.enable(21);t.push(o.mask)}(i,e),i.push(t.outputColorSpace)),i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=m[t.type];let i;if(e){const t=zc[e];i=Br.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n;for(let t=0,e=c.length;t<e;t++){const e=c[t];if(e.cacheKey===i){n=e,++n.usedTimes;break}}return void 0===n&&(n=new Wu(t,i,e,s),c.push(n)),n},releaseProgram:function(t){if(0==--t.usedTimes){const e=c.indexOf(t);c[e]=c[c.length-1],c.pop(),t.destroy()}},releaseShaderCache:function(t){h.remove(t)},programs:c,dispose:function(){h.dispose()}}}function Ku(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove:function(e){t.delete(e)},update:function(e,i,n){t.get(e)[i]=n},dispose:function(){t=new WeakMap}}}function Zu(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Ju(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Qu(){const t=[];let e=0;const i=[],n=[],r=[];function s(i,n,r,s,a,o){let h=t[e];return void 0===h?(h={id:i.id,object:i,geometry:n,material:r,groupOrder:s,renderOrder:i.renderOrder,z:a,group:o},t[e]=h):(h.id=i.id,h.object=i,h.geometry=n,h.material=r,h.groupOrder=s,h.renderOrder=i.renderOrder,h.z=a,h.group=o),e++,h}return{opaque:i,transmissive:n,transparent:r,init:function(){e=0,i.length=0,n.length=0,r.length=0},push:function(t,e,a,o,h,l){const c=s(t,e,a,o,h,l);a.transmission>0?n.push(c):!0===a.transparent?r.push(c):i.push(c)},unshift:function(t,e,a,o,h,l){const c=s(t,e,a,o,h,l);a.transmission>0?n.unshift(c):!0===a.transparent?r.unshift(c):i.unshift(c)},finish:function(){for(let i=e,n=t.length;i<n;i++){const e=t[i];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){i.length>1&&i.sort(t||Zu),n.length>1&&n.sort(e||Ju),r.length>1&&r.sort(e||Ju)}}}function $u(){let t=new WeakMap;return{get:function(e,i){const n=t.get(e);let r;return void 0===n?(r=new Qu,t.set(e,[r])):i>=n.length?(r=new Qu,n.push(r)):r=n[i],r},dispose:function(){t=new WeakMap}}}function tp(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new Ci,color:new Jn};break;case"SpotLight":i={position:new Ci,direction:new Ci,color:new Jn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Ci,color:new Jn,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Ci,skyColor:new Jn,groundColor:new Jn};break;case"RectAreaLight":i={color:new Jn,position:new Ci,halfWidth:new Ci,halfHeight:new Ci}}return t[e.id]=i,i}}}let ep=0;function ip(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function np(t){const e=new tp,i=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e};break;case"PointLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),n={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 t=0;t<9;t++)n.probe.push(new Ci);const r=new Ci,s=new sn,a=new sn;return{setup:function(r){let s=0,a=0,o=0;for(let t=0;t<9;t++)n.probe[t].set(0,0,0);let h=0,l=0,c=0,d=0,u=0,p=0,m=0,f=0,g=0,v=0,_=0;r.sort(ip);for(let t=0,y=r.length;t<y;t++){const y=r[t],x=y.color,b=y.intensity,w=y.distance,S=y.shadow&&y.shadow.map?y.shadow.map.texture:null;if(y.isAmbientLight)s+=x.r*b,a+=x.g*b,o+=x.b*b;else if(y.isLightProbe){for(let t=0;t<9;t++)n.probe[t].addScaledVector(y.sh.coefficients[t],b);_++}else if(y.isDirectionalLight){const t=e.get(y);if(t.color.copy(y.color).multiplyScalar(y.intensity),y.castShadow){const t=y.shadow,e=i.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,n.directionalShadow[h]=e,n.directionalShadowMap[h]=S,n.directionalShadowMatrix[h]=y.shadow.matrix,p++}n.directional[h]=t,h++}else if(y.isSpotLight){const t=e.get(y);t.position.setFromMatrixPosition(y.matrixWorld),t.color.copy(x).multiplyScalar(b),t.distance=w,t.coneCos=Math.cos(y.angle),t.penumbraCos=Math.cos(y.angle*(1-y.penumbra)),t.decay=y.decay,n.spot[c]=t;const r=y.shadow;if(y.map&&(n.spotLightMap[g]=y.map,g++,r.updateMatrices(y),y.castShadow&&v++),n.spotLightMatrix[c]=r.matrix,y.castShadow){const t=i.get(y);t.shadowIntensity=r.intensity,t.shadowBias=r.bias,t.shadowNormalBias=r.normalBias,t.shadowRadius=r.radius,t.shadowMapSize=r.mapSize,n.spotShadow[c]=t,n.spotShadowMap[c]=S,f++}c++}else if(y.isRectAreaLight){const t=e.get(y);t.color.copy(x).multiplyScalar(b),t.halfWidth.set(.5*y.width,0,0),t.halfHeight.set(0,.5*y.height,0),n.rectArea[d]=t,d++}else if(y.isPointLight){const t=e.get(y);if(t.color.copy(y.color).multiplyScalar(y.intensity),t.distance=y.distance,t.decay=y.decay,y.castShadow){const t=y.shadow,e=i.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,e.shadowCameraNear=t.camera.near,e.shadowCameraFar=t.camera.far,n.pointShadow[l]=e,n.pointShadowMap[l]=S,n.pointShadowMatrix[l]=y.shadow.matrix,m++}n.point[l]=t,l++}else if(y.isHemisphereLight){const t=e.get(y);t.skyColor.copy(y.color).multiplyScalar(b),t.groundColor.copy(y.groundColor).multiplyScalar(b),n.hemi[u]=t,u++}}d>0&&(!0===t.has("OES_texture_float_linear")?(n.rectAreaLTC1=Bc.LTC_FLOAT_1,n.rectAreaLTC2=Bc.LTC_FLOAT_2):(n.rectAreaLTC1=Bc.LTC_HALF_1,n.rectAreaLTC2=Bc.LTC_HALF_2)),n.ambient[0]=s,n.ambient[1]=a,n.ambient[2]=o;const y=n.hash;y.directionalLength===h&&y.pointLength===l&&y.spotLength===c&&y.rectAreaLength===d&&y.hemiLength===u&&y.numDirectionalShadows===p&&y.numPointShadows===m&&y.numSpotShadows===f&&y.numSpotMaps===g&&y.numLightProbes===_||(n.directional.length=h,n.spot.length=c,n.rectArea.length=d,n.point.length=l,n.hemi.length=u,n.directionalShadow.length=p,n.directionalShadowMap.length=p,n.pointShadow.length=m,n.pointShadowMap.length=m,n.spotShadow.length=f,n.spotShadowMap.length=f,n.directionalShadowMatrix.length=p,n.pointShadowMatrix.length=m,n.spotLightMatrix.length=f+g-v,n.spotLightMap.length=g,n.numSpotLightShadowsWithMaps=v,n.numLightProbes=_,y.directionalLength=h,y.pointLength=l,y.spotLength=c,y.rectAreaLength=d,y.hemiLength=u,y.numDirectionalShadows=p,y.numPointShadows=m,y.numSpotShadows=f,y.numSpotMaps=g,y.numLightProbes=_,n.version=ep++)},setupView:function(t,e){let i=0,o=0,h=0,l=0,c=0;const d=e.matrixWorldInverse;for(let e=0,u=t.length;e<u;e++){const u=t[e];if(u.isDirectionalLight){const t=n.directional[i];t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),i++}else if(u.isSpotLight){const t=n.spot[h];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),h++}else if(u.isRectAreaLight){const t=n.rectArea[l];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),a.identity(),s.copy(u.matrixWorld),s.premultiply(d),a.extractRotation(s),t.halfWidth.set(.5*u.width,0,0),t.halfHeight.set(0,.5*u.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),l++}else if(u.isPointLight){const t=n.point[o];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),o++}else if(u.isHemisphereLight){const t=n.hemi[c];t.direction.setFromMatrixPosition(u.matrixWorld),t.direction.transformDirection(d),c++}}},state:n}}function rp(t){const e=new np(t),i=[],n=[];const r={lightsArray:i,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:function(t){r.camera=t,i.length=0,n.length=0},state:r,setupLights:function(){e.setup(i)},setupLightsView:function(t){e.setupView(i,t)},pushLight:function(t){i.push(t)},pushShadow:function(t){n.push(t)}}}function sp(t){let e=new WeakMap;return{get:function(i,n=0){const r=e.get(i);let s;return void 0===r?(s=new rp(t),e.set(i,[s])):n>=r.length?(s=new rp(t),r.push(s)):s=r[n],s},dispose:function(){e=new WeakMap}}}function ap(t,e,i){let n=new ta;const r=new $e,s=new $e,a=new wi,o=new Sh({depthPacking:3201}),h=new Mh,l={},c=i.maxTextureSize,d={[b]:1,[w]:0,[S]:2},u=new zr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $e},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}"}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const m=new br;m.setAttribute("position",new cr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Dr(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function _(i,n){const s=e.update(f);u.defines.VSM_SAMPLES!==i.blurSamples&&(u.defines.VSM_SAMPLES=i.blurSamples,p.defines.VSM_SAMPLES=i.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new Mi(r.x,r.y)),u.uniforms.shadow_pass.value=i.map.texture,u.uniforms.resolution.value=i.mapSize,u.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,s,u,f,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,s,p,f,null)}function y(e,i,n,r){let s=null;const a=!0===n.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===n.isPointLight?h:o,t.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0){const t=s.uuid,e=i.uuid;let n=l[t];void 0===n&&(n={},l[t]=n);let r=n[e];void 0===r&&(r=s.clone(),n[e]=r,i.addEventListener("dispose",M)),s=r}if(s.visible=i.visible,s.wireframe=i.wireframe,s.side=3===r?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:d[i.side],s.alphaMap=i.alphaMap,s.alphaTest=i.alphaTest,s.map=i.map,s.clipShadows=i.clipShadows,s.clippingPlanes=i.clippingPlanes,s.clipIntersection=i.clipIntersection,s.displacementMap=i.displacementMap,s.displacementScale=i.displacementScale,s.displacementBias=i.displacementBias,s.wireframeLinewidth=i.wireframeLinewidth,s.linewidth=i.linewidth,!0===n.isPointLight&&!0===s.isMeshDistanceMaterial){t.properties.get(s).light=n}return s}function x(i,r,s,a,o){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===o)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const n=e.update(i),h=i.material;if(Array.isArray(h)){const e=n.groups;for(let l=0,c=e.length;l<c;l++){const c=e[l],d=h[c.materialIndex];if(d&&d.visible){const e=y(i,d,a,o);i.onBeforeShadow(t,i,r,s,n,e,c),t.renderBufferDirect(s,null,n,e,i,c),i.onAfterShadow(t,i,r,s,n,e,c)}}}else if(h.visible){const e=y(i,h,a,o);i.onBeforeShadow(t,i,r,s,n,e,null),t.renderBufferDirect(s,null,n,e,i,null),i.onAfterShadow(t,i,r,s,n,e,null)}}const h=i.children;for(let t=0,e=h.length;t<e;t++)x(h[t],r,s,a,o)}function M(t){t.target.removeEventListener("dispose",M);for(const e in l){const i=l[e],n=t.target.uuid;if(n in i){i[n].dispose(),delete i[n]}}}this.render=function(e,i,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===e.length)return;const h=t.getRenderTarget(),l=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),u=t.state;u.setBlending(0),u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const p=3!==v&&3===this.type,m=3===v&&3!==this.type;for(let h=0,l=e.length;h<l;h++){const l=e[h],d=l.shadow;if(void 0===d){console.warn("THREE.WebGLShadowMap:",l,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;r.copy(d.mapSize);const f=d.getFrameExtents();if(r.multiply(f),s.copy(d.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(s.x=Math.floor(c/f.x),r.x=s.x*f.x,d.mapSize.x=s.x),r.y>c&&(s.y=Math.floor(c/f.y),r.y=s.y*f.y,d.mapSize.y=s.y)),null===d.map||!0===p||!0===m){const t=3!==this.type?{minFilter:ot,magFilter:ot}:{};null!==d.map&&d.map.dispose(),d.map=new Mi(r.x,r.y,t),d.map.texture.name=l.name+".shadowMap",d.camera.updateProjectionMatrix()}t.setRenderTarget(d.map),t.clear();const g=d.getViewportCount();for(let t=0;t<g;t++){const e=d.getViewport(t);a.set(s.x*e.x,s.y*e.y,s.x*e.z,s.y*e.w),u.viewport(a),d.updateMatrices(l,t),n=d.getFrustum(),x(i,o,d.camera,l,this.type)}!0!==d.isPointLightShadow&&3===this.type&&_(d,o),d.needsUpdate=!1}v=this.type,g.needsUpdate=!1,t.setRenderTarget(h,l,d)}}const op={[H]:1,[W]:6,[X]:7,[j]:5,[V]:0,[q]:2,[K]:4,[Y]:3};function hp(t,e){const i=new function(){let e=!1;const i=new wi;let n=null;const r=new wi(0,0,0,0);return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,s,a,o){!0===o&&(e*=a,n*=a,s*=a),i.set(e,n,s,a),!1===r.equals(i)&&(t.clearColor(e,n,s,a),r.copy(i))},reset:function(){e=!1,n=null,r.set(-1,0,0,0)}}},n=new function(){let i=!1,n=!1,r=null,s=null,a=null;return{setReversed:function(t){if(n!==t){const t=e.get("EXT_clip_control");n?t.clipControlEXT(t.LOWER_LEFT_EXT,t.ZERO_TO_ONE_EXT):t.clipControlEXT(t.LOWER_LEFT_EXT,t.NEGATIVE_ONE_TO_ONE_EXT);const i=a;a=null,this.setClear(i)}n=t},getReversed:function(){return n},setTest:function(e){e?rt(t.DEPTH_TEST):st(t.DEPTH_TEST)},setMask:function(e){r===e||i||(t.depthMask(e),r=e)},setFunc:function(e){if(n&&(e=op[e]),s!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}s=e}},setLocked:function(t){i=t},setClear:function(e){a!==e&&(n&&(e=1-e),t.clearDepth(e),a=e)},reset:function(){i=!1,r=null,s=null,a=null,n=!1}}},r=new function(){let e=!1,i=null,n=null,r=null,s=null,a=null,o=null,h=null,l=null;return{setTest:function(i){e||(i?rt(t.STENCIL_TEST):st(t.STENCIL_TEST))},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,a){n===e&&r===i&&s===a||(t.stencilFunc(e,i,a),n=e,r=i,s=a)},setOp:function(e,i,n){a===e&&o===i&&h===n||(t.stencilOp(e,i,n),a=e,o=i,h=n)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,i=null,n=null,r=null,s=null,a=null,o=null,h=null,l=null}}},s=new WeakMap,a=new WeakMap;let o={},h={},l=new WeakMap,c=[],d=null,u=!1,p=null,m=null,f=null,g=null,v=null,_=null,y=null,x=new Jn(0,0,0),b=0,w=!1,S=null,H=null,V=null,W=null,j=null;const X=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,q=0;const K=t.getParameter(t.VERSION);-1!==K.indexOf("WebGL")?(q=parseFloat(/^WebGL (\d)/.exec(K)[1]),Y=q>=1):-1!==K.indexOf("OpenGL ES")&&(q=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),Y=q>=2);let Z=null,J={};const Q=t.getParameter(t.SCISSOR_BOX),$=t.getParameter(t.VIEWPORT),tt=(new wi).fromArray(Q),et=(new wi).fromArray($);function it(e,i,n,r){const s=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let a=0;a<n;a++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(i,0,t.RGBA,1,1,r,0,t.RGBA,t.UNSIGNED_BYTE,s):t.texImage2D(i+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,s);return a}const nt={};function rt(e){!0!==o[e]&&(t.enable(e),o[e]=!0)}function st(e){!1!==o[e]&&(t.disable(e),o[e]=!1)}nt[t.TEXTURE_2D]=it(t.TEXTURE_2D,t.TEXTURE_2D,1),nt[t.TEXTURE_CUBE_MAP]=it(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),nt[t.TEXTURE_2D_ARRAY]=it(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),nt[t.TEXTURE_3D]=it(t.TEXTURE_3D,t.TEXTURE_3D,1,1),i.setClear(0,0,0,1),n.setClear(1),r.setClear(0),rt(t.DEPTH_TEST),n.setFunc(3),lt(!1),ct(1),rt(t.CULL_FACE),ht(0);const at={[M]:t.FUNC_ADD,[T]:t.FUNC_SUBTRACT,[E]:t.FUNC_REVERSE_SUBTRACT};at[103]=t.MIN,at[104]=t.MAX;const ot={[A]:t.ZERO,[C]:t.ONE,[R]:t.SRC_COLOR,[L]:t.SRC_ALPHA,[F]:t.SRC_ALPHA_SATURATE,[N]:t.DST_COLOR,[D]:t.DST_ALPHA,[P]:t.ONE_MINUS_SRC_COLOR,[I]:t.ONE_MINUS_SRC_ALPHA,[U]:t.ONE_MINUS_DST_COLOR,[O]:t.ONE_MINUS_DST_ALPHA,[k]:t.CONSTANT_COLOR,[B]:t.ONE_MINUS_CONSTANT_COLOR,[z]:t.CONSTANT_ALPHA,[G]:t.ONE_MINUS_CONSTANT_ALPHA};function ht(e,i,n,r,s,a,o,h,l,c){if(0!==e){if(!1===u&&(rt(t.BLEND),u=!0),5===e)s=s||i,a=a||n,o=o||r,i===m&&s===v||(t.blendEquationSeparate(at[i],at[s]),m=i,v=s),n===f&&r===g&&a===_&&o===y||(t.blendFuncSeparate(ot[n],ot[r],ot[a],ot[o]),f=n,g=r,_=a,y=o),!1!==h.equals(x)&&l===b||(t.blendColor(h.r,h.g,h.b,l),x.copy(h),b=l),p=e,w=!1;else if(e!==p||c!==w){if(m===M&&v===M||(t.blendEquation(t.FUNC_ADD),m=M,v=M),c)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}f=null,g=null,_=null,y=null,x.set(0,0,0),b=0,p=e,w=c}}else!0===u&&(st(t.BLEND),u=!1)}function lt(e){S!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),S=e)}function ct(e){0!==e?(rt(t.CULL_FACE),e!==H&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):st(t.CULL_FACE),H=e}function dt(e,i,n){e?(rt(t.POLYGON_OFFSET_FILL),W===i&&j===n||(t.polygonOffset(i,n),W=i,j=n)):st(t.POLYGON_OFFSET_FILL)}return{buffers:{color:i,depth:n,stencil:r},enable:rt,disable:st,bindFramebuffer:function(e,i){return h[e]!==i&&(t.bindFramebuffer(e,i),h[e]=i,e===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=i),e===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=i),!0)},drawBuffers:function(e,i){let n=c,r=!1;if(e){n=l.get(i),void 0===n&&(n=[],l.set(i,n));const s=e.textures;if(n.length!==s.length||n[0]!==t.COLOR_ATTACHMENT0){for(let e=0,i=s.length;e<i;e++)n[e]=t.COLOR_ATTACHMENT0+e;n.length=s.length,r=!0}}else n[0]!==t.BACK&&(n[0]=t.BACK,r=!0);r&&t.drawBuffers(n)},useProgram:function(e){return d!==e&&(t.useProgram(e),d=e,!0)},setBlending:ht,setMaterial:function(e,s){2===e.side?st(t.CULL_FACE):rt(t.CULL_FACE);let a=1===e.side;s&&(a=!a),lt(a),1===e.blending&&!1===e.transparent?ht(0):ht(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),n.setFunc(e.depthFunc),n.setTest(e.depthTest),n.setMask(e.depthWrite),i.setMask(e.colorWrite);const o=e.stencilWrite;r.setTest(o),o&&(r.setMask(e.stencilWriteMask),r.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),r.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),dt(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?rt(t.SAMPLE_ALPHA_TO_COVERAGE):st(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:lt,setCullFace:ct,setLineWidth:function(e){e!==V&&(Y&&t.lineWidth(e),V=e)},setPolygonOffset:dt,setScissorTest:function(e){e?rt(t.SCISSOR_TEST):st(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+X-1),Z!==e&&(t.activeTexture(e),Z=e)},bindTexture:function(e,i,n){void 0===n&&(n=null===Z?t.TEXTURE0+X-1:Z);let r=J[n];void 0===r&&(r={type:void 0,texture:void 0},J[n]=r),r.type===e&&r.texture===i||(Z!==n&&(t.activeTexture(n),Z=n),t.bindTexture(e,i||nt[e]),r.type=e,r.texture=i)},unbindTexture:function(){const e=J[Z];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},updateUBOMapping:function(e,i){let n=a.get(i);void 0===n&&(n=new WeakMap,a.set(i,n));let r=n.get(e);void 0===r&&(r=t.getUniformBlockIndex(i,e.name),n.set(e,r))},uniformBlockBinding:function(e,i){const n=a.get(i).get(e);s.get(i)!==n&&(t.uniformBlockBinding(i,n,e.__bindingPointIndex),s.set(i,n))},texStorage2D:function(){try{t.texStorage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===tt.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),tt.copy(e))},viewport:function(e){!1===et.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),et.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),n.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),o={},Z=null,J={},h={},l=new WeakMap,c=[],d=null,u=!1,p=null,m=null,f=null,g=null,v=null,_=null,y=null,x=new Jn(0,0,0),b=0,w=!1,S=null,H=null,V=null,W=null,j=null,tt.set(0,0,t.canvas.width,t.canvas.height),et.set(0,0,t.canvas.width,t.canvas.height),i.reset(),n.reset(),r.reset()}}}function lp(t,e,i,n,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,h="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),l=new $e,c=new WeakMap;let d;const u=new WeakMap;let p=!1;try{p="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function m(t,e){return p?new OffscreenCanvas(t,e):si("canvas")}function f(t,e,i){let n=1;const r=G(t);if((r.width>i||r.height>i)&&(n=i/Math.max(r.width,r.height)),n<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const i=Math.floor(n*r.width),s=Math.floor(n*r.height);void 0===d&&(d=m(i,s));const a=e?m(i,s):d;a.width=i,a.height=s;return a.getContext("2d").drawImage(t,0,0,i,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+i+"x"+s+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function g(t){return t.generateMipmaps}function v(e){t.generateMipmap(e)}function _(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function y(i,n,r,s,a=!1){if(null!==i){if(void 0!==t[i])return t[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let o=n;if(n===t.RED&&(r===t.FLOAT&&(o=t.R32F),r===t.HALF_FLOAT&&(o=t.R16F),r===t.UNSIGNED_BYTE&&(o=t.R8)),n===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.R8UI),r===t.UNSIGNED_SHORT&&(o=t.R16UI),r===t.UNSIGNED_INT&&(o=t.R32UI),r===t.BYTE&&(o=t.R8I),r===t.SHORT&&(o=t.R16I),r===t.INT&&(o=t.R32I)),n===t.RG&&(r===t.FLOAT&&(o=t.RG32F),r===t.HALF_FLOAT&&(o=t.RG16F),r===t.UNSIGNED_BYTE&&(o=t.RG8)),n===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RG8UI),r===t.UNSIGNED_SHORT&&(o=t.RG16UI),r===t.UNSIGNED_INT&&(o=t.RG32UI),r===t.BYTE&&(o=t.RG8I),r===t.SHORT&&(o=t.RG16I),r===t.INT&&(o=t.RG32I)),n===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGB8UI),r===t.UNSIGNED_SHORT&&(o=t.RGB16UI),r===t.UNSIGNED_INT&&(o=t.RGB32UI),r===t.BYTE&&(o=t.RGB8I),r===t.SHORT&&(o=t.RGB16I),r===t.INT&&(o=t.RGB32I)),n===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(o=t.RGBA16UI),r===t.UNSIGNED_INT&&(o=t.RGBA32UI),r===t.BYTE&&(o=t.RGBA8I),r===t.SHORT&&(o=t.RGBA16I),r===t.INT&&(o=t.RGBA32I)),n===t.RGB&&r===t.UNSIGNED_INT_5_9_9_9_REV&&(o=t.RGB9_E5),n===t.RGBA){const e=a?Ee:ui.getTransfer(s);r===t.FLOAT&&(o=t.RGBA32F),r===t.HALF_FLOAT&&(o=t.RGBA16F),r===t.UNSIGNED_BYTE&&(o=e===Ae?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(o=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(o=t.RGB5_A1)}return o!==t.R16F&&o!==t.R32F&&o!==t.RG16F&&o!==t.RG32F&&o!==t.RGBA16F&&o!==t.RGBA32F||e.get("EXT_color_buffer_float"),o}function x(e,i){let n;return e?null===i||i===_t||i===St?n=t.DEPTH24_STENCIL8:i===yt?n=t.DEPTH32F_STENCIL8:i===gt&&(n=t.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===i||i===_t||i===St?n=t.DEPTH_COMPONENT24:i===yt?n=t.DEPTH_COMPONENT32F:i===gt&&(n=t.DEPTH_COMPONENT16),n}function b(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==ot&&t.minFilter!==ct?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function w(t){const e=t.target;e.removeEventListener("dispose",w),function(t){const e=n.get(t);if(void 0===e.__webglInit)return;const i=t.source,r=u.get(i);if(r){const n=r[e.__cacheKey];n.usedTimes--,0===n.usedTimes&&M(t),0===Object.keys(r).length&&u.delete(i)}n.remove(t)}(e),e.isVideoTexture&&c.delete(e)}function S(e){const i=e.target;i.removeEventListener("dispose",S),function(e){const i=n.get(e);e.depthTexture&&(e.depthTexture.dispose(),n.remove(e.depthTexture));if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(i.__webglFramebuffer[e]))for(let n=0;n<i.__webglFramebuffer[e].length;n++)t.deleteFramebuffer(i.__webglFramebuffer[e][n]);else t.deleteFramebuffer(i.__webglFramebuffer[e]);i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e])}else{if(Array.isArray(i.__webglFramebuffer))for(let e=0;e<i.__webglFramebuffer.length;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer);if(i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(let e=0;e<i.__webglColorRenderbuffer.length;e++)i.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(i.__webglColorRenderbuffer[e]);i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer)}const r=e.textures;for(let e=0,i=r.length;e<i;e++){const i=n.get(r[e]);i.__webglTexture&&(t.deleteTexture(i.__webglTexture),a.memory.textures--),n.remove(r[e])}n.remove(e)}(i)}function M(e){const i=n.get(e);t.deleteTexture(i.__webglTexture);const r=e.source;delete u.get(r)[i.__cacheKey],a.memory.textures--}let T=0;function E(e,r){const s=n.get(e);if(e.isVideoTexture&&function(t){const e=a.render.frame;c.get(t)!==e&&(c.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&e.version>0&&s.__version!==e.version){const t=e.image;if(null===t)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void I(s,e,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const A={[rt]:t.REPEAT,[st]:t.CLAMP_TO_EDGE,[at]:t.MIRRORED_REPEAT},C={[ot]:t.NEAREST,[ht]:t.NEAREST_MIPMAP_NEAREST,[lt]:t.NEAREST_MIPMAP_LINEAR,[ct]:t.LINEAR,[dt]:t.LINEAR_MIPMAP_NEAREST,[ut]:t.LINEAR_MIPMAP_LINEAR},R={[Re]:t.NEVER,[Ue]:t.ALWAYS,[Pe]:t.LESS,[Ie]:t.LEQUAL,[Le]:t.EQUAL,[Ne]:t.GEQUAL,[De]:t.GREATER,[Oe]:t.NOTEQUAL};function P(i,s){if(s.type!==yt||!1!==e.has("OES_texture_float_linear")||s.magFilter!==ct&&s.magFilter!==dt&&s.magFilter!==lt&&s.magFilter!==ut&&s.minFilter!==ct&&s.minFilter!==dt&&s.minFilter!==lt&&s.minFilter!==ut||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(i,t.TEXTURE_WRAP_S,A[s.wrapS]),t.texParameteri(i,t.TEXTURE_WRAP_T,A[s.wrapT]),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,A[s.wrapR]),t.texParameteri(i,t.TEXTURE_MAG_FILTER,C[s.magFilter]),t.texParameteri(i,t.TEXTURE_MIN_FILTER,C[s.minFilter]),s.compareFunction&&(t.texParameteri(i,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(i,t.TEXTURE_COMPARE_FUNC,R[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(s.magFilter===ot)return;if(s.minFilter!==lt&&s.minFilter!==ut)return;if(s.type===yt&&!1===e.has("OES_texture_float_linear"))return;if(s.anisotropy>1||n.get(s).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy}}}function L(e,i){let n=!1;void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",w));const r=i.source;let s=u.get(r);void 0===s&&(s={},u.set(r,s));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(i);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,n=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&M(i)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return n}function I(e,a,o){let h=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(h=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(h=t.TEXTURE_3D);const l=L(e,a),c=a.source;i.bindTexture(h,e.__webglTexture,t.TEXTURE0+o);const d=n.get(c);if(c.version!==d.__version||!0===l){i.activeTexture(t.TEXTURE0+o);const e=ui.getPrimaries(ui.workingColorSpace),n=a.colorSpace===Se?null:ui.getPrimaries(a.colorSpace),u=a.colorSpace===Se||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);let p=f(a.image,!1,r.maxTextureSize);p=z(a,p);const m=s.convert(a.format,a.colorSpace),_=s.convert(a.type);let w,S=y(a.internalFormat,m,_,a.colorSpace,a.isVideoTexture);P(h,a);const M=a.mipmaps,T=!0!==a.isVideoTexture,E=void 0===d.__version||!0===l,A=c.dataReady,C=b(a,p);if(a.isDepthTexture)S=x(a.format===Lt,a.type),E&&(T?i.texStorage2D(t.TEXTURE_2D,1,S,p.width,p.height):i.texImage2D(t.TEXTURE_2D,0,S,p.width,p.height,0,m,_,null));else if(a.isDataTexture)if(M.length>0){T&&E&&i.texStorage2D(t.TEXTURE_2D,C,S,M[0].width,M[0].height);for(let e=0,n=M.length;e<n;e++)w=M[e],T?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,w.width,w.height,m,_,w.data):i.texImage2D(t.TEXTURE_2D,e,S,w.width,w.height,0,m,_,w.data);a.generateMipmaps=!1}else T?(E&&i.texStorage2D(t.TEXTURE_2D,C,S,p.width,p.height),A&&i.texSubImage2D(t.TEXTURE_2D,0,0,0,p.width,p.height,m,_,p.data)):i.texImage2D(t.TEXTURE_2D,0,S,p.width,p.height,0,m,_,p.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){T&&E&&i.texStorage3D(t.TEXTURE_2D_ARRAY,C,S,M[0].width,M[0].height,p.depth);for(let e=0,n=M.length;e<n;e++)if(w=M[e],a.format!==At)if(null!==m)if(T){if(A)if(a.layerUpdates.size>0){const n=Oc(w.width,w.height,a.format,a.type);for(const r of a.layerUpdates){const s=w.data.subarray(r*n/w.data.BYTES_PER_ELEMENT,(r+1)*n/w.data.BYTES_PER_ELEMENT);i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,r,w.width,w.height,1,m,s)}a.clearLayerUpdates()}else i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,p.depth,m,w.data)}else i.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,S,w.width,w.height,p.depth,0,w.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else T?A&&i.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,p.depth,m,_,w.data):i.texImage3D(t.TEXTURE_2D_ARRAY,e,S,w.width,w.height,p.depth,0,m,_,w.data)}else{T&&E&&i.texStorage2D(t.TEXTURE_2D,C,S,M[0].width,M[0].height);for(let e=0,n=M.length;e<n;e++)w=M[e],a.format!==At?null!==m?T?A&&i.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,w.width,w.height,m,w.data):i.compressedTexImage2D(t.TEXTURE_2D,e,S,w.width,w.height,0,w.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):T?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,w.width,w.height,m,_,w.data):i.texImage2D(t.TEXTURE_2D,e,S,w.width,w.height,0,m,_,w.data)}else if(a.isDataArrayTexture)if(T){if(E&&i.texStorage3D(t.TEXTURE_2D_ARRAY,C,S,p.width,p.height,p.depth),A)if(a.layerUpdates.size>0){const e=Oc(p.width,p.height,a.format,a.type);for(const n of a.layerUpdates){const r=p.data.subarray(n*e/p.data.BYTES_PER_ELEMENT,(n+1)*e/p.data.BYTES_PER_ELEMENT);i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,n,p.width,p.height,1,m,_,r)}a.clearLayerUpdates()}else i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,m,_,p.data)}else i.texImage3D(t.TEXTURE_2D_ARRAY,0,S,p.width,p.height,p.depth,0,m,_,p.data);else if(a.isData3DTexture)T?(E&&i.texStorage3D(t.TEXTURE_3D,C,S,p.width,p.height,p.depth),A&&i.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,m,_,p.data)):i.texImage3D(t.TEXTURE_3D,0,S,p.width,p.height,p.depth,0,m,_,p.data);else if(a.isFramebufferTexture){if(E)if(T)i.texStorage2D(t.TEXTURE_2D,C,S,p.width,p.height);else{let e=p.width,n=p.height;for(let r=0;r<C;r++)i.texImage2D(t.TEXTURE_2D,r,S,e,n,0,m,_,null),e>>=1,n>>=1}}else if(M.length>0){if(T&&E){const e=G(M[0]);i.texStorage2D(t.TEXTURE_2D,C,S,e.width,e.height)}for(let e=0,n=M.length;e<n;e++)w=M[e],T?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,m,_,w):i.texImage2D(t.TEXTURE_2D,e,S,m,_,w);a.generateMipmaps=!1}else if(T){if(E){const e=G(p);i.texStorage2D(t.TEXTURE_2D,C,S,e.width,e.height)}A&&i.texSubImage2D(t.TEXTURE_2D,0,0,0,m,_,p)}else i.texImage2D(t.TEXTURE_2D,0,S,m,_,p);g(a)&&v(h),d.__version=c.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function D(e,r,a,h,l,c){const d=s.convert(a.format,a.colorSpace),u=s.convert(a.type),p=y(a.internalFormat,d,u,a.colorSpace),m=n.get(r),f=n.get(a);if(f.__renderTarget=r,!m.__hasExternalTextures){const e=Math.max(1,r.width>>c),n=Math.max(1,r.height>>c);l===t.TEXTURE_3D||l===t.TEXTURE_2D_ARRAY?i.texImage3D(l,c,p,e,n,r.depth,0,d,u,null):i.texImage2D(l,c,p,e,n,0,d,u,null)}i.bindFramebuffer(t.FRAMEBUFFER,e),B(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,h,l,f.__webglTexture,0,k(r)):(l===t.TEXTURE_2D||l>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,h,l,f.__webglTexture,c),i.bindFramebuffer(t.FRAMEBUFFER,null)}function O(e,i,n){if(t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer){const r=i.depthTexture,s=r&&r.isDepthTexture?r.type:null,a=x(i.stencilBuffer,s),h=i.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,l=k(i);B(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,l,a,i.width,i.height):n?t.renderbufferStorageMultisample(t.RENDERBUFFER,l,a,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,a,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,h,t.RENDERBUFFER,e)}else{const e=i.textures;for(let r=0;r<e.length;r++){const a=e[r],h=s.convert(a.format,a.colorSpace),l=s.convert(a.type),c=y(a.internalFormat,h,l,a.colorSpace),d=k(i);n&&!1===B(i)?t.renderbufferStorageMultisample(t.RENDERBUFFER,d,c,i.width,i.height):B(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,d,c,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,c,i.width,i.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function N(e){const r=n.get(e),s=!0===e.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),t){const e=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const s=n.get(r.depthTexture);s.__renderTarget=r,s.__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),E(r.depthTexture,0);const a=s.__webglTexture,h=k(r);if(r.depthTexture.format===Pt)B(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0,h):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==Lt)throw new Error("Unknown depthTexture format");B(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0,h):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0)}}(r.__webglFramebuffer,e)}else if(s){r.__webglDepthbuffer=[];for(let n=0;n<6;n++)if(i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[n]),void 0===r.__webglDepthbuffer[n])r.__webglDepthbuffer[n]=t.createRenderbuffer(),O(r.__webglDepthbuffer[n],e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[n];t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,s)}}else if(i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),O(r.__webglDepthbuffer,e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,n=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,n)}i.bindFramebuffer(t.FRAMEBUFFER,null)}const U=[],F=[];function k(t){return Math.min(r.maxSamples,t.samples)}function B(t){const i=n.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function z(t,e){const i=t.colorSpace,n=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||i!==Te&&i!==Se&&(ui.getTransfer(i)===Ae?n===At&&r===pt||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),e}function G(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(l.width=t.naturalWidth||t.width,l.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(l.width=t.displayWidth,l.height=t.displayHeight):(l.width=t.width,l.height=t.height),l}this.allocateTextureUnit=function(){const t=T;return t>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),T+=1,t},this.resetTextureUnits=function(){T=0},this.setTexture2D=E,this.setTexture2DArray=function(e,r){const s=n.get(e);e.version>0&&s.__version!==e.version?I(s,e,r):i.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r)},this.setTexture3D=function(e,r){const s=n.get(e);e.version>0&&s.__version!==e.version?I(s,e,r):i.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,a){const o=n.get(e);e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const h=L(e,a),l=a.source;i.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const c=n.get(l);if(l.version!==c.__version||!0===h){i.activeTexture(t.TEXTURE0+o);const e=ui.getPrimaries(ui.workingColorSpace),n=a.colorSpace===Se?null:ui.getPrimaries(a.colorSpace),d=a.colorSpace===Se||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const u=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,m=[];for(let t=0;t<6;t++)m[t]=u||p?p?a.image[t].image:a.image[t]:f(a.image[t],!0,r.maxCubemapSize),m[t]=z(a,m[t]);const _=m[0],x=s.convert(a.format,a.colorSpace),w=s.convert(a.type),S=y(a.internalFormat,x,w,a.colorSpace),M=!0!==a.isVideoTexture,T=void 0===c.__version||!0===h,E=l.dataReady;let A,C=b(a,_);if(P(t.TEXTURE_CUBE_MAP,a),u){M&&T&&i.texStorage2D(t.TEXTURE_CUBE_MAP,C,S,_.width,_.height);for(let e=0;e<6;e++){A=m[e].mipmaps;for(let n=0;n<A.length;n++){const r=A[n];a.format!==At?null!==x?M?E&&i.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,r.width,r.height,x,r.data):i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,S,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,r.width,r.height,x,w,r.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,S,r.width,r.height,0,x,w,r.data)}}}else{if(A=a.mipmaps,M&&T){A.length>0&&C++;const e=G(m[0]);i.texStorage2D(t.TEXTURE_CUBE_MAP,C,S,e.width,e.height)}for(let e=0;e<6;e++)if(p){M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,m[e].width,m[e].height,x,w,m[e].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,S,m[e].width,m[e].height,0,x,w,m[e].data);for(let n=0;n<A.length;n++){const r=A[n].image[e].image;M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,r.width,r.height,x,w,r.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,S,r.width,r.height,0,x,w,r.data)}}else{M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,x,w,m[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,S,x,w,m[e]);for(let n=0;n<A.length;n++){const r=A[n];M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,x,w,r.image[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,S,x,w,r.image[e])}}}g(a)&&v(t.TEXTURE_CUBE_MAP),c.__version=l.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(o,e,a):i.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,i,r){const s=n.get(e);void 0!==i&&D(s.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==r&&N(e)},this.setupRenderTarget=function(e){const r=e.texture,o=n.get(e),h=n.get(r);e.addEventListener("dispose",S);const l=e.textures,c=!0===e.isWebGLCubeRenderTarget,d=l.length>1;if(d||(void 0===h.__webglTexture&&(h.__webglTexture=t.createTexture()),h.__version=r.version,a.memory.textures++),c){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let i=0;i<r.mipmaps.length;i++)o.__webglFramebuffer[e][i]=t.createFramebuffer()}else o.__webglFramebuffer[e]=t.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let e=0;e<r.mipmaps.length;e++)o.__webglFramebuffer[e]=t.createFramebuffer()}else o.__webglFramebuffer=t.createFramebuffer();if(d)for(let e=0,i=l.length;e<i;e++){const i=n.get(l[e]);void 0===i.__webglTexture&&(i.__webglTexture=t.createTexture(),a.memory.textures++)}if(e.samples>0&&!1===B(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],i.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let i=0;i<l.length;i++){const n=l[i];o.__webglColorRenderbuffer[i]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,o.__webglColorRenderbuffer[i]);const r=s.convert(n.format,n.colorSpace),a=s.convert(n.type),h=y(n.internalFormat,r,a,n.colorSpace,!0===e.isXRRenderTarget),c=k(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,h,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+i,t.RENDERBUFFER,o.__webglColorRenderbuffer[i])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(o.__webglDepthRenderbuffer=t.createRenderbuffer(),O(o.__webglDepthRenderbuffer,e,!0)),i.bindFramebuffer(t.FRAMEBUFFER,null)}}if(c){i.bindTexture(t.TEXTURE_CUBE_MAP,h.__webglTexture),P(t.TEXTURE_CUBE_MAP,r);for(let i=0;i<6;i++)if(r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)D(o.__webglFramebuffer[i][n],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,n);else D(o.__webglFramebuffer[i],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,0);g(r)&&v(t.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(d){for(let r=0,s=l.length;r<s;r++){const s=l[r],a=n.get(s);i.bindTexture(t.TEXTURE_2D,a.__webglTexture),P(t.TEXTURE_2D,s),D(o.__webglFramebuffer,e,s,t.COLOR_ATTACHMENT0+r,t.TEXTURE_2D,0),g(s)&&v(t.TEXTURE_2D)}i.unbindTexture()}else{let n=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(n=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(n,h.__webglTexture),P(n,r),r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)D(o.__webglFramebuffer[i],e,r,t.COLOR_ATTACHMENT0,n,i);else D(o.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0,n,0);g(r)&&v(n),i.unbindTexture()}e.depthBuffer&&N(e)},this.updateRenderTargetMipmap=function(t){const e=t.textures;for(let r=0,s=e.length;r<s;r++){const s=e[r];if(g(s)){const e=_(t),r=n.get(s).__webglTexture;i.bindTexture(e,r),v(e),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)if(!1===B(e)){const r=e.textures,s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const l=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=n.get(e),d=r.length>1;if(d)for(let e=0;e<r.length;e++)i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);i.bindFramebuffer(t.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let i=0;i<r.length;i++){if(e.resolveDepthBuffer&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&e.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),d){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,c.__webglColorRenderbuffer[i]);const e=n.get(r[i]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,s,a,0,0,s,a,o,t.NEAREST),!0===h&&(U.length=0,F.length=0,U.push(t.COLOR_ATTACHMENT0+i),e.depthBuffer&&!1===e.resolveDepthBuffer&&(U.push(l),F.push(l),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,F)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,U))}if(i.bindFramebuffer(t.READ_FRAMEBUFFER,null),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),d)for(let e=0;e<r.length;e++){i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c.__webglColorRenderbuffer[e]);const s=n.get(r[e]).__webglTexture;i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,s,0)}i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&h){const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[i])}},this.setupDepthRenderbuffer=N,this.setupFrameBufferTexture=D,this.useMultisampledRTT=B}function cp(t,e){return{convert:function(i,n=""){let r;const s=ui.getTransfer(n);if(i===pt)return t.UNSIGNED_BYTE;if(i===bt)return t.UNSIGNED_SHORT_4_4_4_4;if(i===wt)return t.UNSIGNED_SHORT_5_5_5_1;if(i===Mt)return t.UNSIGNED_INT_5_9_9_9_REV;if(i===mt)return t.BYTE;if(i===ft)return t.SHORT;if(i===gt)return t.UNSIGNED_SHORT;if(i===vt)return t.INT;if(i===_t)return t.UNSIGNED_INT;if(i===yt)return t.FLOAT;if(i===xt)return t.HALF_FLOAT;if(i===Tt)return t.ALPHA;if(i===Et)return t.RGB;if(i===At)return t.RGBA;if(i===Ct)return t.LUMINANCE;if(i===Rt)return t.LUMINANCE_ALPHA;if(i===Pt)return t.DEPTH_COMPONENT;if(i===Lt)return t.DEPTH_STENCIL;if(i===It)return t.RED;if(i===Dt)return t.RED_INTEGER;if(i===Ot)return t.RG;if(i===Nt)return t.RG_INTEGER;if(i===Ut)return t.RGBA_INTEGER;if(i===Ft||i===kt||i===Bt||i===zt)if(s===Ae){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(i===Ft)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===kt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Bt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===zt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(i===Ft)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===kt)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Bt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===zt)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===Gt||i===Ht||i===Vt||i===Wt){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(i===Gt)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ht)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Vt)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Wt)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===jt||i===Xt||i===Yt){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(i===jt||i===Xt)return s===Ae?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Yt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(i===qt||i===Kt||i===Zt||i===Jt||i===Qt||i===$t||i===te||i===ee||i===ie||i===ne||i===re||i===se||i===ae||i===oe){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(i===qt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Kt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Zt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Jt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Qt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===$t)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===te)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ee)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ie)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ne)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===re)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===se)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===ae)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===oe)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===he||i===le||i===ce){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(i===he)return s===Ae?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===le)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ce)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(i===de||i===ue||i===pe||i===me){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(i===he)return r.COMPRESSED_RED_RGTC1_EXT;if(i===ue)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===pe)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===me)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===St?t.UNSIGNED_INT_24_8:void 0!==t[i]?t[i]:null}}}class dp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,i){if(null===this.texture){const n=new bi;t.properties.get(n).__webglTexture=e.texture,e.depthNear===i.depthNear&&e.depthFar===i.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,i=new zr({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:e.z},depthHeight:{value:e.w}}});this.mesh=new Dr(new rh(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class up extends Ge{constructor(t,e){super();const i=this;let n=null,r=1,s=null,a="local-floor",o=1,h=null,l=null,c=null,d=null,u=null,p=null;const m=new dp,f=e.getContextAttributes();let g=null,v=null;const _=[],y=[],x=new $e;let b=null;const w=new jr;w.viewport=new wi;const S=new jr;S.viewport=new wi;const M=[w,S],T=new Nl;let E=null,A=null;function C(t){const e=y.indexOf(t.inputSource);if(-1===e)return;const i=_[e];void 0!==i&&(i.update(t.inputSource,t.frame,h||s),i.dispatchEvent({type:t.type,data:t.inputSource}))}function R(){n.removeEventListener("select",C),n.removeEventListener("selectstart",C),n.removeEventListener("selectend",C),n.removeEventListener("squeeze",C),n.removeEventListener("squeezestart",C),n.removeEventListener("squeezeend",C),n.removeEventListener("end",R),n.removeEventListener("inputsourceschange",P);for(let t=0;t<_.length;t++){const e=y[t];null!==e&&(y[t]=null,_[t].disconnect(e))}E=null,A=null,m.reset(),t.setRenderTarget(g),u=null,d=null,c=null,n=null,v=null,N.stop(),i.isPresenting=!1,t.setPixelRatio(b),t.setSize(x.width,x.height,!1),i.dispatchEvent({type:"sessionend"})}function P(t){for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=y.indexOf(i);n>=0&&(y[n]=null,_[n].disconnect(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e];let n=y.indexOf(i);if(-1===n){for(let t=0;t<_.length;t++){if(t>=y.length){y.push(i),n=t;break}if(null===y[t]){y[t]=i,n=t;break}}if(-1===n)break}const r=_[n];r&&r.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=_[t];return void 0===e&&(e=new Qr,_[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=_[t];return void 0===e&&(e=new Qr,_[t]=e),e.getGripSpace()},this.getHand=function(t){let e=_[t];return void 0===e&&(e=new Qr,_[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||s},this.setReferenceSpace=function(t){h=t},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(l){if(n=l,null!==n){g=t.getRenderTarget(),n.addEventListener("select",C),n.addEventListener("selectstart",C),n.addEventListener("selectend",C),n.addEventListener("squeeze",C),n.addEventListener("squeezestart",C),n.addEventListener("squeezeend",C),n.addEventListener("end",R),n.addEventListener("inputsourceschange",P),!0!==f.xrCompatible&&await e.makeXRCompatible(),b=t.getPixelRatio(),t.getSize(x);if("undefined"!=typeof XRWebGLBinding&&"createProjectionLayer"in XRWebGLBinding.prototype){let i=null,s=null,a=null;f.depth&&(a=f.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,i=f.stencil?Lt:Pt,s=f.stencil?St:_t);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};c=new XRWebGLBinding(n,e),d=c.createProjectionLayer(o),n.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),v=new Mi(d.textureWidth,d.textureHeight,{format:At,type:pt,depthTexture:new Va(d.textureWidth,d.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:f.stencil,colorSpace:t.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:!1===d.ignoreDepthValues})}else{const i={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(n,e,i),n.updateRenderState({baseLayer:u}),t.setPixelRatio(1),t.setSize(u.framebufferWidth,u.framebufferHeight,!1),v=new Mi(u.framebufferWidth,u.framebufferHeight,{format:At,type:pt,colorSpace:t.outputColorSpace,stencilBuffer:f.stencil})}v.isXRRenderTarget=!0,this.setFoveation(o),h=null,s=await n.requestReferenceSpace(a),N.setContext(n),N.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};const L=new Ci,I=new Ci;function D(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===n)return;let e=t.near,i=t.far;null!==m.texture&&(m.depthNear>0&&(e=m.depthNear),m.depthFar>0&&(i=m.depthFar)),T.near=S.near=w.near=e,T.far=S.far=w.far=i,E===T.near&&A===T.far||(n.updateRenderState({depthNear:T.near,depthFar:T.far}),E=T.near,A=T.far),w.layers.mask=2|t.layers.mask,S.layers.mask=4|t.layers.mask,T.layers.mask=w.layers.mask|S.layers.mask;const r=t.parent,s=T.cameras;D(T,r);for(let t=0;t<s.length;t++)D(s[t],r);2===s.length?function(t,e,i){L.setFromMatrixPosition(e.matrixWorld),I.setFromMatrixPosition(i.matrixWorld);const n=L.distanceTo(I),r=e.projectionMatrix.elements,s=i.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),h=(r[9]+1)/r[5],l=(r[9]-1)/r[5],c=(r[8]-1)/r[0],d=(s[8]+1)/s[0],u=a*c,p=a*d,m=n/(-c+d),f=m*-c;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(f),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===r[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=a+m,i=o+m,r=u-f,s=p+(n-f),c=h*o/i*e,d=l*o/i*e;t.projectionMatrix.makePerspective(r,s,c,d,e,i),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(T,w,S):T.projectionMatrix.copy(w.projectionMatrix),function(t,e,i){null===i?t.matrix.copy(e.matrixWorld):(t.matrix.copy(i.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld));t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*je*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,T,r)},this.getCamera=function(){return T},this.getFoveation=function(){if(null!==d||null!==u)return o},this.setFoveation=function(t){o=t,null!==d&&(d.fixedFoveation=t),null!==u&&void 0!==u.fixedFoveation&&(u.fixedFoveation=t)},this.hasDepthSensing=function(){return null!==m.texture},this.getDepthSensingMesh=function(){return m.getMesh(T)};let O=null;const N=new Uc;N.setAnimationLoop((function(e,r){if(l=r.getViewerPose(h||s),p=r,null!==l){const e=l.views;null!==u&&(t.setRenderTargetFramebuffer(v,u.framebuffer),t.setRenderTarget(v));let i=!1;e.length!==T.cameras.length&&(T.cameras.length=0,i=!0);for(let n=0;n<e.length;n++){const r=e[n];let s=null;if(null!==u)s=u.getViewport(r);else{const e=c.getViewSubImage(d,r);s=e.viewport,0===n&&(t.setRenderTargetTextures(v,e.colorTexture,d.ignoreDepthValues?void 0:e.depthStencilTexture),t.setRenderTarget(v))}let a=M[n];void 0===a&&(a=new jr,a.layers.enable(n),a.viewport=new wi,M[n]=a),a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(r.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(s.x,s.y,s.width,s.height),0===n&&(T.matrix.copy(a.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),!0===i&&T.cameras.push(a)}const r=n.enabledFeatures;if(r&&r.includes("depth-sensing")&&"gpu-optimized"==n.depthUsage&&c){const i=c.getDepthInformation(e[0]);i&&i.isValid&&i.texture&&m.init(t,i,n.renderState)}}for(let t=0;t<_.length;t++){const e=y[t],i=_[t];null!==e&&void 0!==i&&i.update(e,r,h||s)}O&&O(e,r),r.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:r}),p=null})),this.setAnimationLoop=function(t){O=t},this.dispose=function(){}}}const pp=new fn,mp=new sn;function fp(t,e){function i(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function n(t,n){t.opacity.value=n.opacity,n.color&&t.diffuse.value.copy(n.color),n.emissive&&t.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(t.map.value=n.map,i(n.map,t.mapTransform)),n.alphaMap&&(t.alphaMap.value=n.alphaMap,i(n.alphaMap,t.alphaMapTransform)),n.bumpMap&&(t.bumpMap.value=n.bumpMap,i(n.bumpMap,t.bumpMapTransform),t.bumpScale.value=n.bumpScale,1===n.side&&(t.bumpScale.value*=-1)),n.normalMap&&(t.normalMap.value=n.normalMap,i(n.normalMap,t.normalMapTransform),t.normalScale.value.copy(n.normalScale),1===n.side&&t.normalScale.value.negate()),n.displacementMap&&(t.displacementMap.value=n.displacementMap,i(n.displacementMap,t.displacementMapTransform),t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias),n.emissiveMap&&(t.emissiveMap.value=n.emissiveMap,i(n.emissiveMap,t.emissiveMapTransform)),n.specularMap&&(t.specularMap.value=n.specularMap,i(n.specularMap,t.specularMapTransform)),n.alphaTest>0&&(t.alphaTest.value=n.alphaTest);const r=e.get(n),s=r.envMap,a=r.envMapRotation;s&&(t.envMap.value=s,pp.copy(a),pp.x*=-1,pp.y*=-1,pp.z*=-1,s.isCubeTexture&&!1===s.isRenderTargetTexture&&(pp.y*=-1,pp.z*=-1),t.envMapRotation.value.setFromMatrix4(mp.makeRotationFromEuler(pp)),t.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,t.reflectivity.value=n.reflectivity,t.ior.value=n.ior,t.refractionRatio.value=n.refractionRatio),n.lightMap&&(t.lightMap.value=n.lightMap,t.lightMapIntensity.value=n.lightMapIntensity,i(n.lightMap,t.lightMapTransform)),n.aoMap&&(t.aoMap.value=n.aoMap,t.aoMapIntensity.value=n.aoMapIntensity,i(n.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,i){i.color.getRGB(e.fogColor.value,kr(t)),i.isFog?(e.fogNear.value=i.near,e.fogFar.value=i.far):i.isFogExp2&&(e.fogDensity.value=i.density)},refreshMaterialUniforms:function(t,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?n(t,r):r.isMeshToonMaterial?(n(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(n(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(n(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,i(e.metalnessMap,t.metalnessMapTransform));t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,i(e.roughnessMap,t.roughnessMapTransform));e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,n){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,i(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,i(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,i(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,i(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,i(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),1===e.side&&t.clearcoatNormalScale.value.negate()));e.dispersion>0&&(t.dispersion.value=e.dispersion);e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,i(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,i(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,i(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,i(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,i(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,i(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,i(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(n(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?n(t,r):r.isMeshDistanceMaterial?(n(t,r),function(t,i){const n=e.get(i).light;t.referencePosition.value.setFromMatrixPosition(n.matrixWorld),t.nearDistance.value=n.shadow.camera.near,t.farDistance.value=n.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?n(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,n,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*r,e.map&&(t.map.value=e.map,i(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,a):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function gp(t,e,i,n){let r={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function h(t,e,i,n){const r=t.value,s=e+"_"+i;if(void 0===n[s])return n[s]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const t=n[s];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return n[s]=r,!0}else if(!1===t.equals(r))return t.copy(r),!0}return!1}function l(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),e}function c(e){const i=e.target;i.removeEventListener("dispose",c);const n=a.indexOf(i.__bindingPointIndex);a.splice(n,1),t.deleteBuffer(r[i.id]),delete r[i.id],delete s[i.id]}return{bind:function(t,e){const i=e.program;n.uniformBlockBinding(t,i)},update:function(i,d){let u=r[i.id];void 0===u&&(!function(t){const e=t.uniforms;let i=0;const n=16;for(let t=0,r=e.length;t<r;t++){const r=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=r.length;t<e;t++){const e=r[t],s=Array.isArray(e.value)?e.value:[e.value];for(let t=0,r=s.length;t<r;t++){const r=l(s[t]),a=i%n,o=a%r.boundary,h=a+o;i+=o,0!==h&&n-h<r.storage&&(i+=n-h),e.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=i,i+=r.storage}}}const r=i%n;r>0&&(i+=n-r);t.__size=i,t.__cache={}}(i),u=function(e){const i=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=i;const n=t.createBuffer(),r=e.__size,s=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,r,s),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,i,n),n}(i),r[i.id]=u,i.addEventListener("dispose",c));const p=d.program;n.updateUBOMapping(i,p);const m=e.render.frame;s[i.id]!==m&&(!function(e){const i=r[e.id],n=e.uniforms,s=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,i);for(let e=0,i=n.length;e<i;e++){const i=Array.isArray(n[e])?n[e]:[n[e]];for(let n=0,r=i.length;n<r;n++){const r=i[n];if(!0===h(r,e,n,s)){const e=r.__offset,i=Array.isArray(r.value)?r.value:[r.value];let n=0;for(let s=0;s<i.length;s++){const a=i[s],o=l(a);"number"==typeof a||"boolean"==typeof a?(r.__data[0]=a,t.bufferSubData(t.UNIFORM_BUFFER,e+n,r.__data)):a.isMatrix3?(r.__data[0]=a.elements[0],r.__data[1]=a.elements[1],r.__data[2]=a.elements[2],r.__data[3]=0,r.__data[4]=a.elements[3],r.__data[5]=a.elements[4],r.__data[6]=a.elements[5],r.__data[7]=0,r.__data[8]=a.elements[6],r.__data[9]=a.elements[7],r.__data[10]=a.elements[8],r.__data[11]=0):(a.toArray(r.__data,n),n+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,r.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(i),s[i.id]=m)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);a=[],r={},s={}}}}class vp{constructor(t={}){const{canvas:e=ai(),context:i=null,depth:n=!0,stencil:r=!1,alpha:s=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:h=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:c=!1,reverseDepthBuffer:d=!1}=t;let u;if(this.isWebGLRenderer=!0,null!==i){if("undefined"!=typeof WebGLRenderingContext&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");u=i.getContextAttributes().alpha}else u=s;const p=new Uint32Array(4),m=new Int32Array(4);let f=null,g=null;const v=[],y=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Me,this.toneMapping=0,this.toneMappingExposure=1;const x=this;let b=!1,w=0,S=0,M=null,T=-1,E=null;const A=new wi,C=new wi;let R=null;const P=new Jn(0);let L=0,I=e.width,D=e.height,O=1,N=null,U=null;const F=new wi(0,0,I,D),k=new wi(0,0,I,D);let B=!1;const z=new ta;let G=!1,H=!1;this.transmissionResolutionScale=1;const V=new sn,W=new sn,j=new Ci,X=new wi,Y={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let q=!1;function K(){return null===M?O:1}let Z,J,Q,$,tt,et,it,nt,rt,st,at,ot,ht,lt,ct,dt,mt,ft,vt,yt,Mt,Tt,Et,At,Ct=i;function Rt(t,i){return e.getContext(t,i)}try{const t={alpha:!0,depth:n,stencil:r,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:h,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${_}`),e.addEventListener("webglcontextlost",It,!1),e.addEventListener("webglcontextrestored",Ot,!1),e.addEventListener("webglcontextcreationerror",Ft,!1),null===Ct){const e="webgl2";if(Ct=Rt(e,t),null===Ct)throw Rt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function Pt(){Z=new md(Ct),Z.init(),Tt=new cp(Ct,Z),J=new Yc(Ct,Z,t,Tt),Q=new hp(Ct,Z),J.reverseDepthBuffer&&d&&Q.buffers.depth.setReversed(!0),$=new vd(Ct),tt=new Ku,et=new lp(Ct,Z,Q,tt,J,Tt,$),it=new Kc(x),nt=new pd(x),rt=new Fc(Ct),Et=new jc(Ct,rt),st=new fd(Ct,rt,$,Et),at=new yd(Ct,st,rt,$),vt=new _d(Ct,J,et),dt=new qc(tt),ot=new qu(x,it,nt,Z,J,Et,dt),ht=new fp(x,tt),lt=new $u,ct=new sp(Z),ft=new Wc(x,it,nt,Q,at,u,o),mt=new ap(x,at,J),At=new gp(Ct,$,J,Q),yt=new Xc(Ct,Z,$),Mt=new gd(Ct,Z,$),$.programs=ot.programs,x.capabilities=J,x.extensions=Z,x.properties=tt,x.renderLists=lt,x.shadowMap=mt,x.state=Q,x.info=$}Pt();const Lt=new up(x,Ct);function It(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function Ot(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;const t=$.autoReset,e=mt.enabled,i=mt.autoUpdate,n=mt.needsUpdate,r=mt.type;Pt(),$.autoReset=t,mt.enabled=e,mt.autoUpdate=i,mt.needsUpdate=n,mt.type=r}function Ft(t){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function kt(t){const e=t.target;e.removeEventListener("dispose",kt),function(t){(function(t){const e=tt.get(t).programs;void 0!==e&&(e.forEach((function(t){ot.releaseProgram(t)})),t.isShaderMaterial&&ot.releaseShaderCache(t))})(t),tt.remove(t)}(e)}function Bt(t,e,i){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,Kt(t,e,i),t.side=0,t.needsUpdate=!0,Kt(t,e,i),t.side=2):Kt(t,e,i)}this.xr=Lt,this.getContext=function(){return Ct},this.getContextAttributes=function(){return Ct.getContextAttributes()},this.forceContextLoss=function(){const t=Z.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=Z.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return O},this.setPixelRatio=function(t){void 0!==t&&(O=t,this.setSize(I,D,!1))},this.getSize=function(t){return t.set(I,D)},this.setSize=function(t,i,n=!0){Lt.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(I=t,D=i,e.width=Math.floor(t*O),e.height=Math.floor(i*O),!0===n&&(e.style.width=t+"px",e.style.height=i+"px"),this.setViewport(0,0,t,i))},this.getDrawingBufferSize=function(t){return t.set(I*O,D*O).floor()},this.setDrawingBufferSize=function(t,i,n){I=t,D=i,O=n,e.width=Math.floor(t*n),e.height=Math.floor(i*n),this.setViewport(0,0,t,i)},this.getCurrentViewport=function(t){return t.copy(A)},this.getViewport=function(t){return t.copy(F)},this.setViewport=function(t,e,i,n){t.isVector4?F.set(t.x,t.y,t.z,t.w):F.set(t,e,i,n),Q.viewport(A.copy(F).multiplyScalar(O).round())},this.getScissor=function(t){return t.copy(k)},this.setScissor=function(t,e,i,n){t.isVector4?k.set(t.x,t.y,t.z,t.w):k.set(t,e,i,n),Q.scissor(C.copy(k).multiplyScalar(O).round())},this.getScissorTest=function(){return B},this.setScissorTest=function(t){Q.setScissorTest(B=t)},this.setOpaqueSort=function(t){N=t},this.setTransparentSort=function(t){U=t},this.getClearColor=function(t){return t.copy(ft.getClearColor())},this.setClearColor=function(){ft.setClearColor.apply(ft,arguments)},this.getClearAlpha=function(){return ft.getClearAlpha()},this.setClearAlpha=function(){ft.setClearAlpha.apply(ft,arguments)},this.clear=function(t=!0,e=!0,i=!0){let n=0;if(t){let t=!1;if(null!==M){const e=M.texture.format;t=e===Ut||e===Nt||e===Dt}if(t){const t=M.texture.type,e=t===pt||t===_t||t===gt||t===St||t===bt||t===wt,i=ft.getClearColor(),n=ft.getClearAlpha(),r=i.r,s=i.g,a=i.b;e?(p[0]=r,p[1]=s,p[2]=a,p[3]=n,Ct.clearBufferuiv(Ct.COLOR,0,p)):(m[0]=r,m[1]=s,m[2]=a,m[3]=n,Ct.clearBufferiv(Ct.COLOR,0,m))}else n|=Ct.COLOR_BUFFER_BIT}e&&(n|=Ct.DEPTH_BUFFER_BIT),i&&(n|=Ct.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Ct.clear(n)},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(){e.removeEventListener("webglcontextlost",It,!1),e.removeEventListener("webglcontextrestored",Ot,!1),e.removeEventListener("webglcontextcreationerror",Ft,!1),ft.dispose(),lt.dispose(),ct.dispose(),tt.dispose(),it.dispose(),nt.dispose(),at.dispose(),Et.dispose(),At.dispose(),ot.dispose(),Lt.dispose(),Lt.removeEventListener("sessionstart",Gt),Lt.removeEventListener("sessionend",Ht),Vt.stop()},this.renderBufferDirect=function(t,e,i,n,r,s){null===e&&(e=Y);const a=r.isMesh&&r.matrixWorld.determinant()<0,o=function(t,e,i,n,r){!0!==e.isScene&&(e=Y);et.resetTextureUnits();const s=e.fog,a=n.isMeshStandardMaterial?e.environment:null,o=null===M?x.outputColorSpace:!0===M.isXRRenderTarget?M.texture.colorSpace:Te,h=(n.isMeshStandardMaterial?nt:it).get(n.envMap||a),l=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,c=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),d=!!i.morphAttributes.position,u=!!i.morphAttributes.normal,p=!!i.morphAttributes.color;let m=0;n.toneMapped&&(null!==M&&!0!==M.isXRRenderTarget||(m=x.toneMapping));const f=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,v=void 0!==f?f.length:0,_=tt.get(n),y=g.state.lights;if(!0===G&&(!0===H||t!==E)){const e=t===E&&n.id===T;dt.setState(n,t,e)}let b=!1;n.version===_.__version?_.needsLights&&_.lightsStateVersion!==y.state.version||_.outputColorSpace!==o||r.isBatchedMesh&&!1===_.batching?b=!0:r.isBatchedMesh||!0!==_.batching?r.isBatchedMesh&&!0===_.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===_.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===_.instancing?b=!0:r.isInstancedMesh||!0!==_.instancing?r.isSkinnedMesh&&!1===_.skinning?b=!0:r.isSkinnedMesh||!0!==_.skinning?r.isInstancedMesh&&!0===_.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===_.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===_.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===_.instancingMorph&&null!==r.morphTexture||_.envMap!==h||!0===n.fog&&_.fog!==s?b=!0:void 0===_.numClippingPlanes||_.numClippingPlanes===dt.numPlanes&&_.numIntersection===dt.numIntersection?(_.vertexAlphas!==l||_.vertexTangents!==c||_.morphTargets!==d||_.morphNormals!==u||_.morphColors!==p||_.toneMapping!==m||_.morphTargetsCount!==v)&&(b=!0):b=!0:b=!0:b=!0:b=!0:(b=!0,_.__version=n.version);let w=_.currentProgram;!0===b&&(w=Kt(n,e,r));let S=!1,A=!1,C=!1;const R=w.getUniforms(),P=_.uniforms;Q.useProgram(w.program)&&(S=!0,A=!0,C=!0);n.id!==T&&(T=n.id,A=!0);if(S||E!==t){Q.buffers.depth.getReversed()?(V.copy(t.projectionMatrix),function(t){const e=t.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}(V),function(t){const e=t.elements;-1===e[11]?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=1-e[14])}(V),R.setValue(Ct,"projectionMatrix",V)):R.setValue(Ct,"projectionMatrix",t.projectionMatrix),R.setValue(Ct,"viewMatrix",t.matrixWorldInverse);const e=R.map.cameraPosition;void 0!==e&&e.setValue(Ct,j.setFromMatrixPosition(t.matrixWorld)),J.logarithmicDepthBuffer&&R.setValue(Ct,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&R.setValue(Ct,"isOrthographic",!0===t.isOrthographicCamera),E!==t&&(E=t,A=!0,C=!0)}if(r.isSkinnedMesh){R.setOptional(Ct,r,"bindMatrix"),R.setOptional(Ct,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),R.setValue(Ct,"boneTexture",t.boneTexture,et))}r.isBatchedMesh&&(R.setOptional(Ct,r,"batchingTexture"),R.setValue(Ct,"batchingTexture",r._matricesTexture,et),R.setOptional(Ct,r,"batchingIdTexture"),R.setValue(Ct,"batchingIdTexture",r._indirectTexture,et),R.setOptional(Ct,r,"batchingColorTexture"),null!==r._colorsTexture&&R.setValue(Ct,"batchingColorTexture",r._colorsTexture,et));const L=i.morphAttributes;void 0===L.position&&void 0===L.normal&&void 0===L.color||vt.update(r,i,w);(A||_.receiveShadow!==r.receiveShadow)&&(_.receiveShadow=r.receiveShadow,R.setValue(Ct,"receiveShadow",r.receiveShadow));n.isMeshGouraudMaterial&&null!==n.envMap&&(P.envMap.value=h,P.flipEnvMap.value=h.isCubeTexture&&!1===h.isRenderTargetTexture?-1:1);n.isMeshStandardMaterial&&null===n.envMap&&null!==e.environment&&(P.envMapIntensity.value=e.environmentIntensity);A&&(R.setValue(Ct,"toneMappingExposure",x.toneMappingExposure),_.needsLights&&(N=C,(I=P).ambientLightColor.needsUpdate=N,I.lightProbe.needsUpdate=N,I.directionalLights.needsUpdate=N,I.directionalLightShadows.needsUpdate=N,I.pointLights.needsUpdate=N,I.pointLightShadows.needsUpdate=N,I.spotLights.needsUpdate=N,I.spotLightShadows.needsUpdate=N,I.rectAreaLights.needsUpdate=N,I.hemisphereLights.needsUpdate=N),s&&!0===n.fog&&ht.refreshFogUniforms(P,s),ht.refreshMaterialUniforms(P,n,O,D,g.state.transmissionRenderTarget[t.id]),Mu.upload(Ct,Zt(_),P,et));var I,N;n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Mu.upload(Ct,Zt(_),P,et),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&R.setValue(Ct,"center",r.center);if(R.setValue(Ct,"modelViewMatrix",r.modelViewMatrix),R.setValue(Ct,"normalMatrix",r.normalMatrix),R.setValue(Ct,"modelMatrix",r.matrixWorld),n.isShaderMaterial||n.isRawShaderMaterial){const t=n.uniformsGroups;for(let e=0,i=t.length;e<i;e++){const i=t[e];At.update(i,w),At.bind(i,w)}}return w}(t,e,i,n,r);Q.setMaterial(n,a);let h=i.index,l=1;if(!0===n.wireframe){if(h=st.getWireframeAttribute(i),void 0===h)return;l=2}const c=i.drawRange,d=i.attributes.position;let u=c.start*l,p=(c.start+c.count)*l;null!==s&&(u=Math.max(u,s.start*l),p=Math.min(p,(s.start+s.count)*l)),null!==h?(u=Math.max(u,0),p=Math.min(p,h.count)):null!=d&&(u=Math.max(u,0),p=Math.min(p,d.count));const m=p-u;if(m<0||m===1/0)return;let f;Et.setup(r,n,o,i,h);let v=yt;if(null!==h&&(f=rt.get(h),v=Mt,v.setIndex(f)),r.isMesh)!0===n.wireframe?(Q.setLineWidth(n.wireframeLinewidth*K()),v.setMode(Ct.LINES)):v.setMode(Ct.TRIANGLES);else if(r.isLine){let t=n.linewidth;void 0===t&&(t=1),Q.setLineWidth(t*K()),r.isLineSegments?v.setMode(Ct.LINES):r.isLineLoop?v.setMode(Ct.LINE_LOOP):v.setMode(Ct.LINE_STRIP)}else r.isPoints?v.setMode(Ct.POINTS):r.isSprite&&v.setMode(Ct.TRIANGLES);if(r.isBatchedMesh)if(null!==r._multiDrawInstances)v.renderMultiDrawInstances(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount,r._multiDrawInstances);else if(Z.get("WEBGL_multi_draw"))v.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const t=r._multiDrawStarts,e=r._multiDrawCounts,i=r._multiDrawCount,s=h?rt.get(h).bytesPerElement:1,a=tt.get(n).currentProgram.getUniforms();for(let n=0;n<i;n++)a.setValue(Ct,"_gl_DrawID",n),v.render(t[n]/s,e[n])}else if(r.isInstancedMesh)v.renderInstances(u,m,r.count);else if(i.isInstancedBufferGeometry){const t=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,e=Math.min(i.instanceCount,t);v.renderInstances(u,m,e)}else v.render(u,m)},this.compile=function(t,e,i=null){null===i&&(i=t),g=ct.get(i),g.init(e),y.push(g),i.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))})),t!==i&&t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))})),g.setupLights();const n=new Set;return t.traverse((function(t){if(!(t.isMesh||t.isPoints||t.isLine||t.isSprite))return;const e=t.material;if(e)if(Array.isArray(e))for(let r=0;r<e.length;r++){const s=e[r];Bt(s,i,t),n.add(s)}else Bt(e,i,t),n.add(e)})),y.pop(),g=null,n},this.compileAsync=function(t,e,i=null){const n=this.compile(t,e,i);return new Promise((e=>{function i(){n.forEach((function(t){tt.get(t).currentProgram.isReady()&&n.delete(t)})),0!==n.size?setTimeout(i,10):e(t)}null!==Z.get("KHR_parallel_shader_compile")?i():setTimeout(i,10)}))};let zt=null;function Gt(){Vt.stop()}function Ht(){Vt.start()}const Vt=new Uc;function Wt(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)g.pushLight(t),t.castShadow&&g.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||z.intersectsSprite(t)){n&&X.setFromMatrixPosition(t.matrixWorld).applyMatrix4(W);const e=at.update(t),r=t.material;r.visible&&f.push(t,e,r,i,X.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||z.intersectsObject(t))){const e=at.update(t),r=t.material;if(n&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),X.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),X.copy(e.boundingSphere.center)),X.applyMatrix4(t.matrixWorld).applyMatrix4(W)),Array.isArray(r)){const n=e.groups;for(let s=0,a=n.length;s<a;s++){const a=n[s],o=r[a.materialIndex];o&&o.visible&&f.push(t,e,o,i,X.z,a)}}else r.visible&&f.push(t,e,r,i,X.z,null)}const r=t.children;for(let t=0,s=r.length;t<s;t++)Wt(r[t],e,i,n)}function jt(t,e,i,n){const r=t.opaque,s=t.transmissive,a=t.transparent;g.setupLightsView(i),!0===G&&dt.setGlobalState(x.clippingPlanes,i),n&&Q.viewport(A.copy(n)),r.length>0&&Yt(r,e,i),s.length>0&&Yt(s,e,i),a.length>0&&Yt(a,e,i),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function Xt(t,e,i,n){if(null!==(!0===i.isScene?i.overrideMaterial:null))return;void 0===g.state.transmissionRenderTarget[n.id]&&(g.state.transmissionRenderTarget[n.id]=new Mi(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")||Z.has("EXT_color_buffer_float")?xt:pt,minFilter:ut,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ui.workingColorSpace}));const s=g.state.transmissionRenderTarget[n.id],a=n.viewport||A;s.setSize(a.z*x.transmissionResolutionScale,a.w*x.transmissionResolutionScale);const o=x.getRenderTarget();x.setRenderTarget(s),x.getClearColor(P),L=x.getClearAlpha(),L<1&&x.setClearColor(16777215,.5),x.clear(),q&&ft.render(i);const h=x.toneMapping;x.toneMapping=0;const l=n.viewport;if(void 0!==n.viewport&&(n.viewport=void 0),g.setupLightsView(n),!0===G&&dt.setGlobalState(x.clippingPlanes,n),Yt(t,i,n),et.updateMultisampleRenderTarget(s),et.updateRenderTargetMipmap(s),!1===Z.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,s=e.length;r<s;r++){const s=e[r],a=s.object,o=s.geometry,h=s.material,l=s.group;if(2===h.side&&a.layers.test(n.layers)){const e=h.side;h.side=1,h.needsUpdate=!0,qt(a,i,n,o,h,l),h.side=e,h.needsUpdate=!0,t=!0}}!0===t&&(et.updateMultisampleRenderTarget(s),et.updateRenderTargetMipmap(s))}x.setRenderTarget(o),x.setClearColor(P,L),void 0!==l&&(n.viewport=l),x.toneMapping=h}function Yt(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let r=0,s=t.length;r<s;r++){const s=t[r],a=s.object,o=s.geometry,h=null===n?s.material:n,l=s.group;a.layers.test(i.layers)&&qt(a,e,i,o,h,l)}}function qt(t,e,i,n,r,s){t.onBeforeRender(x,e,i,n,r,s),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),r.onBeforeRender(x,e,i,n,t,s),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,x.renderBufferDirect(i,e,n,r,t,s),r.side=0,r.needsUpdate=!0,x.renderBufferDirect(i,e,n,r,t,s),r.side=2):x.renderBufferDirect(i,e,n,r,t,s),t.onAfterRender(x,e,i,n,r,s)}function Kt(t,e,i){!0!==e.isScene&&(e=Y);const n=tt.get(t),r=g.state.lights,s=g.state.shadowsArray,a=r.state.version,o=ot.getParameters(t,r.state,s,e,i),h=ot.getProgramCacheKey(o);let l=n.programs;n.environment=t.isMeshStandardMaterial?e.environment:null,n.fog=e.fog,n.envMap=(t.isMeshStandardMaterial?nt:it).get(t.envMap||n.environment),n.envMapRotation=null!==n.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===l&&(t.addEventListener("dispose",kt),l=new Map,n.programs=l);let c=l.get(h);if(void 0!==c){if(n.currentProgram===c&&n.lightsStateVersion===a)return Jt(t,o),c}else o.uniforms=ot.getUniforms(t),t.onBeforeCompile(o,x),c=ot.acquireProgram(o,h),l.set(h,c),n.uniforms=o.uniforms;const d=n.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(d.clippingPlanes=dt.uniform),Jt(t,o),n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=a,n.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),n.currentProgram=c,n.uniformsList=null,c}function Zt(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=Mu.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function Jt(t,e){const i=tt.get(t);i.outputColorSpace=e.outputColorSpace,i.batching=e.batching,i.batchingColor=e.batchingColor,i.instancing=e.instancing,i.instancingColor=e.instancingColor,i.instancingMorph=e.instancingMorph,i.skinning=e.skinning,i.morphTargets=e.morphTargets,i.morphNormals=e.morphNormals,i.morphColors=e.morphColors,i.morphTargetsCount=e.morphTargetsCount,i.numClippingPlanes=e.numClippingPlanes,i.numIntersection=e.numClipIntersection,i.vertexAlphas=e.vertexAlphas,i.vertexTangents=e.vertexTangents,i.toneMapping=e.toneMapping}Vt.setAnimationLoop((function(t){zt&&zt(t)})),"undefined"!=typeof self&&Vt.setContext(self),this.setAnimationLoop=function(t){zt=t,Lt.setAnimationLoop(t),null===t?Vt.stop():Vt.start()},Lt.addEventListener("sessionstart",Gt),Lt.addEventListener("sessionend",Ht),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===b)return;if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===Lt.enabled&&!0===Lt.isPresenting&&(!0===Lt.cameraAutoUpdate&&Lt.updateCamera(e),e=Lt.getCamera()),!0===t.isScene&&t.onBeforeRender(x,t,e,M),g=ct.get(t,y.length),g.init(e),y.push(g),W.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),z.setFromProjectionMatrix(W),H=this.localClippingEnabled,G=dt.init(this.clippingPlanes,H),f=lt.get(t,v.length),f.init(),v.push(f),!0===Lt.enabled&&!0===Lt.isPresenting){const t=x.xr.getDepthSensingMesh();null!==t&&Wt(t,e,-1/0,x.sortObjects)}Wt(t,e,0,x.sortObjects),f.finish(),!0===x.sortObjects&&f.sort(N,U),q=!1===Lt.enabled||!1===Lt.isPresenting||!1===Lt.hasDepthSensing(),q&&ft.addToRenderList(f,t),this.info.render.frame++,!0===G&&dt.beginShadows();const i=g.state.shadowsArray;mt.render(i,t,e),!0===G&&dt.endShadows(),!0===this.info.autoReset&&this.info.reset();const n=f.opaque,r=f.transmissive;if(g.setupLights(),e.isArrayCamera){const i=e.cameras;if(r.length>0)for(let e=0,s=i.length;e<s;e++){Xt(n,r,t,i[e])}q&&ft.render(t);for(let e=0,n=i.length;e<n;e++){const n=i[e];jt(f,t,n,n.viewport)}}else r.length>0&&Xt(n,r,t,e),q&&ft.render(t),jt(f,t,e);null!==M&&0===S&&(et.updateMultisampleRenderTarget(M),et.updateRenderTargetMipmap(M)),!0===t.isScene&&t.onAfterRender(x,t,e),Et.resetDefaultState(),T=-1,E=null,y.pop(),y.length>0?(g=y[y.length-1],!0===G&&dt.setGlobalState(x.clippingPlanes,g.state.camera)):g=null,v.pop(),f=v.length>0?v[v.length-1]:null},this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return S},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(t,e,i){tt.get(t.texture).__webglTexture=e,tt.get(t.depthTexture).__webglTexture=i;const n=tt.get(t);n.__hasExternalTextures=!0,n.__autoAllocateDepthBuffer=void 0===i,n.__autoAllocateDepthBuffer||!0===Z.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),n.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(t,e){const i=tt.get(t);i.__webglFramebuffer=e,i.__useDefaultFramebuffer=void 0===e};const Qt=Ct.createFramebuffer();this.setRenderTarget=function(t,e=0,i=0){M=t,w=e,S=i;let n=!0,r=null,s=!1,a=!1;if(t){const o=tt.get(t);if(void 0!==o.__useDefaultFramebuffer)Q.bindFramebuffer(Ct.FRAMEBUFFER,null),n=!1;else if(void 0===o.__webglFramebuffer)et.setupRenderTarget(t);else if(o.__hasExternalTextures)et.rebindTextures(t,tt.get(t.texture).__webglTexture,tt.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(o.__boundDepthTexture!==e){if(null!==e&&tt.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");et.setupDepthRenderbuffer(t)}}const h=t.texture;(h.isData3DTexture||h.isDataArrayTexture||h.isCompressedArrayTexture)&&(a=!0);const l=tt.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=Array.isArray(l[e])?l[e][i]:l[e],s=!0):r=t.samples>0&&!1===et.useMultisampledRTT(t)?tt.get(t).__webglMultisampledFramebuffer:Array.isArray(l)?l[i]:l,A.copy(t.viewport),C.copy(t.scissor),R=t.scissorTest}else A.copy(F).multiplyScalar(O).floor(),C.copy(k).multiplyScalar(O).floor(),R=B;0!==i&&(r=Qt);if(Q.bindFramebuffer(Ct.FRAMEBUFFER,r)&&n&&Q.drawBuffers(t,r),Q.viewport(A),Q.scissor(C),Q.setScissorTest(R),s){const n=tt.get(t.texture);Ct.framebufferTexture2D(Ct.FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.__webglTexture,i)}else if(a){const n=tt.get(t.texture),r=e;Ct.framebufferTextureLayer(Ct.FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,n.__webglTexture,i,r)}else if(null!==t&&0!==i){const e=tt.get(t.texture);Ct.framebufferTexture2D(Ct.FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_2D,e.__webglTexture,i)}T=-1},this.readRenderTargetPixels=function(t,e,i,n,r,s,a){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=tt.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){Q.bindFramebuffer(Ct.FRAMEBUFFER,o);try{const a=t.texture,o=a.format,h=a.type;if(!J.textureFormatReadable(o))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!J.textureTypeReadable(h))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&Ct.readPixels(e,i,n,r,Tt.convert(o),Tt.convert(h),s)}finally{const t=null!==M?tt.get(M).__webglFramebuffer:null;Q.bindFramebuffer(Ct.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,i,n,r,s,a){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=tt.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){const a=t.texture,h=a.format,l=a.type;if(!J.textureFormatReadable(h))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!J.textureTypeReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r){Q.bindFramebuffer(Ct.FRAMEBUFFER,o);const t=Ct.createBuffer();Ct.bindBuffer(Ct.PIXEL_PACK_BUFFER,t),Ct.bufferData(Ct.PIXEL_PACK_BUFFER,s.byteLength,Ct.STREAM_READ),Ct.readPixels(e,i,n,r,Tt.convert(h),Tt.convert(l),0);const a=null!==M?tt.get(M).__webglFramebuffer:null;Q.bindFramebuffer(Ct.FRAMEBUFFER,a);const c=Ct.fenceSync(Ct.SYNC_GPU_COMMANDS_COMPLETE,0);return Ct.flush(),await function(t,e,i){return new Promise((function(n,r){setTimeout((function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(s,i);break;default:n()}}),i)}))}(Ct,c,4),Ct.bindBuffer(Ct.PIXEL_PACK_BUFFER,t),Ct.getBufferSubData(Ct.PIXEL_PACK_BUFFER,0,s),Ct.deleteBuffer(t),Ct.deleteSync(c),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,i=0){!0!==t.isTexture&&(hi("WebGLRenderer: copyFramebufferToTexture function signature has changed."),e=arguments[0]||null,t=arguments[1]);const n=Math.pow(2,-i),r=Math.floor(t.image.width*n),s=Math.floor(t.image.height*n),a=null!==e?e.x:0,o=null!==e?e.y:0;et.setTexture2D(t,0),Ct.copyTexSubImage2D(Ct.TEXTURE_2D,i,0,0,a,o,r,s),Q.unbindTexture()};const $t=Ct.createFramebuffer(),te=Ct.createFramebuffer();this.copyTextureToTexture=function(t,e,i=null,n=null,r=0,s=null){let a,o,h,l,c,d,u,p,m;!0!==t.isTexture&&(hi("WebGLRenderer: copyTextureToTexture function signature has changed."),n=arguments[0]||null,t=arguments[1],e=arguments[2],s=arguments[3]||0,i=null),null===s&&(0!==r?(hi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),s=r,r=0):s=0);const f=t.isCompressedTexture?t.mipmaps[s]:t.image;if(null!==i)a=i.max.x-i.min.x,o=i.max.y-i.min.y,h=i.isBox3?i.max.z-i.min.z:1,l=i.min.x,c=i.min.y,d=i.isBox3?i.min.z:0;else{const e=Math.pow(2,-r);a=Math.floor(f.width*e),o=Math.floor(f.height*e),h=t.isDataArrayTexture?f.depth:t.isData3DTexture?Math.floor(f.depth*e):1,l=0,c=0,d=0}null!==n?(u=n.x,p=n.y,m=n.z):(u=0,p=0,m=0);const g=Tt.convert(e.format),v=Tt.convert(e.type);let _;e.isData3DTexture?(et.setTexture3D(e,0),_=Ct.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(et.setTexture2DArray(e,0),_=Ct.TEXTURE_2D_ARRAY):(et.setTexture2D(e,0),_=Ct.TEXTURE_2D),Ct.pixelStorei(Ct.UNPACK_FLIP_Y_WEBGL,e.flipY),Ct.pixelStorei(Ct.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),Ct.pixelStorei(Ct.UNPACK_ALIGNMENT,e.unpackAlignment);const y=Ct.getParameter(Ct.UNPACK_ROW_LENGTH),x=Ct.getParameter(Ct.UNPACK_IMAGE_HEIGHT),b=Ct.getParameter(Ct.UNPACK_SKIP_PIXELS),w=Ct.getParameter(Ct.UNPACK_SKIP_ROWS),S=Ct.getParameter(Ct.UNPACK_SKIP_IMAGES);Ct.pixelStorei(Ct.UNPACK_ROW_LENGTH,f.width),Ct.pixelStorei(Ct.UNPACK_IMAGE_HEIGHT,f.height),Ct.pixelStorei(Ct.UNPACK_SKIP_PIXELS,l),Ct.pixelStorei(Ct.UNPACK_SKIP_ROWS,c),Ct.pixelStorei(Ct.UNPACK_SKIP_IMAGES,d);const M=t.isDataArrayTexture||t.isData3DTexture,T=e.isDataArrayTexture||e.isData3DTexture;if(t.isDepthTexture){const i=tt.get(t),n=tt.get(e),f=tt.get(i.__renderTarget),g=tt.get(n.__renderTarget);Q.bindFramebuffer(Ct.READ_FRAMEBUFFER,f.__webglFramebuffer),Q.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let i=0;i<h;i++)M&&(Ct.framebufferTextureLayer(Ct.READ_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,tt.get(t).__webglTexture,r,d+i),Ct.framebufferTextureLayer(Ct.DRAW_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,tt.get(e).__webglTexture,s,m+i)),Ct.blitFramebuffer(l,c,a,o,u,p,a,o,Ct.DEPTH_BUFFER_BIT,Ct.NEAREST);Q.bindFramebuffer(Ct.READ_FRAMEBUFFER,null),Q.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,null)}else if(0!==r||t.isRenderTargetTexture||tt.has(t)){const i=tt.get(t),n=tt.get(e);Q.bindFramebuffer(Ct.READ_FRAMEBUFFER,$t),Q.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,te);for(let t=0;t<h;t++)M?Ct.framebufferTextureLayer(Ct.READ_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,i.__webglTexture,r,d+t):Ct.framebufferTexture2D(Ct.READ_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_2D,i.__webglTexture,r),T?Ct.framebufferTextureLayer(Ct.DRAW_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,n.__webglTexture,s,m+t):Ct.framebufferTexture2D(Ct.DRAW_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_2D,n.__webglTexture,s),0!==r?Ct.blitFramebuffer(l,c,a,o,u,p,a,o,Ct.COLOR_BUFFER_BIT,Ct.NEAREST):T?Ct.copyTexSubImage3D(_,s,u,p,m+t,l,c,a,o):Ct.copyTexSubImage2D(_,s,u,p,l,c,a,o);Q.bindFramebuffer(Ct.READ_FRAMEBUFFER,null),Q.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,null)}else T?t.isDataTexture||t.isData3DTexture?Ct.texSubImage3D(_,s,u,p,m,a,o,h,g,v,f.data):e.isCompressedArrayTexture?Ct.compressedTexSubImage3D(_,s,u,p,m,a,o,h,g,f.data):Ct.texSubImage3D(_,s,u,p,m,a,o,h,g,v,f):t.isDataTexture?Ct.texSubImage2D(Ct.TEXTURE_2D,s,u,p,a,o,g,v,f.data):t.isCompressedTexture?Ct.compressedTexSubImage2D(Ct.TEXTURE_2D,s,u,p,f.width,f.height,g,f.data):Ct.texSubImage2D(Ct.TEXTURE_2D,s,u,p,a,o,g,v,f);Ct.pixelStorei(Ct.UNPACK_ROW_LENGTH,y),Ct.pixelStorei(Ct.UNPACK_IMAGE_HEIGHT,x),Ct.pixelStorei(Ct.UNPACK_SKIP_PIXELS,b),Ct.pixelStorei(Ct.UNPACK_SKIP_ROWS,w),Ct.pixelStorei(Ct.UNPACK_SKIP_IMAGES,S),0===s&&e.generateMipmaps&&Ct.generateMipmap(_),Q.unbindTexture()},this.copyTextureToTexture3D=function(t,e,i=null,n=null,r=0){return!0!==t.isTexture&&(hi("WebGLRenderer: copyTextureToTexture3D function signature has changed."),i=arguments[0]||null,n=arguments[1]||null,t=arguments[2],e=arguments[3],r=arguments[4]||0),hi('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(t,e,i,n,r)},this.initRenderTarget=function(t){void 0===tt.get(t).__webglFramebuffer&&et.setupRenderTarget(t)},this.initTexture=function(t){t.isCubeTexture?et.setTextureCube(t,0):t.isData3DTexture?et.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?et.setTexture2DArray(t,0):et.setTexture2D(t,0),Q.unbindTexture()},this.resetState=function(){w=0,S=0,M=null,Q.reset(),Et.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Be}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorspace=ui._getDrawingBufferColorSpace(t),e.unpackColorSpace=ui._getUnpackColorSpace()}}var _p=Object.freeze({__proto__:null,ACESFilmicToneMapping:4,AddEquation:M,AddOperation:2,AdditiveAnimationBlendMode:we,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:Tt,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:_l,AnimationAction:ec,AnimationClip:jh,AnimationLoader:class extends Zh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new $h(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}}),i,n)}parse(t){const e=[];for(let i=0;i<t.length;i++){const n=jh.parse(t[i]);e.push(n)}return e}},AnimationMixer:class extends Ge{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,r=n.length,s=t._propertyBindings,a=t._interpolants,o=i.uuid,h=this._bindingsByRootAndName;let l=h[o];void 0===l&&(l={},h[o]=l);for(let t=0;t!==r;++t){const r=n[t],h=r.name;let c=l[h];if(void 0!==c)++c.referenceCount,s[t]=c;else{if(c=s[t],void 0!==c){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,o,h));continue}const n=e&&e._propertyBindings[t].binding.parsedPath;c=new Yl(tc.create(i,h,n),r.ValueTypeName,r.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,o,h),s[t]=c}a[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,i){const n=this._actions,r=this._actionsByClip;let s=r[e];if(void 0===s)s={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=s;else{const e=s.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=n.length,n.push(t),s.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,s=this._actionsByClip,a=s[r],o=a.knownActions,h=o[o.length-1],l=t._byClipCacheIndex;h._byClipCacheIndex=l,o[l]=h,o.pop(),t._byClipCacheIndex=null;delete a.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete s[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_addInactiveBinding(t,e,i){const n=this._bindingsByRootAndName,r=this._bindings;let s=n[e];void 0===s&&(s={},n[e]=s),s[i]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,r=i.path,s=this._bindingsByRootAndName,a=s[n],o=e[e.length-1],h=t._cacheIndex;o._cacheIndex=h,e[h]=o,e.pop(),delete a[r],0===Object.keys(a).length&&delete s[n]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return void 0===i&&(i=new Nh(new Float32Array(2),new Float32Array(2),1,ic),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,r=e[n];t.__cacheIndex=n,e[n]=t,r.__cacheIndex=i,e[i]=r}clipAction(t,e,i){const n=e||this._root,r=n.uuid;let s="string"==typeof t?jh.findByName(n,t):t;const a=null!==s?s.uuid:t,o=this._actionsByClip[a];let h=null;if(void 0===i&&(i=null!==s?s.blendMode:be),void 0!==o){const t=o.actionByRoot[r];if(void 0!==t&&t.blendMode===i)return t;h=o.knownActions[0],null===s&&(s=h._clip)}if(null===s)return null;const l=new ec(this,s,e,i);return this._bindAction(l,h),this._addInactiveAction(l,a,r),l}existingAction(t,e){const i=e||this._root,n=i.uuid,r="string"==typeof t?jh.findByName(i,t):t,s=r?r.uuid:t,a=this._actionsByClip[s];return void 0!==a&&a.actionByRoot[n]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let a=0;a!==i;++a){e[a]._update(n,t,r,s)}const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(s);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){const t=r.knownActions;for(let i=0,n=t.length;i!==n;++i){const n=t[i];this._deactivateAction(n);const r=n._cacheIndex,s=e[e.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,s._cacheIndex=r,e[r]=s,e.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const t in i){const n=i[t].actionByRoot[e];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[e];if(void 0!==n)for(const t in n){const e=n[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}},AnimationObjectGroup:class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Xe(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,i=arguments.length;e!==i;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,i=this._paths,n=this._parsedPaths,r=this._bindings,s=r.length;let a,o=t.length,h=this.nCachedObjects_;for(let l=0,c=arguments.length;l!==c;++l){const c=arguments[l],d=c.uuid;let u=e[d];if(void 0===u){u=o++,e[d]=u,t.push(c);for(let t=0,e=s;t!==e;++t)r[t].push(new tc(c,i[t],n[t]))}else if(u<h){a=t[u];const o=--h,l=t[o];e[l.uuid]=u,t[u]=l,e[d]=o,t[o]=c;for(let t=0,e=s;t!==e;++t){const e=r[t],s=e[o];let a=e[u];e[u]=s,void 0===a&&(a=new tc(c,i[t],n[t])),e[o]=a}}else t[u]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=h}remove(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_;for(let s=0,a=arguments.length;s!==a;++s){const a=arguments[s],o=a.uuid,h=e[o];if(void 0!==h&&h>=r){const s=r++,l=t[s];e[l.uuid]=h,t[h]=l,e[o]=s,t[s]=a;for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[s],r=e[h];e[h]=n,e[s]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,s=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,h=e[o];if(void 0!==h)if(delete e[o],h<r){const a=--r,o=t[a],l=--s,c=t[l];e[o.uuid]=h,t[h]=o,e[c.uuid]=a,t[a]=c,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[a],r=e[l];e[h]=n,e[a]=r,e.pop()}}else{const r=--s,a=t[r];r>0&&(e[a.uuid]=h),t[h]=a,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t];e[h]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const i=this._bindingsIndicesByPath;let n=i[t];const r=this._bindings;if(void 0!==n)return r[n];const s=this._paths,a=this._parsedPaths,o=this._objects,h=o.length,l=this.nCachedObjects_,c=new Array(h);n=r.length,i[t]=n,s.push(t),a.push(e),r.push(c);for(let i=l,n=o.length;i!==n;++i){const n=o[i];c[i]=new tc(n,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const n=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];e[t[a]]=i,s[i]=o,s.pop(),r[i]=r[a],r.pop(),n[i]=n[a],n.pop()}}},AnimationUtils:Ih,ArcCurve:Xa,ArrayCamera:Nl,ArrowHelper:class extends In{constructor(t=new Ci(0,0,1),e=new Ci(0,0,0),i=1,n=16776960,r=.2*i,s=.2*r){super(),this.type="ArrowHelper",void 0===Lc&&(Lc=new br,Lc.setAttribute("position",new pr([0,0,0,0,1,0],3)),Ic=new go(0,.5,1,5,1),Ic.translate(0,-.5,0)),this.position.copy(e),this.line=new Aa(Lc,new ya({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Dr(Ic,new er({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,r,s)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Pc.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Pc,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},AttachedBindMode:Z,Audio:Hl,AudioAnalyser:class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let i=0;i<e.length;i++)t+=e[i];return t/e.length}},AudioContext:Ll,AudioListener:class extends In{constructor(){super(),this.type="AudioListener",this.context=Ll.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Ul}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(kl,Bl,zl),Gl.set(0,0,-1).applyQuaternion(Bl),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(kl.x,t),e.positionY.linearRampToValueAtTime(kl.y,t),e.positionZ.linearRampToValueAtTime(kl.z,t),e.forwardX.linearRampToValueAtTime(Gl.x,t),e.forwardY.linearRampToValueAtTime(Gl.y,t),e.forwardZ.linearRampToValueAtTime(Gl.z,t),e.upX.linearRampToValueAtTime(i.x,t),e.upY.linearRampToValueAtTime(i.y,t),e.upZ.linearRampToValueAtTime(i.z,t)}else e.setPosition(kl.x,kl.y,kl.z),e.setOrientation(Gl.x,Gl.y,Gl.z,i.x,i.y,i.z)}},AudioLoader:class extends Zh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new $h(this.manager);function a(e){n?n(e):console.error(e),r.manager.itemError(t)}s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(t){try{const i=t.slice(0);Ll.getContext().decodeAudioData(i,(function(t){e(t)})).catch(a)}catch(t){a(t)}}),i,n)}},AxesHelper:class extends La{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new br;i.setAttribute("position",new pr(e,3)),i.setAttribute("color",new pr([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(i,new ya({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){const n=new Jn,r=this.geometry.attributes.color.array;return n.set(t),n.toArray(r,0),n.toArray(r,3),n.set(e),n.toArray(r,6),n.toArray(r,9),n.set(i),n.toArray(r,12),n.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BackSide:1,BasicDepthPacking:3200,BasicShadowMap:0,BatchedMesh:_a,Bone:Os,BooleanKeyframeTrack:kh,Box2:class{constructor(t=new $e(1/0,1/0),e=new $e(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=uc.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,uc).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},Box3:Li,Box3Helper:class extends La{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new br;n.setIndex(new cr(i,1)),n.setAttribute("position",new pr([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new ya({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}},BoxGeometry:Nr,BoxHelper:class extends La{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),r=new br;r.setIndex(new cr(i,1)),r.setAttribute("position",new cr(n,3)),super(r,new ya({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(void 0!==t&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&Rc.setFromObject(this.object),Rc.isEmpty())return;const e=Rc.min,i=Rc.max,n=this.geometry.attributes.position,r=n.array;r[0]=i.x,r[1]=i.y,r[2]=i.z,r[3]=e.x,r[4]=i.y,r[5]=i.z,r[6]=e.x,r[7]=e.y,r[8]=i.z,r[9]=i.x,r[10]=e.y,r[11]=i.z,r[12]=i.x,r[13]=i.y,r[14]=e.z,r[15]=e.x,r[16]=i.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=i.x,r[22]=e.y,r[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BufferAttribute:cr,BufferGeometry:br,BufferGeometryLoader:Tl,ByteType:mt,Cache:Yh,Camera:Gr,CameraHelper:class extends La{constructor(t){const e=new br,i=new ya({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],s={};function a(t,e){o(t),o(e)}function o(t){n.push(0,0,0),r.push(0,0,0),void 0===s[t]&&(s[t]=[]),s[t].push(n.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),e.setAttribute("position",new pr(n,3)),e.setAttribute("color",new pr(r,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();const h=new Jn(16755200),l=new Jn(16711680),c=new Jn(43775),d=new Jn(16777215),u=new Jn(3355443);this.setColors(h,l,c,d,u)}setColors(t,e,i,n,r){const s=this.geometry.getAttribute("color");s.setXYZ(0,t.r,t.g,t.b),s.setXYZ(1,t.r,t.g,t.b),s.setXYZ(2,t.r,t.g,t.b),s.setXYZ(3,t.r,t.g,t.b),s.setXYZ(4,t.r,t.g,t.b),s.setXYZ(5,t.r,t.g,t.b),s.setXYZ(6,t.r,t.g,t.b),s.setXYZ(7,t.r,t.g,t.b),s.setXYZ(8,t.r,t.g,t.b),s.setXYZ(9,t.r,t.g,t.b),s.setXYZ(10,t.r,t.g,t.b),s.setXYZ(11,t.r,t.g,t.b),s.setXYZ(12,t.r,t.g,t.b),s.setXYZ(13,t.r,t.g,t.b),s.setXYZ(14,t.r,t.g,t.b),s.setXYZ(15,t.r,t.g,t.b),s.setXYZ(16,t.r,t.g,t.b),s.setXYZ(17,t.r,t.g,t.b),s.setXYZ(18,t.r,t.g,t.b),s.setXYZ(19,t.r,t.g,t.b),s.setXYZ(20,t.r,t.g,t.b),s.setXYZ(21,t.r,t.g,t.b),s.setXYZ(22,t.r,t.g,t.b),s.setXYZ(23,t.r,t.g,t.b),s.setXYZ(24,e.r,e.g,e.b),s.setXYZ(25,e.r,e.g,e.b),s.setXYZ(26,e.r,e.g,e.b),s.setXYZ(27,e.r,e.g,e.b),s.setXYZ(28,e.r,e.g,e.b),s.setXYZ(29,e.r,e.g,e.b),s.setXYZ(30,e.r,e.g,e.b),s.setXYZ(31,e.r,e.g,e.b),s.setXYZ(32,i.r,i.g,i.b),s.setXYZ(33,i.r,i.g,i.b),s.setXYZ(34,i.r,i.g,i.b),s.setXYZ(35,i.r,i.g,i.b),s.setXYZ(36,i.r,i.g,i.b),s.setXYZ(37,i.r,i.g,i.b),s.setXYZ(38,n.r,n.g,n.b),s.setXYZ(39,n.r,n.g,n.b),s.setXYZ(40,r.r,r.g,r.b),s.setXYZ(41,r.r,r.g,r.b),s.setXYZ(42,r.r,r.g,r.b),s.setXYZ(43,r.r,r.g,r.b),s.setXYZ(44,r.r,r.g,r.b),s.setXYZ(45,r.r,r.g,r.b),s.setXYZ(46,r.r,r.g,r.b),s.setXYZ(47,r.r,r.g,r.b),s.setXYZ(48,r.r,r.g,r.b),s.setXYZ(49,r.r,r.g,r.b),s.needsUpdate=!0}update(){const t=this.geometry,e=this.pointMap;Ac.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);const i=this.camera.coordinateSystem===Be?-1:0;Cc("c",e,t,Ac,0,0,i),Cc("t",e,t,Ac,0,0,1),Cc("n1",e,t,Ac,-1,-1,i),Cc("n2",e,t,Ac,1,-1,i),Cc("n3",e,t,Ac,-1,1,i),Cc("n4",e,t,Ac,1,1,i),Cc("f1",e,t,Ac,-1,-1,1),Cc("f2",e,t,Ac,1,-1,1),Cc("f3",e,t,Ac,-1,1,1),Cc("f4",e,t,Ac,1,1,1),Cc("u1",e,t,Ac,.7,1.1,i),Cc("u2",e,t,Ac,-.7,1.1,i),Cc("u3",e,t,Ac,0,2,i),Cc("cf1",e,t,Ac,-1,0,1),Cc("cf2",e,t,Ac,1,0,1),Cc("cf3",e,t,Ac,0,-1,1),Cc("cf4",e,t,Ac,0,1,1),Cc("cn1",e,t,Ac,-1,0,i),Cc("cn2",e,t,Ac,1,0,i),Cc("cn3",e,t,Ac,0,-1,i),Cc("cn4",e,t,Ac,0,1,i),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:Ha,CapsuleGeometry:mo,CatmullRomCurve3:Qa,CineonToneMapping:3,CircleGeometry:fo,ClampToEdgeWrapping:st,Clock:Ul,Color:Jn,ColorKeyframeTrack:Bh,ColorManagement:ui,CompressedArrayTexture:class extends Ga{constructor(t,e,i,n,r,s){super(t,e,i,r,s),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=st,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},CompressedCubeTexture:class extends Ga{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,$),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},CompressedTexture:Ga,CompressedTextureLoader:class extends Zh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=[],a=new Ga,o=new $h(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials);let h=0;function l(l){o.load(t[l],(function(t){const i=r.parse(t,!0);s[l]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},h+=1,6===h&&(1===i.mipmapCount&&(a.minFilter=ct),a.image=s,a.format=i.format,a.needsUpdate=!0,e&&e(a))}),i,n)}if(Array.isArray(t))for(let e=0,i=t.length;e<i;++e)l(e);else o.load(t,(function(t){const i=r.parse(t,!0);if(i.isCubemap){const t=i.mipmaps.length/i.mipmapCount;for(let e=0;e<t;e++){s[e]={mipmaps:[]};for(let t=0;t<i.mipmapCount;t++)s[e].mipmaps.push(i.mipmaps[e*i.mipmapCount+t]),s[e].format=i.format,s[e].width=i.width,s[e].height=i.height}a.image=s}else a.image.width=i.width,a.image.height=i.height,a.mipmaps=i.mipmaps;1===i.mipmapCount&&(a.minFilter=ct),a.format=i.format,a.needsUpdate=!0,e&&e(a)}),i,n);return a}},ConeGeometry:vo,ConstantAlphaFactor:213,ConstantColorFactor:211,Controls:Dc,CubeCamera:Yr,CubeReflectionMapping:$,CubeRefractionMapping:tt,CubeTexture:qr,CubeTextureLoader:class extends Zh{constructor(t){super(t)}load(t,e,i,n){const r=new qr;r.colorSpace=Me;const s=new tl(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let a=0;function o(i){s.load(t[i],(function(t){r.images[i]=t,a++,6===a&&(r.needsUpdate=!0,e&&e(r))}),void 0,n)}for(let e=0;e<t.length;++e)o(e);return r}},CubeUVReflectionMapping:nt,CubicBezierCurve:io,CubicBezierCurve3:no,CubicInterpolant:Oh,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:Wa,CurvePath:co,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:go,Cylindrical:class{constructor(t=1,e=0,i=0){return this.radius=t,this.theta=e,this.y=i,this}set(t,e,i){return this.radius=t,this.theta=e,this.y=i,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+i*i),this.theta=Math.atan2(t,i),this.y=e,this}clone(){return(new this.constructor).copy(this)}},Data3DTexture:Ei,DataArrayTexture:Ti,DataTexture:Ns,DataTextureLoader:class extends Zh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new Ns,a=new $h(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(t,(function(t){let i;try{i=r.parse(t)}catch(t){if(void 0===n)return void console.error(t);n(t)}void 0!==i.image?s.image=i.image:void 0!==i.data&&(s.image.width=i.width,s.image.height=i.height,s.image.data=i.data),s.wrapS=void 0!==i.wrapS?i.wrapS:st,s.wrapT=void 0!==i.wrapT?i.wrapT:st,s.magFilter=void 0!==i.magFilter?i.magFilter:ct,s.minFilter=void 0!==i.minFilter?i.minFilter:ct,s.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.colorSpace&&(s.colorSpace=i.colorSpace),void 0!==i.flipY&&(s.flipY=i.flipY),void 0!==i.format&&(s.format=i.format),void 0!==i.type&&(s.type=i.type),void 0!==i.mipmaps&&(s.mipmaps=i.mipmaps,s.minFilter=ut),1===i.mipmapCount&&(s.minFilter=ct),void 0!==i.generateMipmaps&&(s.generateMipmaps=i.generateMipmaps),s.needsUpdate=!0,e&&e(s,i)}),i,n),s}},DataUtils:ar,DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:Kh,DepthFormat:Pt,DepthStencilFormat:Lt,DepthTexture:Va,DetachedBindMode:J,DirectionalLight:vl,DirectionalLightHelper:class extends In{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",void 0===e&&(e=1);let n=new br;n.setAttribute("position",new pr([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const r=new ya({fog:!1,toneMapped:!1});this.lightPlane=new Aa(n,r),this.add(this.lightPlane),n=new br,n.setAttribute("position",new pr([0,0,0,0,0,1],3)),this.targetLine=new Aa(n,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Sc.setFromMatrixPosition(this.light.matrixWorld),Mc.setFromMatrixPosition(this.light.target.matrixWorld),Tc.subVectors(Mc,Sc),this.lightPlane.lookAt(Mc),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Mc),this.targetLine.scale.z=Tc.length()}},DiscreteInterpolant:Uh,DodecahedronGeometry:yo,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:35048,DynamicReadUsage:35049,EdgesGeometry:Mo,EllipseCurve:ja,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:et,EquirectangularRefractionMapping:it,Euler:fn,EventDispatcher:Ge,ExtrudeGeometry:th,FileLoader:$h,Float16BufferAttribute:class extends cr{constructor(t,e,i){super(new Uint16Array(t),e,i),this.isFloat16BufferAttribute=!0}getX(t){let e=sr(this.array[t*this.itemSize]);return this.normalized&&(e=Ze(e,this.array)),e}setX(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize]=rr(e),this}getY(t){let e=sr(this.array[t*this.itemSize+1]);return this.normalized&&(e=Ze(e,this.array)),e}setY(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+1]=rr(e),this}getZ(t){let e=sr(this.array[t*this.itemSize+2]);return this.normalized&&(e=Ze(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+2]=rr(e),this}getW(t){let e=sr(this.array[t*this.itemSize+3]);return this.normalized&&(e=Ze(e,this.array)),e}setW(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+3]=rr(e),this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),i=Je(i,this.array)),this.array[t+0]=rr(e),this.array[t+1]=rr(i),this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),i=Je(i,this.array),n=Je(n,this.array)),this.array[t+0]=rr(e),this.array[t+1]=rr(i),this.array[t+2]=rr(n),this}setXYZW(t,e,i,n,r){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),i=Je(i,this.array),n=Je(n,this.array),r=Je(r,this.array)),this.array[t+0]=rr(e),this.array[t+1]=rr(i),this.array[t+2]=rr(n),this.array[t+3]=rr(r),this}},Float32BufferAttribute:pr,FloatType:yt,Fog:ts,FogExp2:$r,FramebufferTexture:class extends bi{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=ot,this.minFilter=ot,this.generateMipmaps=!1,this.needsUpdate=!0}},FrontSide:0,Frustum:ta,GLBufferAttribute:class{constructor(t,e,i,n,r){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=i,this.elementSize=n,this.count=r,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}},GLSL1:"100",GLSL3:ke,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:518,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:class extends La{constructor(t=10,e=10,i=4473924,n=8947848){i=new Jn(i),n=new Jn(n);const r=e/2,s=t/e,a=t/2,o=[],h=[];for(let t=0,l=0,c=-a;t<=e;t++,c+=s){o.push(-a,0,c,a,0,c),o.push(c,0,-a,c,0,a);const e=t===r?i:n;e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3}const l=new br;l.setAttribute("position",new pr(o,3)),l.setAttribute("color",new pr(h,3));super(l,new ya({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Group:Zr,HalfFloatType:xt,HemisphereLight:nl,HemisphereLightHelper:class extends In{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new nh(e);n.rotateY(.5*Math.PI),this.material=new er({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=n.getAttribute("position"),s=new Float32Array(3*r.count);n.setAttribute("color",new cr(s,3)),this.add(new Dr(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");bc.copy(this.light.color),wc.copy(this.light.groundColor);for(let t=0,i=e.count;t<i;t++){const n=t<i/2?bc:wc;e.setXYZ(t,n.r,n.g,n.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(xc.setFromMatrixPosition(this.light.matrixWorld).negate())}},IcosahedronGeometry:ih,ImageBitmapLoader:Rl,ImageLoader:tl,ImageUtils:gi,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:Bs,InstancedBufferGeometry:Ml,InstancedInterleavedBuffer:sc,InstancedMesh:Ys,Int16BufferAttribute:class extends cr{constructor(t,e,i){super(new Int16Array(t),e,i)}},Int32BufferAttribute:class extends cr{constructor(t,e,i){super(new Int32Array(t),e,i)}},Int8BufferAttribute:class extends cr{constructor(t,e,i){super(new Int8Array(t),e,i)}},IntType:vt,InterleavedBuffer:is,InterleavedBufferAttribute:rs,Interpolant:Dh,InterpolateDiscrete:fe,InterpolateLinear:ge,InterpolateSmooth:ve,InvertStencilOp:5386,KeepStencilOp:Ce,KeyframeTrack:Fh,LOD:Ss,LatheGeometry:po,Layers:gn,LessCompare:513,LessDepth:2,LessEqualCompare:515,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:il,LightProbe:bl,Line:Aa,Line3:class{constructor(t=new Ci,e=new Ci){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){pc.subVectors(t,this.start),mc.subVectors(this.end,this.start);const i=mc.dot(mc);let n=mc.dot(pc)/i;return e&&(n=Ye(n,0,1)),n}closestPointToPoint(t,e,i){const n=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(n).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}},LineBasicMaterial:ya,LineCurve:ro,LineCurve3:so,LineDashedMaterial:Eh,LineLoop:Ia,LineSegments:La,LinearFilter:ct,LinearInterpolant:Nh,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:ut,LinearMipmapNearestFilter:dt,LinearSRGBColorSpace:Te,LinearToneMapping:1,LinearTransfer:Ee,Loader:Zh,LoaderUtils:Sl,LoadingManager:qh,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,LuminanceAlphaFormat:Rt,LuminanceFormat:Ct,MOUSE:y,Material:tr,MaterialLoader:wl,MathUtils:Qe,Matrix2:dc,Matrix3:ti,Matrix4:sn,MaxEquation:104,Mesh:Dr,MeshBasicMaterial:er,MeshDepthMaterial:Sh,MeshDistanceMaterial:Mh,MeshLambertMaterial:wh,MeshMatcapMaterial:Th,MeshNormalMaterial:bh,MeshPhongMaterial:yh,MeshPhysicalMaterial:_h,MeshStandardMaterial:vh,MeshToonMaterial:xh,MinEquation:103,MirroredRepeatWrapping:at,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:ot,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:lt,NearestMipmapNearestFilter:ht,NeutralToneMapping:7,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:Se,NoToneMapping:0,NormalAnimationBlendMode:be,NormalBlending:1,NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:zh,Object3D:In,ObjectLoader:class extends Zh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=""===this.path?Sl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||s;const a=new $h(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,(function(i){let s=null;try{s=JSON.parse(i)}catch(e){return void 0!==n&&n(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}const a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void 0!==n&&n(new Error("THREE.ObjectLoader: Can't load "+t)),void console.error("THREE.ObjectLoader: Can't load "+t);r.parse(s,e)}),i,n)}async loadAsync(t,e){const i=""===this.path?Sl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;const n=new $h(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);const r=await n.loadAsync(t,e),s=JSON.parse(r),a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(s)}parse(t,e){const i=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,n),s=this.parseImages(t.images,(function(){void 0!==e&&e(h)})),a=this.parseTextures(t.textures,s),o=this.parseMaterials(t.materials,a),h=this.parseObject(t.object,r,o,a,i),l=this.parseSkeletons(t.skeletons,h);if(this.bindSkeletons(h,l),this.bindLightTargets(h),void 0!==e){let t=!1;for(const e in s)if(s[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(h)}return h}async parseAsync(t){const e=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),n=this.parseGeometries(t.geometries,i),r=await this.parseImagesAsync(t.images),s=this.parseTextures(t.textures,r),a=this.parseMaterials(t.materials,s),o=this.parseObject(t.object,n,a,s,e),h=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,h),this.bindLightTargets(o),o}parseShapes(t){const e={};if(void 0!==t)for(let i=0,n=t.length;i<n;i++){const n=(new To).fromJSON(t[i]);e[n.uuid]=n}return e}parseSkeletons(t,e){const i={},n={};if(e.traverse((function(t){t.isBone&&(n[t.uuid]=t)})),void 0!==t)for(let e=0,r=t.length;e<r;e++){const r=(new ks).fromJSON(t[e],n);i[r.uuid]=r}return i}parseGeometries(t,e){const i={};if(void 0!==t){const n=new Tl;for(let r=0,s=t.length;r<s;r++){let s;const a=t[r];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":s=n.parse(a);break;default:a.type in mh?s=mh[a.type].fromJSON(a,e):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${a.type}"`)}s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),void 0!==a.userData&&(s.userData=a.userData),i[a.uuid]=s}}return i}parseMaterials(t,e){const i={},n={};if(void 0!==t){const r=new wl;r.setTextures(e);for(let e=0,s=t.length;e<s;e++){const s=t[e];void 0===i[s.uuid]&&(i[s.uuid]=r.parse(s)),n[s.uuid]=i[s.uuid]}}return n}parseAnimations(t){const e={};if(void 0!==t)for(let i=0;i<t.length;i++){const n=t[i],r=jh.parse(n);e[r.uuid]=r}return e}parseImages(t,e){const i=this,n={};let r;function s(t){if("string"==typeof t){const e=t;return function(t){return i.manager.itemStart(t),r.load(t,(function(){i.manager.itemEnd(t)}),void 0,(function(){i.manager.itemError(t),i.manager.itemEnd(t)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:i.resourcePath+e)}return t.data?{data:ri(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const i=new qh(e);r=new tl(i),r.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],r=i.url;if(Array.isArray(r)){const t=[];for(let e=0,i=r.length;e<i;e++){const i=s(r[e]);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new Ns(i.data,i.width,i.height)))}n[i.uuid]=new _i(t)}else{const t=s(i.url);n[i.uuid]=new _i(t)}}}return n}async parseImagesAsync(t){const e=this,i={};let n;async function r(t){if("string"==typeof t){const i=t,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(i)?i:e.resourcePath+i;return await n.loadAsync(r)}return t.data?{data:ri(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){n=new tl(this.manager),n.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],s=n.url;if(Array.isArray(s)){const t=[];for(let e=0,i=s.length;e<i;e++){const i=s[e],n=await r(i);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new Ns(n.data,n.width,n.height)))}i[n.uuid]=new _i(t)}else{const t=await r(n.url);i[n.uuid]=new _i(t)}}}return i}parseTextures(t,e){function i(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const n={};if(void 0!==t)for(let r=0,s=t.length;r<s;r++){const s=t[r];void 0===s.image&&console.warn('THREE.ObjectLoader: No "image" specified for',s.uuid),void 0===e[s.image]&&console.warn("THREE.ObjectLoader: Undefined image",s.image);const a=e[s.image],o=a.data;let h;Array.isArray(o)?(h=new qr,6===o.length&&(h.needsUpdate=!0)):(h=o&&o.data?new Ns:new bi,o&&(h.needsUpdate=!0)),h.source=a,h.uuid=s.uuid,void 0!==s.name&&(h.name=s.name),void 0!==s.mapping&&(h.mapping=i(s.mapping,El)),void 0!==s.channel&&(h.channel=s.channel),void 0!==s.offset&&h.offset.fromArray(s.offset),void 0!==s.repeat&&h.repeat.fromArray(s.repeat),void 0!==s.center&&h.center.fromArray(s.center),void 0!==s.rotation&&(h.rotation=s.rotation),void 0!==s.wrap&&(h.wrapS=i(s.wrap[0],Al),h.wrapT=i(s.wrap[1],Al)),void 0!==s.format&&(h.format=s.format),void 0!==s.internalFormat&&(h.internalFormat=s.internalFormat),void 0!==s.type&&(h.type=s.type),void 0!==s.colorSpace&&(h.colorSpace=s.colorSpace),void 0!==s.minFilter&&(h.minFilter=i(s.minFilter,Cl)),void 0!==s.magFilter&&(h.magFilter=i(s.magFilter,Cl)),void 0!==s.anisotropy&&(h.anisotropy=s.anisotropy),void 0!==s.flipY&&(h.flipY=s.flipY),void 0!==s.generateMipmaps&&(h.generateMipmaps=s.generateMipmaps),void 0!==s.premultiplyAlpha&&(h.premultiplyAlpha=s.premultiplyAlpha),void 0!==s.unpackAlignment&&(h.unpackAlignment=s.unpackAlignment),void 0!==s.compareFunction&&(h.compareFunction=s.compareFunction),void 0!==s.userData&&(h.userData=s.userData),n[s.uuid]=h}return n}parseObject(t,e,i,n,r){let s,a,o;function h(t){return void 0===e[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),e[t]}function l(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let n=0,r=t.length;n<r;n++){const r=t[n];void 0===i[r]&&console.warn("THREE.ObjectLoader: Undefined material",r),e.push(i[r])}return e}return void 0===i[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),i[t]}}function c(t){return void 0===n[t]&&console.warn("THREE.ObjectLoader: Undefined texture",t),n[t]}switch(t.type){case"Scene":s=new es,void 0!==t.background&&(Number.isInteger(t.background)?s.background=new Jn(t.background):s.background=c(t.background)),void 0!==t.environment&&(s.environment=c(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?s.fog=new ts(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(s.fog=new $r(t.fog.color,t.fog.density)),""!==t.fog.name&&(s.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(s.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(s.backgroundIntensity=t.backgroundIntensity),void 0!==t.backgroundRotation&&s.backgroundRotation.fromArray(t.backgroundRotation),void 0!==t.environmentIntensity&&(s.environmentIntensity=t.environmentIntensity),void 0!==t.environmentRotation&&s.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":s=new jr(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(s.focus=t.focus),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.filmGauge&&(s.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(s.filmOffset=t.filmOffset),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"OrthographicCamera":s=new fl(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"AmbientLight":s=new _l(t.color,t.intensity);break;case"DirectionalLight":s=new vl(t.color,t.intensity),s.target=t.target||"";break;case"PointLight":s=new ml(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":s=new yl(t.color,t.intensity,t.width,t.height);break;case"SpotLight":s=new ll(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),s.target=t.target||"";break;case"HemisphereLight":s=new nl(t.color,t.groundColor,t.intensity);break;case"LightProbe":s=(new bl).fromJSON(t);break;case"SkinnedMesh":a=h(t.geometry),o=l(t.material),s=new Ds(a,o),void 0!==t.bindMode&&(s.bindMode=t.bindMode),void 0!==t.bindMatrix&&s.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(s.skeleton=t.skeleton);break;case"Mesh":a=h(t.geometry),o=l(t.material),s=new Dr(a,o);break;case"InstancedMesh":a=h(t.geometry),o=l(t.material);const e=t.count,i=t.instanceMatrix,n=t.instanceColor;s=new Ys(a,o,e),s.instanceMatrix=new Bs(new Float32Array(i.array),16),void 0!==n&&(s.instanceColor=new Bs(new Float32Array(n.array),n.itemSize));break;case"BatchedMesh":a=h(t.geometry),o=l(t.material),s=new _a(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,o),s.geometry=a,s.perObjectFrustumCulled=t.perObjectFrustumCulled,s.sortObjects=t.sortObjects,s._drawRanges=t.drawRanges,s._reservedRanges=t.reservedRanges,s._visibility=t.visibility,s._active=t.active,s._bounds=t.bounds.map((t=>{const e=new Li;e.min.fromArray(t.boxMin),e.max.fromArray(t.boxMax);const i=new Ki;return i.radius=t.sphereRadius,i.center.fromArray(t.sphereCenter),{boxInitialized:t.boxInitialized,box:e,sphereInitialized:t.sphereInitialized,sphere:i}})),s._maxInstanceCount=t.maxInstanceCount,s._maxVertexCount=t.maxVertexCount,s._maxIndexCount=t.maxIndexCount,s._geometryInitialized=t.geometryInitialized,s._geometryCount=t.geometryCount,s._matricesTexture=c(t.matricesTexture.uuid),void 0!==t.colorsTexture&&(s._colorsTexture=c(t.colorsTexture.uuid));break;case"LOD":s=new Ss;break;case"Line":s=new Aa(h(t.geometry),l(t.material));break;case"LineLoop":s=new Ia(h(t.geometry),l(t.material));break;case"LineSegments":s=new La(h(t.geometry),l(t.material));break;case"PointCloud":case"Points":s=new ka(h(t.geometry),l(t.material));break;case"Sprite":s=new ys(l(t.material));break;case"Group":s=new Zr;break;case"Bone":s=new Os;break;default:s=new In}if(s.uuid=t.uuid,void 0!==t.name&&(s.name=t.name),void 0!==t.matrix?(s.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(s.matrixAutoUpdate=t.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==t.position&&s.position.fromArray(t.position),void 0!==t.rotation&&s.rotation.fromArray(t.rotation),void 0!==t.quaternion&&s.quaternion.fromArray(t.quaternion),void 0!==t.scale&&s.scale.fromArray(t.scale)),void 0!==t.up&&s.up.fromArray(t.up),void 0!==t.castShadow&&(s.castShadow=t.castShadow),void 0!==t.receiveShadow&&(s.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(s.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(s.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(s.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(s.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&s.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(s.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(s.visible=t.visible),void 0!==t.frustumCulled&&(s.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(s.renderOrder=t.renderOrder),void 0!==t.userData&&(s.userData=t.userData),void 0!==t.layers&&(s.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)s.add(this.parseObject(a[t],e,i,n,r))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const i=e[t];s.animations.push(r[i])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(s.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const i=e[t],n=s.getObjectByProperty("uuid",i.object);void 0!==n&&s.addLevel(n,i.distance,i.hysteresis)}}return s}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse((function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const i=e[t.skeleton];void 0===i?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(i,t.bindMatrix)}}))}bindLightTargets(t){t.traverse((function(e){if(e.isDirectionalLight||e.isSpotLight){const i=e.target,n=t.getObjectByProperty("uuid",i);e.target=void 0!==n?n:new In}}))}},ObjectSpaceNormalMap:1,OctahedronGeometry:nh,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:I,OneMinusSrcColorFactor:203,OrthographicCamera:fl,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:od,Path:uo,PerspectiveCamera:jr,Plane:Js,PlaneGeometry:rh,PlaneHelper:class extends Aa{constructor(t,e=1,i=16776960){const n=i,r=new br;r.setAttribute("position",new pr([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new ya({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const s=new br;s.setAttribute("position",new pr([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.add(new Dr(s,new er({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},PointLight:ml,PointLightHelper:class extends Dr{constructor(t,e,i){super(new oh(e,4,2),new er({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Points:ka,PointsMaterial:Da,PolarGridHelper:class extends La{constructor(t=10,e=16,i=8,n=64,r=4473924,s=8947848){r=new Jn(r),s=new Jn(s);const a=[],o=[];if(e>1)for(let i=0;i<e;i++){const n=i/e*(2*Math.PI),h=Math.sin(n)*t,l=Math.cos(n)*t;a.push(0,0,0),a.push(h,0,l);const c=1&i?r:s;o.push(c.r,c.g,c.b),o.push(c.r,c.g,c.b)}for(let e=0;e<i;e++){const h=1&e?r:s,l=t-t/i*e;for(let t=0;t<n;t++){let e=t/n*(2*Math.PI),i=Math.sin(e)*l,r=Math.cos(e)*l;a.push(i,0,r),o.push(h.r,h.g,h.b),e=(t+1)/n*(2*Math.PI),i=Math.sin(e)*l,r=Math.cos(e)*l,a.push(i,0,r),o.push(h.r,h.g,h.b)}}const h=new br;h.setAttribute("position",new pr(a,3)),h.setAttribute("color",new pr(o,3));super(h,new ya({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},PolyhedronGeometry:_o,PositionalAudio:class extends Hl{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,i){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=i,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(Vl,Wl,jl),Xl.set(0,0,1).applyQuaternion(Wl);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(Vl.x,t),e.positionY.linearRampToValueAtTime(Vl.y,t),e.positionZ.linearRampToValueAtTime(Vl.z,t),e.orientationX.linearRampToValueAtTime(Xl.x,t),e.orientationY.linearRampToValueAtTime(Xl.y,t),e.orientationZ.linearRampToValueAtTime(Xl.z,t)}else e.setPosition(Vl.x,Vl.y,Vl.z),e.setOrientation(Xl.x,Xl.y,Xl.z)}},PropertyBinding:tc,PropertyMixer:Yl,QuadraticBezierCurve:ao,QuadraticBezierCurve3:oo,Quaternion:Ai,QuaternionKeyframeTrack:Hh,QuaternionLinearInterpolant:Gh,RED_GREEN_RGTC2_Format:pe,RED_RGTC1_Format:de,REVISION:_,RGBADepthPacking:3201,RGBAFormat:At,RGBAIntegerFormat:Ut,RGBA_ASTC_10x10_Format:se,RGBA_ASTC_10x5_Format:ie,RGBA_ASTC_10x6_Format:ne,RGBA_ASTC_10x8_Format:re,RGBA_ASTC_12x10_Format:ae,RGBA_ASTC_12x12_Format:oe,RGBA_ASTC_4x4_Format:qt,RGBA_ASTC_5x4_Format:Kt,RGBA_ASTC_5x5_Format:Zt,RGBA_ASTC_6x5_Format:Jt,RGBA_ASTC_6x6_Format:Qt,RGBA_ASTC_8x5_Format:$t,RGBA_ASTC_8x6_Format:te,RGBA_ASTC_8x8_Format:ee,RGBA_BPTC_Format:he,RGBA_ETC2_EAC_Format:Yt,RGBA_PVRTC_2BPPV1_Format:Wt,RGBA_PVRTC_4BPPV1_Format:Vt,RGBA_S3TC_DXT1_Format:kt,RGBA_S3TC_DXT3_Format:Bt,RGBA_S3TC_DXT5_Format:zt,RGBDepthPacking:3202,RGBFormat:Et,RGBIntegerFormat:1032,RGB_BPTC_SIGNED_Format:le,RGB_BPTC_UNSIGNED_Format:ce,RGB_ETC1_Format:jt,RGB_ETC2_Format:Xt,RGB_PVRTC_2BPPV1_Format:Ht,RGB_PVRTC_4BPPV1_Format:Gt,RGB_S3TC_DXT1_Format:Ft,RGDepthPacking:3203,RGFormat:Ot,RGIntegerFormat:Nt,RawShaderMaterial:gh,Ray:rn,Raycaster:oc,RectAreaLight:yl,RedFormat:It,RedIntegerFormat:Dt,ReinhardToneMapping:2,RenderTarget:Si,RenderTarget3D:class extends Si{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isRenderTarget3D=!0,this.depth=i,this.texture=new Ei(null,t,e,i),this.texture.isRenderTargetTexture=!0}},RenderTargetArray:class extends Si{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isRenderTargetArray=!0,this.depth=i,this.texture=new Ti(null,t,e,i),this.texture.isRenderTargetTexture=!0}},RepeatWrapping:rt,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:sh,SIGNED_RED_GREEN_RGTC2_Format:me,SIGNED_RED_RGTC1_Format:ue,SRGBColorSpace:Me,SRGBTransfer:Ae,Scene:es,ShaderChunk:kc,ShaderLib:zc,ShaderMaterial:zr,ShadowMaterial:fh,Shape:To,ShapeGeometry:ah,ShapePath:class{constructor(){this.type="ShapePath",this.color=new Jn,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new uo,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,n){return this.currentPath.quadraticCurveTo(t,e,i,n),this}bezierCurveTo(t,e,i,n,r,s){return this.currentPath.bezierCurveTo(t,e,i,n,r,s),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const i=e.length;let n=!1;for(let r=i-1,s=0;s<i;r=s++){let i=e[r],a=e[s],o=a.x-i.x,h=a.y-i.y;if(Math.abs(h)>Number.EPSILON){if(h<0&&(i=e[s],o=-o,a=e[r],h=-h),t.y<i.y||t.y>a.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=h*(t.x-i.x)-o*(t.y-i.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==i.y)continue;if(a.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=a.x)return!0}}return n}const i=Jo.isClockWise,n=this.subPaths;if(0===n.length)return[];let r,s,a;const o=[];if(1===n.length)return s=n[0],a=new To,a.curves=s.curves,o.push(a),o;let h=!i(n[0].getPoints());h=t?!h:h;const l=[],c=[];let d,u,p=[],m=0;c[m]=void 0,p[m]=[];for(let e=0,a=n.length;e<a;e++)s=n[e],d=s.getPoints(),r=i(d),r=t?!r:r,r?(!h&&c[m]&&m++,c[m]={s:new To,p:d},c[m].s.curves=s.curves,h&&m++,p[m]=[]):p[m].push({h:s,p:d[0]});if(!c[0])return function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i],r=new To;r.curves=n.curves,e.push(r)}return e}(n);if(c.length>1){let t=!1,i=0;for(let t=0,e=c.length;t<e;t++)l[t]=[];for(let n=0,r=c.length;n<r;n++){const r=p[n];for(let s=0;s<r.length;s++){const a=r[s];let o=!0;for(let r=0;r<c.length;r++)e(a.p,c[r].p)&&(n!==r&&i++,o?(o=!1,l[r].push(a)):t=!0);o&&l[n].push(a)}}i>0&&!1===t&&(p=l)}for(let t=0,e=c.length;t<e;t++){a=c[t].s,o.push(a),u=p[t];for(let t=0,e=u.length;t<e;t++)a.holes.push(u[t].h)}return o}},ShapeUtils:Jo,ShortType:ft,Skeleton:ks,SkeletonHelper:class extends La{constructor(t){const e=yc(t),i=new br,n=[],r=[],s=new Jn(0,0,1),a=new Jn(0,1,0);for(let t=0;t<e.length;t++){const i=e[t];i.parent&&i.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),r.push(s.r,s.g,s.b),r.push(a.r,a.g,a.b))}i.setAttribute("position",new pr(n,3)),i.setAttribute("color",new pr(r,3));super(i,new ya({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(t){const e=this.bones,i=this.geometry,n=i.getAttribute("position");_c.copy(this.root.matrixWorld).invert();for(let t=0,i=0;t<e.length;t++){const r=e[t];r.parent&&r.parent.isBone&&(vc.multiplyMatrices(_c,r.matrixWorld),gc.setFromMatrixPosition(vc),n.setXYZ(i,gc.x,gc.y,gc.z),vc.multiplyMatrices(_c,r.parent.matrixWorld),gc.setFromMatrixPosition(vc),n.setXYZ(i+1,gc.x,gc.y,gc.z),i+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose()}},SkinnedMesh:Ds,Source:_i,Sphere:Ki,SphereGeometry:oh,Spherical:cc,SphericalHarmonics3:xl,SplineCurve:ho,SpotLight:ll,SpotLightHelper:class extends In{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new br,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,i=32;t<i;t++,e++){const r=t/i*Math.PI*2,s=e/i*Math.PI*2;n.push(Math.cos(r),Math.sin(r),1,Math.cos(s),Math.sin(s),1)}i.setAttribute("position",new pr(n,3));const r=new ya({fog:!1,toneMapped:!1});this.cone=new La(i,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),fc.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(fc),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:ys,SpriteMaterial:ss,SrcAlphaFactor:L,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:Fe,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new jr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new jr,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,Ol.copy(t.projectionMatrix);const i=e.eyeSep/2,n=i*e.near/e.focus,r=e.near*Math.tan(We*e.fov*.5)/e.zoom;let s,a;Dl.elements[12]=-i,Il.elements[12]=i,s=-r*e.aspect+n,a=r*e.aspect+n,Ol.elements[0]=2*e.near/(a-s),Ol.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(Ol),s=-r*e.aspect-n,a=r*e.aspect-n,Ol.elements[0]=2*e.near/(a-s),Ol.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(Ol)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(Dl),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Il)}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:Vh,SubtractEquation:101,SubtractiveBlending:3,TOUCH:x,TangentSpaceNormalMap:0,TetrahedronGeometry:hh,Texture:bi,TextureLoader:el,TextureUtils:Nc,TimestampQuery:{COMPUTE:"compute",RENDER:"render"},TorusGeometry:lh,TorusKnotGeometry:ch,Triangle:Xn,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:dh,UVMapping:Q,Uint16BufferAttribute:dr,Uint32BufferAttribute:ur,Uint8BufferAttribute:class extends cr{constructor(t,e,i){super(new Uint8Array(t),e,i)}},Uint8ClampedBufferAttribute:class extends cr{constructor(t,e,i){super(new Uint8ClampedArray(t),e,i)}},Uniform:nc,UniformsGroup:class extends Ge{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:rc++}),this.name="",this.usage=Fe,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return-1!==e&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let t=0,i=e.length;t<i;t++){const i=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0;t<i.length;t++)this.uniforms.push(i[t].clone())}return this}clone(){return(new this.constructor).copy(this)}},UniformsLib:Bc,UniformsUtils:Br,UnsignedByteType:pt,UnsignedInt248Type:St,UnsignedInt5999Type:Mt,UnsignedIntType:_t,UnsignedShort4444Type:bt,UnsignedShort5551Type:wt,UnsignedShortType:gt,VSMShadowMap:3,Vector2:$e,Vector3:Ci,Vector4:wi,VectorKeyframeTrack:Wh,VideoFrameTexture:class extends za{constructor(t,e,i,n,r,s,a,o){super({},t,e,i,n,r,s,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return(new this.constructor).copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}},VideoTexture:za,WebGL3DRenderTarget:class extends Mi{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Ei(null,t,e,i),this.texture.isRenderTargetTexture=!0}},WebGLArrayRenderTarget:class extends Mi{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Ti(null,t,e,i),this.texture.isRenderTargetTexture=!0}},WebGLCoordinateSystem:Be,WebGLCubeRenderTarget:Kr,WebGLRenderTarget:Mi,WebGLRenderer:vp,WebGLUtils:cp,WebGPUCoordinateSystem:ze,WebXRController:Qr,WireframeGeometry:uh,WrapAroundEnding:xe,ZeroCurvatureEnding:_e,ZeroFactor:200,ZeroSlopeEnding:ye,ZeroStencilOp:0,createCanvasElement:ai});const yp=new oc,xp=new Ci,bp=new Ci,wp=new Ai,Sp={X:new Ci(1,0,0),Y:new Ci(0,1,0),Z:new Ci(0,0,1)},Mp={type:"change"},Tp={type:"mouseDown",mode:null},Ep={type:"mouseUp",mode:null},Ap={type:"objectChange"};class Cp extends Dc{constructor(t,e=null){super(void 0,e);const i=new Kp(this);this._root=i;const n=new Zp;this._gizmo=n,i.add(n);const r=new Jp;this._plane=r,i.add(r);const s=this;function a(t,e){let i=e;Object.defineProperty(s,t,{get:function(){return void 0!==i?i:e},set:function(e){i!==e&&(i=e,r[t]=e,n[t]=e,s.dispatchEvent({type:t+"-changed",value:e}),s.dispatchEvent(Mp))}}),s[t]=e,r[t]=e,n[t]=e}a("camera",t),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const o=new Ci,h=new Ci,l=new Ai,c=new Ai,d=new Ci,u=new Ai,p=new Ci,m=new Ci,f=new Ci,g=new Ci;a("worldPosition",o),a("worldPositionStart",h),a("worldQuaternion",l),a("worldQuaternionStart",c),a("cameraPosition",d),a("cameraQuaternion",u),a("pointStart",p),a("pointEnd",m),a("rotationAxis",f),a("rotationAngle",0),a("eye",g),this._offset=new Ci,this._startNorm=new Ci,this._endNorm=new Ci,this._cameraScale=new Ci,this._parentPosition=new Ci,this._parentQuaternion=new Ai,this._parentQuaternionInv=new Ai,this._parentScale=new Ci,this._worldScaleStart=new Ci,this._worldQuaternionInv=new Ai,this._worldScale=new Ci,this._positionStart=new Ci,this._quaternionStart=new Ai,this._scaleStart=new Ci,this._getPointer=Rp.bind(this),this._onPointerDown=Lp.bind(this),this._onPointerHover=Pp.bind(this),this._onPointerMove=Ip.bind(this),this._onPointerUp=Dp.bind(this),null!==e&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;null!==t&&yp.setFromCamera(t,this.camera);const e=Op(this._gizmo.picker[this.mode],yp);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&(null==t||0===t.button)&&null!==this.axis){null!==t&&yp.setFromCamera(t,this.camera);const e=Op(this._plane,yp,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,Tp.mode=this.mode,this.dispatchEvent(Tp)}}pointerMove(t){const e=this.axis,i=this.mode,n=this.object;let r=this.space;if("scale"===i?r="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(r="world"),void 0===n||null===e||!1===this.dragging||null!==t&&-1!==t.button)return;null!==t&&yp.setFromCamera(t,this.camera);const s=Op(this._plane,yp,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===i)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===r&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(n.position.applyQuaternion(wp.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),"world"===r&&(n.parent&&n.position.add(xp.setFromMatrixPosition(n.parent.matrixWorld)),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(xp.setFromMatrixPosition(n.parent.matrixWorld)))),n.position.x=Math.max(this.minX,Math.min(this.maxX,n.position.x)),n.position.y=Math.max(this.minY,Math.min(this.maxY,n.position.y)),n.position.z=Math.max(this.minZ,Math.min(this.maxZ,n.position.z));else if("scale"===i){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),bp.set(t,t,t)}else xp.copy(this.pointStart),bp.copy(this.pointEnd),xp.applyQuaternion(this._worldQuaternionInv),bp.applyQuaternion(this._worldQuaternionInv),bp.divide(xp),-1===e.search("X")&&(bp.x=1),-1===e.search("Y")&&(bp.y=1),-1===e.search("Z")&&(bp.z=1);n.scale.copy(this._scaleStart).multiply(bp),this.scaleSnap&&(-1!==e.search("X")&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(xp.setFromMatrixPosition(this.camera.matrixWorld));let i=!1;"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(xp.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(Sp[e]),xp.copy(Sp[e]),"local"===r&&xp.applyQuaternion(this.worldQuaternion),xp.cross(this.eye),0===xp.length()?i=!0:this.rotationAngle=this._offset.dot(xp.normalize())*t),("E"===e||i)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==e&&"XYZE"!==e?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(wp.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(wp.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Mp),this.dispatchEvent(Ap)}}pointerUp(t){null!==t&&0!==t.button||(this.dragging&&null!==this.axis&&(Ep.mode=this.mode,this.dispatchEvent(Ep)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Mp),this.dispatchEvent(Ap),this.pointStart.copy(this.pointEnd))}getRaycaster(){return yp}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}}function Rp(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};{const e=this.domElement.getBoundingClientRect();return{x:(t.clientX-e.left)/e.width*2-1,y:-(t.clientY-e.top)/e.height*2+1,button:t.button}}}function Pp(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(t))}}function Lp(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(t)),this.pointerDown(this._getPointer(t)))}function Ip(t){this.enabled&&this.pointerMove(this._getPointer(t))}function Dp(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(t)))}function Op(t,e,i){const n=e.intersectObject(t,!0);for(let t=0;t<n.length;t++)if(n[t].object.visible||i)return n[t];return!1}const Np=new fn,Up=new Ci(0,1,0),Fp=new Ci(0,0,0),kp=new sn,Bp=new Ai,zp=new Ai,Gp=new Ci,Hp=new sn,Vp=new Ci(1,0,0),Wp=new Ci(0,1,0),jp=new Ci(0,0,1),Xp=new Ci,Yp=new Ci,qp=new Ci;class Kp extends In{constructor(t){super(),this.isTransformControlsRoot=!0,this.controls=t,this.visible=!1}updateMatrixWorld(t){const e=this.controls;void 0!==e.object&&(e.object.updateMatrixWorld(),null===e.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):e.object.parent.matrixWorld.decompose(e._parentPosition,e._parentQuaternion,e._parentScale),e.object.matrixWorld.decompose(e.worldPosition,e.worldQuaternion,e._worldScale),e._parentQuaternionInv.copy(e._parentQuaternion).invert(),e._worldQuaternionInv.copy(e.worldQuaternion).invert()),e.camera.updateMatrixWorld(),e.camera.matrixWorld.decompose(e.cameraPosition,e.cameraQuaternion,e._cameraScale),e.camera.isOrthographicCamera?e.camera.getWorldDirection(e.eye).negate():e.eye.copy(e.cameraPosition).sub(e.worldPosition).normalize(),super.updateMatrixWorld(t)}dispose(){this.traverse((function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()}))}}class Zp extends In{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new er({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new ya({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=t.clone();i.opacity=.15;const n=e.clone();n.opacity=.5;const r=t.clone();r.color.setHex(16711680);const s=t.clone();s.color.setHex(65280);const a=t.clone();a.color.setHex(255);const o=t.clone();o.color.setHex(16711680),o.opacity=.5;const h=t.clone();h.color.setHex(65280),h.opacity=.5;const l=t.clone();l.color.setHex(255),l.opacity=.5;const c=t.clone();c.opacity=.25;const d=t.clone();d.color.setHex(16776960),d.opacity=.25;t.clone().color.setHex(16776960);const u=t.clone();u.color.setHex(7895160);const p=new go(0,.04,.1,12);p.translate(0,.05,0);const m=new Nr(.08,.08,.08);m.translate(0,.04,0);const f=new br;f.setAttribute("position",new pr([0,0,0,1,0,0],3));const g=new go(.0075,.0075,.5,3);function v(t,e){const i=new lh(t,.0075,3,64,e*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}g.translate(0,.25,0);const _={X:[[new Dr(p,r),[.5,0,0],[0,0,-Math.PI/2]],[new Dr(p,r),[-.5,0,0],[0,0,Math.PI/2]],[new Dr(g,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Dr(p,s),[0,.5,0]],[new Dr(p,s),[0,-.5,0],[Math.PI,0,0]],[new Dr(g,s)]],Z:[[new Dr(p,a),[0,0,.5],[Math.PI/2,0,0]],[new Dr(p,a),[0,0,-.5],[-Math.PI/2,0,0]],[new Dr(g,a),null,[Math.PI/2,0,0]]],XYZ:[[new Dr(new nh(.1,0),c.clone()),[0,0,0]]],XY:[[new Dr(new Nr(.15,.15,.01),l.clone()),[.15,.15,0]]],YZ:[[new Dr(new Nr(.15,.15,.01),o.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Dr(new Nr(.15,.15,.01),h.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},y={X:[[new Dr(new go(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Dr(new go(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Dr(new go(.2,0,.6,4),i),[0,.3,0]],[new Dr(new go(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Dr(new go(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Dr(new go(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Dr(new nh(.2,0),i)]],XY:[[new Dr(new Nr(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Dr(new Nr(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Dr(new Nr(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},x={START:[[new Dr(new nh(.01,2),n),null,null,null,"helper"]],END:[[new Dr(new nh(.01,2),n),null,null,null,"helper"]],DELTA:[[new Aa(function(){const t=new br;return t.setAttribute("position",new pr([0,0,0,1,1,1],3)),t}(),n),null,null,null,"helper"]],X:[[new Aa(f,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Aa(f,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Aa(f,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},b={XYZE:[[new Dr(v(.5,1),u),null,[0,Math.PI/2,0]]],X:[[new Dr(v(.5,.5),r)]],Y:[[new Dr(v(.5,.5),s),null,[0,0,-Math.PI/2]]],Z:[[new Dr(v(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new Dr(v(.75,1),d),null,[0,Math.PI/2,0]]]},w={AXIS:[[new Aa(f,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},S={XYZE:[[new Dr(new oh(.25,10,8),i)]],X:[[new Dr(new lh(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Dr(new lh(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Dr(new lh(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Dr(new lh(.75,.1,2,24),i)]]},M={X:[[new Dr(m,r),[.5,0,0],[0,0,-Math.PI/2]],[new Dr(g,r),[0,0,0],[0,0,-Math.PI/2]],[new Dr(m,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Dr(m,s),[0,.5,0]],[new Dr(g,s)],[new Dr(m,s),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Dr(m,a),[0,0,.5],[Math.PI/2,0,0]],[new Dr(g,a),[0,0,0],[Math.PI/2,0,0]],[new Dr(m,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Dr(new Nr(.15,.15,.01),l),[.15,.15,0]]],YZ:[[new Dr(new Nr(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Dr(new Nr(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Dr(new Nr(.1,.1,.1),c.clone())]]},T={X:[[new Dr(new go(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Dr(new go(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Dr(new go(.2,0,.6,4),i),[0,.3,0]],[new Dr(new go(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Dr(new go(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Dr(new go(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Dr(new Nr(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Dr(new Nr(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Dr(new Nr(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Dr(new Nr(.2,.2,.2),i),[0,0,0]]]},E={X:[[new Aa(f,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Aa(f,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Aa(f,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function A(t){const e=new In;for(const i in t)for(let n=t[i].length;n--;){const r=t[i][n][0].clone(),s=t[i][n][1],a=t[i][n][2],o=t[i][n][3],h=t[i][n][4];r.name=i,r.tag=h,s&&r.position.set(s[0],s[1],s[2]),a&&r.rotation.set(a[0],a[1],a[2]),o&&r.scale.set(o[0],o[1],o[2]),r.updateMatrix();const l=r.geometry.clone();l.applyMatrix4(r.matrix),r.geometry=l,r.renderOrder=1/0,r.position.set(0,0,0),r.rotation.set(0,0,0),r.scale.set(1,1,1),e.add(r)}return e}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=A(_)),this.add(this.gizmo.rotate=A(b)),this.add(this.gizmo.scale=A(M)),this.add(this.picker.translate=A(y)),this.add(this.picker.rotate=A(S)),this.add(this.picker.scale=A(T)),this.add(this.helper.translate=A(x)),this.add(this.helper.rotate=A(w)),this.add(this.helper.scale=A(E)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const e="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:zp;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let t=0;t<i.length;t++){const n=i[t];let r;if(n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition),r=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(r*this.size/4),"helper"!==n.tag){if(n.quaternion.copy(e),"translate"===this.mode||"scale"===this.mode){const t=.99,i=.2;"X"===n.name&&Math.abs(Up.copy(Vp).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Y"===n.name&&Math.abs(Up.copy(Wp).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Z"===n.name&&Math.abs(Up.copy(jp).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XY"===n.name&&Math.abs(Up.copy(jp).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"YZ"===n.name&&Math.abs(Up.copy(Vp).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XZ"===n.name&&Math.abs(Up.copy(Wp).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)}else"rotate"===this.mode&&(Bp.copy(e),Up.copy(this.eye).applyQuaternion(wp.copy(e).invert()),-1!==n.name.search("E")&&n.quaternion.setFromRotationMatrix(kp.lookAt(this.eye,Fp,Wp)),"X"===n.name&&(wp.setFromAxisAngle(Vp,Math.atan2(-Up.y,Up.z)),wp.multiplyQuaternions(Bp,wp),n.quaternion.copy(wp)),"Y"===n.name&&(wp.setFromAxisAngle(Wp,Math.atan2(Up.x,Up.z)),wp.multiplyQuaternions(Bp,wp),n.quaternion.copy(wp)),"Z"===n.name&&(wp.setFromAxisAngle(jp,Math.atan2(Up.y,Up.x)),wp.multiplyQuaternions(Bp,wp),n.quaternion.copy(wp)));n.visible=n.visible&&(-1===n.name.indexOf("X")||this.showX),n.visible=n.visible&&(-1===n.name.indexOf("Y")||this.showY),n.visible=n.visible&&(-1===n.name.indexOf("Z")||this.showZ),n.visible=n.visible&&(-1===n.name.indexOf("E")||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some((function(t){return n.name===t})))&&(n.material.color.setHex(16776960),n.material.opacity=1)}else n.visible=!1,"AXIS"===n.name?(n.visible=!!this.axis,"X"===this.axis&&(wp.setFromEuler(Np.set(0,0,0)),n.quaternion.copy(e).multiply(wp),Math.abs(Up.copy(Vp).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Y"===this.axis&&(wp.setFromEuler(Np.set(0,0,Math.PI/2)),n.quaternion.copy(e).multiply(wp),Math.abs(Up.copy(Wp).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Z"===this.axis&&(wp.setFromEuler(Np.set(0,Math.PI/2,0)),n.quaternion.copy(e).multiply(wp),Math.abs(Up.copy(jp).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"XYZE"===this.axis&&(wp.setFromEuler(Np.set(0,Math.PI/2,0)),Up.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(kp.lookAt(Fp,Up,Wp)),n.quaternion.multiply(wp),n.visible=this.dragging),"E"===this.axis&&(n.visible=!1)):"START"===n.name?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):"END"===n.name?(n.position.copy(this.worldPosition),n.visible=this.dragging):"DELTA"===n.name?(n.position.copy(this.worldPositionStart),n.quaternion.copy(this.worldQuaternionStart),xp.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),xp.applyQuaternion(this.worldQuaternionStart.clone().invert()),n.scale.copy(xp),n.visible=this.dragging):(n.quaternion.copy(e),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=-1!==this.axis.search(n.name)))}super.updateMatrixWorld(t)}}class Jp extends Dr{constructor(){super(new rh(1e5,1e5,2,2),new er({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),Xp.copy(Vp).applyQuaternion("local"===e?this.worldQuaternion:zp),Yp.copy(Wp).applyQuaternion("local"===e?this.worldQuaternion:zp),qp.copy(jp).applyQuaternion("local"===e?this.worldQuaternion:zp),Up.copy(Yp),this.mode){case"translate":case"scale":switch(this.axis){case"X":Up.copy(this.eye).cross(Xp),Gp.copy(Xp).cross(Up);break;case"Y":Up.copy(this.eye).cross(Yp),Gp.copy(Yp).cross(Up);break;case"Z":Up.copy(this.eye).cross(qp),Gp.copy(qp).cross(Up);break;case"XY":Gp.copy(qp);break;case"YZ":Gp.copy(Xp);break;case"XZ":Up.copy(qp),Gp.copy(Yp);break;case"XYZ":case"E":Gp.set(0,0,0)}break;default:Gp.set(0,0,0)}0===Gp.length()?this.quaternion.copy(this.cameraQuaternion):(Hp.lookAt(xp.set(0,0,0),Gp,Up),this.quaternion.setFromRotationMatrix(Hp)),super.updateMatrixWorld(t)}}class Qp extends Aa{constructor(t,e=1,i=16776960,n=new Ci){const r=new br;r.setAttribute("position",new pr([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new ya({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e,this.offset=n;const s=new br;s.setAttribute("position",new pr([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.helper=new Dr(s,new er({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1,side:2})),this.add(this.helper)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}updateMatrixWorld(t){this.position.set(0,0,0),this.lookAt(this.plane.normal),this.position.copy(this.offset),this.translateZ(-(this.offset.dot(this.plane.normal)+this.plane.constant)),this.scale.set(.5*this.size,.5*this.size,1),super.updateMatrixWorld(t)}}const $p={type:"change"},tm={type:"start"},em={type:"end"},im=-1,nm=0,rm=1,sm=2,am=3,om=4,hm=5,lm=6;class cm extends Ge{constructor(t,e){super(),this.object=t,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Ci,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:y.ROTATE,MIDDLE:y.DOLLY,RIGHT:y.PAN},this.touches={ONE:x.ROTATE,TWO:x.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return r.phi},this.getAzimuthalAngle=function(){return r.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",C),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",C),this._domElementKeyEvents=null},this.saveState=function(){i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=function(){i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent($p),i.update(),i.state=im},this.update=function(){const e=new Ci,a=(new Ai).setFromUnitVectors(t.up,new Ci(0,1,0)),h=a.clone().invert(),l=new Ci,c=new Ai,d=new Ci,u=2*Math.PI;return function(){const t=i.object.position;e.copy(t).sub(i.target),e.applyQuaternion(a),r.setFromVector3(e),i.autoRotate&&i.state===im&&o(2*Math.PI/60/60*i.autoRotateSpeed),i.enableDamping?(r.theta+=s.theta*i.dampingFactor,r.phi+=s.phi*i.dampingFactor):(r.theta+=s.theta,r.phi+=s.phi);let p=i.minAzimuthAngle,m=i.maxAzimuthAngle;return isFinite(p)&&isFinite(m)&&(p<-Math.PI?p+=u:p>Math.PI&&(p-=u),m<-Math.PI?m+=u:m>Math.PI&&(m-=u),r.theta=p<=m?Math.max(p,Math.min(m,r.theta)):r.theta>(p+m)/2?Math.max(p,r.theta):Math.min(m,r.theta)),r.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,r.phi)),r.makeSafe(),r.radius*=i.scale,r.radius=Math.max(i.minDistance,Math.min(i.maxDistance,r.radius)),!0===i.enableDamping?i.target.addScaledVector(i.panOffset,i.dampingFactor):i.target.add(i.panOffset),e.setFromSpherical(r),e.applyQuaternion(h),t.copy(i.target).add(e),i.object.lookAt(i.target),!0===i.enableDamping?(s.theta*=1-i.dampingFactor,s.phi*=1-i.dampingFactor,i.panOffset.multiplyScalar(1-i.dampingFactor)):(s.set(0,0,0),i.panOffset.set(0,0,0)),i.scale=1,!!(i.zoomChanged||l.distanceToSquared(i.object.position)>n||8*(1-c.dot(i.object.quaternion))>n||d.distanceToSquared(i.target)>0)&&(i.dispatchEvent($p),l.copy(i.object.position),c.copy(i.object.quaternion),d.copy(i.target),i.zoomChanged=!1,!0)}}(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",R),i.domElement.removeEventListener("pointerdown",M),i.domElement.removeEventListener("pointercancel",E),i.domElement.removeEventListener("wheel",A),i.domElement.removeEventListener("pointermove",T),i.domElement.removeEventListener("pointerup",E),null!==i._domElementKeyEvents&&(i._domElementKeyEvents.removeEventListener("keydown",C),i._domElementKeyEvents=null)};const i=this;i.state=im;const n=1e-6,r=new cc,s=new cc;function a(){return Math.pow(.95,i.zoomSpeed)}function o(t){s.theta-=t}function h(t){s.phi-=t}i.scale=1,i.panOffset=new Ci,i.zoomChanged=!1,i.rotateStart=new $e,i.rotateEnd=new $e,i.rotateDelta=new $e,i.panStart=new $e,i.panEnd=new $e,i.panDelta=new $e,i.dollyStart=new $e,i.dollyEnd=new $e,i.dollyDelta=new $e,i.dollyScale=0,i.pointers=[],i.pointerPositions={};const l=function(){const t=new Ci;return function(e,n){t.setFromMatrixColumn(n,0),t.multiplyScalar(-e),i.panOffset.add(t)}}(),c=function(){const t=new Ci;return function(e,n){!0===i.screenSpacePanning?t.setFromMatrixColumn(n,1):(t.setFromMatrixColumn(n,0),t.crossVectors(i.object.up,t)),t.multiplyScalar(e),i.panOffset.add(t)}}(),d=function(){const t=new Ci;return function(e,n){const r=i.domElement;if(i.object.isPerspectiveCamera){const s=i.object.position;t.copy(s).sub(i.target);let a=t.length();a*=Math.tan(i.object.fov/2*Math.PI/180),l(2*e*a/r.clientHeight,i.object.matrix),c(2*n*a/r.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(l(e*(i.object.right-i.object.left)/i.object.zoom/r.clientWidth,i.object.matrix),c(n*(i.object.top-i.object.bottom)/i.object.zoom/r.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}}();function u(t){i.object.isPerspectiveCamera?i.scale/=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom*t)),i.object.updateProjectionMatrix(),i.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function p(t){i.object.isPerspectiveCamera?i.scale*=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/t)),i.object.updateProjectionMatrix(),i.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function m(t){i.rotateStart.set(t.clientX,t.clientY)}function f(t){i.panStart.set(t.clientX,t.clientY)}function g(){if(1===i.pointers.length)i.rotateStart.set(i.pointers[0].pageX,i.pointers[0].pageY);else{const t=.5*(i.pointers[0].pageX+i.pointers[1].pageX),e=.5*(i.pointers[0].pageY+i.pointers[1].pageY);i.rotateStart.set(t,e)}}function v(){if(1===i.pointers.length)i.panStart.set(i.pointers[0].pageX,i.pointers[0].pageY);else{const t=.5*(i.pointers[0].pageX+i.pointers[1].pageX),e=.5*(i.pointers[0].pageY+i.pointers[1].pageY);i.panStart.set(t,e)}}function _(){const t=i.pointers[0].pageX-i.pointers[1].pageX,e=i.pointers[0].pageY-i.pointers[1].pageY,n=Math.sqrt(t*t+e*e);i.dollyStart.set(0,n)}function b(t){if(1==i.pointers.length)i.rotateEnd.set(t.pageX,t.pageY);else{const e=L(t),n=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);i.rotateEnd.set(n,r)}i.rotateDelta.subVectors(i.rotateEnd,i.rotateStart).multiplyScalar(i.rotateSpeed);const e=i.domElement;o(2*Math.PI*i.rotateDelta.x/e.clientHeight),h(2*Math.PI*i.rotateDelta.y/e.clientHeight),i.rotateStart.copy(i.rotateEnd)}function w(t){if(1===i.pointers.length)i.panEnd.set(t.pageX,t.pageY);else{const e=L(t),n=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);i.panEnd.set(n,r)}i.panDelta.subVectors(i.panEnd,i.panStart).multiplyScalar(i.panSpeed),d(i.panDelta.x,i.panDelta.y),i.panStart.copy(i.panEnd)}function S(t){const e=L(t),n=t.pageX-e.x,r=t.pageY-e.y,s=Math.sqrt(n*n+r*r);i.dollyEnd.set(0,s),i.dollyDelta.set(0,Math.pow(i.dollyEnd.y/i.dollyStart.y,i.zoomSpeed)),u(i.dollyDelta.y),i.dollyStart.copy(i.dollyEnd)}function M(t){!1!==i.enabled&&(0===i.pointers.length&&(i.domElement.setPointerCapture(t.pointerId),i.domElement.addEventListener("pointermove",T),i.domElement.addEventListener("pointerup",E)),function(t){i.pointers.push(t)}(t),"touch"===t.pointerType?function(t){switch(P(t),i.pointers.length){case 1:switch(i.touches.ONE){case x.ROTATE:if(!1===i.enableRotate)return;g(),i.state=am;break;case x.PAN:if(!1===i.enablePan)return;v(),i.state=om;break;default:i.state=im}break;case 2:switch(i.touches.TWO){case x.DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;i.enableZoom&&_(),i.enablePan&&v(),i.state=hm;break;case x.DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;i.enableZoom&&_(),i.enableRotate&&g(),i.state=lm;break;default:i.state=im}break;default:i.state=im}i.state!==im&&i.dispatchEvent(tm)}(t):function(t){let e;switch(t.button){case 0:e=i.mouseButtons.LEFT;break;case 1:e=i.mouseButtons.MIDDLE;break;case 2:e=i.mouseButtons.RIGHT;break;default:e=-1}switch(e){case y.DOLLY:if(!1===i.enableZoom)return;!function(t){i.dollyStart.set(t.clientX,t.clientY)}(t),i.state=rm;break;case y.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enablePan)return;f(t),i.state=sm}else{if(!1===i.enableRotate)return;m(t),i.state=nm}break;case y.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enableRotate)return;m(t),i.state=nm}else{if(!1===i.enablePan)return;f(t),i.state=sm}break;default:i.state=im}i.state!==im&&i.dispatchEvent(tm)}(t))}function T(t){!1!==i.enabled&&("touch"===t.pointerType?function(t){switch(P(t),i.state){case am:if(!1===i.enableRotate)return;b(t),i.update();break;case om:if(!1===i.enablePan)return;w(t),i.update();break;case hm:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(t){i.enableZoom&&S(t),i.enablePan&&w(t)}(t),i.update();break;case lm:if(!1===i.enableZoom&&!1===i.enableRotate)return;!function(t){i.enableZoom&&S(t),i.enableRotate&&b(t)}(t),i.update();break;default:i.state=im}}(t):function(t){switch(i.state){case nm:if(!1===i.enableRotate)return;!function(t){i.rotateEnd.set(t.clientX,t.clientY),i.rotateDelta.subVectors(i.rotateEnd,i.rotateStart).multiplyScalar(i.rotateSpeed);const e=i.domElement;o(2*Math.PI*i.rotateDelta.x/e.clientHeight),h(2*Math.PI*i.rotateDelta.y/e.clientHeight),i.rotateStart.copy(i.rotateEnd),i.update()}(t);break;case rm:if(!1===i.enableZoom)return;!function(t){i.dollyEnd.set(t.clientX,t.clientY),i.dollyDelta.subVectors(i.dollyEnd,i.dollyStart),i.dollyDelta.y<0?(i.dollyScale=1/a(),u(a())):i.dollyDelta.y>0&&(i.dollyScale=a(),p(a())),i.dollyStart.copy(i.dollyEnd),i.update()}(t);break;case sm:if(!1===i.enablePan)return;!function(t){i.panEnd.set(t.clientX,t.clientY),i.panDelta.subVectors(i.panEnd,i.panStart).multiplyScalar(i.panSpeed),d(i.panDelta.x,i.panDelta.y),i.panStart.copy(i.panEnd),i.update()}(t)}}(t))}function E(t){!function(t){delete i.pointerPositions[t.pointerId];for(let e=0;e<i.pointers.length;e++)if(i.pointers[e].pointerId==t.pointerId)return void i.pointers.splice(e,1)}(t),0===i.pointers.length&&(i.domElement.releasePointerCapture(t.pointerId),i.domElement.removeEventListener("pointermove",T),i.domElement.removeEventListener("pointerup",E)),i.dispatchEvent(em),i.state=im}function A(t){!1!==i.enabled&&!1!==i.enableZoom&&i.state===im&&(t.preventDefault(),i.dispatchEvent(tm),function(t){i.dollyEnd.set(i.domElement.clientWidth/2,i.domElement.clientHeight/2),i.dollyDelta.set(t.deltaX,t.deltaY),t.deltaY<0?(i.dollyScale=1/a(),p(a())):t.deltaY>0&&(i.dollyScale=a(),u(a())),i.dollyStart.copy(i.dollyEnd),i.update(),0!==t.deltaY&&(i.state=rm,i.dispatchEvent($p),i.state=im)}(t),i.dispatchEvent(em))}function C(t){!1!==i.enabled&&!1!==i.enablePan&&function(t){let e=!1;switch(t.code){case i.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?h(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(0,i.keyPanSpeed),e=!0;break;case i.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?h(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(0,-i.keyPanSpeed),e=!0;break;case i.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?o(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(i.keyPanSpeed,0),e=!0;break;case i.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?o(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(-i.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),i.update())}(t)}function R(t){!1!==i.enabled&&t.preventDefault()}function P(t){let e=i.pointerPositions[t.pointerId];void 0===e&&(e=new $e,i.pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}function L(t){const e=t.pointerId===i.pointers[0].pointerId?i.pointers[1]:i.pointers[0];return i.pointerPositions[e.pointerId]}i.domElement.addEventListener("contextmenu",R),i.domElement.addEventListener("pointerdown",M),i.domElement.addEventListener("pointercancel",E),i.domElement.addEventListener("wheel",A,{passive:!1}),this.update()}}class dm{constructor(t){this.updateControls=()=>{this.orbit.maxDistance=this.viewer.camera.far,this.orbit.minDistance=this.viewer.camera.near,this.orbit.object=this.viewer.camera,this.orbit.target.copy(this.viewer.target),this.orbit.update()},this.controlsStart=()=>{this.changed=!1},this.controlsChange=()=>{switch(this.viewer.target.copy(this.orbit.target),this.viewer.update(),this.orbit.state){case sm:case om:this.viewer.emitEvent({type:"pan",x:this.orbit.panEnd.x,y:this.orbit.panEnd.y,dX:this.orbit.panDelta.x,dY:this.orbit.panDelta.y});break;case rm:this.viewer.emitEvent({type:"zoomat",data:this.orbit.dollyScale,x:this.orbit.dollyEnd.x,y:this.orbit.dollyEnd.y})}this.changed=!0},this.stopContextMenu=t=>{this.changed&&(t.preventDefault(),t.stopPropagation())},this.orbit=new cm(t.camera,t.canvas),this.orbit.mouseButtons={LEFT:y.ROTATE,MIDDLE:y.PAN,RIGHT:y.PAN},this.orbit.touches={ONE:x.ROTATE,TWO:x.DOLLY_PAN},this.orbit.screenSpacePanning=!0,this.orbit.rotateSpeed=.33,this.orbit.addEventListener("start",this.controlsStart),this.orbit.addEventListener("change",this.controlsChange),this.changed=!1,this.viewer=t,this.viewer.addEventListener("databasechunk",this.updateControls),this.viewer.on("viewposition",this.updateControls),this.viewer.addEventListener("zoom",this.updateControls),this.viewer.addEventListener("drawviewpoint",this.updateControls),this.viewer.addEventListener("contextmenu",this.stopContextMenu),this.updateControls()}initialize(){}dispose(){this.viewer.removeEventListener("databasechunk",this.updateControls),this.viewer.off("viewposition",this.updateControls),this.viewer.removeEventListener("zoom",this.updateControls),this.viewer.removeEventListener("drawviewpoint",this.updateControls),this.viewer.removeEventListener("contextmenu",this.stopContextMenu),this.orbit.removeEventListener("start",this.controlsStart),this.orbit.removeEventListener("change",this.controlsChange),this.orbit.dispose()}}class um extends dm{constructor(t,e,i){super(t),this.transformChange=()=>{this.plane.constant=-this.planeCenter.position.dot(this.plane.normal),this.viewer.update()},this.transformDrag=t=>{this.orbit.enabled=!t.value},this.updatePlaneSize=()=>{this.planeHelper.size=this.viewer.extents.getSize(new Ci).length(),this.viewer.update()},this.onDoubleClick=t=>{t.stopPropagation(),this.plane.negate(),this.viewer.update()};const n=t.extents.getSize(new Ci).length(),r=t.extents.getCenter(new Ci),s=-r.dot(e);this.plane=new Js(e,s),t.renderer.clippingPlanes||(t.renderer.clippingPlanes=[]),t.renderer.clippingPlanes.push(this.plane),this.planeHelper=new Qp(this.plane,n,i,r),this.viewer.helpers.add(this.planeHelper),this.planeCenter=new In,this.planeCenter.position.copy(t.extents.getCenter(new Ci)),this.viewer.helpers.add(this.planeCenter),this.transform=new Cp(t.camera,t.canvas),this.transform.showX=!!e.x,this.transform.showY=!!e.y,this.transform.showZ=!!e.z,this.transform.attach(this.planeCenter),this.transform.addEventListener("change",this.transformChange),this.transform.addEventListener("dragging-changed",this.transformDrag),this.viewer.helpers.add(this.transform.getHelper()),this.viewer.on("explode",this.updatePlaneSize),this.viewer.on("show",this.updatePlaneSize),this.viewer.on("showall",this.updatePlaneSize),this.viewer.canvas.addEventListener("dblclick",this.onDoubleClick,!0),this.viewer.update()}dispose(){this.viewer.off("explode",this.updatePlaneSize),this.viewer.off("show",this.updatePlaneSize),this.viewer.off("showAll",this.updatePlaneSize),this.viewer.canvas.removeEventListener("dblclick",this.onDoubleClick,!0),this.transform.removeEventListener("change",this.transformChange),this.transform.removeEventListener("dragging-changed",this.transformDrag),this.transform.getHelper().removeFromParent(),this.transform.detach(),this.transform.dispose(),this.planeHelper.removeFromParent(),this.planeHelper.dispose(),this.planeCenter.removeFromParent(),super.dispose()}}class pm extends um{constructor(t){super(t,new Ci(1,0,0),16711680)}}class mm extends um{constructor(t){super(t,new Ci(0,1,0),65280)}}class fm extends um{constructor(t){super(t,new Ci(0,0,1),255)}}class gm extends dm{constructor(t){super(t),this.onPointerDown=t=>{0===t.button&&(this.line.startPoint=this.snapper.getSnapPoint(t),this.line.render(),this.viewer.canvas.setPointerCapture(t.pointerId),this.orbit.enabled=!this.line.startPoint)},this.onPointerMove=t=>{this.orbit.enabled&&-1!==this.orbit.state||(this.line.endPoint=this.snapper.getSnapPoint(t),this.line.render(),this.line.startPoint&&(this.changed=!0))},this.onPointerUp=t=>{this.line.startPoint&&this.line.endPoint&&this.line.getDistance()>=.01?(this.line=new xm(this.overlay),this.overlay.addLine(this.line)):(this.line.startPoint=void 0,this.line.endPoint=void 0,this.line.render()),this.viewer.canvas.releasePointerCapture(t.pointerId),this.orbit.enabled=!0},this.onPointerCancel=t=>{this.viewer.canvas.dispatchEvent(new PointerEvent("pointerup",t))},this.onPointerLeave=()=>{this.line.endPoint=void 0,this.line.render()},this.renderOverlay=()=>{this.overlay.render()},this.updateSnapper=()=>{this.snapper.update(this.viewer.scene)},this.overlay=new _m(t.camera,t.canvas),this.overlay.attach(),this.line=new xm(this.overlay),this.overlay.addLine(this.line),this.snapper=new vm(t.camera,t.canvas),this.snapper.update(t.scene),this.viewer.canvas.addEventListener("pointerdown",this.onPointerDown),this.viewer.canvas.addEventListener("pointermove",this.onPointerMove),this.viewer.canvas.addEventListener("pointerup",this.onPointerUp),this.viewer.canvas.addEventListener("pointercancel",this.onPointerCancel),this.viewer.canvas.addEventListener("pointerleave",this.onPointerLeave),this.viewer.addEventListener("render",this.renderOverlay),this.viewer.addEventListener("hide",this.updateSnapper),this.viewer.addEventListener("isolate",this.updateSnapper),this.viewer.addEventListener("show",this.updateSnapper),this.viewer.addEventListener("showall",this.updateSnapper)}dispose(){this.viewer.canvas.removeEventListener("pointerdown",this.onPointerDown),this.viewer.canvas.removeEventListener("pointermove",this.onPointerMove),this.viewer.canvas.removeEventListener("pointerup",this.onPointerUp),this.viewer.canvas.removeEventListener("pointercancel",this.onPointerCancel),this.viewer.canvas.removeEventListener("pointerleave",this.onPointerLeave),this.viewer.removeEventListener("render",this.renderOverlay),this.viewer.removeEventListener("hide",this.updateSnapper),this.viewer.removeEventListener("isolate",this.updateSnapper),this.viewer.removeEventListener("show",this.updateSnapper),this.viewer.removeEventListener("showall",this.updateSnapper),this.overlay.detach(),this.overlay.dispose(),super.dispose()}}class vm{constructor(t,e){this.objects=[],this.camera=t,this.canvas=e,this.raycaster=new oc}getSnapPoint(t){const e=new $e(t.clientX,t.clientY),i=this.canvas.getBoundingClientRect(),n=(e.x-i.left)/i.width*2-1,r=-(e.y-i.top)/i.height*2+1,s=new $e(n,r);this.raycaster.setFromCamera(s,this.camera),this.raycaster.params={Mesh:{},Line:{threshold:.25},Line2:{threshold:.25},LOD:{},Points:{threshold:.1},Sprite:{}};const a=this.raycaster.intersectObjects(this.objects,!1);if(0!==a.length)return a[0].point}update(t){this.objects=[],t.traverseVisible((t=>this.objects.push(t)))}}class _m{constructor(t,e){this.lines=[],this.camera=t,this.canvas=e,this.projector=new Lm(t,e)}attach(){this.container=document.createElement("div"),this.container.id="measure-container",this.container.style.background="rgba(0,0,0,0)",this.container.style.position="absolute",this.container.style.top="0px",this.container.style.left="0px",this.container.style.width="100%",this.container.style.height="100%",this.container.style.outline="none",this.container.style.pointerEvents="none",this.container.style.overflow="hidden",this.canvas.parentElement.appendChild(this.container)}dispose(){this.clear()}detach(){this.container.remove(),this.container=void 0}clear(){this.lines.forEach((t=>t.dispose())),this.lines=[]}render(){this.projector.updateProjectionMatrix(),this.lines.forEach((t=>t.render()))}update(){this.lines.forEach((t=>t.update()))}addLine(t){this.lines.push(t)}removeLine(t){this.lines=this.lines.filter((e=>e!==t))}}const ym=new Ci;class xm{constructor(t){this.id=Date.now(),this.unit="",this.scale=1,this.size=10,this.lineWidth=2,this.style={border:"2px solid #FFFFFF",background:"#009bff",boxShadow:"0 0 10px rgba(0,0,0,0.5)",color:"white",font:"1rem system-ui"},this.overlay=t,this.elementStartPoint=t.container.appendChild(document.createElement("div")),this.elementEndPoint=t.container.appendChild(document.createElement("div")),this.elementLine=t.container.appendChild(document.createElement("div")),this.elementLabel=t.container.appendChild(document.createElement("div")),this.update()}dispose(){this.elementStartPoint.remove(),this.elementEndPoint.remove(),this.elementLine.remove(),this.elementLabel.remove()}render(){const t=this.overlay.projector;if(this.startPoint){const{point:e,visible:i}=t.projectPoint(this.startPoint);this.elementStartPoint.style.display=i?"block":"none",this.elementStartPoint.style.left=`${e.x}px`,this.elementStartPoint.style.top=`${e.y}px`}else this.elementStartPoint.style.display="none";if(this.endPoint){const{point:e,visible:i}=t.projectPoint(this.endPoint);this.elementEndPoint.style.display=i?"block":"none",this.elementEndPoint.style.left=`${e.x}px`,this.elementEndPoint.style.top=`${e.y}px`}else this.elementEndPoint.style.display="none";if(this.startPoint&&this.endPoint){const{point1:e,point2:i,visible:n}=t.projectLine(this.startPoint,this.endPoint);i.sub(e);const r=i.angle(),s=i.length();this.elementLine.style.display=n?"block":"none",this.elementLine.style.left=`${e.x}px`,this.elementLine.style.top=`${e.y}px`,this.elementLine.style.width=`${s}px`,this.elementLine.style.transform=`translate(0px, ${-this.lineWidth/2}px) rotate(${r}rad)`}else this.elementLine.style.display="none";if(this.startPoint&&this.endPoint){ym.lerpVectors(this.startPoint,this.endPoint,.5);const{point:e,visible:i}=t.projectPoint(ym),n=this.getDistance();this.elementLabel.style.display=i&&n>=.01?"block":"none",this.elementLabel.style.left=`${e.x}px`,this.elementLabel.style.top=`${e.y}px`,this.elementLabel.innerHTML=`${n.toFixed(2)} ${this.unit}`}else this.elementLabel.style.display="none"}update(){this.elementStartPoint.id=`markup-dot-start-${this.id}`,this.elementStartPoint.style.position="absolute",this.elementStartPoint.style.zIndex="2",this.elementStartPoint.style.width=`${this.size}px`,this.elementStartPoint.style.height=`${this.size}px`,this.elementStartPoint.style.border=this.style.border,this.elementStartPoint.style.borderRadius=`${this.size}px`,this.elementStartPoint.style.background=this.style.background,this.elementStartPoint.style.boxShadow=this.style.boxShadow,this.elementStartPoint.style.transform="translate(-50%, -50%)",this.elementEndPoint.id=`markup-dot-end-${this.id}`,this.elementEndPoint.style.position="absolute",this.elementEndPoint.style.zIndex="2",this.elementEndPoint.style.width=`${this.size}px`,this.elementEndPoint.style.height=`${this.size}px`,this.elementEndPoint.style.border=this.style.border,this.elementEndPoint.style.borderRadius=`${this.size}px`,this.elementEndPoint.style.background=this.style.background,this.elementEndPoint.style.boxShadow=this.style.boxShadow,this.elementEndPoint.style.transform="translate(-50%, -50%)",this.elementLine.id=`markup-line-${this.id}`,this.elementLine.style.position="absolute",this.elementLine.style.zIndex="1",this.elementLine.style.height=`${this.lineWidth}px`,this.elementLine.style.background=this.style.background,this.elementLine.style.boxShadow=this.style.boxShadow,this.elementLine.style.transformOrigin=`0px ${this.lineWidth/2}px`,this.elementLabel.id=`markup-label-${this.id}`,this.elementLabel.style.position="absolute",this.elementLabel.style.zIndex="3",this.elementLabel.style.padding="2px",this.elementLabel.style.paddingInline="5px",this.elementLabel.style.borderRadius="5px",this.elementLabel.style.background=this.style.background,this.elementLabel.style.boxShadow=this.style.boxShadow,this.elementLabel.style.color=this.style.color,this.elementLabel.style.font=this.style.font,this.elementLabel.style.transform="translate(-50%, -50%)"}getDistance(){return this.startPoint.distanceTo(this.endPoint)/this.scale}}let bm,wm;const Sm=new sn,Mm=new sn,Tm=new Ci,Em=new wi,Am=new wi,Cm=new $e,Rm=new $e,Pm=new $e;class Lm{constructor(t,e){this.camera=t,this.canvas=e}updateProjectionMatrix(){const t=this.canvas.getBoundingClientRect();bm=t.width/2,wm=t.height/2,Sm.copy(this.camera.matrixWorldInverse),Mm.multiplyMatrices(this.camera.projectionMatrix,Sm)}projectPoint(t){Tm.copy(t).applyMatrix4(Mm);const e=Tm.z>=-1&&Tm.z<=1;return Cm.x=(Tm.x+1)*bm,Cm.y=(1-Tm.y)*wm,{point:Cm,visible:e}}projectLine(t,e){let i;Em.copy(t).applyMatrix4(Mm),Am.copy(e).applyMatrix4(Mm);const n=Em.z+Em.w,r=Am.z+Am.w,s=-Em.z+Em.w,a=-Am.z+Am.w;if(n>=0&&r>=0&&s>=0&&a>=0)i=!0;else if(n<0&&r<0||s<0&&a<0)i=!1;else{let t=0,e=1;n<0?t=Math.max(t,n/(n-r)):r<0&&(e=Math.min(e,n/(n-r))),s<0?t=Math.max(t,s/(s-a)):a<0&&(e=Math.min(e,s/(s-a))),i=e>=t,i&&(Em.lerp(Am,t),Am.lerp(Em,1-e))}return Em.multiplyScalar(1/Em.w),Am.multiplyScalar(1/Am.w),Rm.x=(Em.x+1)*bm,Rm.y=(1-Em.y)*wm,Pm.x=(Am.x+1)*bm,Pm.y=(1-Am.y)*wm,{point1:Rm,point2:Pm,visible:i}}}class Im extends dm{constructor(t){super(t),this.orbit.mouseButtons={LEFT:y.PAN,MIDDLE:y.PAN,RIGHT:y.PAN}}}class Dm extends Dc{constructor(t,e){super(t,e),this.movementSpeed=.2,this.lookSpeed=5,this.multiplier=5,this.moveWheel=0,this.mouseDragOn=!1,this.onPointerDown=t=>{0===t.button&&(this.domElement.setPointerCapture(t.pointerId),this.downPosition.set(t.clientX,t.clientY),this.quaternion.copy(this.object.quaternion),this.mouseDragOn=!0)},this.onPointerMove=t=>{if(!this.mouseDragOn)return;const e=new $e(t.clientX,t.clientY);0!==this.downPosition.distanceTo(e)&&(this.rotateDelta.copy(this.downPosition).sub(e),this.rotateCamera(this.rotateDelta),this.dispatchEvent({type:"change"}))},this.onPointerUp=t=>{this.domElement.releasePointerCapture(t.pointerId),this.mouseDragOn=!1},this.onPointerCancel=t=>{this.domElement.dispatchEvent(new PointerEvent("pointerup",t))},this.onWheel=t=>{this.moveWheel=t.deltaY,this.update()},this.onKeyDown=t=>{switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"KeyW":case"KeyS":case"KeyA":case"KeyD":case"KeyQ":case"KeyE":this.moveKeys.add(t.code),this.update()}},this.onKeyUp=t=>{this.moveKeys.delete(t.code)&&this.update()},this.moveKeys=new Set,this.moveClock=new Ul,this.quaternion=t.quaternion.clone(),this.downPosition=new $e(0,0),this.rotateDelta=new $e(0,0),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onWheel),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}dispose(){this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onWheel),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),super.dispose()}update(){if(this.moveKeys.size>0){const t=this.moveClock.getDelta()*this.movementSpeed*this.multiplier;this.moveKeys.has("KeyW")&&this.object.translateZ(-t),this.moveKeys.has("KeyS")&&this.object.translateZ(t),this.moveKeys.has("KeyA")&&this.object.translateX(-t),this.moveKeys.has("KeyD")&&this.object.translateX(t),this.moveKeys.has("KeyQ")&&this.object.translateY(t),this.moveKeys.has("KeyE")&&this.object.translateY(-t);const e=this.lookSpeed+(this.multiplier-1);this.moveKeys.has("ArrowUp")&&this.rotateCamera(this.rotateDelta.add(new $e(0,-e/2))),this.moveKeys.has("ArrowDown")&&this.rotateCamera(this.rotateDelta.add(new $e(0,e/2))),this.moveKeys.has("ArrowLeft")&&this.rotateCamera(this.rotateDelta.add(new $e(e,0))),this.moveKeys.has("ArrowRight")&&this.rotateCamera(this.rotateDelta.add(new $e(-e,0))),this.moveWheel=0,this.dispatchEvent({type:"change"})}if(0!==this.moveWheel){const t=1e-4*this.moveWheel*this.movementSpeed*this.multiplier;this.object.translateZ(-t),this.moveWheel+=-1*Math.sign(this.moveWheel),this.dispatchEvent({type:"change"})}0===this.moveKeys.size&&0===this.moveWheel&&(this.moveClock.stop(),this.moveClock.autoStart=!0)}rotateCamera(t){const e=Math.PI*t.x/this.domElement.clientWidth,i=Math.PI*t.y/this.domElement.clientHeight,n=new Ai;n.setFromAxisAngle(this.object.up,e);const r=new Ai;r.setFromAxisAngle(new Ci(1,0,0),i);const s=this.quaternion.clone();s.premultiply(n).multiply(r).normalize(),this.object.setRotationFromQuaternion(s)}}class Om{constructor(t){this.updateControls=()=>{const t=this.viewer.extents.getSize(new Ci);this.controls.movementSpeed=Math.min(t.x,t.y,t.z)/2},this.controlsChange=()=>{this.viewer.update()},this.walkspeedChange=t=>{this.viewer.emitEvent(t)},this.viewerRender=()=>{this.controls.update()},this.viewerZoom=()=>{this.controls.rotateDelta.set(0,0)},this.controls=new Dm(t.camera,t.canvas),this.controls.addEventListener("change",this.controlsChange),this.controls.addEventListener("walkspeedchange",this.walkspeedChange),this.viewer=t,this.viewer.on("render",this.viewerRender),this.viewer.on("zoom",this.viewerZoom),this.updateControls()}dispose(){this.viewer.off("render",this.viewerRender),this.viewer.off("zoom",this.viewerZoom),this.controls.removeEventListener("walkspeedchange",this.walkspeedChange),this.controls.removeEventListener("change",this.controlsChange),this.controls.dispose()}}class Nm extends dm{constructor(t){super(t),this.orbit.mouseButtons={LEFT:y.DOLLY,MIDDLE:y.PAN,RIGHT:y.PAN}}}const Um=a("threejs");function Fm(t,e=0){t.models.forEach((t=>t.explode(e))),t.update(),t.emitEvent({type:"explode",data:e})}function km(t,e){if(e.isEmpty())return;const i=e.getCenter(new Ci),n=e.getBoundingSphere(new Ki),r=t.renderer.getSize(new $e),s=r.x/r.y,a=t.camera;if(a.isPerspectiveCamera){const t=new Ci(0,0,1);t.applyQuaternion(a.quaternion),t.multiplyScalar(n.radius/Math.tan(Qe.DEG2RAD*a.fov*.5)),a.position.copy(i).add(t),a.updateMatrixWorld()}if(a.isOrthographicCamera){a.top=n.radius,a.bottom=-n.radius,a.left=a.bottom*s,a.right=a.top*s,a.zoom=1,a.updateProjectionMatrix();const e=new Ci(0,0,1);e.applyQuaternion(a.quaternion),e.multiplyScalar(3*t.extents.getBoundingSphere(new Ki).radius),a.position.copy(i).add(e),a.updateMatrixWorld()}t.target.copy(i),t.update(),t.emitEvent({type:"zoom"})}Um.registerDragger("Pan",(t=>new Im(t))),Um.registerDragger("Orbit",(t=>new dm(t))),Um.registerDragger("Zoom",(t=>new Nm(t))),Um.registerDragger("MeasureLine",(t=>new gm(t))),Um.registerDragger("CuttingPlaneXAxis",(t=>new pm(t))),Um.registerDragger("CuttingPlaneYAxis",(t=>new mm(t))),Um.registerDragger("CuttingPlaneZAxis",(t=>new fm(t))),Um.registerDragger("Walk",(t=>new Om(t)));const Bm={top:new Ci(0,0,1),bottom:new Ci(0,0,-1),left:new Ci(-1,0,0),right:new Ci(1,0,0),front:new Ci(0,-1,0),back:new Ci(0,1,0),sw:new Ci(-.5,-.5,1).normalize(),se:new Ci(.5,-.5,1).normalize(),ne:new Ci(.5,.5,1).normalize(),nw:new Ci(-.5,.5,1).normalize()};function zm(t,e){const i=Bm[e]||Bm.sw,n=t.extents.getCenter(new Ci),r=t.extents.getBoundingSphere(new Ki),s=i.clone().multiplyScalar(r.radius),a=t.camera;a.position.copy(n).add(s),a.lookAt(n),a.updateMatrixWorld(),t.target.copy(n),t.update(),t.emit({type:"viewposition",data:e}),km(t,t.extents)}const Gm=n("threejs");Gm.registerCommand("applyModelTransform",(function(t,e){console.warn("applyModelTransform not implemented")})),Gm.registerCommand("clearMarkup",(function(t){t.clearOverlay()})),Gm.registerCommand("clearSelected",(function(t){t.getComponent("SelectionComponent").clearSelection(),t.update(),t.emitEvent({type:"select",data:void 0,handles:[]})})),Gm.registerCommand("clearSlices",(function(t){t.clearSlices()})),Gm.registerCommand("createPreview",(function(t,e="image/jpeg",i=.25){return t.update(!0),t.canvas.toDataURL(e,i)})),Gm.registerCommand("explode",Fm),Gm.registerCommand("collect",(function(t){Fm(t,0)})),Gm.registerCommand("getDefaultViewPositions",(function(){return Object.keys(Bm)})),Gm.registerCommand("getModels",(function(t){return t.models.map((t=>t.handle))})),Gm.registerCommand("getSelected",(function(t){const e=[];return t.models.forEach((i=>e.push(...i.getHandlesByObjects(t.selected)))),e})),Gm.registerCommand("hideSelected",(function(t){t.models.forEach((e=>e.hideObjects(t.selected))),t.getComponent("SelectionComponent").clearSelection(),t.update(),t.emitEvent({type:"hide"}),t.emitEvent({type:"select",data:void 0,handles:[]})})),Gm.registerCommand("isolateSelected",(function(t){t.models.forEach((e=>e.isolateObjects(t.selected))),t.update(),t.emitEvent({type:"isolate"})})),Gm.registerCommand("regenerateAll",(function(t){t.emit({type:"regenerateall"})})),Gm.registerCommand("resetView",(function(t){t.executeCommand("setActiveDragger"),t.executeCommand("clearSlices"),t.executeCommand("clearOverlay"),t.executeCommand("setMarkupColor"),t.executeCommand("clearSelected"),t.executeCommand("showAll"),t.executeCommand("explode",0),t.executeCommand("zoomToExtents",!0),t.executeCommand("k3DViewSW"),t.emit({type:"resetview"})})),Gm.registerCommand("selectModel",(function(t,e){const i=t.getComponent("SelectionComponent");i.clearSelection(),t.models.filter((t=>t.handle===e)).forEach((t=>i.select(t.getObjects(),t))),t.update(),t.emit({type:"select",data:[]})})),Gm.registerCommand("setActiveDragger",(function(t,e=""){t.setActiveDragger(e)})),Gm.registerCommand("setDefaultViewPosition",zm),Gm.registerCommand("setMarkupColor",(function(t,e=255,i=0,n=0){t.markup.setMarkupColor(e,i,n)})),Gm.registerCommand("setSelected",(function(t,e=[]){const i=t.getComponent("SelectionComponent");i.clearSelection(),t.models.forEach((t=>{const n=t.getObjectsByHandles(e);i.select(n,t)})),t.update(),t.emitEvent({type:"show"}),t.emitEvent({type:"select",data:void 0,handles:e})})),Gm.registerCommand("showAll",(function(t){t.models.forEach((t=>t.showAllObjects())),t.update(),t.emitEvent({type:"showall"})})),Gm.registerCommand("zoomToExtents",(function(t){km(t,t.extents)})),Gm.registerCommand("zoomToObjects",(function(t,e=[]){const i=new Set(e),n=[];t.scene.traverseVisible((t=>{var e;i.has(null===(e=t.userData)||void 0===e?void 0:e.handle)&&n.push(t)}));const r=n.reduce(((t,e)=>t.expandByObject(e)),new Li);r.isEmpty()&&r.copy(t.extents),km(t,r)})),Gm.registerCommand("zoomToSelected",(function(t){const e=t.selected.reduce(((t,e)=>t.expandByObject(e)),new Li);e.isEmpty()&&e.copy(t.extents),km(t,e)})),Gm.registerCommand("top",(t=>zm(t,"top"))),Gm.registerCommand("bottom",(t=>zm(t,"bottom"))),Gm.registerCommand("left",(t=>zm(t,"left"))),Gm.registerCommand("right",(t=>zm(t,"right"))),Gm.registerCommand("front",(t=>zm(t,"front"))),Gm.registerCommand("back",(t=>zm(t,"back"))),Gm.registerCommand("sw",(t=>zm(t,"sw"))),Gm.registerCommand("se",(t=>zm(t,"se"))),Gm.registerCommand("ne",(t=>zm(t,"ne"))),Gm.registerCommand("nw",(t=>zm(t,"nw"))),Gm.registerCommandAlias("clearMarkup","clearOverlay"),Gm.registerCommandAlias("clearSelected","unselect"),Gm.registerCommandAlias("zoomToExtents","zoomExtents"),Gm.registerCommandAlias("top","k3DViewTop"),Gm.registerCommandAlias("bottom","k3DViewBottom"),Gm.registerCommandAlias("left","k3DViewLeft"),Gm.registerCommandAlias("right","k3DViewRight"),Gm.registerCommandAlias("front","k3DViewFront"),Gm.registerCommandAlias("back","k3DViewBack"),Gm.registerCommandAlias("se","k3DViewSE"),Gm.registerCommandAlias("sw","k3DViewSW"),Gm.registerCommandAlias("ne","k3DViewNE"),Gm.registerCommandAlias("nw","k3DViewNW");class Hm{constructor(t){this.syncOptions=()=>{this.backgroundColor.setHex(16777215),this.viewer.renderer.setClearColor(this.backgroundColor)},this.viewer=t,this.backgroundColor=new Jn(16777215),this.viewer.renderer.setClearColor(this.backgroundColor),this.viewer.scene.background=this.backgroundColor,this.viewer.addEventListener("optionschange",this.syncOptions)}dispose(){this.viewer.removeEventListener("optionschange",this.syncOptions),this.viewer.scene.background=void 0}}class Vm{constructor(t){this.geometryEnd=()=>{const t=this.viewer.extents.getCenter(new Ci),e=2*this.viewer.extents.getBoundingSphere(new Ki).radius,i=this.viewer.renderer.getSize(new $e),n=i.x/i.y;let r;this.viewer.scene.traverse((t=>{t.isCamera&&(r?t.isPerspectiveCamera&&r.isOrthographicCamera&&(r=t):r=t)})),r&&(this.viewer.camera=r.clone(),this.viewer.camera.up.set(0,0,1),this.viewer.camera.scale.set(1,1,1));const s=this.viewer.camera;s.isPerspectiveCamera&&(s.aspect=n,s.near=e/100,s.far=100*e,s.updateProjectionMatrix()),s.isOrthographicCamera&&(s.left=s.bottom*n,s.right=s.top*n,s.near=0,s.far=100*e,s.updateProjectionMatrix()),this.viewer.target.copy(t),r||this.viewer.executeCommand("setDefaultViewPosition")},this.viewer=t,this.viewer.addEventListener("databasechunk",this.geometryEnd)}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd)}}class Wm{constructor(t){this.syncExtents=()=>{const t=new Li;this.viewer.models.forEach((e=>e.getExtents(t))),this.viewer.extents.copy(t)},this.viewer=t,this.viewer.addEventListener("databasechunk",this.syncExtents),this.viewer.addEventListener("clear",this.syncExtents),this.viewer.on("explode",this.syncExtents),this.viewer.on("hide",this.syncExtents),this.viewer.on("isolate",this.syncExtents),this.viewer.on("show",this.syncExtents),this.viewer.on("showall",this.syncExtents)}dispose(){this.viewer.removeEventListener("databasechunk",this.syncExtents),this.viewer.removeEventListener("clear",this.syncExtents),this.viewer.off("explode",this.syncExtents),this.viewer.off("hide",this.syncExtents),this.viewer.off("isolate",this.syncExtents),this.viewer.off("show",this.syncExtents),this.viewer.off("showall",this.syncExtents)}}class jm{constructor(t){this.geometryEnd=()=>{if(this.ambientLight.removeFromParent(),this.directionalLight.removeFromParent(),this.frontLight.removeFromParent(),this.hemisphereLight.removeFromParent(),this.viewer.extents.isEmpty())return;const t=this.viewer.extents.getCenter(new Ci),e=this.viewer.extents.getBoundingSphere(new Ki).radius;this.directionalLight.position.set(.5,0,.866).multiplyScalar(2*e).add(t),this.directionalLight.target.position.copy(t),this.frontLight.position.set(0,2*e,0).add(t),this.frontLight.target.position.copy(t),this.hemisphereLight.position.set(0,3*e,0).add(t),this.viewer.scene.add(this.ambientLight),this.viewer.scene.add(this.directionalLight),this.viewer.scene.add(this.frontLight),this.viewer.scene.add(this.hemisphereLight)},this.viewer=t,this.ambientLight=new _l(16777215,1),this.viewer.scene.add(this.ambientLight),this.directionalLight=new vl(16777215,1),this.directionalLight.position.set(.5,0,.866),this.viewer.scene.add(this.directionalLight),this.frontLight=new vl(16777215,1.25),this.frontLight.position.set(0,1,0),this.viewer.scene.add(this.frontLight),this.hemisphereLight=new nl(16777215,4473924,1.25),this.hemisphereLight.position.set(0,0,1),this.viewer.scene.add(this.hemisphereLight),this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("clear",this.geometryEnd)}dispose(){this.ambientLight.removeFromParent(),this.ambientLight.dispose(),this.directionalLight.removeFromParent(),this.directionalLight.dispose(),this.frontLight.removeFromParent(),this.frontLight.dispose(),this.hemisphereLight.removeFromParent(),this.hemisphereLight.dispose(),this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("clear",this.geometryEnd)}}class Xm{constructor(t){this.animate=(t=0)=>{this.requestId=requestAnimationFrame(this.animate),this.viewer.render(t),this.viewer.emitEvent({type:"animate",time:t})},this.viewer=t,this.animate()}dispose(){cancelAnimationFrame(this.requestId)}}class Ym{constructor(t){this.resizeViewer=t=>{const{width:e,height:i}=t[0].contentRect;if(!e||!i)return;const n=this.viewer.camera,r=e/i;n.isPerspectiveCamera&&(n.aspect=r,n.updateProjectionMatrix()),n.isOrthographicCamera&&(n.left=n.bottom*r,n.right=n.top*r,n.updateProjectionMatrix()),this.viewer.renderer.setSize(e,i,!0),this.viewer.update(!0),this.viewer.emitEvent({type:"resize",width:e,height:i})},this.viewer=t,this.resizeObserver=new ResizeObserver(this.resizeViewer),this.resizeObserver.observe(t.canvas.parentElement)}dispose(){this.resizeObserver.disconnect()}}const qm=new Li,Km=new Ci;class Zm extends Ml{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new pr([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new pr([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,i=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),i.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new sc(e,6,1);return this.setAttribute("instanceStart",new rs(i,3,0)),this.setAttribute("instanceEnd",new rs(i,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new sc(e,6,1);return this.setAttribute("instanceColorStart",new rs(i,3,0)),this.setAttribute("instanceColorEnd",new rs(i,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new uh(t.geometry)),this}fromLineSegments(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Li);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),qm.setFromBufferAttribute(e),this.boundingBox.union(qm))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Ki),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let n=0;for(let r=0,s=t.count;r<s;r++)Km.fromBufferAttribute(t,r),n=Math.max(n,i.distanceToSquared(Km)),Km.fromBufferAttribute(e,r),n=Math.max(n,i.distanceToSquared(Km));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(t){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(t)}}Bc.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new $e(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},zc.line={uniforms:Br.merge([Bc.common,Bc.fog,Bc.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class Jm extends zr{constructor(t){super({type:"LineMaterial",uniforms:Br.clone(zc.line.uniforms),vertexShader:zc.line.vertexShader,fragmentShader:zc.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(t)}get color(){return this.uniforms.diffuse.value}set color(t){this.uniforms.diffuse.value=t}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(t){this.uniforms.linewidth&&(this.uniforms.linewidth.value=t)}get dashed(){return"USE_DASH"in this.defines}set dashed(t){!0===t!==this.dashed&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(t){this.uniforms.dashScale.value=t}get dashSize(){return this.uniforms.dashSize.value}set dashSize(t){this.uniforms.dashSize.value=t}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(t){this.uniforms.dashOffset.value=t}get gapSize(){return this.uniforms.gapSize.value}set gapSize(t){this.uniforms.gapSize.value=t}get opacity(){return this.uniforms.opacity.value}set opacity(t){this.uniforms&&(this.uniforms.opacity.value=t)}get resolution(){return this.uniforms.resolution.value}set resolution(t){this.uniforms.resolution.value.copy(t)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(t){this.defines&&(!0===t!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===t?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const Qm=new Ci,$m=new Ci,tf=new wi;class ef extends Dr{constructor(t=new Zm,e=new Jm({color:16777215*Math.random()})){super(t,e),this.isWireframe=!0,this.type="Wireframe"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,n=new Float32Array(2*e.count);for(let t=0,r=0,s=e.count;t<s;t++,r+=2)Qm.fromBufferAttribute(e,t),$m.fromBufferAttribute(i,t),n[r]=0===r?0:n[r-1],n[r+1]=n[r]+Qm.distanceTo($m);const r=new sc(n,2,1);return t.setAttribute("instanceDistanceStart",new rs(r,1,0)),t.setAttribute("instanceDistanceEnd",new rs(r,1,1)),this}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(tf),this.material.uniforms.resolution.value.set(tf.z,tf.w))}}class nf{static isBreak(t,e){return isNaN(t[e])||isNaN(t[e+1])||isNaN(t[e+2])||t[e]===1/0||t[e]===-1/0||t[e+1]===1/0||t[e+1]===-1/0||t[e+2]===1/0||t[e+2]===-1/0}static fromIndexedLine(t,e){const i=new Zm,n=[];for(let i=0;i<e.length;i+=2){const r=3*e[i],s=3*e[i+1];-1!==e[i]&&-1!==e[i+1]&&n.push(t[r],t[r+1],t[r+2],t[s],t[s+1],t[s+2])}return 0===n.length?null:(i.setPositions(n),i)}static fromNonIndexedLine(t,e){const i=new Zm,n=[];if(e)for(let e=0;e<t.length&&!(e+5>=t.length);e+=6)nf.isBreak(t,e)||nf.isBreak(t,e+3)||n.push(t[e],t[e+1],t[e+2],t[e+3],t[e+4],t[e+5]);else{let e=-1;for(let i=0;i<t.length;i+=3)nf.isBreak(t,i)?e=-1:(-1!==e&&n.push(t[e],t[e+1],t[e+2],t[i],t[i+1],t[i+2]),e=i)}return 0===n.length?null:(i.setPositions(n),i)}}class rf{constructor(t){this.geometryEnd=()=>{const{facesColor:t,facesTransparancy:e,edgesColor:i}=this.viewer.options;this.highlightMaterial=new er({color:new Jn(t.r/255,t.g/255,t.b/255),transparent:!0,opacity:(255-e)/255,depthTest:!1,depthWrite:!1}),this.outlineMaterial=new Jm({color:new Jn(i.r/255,i.g/255,i.b/255),linewidth:1.5,depthTest:!1,depthWrite:!1,resolution:new $e(window.innerWidth,window.innerHeight)}),this.highlightLineMaterial=new ya({color:new Jn(t.r/255,t.g/255,t.b/255),depthTest:!1,depthWrite:!1}),this.highlightLineGlowMaterial=new Jm({color:new Jn(t.r/255,t.g/255,t.b/255),linewidth:5,transparent:!0,opacity:.8,depthTest:!0,depthWrite:!0,resolution:new $e(window.innerWidth,window.innerHeight)})},this.optionsChange=()=>{const{facesColor:t,facesTransparancy:e,edgesColor:i}=this.viewer.options;this.highlightMaterial.color.setRGB(t.r/255,t.g/255,t.b/255),this.highlightMaterial.opacity=(255-e)/255,this.outlineMaterial.color.setRGB(i.r/255,i.g/255,i.b/255),this.highlightLineMaterial.color.setRGB(t.r/255,t.g/255,t.b/255),this.highlightLineGlowMaterial.color.setRGB(t.r/255,t.g/255,t.b/255),this.viewer.update()},this.viewer=t;if(t.canvas.getContext("webgl2")){const e=t.renderer.getSize(new $e);this.renderTarget=new Mi(e.x,e.y,{format:At,stencilBuffer:!1,samples:4,type:pt})}this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("resize",this.viewerResize),this.geometryEnd()}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("resize",this.viewerResize)}highlight(t){Array.isArray(t)||(t=[t]),t.length&&t.forEach((t=>{if(!t.isHighlighted)if(t.isLine||t.isLineSegments){const e=t.geometry.attributes.position.array,i=t.geometry.index?t.geometry.index.array:null,n=i?nf.fromIndexedLine(e,i):nf.fromNonIndexedLine(e,t.isLineSegments),r=new ef(n,this.highlightLineGlowMaterial);r.position.copy(t.position),r.rotation.copy(t.rotation),r.scale.copy(t.scale),t.parent.add(r),t.userData.highlightwireframe=r,t.userData.originalMaterial=t.material,t.material=this.highlightLineMaterial,t.isHighlighted=!0}else if(t.isMesh){const e=new Mo(t.geometry,30),i=(new Zm).fromEdgesGeometry(e),n=new ef(i,this.outlineMaterial);n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),t.parent.add(n),t.userData.highlightwireframe=n,t.userData.originalMaterial=t.material,t.material=this.highlightMaterial,t.isHighlighted=!0}}))}unhighlight(t){Array.isArray(t)||(t=[t]),t.length&&t.forEach((t=>{t.isHighlighted&&(t.isHighlighted=!1,t.material=t.userData.originalMaterial,t.userData.highlightwireframe.removeFromParent(),delete t.userData.originalMaterial,delete t.userData.highlightwireframe)}))}viewerResize(t){var e,i;null===(e=this.renderTarget)||void 0===e||e.setSize(t.width,t.height),null===(i=this.outlineMaterial)||void 0===i||i.resolution.set(t.width,t.height)}}class sf{constructor(t){this.onPointerDown=t=>{t.isPrimary&&0===t.button&&this.getMousePosition(t,this.downPosition)},this.onPointerUp=t=>{if(!t.isPrimary)return;const e=this.getMousePosition(t,new $e);if(0!==e.distanceTo(this.downPosition))return;let i=[];if(this.viewer.models.forEach((t=>{const n=t.getVisibleObjects(),r=this.getPointerIntersects(e,n);i.push(...r.map((e=>({...e,model:t}))))})),i=i.sort(((t,e)=>t.distance-e.distance)),t.shiftKey||this.clearSelection(),i.length>0){const e=i[0].model,n=e.getHandlesByObjects(i[0].object),r=e.getObjectsByHandles(n);t.shiftKey?this.toggleSelection(r,e):this.select(r,e)}this.viewer.update(),this.viewer.emitEvent({type:"select",data:void 0,handles:this.viewer.getSelected()})},this.onDoubleClick=t=>{0===t.button&&this.viewer.executeCommand("zoomToSelected")},this.initHighlighter=()=>{this.highlighter=this.viewer.getComponent("HighlighterComponent")},this.viewer=t,this.raycaster=new oc,this.downPosition=new $e,this.viewer.addEventListener("pointerdown",this.onPointerDown),this.viewer.addEventListener("pointerup",this.onPointerUp),this.viewer.addEventListener("dblclick",this.onDoubleClick),this.viewer.addEventListener("initialize",this.initHighlighter)}dispose(){this.viewer.removeEventListener("pointerdown",this.onPointerDown),this.viewer.removeEventListener("pointerup",this.onPointerUp),this.viewer.removeEventListener("dblclick",this.onDoubleClick),this.viewer.removeEventListener("initialize",this.initHighlighter)}getMousePosition(t,e){return e.set(t.clientX,t.clientY)}getPointerIntersects(t,e){const i=this.viewer.canvas.getBoundingClientRect(),n=(t.x-i.left)/i.width*2-1,r=-(t.y-i.top)/i.height*2+1,s=new $e(n,r);return this.raycaster.setFromCamera(s,this.viewer.camera),this.raycaster.params=this.raycaster.params={Mesh:{},Line:{threshold:.25},Line2:{threshold:.25},LOD:{},Points:{threshold:.1},Sprite:{}},this.raycaster.intersectObjects(e,!1)}select(t,e){e?(Array.isArray(t)||(t=[t]),t.length&&(e.showObjects(t),e.showOriginalObjects(t),this.highlighter.highlight(t),t.forEach((t=>this.viewer.selected.push(t))),t.forEach((t=>t.isSelected=!0)))):this.viewer.models.forEach((e=>this.select(t,e)))}deselect(t,e){e?(Array.isArray(t)||(t=[t]),t.length&&(this.highlighter.unhighlight(t),e.hideOriginalObjects(t),this.viewer.selected=this.viewer.selected.filter((e=>!t.includes(e))),t.forEach((t=>t.isSelected=!1)))):this.viewer.models.forEach((e=>this.select(t,e)))}toggleSelection(t,e){Array.isArray(t)||(t=[t]),t.length&&(t[0].isSelected?this.deselect(t,e):this.select(t,e))}clearSelection(){this.viewer.selected.length&&(this.highlighter.unhighlight(this.viewer.selected),this.viewer.models.forEach((t=>t.hideOriginalObjects(this.viewer.selected))),this.viewer.selected.forEach((t=>t.isSelected=!1)),this.viewer.selected.length=0)}}class af extends In{constructor(t){super(),this.camera=t,this.size=160,this.orthoCamera=new fl(-2,2,2,-2,0,4),this.orthoCamera.position.set(0,0,2);const e=new er({toneMapped:!1,color:"#aa0000"}),i=new er({toneMapped:!1,color:"#00aa00"}),n=new er({toneMapped:!1,color:"#0000aa"}),r=this.getSpriteMaterial(e.color,"X"),s=this.getSpriteMaterial(i.color,"Y"),a=this.getSpriteMaterial(n.color,"Z"),o=new go(.01,.01,1,3);o.translate(0,.5,0);const h=new go(0,.1,.25,12);h.translate(0,.625,0);const l={X:[[new Dr(h,e),[.5,0,0],[0,0,-Math.PI/2]],[new Dr(o,e),[0,0,0],[0,0,-Math.PI/2]],[new ys(r),[1.55,0,0]]],Y:[[new Dr(h,i),[0,.5,0],null],[new Dr(o,i),null,null],[new ys(s),[0,1.55,0]]],Z:[[new Dr(h,n),[0,0,.5],[Math.PI/2,0,0]],[new Dr(o,n),null,[Math.PI/2,0,0]],[new ys(a),[0,0,1.55]]]};Object.keys(l).forEach((t=>{l[t].forEach((e=>{const i=e[0],n=e[1],r=e[2];i.name=t,n&&i.position.set(n[0],n[1],n[2]),r&&i.rotation.set(r[0],r[1],r[2]),i.updateMatrixWorld(),this.add(i)}))}))}dispose(){this.traverse((t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()}))}getSpriteMaterial(t,e){const i=document.createElement("canvas");i.width=64,i.height=64;const n=i.getContext("2d");n.clearRect(0,0,64,64),n.font="24px Arial",n.textAlign="center",n.fillStyle=t.getStyle(),n.fillText(e,32,41);const r=new Ha(i);return r.colorSpace=Me,new ss({map:r,toneMapped:!1})}render(t){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld();const e=t.clippingPlanes,i=t.getViewport(new wi);t.setViewport(this.position.x,this.position.y,this.size,this.size),t.clippingPlanes=[],t.clearDepth(),t.render(this,this.orthoCamera),t.setViewport(i),t.clippingPlanes=e}}class of{constructor(t){this.geometryEnd=()=>{this.wcsHelper.dispose(),this.wcsHelper=new af(this.viewer.camera)},this.viewerRender=()=>{this.viewer.options.showWCS&&this.wcsHelper.render(this.viewer.renderer)},this.wcsHelper=new af(t.camera),this.viewer=t,this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("drawviewpoint",this.geometryEnd),this.viewer.addEventListener("render",this.viewerRender)}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("drawviewpoint",this.geometryEnd),this.viewer.removeEventListener("render",this.viewerRender),this.wcsHelper.dispose()}}const hf=l("threejs");function lf(t,e=!1){const i=null!==t[0].index,n=new Set(Object.keys(t[0].attributes)),r=new Set(Object.keys(t[0].morphAttributes)),s={},a={},o=t[0].morphTargetsRelative,h=new br;let l=0;for(let c=0;c<t.length;++c){const d=t[c];let u=0;if(i!==(null!==d.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const t in d.attributes){if(!n.has(t))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+t+'" attribute exists among all geometries, or in none of them.'),null;void 0===s[t]&&(s[t]=[]),s[t].push(d.attributes[t]),u++}if(u!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const t in d.morphAttributes){if(!r.has(t))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;void 0===a[t]&&(a[t]=[]),a[t].push(d.morphAttributes[t])}if(e){let t;if(i)t=d.index.count;else{if(void 0===d.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;t=d.attributes.position.count}h.addGroup(l,t,c),l+=t}}if(i){let e=0;const i=[];for(let n=0;n<t.length;++n){const r=t[n].index;for(let t=0;t<r.count;++t)i.push(r.getX(t)+e);e+=t[n].attributes.position.count}h.setIndex(i)}for(const t in s){const e=cf(s[t]);if(!e)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+t+" attribute."),null;h.setAttribute(t,e)}for(const t in a){const e=a[t][0].length;if(0===e)break;h.morphAttributes=h.morphAttributes||{},h.morphAttributes[t]=[];for(let i=0;i<e;++i){const e=[];for(let n=0;n<a[t].length;++n)e.push(a[t][n][i]);const n=cf(e);if(!n)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+t+" morphAttribute."),null;h.morphAttributes[t].push(n)}}return h}function cf(t){let e,i,n,r=-1,s=0;for(let a=0;a<t.length;++a){const o=t[a];if(void 0===e&&(e=o.array.constructor),e!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===i&&(i=o.itemSize),i!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===n&&(n=o.normalized),n!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===r&&(r=o.gpuType),r!==o.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=o.count*i}const a=new e(s),o=new cr(a,i,n);let h=0;for(let e=0;e<t.length;++e){const n=t[e];if(n.isInterleavedBufferAttribute){const t=h/i;for(let e=0,r=n.count;e<r;e++)for(let r=0;r<i;r++){const i=n.getComponent(e,r);o.setComponent(e+t,r,i)}}else a.set(n.array,h);h+=n.count*i}return void 0!==r&&(o.gpuType=r),o}function df(t,e){if(0===e)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(2===e||1===e){let i=t.getIndex();if(null===i){const e=[],n=t.getAttribute("position");if(void 0===n)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<n.count;t++)e.push(t);t.setIndex(e),i=t.getIndex()}const n=i.count-2,r=[];if(2===e)for(let t=1;t<=n;t++)r.push(i.getX(0)),r.push(i.getX(t)),r.push(i.getX(t+1));else for(let t=0;t<n;t++)t%2==0?(r.push(i.getX(t)),r.push(i.getX(t+1)),r.push(i.getX(t+2))):(r.push(i.getX(t+2)),r.push(i.getX(t+1)),r.push(i.getX(t)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=t.clone();return s.setIndex(r),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),t}hf.registerComponent("ExtentsComponent",(t=>new Wm(t))),hf.registerComponent("CameraComponent",(t=>new Vm(t))),hf.registerComponent("BackgroundComponent",(t=>new Hm(t))),hf.registerComponent("LightComponent",(t=>new jm(t))),hf.registerComponent("ResizeCanvasComponent",(t=>new Ym(t))),hf.registerComponent("RenderLoopComponent",(t=>new Xm(t))),hf.registerComponent("HighlighterComponent",(t=>new rf(t))),hf.registerComponent("SelectionComponent",(t=>new sf(t))),hf.registerComponent("WCSHelperComponent",(t=>new of(t)));class uf extends Zh{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(t){return new _f(t)})),this.register((function(t){return new yf(t)})),this.register((function(t){return new Cf(t)})),this.register((function(t){return new Rf(t)})),this.register((function(t){return new Pf(t)})),this.register((function(t){return new bf(t)})),this.register((function(t){return new wf(t)})),this.register((function(t){return new Sf(t)})),this.register((function(t){return new Mf(t)})),this.register((function(t){return new vf(t)})),this.register((function(t){return new Tf(t)})),this.register((function(t){return new xf(t)})),this.register((function(t){return new Af(t)})),this.register((function(t){return new Ef(t)})),this.register((function(t){return new ff(t)})),this.register((function(t){return new Lf(t)})),this.register((function(t){return new If(t)}))}load(t,e,i,n){const r=this;let s;if(""!==this.resourcePath)s=this.resourcePath;else if(""!==this.path){const e=Sl.extractUrlBase(t);s=Sl.resolveURL(e,this.path)}else s=Sl.extractUrlBase(t);this.manager.itemStart(t);const a=function(e){n?n(e):console.error(e),r.manager.itemError(t),r.manager.itemEnd(t)},o=new $h(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(i){try{r.parse(i,s,(function(i){e(i),r.manager.itemEnd(t)}),a)}catch(t){a(t)}}),i,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,i,n){let r;const s={},a={},o=new TextDecoder;if("string"==typeof t)r=JSON.parse(t);else if(t instanceof ArrayBuffer){if(o.decode(new Uint8Array(t,0,4))===Df){try{s[mf.KHR_BINARY_GLTF]=new Uf(t)}catch(t){return void(n&&n(t))}r=JSON.parse(s[mf.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(t))}else r=t;if(void 0===r.asset||r.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const h=new og(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](h);e.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[e.name]=e,s[e.name]=!0}if(r.extensionsUsed)for(let t=0;t<r.extensionsUsed.length;++t){const e=r.extensionsUsed[t],i=r.extensionsRequired||[];switch(e){case mf.KHR_MATERIALS_UNLIT:s[e]=new gf;break;case mf.KHR_DRACO_MESH_COMPRESSION:s[e]=new Ff(r,this.dracoLoader);break;case mf.KHR_TEXTURE_TRANSFORM:s[e]=new kf;break;case mf.KHR_MESH_QUANTIZATION:s[e]=new Bf;break;default:i.indexOf(e)>=0&&void 0===a[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}h.setExtensions(s),h.setPlugins(a),h.parse(i,n)}parseAsync(t,e){const i=this;return new Promise((function(n,r){i.parse(t,e,n,r)}))}}function pf(){let t={};return{get:function(e){return t[e]},add:function(e,i){t[e]=i},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const mf={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ff{constructor(t){this.parser=t,this.name=mf.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let i=0,n=e.length;i<n;i++){const n=e[i];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&t._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(t){const e=this.parser,i="light:"+t;let n=e.cache.get(i);if(n)return n;const r=e.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let a;const o=new Jn(16777215);void 0!==s.color&&o.setRGB(s.color[0],s.color[1],s.color[2],Te);const h=void 0!==s.range?s.range:0;switch(s.type){case"directional":a=new vl(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new ml(o),a.distance=h;break;case"spot":a=new ll(o),a.distance=h,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,a.angle=s.spot.outerConeAngle,a.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return a.position.set(0,0,0),eg(a,s),void 0!==s.intensity&&(a.intensity=s.intensity),a.name=e.createUniqueName(s.name||"light_"+t),n=Promise.resolve(a),e.cache.add(i,n),n}getDependency(t,e){if("light"===t)return this._loadLight(e)}createNodeAttachment(t){const e=this,i=this.parser,n=i.json.nodes[t],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(t){return i._getNodeRef(e.cache,r,t)}))}}class gf{constructor(){this.name=mf.KHR_MATERIALS_UNLIT}getMaterialType(){return er}extendParams(t,e,i){const n=[];t.color=new Jn(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const e=r.baseColorFactor;t.color.setRGB(e[0],e[1],e[2],Te),t.opacity=e[3]}void 0!==r.baseColorTexture&&n.push(i.assignTexture(t,"map",r.baseColorTexture,Me))}return Promise.all(n)}}class vf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name].emissiveStrength;return void 0!==n&&(e.emissiveIntensity=n),Promise.resolve()}}class _f{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];if(void 0!==s.clearcoatFactor&&(e.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&r.push(i.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&r.push(i.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(r.push(i.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const t=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new $e(t,t)}return Promise.all(r)}}class yf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_DISPERSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name];return e.dispersion=void 0!==n.dispersion?n.dispersion:0,Promise.resolve()}}class xf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return void 0!==s.iridescenceFactor&&(e.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&r.push(i.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(e.iridescenceIOR=s.iridescenceIor),void 0===e.iridescenceThicknessRange&&(e.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&r.push(i.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class bf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_SHEEN}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new Jn(0,0,0),e.sheenRoughness=0,e.sheen=1;const s=n.extensions[this.name];if(void 0!==s.sheenColorFactor){const t=s.sheenColorFactor;e.sheenColor.setRGB(t[0],t[1],t[2],Te)}return void 0!==s.sheenRoughnessFactor&&(e.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&r.push(i.assignTexture(e,"sheenColorMap",s.sheenColorTexture,Me)),void 0!==s.sheenRoughnessTexture&&r.push(i.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class wf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return void 0!==s.transmissionFactor&&(e.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(i.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class Sf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_VOLUME}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];e.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&r.push(i.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return e.attenuationColor=(new Jn).setRGB(a[0],a[1],a[2],Te),Promise.all(r)}}class Mf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_IOR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name];return e.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class Tf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_SPECULAR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];e.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&r.push(i.assignTexture(e,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return e.specularColor=(new Jn).setRGB(a[0],a[1],a[2],Te),void 0!==s.specularColorTexture&&r.push(i.assignTexture(e,"specularColorMap",s.specularColorTexture,Me)),Promise.all(r)}}class Ef{constructor(t){this.parser=t,this.name=mf.EXT_MATERIALS_BUMP}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return e.bumpScale=void 0!==s.bumpFactor?s.bumpFactor:1,void 0!==s.bumpTexture&&r.push(i.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(r)}}class Af{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return void 0!==s.anisotropyStrength&&(e.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(e.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&r.push(i.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class Cf{constructor(t){this.parser=t,this.name=mf.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,i=e.json,n=i.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],s=e.options.ktx2Loader;if(!s){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class Rf{constructor(t){this.parser=t,this.name=mf.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let o=i.textureLoader;if(a.uri){const t=i.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(t,s.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class Pf{constructor(t){this.parser=t,this.name=mf.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let o=i.textureLoader;if(a.uri){const t=i.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(t,s.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class Lf{constructor(t){this.name=mf.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,i=e.bufferViews[t];if(i.extensions&&i.extensions[this.name]){const t=i.extensions[this.name],n=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then((function(e){const i=t.byteOffset||0,n=t.byteLength||0,s=t.count,a=t.byteStride,o=new Uint8Array(e,i,n);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,t.mode,t.filter).then((function(t){return t.buffer})):r.ready.then((function(){const e=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(e),s,a,o,t.mode,t.filter),e}))}))}return null}}class If{constructor(t){this.name=mf.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,i=e.nodes[t];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;const n=e.meshes[i.mesh];for(const t of n.primitives)if(t.mode!==Vf.TRIANGLES&&t.mode!==Vf.TRIANGLE_STRIP&&t.mode!==Vf.TRIANGLE_FAN&&void 0!==t.mode)return null;const r=i.extensions[this.name].attributes,s=[],a={};for(const t in r)s.push(this.parser.getDependency("accessor",r[t]).then((e=>(a[t]=e,a[t]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(t)),Promise.all(s).then((t=>{const e=t.pop(),i=e.isGroup?e.children:[e],n=t[0].count,r=[];for(const t of i){const e=new sn,i=new Ci,s=new Ai,o=new Ci(1,1,1),h=new Ys(t.geometry,t.material,n);for(let t=0;t<n;t++)a.TRANSLATION&&i.fromBufferAttribute(a.TRANSLATION,t),a.ROTATION&&s.fromBufferAttribute(a.ROTATION,t),a.SCALE&&o.fromBufferAttribute(a.SCALE,t),h.setMatrixAt(t,e.compose(i,s,o));for(const e in a)if("_COLOR_0"===e){const t=a[e];h.instanceColor=new Bs(t.array,t.itemSize,t.normalized)}else"TRANSLATION"!==e&&"ROTATION"!==e&&"SCALE"!==e&&t.geometry.setAttribute(e,a[e]);In.prototype.copy.call(h,t),this.parser.assignFinalMaterial(h),r.push(h)}return e.isGroup?(e.clear(),e.add(...r),e):r[0]})))}}const Df="glTF",Of=1313821514,Nf=5130562;class Uf{constructor(t){this.name=mf.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Df)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(t,12);let s=0;for(;s<n;){const e=r.getUint32(s,!0);s+=4;const n=r.getUint32(s,!0);if(s+=4,n===Of){const n=new Uint8Array(t,12+s,e);this.content=i.decode(n)}else if(n===Nf){const i=12+s;this.body=t.slice(i,i+e)}s+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Ff{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=mf.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const i=this.json,n=this.dracoLoader,r=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,a={},o={},h={};for(const t in s){const e=qf[t]||t.toLowerCase();a[e]=s[t]}for(const e in t.attributes){const n=qf[e]||e.toLowerCase();if(void 0!==s[e]){const r=i.accessors[t.attributes[e]],s=Wf[r.componentType];h[n]=s.name,o[n]=!0===r.normalized}}return e.getDependency("bufferView",r).then((function(t){return new Promise((function(e,i){n.decodeDracoFile(t,(function(t){for(const e in t.attributes){const i=t.attributes[e],n=o[e];void 0!==n&&(i.normalized=n)}e(t)}),a,h,Te,i)}))}))}}class kf{constructor(){this.name=mf.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return void 0!==e.texCoord&&e.texCoord!==t.channel||void 0!==e.offset||void 0!==e.rotation||void 0!==e.scale?(t=t.clone(),void 0!==e.texCoord&&(t.channel=e.texCoord),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0,t):t}}class Bf{constructor(){this.name=mf.KHR_MESH_QUANTIZATION}}class zf extends Dh{constructor(t,e,i,n){super(t,e,i,n)}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=t*n*3+n;for(let t=0;t!==n;t++)e[t]=i[r+t];return e}interpolate_(t,e,i,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=2*a,h=3*a,l=n-e,c=(i-e)/l,d=c*c,u=d*c,p=t*h,m=p-h,f=-2*u+3*d,g=u-d,v=1-f,_=g-d+c;for(let t=0;t!==a;t++){const e=s[m+t+a],i=s[m+t+o]*l,n=s[p+t+a],h=s[p+t]*l;r[t]=v*e+_*i+f*n+g*h}return r}}const Gf=new Ai;class Hf extends zf{interpolate_(t,e,i,n){const r=super.interpolate_(t,e,i,n);return Gf.fromArray(r).normalize().toArray(r),r}}const Vf={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Wf={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},jf={9728:ot,9729:ct,9984:ht,9985:dt,9986:lt,9987:ut},Xf={33071:st,33648:at,10497:rt},Yf={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qf={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Kf={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Zf={CUBICSPLINE:void 0,LINEAR:ge,STEP:fe},Jf="OPAQUE",Qf="MASK",$f="BLEND";function tg(t,e,i){for(const n in i.extensions)void 0===t[n]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=i.extensions[n])}function eg(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ig(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let i=0,n=e.weights.length;i<n;i++)t.morphTargetInfluences[i]=e.weights[i];if(e.extras&&Array.isArray(e.extras.targetNames)){const i=e.extras.targetNames;if(t.morphTargetInfluences.length===i.length){t.morphTargetDictionary={};for(let e=0,n=i.length;e<n;e++)t.morphTargetDictionary[i[e]]=e}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ng(t){let e;const i=t.extensions&&t.extensions[mf.KHR_DRACO_MESH_COMPRESSION];if(e=i?"draco:"+i.bufferView+":"+i.indices+":"+rg(i.attributes):t.indices+":"+rg(t.attributes)+":"+t.mode,void 0!==t.targets)for(let i=0,n=t.targets.length;i<n;i++)e+=":"+rg(t.targets[i]);return e}function rg(t){let e="";const i=Object.keys(t).sort();for(let n=0,r=i.length;n<r;n++)e+=i[n]+":"+t[i[n]]+";";return e}function sg(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const ag=new sn;class og{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new pf,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,n=-1,r=!1,s=-1;if("undefined"!=typeof navigator){const t=navigator.userAgent;i=!0===/^((?!chrome|android).)*safari/i.test(t);const e=t.match(/Version\/(\d+)/);n=i&&e?parseInt(e[1],10):-1,r=t.indexOf("Firefox")>-1,s=r?t.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||i&&n<17||r&&s<98?this.textureLoader=new el(this.options.manager):this.textureLoader=new Rl(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new $h(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])})).then((function(e){const s={scene:e[0][n.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:n.asset,parser:i,userData:{}};return tg(r,s,n),eg(s,n),Promise.all(i._invokeAll((function(t){return t.afterRoot&&t.afterRoot(s)}))).then((function(){for(const t of s.scenes)t.updateMatrixWorld();t(s)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],i=this.json.meshes||[];for(let i=0,n=e.length;i<n;i++){const n=e[i].joints;for(let e=0,i=n.length;e<i;e++)t[n[e]].isBone=!0}for(let e=0,n=t.length;e<n;e++){const n=t[e];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(i[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,i){if(t.refs[e]<=1)return i;const n=i.clone(),r=(t,e)=>{const i=this.associations.get(t);null!=i&&this.associations.set(e,i);for(const[i,n]of t.children.entries())r(n,e.children[i])};return r(i,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let i=0;i<e.length;i++){const n=t(e[i]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const i=[];for(let n=0;n<e.length;n++){const r=t(e[n]);r&&i.push(r)}return i}getDependency(t,e){const i=t+":"+e;let n=this.cache.get(i);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne((function(t){return t.loadNode&&t.loadNode(e)}));break;case"mesh":n=this._invokeOne((function(t){return t.loadMesh&&t.loadMesh(e)}));break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne((function(t){return t.loadBufferView&&t.loadBufferView(e)}));break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne((function(t){return t.loadMaterial&&t.loadMaterial(e)}));break;case"texture":n=this._invokeOne((function(t){return t.loadTexture&&t.loadTexture(e)}));break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne((function(t){return t.loadAnimation&&t.loadAnimation(e)}));break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne((function(i){return i!=this&&i.getDependency&&i.getDependency(t,e)})),!n)throw new Error("Unknown type: "+t)}this.cache.add(i,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const i=this,n=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(n.map((function(e,n){return i.getDependency(t,n)}))),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],i=this.fileLoader;if(e.type&&"arraybuffer"!==e.type)throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(void 0===e.uri&&0===t)return Promise.resolve(this.extensions[mf.KHR_BINARY_GLTF].body);const n=this.options;return new Promise((function(t,r){i.load(Sl.resolveURL(e.uri,n.path),t,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))}))}))}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then((function(t){const i=e.byteLength||0,n=e.byteOffset||0;return t.slice(n,n+i)}))}loadAccessor(t){const e=this,i=this.json,n=this.json.accessors[t];if(void 0===n.bufferView&&void 0===n.sparse){const t=Yf[n.type],e=Wf[n.componentType],i=!0===n.normalized,r=new e(n.count*t);return Promise.resolve(new cr(r,t,i))}const r=[];return void 0!==n.bufferView?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),void 0!==n.sparse&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then((function(t){const r=t[0],s=Yf[n.type],a=Wf[n.componentType],o=a.BYTES_PER_ELEMENT,h=o*s,l=n.byteOffset||0,c=void 0!==n.bufferView?i.bufferViews[n.bufferView].byteStride:void 0,d=!0===n.normalized;let u,p;if(c&&c!==h){const t=Math.floor(l/c),i="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+t+":"+n.count;let h=e.cache.get(i);h||(u=new a(r,t*c,n.count*c/o),h=new is(u,c/o),e.cache.add(i,h)),p=new rs(h,s,l%c/o,d)}else u=null===r?new a(n.count*s):new a(r,l,n.count*s),p=new cr(u,s,d);if(void 0!==n.sparse){const e=Yf.SCALAR,i=Wf[n.sparse.indices.componentType],o=n.sparse.indices.byteOffset||0,h=n.sparse.values.byteOffset||0,l=new i(t[1],o,n.sparse.count*e),c=new a(t[2],h,n.sparse.count*s);null!==r&&(p=new cr(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let t=0,e=l.length;t<e;t++){const e=l[t];if(p.setX(e,c[t*s]),s>=2&&p.setY(e,c[t*s+1]),s>=3&&p.setZ(e,c[t*s+2]),s>=4&&p.setW(e,c[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=d}return p}))}loadTexture(t){const e=this.json,i=this.options,n=e.textures[t].source,r=e.images[n];let s=this.textureLoader;if(r.uri){const t=i.manager.getHandler(r.uri);null!==t&&(s=t)}return this.loadTextureImage(t,n,s)}loadTextureImage(t,e,i){const n=this,r=this.json,s=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const h=this.loadImageSource(e,i).then((function(e){e.flipY=!1,e.name=s.name||a.name||"",""===e.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(e.name=a.uri);const i=(r.samplers||{})[s.sampler]||{};return e.magFilter=jf[i.magFilter]||ct,e.minFilter=jf[i.minFilter]||ut,e.wrapS=Xf[i.wrapS]||rt,e.wrapT=Xf[i.wrapT]||rt,e.generateMipmaps=!e.isCompressedTexture&&e.minFilter!==ot&&e.minFilter!==ct,n.associations.set(e,{textures:t}),e})).catch((function(){return null}));return this.textureCache[o]=h,h}loadImageSource(t,e){const i=this,n=this.json,r=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((t=>t.clone()));const s=n.images[t],a=self.URL||self.webkitURL;let o=s.uri||"",h=!1;if(void 0!==s.bufferView)o=i.getDependency("bufferView",s.bufferView).then((function(t){h=!0;const e=new Blob([t],{type:s.mimeType});return o=a.createObjectURL(e),o}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const l=Promise.resolve(o).then((function(t){return new Promise((function(i,n){let s=i;!0===e.isImageBitmapLoader&&(s=function(t){const e=new bi(t);e.needsUpdate=!0,i(e)}),e.load(Sl.resolveURL(t,r.path),s,void 0,n)}))})).then((function(t){var e;return!0===h&&a.revokeObjectURL(o),eg(t,s),t.userData.mimeType=s.mimeType||((e=s.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":e.search(/\.ktx2($|\?)/i)>0||0===e.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),t})).catch((function(t){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),t}));return this.sourceCache[t]=l,l}assignTexture(t,e,i,n){const r=this;return this.getDependency("texture",i.index).then((function(s){if(!s)return null;if(void 0!==i.texCoord&&i.texCoord>0&&((s=s.clone()).channel=i.texCoord),r.extensions[mf.KHR_TEXTURE_TRANSFORM]){const t=void 0!==i.extensions?i.extensions[mf.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(s);s=r.extensions[mf.KHR_TEXTURE_TRANSFORM].extendTexture(s,t),r.associations.set(s,e)}}return void 0!==n&&(s.colorSpace=n),t[e]=s,s}))}assignFinalMaterial(t){const e=t.geometry;let i=t.material;const n=void 0===e.attributes.tangent,r=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+i.uuid;let e=this.cache.get(t);e||(e=new Da,tr.prototype.copy.call(e,i),e.color.copy(i.color),e.map=i.map,e.sizeAttenuation=!1,this.cache.add(t,e)),i=e}else if(t.isLine){const t="LineBasicMaterial:"+i.uuid;let e=this.cache.get(t);e||(e=new ya,tr.prototype.copy.call(e,i),e.color.copy(i.color),e.map=i.map,this.cache.add(t,e)),i=e}if(n||r||s){let t="ClonedMaterial:"+i.uuid+":";n&&(t+="derivative-tangents:"),r&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=i.clone(),r&&(e.vertexColors=!0),s&&(e.flatShading=!0),n&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(i))),i=e}t.material=i}getMaterialType(){return vh}loadMaterial(t){const e=this,i=this.json,n=this.extensions,r=i.materials[t];let s;const a={},o=[];if((r.extensions||{})[mf.KHR_MATERIALS_UNLIT]){const t=n[mf.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),o.push(t.extendParams(a,r,e))}else{const i=r.pbrMetallicRoughness||{};if(a.color=new Jn(1,1,1),a.opacity=1,Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;a.color.setRGB(t[0],t[1],t[2],Te),a.opacity=t[3]}void 0!==i.baseColorTexture&&o.push(e.assignTexture(a,"map",i.baseColorTexture,Me)),a.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,a.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(o.push(e.assignTexture(a,"metalnessMap",i.metallicRoughnessTexture)),o.push(e.assignTexture(a,"roughnessMap",i.metallicRoughnessTexture))),s=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),o.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)}))))}!0===r.doubleSided&&(a.side=2);const h=r.alphaMode||Jf;if(h===$f?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Qf&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==er&&(o.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new $e(1,1),void 0!==r.normalTexture.scale)){const t=r.normalTexture.scale;a.normalScale.set(t,t)}if(void 0!==r.occlusionTexture&&s!==er&&(o.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==er){const t=r.emissiveFactor;a.emissive=(new Jn).setRGB(t[0],t[1],t[2],Te)}return void 0!==r.emissiveTexture&&s!==er&&o.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,Me)),Promise.all(o).then((function(){const i=new s(a);return r.name&&(i.name=r.name),eg(i,r),e.associations.set(i,{materials:t}),r.extensions&&tg(n,i,r),i}))}createUniqueName(t){const e=tc.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,i=this.extensions,n=this.primitiveCache;function r(t){return i[mf.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(i){return hg(i,t,e)}))}const s=[];for(let i=0,a=t.length;i<a;i++){const a=t[i],o=ng(a),h=n[o];if(h)s.push(h.promise);else{let t;t=a.extensions&&a.extensions[mf.KHR_DRACO_MESH_COMPRESSION]?r(a):hg(new br,a,e),n[o]={primitive:a,promise:t},s.push(t)}}return Promise.all(s)}loadMesh(t){const e=this,i=this.json,n=this.extensions,r=i.meshes[t],s=r.primitives,a=[];for(let t=0,e=s.length;t<e;t++){const e=void 0===s[t].material?(void 0===(o=this.cache).DefaultMaterial&&(o.DefaultMaterial=new vh({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),o.DefaultMaterial):this.getDependency("material",s[t].material);a.push(e)}var o;return a.push(e.loadGeometries(s)),Promise.all(a).then((function(i){const a=i.slice(0,i.length-1),o=i[i.length-1],h=[];for(let i=0,l=o.length;i<l;i++){const l=o[i],c=s[i];let d;const u=a[i];if(c.mode===Vf.TRIANGLES||c.mode===Vf.TRIANGLE_STRIP||c.mode===Vf.TRIANGLE_FAN||void 0===c.mode)d=!0===r.isSkinnedMesh?new Ds(l,u):new Dr(l,u),!0===d.isSkinnedMesh&&d.normalizeSkinWeights(),c.mode===Vf.TRIANGLE_STRIP?d.geometry=df(d.geometry,1):c.mode===Vf.TRIANGLE_FAN&&(d.geometry=df(d.geometry,2));else if(c.mode===Vf.LINES)d=new La(l,u);else if(c.mode===Vf.LINE_STRIP)d=new Aa(l,u);else if(c.mode===Vf.LINE_LOOP)d=new Ia(l,u);else{if(c.mode!==Vf.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+c.mode);d=new ka(l,u)}Object.keys(d.geometry.morphAttributes).length>0&&ig(d,r),d.name=e.createUniqueName(r.name||"mesh_"+t),eg(d,r),c.extensions&&tg(n,d,c),e.assignFinalMaterial(d),h.push(d)}for(let i=0,n=h.length;i<n;i++)e.associations.set(h[i],{meshes:t,primitives:i});if(1===h.length)return r.extensions&&tg(n,h[0],r),h[0];const l=new Zr;r.extensions&&tg(n,l,r),e.associations.set(l,{meshes:t});for(let t=0,e=h.length;t<e;t++)l.add(h[t]);return l}))}loadCamera(t){let e;const i=this.json.cameras[t],n=i[i.type];if(n)return"perspective"===i.type?e=new jr(Qe.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===i.type&&(e=new fl(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(e.name=this.createUniqueName(i.name)),eg(e,i),Promise.resolve(e);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const e=this.json.skins[t],i=[];for(let t=0,n=e.joints.length;t<n;t++)i.push(this._loadNodeShallow(e.joints[t]));return void 0!==e.inverseBindMatrices?i.push(this.getDependency("accessor",e.inverseBindMatrices)):i.push(null),Promise.all(i).then((function(t){const i=t.pop(),n=t,r=[],s=[];for(let t=0,a=n.length;t<a;t++){const a=n[t];if(a){r.push(a);const e=new sn;null!==i&&e.fromArray(i.array,16*t),s.push(e)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[t])}return new ks(r,s)}))}loadAnimation(t){const e=this.json,i=this,n=e.animations[t],r=n.name?n.name:"animation_"+t,s=[],a=[],o=[],h=[],l=[];for(let t=0,e=n.channels.length;t<e;t++){const e=n.channels[t],i=n.samplers[e.sampler],r=e.target,c=r.node,d=void 0!==n.parameters?n.parameters[i.input]:i.input,u=void 0!==n.parameters?n.parameters[i.output]:i.output;void 0!==r.node&&(s.push(this.getDependency("node",c)),a.push(this.getDependency("accessor",d)),o.push(this.getDependency("accessor",u)),h.push(i),l.push(r))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(h),Promise.all(l)]).then((function(t){const e=t[0],n=t[1],s=t[2],a=t[3],o=t[4],h=[];for(let t=0,r=e.length;t<r;t++){const r=e[t],l=n[t],c=s[t],d=a[t],u=o[t];if(void 0===r)continue;r.updateMatrix&&r.updateMatrix();const p=i._createAnimationTracks(r,l,c,d,u);if(p)for(let t=0;t<p.length;t++)h.push(p[t])}return new jh(r,void 0,h)}))}createNodeMesh(t){const e=this.json,i=this,n=e.nodes[t];return void 0===n.mesh?null:i.getDependency("mesh",n.mesh).then((function(t){const e=i._getNodeRef(i.meshCache,n.mesh,t);return void 0!==n.weights&&e.traverse((function(t){if(t.isMesh)for(let e=0,i=n.weights.length;e<i;e++)t.morphTargetInfluences[e]=n.weights[e]})),e}))}loadNode(t){const e=this,i=this.json.nodes[t],n=e._loadNodeShallow(t),r=[],s=i.children||[];for(let t=0,i=s.length;t<i;t++)r.push(e.getDependency("node",s[t]));const a=void 0===i.skin?Promise.resolve(null):e.getDependency("skin",i.skin);return Promise.all([n,Promise.all(r),a]).then((function(t){const e=t[0],i=t[1],n=t[2];null!==n&&e.traverse((function(t){t.isSkinnedMesh&&t.bind(n,ag)}));for(let t=0,n=i.length;t<n;t++)e.add(i[t]);return e}))}_loadNodeShallow(t){const e=this.json,i=this.extensions,n=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const r=e.nodes[t],s=r.name?n.createUniqueName(r.name):"",a=[],o=n._invokeOne((function(e){return e.createNodeMesh&&e.createNodeMesh(t)}));return o&&a.push(o),void 0!==r.camera&&a.push(n.getDependency("camera",r.camera).then((function(t){return n._getNodeRef(n.cameraCache,r.camera,t)}))),n._invokeAll((function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)})).forEach((function(t){a.push(t)})),this.nodeCache[t]=Promise.all(a).then((function(e){let a;if(a=!0===r.isBone?new Os:e.length>1?new Zr:1===e.length?e[0]:new In,a!==e[0])for(let t=0,i=e.length;t<i;t++)a.add(e[t]);if(r.name&&(a.userData.name=r.name,a.name=s),eg(a,r),r.extensions&&tg(i,a,r),void 0!==r.matrix){const t=new sn;t.fromArray(r.matrix),a.applyMatrix4(t)}else void 0!==r.translation&&a.position.fromArray(r.translation),void 0!==r.rotation&&a.quaternion.fromArray(r.rotation),void 0!==r.scale&&a.scale.fromArray(r.scale);return n.associations.has(a)||n.associations.set(a,{}),n.associations.get(a).nodes=t,a})),this.nodeCache[t]}loadScene(t){const e=this.extensions,i=this.json.scenes[t],n=this,r=new Zr;i.name&&(r.name=n.createUniqueName(i.name)),eg(r,i),i.extensions&&tg(e,r,i);const s=i.nodes||[],a=[];for(let t=0,e=s.length;t<e;t++)a.push(n.getDependency("node",s[t]));return Promise.all(a).then((function(t){for(let e=0,i=t.length;e<i;e++)r.add(t[e]);return n.associations=(t=>{const e=new Map;for(const[t,i]of n.associations)(t instanceof tr||t instanceof bi)&&e.set(t,i);return t.traverse((t=>{const i=n.associations.get(t);null!=i&&e.set(t,i)})),e})(r),r}))}_createAnimationTracks(t,e,i,n,r){const s=[],a=t.name?t.name:t.uuid,o=[];let h;switch(Kf[r.path]===Kf.weights?t.traverse((function(t){t.morphTargetInfluences&&o.push(t.name?t.name:t.uuid)})):o.push(a),Kf[r.path]){case Kf.weights:h=zh;break;case Kf.rotation:h=Hh;break;case Kf.position:case Kf.scale:h=Wh;break;default:if(1===i.itemSize)h=zh;else h=Wh}const l=void 0!==n.interpolation?Zf[n.interpolation]:ge,c=this._getArrayFromAccessor(i);for(let t=0,i=o.length;t<i;t++){const i=new h(o[t]+"."+Kf[r.path],e.array,c,l);"CUBICSPLINE"===n.interpolation&&this._createCubicSplineTrackInterpolant(i),s.push(i)}return s}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const t=sg(e.constructor),i=new Float32Array(e.length);for(let n=0,r=e.length;n<r;n++)i[n]=e[n]*t;e=i}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(t){return new(this instanceof Hh?Hf:zf)(this.times,this.values,this.getValueSize()/3,t)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function hg(t,e,i){const n=e.attributes,r=[];function s(e,n){return i.getDependency("accessor",e).then((function(e){t.setAttribute(n,e)}))}for(const e in n){const i=qf[e]||e.toLowerCase();i in t.attributes||r.push(s(n[e],i))}if(void 0!==e.indices&&!t.index){const n=i.getDependency("accessor",e.indices).then((function(e){t.setIndex(e)}));r.push(n)}return ui.workingColorSpace!==Te&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ui.workingColorSpace}" not supported.`),eg(t,e),function(t,e,i){const n=e.attributes,r=new Li;if(void 0===n.POSITION)return;{const t=i.json.accessors[n.POSITION],e=t.min,s=t.max;if(void 0===e||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new Ci(e[0],e[1],e[2]),new Ci(s[0],s[1],s[2])),t.normalized){const e=sg(Wf[t.componentType]);r.min.multiplyScalar(e),r.max.multiplyScalar(e)}}const s=e.targets;if(void 0!==s){const t=new Ci,e=new Ci;for(let n=0,r=s.length;n<r;n++){const r=s[n];if(void 0!==r.POSITION){const n=i.json.accessors[r.POSITION],s=n.min,a=n.max;if(void 0!==s&&void 0!==a){if(e.setX(Math.max(Math.abs(s[0]),Math.abs(a[0]))),e.setY(Math.max(Math.abs(s[1]),Math.abs(a[1]))),e.setZ(Math.max(Math.abs(s[2]),Math.abs(a[2]))),n.normalized){const t=sg(Wf[n.componentType]);e.multiplyScalar(t)}t.max(e)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(t)}t.boundingBox=r;const a=new Ki;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,t.boundingSphere=a}(t,e,i),Promise.all(r).then((function(){return void 0!==e.targets?function(t,e,i){let n=!1,r=!1,s=!1;for(let t=0,i=e.length;t<i;t++){const i=e[t];if(void 0!==i.POSITION&&(n=!0),void 0!==i.NORMAL&&(r=!0),void 0!==i.COLOR_0&&(s=!0),n&&r&&s)break}if(!n&&!r&&!s)return Promise.resolve(t);const a=[],o=[],h=[];for(let l=0,c=e.length;l<c;l++){const c=e[l];if(n){const e=void 0!==c.POSITION?i.getDependency("accessor",c.POSITION):t.attributes.position;a.push(e)}if(r){const e=void 0!==c.NORMAL?i.getDependency("accessor",c.NORMAL):t.attributes.normal;o.push(e)}if(s){const e=void 0!==c.COLOR_0?i.getDependency("accessor",c.COLOR_0):t.attributes.color;h.push(e)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(h)]).then((function(e){const i=e[0],a=e[1],o=e[2];return n&&(t.morphAttributes.position=i),r&&(t.morphAttributes.normal=a),s&&(t.morphAttributes.color=o),t.morphTargetsRelative=!0,t}))}(t,e.targets,i):t}))}class lg extends qh{constructor(t,e={}){super(),this.path="",this.resourcePath="",this.fileURL="",this.dataURLs=new Map,this.path=e.path||"";const i=e.externalFiles||new Map;"string"==typeof t?(this.fileURL=t,this.resourcePath=Sl.extractUrlBase(t)):(i.forEach(((e,i)=>this.fileURL=e===t?i:this.fileURL)),i.set(this.fileURL,t)),i.forEach(((t,e)=>{let i;i="string"==typeof t?t:URL.createObjectURL(new Blob([t])),this.dataURLs.set(e,i)})),this.setURLModifier((t=>{const e=decodeURI(t).replace(this.path,"").replace(this.resourcePath,"").replace(/^(\.?\/)/,""),i=this.dataURLs.get(e);return null!=i?i:t}))}dispose(){this.dataURLs.forEach(URL.revokeObjectURL)}}class cg{constructor(t){this.handle="1",this.scene=t}dispose(){this.scene.traverse((function(t){var e;t.geometry&&t.geometry.dispose(),t.material&&(e=t.material,(Array.isArray(e)?e:[e]).forEach((t=>function(t){t.dispose()}(t))))})),this.scene.clear()}getExtents(t){return this.scene.traverseVisible((e=>!e.children.length&&t.expandByObject(e))),t}getObjects(){const t=[];return this.scene.traverse((e=>t.push(e))),t}getVisibleObjects(){const t=[];return this.scene.traverseVisible((e=>t.push(e))),t}hasObject(t){for(;t;){if(t===this.scene)return!0;t=t.parent}return!1}getOwnObjects(t){return Array.isArray(t)||(t=[t]),t.filter((t=>this.hasObject(t)))}getObjectsByHandles(t){const e=new Set(t),i=[];return this.scene.traverse((t=>e.has(t.userData.handle)&&i.push(t))),i}getHandlesByObjects(t){Array.isArray(t)||(t=[t]);const e=new Set;return this.getOwnObjects(t).forEach((t=>e.add(t.userData.handle))),Array.from(e)}hideObjects(t){return Array.isArray(t)||(t=[t]),this.getOwnObjects(t).forEach((t=>t.visible=!1)),this}hideAllObjects(){return this.isolateObjects([])}isolateObjects(t){Array.isArray(t)||(t=[t]);const e=new Set(t);return this.getOwnObjects(t).forEach((t=>t.traverseAncestors((t=>e.add(t))))),this.scene.traverse((t=>t.visible=e.has(t))),this}showObjects(t){return Array.isArray(t)||(t=[t]),this.getOwnObjects(t).forEach((t=>{t.visible=!0,t.traverseAncestors((t=>t.visible=!0))})),this}showAllObjects(){return this.scene.traverse((t=>t.visible=!0)),this}showOriginalObjects(t){return this}hideOriginalObjects(t){return this}explode(t=0,e=4){t/=100,this.scene.userData.explodeDepth||(this.scene.userData.explodeDepth=function t(e,i){let n=i;return e.children.forEach((e=>{const r=t(e,i+1);n<r&&(n=r)})),e.userData.originalPosition=e.position.clone(),e.userData.originalCenter=(new Li).setFromObject(e).getCenter(new Ci),e.userData.isExplodeLocked=i>2&&0===e.children.length,n}(this.scene,1));const i=this.scene.userData.explodeDepth,n=t*i+1,r=0|n,s=n-r;return function i(n,a){if(n.position.copy(n.userData.originalPosition),a>0&&a<=r&&!n.userData.isExplodeLocked){let i=t*e;a===r&&(i*=s);const o=n.parent.userData.originalCenter,h=n.userData.originalCenter.clone().sub(o).multiplyScalar(i);n.position.add(h)}n.children.forEach((t=>i(t,a+1)))}(this.scene,0),this.scene.updateMatrixWorld(),this}}class dg extends c{constructor(t){super(),this.viewer=t}isSupport(t,e){return("string"==typeof t||t instanceof globalThis.File||t instanceof ArrayBuffer)&&/(gltf|glb)$/i.test(e)}async load(t,e,i){const n=new lg(t,i),r=new uf(n);r.setPath(n.path),r.setCrossOrigin(i.crossOrigin||r.crossOrigin),r.setWithCredentials(i.withCredentials||r.withCredentials);const s=await r.loadAsync(n.fileURL,(e=>{const{lengthComputable:i,loaded:n,total:r}=e,s=i?n/r:1;this.viewer.emitEvent({type:"geometryprogress",data:s,file:t})}));if(!this.viewer.scene)return this;const a=new cg(s.scene);return a.loader=this,a.viewer=this.viewer,this.viewer.scene.add(s.scene),this.viewer.models.push(a),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.update(),this.viewer.emitEvent({type:"databasechunk",data:s.scene,file:t}),this}}class ug extends cg{getExtents(t){return t.union(this.gltfLoader.getTotalGeometryExtent())}getObjects(){const t=[];return this.gltfLoader.originalObjects.forEach((e=>{t.push(e)})),t}getVisibleObjects(){return this.gltfLoader.getOriginalObjectForSelect()}hasObject(t){return this.gltfLoader.originalObjects.has(t)}getObjectsByHandles(t){const e=new Set(t),i=[];return e.forEach((t=>{const e=this.gltfLoader.handleToObjects.get(t)||[];i.push(...Array.from(e))})),i}hideObjects(t){return this.getOwnObjects(t).map((t=>t.userData.handle)).forEach((t=>this.gltfLoader.hiddenHandles.add(t))),this.gltfLoader.syncHiddenObjects(),this}isolateObjects(t){const e=this.getHandlesByObjects(t);return this.gltfLoader.isolateObjects(new Set(e)),this}showObjects(t){return this.getOwnObjects(t).map((t=>t.userData.handle)).forEach((t=>this.gltfLoader.hiddenHandles.delete(t))),this.gltfLoader.syncHiddenObjects(),this}showAllObjects(){return this.gltfLoader.hiddenHandles.clear(),this.gltfLoader.syncHiddenObjects(),this}showOriginalObjects(t){return this.getOwnObjects(t).forEach((t=>t.visible=!0)),this}hideOriginalObjects(t){return this.getOwnObjects(t).forEach((t=>t.visible=!1)),this}}const pg={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},mg=0,fg=1,gg=2,vg=3,_g=4,yg=5,xg=6;class bg{constructor(t){this.id=`${t}`,this.json=null,this.baseUrl="",this.loadController=null,this.batchDelay=10,this.maxBatchSize=5242880,this.maxRangesPerRequest=512,this.pendingRequests=[],this.batchTimeout=null,this.textureLoader=new el,this.materials=new Map,this.textureCache=new Map}async initialize(t){this.json=await t.loadJson(),this.baseUrl=await t.baseUrl(),this.loadController=t}clear(){this.json=null,this.baseUrl="",this.loadController=null,this.pendingRequests=[],this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=null),this.disposeMaterials(),this.textureCache.clear(),this.materials.clear()}getJson(){return this.json}scheduleRequest(t){return this.pendingRequests.push(t),this.batchTimeout&&clearTimeout(this.batchTimeout),this.batchTimeout=setTimeout((()=>this.processBatch()),this.batchDelay),new Promise(((e,i)=>{t.resolve=e,t.reject=i}))}async processBatch(){if(0===this.pendingRequests.length)return;const t=[...this.pendingRequests];this.pendingRequests=[],this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=null);try{for(let e=0;e<t.length;e+=this.maxRangesPerRequest){const i=t.slice(e,e+this.maxRangesPerRequest),n=await this.loadController.loadBinaryData(i);let r=0;i.forEach((t=>{const e=this.createTypedArray(n,r,t.length,t.componentType);t.resolve(e),r+=t.length}))}}catch(e){console.error("Error processing batch:",e),t.forEach((t=>t.reject(e)))}this.pendingRequests.length>0&&(this.batchTimeout=setTimeout((()=>this.processBatch()),this.batchDelay))}getBufferView(t,e,i){return this.scheduleRequest({offset:t,length:e,componentType:i})}createTypedArray(t,e,i,n){try{if(!(t&&t instanceof ArrayBuffer))throw new Error("Invalid buffer");let r;switch(n){case 5120:case 5121:r=1;break;case 5122:case 5123:r=2;break;case 5125:case 5126:r=4;break;default:throw new Error(`Unsupported component type: ${n}`)}const s=i/r;if(!Number.isInteger(s))throw new Error(`Invalid length ${i} for component type ${n}`);if(i>t.byteLength)throw new Error(`Buffer too small: need ${i} bytes, but buffer is ${t.byteLength} bytes`);return new(0,pg[n])(t,e,s)}catch(r){throw"AbortError"!==r.name&&console.error("Error creating typed array:",{bufferSize:t?.byteLength,offset:e,length:i,componentType:n,error:r}),r}}async createBufferAttribute(t){if(!this.json)throw new Error("No GLTF structure loaded");const e=this.json,i=e.accessors[t],n=e.bufferViews[i.bufferView];try{const t=(n.byteOffset||0)+(i.byteOffset||0),e=this.getNumComponents(i.type),r=i.count*e*this.getComponentSize(i.componentType),s=await this.getBufferView(t,r,i.componentType),a=new cr(s,e);return void 0!==i.min&&(a.min=i.min),void 0!==i.max&&(a.max=i.max),a}catch(t){throw"AbortError"!==t.name&&console.error("Error creating buffer attribute:",{error:t,accessor:i,bufferView:n}),t}}getComponentSize(t){switch(t){case 5120:case 5121:return 1;case 5122:case 5123:return 2;case 5125:case 5126:return 4;default:throw new Error(`Unknown component type: ${t}`)}}getNumComponents(t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:throw new Error(`Unknown type: ${t}`)}}async loadTextures(){if(!this.json.textures)return;const t=async t=>{const e=this.json.images[t];if(e.uri){if(e.uri.startsWith("data:"))return await this.textureLoader.loadAsync(e.uri);{const t=this.baseUrl+e.uri;return await this.textureLoader.loadAsync(t)}}if(void 0!==e.bufferView){const t=this.json.bufferViews[e.bufferView],i=await this.getBufferView(t.byteOffset||0,t.byteLength,5121),n=new Blob([i],{type:e.mimeType}),r=URL.createObjectURL(n),s=await this.textureLoader.loadAsync(r);return URL.revokeObjectURL(r),s.flipY=!1,s}},e=[];for(let i=0;i<this.json.textures.length;i++)e.push(t(this.json.textures[i].source).then((t=>this.textureCache.set(i,t))));await Promise.all(e)}loadMaterials(){if(!this.json.materials)return this.materials;for(let t=0;t<this.json.materials.length;t++){const e=this.json.materials[t],i=this.createMaterial(e);this.materials.set(t,i)}return this.materials}createMaterial(t){const e=new vh;if(t.pbrMetallicRoughness){const i=t.pbrMetallicRoughness;i.baseColorFactor&&(e.color.fromArray(i.baseColorFactor),e.opacity=i.baseColorFactor[3]),i.baseColorTexture&&(e.map=this.textureCache.get(i.baseColorTexture.index)),void 0!==i.metallicFactor&&(e.metalness=i.metallicFactor),void 0!==i.roughnessFactor&&(e.roughness=i.roughnessFactor),i.metallicRoughnessTexture&&(e.metalnessMap=this.textureCache.get(i.metallicRoughnessTexture.index),e.roughnessMap=e.metalnessMap)}return t.normalTexture&&(e.normalMap=this.textureCache.get(t.normalTexture.index),void 0!==t.normalTexture.scale&&e.normalScale.set(t.normalTexture.scale,t.normalTexture.scale)),t.emissiveFactor&&e.emissive.fromArray(t.emissiveFactor),t.emissiveTexture&&(e.emissiveMap=this.textureCache.get(t.emissiveTexture.index)),t.occlusionTexture&&(e.aoMap=this.textureCache.get(t.occlusionTexture.index),void 0!==t.occlusionTexture.strength&&(e.aoMapIntensity=t.occlusionTexture.strength)),"BLEND"===t.alphaMode?e.transparent=!0:"MASK"===t.alphaMode&&(e.alphaTest=void 0!==t.alphaCutoff?t.alphaCutoff:.5),e.side=t.doubleSided?2:0,e.name=t.name,e}disposeMaterials(){this.textureCache.forEach((t=>t.dispose())),this.textureCache.clear(),this.materials.forEach((t=>{t.map&&t.map.dispose(),t.lightMap&&t.lightMap.dispose(),t.bumpMap&&t.bumpMap.dispose(),t.normalMap&&t.normalMap.dispose(),t.specularMap&&t.specularMap.dispose(),t.envMap&&t.envMap.dispose(),t.aoMap&&t.aoMap.dispose(),t.metalnessMap&&t.metalnessMap.dispose(),t.roughnessMap&&t.roughnessMap.dispose(),t.emissiveMap&&t.emissiveMap.dispose(),t.dispose()})),this.materials.clear()}estimateNodeSize(t){if(!this.json.meshes)return 0;const e=this.json.meshes[t];if(!e||!e.primitives)return 0;let i=0;for(const t of e.primitives){if(t.attributes)for(const[,e]of Object.entries(t.attributes)){if(void 0===e)continue;const t=this.json.accessors[e];if(!t)continue;const n=this.getNumComponents(t.type),r=this.getComponentSize(t.componentType);i+=t.count*n*r}if(void 0!==t.indices){const e=this.json.accessors[t.indices];if(e){const t=this.getComponentSize(e.componentType);i+=e.count*t}}}return i}}class wg{constructor(t,e,i){this.camera=t,this.scene=e,this.renderer=i,this.eventHandlers={geometryprogress:[],databasechunk:[],geometryend:[],geometryerror:[],update:[],geometrymemory:[]},this.loadDistance=100,this.unloadDistance=150,this.checkInterval=1e3,this.nodes=new Map,this.loadedMeshes=new Map,this.nodesToLoad=[],this.edgeNodes=[],this.structures=[],this.structureRoots=new Map,this.memoryLimit=this.getAvailableMemory(),this.loadedGeometrySize=0,this.geometryCache=new Map,this.materialCache=new Map,this.textureCache=new Map,this.currentMemoryUsage=0,this.updateMemoryIndicator(),this.loadedMaterials=new Map,this.abortController=new AbortController,this.batchSize=1e4,this.frameDelay=0,this.graphicsObjectLimit=1e4,this.totalLoadedObjects=0,this.lastUpdateTime=0,this.updateInterval=1e3,this.handleToObjects=new Map,this.originalObjects=new Set,this.originalObjectsToSelection=new Set,this.optimizedOriginalMap=new Map,this.mergedMesh=new Set,this.mergedLines=new Set,this.mergedLineSegments=new Set,this.mergedPoints=new Set,this.isolatedObjects=[],this.useVAO=!!window.WebGL2RenderingContext&&this.renderer.getContext()instanceof WebGL2RenderingContext,this.handleToOptimizedObjects=new Map,this.hiddenHandles=new Set,this.newOptimizedObjects=new Set,this.oldOptimizeObjects=new Set}getAvailableMemory(){let t=6442450944;try{if(navigator.deviceMemory)t=1024*navigator.deviceMemory*1024*1024;else if(performance.memory){const e=performance.memory.jsHeapSizeLimit;e&&(t=Math.min(t,e))}t=Math.min(t,17179869184),t=Math.max(t,2147483648),console.log(`Available memory set to ${Math.round(t/1073741824)}GB`)}catch(t){console.warn("Error detecting available memory:",t)}return t}getAbortController(){return this.abortController}abortLoading(){this.abortController.abort()}updateMemoryIndicator(){this.dispatchEvent("geometrymemory",{currentUsage:this.currentMemoryUsage,limit:this.memoryLimit})}setMemoryLimit(t){}estimateGeometrySize(t){let e=0;return t.traverse((t=>{if(t.geometry){if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const i=t.geometry;i.attributes&&Object.values(i.attributes).forEach((t=>{t&&t.array&&(e+=t.array.byteLength)})),i.index&&i.index.array&&(e+=i.index.array.byteLength)}})),e}recalculateScene(){const t=[];if(this.scene.traverse((e=>{if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");if(e.geometry&&!this.geometryCache.has(e.geometry.uuid)){const i=this.estimateGeometrySize(e);this.geometryCache.set(e.geometry.uuid,i),t.push({object:e,size:i,distance:e.position.distanceTo(this.camera.position)})}})),this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");t.sort(((t,e)=>e.distance-t.distance));let e=0;for(const i of t)e+=i.size;if(e>this.memoryLimit){console.log(`Memory usage (${Math.round(e/1048576)}MB) exceeds limit`);for(const i of t){if(e<=this.memoryLimit)break;if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const t=i.object;t.geometry&&(e-=i.size,this.geometryCache.delete(t.geometry.uuid),t.geometry.dispose(),t.visible=!1)}}this.currentMemoryUsage=e,this.updateMemoryIndicator(),console.log(`Final memory usage: ${Math.round(e/1048576)}MB`)}async loadNode(t){const e=this.nodes.get(t);if(!e||e.loaded||e.loading)return;e.loading=!0;const i=e.structure.getJson().meshes[e.meshIndex];try{for(const t of i.primitives){const n=t.attributes.POSITION,r=new br,s=new Map;s.set("position",e.structure.createBufferAttribute(n)),void 0!==t.attributes.NORMAL&&s.set("normal",e.structure.createBufferAttribute(t.attributes.NORMAL)),void 0!==t.attributes.TEXCOORD_0&&s.set("uv",e.structure.createBufferAttribute(t.attributes.TEXCOORD_0));if((await Promise.all([...s.entries()].map((async([t,e])=>[t,await e])))).forEach((([t,e])=>{r.setAttribute(t,e)})),void 0!==t.indices){const i=await e.structure.createBufferAttribute(t.indices);r.setIndex(i)}let a,o;if(this.currentPrimitiveMode=t.mode,a=void 0!==t.material&&e.structure.materials.get(t.material)||this.createDefaultMaterial(),t.mode===mg){const t=new Da;tr.prototype.copy.call(t,a),t.color.copy(a.color),t.map=a.map,t.sizeAttenuation=!1,o=new ka(r,t)}else t.mode===_g||t.mode===yg||t.mode===xg||void 0===t.mode?(o=new Dr(r,a),t.mode===yg?o.drawMode=1:t.mode===xg&&(o.drawMode=2)):t.mode===fg?o=new La(r,a):t.mode===vg?o=new Aa(r,a):t.mode===gg&&(o=new Ia(r,a));e.extras&&(o.userData={...o.userData,...e.extras}),i.extras&&(o.userData={...o.userData,...i.extras}),t.extras&&(o.userData={...o.userData,...t.extras}),e.handle?o.userData.handle=e.handle:o.userData.handle=`${e.structure.id}_${o.userData.handle}`,"edges"===o.material.name?o.userData.isEdge=!0:o.userData.isEdge=!1,this.registerObjectWithHandle(o,o.userData.handle),o.position.copy(e.position),r.attributes.normal||r.computeVertexNormals(),a.aoMap&&r.attributes.uv&&r.setAttribute("uv2",r.attributes.uv),e.group?e.group.add(o):this.scene.add(o),e.object=o,this.totalLoadedObjects++,o.visible=this.totalLoadedObjects<this.graphicsObjectLimit}e.loaded=!0,e.loading=!1;const t=this.estimateGeometrySize(e.object);this.geometryCache.set(e.object.uuid,t),this.currentMemoryUsage+=t}catch(i){"AbortError"!==i.name&&console.error(`Error loading node ${t}:`,i),e.loading=!1}}unloadNode(t){const e=this.nodes.get(t);e&&e.loaded&&e.object&&(e.object.parent?e.object.parent.remove(e.object):this.scene.remove(e.object),e.object.traverse((t=>{if(t.geometry){const e=this.geometryCache.get(t.geometry.uuid)||0;this.currentMemoryUsage-=e,this.geometryCache.delete(t.geometry.uuid),t.geometry.dispose()}})),e.object=null,e.loaded=!1,this.updateMemoryIndicator(),console.log(`Unloaded node: ${t}`))}checkDistances(){const t=this.camera.position;this.nodes.forEach(((e,i)=>{const n=t.distanceTo(e.position);e.loaded?n>this.unloadDistance&&this.unloadNode(i):e.loading||n<this.loadDistance&&this.loadNode(i)}))}async loadStructure(t){this.clear();const e=Array.isArray(t)?t:[t];for(const t of e)this.structures.push(t);for(const t of this.structures)try{await t.loadTextures(),await t.loadMaterials()}catch(t){throw console.error("Error loading materials:",t),t}await this.processSceneHierarchy()}async processSceneHierarchy(){if(0===this.structures.length)throw new Error("No GLTF structures loaded");this.nodesToLoad=[];let t=0;for(const e of this.structures){const i=e.getJson();if(!i.scenes||!i.scenes.length){console.warn("No scenes found in GLTF structure");continue}t+=i.buffers[0].byteLength;const n=new Zr;n.name=`structure_${e.id}_root`,this.scene.add(n),this.structureRoots.set(e.id,n);const r=i.scenes[i.scene||0];for(const t of r.nodes)await this.processNodeHierarchy(e,t,n)}const e=2*t>this.memoryLimit;this.nodesToLoad.sort(((t,e)=>{const i=this.nodes.get(t),n=this.nodes.get(e);if(!i?.geometryExtents||!n?.geometryExtents)return 0;const r=i.geometryExtents.getSize(new Ci),s=n.geometryExtents.getSize(new Ci),a=r.x*r.y*r.z;return s.x*s.y*s.z-a})),e||this.nodesToLoad.push(...this.edgeNodes),this.dispatchEvent("databasechunk",{totalNodes:this.nodesToLoad.length,structures:this.structures.map((t=>({id:t.id,nodeCount:this.nodesToLoad.filter((e=>e.startsWith(t.id))).length})))})}async processNodeHierarchy(t,e,i){const n=t.json.nodes[e];let r=null,s=null;if(n.extras?.handle&&(s=`${t.id}_${n.extras.handle}`),void 0!==n.camera){const e=this.loadCamera(t,n.camera,n);return n.extras&&(e.userData={...e.userData,...n.extras}),void this.scene.add(e)}if(this.needsGroupForNode(t,n)){if(r=new Zr,r.name=n.name||`node_${e}`,n.extras&&(r.userData={...n.extras},r.userData.handle&&(r.userData.handle=`${t.id}_${r.userData.handle}`)),n.matrix)r.matrix.fromArray(n.matrix),r.matrixAutoUpdate=!1;else if(n.translation||n.rotation||n.scale){const t=n.translation?(new Ci).fromArray(n.translation):new Ci,e=n.rotation?(new Ai).fromArray(n.rotation):new Ai,i=n.scale?(new Ci).fromArray(n.scale):new Ci(1,1,1);r.matrix.compose(t,e,i),r.matrixAutoUpdate=!1}i&&i.add(r)}if(void 0!==n.mesh){const a=new sn,o=`${t.id}_${e}`,h=t.json.meshes[n.mesh],l=new Li;for(const e of h.primitives){const i=t.json.accessors[e.attributes.POSITION];if(i&&i.min&&i.max){const t=new Li((new Ci).fromArray(i.min),(new Ci).fromArray(i.max));l.union(t)}}let c=!1;if(void 0!==h.primitives[0].material){const e=t.json.materials[h.primitives[0].material];"edges"===e?.name&&(c=!0)}c?this.edgeNodes.push(o):this.nodesToLoad.push(o),this.nodes.set(o,{position:r?r.position.clone():(new Ci).setFromMatrixPosition(a),nodeIndex:e,meshIndex:n.mesh,loaded:!1,loading:!1,object:null,group:r||i,structure:t,extras:n.extras,geometryExtents:l,handle:s})}if(n.children)for(const e of n.children)await this.processNodeHierarchy(t,e,r||i);return r}needsGroupForNode(t,e){const i=e.matrix||e.translation||e.rotation||e.scale,n=void 0!==e.mesh&&t.json.meshes[e.mesh].primitives.length>1;return void 0!==i||n}async processNodes(){const t=this.nodesToLoad;let e=0;const i=t.length;try{for(;e<i;){const n=t.slice(e,e+this.batchSize),r=[];for(const t of n){if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const i=await this.estimateNodeSize(t);if(this.currentMemoryUsage+i>this.memoryLimit)return console.log(`Memory limit reached after loading ${e} nodes`),this.dispatchEvent("geometryerror",{message:"Memory limit reached"}),this.dispatchEvent("update"),e;r.push(this.loadNode(t))}await Promise.all(r),e+=n.length,this.updateMemoryIndicator(),this.dispatchEvent("geometryprogress",{percentage:Math.round(e/i*100),loaded:e,total:i});const s=Date.now();s-this.lastUpdateTime>=this.updateInterval&&(this.dispatchEvent("update"),this.lastUpdateTime=s),await new Promise((t=>{setTimeout(t,0)}))}return this.dispatchEvent("geometryend",{totalLoaded:e,totalNodes:i}),e}catch(t){throw this.dispatchEvent("geometryerror",{error:t}),t}}async loadNodes(){console.time("process nodes"),await this.processNodes(),console.timeEnd("process nodes"),console.time("optimize scene"),await this.optimizeScene(),console.timeEnd("optimize scene")}cleanupPartialLoad(){this.nodesToLoad.forEach((t=>{const e=this.nodes.get(t);e&&e.loading&&this.unloadNode(t)}))}createDefaultMaterial(){return this.currentPrimitiveMode===mg?new Da({color:new Jn(8421504),size:.05,sizeAttenuation:!0,alphaTest:.5,transparent:!0,vertexColors:!1,blending:1,depthWrite:!1,depthTest:!0}):new vh({color:8421504,metalness:0,roughness:1,side:2})}async estimateNodeSize(t){const e=this.nodes.get(t);return e?await e.structure.estimateNodeSize(e.meshIndex):0}getTotalGeometryExtent(){const t=new Li;for(const e of this.nodes.values()){if(!e.geometryExtents)continue;if(e.object&&this.hiddenHandles.has(e.object.userData.handle))continue;const i=e.geometryExtents.clone();e.group&&e.group.matrix&&(i.applyMatrix4(e.group.matrix),e.group.parent&&e.group.parent.matrix&&i.applyMatrix4(e.group.parent.matrix)),t.union(i)}return t}loadCamera(t,e,i){const n=t.getJson().cameras[e],r=n[n.type];let s;return"perspective"===n.type?s=new jr(Qe.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(s=new fl(r.xmag/-2,r.xmag/2,r.ymag/2,r.ymag/-2,r.znear,r.zfar)),i.matrix?(s.matrix.fromArray(i.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale)):(i.translation&&s.position.fromArray(i.translation),i.rotation&&s.quaternion.fromArray(i.rotation),i.scale&&s.scale.fromArray(i.scale)),s}clearNodesToLoad(){this.nodesToLoad=[]}async addStructure(t){const e=new bg;return await e.initialize(t),this.structures.push(e),e}removeOptimization(){this.originalObjects.forEach((t=>t.visible=!0));const t=t=>{t.parent&&t.parent.remove(t),t.geometry&&t.geometry.dispose()};if(this.structureGroups)for(const e of this.structureGroups.values())e.meshes.forEach(t),e.lines.forEach(t),e.lineSegments.forEach(t),e.meshes.clear(),e.lines.clear(),e.lineSegments.clear();this.optimizedOriginalMap.clear(),this.mergedMesh.clear(),this.mergedLines.clear(),this.mergedLineSegments.clear(),this.originalObjects.clear(),this.originalObjectsToSelection.clear()}clear(){this.structures.forEach((t=>{t&&t.clear()})),this.structures=[],this.nodes.forEach((t=>{t.object&&(t.object.parent&&t.object.parent.remove(t.object),t.object.geometry&&t.object.geometry.dispose(),t.object.material&&(Array.isArray(t.object.material)?t.object.material.forEach((t=>t.dispose())):t.object.material.dispose()))})),this.nodes.clear(),this.loadedMeshes.forEach((t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach((t=>t.dispose())):t.material.dispose())})),this.loadedMeshes.clear(),this.structureRoots.forEach((t=>{t&&(t.traverse((t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach((t=>t.dispose())):t.material.dispose())})),t.parent&&t.parent.remove(t))})),this.structureRoots.clear(),this.mergedMesh.forEach((t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach((t=>t.dispose())):t.material.dispose()),t.parent&&t.parent.remove(t)})),this.mergedMesh.clear(),this.mergedLines.forEach((t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)})),this.mergedLines.clear(),this.mergedLineSegments.forEach((t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)})),this.mergedLineSegments.clear(),this.mergedPoints.forEach((t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)})),this.mergedPoints.clear(),this.geometryCache.clear(),this.materialCache.clear(),this.textureCache.clear(),this.loadedMaterials.clear(),this.nodesToLoad=[],this.handleToObjects.clear(),this.originalObjects.clear(),this.originalObjectsToSelection.clear(),this.optimizedOriginalMap.clear(),this.handleToOptimizedObjects.clear(),this.hiddenHandles.clear(),this.newOptimizedObjects.clear(),this.oldOptimizeObjects.clear(),this.isolatedObjects=[],this.totalLoadedObjects=0,this.lastUpdateTime=0,this.currentMemoryUsage=0,this.loadedGeometrySize=0,this.abortController=new AbortController,this.updateMemoryIndicator()}setStructureTransform(t,e){const i=this.structureRoots.get(t);return!!i&&(i.matrix.copy(e),i.matrix.decompose(i.position,i.quaternion,i.scale),!0)}getStructureRootGroup(t){return this.structureRoots.get(t)}addEventListener(t,e){this.eventHandlers[t]&&this.eventHandlers[t].push(e)}removeEventListener(t,e){this.eventHandlers[t]&&(this.eventHandlers[t]=this.eventHandlers[t].filter((t=>t!==e)))}dispatchEvent(t,e){this.eventHandlers[t]&&this.eventHandlers[t].forEach((t=>t(e)))}registerObjectWithHandle(t,e){if(!e)return;const i=t.userData.handle;this.handleToObjects.has(i)||this.handleToObjects.set(i,new Set),this.handleToObjects.get(i).add(t),t.userData.structureId=t.userData.handle.split("_")[0]}getObjectsByHandle(t){return t?Array.from(this.handleToObjects.get(t)||[]):[]}getHandlesByObjects(t){if(!t.length)return[];const e=new Set;return t.forEach((t=>{this.originalObjects.has(t)&&e.add(t.userData.handle)})),Array.from(e)}getMaterialId(t,e){const i={type:t.type,color:t.color?.getHex(),map:t.map?.uuid,transparent:t.transparent,opacity:t.opacity,side:t.side,index:e?1:0};return JSON.stringify(i)}addToMaterialGroup(t,e,i){const n=t.geometry.attributes.position.count,r=t.geometry.index?t.geometry.index.count:0,s=t.material;let a,o=this.getMaterialId(s,null!==t.geometry.index);if(e.has(o))if(a=e.get(o),a.totalVertices+n>1e5||a.totalIndices+r>1e5){const a={material:s,objects:[t],totalVertices:n,totalIndices:r};o=this.getMaterialId(s,null!==t.geometry.index),e.set(o,a),i.push(a)}else a.objects.push(t),a.totalVertices+=n,a.totalIndices+=r;else a={material:s,objects:[t],totalVertices:n,totalIndices:r},e.set(o,a),i.push(a);this.originalObjects.add(t)}optimizeScene(){this.originalObjects.clear(),this.originalObjectsToSelection.clear();const t=new Map;this.scene.traverse((e=>{if(e.userData.structureId){const i=e.userData.structureId;t.has(i)||t.set(i,{mapMeshes:new Map,mapLines:new Map,mapLineSegments:new Map,mapPoints:new Map,meshes:[],lines:[],lineSegments:[],points:[],rootGroup:this.structureRoots.get(i)});const n=t.get(i);e instanceof Dr?this.addToMaterialGroup(e,n.mapMeshes,n.meshes):e instanceof La?this.addToMaterialGroup(e,n.mapLineSegments,n.lineSegments):e instanceof Aa?this.addToMaterialGroup(e,n.mapLines,n.lines):e instanceof ka&&this.addToMaterialGroup(e,n.mapPoints,n.points)}}));for(const e of t.values())e.mapMeshes.clear(),e.mapLines.clear(),e.mapLineSegments.clear(),e.mapPoints.clear(),this.mergeMeshGroups(e.meshes,e.rootGroup),this.mergeLineGroups(e.lines,e.rootGroup),this.mergeLineSegmentGroups(e.lineSegments,e.rootGroup),this.mergePointsGroups(e.points,e.rootGroup);this.originalObjects.forEach((t=>{t.visible=!1,t instanceof ka||t.userData.isEdge||this.originalObjectsToSelection.add(t)})),this.dispatchEvent("update")}mergeMeshGroups(t,e){for(const i of t)try{const t=[],n=new Set,r=[];for(const e of i.objects){const i=e.geometry.clone();e.updateWorldMatrix(!0,!1),i.applyMatrix4(e.matrixWorld),t.push(i),r.push(e),n.add(e.userData.handle)}const s=[];if(t.length>0){const n=lf(t);this.useVAO&&this.createVAO(n);const a=new Dr(n,i.material);e.add(a),this.mergedMesh.add(a),this.optimizedOriginalMap.set(a,r),s.push(a),t.forEach((t=>{t.dispose()}))}n.forEach((t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...s),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,s)}))}catch(t){console.error("Failed to merge meshes for material:",t),i.objects.forEach((t=>{t.visible=!0}))}}mergeLineGroups(t,e){for(const i of t){if(0===i.objects.length)continue;const t=new Set;let n=0;i.objects.map((e=>{t.add(e.userData.handle),n+=e.geometry.attributes.position.count}));const r=new Float32Array(3*n);let s=0;const a=[];let o=0;i.objects.forEach((t=>{const e=t.geometry.attributes.position,i=e.count;t.updateWorldMatrix(!0,!1);const n=t.matrixWorld,h=new Ci;for(let t=0;t<i;t++)h.fromBufferAttribute(e,t),h.applyMatrix4(n),r[s++]=h.x,r[s++]=h.y,r[s++]=h.z;for(let t=0;t<i-1;t++)a.push(o+t,o+t+1);o+=i}));const h=new br;h.setAttribute("position",new cr(r,3)),h.setIndex(a),h.computeBoundingSphere(),h.computeBoundingBox();const l=new La(h,i.material),c=[l];this.useVAO&&this.createVAO(l),e.add(l),this.mergedLines.add(l),this.optimizedOriginalMap.set(l,i.objects),t.forEach((t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...c),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,c)}))}}mergeLineSegmentGroups(t,e){for(const i of t)try{const t=[],n=[],r=new Set;for(const e of i.objects){const i=e.geometry.clone();e.updateWorldMatrix(!0,!1),i.applyMatrix4(e.matrixWorld),t.push(i),n.push(e),r.add(e.userData.handle)}const s=[];if(t.length>0){const r=lf(t,!1),a=new La(r,i.material);this.useVAO&&this.createVAO(a),e.add(a),this.mergedLineSegments.add(a),this.optimizedOriginalMap.set(a,n),s.push(a),t.forEach((t=>{t.dispose()}))}r.forEach((t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...s),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,s)}))}catch(t){console.warn("Failed to merge line segments for material:",t),i.objects.forEach((t=>{t.visible=!0}))}}mergePointsGroups(t,e){for(const i of t)try{const t=[],n=[],r=new Set;for(const e of i.objects){const i=e.geometry.clone();e.updateWorldMatrix(!0,!1),i.applyMatrix4(e.matrixWorld),t.push(i),n.push(e),r.add(e.userData.handle)}const s=[];if(t.length>0){const r=lf(t,!1),a=new ka(r,i.material);this.useVAO&&this.createVAO(a),e.add(a),this.mergedPoints.add(a),this.optimizedOriginalMap.set(a,n),s.push(a),t.forEach((t=>{t.dispose()}))}r.forEach((t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...s),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,s)}))}catch(t){console.warn("Failed to merge points for material:",t),i.objects.forEach((t=>{t.visible=!0}))}}mergeInSingleSegment(t,e){const i=[...this.mergedLineSegments,...this.mergedLines].filter((e=>e.userData.structureId===t));if(0!==i.length)try{const n=[],r=i.some((t=>void 0!==t.geometry.attributes.normal));i.forEach((t=>{const e=t.geometry.clone();t.updateWorldMatrix(!0,!1),e.applyMatrix4(t.matrixWorld),r&&!e.attributes.normal&&e.computeVertexNormals(),!r&&e.attributes.normal&&e.deleteAttribute("normal");const i=new Float32Array(3*e.attributes.position.count);for(let e=0;e<i.length;e+=3)i[e]=t.material.color.r,i[e+1]=t.material.color.g,i[e+2]=t.material.color.b;if(e.setAttribute("color",new cr(i,3)),!e.index){const t=[],i=e.attributes.position.count;for(let e=0;e<i-1;e+=2)t.push(e,e+1);e.setIndex(t)}n.push(e)}));const s=lf(n,!1),a=new ya({vertexColors:!0});this.useVAO&&this.createVAO(s);const o=new La(s,a);o.userData.structureId=t,e.add(o),this.mergedLineSegments.add(o),i.forEach((t=>{t.parent&&t.parent.remove(t),t.geometry.dispose()}))}catch(t){console.error("Failed to merge geometries:",t),i.forEach((t=>{t.visible=!0,e.add(t)}))}}showOriginalObjects(t){t.forEach((t=>{this.originalObjects.has(t)&&(t.visible=!0)}))}hideOriginalObjects(t){t.forEach((t=>{this.originalObjects.has(t)&&(t.visible=!1)}))}createVAO(t){if(!this.useVAO)return;if(t.attributes?.position?.count<1e3)return;const e=this.renderer.getContext(),i=e.createVertexArray();e.bindVertexArray(i);for(const i in t.attributes){const n=t.attributes[i],r=this.renderer.properties.get(n).buffer;e.bindBuffer(e.ARRAY_BUFFER,r),e.enableVertexAttribArray(n.itemSize),e.vertexAttribPointer(n.itemSize,n.itemSize,e.FLOAT,!1,0,0)}if(t.index){const i=this.renderer.properties.get(t.index).buffer;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,i)}e.bindVertexArray(null),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),t.vao=i}getOriginalObjectForSelect(){const t=[];for(const e of this.originalObjectsToSelection)this.hiddenHandles.has(e.userData.handle)||t.push(e);return t}isolateObjects(t){0!==this.hiddenHandles.size&&(this.hiddenHandles.clear(),this.syncHiddenObjects());for(const e of this.handleToOptimizedObjects.keys())t.has(e)||this.hiddenHandles.add(e);this.syncHiddenObjects()}showAllHiddenObjects(){this.hiddenHandles.clear(),this.syncHiddenObjects()}hideObjects(t){t.forEach((t=>{this.hiddenHandles.add(t)})),this.syncHiddenObjects()}showObjects(t){t.forEach((t=>{this.hiddenHandles.delete(t)})),this.syncHiddenObjects()}syncHiddenObjects(){if(0!==this.oldOptimizeObjects.size){for(const t of this.oldOptimizeObjects)t.visible=!0;this.oldOptimizeObjects.clear()}if(0!==this.newOptimizedObjects.size){for(const t of this.newOptimizedObjects)t.visible=!1,t.geometry.dispose(),t.parent.remove(t);this.newOptimizedObjects.clear()}0!==this.hiddenHandles.size&&(this.hiddenHandles.forEach((t=>{const e=this.handleToOptimizedObjects.get(t);e&&e.forEach((t=>this.oldOptimizeObjects.add(t)))})),this.oldOptimizeObjects.forEach((t=>{t.visible=!1;const e=this.optimizedOriginalMap.get(t),i=[];e.forEach((t=>{this.hiddenHandles.has(t.userData.handle)||i.push(t)}));const n=i[0];if(n instanceof Dr||n instanceof La){const e=i.map((t=>{const e=t.geometry.clone();return t.updateWorldMatrix(!0,!1),e.applyMatrix4(t.matrixWorld),e})),r=lf(e),s=n instanceof Dr?new Dr(r,t.material):new La(r,t.material);s.visible=!0,t.parent.add(s),this.newOptimizedObjects.add(s),e.forEach((t=>{t.dispose()}))}else if(n instanceof Aa){let e=0;i.map((t=>{e+=t.geometry.attributes.position.count}));const n=new Float32Array(3*e);let r=0;const s=[];let a=0;i.forEach((t=>{const e=t.geometry.attributes.position,i=e.count;t.updateWorldMatrix(!0,!1);const o=t.matrixWorld,h=new Ci;for(let t=0;t<i;t++)h.fromBufferAttribute(e,t),h.applyMatrix4(o),n[r++]=h.x,n[r++]=h.y,n[r++]=h.z;for(let t=0;t<i-1;t++)s.push(a+t,a+t+1);a+=i}));const o=new br;o.setAttribute("position",new cr(n,3)),o.setIndex(s),o.computeBoundingSphere(),o.computeBoundingBox();const h=new La(o,t.material);h.visible=!0,t.parent.add(h),this.newOptimizedObjects.add(h)}})))}}class Sg{constructor(t){this.requestId=0,this.viewer=t,this.scene=new Zr}dispose(){this.gltfLoader&&this.gltfLoader.clear()}isSupport(t){return"object"==typeof t&&"string"==typeof t.database&&"function"==typeof t.downloadResource&&"function"==typeof t.downloadResourceRange&&/.gltf$/i.test(t.database)}async load(t,e,i){this.gltfLoader=new wg(this.viewer.camera,this.viewer.scene,this.viewer.renderer),this.gltfLoader.memoryLimit=this.viewer.options.memoryLimit,this.gltfLoader.addEventListener("databasechunk",(e=>{const i=new ug(this.scene);i.loader=this,i.gltfLoader=this.gltfLoader,i.viewer=this.viewer,this.viewer.scene.add(this.scene),this.viewer.models.push(i),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.update(),this.viewer.emitEvent({type:"databasechunk",data:e,file:t.file,model:t})})),this.gltfLoader.addEventListener("geometryprogress",(e=>{const i=e.loaded/e.total;this.viewer.emitEvent({type:"geometryprogress",data:i,file:t.file,model:t})})),this.gltfLoader.addEventListener("geometrymemory",(t=>{this.viewer.emit({type:"geometryprogress",data:t})})),this.gltfLoader.addEventListener("geometryerror",(e=>{this.viewer.emitEvent({type:"geometryerror",data:e,file:t.file,model:t})})),this.gltfLoader.addEventListener("update",(t=>{this.viewer.update()}));const n={loadJson:async()=>{const e=await t.downloadResource(t.database,(e=>{this.viewer.emitEvent({type:"geometryprogress",data:e,file:t})}),this.gltfLoader.getAbortController().signal),i=(new TextDecoder).decode(e);return JSON.parse(i)},loadBinaryData:e=>{const i=e.map((t=>({begin:t.offset,end:t.offset+t.length-1,requestId:this.requestId++})));return t.downloadResourceRange(t.geometry[0],void 0,i,void 0,this.gltfLoader.getAbortController().signal)},baseUrl:()=>Promise.resolve(`${t.httpClient.serverUrl}${t.path}/`)},r=new bg(1);return await r.initialize(n),await this.gltfLoader.loadStructure(r),await this.gltfLoader.loadNodes(),this}cancel(){this.gltfLoader&&this.gltfLoader.abortLoading()}}const Mg=p("threejs");Mg.registerLoader("gltf-file",(t=>new dg(t))),Mg.registerLoader("gltf-cloud",(t=>new Sg(t)));class Tg{constructor(){this._listeners={}}addEventListener(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners[t])return this;const i=this._listeners[t].filter((t=>t!==e));return 0!==i.length?this._listeners[t]=i:delete this._listeners[t],this}removeAllListeners(t){return t?delete this._listeners[t]:this._listeners={},this}emitEvent(t){if(void 0===this._listeners[t.type])return!1;return this._listeners[t.type].slice().forEach((e=>e.call(this,t))),!0}on(t,e){return this.addEventListener(t,e)}off(t,e){return this.removeEventListener(t,e)}emit(t,...e){return"string"==typeof t?this.emitEvent({type:t,args:e}):"object"==typeof t&&this.emitEvent(t)}}var Eg="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ag(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Cg,Rg={exports:{}},Pg={},Lg={},Ig={};function Dg(){return Cg||(Cg=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t._registerNode=t.Konva=t.glob=void 0;const e=Math.PI/180;t.glob=void 0!==Eg?Eg:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.18",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:i=>t.Konva.angleDeg?i*e:i,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(Ig)),Ig}var Og,Ng={};function Ug(){return Og||(Og=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=Dg();class i{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new i(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.m[0]*e+this.m[2]*i,r=this.m[1]*e+this.m[3]*i,s=this.m[0]*-i+this.m[2]*e,a=this.m[1]*-i+this.m[3]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=s,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,n=this.m[1]+this.m[3]*e,r=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=n,this.m[2]=r,this.m[3]=s,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],n=this.m[0]*t.m[2]+this.m[2]*t.m[3],r=this.m[1]*t.m[2]+this.m[3]*t.m[3],s=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=r,this.m[4]=s,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,n=-this.m[2]*t,r=this.m[0]*t,s=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=r,this.m[4]=s,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const e=this.m[0],i=this.m[1],n=this.m[2],r=this.m[3],s=e*r-i*n,a={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=i){const t=Math.sqrt(e*e+i*i);a.rotation=i>0?Math.acos(e/t):-Math.acos(e/t),a.scaleX=t,a.scaleY=s/t,a.skewX=(e*n+i*r)/s,a.skewY=0}else if(0!=n||0!=r){const t=Math.sqrt(n*n+r*r);a.rotation=Math.PI/2-(r>0?Math.acos(-n/t):-Math.acos(n/t)),a.scaleX=s/t,a.scaleY=t,a.skewX=0,a.skewY=(e*n+i*r)/s}return a.rotation=t.Util._getRotation(a.rotation),a}}t.Transform=i;const n=Math.PI/180,r=180/Math.PI,s="Konva error: ",a={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},o=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let h=[];const l="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};t.Util={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){h.push(t),1===h.length&&l((function(){const t=h;h=[],t.forEach((function(t){t()}))}))},createCanvasElement(){const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(e,i){const n=t.Util.createImageElement();n.onload=function(){i(n)},n.src=e},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return"#"+t},getRGB(t){let e;return t in a?(e=a[t],{r:e[0],g:e[1],b:e[2]}):"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=o.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",t.Util._namedColorToRBA(e)||t.Util._hex3ColorToRGBA(e)||t.Util._hex4ColorToRGBA(e)||t.Util._hex6ColorToRGBA(e)||t.Util._hex8ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)),_namedColorToRBA(t){const e=a[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map(((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t)));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),n=Number(i[0])/360,r=Number(i[1])/100,s=Number(i[2])/100;let a,o,h;if(0===r)return h=255*s,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};a=s<.5?s*(1+r):s+r-s*r;const l=2*s-a,c=[0,0,0];for(let t=0;t<3;t++)o=n+1/3*-(t-1),o<0&&o++,o>1&&o--,h=6*o<1?l+6*(a-l)*o:2*o<1?a:3*o<2?l+(a-l)*(2/3-o)*6:l,c[t]=255*h;return{r:Math.round(c[0]),g:Math.round(c[1]),b:Math.round(c[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){const e={};for(const i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*n,radToDeg:t=>t*r,_degToRad:e=>(t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),t.Util.degToRad(e)),_radToDeg:e=>(t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),t.Util.radToDeg(e)),_getRotation:i=>e.Konva.angleDeg?t.Util.radToDeg(i):i,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(s+t)},error(t){console.error(s+t)},warn(t){e.Konva.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,n,r,s){let a,o,h;const l=(t-i)*(t-i)+(e-n)*(e-n);if(0==l)a=t,o=e,h=(r-i)*(r-i)+(s-n)*(s-n);else{const c=((r-t)*(i-t)+(s-e)*(n-e))/l;c<0?(a=t,o=e,h=(t-r)*(t-r)+(e-s)*(e-s)):c>1?(a=i,o=n,h=(i-r)*(i-r)+(n-s)*(n-s)):(a=t+c*(i-t),o=e+c*(n-e),h=(a-r)*(a-r)+(o-s)*(o-s))}return[a,o,h]},_getProjectionToLine(e,i,n){const r=t.Util.cloneObject(e);let s=Number.MAX_VALUE;return i.forEach((function(a,o){if(!n&&o===i.length-1)return;const h=i[(o+1)%i.length],l=t.Util._getProjectionToSegment(a.x,a.y,h.x,h.y,e.x,e.y),c=l[0],d=l[1],u=l[2];u<s&&(r.x=c,r.y=d,s=u)})),r},_prepareArrayForTween(e,i,n){const r=[],s=[];if(e.length>i.length){const t=i;i=e,e=t}for(let t=0;t<e.length;t+=2)r.push({x:e[t],y:e[t+1]});for(let t=0;t<i.length;t+=2)s.push({x:i[t],y:i[t+1]});const a=[];return s.forEach((function(e){const i=t.Util._getProjectionToLine(e,r,n);a.push(i.x),a.push(i.y)})),a},_prepareToStringify(e){let i;e.visitedByCircularReferenceRemoval=!0;for(const n in e)if(e.hasOwnProperty(n)&&e[n]&&"object"==typeof e[n])if(i=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||t.Util._isElement(e[n])){if(!i.configurable)return null;delete e[n]}else if(null===t.Util._prepareToStringify(e[n])){if(!i.configurable)return null;delete e[n]}return delete e.visitedByCircularReferenceRemoval,e},_assign(t,e){for(const i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){e.Konva.releaseCanvasOnDestroy&&t.forEach((t=>{t.width=0,t.height=0}))},drawRoundedRectPath(t,e,i,n){let r=0,s=0,a=0,o=0;"number"==typeof n?r=s=a=o=Math.min(n,e/2,i/2):(r=Math.min(n[0]||0,e/2,i/2),s=Math.min(n[1]||0,e/2,i/2),o=Math.min(n[2]||0,e/2,i/2),a=Math.min(n[3]||0,e/2,i/2)),t.moveTo(r,0),t.lineTo(e-s,0),t.arc(e-s,s,s,3*Math.PI/2,0,!1),t.lineTo(e,i-o),t.arc(e-o,i-o,o,0,Math.PI/2,!1),t.lineTo(a,i),t.arc(a,i-a,a,Math.PI/2,Math.PI,!1),t.lineTo(0,r),t.arc(r,r,r,Math.PI,3*Math.PI/2,!1)}}}(Ng)),Ng}var Fg,kg,Bg={},zg={},Gg={};function Hg(){if(Fg)return Gg;Fg=1,Object.defineProperty(Gg,"__esModule",{value:!0}),Gg.RGBComponent=function(t){if(t>255)return 255;if(t<0)return 0;return Math.round(t)},Gg.alphaComponent=function(t){if(t>1)return 1;if(t<1e-4)return 1e-4;return t},Gg.getNumberValidator=function(){if(t.Konva.isUnminified)return function(t,n){return e.Util._isNumber(t)||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a number.'),t}},Gg.getNumberOrArrayOfNumbersValidator=function(n){if(t.Konva.isUnminified)return function(t,r){let s=e.Util._isNumber(t),a=e.Util._isArray(t)&&t.length==n;return s||a||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a number or Array<number>('+n+")"),t}},Gg.getNumberOrAutoValidator=function(){if(t.Konva.isUnminified)return function(t,n){return e.Util._isNumber(t)||"auto"===t||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or "auto".'),t}},Gg.getStringValidator=function(){if(t.Konva.isUnminified)return function(t,n){return e.Util._isString(t)||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a string.'),t}},Gg.getStringOrGradientValidator=function(){if(t.Konva.isUnminified)return function(t,n){const r=e.Util._isString(t),s="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return r||s||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a string or a native gradient.'),t}},Gg.getFunctionValidator=function(){if(t.Konva.isUnminified)return function(t,n){return e.Util._isFunction(t)||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a function.'),t}},Gg.getNumberArrayValidator=function(){if(t.Konva.isUnminified)return function(t,n){const r=Int8Array?Object.getPrototypeOf(Int8Array):null;return r&&t instanceof r||(e.Util._isArray(t)?t.forEach((function(t){e.Util._isNumber(t)||e.Util.warn('"'+n+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a array of numbers.')),t}},Gg.getBooleanValidator=function(){if(t.Konva.isUnminified)return function(t,n){return!0===t||!1===t||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a boolean.'),t}},Gg.getComponentValidator=function(n){if(t.Konva.isUnminified)return function(t,r){return null==t||e.Util.isObject(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be an object with properties '+n),t}};const t=Dg(),e=Ug();function i(t){return e.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||e.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}return Gg}function Vg(){return kg||(kg=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=Ug(),i=Hg(),n="get",r="set";t.Factory={addGetterSetter(e,i,n,r,s){t.Factory.addGetter(e,i,n),t.Factory.addSetter(e,i,r,s),t.Factory.addOverloadedGetterSetter(e,i)},addGetter(t,i,r){var s=n+e.Util._capitalize(i);t.prototype[s]=t.prototype[s]||function(){const t=this.attrs[i];return void 0===t?r:t}},addSetter(i,n,s,a){var o=r+e.Util._capitalize(n);i.prototype[o]||t.Factory.overWriteSetter(i,n,s,a)},overWriteSetter(t,i,n,s){var a=r+e.Util._capitalize(i);t.prototype[a]=function(t){return n&&null!=t&&(t=n.call(this,t,i)),this._setAttr(i,t),s&&s.call(this),this}},addComponentsGetterSetter(s,a,o,h,l){const c=o.length,d=e.Util._capitalize,u=n+d(a),p=r+d(a);s.prototype[u]=function(){const t={};for(let e=0;e<c;e++){const i=o[e];t[i]=this.getAttr(a+d(i))}return t};const m=(0,i.getComponentValidator)(o);s.prototype[p]=function(t){const e=this.attrs[a];h&&(t=h.call(this,t,a)),m&&m.call(this,t,a);for(const e in t)t.hasOwnProperty(e)&&this._setAttr(a+d(e),t[e]);return t||o.forEach((t=>{this._setAttr(a+d(t),void 0)})),this._fireChangeEvent(a,e,t),l&&l.call(this),this},t.Factory.addOverloadedGetterSetter(s,a)},addOverloadedGetterSetter(t,i){var s=e.Util._capitalize(i),a=r+s,o=n+s;t.prototype[i]=function(){return arguments.length?(this[a](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(i,r,s,a){e.Util.error("Adding deprecated "+r);const o=n+e.Util._capitalize(r),h=r+" property is deprecated and will be removed soon. Look at Konva change log for more information.";i.prototype[o]=function(){e.Util.error(h);const t=this.attrs[r];return void 0===t?s:t},t.Factory.addSetter(i,r,a,(function(){e.Util.error(h)})),t.Factory.addOverloadedGetterSetter(i,r)},backCompat(t,i){e.Util.each(i,(function(i,s){const a=t.prototype[s],o=n+e.Util._capitalize(i),h=r+e.Util._capitalize(i);function l(){a.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+s+'" instead.')}t.prototype[i]=l,t.prototype[o]=l,t.prototype[h]=l}))},afterSetFilter(){this._filterUpToDate=!1}}}(zg)),zg}var Wg,jg,Xg={},Yg={};function qg(){if(Wg)return Yg;Wg=1,Object.defineProperty(Yg,"__esModule",{value:!0}),Yg.HitContext=Yg.SceneContext=Yg.Context=void 0;const t=Ug(),e=Dg();const i=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];let n=class{constructor(t){this.canvas=t,e.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(e,i){let n,r,s,a,o=this.traceArr,h=o.length,l="";for(n=0;n<h;n++)r=o[n],s=r.method,s?(a=r.args,l+=s,e?l+="()":t.Util._isArray(a[0])?l+="(["+a.join(",")+"])":(i&&(a=a.map((t=>"number"==typeof t?Math.floor(t):t))),l+="("+a.join(",")+")")):(l+=r.property,e||(l+="="+r.val)),l+=";";return l}clearTrace(){this.traceArr=[]}_trace(t){let e,i=this.traceArr;i.push(t),e=i.length,e>=100&&i.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,n,r,s){this._context.arc(t,e,i,n,r,s)}arcTo(t,e,i,n,r){this._context.arcTo(t,e,i,n,r)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,n,r,s){this._context.bezierCurveTo(t,e,i,n,r,s)}clearRect(t,e,i,n){this._context.clearRect(t,e,i,n)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,n){return this._context.createLinearGradient(t,e,i,n)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,n,r,s){return this._context.createRadialGradient(t,e,i,n,r,s)}drawImage(t,e,i,n,r,s,a,o,h){const l=arguments,c=this._context;3===l.length?c.drawImage(t,e,i):5===l.length?c.drawImage(t,e,i,n,r):9===l.length&&c.drawImage(t,e,i,n,r,s,a,o,h)}ellipse(t,e,i,n,r,s,a,o){this._context.ellipse(t,e,i,n,r,s,a,o)}isPointInPath(t,e,i,n){return i?this._context.isPointInPath(i,t,e,n):this._context.isPointInPath(t,e,n)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,n){this._context.fillRect(t,e,i,n)}strokeRect(t,e,i,n){this._context.strokeRect(t,e,i,n)}fillText(t,e,i,n){n?this._context.fillText(t,e,i,n):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,n){return this._context.getImageData(t,e,i,n)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,n){this._context.rect(t,e,i,n)}roundRect(t,e,i,n,r){this._context.roundRect(t,e,i,n,r)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,n){this._context.quadraticCurveTo(t,e,i,n)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,n,r,s){this._context.setTransform(t,e,i,n,r,s)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,n){this._context.strokeText(t,e,i,n)}transform(t,e,i,n,r,s){this._context.transform(t,e,i,n,r,s)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let e,n,r=this,s=i.length,a=this.setAttr;const o=function(e){let i,s=r[e];r[e]=function(){return n=function(e){const i=[],n=e.length,r=t.Util;for(let t=0;t<n;t++){let n=e[t];r._isNumber(n)?n=Math.round(1e3*n)/1e3:r._isString(n)||(n+=""),i.push(n)}return i}(Array.prototype.slice.call(arguments,0)),i=s.apply(r,arguments),r._trace({method:e,args:n}),i}};for(e=0;e<s;e++)o(i[e]);r.setAttr=function(){a.apply(r,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),r._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}};Yg.Context=n,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(n.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}));Yg.SceneContext=class extends n{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){const e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const n=t.getFillPatternImage();if(n&&"pattern"===i)return void this._fillPattern(t);const r=t.getFillLinearGradientColorStops();if(r&&"linear-gradient"===i)return void this._fillLinearGradient(t);const s=t.getFillRadialGradientColorStops();s&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):n?this._fillPattern(t):r?this._fillLinearGradient(t):s&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),n=t.getStrokeLinearGradientColorStops(),r=this.createLinearGradient(e.x,e.y,i.x,i.y);if(n){for(let t=0;t<n.length;t+=2)r.addColorStop(n[t],n[t+1]);this.setAttr("strokeStyle",r)}}_stroke(t){const e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,n;const r=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",s=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,a=null!==(n=t.getShadowOffset())&&void 0!==n?n:{x:0,y:0},o=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=o.x*h,c=o.y*h;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",s*Math.min(Math.abs(l),Math.abs(c))),this.setAttr("shadowOffsetX",a.x*l),this.setAttr("shadowOffsetY",a.y*c)}};return Yg.HitContext=class extends n{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const e=t.getStrokeScaleEnabled();if(!e){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t);const i=t.hitStrokeWidth(),n="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}},Yg}function Kg(){if(jg)return Xg;jg=1,Object.defineProperty(Xg,"__esModule",{value:!0}),Xg.HitCanvas=Xg.SceneCanvas=Xg.Canvas=void 0;const t=Ug(),e=qg(),i=Dg(),n=Vg(),r=Hg();let s;let a=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const n=(e||{}).pixelRatio||i.Konva.pixelRatio||function(){if(s)return s;const e=t.Util.createCanvasElement(),n=e.getContext("2d");return s=(i.Konva._global.devicePixelRatio||1)/(n.webkitBackingStorePixelRatio||n.mozBackingStorePixelRatio||n.msBackingStorePixelRatio||n.oBackingStorePixelRatio||n.backingStorePixelRatio||1),t.Util.releaseCanvas(e),s}();this.pixelRatio=n,this._canvas=t.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){const e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(e,i){try{return this._canvas.toDataURL(e,i)}catch(e){try{return this._canvas.toDataURL()}catch(e){return t.Util.error("Unable to get data URL. "+e.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}};Xg.Canvas=a,n.Factory.addGetterSetter(a,"pixelRatio",void 0,(0,r.getNumberValidator)());Xg.SceneCanvas=class extends a{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new e.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};return Xg.HitCanvas=class extends a{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new e.HitContext(this),this.setSize(t.width,t.height)}},Xg}var Zg,Jg,Qg={};function $g(){return Zg||(Zg=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=Dg(),i=Ug();t.DD={get isDragging(){let e=!1;return t.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){let e;return t.DD._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const n=[];t.DD._dragElements.forEach(((t,r)=>{const{node:s}=t,a=s.getStage();a.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=i.Util._getFirstPointerId(e));const o=a._changedPointerPositions.find((e=>e.id===t.pointerId));if(o){if("dragging"!==t.dragStatus){const i=s.dragDistance();if(Math.max(Math.abs(o.x-t.startPointerPos.x),Math.abs(o.y-t.startPointerPos.y))<i)return;if(s.startDrag({evt:e}),!s.isDragging())return}s._setDragPosition(e,t),n.push(s)}})),n.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(i){const n=[];t.DD._dragElements.forEach((r=>{const{node:s}=r,a=s.getStage();i&&a.setPointersPositions(i);if(!a._changedPointerPositions.find((t=>t.id===r.pointerId)))return;"dragging"!==r.dragStatus&&"stopped"!==r.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,r.dragStatus="stopped");const o=r.node.getLayer()||r.node instanceof e.Konva.Stage&&r.node;o&&-1===n.indexOf(o)&&n.push(o)})),n.forEach((t=>{t.draw()}))},_endDragAfter(e){t.DD._dragElements.forEach(((i,n)=>{"stopped"===i.dragStatus&&i.node.fire("dragend",{type:"dragend",target:i.node,evt:e},!0),"dragging"!==i.dragStatus&&t.DD._dragElements.delete(n)}))}},e.Konva.isBrowser&&(window.addEventListener("mouseup",t.DD._endDragBefore,!0),window.addEventListener("touchend",t.DD._endDragBefore,!0),window.addEventListener("touchcancel",t.DD._endDragBefore,!0),window.addEventListener("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1),window.addEventListener("touchcancel",t.DD._endDragAfter,!1))}(Qg)),Qg}function tv(){if(Jg)return Bg;Jg=1,Object.defineProperty(Bg,"__esModule",{value:!0}),Bg.Node=void 0;const t=Ug(),e=Vg(),i=Kg(),n=Dg(),r=$g(),s=Hg(),a="absoluteOpacity",o="allEventListeners",h="absoluteTransform",l="absoluteScale",c="canvas",d="listening",u="mouseenter",p="mouseleave",m="Shape",f=" ",g="stage",v="transform",_="visible",y=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(f);let x=1,b=class e{constructor(t){this._id=x++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==v&&t!==h||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let i=this._cache.get(t);return(void 0===i||(t===v||t===h)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map((t=>t+"Change.konva")).join(f);this.on(i,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(c)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===h&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(c)){const{scene:e,filter:i,hit:n}=this._cache.get(c);t.Util.releaseCanvas(e,i,n),this._cache.delete(c)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){const n=e||{};let r={};void 0!==n.x&&void 0!==n.y&&void 0!==n.width&&void 0!==n.height||(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let s=Math.ceil(n.width||r.width),o=Math.ceil(n.height||r.height),h=n.pixelRatio,d=void 0===n.x?Math.floor(r.x):n.x,u=void 0===n.y?Math.floor(r.y):n.y,p=n.offset||0,m=n.drawBorder||!1,f=n.hitCanvasPixelRatio||1;if(!s||!o)return void t.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");s+=2*p+(Math.abs(Math.round(r.x)-d)>.5?1:0),o+=2*p+(Math.abs(Math.round(r.y)-u)>.5?1:0),d-=p,u-=p;const g=new i.SceneCanvas({pixelRatio:h,width:s,height:o}),v=new i.SceneCanvas({pixelRatio:h,width:0,height:0,willReadFrequently:!0}),_=new i.HitCanvas({pixelRatio:f,width:s,height:o}),y=g.getContext(),x=_.getContext();return _.isCache=!0,g.isCache=!0,this._cache.delete(c),this._filterUpToDate=!1,!1===n.imageSmoothingEnabled&&(g.getContext()._context.imageSmoothingEnabled=!1,v.getContext()._context.imageSmoothingEnabled=!1),y.save(),x.save(),y.translate(-d,-u),x.translate(-d,-u),this._isUnderCache=!0,this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(l),this.drawScene(g,this),this.drawHit(_,this),this._isUnderCache=!1,y.restore(),x.restore(),m&&(y.save(),y.beginPath(),y.rect(0,0,s,o),y.closePath(),y.setAttr("strokeStyle","red"),y.setAttr("lineWidth",5),y.stroke(),y.restore()),this._cache.set(c,{scene:g,filter:v,hit:_,x:d,y:u}),this._requestDraw(),this}isCached(){return this._cache.has(c)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let n=1/0,r=1/0,s=-1/0,a=-1/0;const o=this.getAbsoluteTransform(e);return i.forEach((function(t){const e=o.point(t);void 0===n&&(n=s=e.x,r=a=e.y),n=Math.min(n,e.x),r=Math.min(r,e.y),s=Math.max(s,e.x),a=Math.max(a,e.y)})),{x:n,y:r,width:s-n,height:a-r}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const i=this._getCachedSceneCanvas(),n=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/n,i.height/n),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){let e,i,n,r,s=this.filters(),a=this._getCanvasCache(),o=a.scene,h=a.filter,l=h.getContext();if(s){if(!this._filterUpToDate){const a=o.pixelRatio;h.setSize(o.width/o.pixelRatio,o.height/o.pixelRatio);try{for(e=s.length,l.clear(),l.drawImage(o._canvas,0,0,o.getWidth()/a,o.getHeight()/a),i=l.getImageData(0,0,h.getWidth(),h.getHeight()),n=0;n<e;n++)r=s[n],"function"==typeof r?(r.call(this,i),l.putImageData(i,0,0)):t.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(e){t.Util.error("Unable to apply filter. "+e.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return h}return o}on(t,e){if(this._cache&&this._cache.delete(o),3===arguments.length)return this._delegate.apply(this,arguments);let i,n,r,s,a,h=t.split(f),l=h.length;for(i=0;i<l;i++)n=h[i],r=n.split("."),s=r[0],a=r[1]||"",this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:a,handler:e});return this}off(t,e){let i,n,r,s,a,h,l=(t||"").split(f),c=l.length;if(this._cache&&this._cache.delete(o),!t)for(n in this.eventListeners)this._off(n);for(i=0;i<c;i++)if(r=l[i],s=r.split("."),a=s[0],h=s[1],a)this.eventListeners[a]&&this._off(a,h,e);else for(n in this.eventListeners)this._off(n,h,e);return this}dispatchEvent(t){const e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,(function(t){e.call(this,t.evt)})),this}removeEventListener(t){return this.off(t),this}_delegate(e,i,n){const r=this;this.on(e,(function(e){const s=e.target.findAncestors(i,!0,r);for(let i=0;i<s.length;i++)(e=t.Util.cloneObject(e)).currentTarget=s[i],n.call(s[i],e)}))}remove(){return this.isDragging()&&this.stopDrag(),r.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(h),this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(g),this._clearSelfAndDescendantCache(_),this._clearSelfAndDescendantCache(d)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){const i="get"+t.Util._capitalize(e);return t.Util._isFunction(this[i])?this[i]():this.attrs[e]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges((()=>{let i,n;if(!e)return this;for(i in e)"children"!==i&&(n="set"+t.Util._capitalize(i),t.Util._isFunction(this[n])?this[n](e[i]):this._setAttr(i,e[i]))})),this}isListening(){return this._getCache(d,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(_,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const i=this.getLayer();let s=!1;r.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(s=!0)}));const a=!e&&!n.Konva.hitOnDragEnabled&&(s||n.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!a}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,n,r=this.getDepth(),s=this,a=0;const o=this.getStage();return"Stage"!==s.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)n=h[i],a++,n.nodeType!==m&&(t=t.concat(n.getChildren().slice())),n._id===s._id&&(i=e);t.length>0&&t[0].getDepth()<=r&&o(t)}(o.getChildren()),a}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(v),this._clearSelfAndDescendantCache(h)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges((()=>{this.x(t.x),this.y(t.y)})),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(e){let i=!1,n=this.parent;for(;n;){if(n.isCached()){i=!0;break}n=n.parent}i&&!e&&(e=!0);const r=this.getAbsoluteTransform(e).getMatrix(),s=new t.Transform,a=this.offset();return s.m=r.slice(),s.translate(a.x,a.y),s.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...n}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(v);const r=this._getAbsoluteTransform().copy();return r.invert(),r.translate(t.x,t.y),t={x:this.attrs.x+r.getTranslation().x,y:this.attrs.y+r.getTranslation().y},this._setTransform(n),this.setPosition({x:t.x,y:t.y}),this._clearCache(v),this._clearSelfAndDescendantCache(h),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,i=t.y,n=this.x(),r=this.y();return void 0!==e&&(n+=e),void 0!==i&&(r+=i),this.setPosition({x:n,y:r}),this}_eachAncestorReverse(t,e){let i,n,r=[],s=this.getParent();if(!e||e._id!==this._id){for(r.unshift(this);s&&(!e||s._id!==e._id);)r.unshift(s),s=s.parent;for(i=r.length,n=0;n<i;n++)t(r[n])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return t.Util.warn("Node has no parent. moveToTop function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return t.Util.warn("Node has no parent. moveUp function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return t.Util.warn("Node has no parent. moveDown function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return t.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return t.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&t.Util.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const i=this.index;return this.parent.children.splice(i,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(a,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let e,i,n,r,s,a=this.getAttrs();const o={attrs:{},className:this.getClassName()};for(e in a)i=a[e],s=t.Util.isObject(i)&&!t.Util._isPlainObject(i)&&!t.Util._isArray(i),s||(n="function"==typeof this[e]&&this[e],delete a[e],r=n?n.call(this):null,a[e]=i,r!==i&&(o.attrs[e]=i));return t.Util._prepareToStringify(o)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const n=[];e&&this._isMatch(t)&&n.push(this);let r=this.parent;for(;r;){if(r===i)return n;r._isMatch(t)&&n.push(r),r=r.parent}return n}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(e){if(!e)return!1;if("function"==typeof e)return e(this);let i,n,r=e.replace(/ /g,"").split(","),s=r.length;for(i=0;i<s;i++)if(n=r[i],t.Util.isValidSelector(n)||(t.Util.warn('Selector "'+n+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),t.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),t.Util.warn("Konva is awesome, right?")),"#"===n.charAt(0)){if(this.id()===n.slice(1))return!0}else if("."===n.charAt(0)){if(this.hasName(n.slice(1)))return!0}else if(this.className===n||this.nodeType===n)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(g,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(h,this._getAbsoluteTransform)}_getAbsoluteTransform(e){let i;if(e)return i=new t.Transform,this._eachAncestorReverse((function(t){const e=t.transformsEnabled();"all"===e?i.multiply(t.getTransform()):"position"===e&&i.translate(t.x()-t.offsetX(),t.y()-t.offsetY())}),e),i;{i=this._cache.get(h)||new t.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(i):i.reset();const e=this.transformsEnabled();if("all"===e)i.multiply(this.getTransform());else if("position"===e){const t=this.attrs.x||0,e=this.attrs.y||0,n=this.attrs.offsetX||0,r=this.attrs.offsetY||0;i.translate(t-n,e-r)}return i.dirty=!1,i}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(v,this._getTransform)}_getTransform(){var e,i;const r=this._cache.get(v)||new t.Transform;r.reset();const s=this.x(),a=this.y(),o=n.Konva.getAngle(this.rotation()),h=null!==(e=this.attrs.scaleX)&&void 0!==e?e:1,l=null!==(i=this.attrs.scaleY)&&void 0!==i?i:1,c=this.attrs.skewX||0,d=this.attrs.skewY||0,u=this.attrs.offsetX||0,p=this.attrs.offsetY||0;return 0===s&&0===a||r.translate(s,a),0!==o&&r.rotate(o),0===c&&0===d||r.skew(c,d),1===h&&1===l||r.scale(h,l),0===u&&0===p||r.translate(-1*u,-1*p),r.dirty=!1,r}clone(e){let i,n,r,s,a,o=t.Util.cloneObject(this.attrs);for(i in e)o[i]=e[i];const h=new this.constructor(o);for(i in this.eventListeners)for(n=this.eventListeners[i],r=n.length,s=0;s<r;s++)a=n[s],a.name.indexOf("konva")<0&&(h.eventListeners[i]||(h.eventListeners[i]=[]),h.eventListeners[i].push(a));return h}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),n=this.getStage(),r=void 0!==t.x?t.x:Math.floor(e.x),s=void 0!==t.y?t.y:Math.floor(e.y),a=t.pixelRatio||1,o=new i.SceneCanvas({width:t.width||Math.ceil(e.width)||(n?n.width():0),height:t.height||Math.ceil(e.height)||(n?n.height():0),pixelRatio:a}),h=o.getContext(),l=new i.SceneCanvas({width:o.width/o.pixelRatio+Math.abs(r),height:o.height/o.pixelRatio+Math.abs(s),pixelRatio:o.pixelRatio});return!1===t.imageSmoothingEnabled&&(h._context.imageSmoothingEnabled=!1),h.save(),(r||s)&&h.translate(-1*r,-1*s),this.drawScene(o,void 0,l),h.restore(),o}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,n=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(n),n}toImage(e){return new Promise(((i,n)=>{try{const n=null==e?void 0:e.callback;n&&delete e.callback,t.Util._urlToImage(this.toDataURL(e),(function(t){i(t),null==n||n(t)}))}catch(t){n(t)}}))}toBlob(t){return new Promise(((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob((t=>{e(t),null==i||i(t)}),null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}}))}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():n.Konva.dragDistance}_off(t,e,i){let n,r,s,a=this.eventListeners[t];for(n=0;n<a.length;n++)if(r=a[n].name,s=a[n].handler,!("konva"===r&&"konva"!==e||e&&r!==e||i&&i!==s)){if(a.splice(n,1),0===a.length){delete this.eventListeners[t];break}n--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){const e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();if(!e)return!1;return-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){const e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(e,i){const n=this["set"+t.Util._capitalize(e)];return t.Util._isFunction(n)?n.call(this,i):this._setAttr(e,i),this}_requestDraw(){if(n.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(e,i){const n=this.attrs[e];(n!==i||t.Util.isObject(i))&&(null==i?delete this.attrs[e]:this.attrs[e]=i,this._shouldFireChangeEvents&&this._fireChangeEvent(e,n,i),this._requestDraw())}_setComponentAttr(t,e,i){let n;void 0!==i&&(n=this.attrs[t],n||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,n,i))}_fireAndBubble(t,e,i){e&&this.nodeType===m&&(e.target=this);if(!((t===u||t===p)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const n=(t===u||t===p)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!n&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,n;const r=null!==(e=this._cache.get(o))&&void 0!==e?e:{};let s=null==r?void 0:r[t];if(void 0===s){s=[];let e=Object.getPrototypeOf(this);for(;e;){const r=null!==(n=null===(i=e.eventListeners)||void 0===i?void 0:i[t])&&void 0!==n?n:[];s.push(...r),e=Object.getPrototypeOf(e)}r[t]=s,this._cache.set(o,r)}return s}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(var n=0;n<i.length;n++)i[n].handler.call(this,e);const r=this.eventListeners[t];if(r)for(n=0;n<r.length;n++)r[n].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,i=this.getStage(),n=this.getAbsolutePosition();if(!i)return;const s=i._getPointerById(e)||i._changedPointerPositions[0]||n;r.DD._dragElements.set(this._id,{node:this,startPointerPos:s,offset:{x:s.x-n.x,y:s.y-n.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){r.DD._dragElements.has(this._id)||this._createDragElement(t);r.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(e,i){const n=this.getStage()._getPointerById(i.pointerId);if(!n)return;let r={x:n.x-i.offset.x,y:n.y-i.offset.y};const s=this.dragBoundFunc();if(void 0!==s){const i=s.call(this,r,e);i?r=i:t.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}stopDrag(t){const e=r.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),r.DD._endDragBefore(t),r.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=r.DD._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(t){if(!(!(void 0!==t.evt.button)||n.Konva.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;r.DD._dragElements.forEach((t=>{this.isAncestorOf(t.node)&&(e=!0)})),e||this._createDragElement(t)}))}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=r.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&r.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const i=this.getStage();if(!i)return!1;const n={x:-e.x,y:-e.y,width:i.width()+2*e.x,height:i.height()+2*e.y};return t.Util.haveIntersection(n,this.getClientRect())}static create(e,i){return t.Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,i)}static _createNode(i,r){let s,a,o,h=e.prototype.getClassName.call(i),l=i.children;r&&(i.attrs.container=r),n.Konva[h]||(t.Util.warn('Can not find a node with class name "'+h+'". Fallback to "Shape".'),h="Shape");if(s=new(0,n.Konva[h])(i.attrs),l)for(a=l.length,o=0;o<a;o++)s.add(e._createNode(l[o]));return s}};Bg.Node=b,b.prototype.nodeType="Node",b.prototype._attrsAffectingSize=[],b.prototype.eventListeners={},b.prototype.on.call(b.prototype,y,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(v),this._clearSelfAndDescendantCache(h))})),b.prototype.on.call(b.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(_)})),b.prototype.on.call(b.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(d)})),b.prototype.on.call(b.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(a)}));const w=e.Factory.addGetterSetter;return w(b,"zIndex"),w(b,"absolutePosition"),w(b,"position"),w(b,"x",0,(0,s.getNumberValidator)()),w(b,"y",0,(0,s.getNumberValidator)()),w(b,"globalCompositeOperation","source-over",(0,s.getStringValidator)()),w(b,"opacity",1,(0,s.getNumberValidator)()),w(b,"name","",(0,s.getStringValidator)()),w(b,"id","",(0,s.getStringValidator)()),w(b,"rotation",0,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(b,"scale",["x","y"]),w(b,"scaleX",1,(0,s.getNumberValidator)()),w(b,"scaleY",1,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(b,"skew",["x","y"]),w(b,"skewX",0,(0,s.getNumberValidator)()),w(b,"skewY",0,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(b,"offset",["x","y"]),w(b,"offsetX",0,(0,s.getNumberValidator)()),w(b,"offsetY",0,(0,s.getNumberValidator)()),w(b,"dragDistance",void 0,(0,s.getNumberValidator)()),w(b,"width",0,(0,s.getNumberValidator)()),w(b,"height",0,(0,s.getNumberValidator)()),w(b,"listening",!0,(0,s.getBooleanValidator)()),w(b,"preventDefault",!0,(0,s.getBooleanValidator)()),w(b,"filters",void 0,(function(t){return this._filterUpToDate=!1,t})),w(b,"visible",!0,(0,s.getBooleanValidator)()),w(b,"transformsEnabled","all",(0,s.getStringValidator)()),w(b,"size"),w(b,"dragBoundFunc"),w(b,"draggable",!1,(0,s.getBooleanValidator)()),e.Factory.backCompat(b,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"}),Bg}var ev,iv={};function nv(){if(ev)return iv;ev=1,Object.defineProperty(iv,"__esModule",{value:!0}),iv.Container=void 0;const t=Vg(),e=tv(),i=Hg();let n=class extends e.Node{constructor(){super(...arguments),this.children=[]}getChildren(t){if(!t)return this.children||[];const e=this.children||[],i=[];return e.forEach((function(e){t(e)&&i.push(e)})),i}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.remove()})),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.destroy()})),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e<t.length;e++)this.add(t[e]);return this}const e=t[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){const e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){const i=[];return this._descendants((n=>{const r=n._isMatch(t);return r&&i.push(n),!(!r||!e)})),i}_descendants(t){let e=!1;const i=this.getChildren();for(const n of i){if(e=t(n),e)return!0;if(n.hasChildren()&&(e=n._descendants(t),e))return!0}return!1}toObject(){const t=e.Node.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach((e=>{t.children.push(e.toObject())})),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const i=e.Node.prototype.clone.call(this,t);return this.getChildren().forEach((function(t){i.add(t.clone())})),i}getAllIntersections(t){const e=[];return this.find("Shape").forEach((i=>{i.isVisible()&&i.intersects(t)&&e.push(i)})),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach((function(e){e._clearSelfAndDescendantCache(t)}))}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach((function(t,e){t.index=e})),this._requestDraw()}drawScene(t,e,i){const n=this.getLayer(),r=t||n&&n.getCanvas(),s=r&&r.getContext(),a=this._getCanvasCache(),o=a&&a.scene,h=r&&r.isCache;if(!this.isVisible()&&!h)return this;if(o){s.save();const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(s),s.restore()}else this._drawChildren("drawScene",r,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),n=t||i&&i.hitCanvas,r=n&&n.getContext(),s=this._getCanvasCache();if(s&&s.hit){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(r),r.restore()}else this._drawChildren("drawHit",n,e);return this}_drawChildren(t,e,i,n){var r;const s=e&&e.getContext(),a=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l="number"==typeof a&&"number"==typeof o||h,c=i===this;if(l){s.save();const t=this.getAbsoluteTransform(i);let e,n=t.getMatrix();if(s.transform(n[0],n[1],n[2],n[3],n[4],n[5]),s.beginPath(),h)e=h.call(this,s,this);else{const t=this.clipX(),e=this.clipY();s.rect(t||0,e||0,a,o)}s.clip.apply(s,e),n=t.copy().invert().getMatrix(),s.transform(n[0],n[1],n[2],n[3],n[4],n[5])}const d=!c&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;d&&(s.save(),s._applyGlobalCompositeOperation(this)),null===(r=this.children)||void 0===r||r.forEach((function(r){r[t](e,i,n)})),d&&s.restore(),l&&s.restore()}getClientRect(t={}){var e;const i=t.skipTransform,n=t.relativeTo;let r,s,a,o,h={x:1/0,y:1/0,width:0,height:0};const l=this;null===(e=this.children)||void 0===e||e.forEach((function(e){if(!e.visible())return;const i=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===i.width&&0===i.height||(void 0===r?(r=i.x,s=i.y,a=i.x+i.width,o=i.y+i.height):(r=Math.min(r,i.x),s=Math.min(s,i.y),a=Math.max(a,i.x+i.width),o=Math.max(o,i.y+i.height)))}));const c=this.find("Shape");let d=!1;for(let t=0;t<c.length;t++){if(c[t]._isVisible(this)){d=!0;break}}return h=d&&void 0!==r?{x:r,y:s,width:a-r,height:o-s}:{x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,n)}};return iv.Container=n,t.Factory.addComponentsGetterSetter(n,"clip",["x","y","width","height"]),t.Factory.addGetterSetter(n,"clipX",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"clipY",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"clipWidth",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"clipHeight",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"clipFunc"),iv}var rv,sv,av={},ov={};function hv(){if(rv)return ov;rv=1,Object.defineProperty(ov,"__esModule",{value:!0}),ov.getCapturedShape=function(t){return e.get(t)},ov.createEvent=n,ov.hasPointerCapture=function(t,i){return e.get(t)===i},ov.setPointerCapture=function(t,s){r(t);if(!s.getStage())return;e.set(t,s),i&&s._fire("gotpointercapture",n(new PointerEvent("gotpointercapture")))},ov.releaseCapture=r;const t=Dg(),e=new Map,i=void 0!==t.Konva._global.PointerEvent;function n(t){return{evt:t,pointerId:t.pointerId}}function r(t,r){const s=e.get(t);if(!s)return;const a=s.getStage();a&&a.content,e.delete(t),i&&s._fire("lostpointercapture",n(new PointerEvent("lostpointercapture")))}return ov}var lv,cv,dv={},uv={};function pv(){return lv||(lv=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=Dg(),i=Ug(),n=Vg(),r=tv(),s=Hg(),a=Dg(),o=hv(),h="hasShadow",l="shadowRGBA",c="patternImage",d="linearGradient",u="radialGradient";let p;function m(){return p||(p=i.Util.createCanvasElement().getContext("2d"),p)}t.shapes={};class f extends r.Node{constructor(e){let n;for(super(e);n=i.Util.getRandomColor(),!n||n in t.shapes;);this.colorKey=n,t.shapes[n]=this}getContext(){return i.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return i.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(h,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(c,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=m().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const n=new i.Transform;n.translate(this.fillPatternX(),this.fillPatternY()),n.rotate(e.Konva.getAngle(this.fillPatternRotation())),n.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),n.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const r=n.getMatrix(),s="undefined"==typeof DOMMatrix?{a:r[0],b:r[1],c:r[2],d:r[3],e:r[4],f:r[5]}:new DOMMatrix(r);t.setTransform(s)}return t}}_getLinearGradient(){return this._getCache(d,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=m(),i=this.fillLinearGradientStartPoint(),n=this.fillLinearGradientEndPoint(),r=e.createLinearGradient(i.x,i.y,n.x,n.y);for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}_getRadialGradient(){return this._getCache(u,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=m(),i=this.fillRadialGradientStartPoint(),n=this.fillRadialGradientEndPoint(),r=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),n.x,n.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}getShadowRGBA(){return this._getCache(l,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=i.Util.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return r.Node.prototype.destroy.call(this),delete t.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),n=this.hasStroke(),r=1!==this.getAbsoluteOpacity();if(i&&n&&r)return!0;const s=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(i&&n&&s&&a)}setStrokeHitEnabled(t){i.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const n=t.skipTransform,r=t.relativeTo||e&&this.getStage()||void 0,s=this.getSelfRect(),a=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=s.width+a,h=s.height+a,l=!t.skipShadow&&this.hasShadow(),c=l?this.shadowOffsetX():0,d=l?this.shadowOffsetY():0,u=o+Math.abs(c),p=h+Math.abs(d),m=l&&this.shadowBlur()||0,f={width:u+2*m,height:p+2*m,x:-(a/2+m)+Math.min(c,0)+s.x,y:-(a/2+m)+Math.min(d,0)+s.y};return n?f:this._transformedRect(f,r)}drawScene(t,e,i){const n=this.getLayer();let r,s,a=t||n.getCanvas(),o=a.getContext(),h=this._getCanvasCache(),l=this.getSceneFunc(),c=this.hasShadow();const d=a.isCache,u=e===this;if(!this.isVisible()&&!u)return this;if(h){o.save();const t=this.getAbsoluteTransform(e).getMatrix();return o.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!l)return this;if(o.save(),this._useBufferCanvas()&&!d){r=this.getStage();const t=i||r.bufferCanvas;s=t.getContext(),s.clear(),s.save(),s._applyLineJoin(this);var p=this.getAbsoluteTransform(e).getMatrix();s.transform(p[0],p[1],p[2],p[3],p[4],p[5]),l.call(this,s,this),s.restore();const n=t.pixelRatio;c&&o._applyShadow(this),o._applyOpacity(this),o._applyGlobalCompositeOperation(this),o.drawImage(t._canvas,0,0,t.width/n,t.height/n)}else{if(o._applyLineJoin(this),!u){p=this.getAbsoluteTransform(e).getMatrix();o.transform(p[0],p[1],p[2],p[3],p[4],p[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}c&&o._applyShadow(this),l.call(this,o,this)}return o.restore(),this}drawHit(t,e,n=!1){if(!this.shouldDrawHit(e,n))return this;const r=this.getLayer(),s=t||r.hitCanvas,a=s&&s.getContext(),o=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),l=h&&h.hit;if(this.colorKey||i.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){a.save();const t=this.getAbsoluteTransform(e).getMatrix();return a.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!o)return this;a.save(),a._applyLineJoin(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();a.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return o.call(this,a,this),a.restore(),this}drawHitFromCache(t=0){const e=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=e.hit,s=r.getContext(),a=r.getWidth(),o=r.getHeight();s.clear(),s.drawImage(n._canvas,0,0,a,o);try{const e=s.getImageData(0,0,a,o),n=e.data,r=n.length,h=i.Util._hexToRgb(this.colorKey);for(let e=0;e<r;e+=4){n[e+3]>t?(n[e]=h.r,n[e+1]=h.g,n[e+2]=h.b,n[e+3]=255):n[e+3]=0}s.putImageData(e,0,0)}catch(t){i.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return o.hasPointerCapture(t,this)}setPointerCapture(t){o.setPointerCapture(t,this)}releaseCapture(t){o.releaseCapture(t,this)}}t.Shape=f,f.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},f.prototype._strokeFunc=function(t){t.stroke()},f.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},f.prototype._strokeFuncHit=function(t){t.stroke()},f.prototype._centroid=!1,f.prototype.nodeType="Shape",(0,a._registerNode)(f),f.prototype.eventListeners={},f.prototype.on.call(f.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(h)})),f.prototype.on.call(f.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(l)})),f.prototype.on.call(f.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(c)})),f.prototype.on.call(f.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(d)})),f.prototype.on.call(f.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(u)})),n.Factory.addGetterSetter(f,"stroke",void 0,(0,s.getStringOrGradientValidator)()),n.Factory.addGetterSetter(f,"strokeWidth",2,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"fillAfterStrokeEnabled",!1),n.Factory.addGetterSetter(f,"hitStrokeWidth","auto",(0,s.getNumberOrAutoValidator)()),n.Factory.addGetterSetter(f,"strokeHitEnabled",!0,(0,s.getBooleanValidator)()),n.Factory.addGetterSetter(f,"perfectDrawEnabled",!0,(0,s.getBooleanValidator)()),n.Factory.addGetterSetter(f,"shadowForStrokeEnabled",!0,(0,s.getBooleanValidator)()),n.Factory.addGetterSetter(f,"lineJoin"),n.Factory.addGetterSetter(f,"lineCap"),n.Factory.addGetterSetter(f,"sceneFunc"),n.Factory.addGetterSetter(f,"hitFunc"),n.Factory.addGetterSetter(f,"dash"),n.Factory.addGetterSetter(f,"dashOffset",0,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"shadowColor",void 0,(0,s.getStringValidator)()),n.Factory.addGetterSetter(f,"shadowBlur",0,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"shadowOpacity",1,(0,s.getNumberValidator)()),n.Factory.addComponentsGetterSetter(f,"shadowOffset",["x","y"]),n.Factory.addGetterSetter(f,"shadowOffsetX",0,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"shadowOffsetY",0,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"fillPatternImage"),n.Factory.addGetterSetter(f,"fill",void 0,(0,s.getStringOrGradientValidator)()),n.Factory.addGetterSetter(f,"fillPatternX",0,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"fillPatternY",0,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"fillLinearGradientColorStops"),n.Factory.addGetterSetter(f,"strokeLinearGradientColorStops"),n.Factory.addGetterSetter(f,"fillRadialGradientStartRadius",0),n.Factory.addGetterSetter(f,"fillRadialGradientEndRadius",0),n.Factory.addGetterSetter(f,"fillRadialGradientColorStops"),n.Factory.addGetterSetter(f,"fillPatternRepeat","repeat"),n.Factory.addGetterSetter(f,"fillEnabled",!0),n.Factory.addGetterSetter(f,"strokeEnabled",!0),n.Factory.addGetterSetter(f,"shadowEnabled",!0),n.Factory.addGetterSetter(f,"dashEnabled",!0),n.Factory.addGetterSetter(f,"strokeScaleEnabled",!0),n.Factory.addGetterSetter(f,"fillPriority","color"),n.Factory.addComponentsGetterSetter(f,"fillPatternOffset",["x","y"]),n.Factory.addGetterSetter(f,"fillPatternOffsetX",0,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"fillPatternOffsetY",0,(0,s.getNumberValidator)()),n.Factory.addComponentsGetterSetter(f,"fillPatternScale",["x","y"]),n.Factory.addGetterSetter(f,"fillPatternScaleX",1,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"fillPatternScaleY",1,(0,s.getNumberValidator)()),n.Factory.addComponentsGetterSetter(f,"fillLinearGradientStartPoint",["x","y"]),n.Factory.addComponentsGetterSetter(f,"strokeLinearGradientStartPoint",["x","y"]),n.Factory.addGetterSetter(f,"fillLinearGradientStartPointX",0),n.Factory.addGetterSetter(f,"strokeLinearGradientStartPointX",0),n.Factory.addGetterSetter(f,"fillLinearGradientStartPointY",0),n.Factory.addGetterSetter(f,"strokeLinearGradientStartPointY",0),n.Factory.addComponentsGetterSetter(f,"fillLinearGradientEndPoint",["x","y"]),n.Factory.addComponentsGetterSetter(f,"strokeLinearGradientEndPoint",["x","y"]),n.Factory.addGetterSetter(f,"fillLinearGradientEndPointX",0),n.Factory.addGetterSetter(f,"strokeLinearGradientEndPointX",0),n.Factory.addGetterSetter(f,"fillLinearGradientEndPointY",0),n.Factory.addGetterSetter(f,"strokeLinearGradientEndPointY",0),n.Factory.addComponentsGetterSetter(f,"fillRadialGradientStartPoint",["x","y"]),n.Factory.addGetterSetter(f,"fillRadialGradientStartPointX",0),n.Factory.addGetterSetter(f,"fillRadialGradientStartPointY",0),n.Factory.addComponentsGetterSetter(f,"fillRadialGradientEndPoint",["x","y"]),n.Factory.addGetterSetter(f,"fillRadialGradientEndPointX",0),n.Factory.addGetterSetter(f,"fillRadialGradientEndPointY",0),n.Factory.addGetterSetter(f,"fillPatternRotation",0),n.Factory.addGetterSetter(f,"fillRule",void 0,(0,s.getStringValidator)()),n.Factory.backCompat(f,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})}(uv)),uv}function mv(){if(cv)return dv;cv=1,Object.defineProperty(dv,"__esModule",{value:!0}),dv.Layer=void 0;const t=Ug(),e=nv(),i=tv(),n=Vg(),r=Kg(),s=Hg(),a=pv(),o=Dg(),h=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],l=h.length;let c=class extends e.Container{constructor(t){super(t),this.canvas=new r.SceneCanvas,this.hitCanvas=new r.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){i.Node.prototype.moveToTop.call(this);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!i.Node.prototype.moveUp.call(this))return!1;const t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(i.Node.prototype.moveDown.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(i.Node.prototype.moveToBottom.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const e=this.getNativeCanvasElement();return i.Node.prototype.remove.call(this),e&&e.parentNode&&t.Util._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(e){const i=e.getType();"Group"!==i&&"Shape"!==i&&t.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t=t||{}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),i.Node.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){t.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){t.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,t.Util.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,i=!1;for(;;){for(let n=0;n<l;n++){const r=h[n],s=this._getIntersection({x:t.x+r.x*e,y:t.y+r.y*e}),a=s.shape;if(a)return a;if(i=!!s.antialiased,!s.antialiased)break}if(!i)return null;e+=1}}_getIntersection(e){const i=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*i),Math.round(e.y*i),1,1).data,r=n[3];if(255===r){const e=t.Util._rgbToHex(n[0],n[1],n[2]),i=a.shapes["#"+e];return i?{shape:i}:{antialiased:!0}}return r>0?{antialiased:!0}:{}}drawScene(t,i){const n=this.getLayer(),r=t||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),e.Container.prototype.drawScene.call(this,r,i),this._fire("draw",{node:this}),this}drawHit(t,i){const n=this.getLayer(),r=t||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),e.Container.prototype.drawHit.call(this,r,i),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return t.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};return dv.Layer=c,c.prototype.nodeType="Layer",(0,o._registerNode)(c),n.Factory.addGetterSetter(c,"imageSmoothingEnabled",!0),n.Factory.addGetterSetter(c,"clearBeforeDraw",!0),n.Factory.addGetterSetter(c,"hitGraphEnabled",!0,(0,s.getBooleanValidator)()),dv}var fv,gv={};var vv,_v={};function yv(){if(vv)return _v;vv=1,Object.defineProperty(_v,"__esModule",{value:!0}),_v.Group=void 0;const t=Ug(),e=nv(),i=Dg();let n=class extends e.Container{_validateAdd(e){const i=e.getType();"Group"!==i&&"Shape"!==i&&t.Util.throw("You may only add groups and shapes to groups.")}};return _v.Group=n,n.prototype.nodeType="Group",(0,i._registerNode)(n),_v}var xv,bv={};function wv(){if(xv)return bv;xv=1,Object.defineProperty(bv,"__esModule",{value:!0}),bv.Animation=void 0;const t=Dg(),e=Ug(),i=t.glob.performance&&t.glob.performance.now?function(){return t.glob.performance.now()}:function(){return(new Date).getTime()};let n=class t{constructor(e,n){this.id=t.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:i(),frameRate:0},this.func=e,this.setLayers(n)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let n=0;n<i;n++)if(e[n]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const e=t.animations,i=e.length;for(let t=0;t<i;t++)if(e[t].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=i(),t._addAnimation(this),this}stop(){return t._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,n=i.length;for(let t=0;t<n;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let n=0;n<e.length;n++){const r=e[n],s=r.layers,a=r.func;r._updateFrameObject(i());const o=s.length;let h;if(h=!a||!1!==a.call(r,r.frame),h)for(let e=0;e<o;e++){const i=s[e];void 0!==i._id&&(t[i._id]=i)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const i=t;i.animations.length?(i._runFrames(),e.Util.requestAnimFrame(i._animationLoop)):i.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,e.Util.requestAnimFrame(this._animationLoop))}};return bv.Animation=n,n.animations=[],n.animIdCounter=0,n.animRunning=!1,bv}var Sv,Mv,Tv={};function Ev(){return Mv||(Mv=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=Dg(),i=Ug(),n=tv(),r=nv(),s=(sv||(sv=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=Ug(),i=Vg(),n=nv(),r=Dg(),s=Kg(),a=$g(),o=Dg(),h=hv(),l="mouseleave",c="mouseover",d="mouseenter",u="mousemove",p="mousedown",m="mouseup",f="pointermove",g="pointerdown",v="pointerup",_="pointercancel",y="pointerout",x="pointerleave",b="pointerover",w="pointerenter",S="contextmenu",M="touchstart",T="touchend",E="touchmove",A="touchcancel",C="wheel",R=[[d,"_pointerenter"],[p,"_pointerdown"],[u,"_pointermove"],[m,"_pointerup"],[l,"_pointerleave"],[M,"_pointerdown"],[E,"_pointermove"],[T,"_pointerup"],[A,"_pointercancel"],[c,"_pointerover"],[C,"_wheel"],[S,"_contextmenu"],[g,"_pointerdown"],[f,"_pointermove"],[v,"_pointerup"],[_,"_pointercancel"],["lostpointercapture","_lostpointercapture"]],P={mouse:{[y]:"mouseout",[x]:l,[b]:c,[w]:d,[f]:u,[g]:p,[v]:m,[_]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[y]:"touchout",[x]:"touchleave",[b]:"touchover",[w]:"touchenter",[f]:E,[g]:M,[v]:T,[_]:A,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[y]:y,[x]:x,[b]:b,[w]:w,[f]:f,[g]:g,[v]:v,[_]:_,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},L=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",I=t=>{const e=L(t);return"pointer"===e?r.Konva.pointerEventsEnabled&&P.pointer:"touch"===e?P.touch:"mouse"===e?P.mouse:void 0};function D(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}t.stages=[];class O extends n.Container{constructor(e){super(D(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),t.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{D(this.attrs)})),this._checkVisibility()}_validateAdd(t){const i="Layer"===t.getType(),n="FastLayer"===t.getType();i||n||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else{var e;e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e)}if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const t=this.children,e=t.length;for(let i=0;i<e;i++)t[i].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),n.Container.prototype.clone.call(this,t)}destroy(){super.destroy();const i=this.content;i&&e.Util._isInDocument(i)&&this.container().removeChild(i);const n=t.stages.indexOf(this);return n>-1&&t.stages.splice(n,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(e.Util.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find((e=>e.id===t))}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t=t||{}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new s.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,n=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),n.forEach((function(e){if(!e.isVisible())return;const n=e._toKonvaCanvas(t);i.drawImage(n._canvas,t.x,t.y,n.getWidth()/n.getPixelRatio(),n.getHeight()/n.getPixelRatio())})),e}getIntersection(t){if(!t)return null;const e=this.children;for(let i=e.length-1;i>=0;i--){const n=e[i].getIntersection(t);if(n)return n}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach((i=>{i.setSize({width:t,height:e}),i.draw()}))}add(t,...i){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const n=this.children.length;return n>5&&e.Util.warn("The stage has "+n+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),r.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return h.hasPointerCapture(t,this)}setPointerCapture(t){h.setPointerCapture(t,this)}releaseCapture(t){h.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){r.Konva.isBrowser&&R.forEach((([t,e])=>{this.content.addEventListener(t,(t=>{this[e](t)}),{passive:!1})}))}_pointerenter(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=I(t.type),i=L(t.type);if(!e)return;this.setPointersPositions(t);const n=this._getTargetShape(i),s=!(r.Konva.isDragging()||r.Konva.isTransforming())||r.Konva.hitOnDragEnabled;n&&s?(n._fireAndBubble(e.pointerout,{evt:t}),n._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):s&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=I(t.type),i=L(t.type);if(!e)return;this.setPointersPositions(t);let n=!1;this._changedPointerPositions.forEach((s=>{const o=this.getIntersection(s);if(a.DD.justDragged=!1,r.Konva["_"+i+"ListenClick"]=!0,!o||!o.isListening())return void(this[i+"ClickStartShape"]=void 0);r.Konva.capturePointerEventsEnabled&&o.setPointerCapture(s.id),this[i+"ClickStartShape"]=o,o._fireAndBubble(e.pointerdown,{evt:t,pointerId:s.id}),n=!0;const h=t.type.indexOf("touch")>=0;o.preventDefault()&&t.cancelable&&h&&t.preventDefault()})),n||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=I(t.type),i=L(t.type);if(!e)return;if(r.Konva.isDragging()&&a.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),(r.Konva.isDragging()||r.Konva.isTransforming())&&!r.Konva.hitOnDragEnabled)return;const n={};let s=!1;const o=this._getTargetShape(i);this._changedPointerPositions.forEach((r=>{const a=h.getCapturedShape(r.id)||this.getIntersection(r),l=r.id,c={evt:t,pointerId:l},d=o!==a;if(d&&o&&(o._fireAndBubble(e.pointerout,{...c},a),o._fireAndBubble(e.pointerleave,{...c},a)),a){if(n[a._id])return;n[a._id]=!0}a&&a.isListening()?(s=!0,d&&(a._fireAndBubble(e.pointerover,{...c},o),a._fireAndBubble(e.pointerenter,{...c},o),this[i+"targetShape"]=a),a._fireAndBubble(e.pointermove,{...c})):o&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:l}),this[i+"targetShape"]=null)})),s||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=I(t.type),i=L(t.type);if(!e)return;this.setPointersPositions(t);const n=this[i+"ClickStartShape"],s=this[i+"ClickEndShape"],o={};let l=!1;this._changedPointerPositions.forEach((c=>{const d=h.getCapturedShape(c.id)||this.getIntersection(c);if(d){if(d.releaseCapture(c.id),o[d._id])return;o[d._id]=!0}const u=c.id,p={evt:t,pointerId:u};let m=!1;r.Konva["_"+i+"InDblClickWindow"]?(m=!0,clearTimeout(this[i+"DblTimeout"])):a.DD.justDragged||(r.Konva["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout((function(){r.Konva["_"+i+"InDblClickWindow"]=!1}),r.Konva.dblClickWindow),d&&d.isListening()?(l=!0,this[i+"ClickEndShape"]=d,d._fireAndBubble(e.pointerup,{...p}),r.Konva["_"+i+"ListenClick"]&&n&&n===d&&(d._fireAndBubble(e.pointerclick,{...p}),m&&s&&s===d&&d._fireAndBubble(e.pointerdblclick,{...p}))):(this[i+"ClickEndShape"]=null,r.Konva["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:u}),m&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:u}))})),l||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),r.Konva["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&"pointer"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(S,{evt:t}):this._fire(S,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(C,{evt:t}):this._fire(C,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=h.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(v,h.createEvent(t)),h.releaseCapture(t.pointerId)}_lostpointercapture(t){h.releaseCapture(t.pointerId)}setPointersPositions(t){const i=this._getContentPosition();let n=null,r=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,(t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})})),Array.prototype.forEach.call(t.changedTouches||t.touches,(t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})}))):(n=(t.clientX-i.left)/i.scaleX,r=(t.clientY-i.top)/i.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:e.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:n,y:r,id:e.Util._getFirstPointerId(t)}])}_setPointerPosition(t){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new s.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new s.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!r.Konva.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}cache(){return e.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach((function(t){t.batchDraw()})),this}}t.Stage=O,O.prototype.nodeType="Stage",(0,o._registerNode)(O),i.Factory.addGetterSetter(O,"container"),r.Konva.isBrowser&&document.addEventListener("visibilitychange",(()=>{t.stages.forEach((t=>{t.batchDraw()}))}))}(av)),av),a=mv(),o=function(){if(fv)return gv;fv=1,Object.defineProperty(gv,"__esModule",{value:!0}),gv.FastLayer=void 0;const t=Ug(),e=mv(),i=Dg();let n=class extends e.Layer{constructor(e){super(e),this.listening(!1),t.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};return gv.FastLayer=n,n.prototype.nodeType="FastLayer",(0,i._registerNode)(n),gv}(),h=yv(),l=$g(),c=pv(),d=wv(),u=(Sv||(Sv=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=Ug(),i=wv(),n=tv(),r=Dg(),s={node:1,duration:1,easing:1,onFinish:1,yoyo:1},a=["fill","stroke","shadowColor"];let o=0;class h{constructor(t,e,i,n,r,s,a){this.prop=t,this.propFunc=e,this.begin=n,this._pos=n,this.duration=s,this._change=0,this.prevPos=0,this.yoyo=a,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=r-this.begin,this.pause()}fire(t){const e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class l{constructor(n){const a=this,c=n.node,d=c._id,u=n.easing||t.Easings.Linear,p=!!n.yoyo;let m,f;m=void 0===n.duration?.3:0===n.duration?.001:n.duration,this.node=c,this._id=o++;const g=c.getLayer()||(c instanceof r.Konva.Stage?c.getLayers():null);for(f in g||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new i.Animation((function(){a.tween.onEnterFrame()}),g),this.tween=new h(f,(function(t){a._tweenFunc(t)}),u,0,1,1e3*m,p),this._addListeners(),l.attrs[d]||(l.attrs[d]={}),l.attrs[d][this._id]||(l.attrs[d][this._id]={}),l.tweens[d]||(l.tweens[d]={}),n)void 0===s[f]&&this._addAttr(f,n[f]);this.reset(),this.onFinish=n.onFinish,this.onReset=n.onReset,this.onUpdate=n.onUpdate}_addAttr(t,i){const n=this.node,r=n._id;let s,o,h,c,d;const u=l.tweens[r][t];u&&delete l.attrs[r][u][t];let p=n.getAttr(t);if(e.Util._isArray(i))if(s=[],o=Math.max(i.length,p.length),"points"===t&&i.length!==p.length&&(i.length>p.length?(c=p,p=e.Util._prepareArrayForTween(p,i,n.closed())):(h=i,i=e.Util._prepareArrayForTween(i,p,n.closed()))),0===t.indexOf("fill"))for(let t=0;t<o;t++)if(t%2==0)s.push(i[t]-p[t]);else{const n=e.Util.colorToRGBA(p[t]);d=e.Util.colorToRGBA(i[t]),p[t]=n,s.push({r:d.r-n.r,g:d.g-n.g,b:d.b-n.b,a:d.a-n.a})}else for(let t=0;t<o;t++)s.push(i[t]-p[t]);else-1!==a.indexOf(t)?(p=e.Util.colorToRGBA(p),d=e.Util.colorToRGBA(i),s={r:d.r-p.r,g:d.g-p.g,b:d.b-p.b,a:d.a-p.a}):s=i-p;l.attrs[r][this._id][t]={start:p,diff:s,end:i,trueEnd:h,trueStart:c},l.tweens[r][t]=this._id}_tweenFunc(t){const i=this.node,n=l.attrs[i._id][this._id];let r,s,o,h,c,d,u,p;for(r in n){if(s=n[r],o=s.start,h=s.diff,p=s.end,e.Util._isArray(o))if(c=[],u=Math.max(o.length,p.length),0===r.indexOf("fill"))for(d=0;d<u;d++)d%2==0?c.push((o[d]||0)+h[d]*t):c.push("rgba("+Math.round(o[d].r+h[d].r*t)+","+Math.round(o[d].g+h[d].g*t)+","+Math.round(o[d].b+h[d].b*t)+","+(o[d].a+h[d].a*t)+")");else for(d=0;d<u;d++)c.push((o[d]||0)+h[d]*t);else c=-1!==a.indexOf(r)?"rgba("+Math.round(o.r+h.r*t)+","+Math.round(o.g+h.g*t)+","+Math.round(o.b+h.b*t)+","+(o.a+h.a*t)+")":o+h*t;i.setAttr(r,c)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=l.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=l.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,e=this._id,i=l.tweens[t];this.pause();for(const e in i)delete l.tweens[t][e];delete l.attrs[t][e]}}t.Tween=l,l.attrs={},l.tweens={},n.Node.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new l(t).play()},t.Easings={BackEaseIn(t,e,i,n){const r=1.70158;return i*(t/=n)*t*((r+1)*t-r)+e},BackEaseOut(t,e,i,n){const r=1.70158;return i*((t=t/n-1)*t*((r+1)*t+r)+1)+e},BackEaseInOut(t,e,i,n){let r=1.70158;return(t/=n/2)<1?i/2*(t*t*((1+(r*=1.525))*t-r))+e:i/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},ElasticEaseIn(t,e,i,n,r,s){let a=0;return 0===t?e:1==(t/=n)?e+i:(s||(s=.3*n),!r||r<Math.abs(i)?(r=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/r),-r*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/s)+e)},ElasticEaseOut(t,e,i,n,r,s){let a=0;return 0===t?e:1==(t/=n)?e+i:(s||(s=.3*n),!r||r<Math.abs(i)?(r=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/r),r*Math.pow(2,-10*t)*Math.sin((t*n-a)*(2*Math.PI)/s)+i+e)},ElasticEaseInOut(t,e,i,n,r,s){let a=0;return 0===t?e:2==(t/=n/2)?e+i:(s||(s=n*(.3*1.5)),!r||r<Math.abs(i)?(r=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/r),t<1?r*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/s)*-.5+e:r*Math.pow(2,-10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/s)*.5+i+e)},BounceEaseOut:(t,e,i,n)=>(t/=n)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(e,i,n,r)=>n-t.Easings.BounceEaseOut(r-e,0,n,r)+i,BounceEaseInOut:(e,i,n,r)=>e<r/2?.5*t.Easings.BounceEaseIn(2*e,0,n,r)+i:.5*t.Easings.BounceEaseOut(2*e-r,0,n,r)+.5*n+i,EaseIn:(t,e,i,n)=>i*(t/=n)*t+e,EaseOut:(t,e,i,n)=>-i*(t/=n)*(t-2)+e,EaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,n)=>i*(t/=n)*t*t*t*t+e,StrongEaseOut:(t,e,i,n)=>i*((t=t/n-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,n)=>i*t/n+e}}(Tv)),Tv),p=qg(),m=Kg();t.Konva=i.Util._assign(e.Konva,{Util:i.Util,Transform:i.Transform,Node:n.Node,Container:r.Container,Stage:s.Stage,stages:s.stages,Layer:a.Layer,FastLayer:o.FastLayer,Group:h.Group,DD:l.DD,Shape:c.Shape,shapes:c.shapes,Animation:d.Animation,Tween:u.Tween,Easings:u.Easings,Context:p.Context,Canvas:m.Canvas}),t.default=t.Konva}(Lg)),Lg}var Av,Cv={};var Rv,Pv={},Lv={};function Iv(){if(Rv)return Lv;Rv=1,Object.defineProperty(Lv,"__esModule",{value:!0}),Lv.Line=void 0;const t=Vg(),e=Dg(),i=pv(),n=Hg();function r(t,e,i,n,r,s,a){const o=Math.sqrt(Math.pow(i-t,2)+Math.pow(n-e,2)),h=Math.sqrt(Math.pow(r-i,2)+Math.pow(s-n,2)),l=a*o/(o+h),c=a*h/(o+h);return[i-l*(r-t),n-l*(s-e),i+c*(r-t),n+c*(s-e)]}function s(t,e){const i=t.length,n=[];for(let s=2;s<i-2;s+=2){const i=r(t[s-2],t[s-1],t[s],t[s+1],t[s+2],t[s+3],e);isNaN(i[0])||(n.push(i[0]),n.push(i[1]),n.push(t[s]),n.push(t[s+1]),n.push(i[2]),n.push(i[3]))}return n}let a=class extends i.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(t){let e,i,n,r=this.points(),s=r.length,a=this.tension(),o=this.closed(),h=this.bezier();if(s){if(t.beginPath(),t.moveTo(r[0],r[1]),0!==a&&s>4){for(e=this.getTensionPoints(),i=e.length,n=o?0:4,o||t.quadraticCurveTo(e[0],e[1],e[2],e[3]);n<i-2;)t.bezierCurveTo(e[n++],e[n++],e[n++],e[n++],e[n++],e[n++]);o||t.quadraticCurveTo(e[i-2],e[i-1],r[s-2],r[s-1])}else if(h)for(n=2;n<s;)t.bezierCurveTo(r[n++],r[n++],r[n++],r[n++],r[n++],r[n++]);else for(n=2;n<s;n+=2)t.lineTo(r[n],r[n+1]);o?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():s(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,i=this.tension(),n=r(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),a=r(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),o=s(t,i);return[n[2],n[3]].concat(o).concat([a[0],a[1],t[e-2],t[e-1],a[2],a[3],n[0],n[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points();let e,i,n=t[0],r=t[0],s=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),r=Math.max(r,e),s=Math.min(s,i),a=Math.max(a,i);return{x:n,y:s,width:r-n,height:a-s}}};return Lv.Line=a,a.prototype.className="Line",a.prototype._attrsAffectingSize=["points","bezier","tension"],(0,e._registerNode)(a),t.Factory.addGetterSetter(a,"closed",!1),t.Factory.addGetterSetter(a,"bezier",!1),t.Factory.addGetterSetter(a,"tension",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(a,"points",[],(0,n.getNumberArrayValidator)()),Lv}var Dv,Ov,Nv,Uv={},Fv={};function kv(){if(Ov)return Uv;Ov=1,Object.defineProperty(Uv,"__esModule",{value:!0}),Uv.Path=void 0;const t=Vg(),e=pv(),i=Dg(),n=(Dv||(Dv=1,function(t){function e(t,e,n){const r=i(1,n,t),s=i(1,n,e),a=r*r+s*s;return Math.sqrt(a)}Object.defineProperty(t,"__esModule",{value:!0}),t.t2length=t.getQuadraticArcLength=t.getCubicArcLength=t.binomialCoefficients=t.cValues=t.tValues=void 0,t.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],t.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],t.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]],t.getCubicArcLength=(i,n,r)=>{let s,a;const o=r/2;s=0;for(let r=0;r<20;r++)a=o*t.tValues[20][r]+o,s+=t.cValues[20][r]*e(i,n,a);return o*s},t.getQuadraticArcLength=(t,e,i)=>{void 0===i&&(i=1);const n=t[0]-2*t[1]+t[2],r=e[0]-2*e[1]+e[2],s=2*t[1]-2*t[0],a=2*e[1]-2*e[0],o=4*(n*n+r*r),h=4*(n*s+r*a),l=s*s+a*a;if(0===o)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const c=h/(2*o),d=i+c,u=l/o-c*c,p=d*d+u>0?Math.sqrt(d*d+u):0,m=c*c+u>0?Math.sqrt(c*c+u):0,f=c+Math.sqrt(c*c+u)!==0?u*Math.log(Math.abs((d+p)/(c+m))):0;return Math.sqrt(o)/2*(d*p-c*m+f)};const i=(e,n,r)=>{const s=r.length-1;let a,o;if(0===s)return 0;if(0===e){o=0;for(let e=0;e<=s;e++)o+=t.binomialCoefficients[s][e]*Math.pow(1-n,s-e)*Math.pow(n,e)*r[e];return o}a=new Array(s);for(let t=0;t<s;t++)a[t]=s*(r[t+1]-r[t]);return i(e-1,n,a)};t.t2length=(t,e,i)=>{let n=1,r=t/e,s=(t-i(r))/e,a=0;for(;n>.001;){const o=i(r+s),h=Math.abs(t-o)/e;if(h<n)n=h,r+=s;else{const a=i(r-s),o=Math.abs(t-a)/e;o<n?(n=o,r-=s):s/=2}if(a++,a>500)break}return r}}(Fv)),Fv);let r=class t extends e.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute()}))}_readDataAttribute(){this.dataArray=t.parsePathData(this.data()),this.pathLength=t.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let m=0;m<e.length;m++){const f=e[m].command,g=e[m].points;switch(f){case"L":t.lineTo(g[0],g[1]);break;case"M":t.moveTo(g[0],g[1]);break;case"C":t.bezierCurveTo(g[0],g[1],g[2],g[3],g[4],g[5]);break;case"Q":t.quadraticCurveTo(g[0],g[1],g[2],g[3]);break;case"A":var n=g[0],r=g[1],s=g[2],a=g[3],o=g[4],h=g[5],l=g[6],c=g[7],d=s>a?s:a,u=s>a?1:s/a,p=s>a?a/s:1;t.translate(n,r),t.rotate(l),t.scale(u,p),t.arc(0,0,d,o,o+h,1-c),t.scale(1/u,1/p),t.rotate(-l),t.translate(-n,-r);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let e=[];this.dataArray.forEach((function(i){if("A"===i.command){const n=i.points[4],r=i.points[5],s=i.points[4]+r;let a=Math.PI/180;if(Math.abs(n-s)<a&&(a=Math.abs(n-s)),r<0)for(let r=n-a;r>s;r-=a){const n=t.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],r,0);e.push(n.x,n.y)}else for(let r=n+a;r<s;r+=a){const n=t.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],r,0);e.push(n.x,n.y)}}else if("C"===i.command)for(let n=0;n<=1;n+=.01){const r=t.getPointOnCubicBezier(n,i.start.x,i.start.y,i.points[0],i.points[1],i.points[2],i.points[3],i.points[4],i.points[5]);e.push(r.x,r.y)}else e=e.concat(i.points)}));let i,n,r=e[0],s=e[0],a=e[1],o=e[1];for(let t=0;t<e.length/2;t++)i=e[2*t],n=e[2*t+1],isNaN(i)||(r=Math.min(r,i),s=Math.max(s,i)),isNaN(n)||(a=Math.min(a,n),o=Math.max(o,n));return{x:r,y:a,width:s-r,height:o-a}}getLength(){return this.pathLength}getPointAtLength(e){return t.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(t,e,i,n){return Math.sqrt((i-t)*(i-t)+(n-e)*(n-e))}static getPathLength(t){let e=0;for(let i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(e,i){let r,s=0,a=i.length;if(!a)return null;for(;s<a&&e>i[s].pathLength;)e-=i[s].pathLength,++s;if(s===a)return r=i[s-1].points.slice(-2),{x:r[0],y:r[1]};if(e<.01)return r=i[s].points.slice(0,2),{x:r[0],y:r[1]};const o=i[s],h=o.points;switch(o.command){case"L":return t.getPointOnLine(e,o.start.x,o.start.y,h[0],h[1]);case"C":return t.getPointOnCubicBezier((0,n.t2length)(e,t.getPathLength(i),(t=>(0,n.getCubicArcLength)([o.start.x,h[0],h[2],h[4]],[o.start.y,h[1],h[3],h[5]],t))),o.start.x,o.start.y,h[0],h[1],h[2],h[3],h[4],h[5]);case"Q":return t.getPointOnQuadraticBezier((0,n.t2length)(e,t.getPathLength(i),(t=>(0,n.getQuadraticArcLength)([o.start.x,h[0],h[2]],[o.start.y,h[1],h[3]],t))),o.start.x,o.start.y,h[0],h[1],h[2],h[3]);case"A":var l=h[0],c=h[1],d=h[2],u=h[3],p=h[4],m=h[5],f=h[6];return p+=m*e/o.pathLength,t.getPointOnEllipticalArc(l,c,d,u,p,f)}return null}static getPointOnLine(t,e,i,n,r,s,a){s=null!=s?s:e,a=null!=a?a:i;const o=this.getLineLength(e,i,n,r);if(o<1e-10)return{x:e,y:i};if(n===e)return{x:s,y:a+(r>i?t:-t)};const h=(r-i)/(n-e),l=Math.sqrt(t*t/(1+h*h))*(n<e?-1:1),c=h*l;if(Math.abs(a-i-h*(s-e))<1e-10)return{x:s+l,y:a+c};const d=((s-e)*(n-e)+(a-i)*(r-i))/(o*o),u=e+d*(n-e),p=i+d*(r-i),m=this.getLineLength(s,a,u,p),f=Math.sqrt(t*t-m*m),g=Math.sqrt(f*f/(1+h*h))*(n<e?-1:1);return{x:u+g,y:p+h*g}}static getPointOnCubicBezier(t,e,i,n,r,s,a,o,h){function l(t){return t*t*t}function c(t){return 3*t*t*(1-t)}function d(t){return 3*t*(1-t)*(1-t)}function u(t){return(1-t)*(1-t)*(1-t)}return{x:o*l(t)+s*c(t)+n*d(t)+e*u(t),y:h*l(t)+a*c(t)+r*d(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,n,r,s,a){function o(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:s*o(t)+n*h(t)+e*l(t),y:a*o(t)+r*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,n,r,s){const a=Math.cos(s),o=Math.sin(s),h=i*Math.cos(r),l=n*Math.sin(r);return{x:t+(h*a-l*o),y:e+(h*o+l*a)}}static parsePathData(t){if(!t)return[];let e=t;const i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(var n=0;n<i.length;n++)e=e.replace(new RegExp(i[n],"g"),"|"+i[n]);const r=e.split("|"),s=[],a=[];let o=0,h=0;const l=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let c;for(n=1;n<r.length;n++){let t=r[n],e=t.charAt(0);for(t=t.slice(1),a.length=0;c=l.exec(t);)a.push(c[0]);const i=[];for(let t=0,e=a.length;t<e;t++){if("00"===a[t]){i.push(0,0);continue}const e=parseFloat(a[t]);isNaN(e)?i.push(0):i.push(e)}for(;i.length>0&&!isNaN(i[0]);){let t="",n=[];const r=o,a=h;var d,u,p,m,f,g,v,_,y,x;switch(e){case"l":o+=i.shift(),h+=i.shift(),t="L",n.push(o,h);break;case"L":o=i.shift(),h=i.shift(),n.push(o,h);break;case"m":var b=i.shift(),w=i.shift();if(o+=b,h+=w,t="M",s.length>2&&"z"===s[s.length-1].command)for(let t=s.length-2;t>=0;t--)if("M"===s[t].command){o=s[t].points[0]+b,h=s[t].points[1]+w;break}n.push(o,h),e="l";break;case"M":o=i.shift(),h=i.shift(),t="M",n.push(o,h),e="L";break;case"h":o+=i.shift(),t="L",n.push(o,h);break;case"H":o=i.shift(),t="L",n.push(o,h);break;case"v":h+=i.shift(),t="L",n.push(o,h);break;case"V":h=i.shift(),t="L",n.push(o,h);break;case"C":n.push(i.shift(),i.shift(),i.shift(),i.shift()),o=i.shift(),h=i.shift(),n.push(o,h);break;case"c":n.push(o+i.shift(),h+i.shift(),o+i.shift(),h+i.shift()),o+=i.shift(),h+=i.shift(),t="C",n.push(o,h);break;case"S":u=o,p=h,"C"===(d=s[s.length-1]).command&&(u=o+(o-d.points[2]),p=h+(h-d.points[3])),n.push(u,p,i.shift(),i.shift()),o=i.shift(),h=i.shift(),t="C",n.push(o,h);break;case"s":u=o,p=h,"C"===(d=s[s.length-1]).command&&(u=o+(o-d.points[2]),p=h+(h-d.points[3])),n.push(u,p,o+i.shift(),h+i.shift()),o+=i.shift(),h+=i.shift(),t="C",n.push(o,h);break;case"Q":n.push(i.shift(),i.shift()),o=i.shift(),h=i.shift(),n.push(o,h);break;case"q":n.push(o+i.shift(),h+i.shift()),o+=i.shift(),h+=i.shift(),t="Q",n.push(o,h);break;case"T":u=o,p=h,"Q"===(d=s[s.length-1]).command&&(u=o+(o-d.points[0]),p=h+(h-d.points[1])),o=i.shift(),h=i.shift(),t="Q",n.push(u,p,o,h);break;case"t":u=o,p=h,"Q"===(d=s[s.length-1]).command&&(u=o+(o-d.points[0]),p=h+(h-d.points[1])),o+=i.shift(),h+=i.shift(),t="Q",n.push(u,p,o,h);break;case"A":m=i.shift(),f=i.shift(),g=i.shift(),v=i.shift(),_=i.shift(),y=o,x=h,o=i.shift(),h=i.shift(),t="A",n=this.convertEndpointToCenterParameterization(y,x,o,h,v,_,m,f,g);break;case"a":m=i.shift(),f=i.shift(),g=i.shift(),v=i.shift(),_=i.shift(),y=o,x=h,o+=i.shift(),h+=i.shift(),t="A",n=this.convertEndpointToCenterParameterization(y,x,o,h,v,_,m,f,g)}s.push({command:t||e,points:n,start:{x:r,y:a},pathLength:this.calcLength(r,a,t||e,n)})}"z"!==e&&"Z"!==e||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(e,i,r,s){let a,o,h,l;const c=t;switch(r){case"L":return c.getLineLength(e,i,s[0],s[1]);case"C":return(0,n.getCubicArcLength)([e,s[0],s[2],s[4]],[i,s[1],s[3],s[5]],1);case"Q":return(0,n.getQuadraticArcLength)([e,s[0],s[2]],[i,s[1],s[3]],1);case"A":a=0;var d=s[4],u=s[5],p=s[4]+u,m=Math.PI/180;if(Math.abs(d-p)<m&&(m=Math.abs(d-p)),o=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],d,0),u<0)for(l=d-m;l>p;l-=m)h=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],l,0),a+=c.getLineLength(o.x,o.y,h.x,h.y),o=h;else for(l=d+m;l<p;l+=m)h=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],l,0),a+=c.getLineLength(o.x,o.y,h.x,h.y),o=h;return h=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],p,0),a+=c.getLineLength(o.x,o.y,h.x,h.y),a}return 0}static convertEndpointToCenterParameterization(t,e,i,n,r,s,a,o,h){const l=h*(Math.PI/180),c=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-n)/2,d=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-n)/2,u=c*c/(a*a)+d*d/(o*o);u>1&&(a*=Math.sqrt(u),o*=Math.sqrt(u));let p=Math.sqrt((a*a*(o*o)-a*a*(d*d)-o*o*(c*c))/(a*a*(d*d)+o*o*(c*c)));r===s&&(p*=-1),isNaN(p)&&(p=0);const m=p*a*d/o,f=p*-o*c/a,g=(t+i)/2+Math.cos(l)*m-Math.sin(l)*f,v=(e+n)/2+Math.sin(l)*m+Math.cos(l)*f,_=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},y=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(_(t)*_(e))},x=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y(t,e))},b=x([1,0],[(c-m)/a,(d-f)/o]),w=[(c-m)/a,(d-f)/o],S=[(-1*c-m)/a,(-1*d-f)/o];let M=x(w,S);return y(w,S)<=-1&&(M=Math.PI),y(w,S)>=1&&(M=0),0===s&&M>0&&(M-=2*Math.PI),1===s&&M<0&&(M+=2*Math.PI),[g,v,a,o,b,M,l,s]}};return Uv.Path=r,r.prototype.className="Path",r.prototype._attrsAffectingSize=["data"],(0,i._registerNode)(r),t.Factory.addGetterSetter(r,"data"),Uv}var Bv,zv={};var Gv,Hv={};var Vv,Wv={};var jv,Xv={};var Yv,qv={};function Kv(){if(Yv)return qv;Yv=1,Object.defineProperty(qv,"__esModule",{value:!0}),qv.Rect=void 0;const t=Vg(),e=pv(),i=Dg(),n=Ug(),r=Hg();let s=class extends e.Shape{_sceneFunc(t){const e=this.cornerRadius(),i=this.width(),r=this.height();t.beginPath(),e?n.Util.drawRoundedRectPath(t,i,r,e):t.rect(0,0,i,r),t.closePath(),t.fillStrokeShape(this)}};return qv.Rect=s,s.prototype.className="Rect",(0,i._registerNode)(s),t.Factory.addGetterSetter(s,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),qv}var Zv,Jv={};var Qv,$v={};var t_,e_={};var i_,n_={};var r_,s_={};function a_(){if(r_)return s_;r_=1,Object.defineProperty(s_,"__esModule",{value:!0}),s_.Text=void 0,s_.stringToArray=a;const t=Ug(),e=Vg(),i=pv(),n=Dg(),r=Hg(),s=Dg();function a(t){return[...t].reduce(((t,e,i,n)=>{if(/\p{Emoji}/u.test(e)){const r=n[i+1];r&&/\p{Emoji_Modifier}|\u200D/u.test(r)?(t.push(e+r),n[i+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(n[i+1]||""))?t.push(e+n[i+1]):i>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:e&&t.push(e);return t}),[])}const o="auto",h="inherit",l="justify",c="left",d="middle",u="normal",p=" ",m="none",f=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],g=f.length;let v;function _(){return v||(v=t.Util.createCanvasElement().getContext("2d"),v)}let y=class extends i.Shape{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<g;t++)this.on(f[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){const e=this.textArr,i=e.length;if(!this.text())return;let r,s=this.padding(),o=this.fontSize(),u=this.lineHeight()*o,p=this.verticalAlign(),m=this.direction(),f=0,g=this.align(),v=this.getWidth(),_=this.letterSpacing(),y=this.fill(),x=this.textDecoration(),b=-1!==x.indexOf("underline"),w=-1!==x.indexOf("line-through");m=m===h?t.direction:m;let S=u/2,M=d;if(n.Konva._fixTextRendering){const t=this.measureSize("M");M="alphabetic",S=(t.fontBoundingBoxAscent-t.fontBoundingBoxDescent)/2+u/2}var T=0,E=0;for("rtl"===m&&t.setAttr("direction",m),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",M),t.setAttr("textAlign",c),p===d?f=(this.getHeight()-i*u-2*s)/2:"bottom"===p&&(f=this.getHeight()-i*u-2*s),t.translate(s,f+s),r=0;r<i;r++){T=0,E=0;var A,C,R=e[r],P=R.text,L=R.width,I=R.lastInParagraph;if(t.save(),"right"===g?T+=v-L-2*s:"center"===g&&(T+=(v-L-2*s)/2),b){t.save(),t.beginPath();const e=T,i=S+E+(n.Konva._fixTextRendering?Math.round(o/4):Math.round(o/2));t.moveTo(e,i),A=P.split(" ").length-1,C=g!==l||I?L:v-2*s,t.lineTo(e+Math.round(C),i),t.lineWidth=o/15;const r=this._getLinearGradient();t.strokeStyle=r||y,t.stroke(),t.restore()}if(w){t.save(),t.beginPath();const e=n.Konva._fixTextRendering?-Math.round(o/4):0;t.moveTo(T,S+E+e),A=P.split(" ").length-1,C=g!==l||I?L:v-2*s,t.lineTo(T+Math.round(C),S+E+e),t.lineWidth=o/15;const i=this._getLinearGradient();t.strokeStyle=i||y,t.stroke(),t.restore()}if("rtl"===m||0===_&&g!==l)0!==_&&t.setAttr("letterSpacing",`${_}px`),this._partialTextX=T,this._partialTextY=S+E,this._partialText=P,t.fillStrokeShape(this);else{A=P.split(" ").length-1;const e=a(P);for(let i=0;i<e.length;i++){const n=e[i];" "!==n||I||g!==l||(T+=(v-2*s-L)/A),this._partialTextX=T,this._partialTextY=S+E,this._partialText=n,t.fillStrokeShape(this),T+=this.measureSize(n).width+_}}t.restore(),i>1&&(S+=u)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(e){const i=t.Util._isString(e)?e:null==e?"":e+"";return this._setAttr("text",i),this}getWidth(){return this.attrs.width===o||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===o||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,n,r,s,a,o,h,l,c,d;let u,p=_(),m=this.fontSize();p.save(),p.font=this._getContextFont(),u=p.measureText(t),p.restore();const f=m/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*f,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(n=u.actualBoundingBoxLeft)&&void 0!==n?n:-7.421875*f,actualBoundingBoxRight:null!==(r=u.actualBoundingBoxRight)&&void 0!==r?r:75.732421875*f,alphabeticBaseline:null!==(s=u.alphabeticBaseline)&&void 0!==s?s:0,emHeightAscent:null!==(a=u.emHeightAscent)&&void 0!==a?a:100*f,emHeightDescent:null!==(o=u.emHeightDescent)&&void 0!==o?o:-20*f,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*f,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*f,hangingBaseline:null!==(c=u.hangingBaseline)&&void 0!==c?c:72.80000305175781*f,ideographicBaseline:null!==(d=u.ideographicBaseline)&&void 0!==d?d:-21*f,width:u.width,height:m}}_getContextFont(){return this.fontStyle()+p+this.fontVariant()+p+(this.fontSize()+"px ")+this.fontFamily().split(",").map((t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t})).join(", ")}_addTextLine(t){this.align()===l&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),i=t.length;return _().measureText(t).width+e*i}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,n=this.lineHeight()*e,r=this.attrs.width,s=this.attrs.height,h=r!==o&&void 0!==r,l=s!==o&&void 0!==s,c=this.padding(),d=r-2*c,u=s-2*c,f=0,g=this.wrap(),v="char"!==g&&g!==m,y=this.ellipsis();this.textArr=[],_().font=this._getContextFont();const x=y?this._getTextWidth("…"):0;for(let e=0,r=t.length;e<r;++e){let s=t[e],o=this._getTextWidth(s);if(h&&o>d)for(;s.length>0;){let t=0,e=a(s).length,r="",h=0;for(;t<e;){const i=t+e>>>1,n=a(s).slice(0,i+1).join(""),o=this._getTextWidth(n)+x;o<=d?(t=i+1,r=n,h=o):e=i}if(!r)break;if(v){const e=a(s),i=a(r),n=e[i.length];let o;if((n===p||"-"===n)&&h<=d)o=i.length;else{const t=i.lastIndexOf(p),e=i.lastIndexOf("-");o=Math.max(t,e)+1}o>0&&(t=o,r=e.slice(0,t).join(""),h=this._getTextWidth(r))}r=r.trimRight(),this._addTextLine(r),i=Math.max(i,h),f+=n;if(this._shouldHandleEllipsis(f)){this._tryToAddEllipsisToLastLine();break}if(s=a(s).slice(t).join("").trimLeft(),s.length>0&&(o=this._getTextWidth(s),o<=d)){this._addTextLine(s),f+=n,i=Math.max(i,o);break}}else this._addTextLine(s),f+=n,i=Math.max(i,o),this._shouldHandleEllipsis(f)&&e<r-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),l&&f+n>u)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,n=this.attrs.height,r=n!==o&&void 0!==n,s=n-2*this.padding();return!(this.wrap()!==m)||r&&t+i>s}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==o&&void 0!==t,i=t-2*this.padding(),n=this.ellipsis(),r=this.textArr[this.textArr.length-1];if(r&&n){if(e){this._getTextWidth(r.text+"…")<i||(r.text=r.text.slice(0,r.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(r.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}};return s_.Text=y,y.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},y.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},y.prototype.className="Text",y.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,s._registerNode)(y),e.Factory.overWriteSetter(y,"width",(0,r.getNumberOrAutoValidator)()),e.Factory.overWriteSetter(y,"height",(0,r.getNumberOrAutoValidator)()),e.Factory.addGetterSetter(y,"direction",h),e.Factory.addGetterSetter(y,"fontFamily","Arial"),e.Factory.addGetterSetter(y,"fontSize",12,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"fontStyle",u),e.Factory.addGetterSetter(y,"fontVariant",u),e.Factory.addGetterSetter(y,"padding",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"align",c),e.Factory.addGetterSetter(y,"verticalAlign","top"),e.Factory.addGetterSetter(y,"lineHeight",1,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"wrap","word"),e.Factory.addGetterSetter(y,"ellipsis",!1,(0,r.getBooleanValidator)()),e.Factory.addGetterSetter(y,"letterSpacing",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"text","",(0,r.getStringValidator)()),e.Factory.addGetterSetter(y,"textDecoration",""),s_}var o_,h_={};var l_,c_={};function d_(){if(l_)return c_;l_=1,Object.defineProperty(c_,"__esModule",{value:!0}),c_.Transformer=void 0;const t=Ug(),e=Vg(),i=tv(),n=pv(),r=Kv(),s=yv(),a=Dg(),o=Hg(),h=Dg(),l="tr-konva",c=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((t=>t+`.${l}`)).join(" "),d="nodesRect",u=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],p={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},m="ontouchstart"in a.Konva._global;const f=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function g(t,e,i){const n=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),r=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:n,y:r}}function v(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return g(t,e,i)}let _=0,y=class extends s.Group{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(c,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(e){return t.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return l+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const i=e.filter((e=>!e.isAncestorOf(this)||(t.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));this._nodes=e=i,1===e.length&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()},i=t._attrsAffectingSize.map((t=>t+"Change."+this._getEventNamespace())).join(" ");t.on(i,e),t.on(u.map((t=>t+`.${this._getEventNamespace()}`)).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)})),this._resetTransformCache();return!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,(i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)})),t.on(`dragmove.${this._getEventNamespace()}`,(i=>{if(!e)return;const n=t.getAbsolutePosition(),r=n.x-e.x,s=n.y-e.y;this.nodes().forEach((e=>{if(e===t)return;if(e.isDragging())return;const n=e.getAbsolutePosition();e.setAbsolutePosition({x:n.x+r,y:n.y+s}),e.startDrag(i)})),e=null}))}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach((t=>{t.off("."+this._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(d),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(d,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){const n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=t.getAbsoluteScale(i),s=t.getAbsolutePosition(i),o=n.x*r.x-t.offsetX()*r.x,h=n.y*r.y-t.offsetY()*r.y,l=(a.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return g({x:s.x+o*Math.cos(l)+h*Math.sin(-l),y:s.y+h*Math.cos(l)+o*Math.sin(l),width:n.width*r.x,height:n.height*r.y,rotation:l},-a.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map((t=>{const i=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),n=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],r=t.getAbsoluteTransform();n.forEach((function(t){const i=r.point(t);e.push(i)}))}));const i=new t.Transform;i.rotate(-a.Konva.getAngle(this.rotation()));let n=1/0,r=1/0,s=-1/0,o=-1/0;e.forEach((function(t){const e=i.point(t);void 0===n&&(n=s=e.x,r=o=e.y),n=Math.min(n,e.x),r=Math.min(r,e.y),s=Math.max(s,e.x),o=Math.max(o,e.y)})),i.invert();const h=i.point({x:n,y:r});return{x:h.x,y:h.y,width:s-n,height:o-r,rotation:a.Konva.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),f.forEach((t=>{this._createAnchor(t)})),this._createAnchor("rotater")}_createAnchor(e){const i=new r.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:m?10:"auto"}),n=this;i.on("mousedown touchstart",(function(t){n._handleMouseDown(t)})),i.on("dragstart",(t=>{i.stopDrag(),t.cancelBubble=!0})),i.on("dragend",(t=>{t.cancelBubble=!0})),i.on("mouseenter",(()=>{const n=a.Konva.getAngle(this.rotation()),r=this.rotateAnchorCursor(),s=function(e,i,n){if("rotater"===e)return n;i+=t.Util.degToRad(p[e]||0);const r=(t.Util.radToDeg(i)%360+360)%360;return t.Util._inRange(r,337.5,360)||t.Util._inRange(r,0,22.5)?"ns-resize":t.Util._inRange(r,22.5,67.5)?"nesw-resize":t.Util._inRange(r,67.5,112.5)?"ew-resize":t.Util._inRange(r,112.5,157.5)?"nwse-resize":t.Util._inRange(r,157.5,202.5)?"ns-resize":t.Util._inRange(r,202.5,247.5)?"nesw-resize":t.Util._inRange(r,247.5,292.5)?"ew-resize":t.Util._inRange(r,292.5,337.5)?"nwse-resize":(t.Util.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}(e,n,r);i.getStage().content&&(i.getStage().content.style.cursor=s),this._cursorChange=!0})),i.on("mouseout",(()=>{i.getStage().content&&(i.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(i)}_createBack(){const e=new n.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(e,i){const n=i.getParent(),r=n.padding();e.beginPath(),e.rect(-r,-r,i.width()+2*r,i.height()+2*r),e.moveTo(i.width()/2,-r),n.rotateEnabled()&&n.rotateLineVisible()&&e.lineTo(i.width()/2,-n.rotateAnchorOffset()*t.Util._sign(i.height())-r),e.fillStrokeShape(i)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}});this.add(e),this._proxyDrag(e),e.on("dragstart",(t=>{t.cancelBubble=!0})),e.on("dragmove",(t=>{t.cancelBubble=!0})),e.on("dragend",(t=>{t.cancelBubble=!0})),this.on("dragmove",(t=>{this.update()}))}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const e=this._getNodeRect(),i=e.width,n=e.height,r=Math.sqrt(Math.pow(i,2)+Math.pow(n,2));this.sin=Math.abs(n/r),this.cos=Math.abs(i/r),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const s=t.target.getAbsolutePosition(),a=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:a.x-s.x,y:a.y-s.y},_++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach((e=>{e._fire("transformstart",{evt:t.evt,target:e})}))}_handleMouseMove(t){let e,i,n;const r=this.findOne("."+this._movingAnchorName),s=r.getStage();s.setPointersPositions(t);const o=s.getPointerPosition();let h={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y};const l=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(h=this.anchorDragBoundFunc()(l,h,t)),r.setAbsolutePosition(h);const c=r.getAbsolutePosition();if(l.x===c.x&&l.y===c.y)return;if("rotater"===this._movingAnchorName){const n=this._getNodeRect();e=r.x()-n.width/2,i=-r.y()+n.height/2;let s=Math.atan2(-i,e)+Math.PI/2;n.height<0&&(s-=Math.PI);const o=a.Konva.getAngle(this.rotation())+s,h=a.Konva.getAngle(this.rotationSnapTolerance()),l=function(t,e,i){let n=e;for(let r=0;r<t.length;r++){const s=a.Konva.getAngle(t[r]),o=Math.abs(s-e)%(2*Math.PI);Math.min(o,2*Math.PI-o)<i&&(n=s)}return n}(this.rotationSnaps(),o,h),c=v(n,l-n.rotation);return void this._fitNodesInto(c,t)}const d=this.shiftBehavior();let u;u="inverted"===d?this.keepRatio()&&!t.shiftKey:"none"===d?this.keepRatio():this.keepRatio()||t.shiftKey;var p=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(u){var m=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};n=Math.sqrt(Math.pow(m.x-r.x(),2)+Math.pow(m.y-r.y(),2));var f=this.findOne(".top-left").x()>m.x?-1:1,g=this.findOne(".top-left").y()>m.y?-1:1;e=n*this.cos*f,i=n*this.sin*g,this.findOne(".top-left").x(m.x-e),this.findOne(".top-left").y(m.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(r.y());else if("top-right"===this._movingAnchorName){if(u){m=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};n=Math.sqrt(Math.pow(r.x()-m.x,2)+Math.pow(m.y-r.y(),2));f=this.findOne(".top-right").x()<m.x?-1:1,g=this.findOne(".top-right").y()>m.y?-1:1;e=n*this.cos*f,i=n*this.sin*g,this.findOne(".top-right").x(m.x+e),this.findOne(".top-right").y(m.y-i)}var _=r.position();this.findOne(".top-left").y(_.y),this.findOne(".bottom-right").x(_.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(r.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(r.x());else if("bottom-left"===this._movingAnchorName){if(u){m=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};n=Math.sqrt(Math.pow(m.x-r.x(),2)+Math.pow(r.y()-m.y,2));f=m.x<r.x()?-1:1,g=r.y()<m.y?-1:1;e=n*this.cos*f,i=n*this.sin*g,r.x(m.x-e),r.y(m.y+i)}_=r.position(),this.findOne(".top-left").x(_.x),this.findOne(".bottom-right").y(_.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(r.y());else if("bottom-right"===this._movingAnchorName){if(u){m=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};n=Math.sqrt(Math.pow(r.x()-m.x,2)+Math.pow(r.y()-m.y,2));f=this.findOne(".bottom-right").x()<m.x?-1:1,g=this.findOne(".bottom-right").y()<m.y?-1:1;e=n*this.cos*f,i=n*this.sin*g,this.findOne(".bottom-right").x(m.x+e),this.findOne(".bottom-right").y(m.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(p=this.centeredScaling()||t.altKey){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),i=t.x(),n=t.y(),r=this.getWidth()-e.x(),s=this.getHeight()-e.y();e.move({x:-i,y:-n}),t.move({x:r,y:s})}const y=this.findOne(".top-left").getAbsolutePosition();e=y.x,i=y.y;const x=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),b=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:x,height:b,rotation:a.Konva.getAngle(this.rotation())},t)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const i=this.getNode();_--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&this._nodes.forEach((e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this._movingAnchorName=null}}_fitNodesInto(e,i){const n=this._getNodeRect();if(t.Util._inRange(e.width,2*-this.padding()-1,1))return void this.update();if(t.Util._inRange(e.height,2*-this.padding()-1,1))return void this.update();const r=new t.Transform;if(r.rotate(a.Konva.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const t=r.point({x:2*-this.padding(),y:0});e.x+=t.x,e.y+=t.y,e.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const t=r.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=2*this.padding()}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const t=r.point({x:0,y:2*-this.padding()});e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const t=r.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}if(this.boundBoxFunc()){const i=this.boundBoxFunc()(n,e);i?e=i:t.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const s=1e7,o=new t.Transform;o.translate(n.x,n.y),o.rotate(n.rotation),o.scale(n.width/s,n.height/s);const h=new t.Transform,l=e.width/s,c=e.height/s;!1===this.flipEnabled()?(h.translate(e.x,e.y),h.rotate(e.rotation),h.translate(e.width<0?e.width:0,e.height<0?e.height:0),h.scale(Math.abs(l),Math.abs(c))):(h.translate(e.x,e.y),h.rotate(e.rotation),h.scale(l,c));const d=h.multiply(o.invert());this._nodes.forEach((e=>{var i;const n=e.getParent().getAbsoluteTransform(),r=e.getTransform().copy();r.translate(e.offsetX(),e.offsetY());const s=new t.Transform;s.multiply(n.copy().invert()).multiply(d).multiply(n).multiply(r);const a=s.decompose();e.setAttrs(a),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this.rotation(t.Util._getRotation(e.rotation)),this._nodes.forEach((t=>{this._fire("transform",{evt:i,target:t}),t._fire("transform",{evt:i,target:t})})),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var e;const i=this._getNodeRect();this.rotation(t.Util._getRotation(i.rotation));const n=i.width,r=i.height,s=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),h=this.anchorSize(),l=this.find("._anchor");l.forEach((t=>{t.setAttrs({width:h,height:h,offsetX:h/2,offsetY:h/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:h/2+o,offsetY:h/2+o,visible:a&&s.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:h/2+o,visible:a&&s.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:h/2-o,offsetY:h/2+o,visible:a&&s.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:h/2+o,visible:a&&s.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:h/2-o,visible:a&&s.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:h/2+o,offsetY:h/2-o,visible:a&&s.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:h/2-o,visible:a&&s.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:h/2-o,offsetY:h/2-o,visible:a&&s.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:n/2,y:-this.rotateAnchorOffset()*t.Util._sign(r)-o,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const c=this.anchorStyleFunc();c&&l.forEach((t=>{c(t)})),null===(e=this.getLayer())||void 0===e||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),s.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return i.Node.prototype.toObject.call(this)}clone(t){return i.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};return c_.Transformer=y,y.isTransforming=()=>_>0,y.prototype.className="Transformer",(0,h._registerNode)(y),e.Factory.addGetterSetter(y,"enabledAnchors",f,(function(e){return e instanceof Array||t.Util.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach((function(e){-1===f.indexOf(e)&&t.Util.warn("Unknown anchor name: "+e+". Available names are: "+f.join(", "))})),e||[]})),e.Factory.addGetterSetter(y,"flipEnabled",!0,(0,o.getBooleanValidator)()),e.Factory.addGetterSetter(y,"resizeEnabled",!0),e.Factory.addGetterSetter(y,"anchorSize",10,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"rotateEnabled",!0),e.Factory.addGetterSetter(y,"rotateLineVisible",!0),e.Factory.addGetterSetter(y,"rotationSnaps",[]),e.Factory.addGetterSetter(y,"rotateAnchorOffset",50,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"rotateAnchorCursor","crosshair"),e.Factory.addGetterSetter(y,"rotationSnapTolerance",5,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderEnabled",!0),e.Factory.addGetterSetter(y,"anchorStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(y,"anchorStrokeWidth",1,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"anchorFill","white"),e.Factory.addGetterSetter(y,"anchorCornerRadius",0,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(y,"borderStrokeWidth",1,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderDash"),e.Factory.addGetterSetter(y,"keepRatio",!0),e.Factory.addGetterSetter(y,"shiftBehavior","default"),e.Factory.addGetterSetter(y,"centeredScaling",!1),e.Factory.addGetterSetter(y,"ignoreStroke",!1),e.Factory.addGetterSetter(y,"padding",0,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"nodes"),e.Factory.addGetterSetter(y,"node"),e.Factory.addGetterSetter(y,"boundBoxFunc"),e.Factory.addGetterSetter(y,"anchorDragBoundFunc"),e.Factory.addGetterSetter(y,"anchorStyleFunc"),e.Factory.addGetterSetter(y,"shouldOverdrawWholeArea",!1),e.Factory.addGetterSetter(y,"useSingleNodeRotation",!0),e.Factory.backCompat(y,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"}),c_}var u_,p_={};var m_,f_={};function g_(){if(m_)return f_;m_=1,Object.defineProperty(f_,"__esModule",{value:!0}),f_.Blur=void 0;const t=Vg(),e=tv(),i=Hg();function n(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}const r=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],s=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];return f_.Blur=function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const i=t.data,a=t.width,o=t.height;let h,l,c,d,u,p,m,f,g,v,_,y,x,b,w,S,M,T,E,A,C,R,P,L;const I=e+e+1,D=a-1,O=o-1,N=e+1,U=N*(N+1)/2,F=new n,k=r[e],B=s[e];let z=null,G=F,H=null,V=null;for(c=1;c<I;c++)G=G.next=new n,c===N&&(z=G);for(G.next=F,m=p=0,l=0;l<o;l++){for(S=M=T=E=f=g=v=_=0,y=N*(A=i[p]),x=N*(C=i[p+1]),b=N*(R=i[p+2]),w=N*(P=i[p+3]),f+=U*A,g+=U*C,v+=U*R,_+=U*P,G=F,c=0;c<N;c++)G.r=A,G.g=C,G.b=R,G.a=P,G=G.next;for(c=1;c<N;c++)d=p+((D<c?D:c)<<2),f+=(G.r=A=i[d])*(L=N-c),g+=(G.g=C=i[d+1])*L,v+=(G.b=R=i[d+2])*L,_+=(G.a=P=i[d+3])*L,S+=A,M+=C,T+=R,E+=P,G=G.next;for(H=F,V=z,h=0;h<a;h++)i[p+3]=P=_*k>>B,0!==P?(P=255/P,i[p]=(f*k>>B)*P,i[p+1]=(g*k>>B)*P,i[p+2]=(v*k>>B)*P):i[p]=i[p+1]=i[p+2]=0,f-=y,g-=x,v-=b,_-=w,y-=H.r,x-=H.g,b-=H.b,w-=H.a,d=m+((d=h+e+1)<D?d:D)<<2,S+=H.r=i[d],M+=H.g=i[d+1],T+=H.b=i[d+2],E+=H.a=i[d+3],f+=S,g+=M,v+=T,_+=E,H=H.next,y+=A=V.r,x+=C=V.g,b+=R=V.b,w+=P=V.a,S-=A,M-=C,T-=R,E-=P,V=V.next,p+=4;m+=a}for(h=0;h<a;h++){for(M=T=E=S=g=v=_=f=0,p=h<<2,y=N*(A=i[p]),x=N*(C=i[p+1]),b=N*(R=i[p+2]),w=N*(P=i[p+3]),f+=U*A,g+=U*C,v+=U*R,_+=U*P,G=F,c=0;c<N;c++)G.r=A,G.g=C,G.b=R,G.a=P,G=G.next;for(u=a,c=1;c<=e;c++)p=u+h<<2,f+=(G.r=A=i[p])*(L=N-c),g+=(G.g=C=i[p+1])*L,v+=(G.b=R=i[p+2])*L,_+=(G.a=P=i[p+3])*L,S+=A,M+=C,T+=R,E+=P,G=G.next,c<O&&(u+=a);for(p=h,H=F,V=z,l=0;l<o;l++)d=p<<2,i[d+3]=P=_*k>>B,P>0?(P=255/P,i[d]=(f*k>>B)*P,i[d+1]=(g*k>>B)*P,i[d+2]=(v*k>>B)*P):i[d]=i[d+1]=i[d+2]=0,f-=y,g-=x,v-=b,_-=w,y-=H.r,x-=H.g,b-=H.b,w-=H.a,d=h+((d=l+N)<O?d:O)*a<<2,f+=S+=H.r=i[d],g+=M+=H.g=i[d+1],v+=T+=H.b=i[d+2],_+=E+=H.a=i[d+3],H=H.next,y+=A=V.r,x+=C=V.g,b+=R=V.b,w+=P=V.a,S-=A,M-=C,T-=R,E-=P,V=V.next,p+=a}}(t,e)},t.Factory.addGetterSetter(e.Node,"blurRadius",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),f_}var v_,__={};var y_,x_={};var b_,w_={};var S_,M_={};var T_,E_={};var A_,C_={};var R_,P_={};var L_,I_={};var D_,O_={};function N_(){if(D_)return O_;D_=1,Object.defineProperty(O_,"__esModule",{value:!0}),O_.Kaleidoscope=void 0;const t=Vg(),e=tv(),i=Ug(),n=Hg();return O_.Kaleidoscope=function(t){const e=t.width,n=t.height;let r,s,a,o,h,l,c,d,u,p,m=Math.round(this.kaleidoscopePower());const f=Math.round(this.kaleidoscopeAngle()),g=Math.floor(e*(f%360)/360);if(m<1)return;const v=i.Util.createCanvasElement();v.width=e,v.height=n;const _=v.getContext("2d").getImageData(0,0,e,n);i.Util.releaseCanvas(v),function(t,e,i){const n=t.data,r=e.data,s=t.width,a=t.height,o=i.polarCenterX||s/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),c=s-o,d=a-h;const u=Math.sqrt(c*c+d*d);l=u>l?u:l;const p=a,m=s,f=360/m*Math.PI/180;for(let t=0;t<m;t+=1){const e=Math.sin(t*f),i=Math.cos(t*f);for(let a=0;a<p;a+=1){c=Math.floor(o+l*a/p*i),d=Math.floor(h+l*a/p*e);let u=4*(d*s+c);const m=n[u+0],f=n[u+1],g=n[u+2],v=n[u+3];u=4*(t+a*s),r[u+0]=m,r[u+1]=f,r[u+2]=g,r[u+3]=v}}}(t,_,{polarCenterX:e/2,polarCenterY:n/2});let y=e/Math.pow(2,m);for(;y<=8;)y*=2,m-=1;y=Math.ceil(y);let x=y,b=0,w=x,S=1;for(g+y>e&&(b=x,w=0,S=-1),s=0;s<n;s+=1)for(r=b;r!==w;r+=S)a=Math.round(r+g)%e,u=4*(e*s+a),h=_.data[u+0],l=_.data[u+1],c=_.data[u+2],d=_.data[u+3],p=4*(e*s+r),_.data[p+0]=h,_.data[p+1]=l,_.data[p+2]=c,_.data[p+3]=d;for(s=0;s<n;s+=1)for(x=Math.floor(y),o=0;o<m;o+=1){for(r=0;r<x+1;r+=1)u=4*(e*s+r),h=_.data[u+0],l=_.data[u+1],c=_.data[u+2],d=_.data[u+3],p=4*(e*s+2*x-r-1),_.data[p+0]=h,_.data[p+1]=l,_.data[p+2]=c,_.data[p+3]=d;x*=2}!function(t,e,i){const n=t.data,r=e.data,s=t.width,a=t.height,o=i.polarCenterX||s/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),c=s-o,d=a-h;const u=Math.sqrt(c*c+d*d);l=u>l?u:l;const p=a,m=s;let f,g;for(c=0;c<s;c+=1)for(d=0;d<a;d+=1){const t=c-o,e=d-h,i=Math.sqrt(t*t+e*e)*p/l;let a=(180*Math.atan2(e,t)/Math.PI+360+0)%360;a=a*m/360,f=Math.floor(a),g=Math.floor(i);let u=4*(g*s+f);const v=n[u+0],_=n[u+1],y=n[u+2],x=n[u+3];u=4*(d*s+c),r[u+0]=v,r[u+1]=_,r[u+2]=y,r[u+3]=x}}(_,t,{})},t.Factory.addGetterSetter(e.Node,"kaleidoscopePower",2,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"kaleidoscopeAngle",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),O_}var U_,F_={};function k_(){if(U_)return F_;U_=1,Object.defineProperty(F_,"__esModule",{value:!0}),F_.Mask=void 0;const t=Vg(),e=tv(),i=Hg();function n(t,e,i){let n=4*(i*t.width+e);const r=[];return r.push(t.data[n++],t.data[n++],t.data[n++],t.data[n++]),r}function r(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}return F_.Mask=function(t){let e=function(t,e){const i=n(t,0,0),s=n(t,t.width-1,0),a=n(t,0,t.height-1),o=n(t,t.width-1,t.height-1),h=e||10;if(r(i,s)<h&&r(s,o)<h&&r(o,a)<h&&r(a,i)<h){const e=function(t){const e=[0,0,0];for(let i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([s,i,o,a]),n=[];for(let i=0;i<t.width*t.height;i++){const s=r(e,[t.data[4*i],t.data[4*i+1],t.data[4*i+2]]);n[i]=s<h?0:255}return n}}(t,this.threshold());return e&&(e=function(t,e,i){const n=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(n.length)),s=Math.floor(r/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<r;a++)for(let l=0;l<r;l++){const d=o+a-s,u=h+l-s;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*r+l];c+=t[d*e+u]*i}}a[l]=2040===c?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(n.length)),s=Math.floor(r/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<r;a++)for(let l=0;l<r;l++){const d=o+a-s,u=h+l-s;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*r+l];c+=t[d*e+u]*i}}a[l]=c>=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],r=Math.round(Math.sqrt(n.length)),s=Math.floor(r/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<r;a++)for(let l=0;l<r;l++){const d=o+a-s,u=h+l-s;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*r+l];c+=t[d*e+u]*i}}a[l]=c}return a}(e,t.width,t.height),function(t,e){for(let i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e)),t},t.Factory.addGetterSetter(e.Node,"threshold",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),F_}var B_,z_={};var G_,H_={};var V_,W_={};var j_,X_={};var Y_,q_={};var K_,Z_={};var J_,Q_={};var $_,ty,ey={};function iy(){if(ty)return Pg;ty=1,Object.defineProperty(Pg,"__esModule",{value:!0}),Pg.Konva=void 0;const t=Ev(),e=function(){if(Av)return Cv;Av=1,Object.defineProperty(Cv,"__esModule",{value:!0}),Cv.Arc=void 0;const t=Vg(),e=pv(),i=Dg(),n=Hg(),r=Dg();let s=class extends e.Shape{_sceneFunc(t){const e=i.Konva.getAngle(this.angle()),n=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,n),t.arc(0,0,this.innerRadius(),e,0,!n),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),n=this.clockwise(),r=i.Konva.getAngle(n?360-this.angle():this.angle()),s=Math.cos(Math.min(r,Math.PI)),a=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),o=Math.sin(Math.min(r,Math.PI/2)),h=s*(s>0?t:e),l=a*(a>0?t:e),c=o*(o>0?e:t);return{x:h,y:n?-1*c:l,width:1*e-h,height:c-l}}};return Cv.Arc=s,s.prototype._centroid=!0,s.prototype.className="Arc",s.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"innerRadius",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"outerRadius",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"angle",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"clockwise",!1,(0,n.getBooleanValidator)()),Cv}(),i=function(){if(Nv)return Pv;Nv=1,Object.defineProperty(Pv,"__esModule",{value:!0}),Pv.Arrow=void 0;const t=Vg(),e=Iv(),i=Hg(),n=Dg(),r=kv();let s=class extends e.Line{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let n=i;const s=0!==this.tension()&&i.length>4;s&&(n=this.getTensionPoints());const a=this.pointerLength(),o=i.length;let h,l;if(s){const t=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],i[o-2],i[o-1]],e=r.Path.calcLength(n[n.length-4],n[n.length-3],"C",t),s=r.Path.getPointOnQuadraticBezier(Math.min(1,1-a/e),t[0],t[1],t[2],t[3],t[4],t[5]);h=i[o-2]-s.x,l=i[o-1]-s.y}else h=i[o-2]-i[o-4],l=i[o-1]-i[o-3];const c=(Math.atan2(l,h)+e)%e,d=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[o-2],i[o-1]),t.rotate(c),t.moveTo(0,0),t.lineTo(-a,d/2),t.lineTo(-a,-d/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),s?(h=(n[0]+n[2])/2-i[0],l=(n[1]+n[3])/2-i[1]):(h=i[2]-i[0],l=i[3]-i[1]),t.rotate((Math.atan2(-l,-h)+e)%e),t.moveTo(0,0),t.lineTo(-a,d/2),t.lineTo(-a,-d/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x,y:t.y-e,width:t.width,height:t.height+2*e}}};return Pv.Arrow=s,s.prototype.className="Arrow",(0,n._registerNode)(s),t.Factory.addGetterSetter(s,"pointerLength",10,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"pointerWidth",10,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"pointerAtBeginning",!1),t.Factory.addGetterSetter(s,"pointerAtEnding",!0),Pv}(),n=function(){if(Bv)return zv;Bv=1,Object.defineProperty(zv,"__esModule",{value:!0}),zv.Circle=void 0;const t=Vg(),e=pv(),i=Hg(),n=Dg();let r=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}};return zv.Circle=r,r.prototype._centroid=!0,r.prototype.className="Circle",r.prototype._attrsAffectingSize=["radius"],(0,n._registerNode)(r),t.Factory.addGetterSetter(r,"radius",0,(0,i.getNumberValidator)()),zv}(),r=function(){if(Gv)return Hv;Gv=1,Object.defineProperty(Hv,"__esModule",{value:!0}),Hv.Ellipse=void 0;const t=Vg(),e=pv(),i=Hg(),n=Dg();let r=class extends e.Shape{_sceneFunc(t){const e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}};return Hv.Ellipse=r,r.prototype.className="Ellipse",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,n._registerNode)(r),t.Factory.addComponentsGetterSetter(r,"radius",["x","y"]),t.Factory.addGetterSetter(r,"radiusX",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"radiusY",0,(0,i.getNumberValidator)()),Hv}(),s=function(){if(Vv)return Wv;Vv=1,Object.defineProperty(Wv,"__esModule",{value:!0}),Wv.Image=void 0;const t=Ug(),e=Vg(),i=pv(),n=Dg(),r=Hg();class s extends i.Shape{constructor(t){super(t),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(e){const i=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),s=this.attrs.image;let a;if(s){const t=this.attrs.cropWidth,e=this.attrs.cropHeight;a=t&&e?[s,this.cropX(),this.cropY(),t,e,0,0,i,n]:[s,0,0,i,n]}(this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?t.Util.drawRoundedRectPath(e,i,n,r):e.rect(0,0,i,n),e.closePath(),e.fillStrokeShape(this)),s&&(r&&e.clip(),e.drawImage.apply(e,a))}_hitFunc(e){const i=this.width(),n=this.height(),r=this.cornerRadius();e.beginPath(),r?t.Util.drawRoundedRectPath(e,i,n,r):e.rect(0,0,i,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(e,i,n=null){const r=t.Util.createImageElement();r.onload=function(){const t=new s({image:r});i(t)},r.onerror=n,r.crossOrigin="Anonymous",r.src=e}}return Wv.Image=s,s.prototype.className="Image",(0,n._registerNode)(s),e.Factory.addGetterSetter(s,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),e.Factory.addGetterSetter(s,"image"),e.Factory.addComponentsGetterSetter(s,"crop",["x","y","width","height"]),e.Factory.addGetterSetter(s,"cropX",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropY",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropWidth",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropHeight",0,(0,r.getNumberValidator)()),Wv}(),a=function(){if(jv)return Xv;jv=1,Object.defineProperty(Xv,"__esModule",{value:!0}),Xv.Tag=Xv.Label=void 0;const t=Vg(),e=pv(),i=yv(),n=Hg(),r=Dg(),s=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],a="up",o="right",h="down",l="left",c=s.length;let d=class extends i.Group{constructor(t){super(t),this.on("add.konva",(function(t){this._addListeners(t.child),this._sync()}))}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,i=this;const n=function(){i._sync()};for(e=0;e<c;e++)t.on(s[e]+"Change.konva",n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,i,n,r,s,c,d=this.getText(),u=this.getTag();if(d&&u){switch(t=d.width(),e=d.height(),i=u.pointerDirection(),n=u.pointerWidth(),c=u.pointerHeight(),r=0,s=0,i){case a:r=t/2,s=-1*c;break;case o:r=t+n,s=e/2;break;case h:r=t/2,s=e+c;break;case l:r=-1*n,s=e/2}u.setAttrs({x:-1*r,y:-1*s,width:t,height:e}),d.setAttrs({x:-1*r,y:-1*s})}}};Xv.Label=d,d.prototype.className="Label",(0,r._registerNode)(d);class u extends e.Shape{_sceneFunc(t){const e=this.width(),i=this.height(),n=this.pointerDirection(),r=this.pointerWidth(),s=this.pointerHeight(),c=this.cornerRadius();let d=0,u=0,p=0,m=0;"number"==typeof c?d=u=p=m=Math.min(c,e/2,i/2):(d=Math.min(c[0]||0,e/2,i/2),u=Math.min(c[1]||0,e/2,i/2),m=Math.min(c[2]||0,e/2,i/2),p=Math.min(c[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(d,0),n===a&&(t.lineTo((e-r)/2,0),t.lineTo(e/2,-1*s),t.lineTo((e+r)/2,0)),t.lineTo(e-u,0),t.arc(e-u,u,u,3*Math.PI/2,0,!1),n===o&&(t.lineTo(e,(i-s)/2),t.lineTo(e+r,i/2),t.lineTo(e,(i+s)/2)),t.lineTo(e,i-m),t.arc(e-m,i-m,m,0,Math.PI/2,!1),n===h&&(t.lineTo((e+r)/2,i),t.lineTo(e/2,i+s),t.lineTo((e-r)/2,i)),t.lineTo(p,i),t.arc(p,i-p,p,Math.PI/2,Math.PI,!1),n===l&&(t.lineTo(0,(i+s)/2),t.lineTo(-1*r,i/2),t.lineTo(0,(i-s)/2)),t.lineTo(0,d),t.arc(d,d,d,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,i=this.pointerWidth(),n=this.pointerHeight(),r=this.pointerDirection(),s=this.width(),c=this.height();return r===a?(e-=n,c+=n):r===h?c+=n:r===l?(t-=1.5*i,s+=i):r===o&&(s+=1.5*i),{x:t,y:e,width:s,height:c}}}return Xv.Tag=u,u.prototype.className="Tag",(0,r._registerNode)(u),t.Factory.addGetterSetter(u,"pointerDirection","none"),t.Factory.addGetterSetter(u,"pointerWidth",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(u,"pointerHeight",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(u,"cornerRadius",0,(0,n.getNumberOrArrayOfNumbersValidator)(4)),Xv}(),o=Iv(),h=kv(),l=Kv(),c=function(){if(Zv)return Jv;Zv=1,Object.defineProperty(Jv,"__esModule",{value:!0}),Jv.RegularPolygon=void 0;const t=Vg(),e=pv(),i=Hg(),n=Dg();let r=class extends e.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y);t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(let n=0;n<t;n++)i.push({x:e*Math.sin(2*n*Math.PI/t),y:-1*e*Math.cos(2*n*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();let e=t[0].x,i=t[0].y,n=t[0].x,r=t[0].y;return t.forEach((t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),r=Math.max(r,t.y)})),{x:e,y:n,width:i-e,height:r-n}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}};return Jv.RegularPolygon=r,r.prototype.className="RegularPolygon",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["radius"],(0,n._registerNode)(r),t.Factory.addGetterSetter(r,"radius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"sides",0,(0,i.getNumberValidator)()),Jv}(),d=function(){if(Qv)return $v;Qv=1,Object.defineProperty($v,"__esModule",{value:!0}),$v.Ring=void 0;const t=Vg(),e=pv(),i=Hg(),n=Dg(),r=2*Math.PI;let s=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,r,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),r,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}};return $v.Ring=s,s.prototype.className="Ring",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,n._registerNode)(s),t.Factory.addGetterSetter(s,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"outerRadius",0,(0,i.getNumberValidator)()),$v}(),u=function(){if(t_)return e_;t_=1,Object.defineProperty(e_,"__esModule",{value:!0}),e_.Sprite=void 0;const t=Vg(),e=pv(),i=wv(),n=Hg(),r=Dg();let s=class extends e.Shape{constructor(t){super(t),this._updated=!0,this.anim=new i.Animation((()=>{const t=this._updated;return this._updated=!1,t})),this.on("animationChange.konva",(function(){this.frameIndex(0)})),this.on("frameIndexChange.konva",(function(){this._updated=!0})),this.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}))}_sceneFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,r=this.animations()[e],s=this.frameOffsets(),a=r[n+0],o=r[n+1],h=r[n+2],l=r[n+3],c=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),c)if(s){const n=s[e],r=2*i;t.drawImage(c,a,o,h,l,n[r+0],n[r+1],h,l)}else t.drawImage(c,a,o,h,l,0,0,h,l)}_hitFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,r=this.animations()[e],s=this.frameOffsets(),a=r[n+2],o=r[n+3];if(t.beginPath(),s){const n=s[e],r=2*i;t.rect(n[r+0],n[r+1],a,o)}else t.rect(0,0,a,o);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval((function(){t._updateIndex()}),1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}};return e_.Sprite=s,s.prototype.className="Sprite",(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"animation"),t.Factory.addGetterSetter(s,"animations"),t.Factory.addGetterSetter(s,"frameOffsets"),t.Factory.addGetterSetter(s,"image"),t.Factory.addGetterSetter(s,"frameIndex",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"frameRate",17,(0,n.getNumberValidator)()),t.Factory.backCompat(s,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"}),e_}(),p=function(){if(i_)return n_;i_=1,Object.defineProperty(n_,"__esModule",{value:!0}),n_.Star=void 0;const t=Vg(),e=pv(),i=Hg(),n=Dg();let r=class extends e.Shape{_sceneFunc(t){const e=this.innerRadius(),i=this.outerRadius(),n=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(let r=1;r<2*n;r++){const s=r%2==0?i:e,a=s*Math.sin(r*Math.PI/n),o=-1*s*Math.cos(r*Math.PI/n);t.lineTo(a,o)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}};return n_.Star=r,r.prototype.className="Star",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,n._registerNode)(r),t.Factory.addGetterSetter(r,"numPoints",5,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"outerRadius",0,(0,i.getNumberValidator)()),n_}(),m=a_(),f=function(){if(o_)return h_;o_=1,Object.defineProperty(h_,"__esModule",{value:!0}),h_.TextPath=void 0;const t=Ug(),e=Vg(),i=pv(),n=kv(),r=a_(),s=Hg(),a=Dg(),o="normal";function h(t){t.fillText(this.partialText,0,0)}function l(t){t.strokeText(this.partialText,0,0)}let c=class extends i.Shape{constructor(e){super(e),this.dummyCanvas=t.Util.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute(),this._setTextData()})),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return n.Path.getPathLength(this.dataArray)}_getPointAtLength(t){return this.attrs.data?t-1>this.pathLength?null:n.Path.getPointAtLengthOfDataArray(t,this.dataArray):null}_readDataAttribute(){this.dataArray=n.Path.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),i=this.fill(),n=this.fontSize(),r=this.glyphInfo;"underline"===e&&t.beginPath();for(let i=0;i<r.length;i++){t.save();const s=r[i].p0;t.translate(s.x,s.y),t.rotate(r[i].rotation),this.partialText=r[i].text,t.fillStrokeShape(this),"underline"===e&&(0===i&&t.moveTo(0,n/2+1),t.lineTo(n,n/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=i,t.lineWidth=n/20,t.stroke()),t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const i=e[0].p0;t.moveTo(i.x,i.y)}for(let i=0;i<e.length;i++){const n=e[i].p1;t.lineTo(n.x,n.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return r.Text.prototype.setText.call(this,t)}_getContextFont(){return r.Text.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let h=0;"center"===s&&(h=Math.max(0,this.pathLength/2-o/2)),"right"===s&&(h=Math.max(0,this.pathLength-o));const l=(0,r.stringToArray)(this.text());let c=h;for(let t=0;t<l.length;t++){const e=this._getPointAtLength(c);if(!e)return;let r=this._getTextSize(l[t]).width+i;if(" "===l[t]&&"justify"===s){const t=this.text().split(" ").length-1;r+=(this.pathLength-o)/t}const h=this._getPointAtLength(c+r);if(!h)return;const d=n.Path.getLineLength(e.x,e.y,h.x,h.y);let u=0;if(a)try{u=a(l[t-1],l[t])*this.fontSize()}catch(t){u=0}e.x+=u,h.x+=u,this.textWidth+=u;const p=n.Path.getPointOnLine(u+d/2,e.x,e.y,h.x,h.y),m=Math.atan2(h.y-e.y,h.x-e.x);this.glyphInfo.push({transposeX:p.x,transposeY:p.y,text:l[t],rotation:m,p0:e,p1:h}),c+=r}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const t=[];this.glyphInfo.forEach((function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)}));let e,i,n=t[0]||0,r=t[0]||0,s=t[1]||0,a=t[1]||0;for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),r=Math.max(r,e),s=Math.min(s,i),a=Math.max(a,i);const o=this.fontSize();return{x:n-o/2,y:s-o/2,width:r-n+o,height:a-s+o}}destroy(){return t.Util.releaseCanvas(this.dummyCanvas),super.destroy()}};return h_.TextPath=c,c.prototype._fillFunc=h,c.prototype._strokeFunc=l,c.prototype._fillFuncHit=h,c.prototype._strokeFuncHit=l,c.prototype.className="TextPath",c.prototype._attrsAffectingSize=["text","fontSize","data"],(0,a._registerNode)(c),e.Factory.addGetterSetter(c,"data"),e.Factory.addGetterSetter(c,"fontFamily","Arial"),e.Factory.addGetterSetter(c,"fontSize",12,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(c,"fontStyle",o),e.Factory.addGetterSetter(c,"align","left"),e.Factory.addGetterSetter(c,"letterSpacing",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(c,"textBaseline","middle"),e.Factory.addGetterSetter(c,"fontVariant",o),e.Factory.addGetterSetter(c,"text",""),e.Factory.addGetterSetter(c,"textDecoration",""),e.Factory.addGetterSetter(c,"kerningFunc",void 0),h_}(),g=d_(),v=function(){if(u_)return p_;u_=1,Object.defineProperty(p_,"__esModule",{value:!0}),p_.Wedge=void 0;const t=Vg(),e=pv(),i=Dg(),n=Hg(),r=Dg();let s=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,i.Konva.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}};return p_.Wedge=s,s.prototype.className="Wedge",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["radius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"radius",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"angle",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"clockwise",!1),t.Factory.backCompat(s,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"}),p_}(),_=g_(),y=function(){if(v_)return __;v_=1,Object.defineProperty(__,"__esModule",{value:!0}),__.Brighten=void 0;const t=Vg(),e=tv(),i=Hg();return __.Brighten=function(t){const e=255*this.brightness(),i=t.data,n=i.length;for(let t=0;t<n;t+=4)i[t]+=e,i[t+1]+=e,i[t+2]+=e},t.Factory.addGetterSetter(e.Node,"brightness",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),__}(),x=function(){if(y_)return x_;y_=1,Object.defineProperty(x_,"__esModule",{value:!0}),x_.Contrast=void 0;const t=Vg(),e=tv(),i=Hg();return x_.Contrast=function(t){const e=Math.pow((this.contrast()+100)/100,2),i=t.data,n=i.length;let r=150,s=150,a=150;for(let t=0;t<n;t+=4)r=i[t],s=i[t+1],a=i[t+2],r/=255,r-=.5,r*=e,r+=.5,r*=255,s/=255,s-=.5,s*=e,s+=.5,s*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,r=r<0?0:r>255?255:r,s=s<0?0:s>255?255:s,a=a<0?0:a>255?255:a,i[t]=r,i[t+1]=s,i[t+2]=a},t.Factory.addGetterSetter(e.Node,"contrast",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),x_}(),b=function(){if(b_)return w_;b_=1,Object.defineProperty(w_,"__esModule",{value:!0}),w_.Emboss=void 0;const t=Vg(),e=tv(),i=Ug(),n=Hg();return w_.Emboss=function(t){const e=10*this.embossStrength(),n=255*this.embossWhiteLevel(),r=this.embossDirection(),s=this.embossBlend(),a=t.data,o=t.width,h=t.height,l=4*o;let c=0,d=0,u=h;switch(r){case"top-left":c=-1,d=-1;break;case"top":c=-1,d=0;break;case"top-right":c=-1,d=1;break;case"right":c=0,d=1;break;case"bottom-right":c=1,d=1;break;case"bottom":c=1,d=0;break;case"bottom-left":c=1,d=-1;break;case"left":c=0,d=-1;break;default:i.Util.error("Unknown emboss direction: "+r)}do{const t=(u-1)*l;let i=c;u+i<1&&(i=0),u+i>h&&(i=0);const r=(u-1+i)*o*4;let p=o;do{const i=t+4*(p-1);let h=d;p+h<1&&(h=0),p+h>o&&(h=0);const l=r+4*(p-1+h),c=a[i]-a[l],u=a[i+1]-a[l+1],m=a[i+2]-a[l+2];let f=c;const g=f>0?f:-f;if((u>0?u:-u)>g&&(f=u),(m>0?m:-m)>g&&(f=m),f*=e,s){const t=a[i]+f,e=a[i+1]+f,n=a[i+2]+f;a[i]=t>255?255:t<0?0:t,a[i+1]=e>255?255:e<0?0:e,a[i+2]=n>255?255:n<0?0:n}else{let t=n-f;t<0?t=0:t>255&&(t=255),a[i]=a[i+1]=a[i+2]=t}}while(--p)}while(--u)},t.Factory.addGetterSetter(e.Node,"embossStrength",.5,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossWhiteLevel",.5,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossDirection","top-left",void 0,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossBlend",!1,void 0,t.Factory.afterSetFilter),w_}(),w=function(){if(S_)return M_;S_=1,Object.defineProperty(M_,"__esModule",{value:!0}),M_.Enhance=void 0;const t=Vg(),e=tv(),i=Hg();function n(t,e,i,n,r){const s=i-e,a=r-n;if(0===s)return n+a/2;if(0===a)return n;let o=(t-e)/s;return o=a*o+n,o}return M_.Enhance=function(t){const e=t.data,i=e.length;let r,s,a,o=e[0],h=o,l=e[1],c=l,d=e[2],u=d;const p=this.enhance();if(0===p)return;for(let t=0;t<i;t+=4)r=e[t+0],r<o?o=r:r>h&&(h=r),s=e[t+1],s<l?l=s:s>c&&(c=s),a=e[t+2],a<d?d=a:a>u&&(u=a);let m,f,g,v,_,y,x,b,w;h===o&&(h=255,o=0),c===l&&(c=255,l=0),u===d&&(u=255,d=0),p>0?(f=h+p*(255-h),g=o-p*(o-0),_=c+p*(255-c),y=l-p*(l-0),b=u+p*(255-u),w=d-p*(d-0)):(m=.5*(h+o),f=h+p*(h-m),g=o+p*(o-m),v=.5*(c+l),_=c+p*(c-v),y=l+p*(l-v),x=.5*(u+d),b=u+p*(u-x),w=d+p*(d-x));for(let t=0;t<i;t+=4)e[t+0]=n(e[t+0],o,h,g,f),e[t+1]=n(e[t+1],l,c,y,_),e[t+2]=n(e[t+2],d,u,w,b)},t.Factory.addGetterSetter(e.Node,"enhance",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),M_}(),S=(T_||(T_=1,Object.defineProperty(E_,"__esModule",{value:!0}),E_.Grayscale=void 0,E_.Grayscale=function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=.34*e[t]+.5*e[t+1]+.16*e[t+2];e[t]=i,e[t+1]=i,e[t+2]=i}}),E_),M=function(){if(A_)return C_;A_=1,Object.defineProperty(C_,"__esModule",{value:!0}),C_.HSL=void 0;const t=Vg(),e=tv(),i=Hg();return t.Factory.addGetterSetter(e.Node,"hue",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"luminance",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),C_.HSL=function(t){const e=t.data,i=e.length,n=Math.pow(2,this.saturation()),r=Math.abs(this.hue()+360)%360,s=127*this.luminance(),a=1*n*Math.cos(r*Math.PI/180),o=1*n*Math.sin(r*Math.PI/180),h=.299+.701*a+.167*o,l=.587-.587*a+.33*o,c=.114-.114*a-.497*o,d=.299-.299*a-.328*o,u=.587+.413*a+.035*o,p=.114-.114*a+.293*o,m=.299-.3*a+1.25*o,f=.587-.586*a-1.05*o,g=.114+.886*a-.2*o;let v,_,y,x;for(let t=0;t<i;t+=4)v=e[t+0],_=e[t+1],y=e[t+2],x=e[t+3],e[t+0]=h*v+l*_+c*y+s,e[t+1]=d*v+u*_+p*y+s,e[t+2]=m*v+f*_+g*y+s,e[t+3]=x},C_}(),T=function(){if(R_)return P_;R_=1,Object.defineProperty(P_,"__esModule",{value:!0}),P_.HSV=void 0;const t=Vg(),e=tv(),i=Hg();return P_.HSV=function(t){const e=t.data,i=e.length,n=Math.pow(2,this.value()),r=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,a=n*r*Math.cos(s*Math.PI/180),o=n*r*Math.sin(s*Math.PI/180),h=.299*n+.701*a+.167*o,l=.587*n-.587*a+.33*o,c=.114*n-.114*a-.497*o,d=.299*n-.299*a-.328*o,u=.587*n+.413*a+.035*o,p=.114*n-.114*a+.293*o,m=.299*n-.3*a+1.25*o,f=.587*n-.586*a-1.05*o,g=.114*n+.886*a-.2*o;let v,_,y,x;for(let t=0;t<i;t+=4)v=e[t+0],_=e[t+1],y=e[t+2],x=e[t+3],e[t+0]=h*v+l*_+c*y,e[t+1]=d*v+u*_+p*y,e[t+2]=m*v+f*_+g*y,e[t+3]=x},t.Factory.addGetterSetter(e.Node,"hue",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"value",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),P_}(),E=(L_||(L_=1,Object.defineProperty(I_,"__esModule",{value:!0}),I_.Invert=void 0,I_.Invert=function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]}),I_),A=N_(),C=k_(),R=function(){if(B_)return z_;B_=1,Object.defineProperty(z_,"__esModule",{value:!0}),z_.Noise=void 0;const t=Vg(),e=tv(),i=Hg();return z_.Noise=function(t){const e=255*this.noise(),i=t.data,n=i.length,r=e/2;for(let t=0;t<n;t+=4)i[t+0]+=r-2*r*Math.random(),i[t+1]+=r-2*r*Math.random(),i[t+2]+=r-2*r*Math.random()},t.Factory.addGetterSetter(e.Node,"noise",.2,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),z_}(),P=function(){if(G_)return H_;G_=1,Object.defineProperty(H_,"__esModule",{value:!0}),H_.Pixelate=void 0;const t=Vg(),e=Ug(),i=tv(),n=Hg();return H_.Pixelate=function(t){let i,n,r,s,a,o,h,l,c,d,u,p,m,f,g=Math.ceil(this.pixelSize()),v=t.width,_=t.height,y=Math.ceil(v/g),x=Math.ceil(_/g),b=t.data;if(g<=0)e.Util.error("pixelSize value can not be <= 0");else for(p=0;p<y;p+=1)for(m=0;m<x;m+=1){for(s=0,a=0,o=0,h=0,l=p*g,c=l+g,d=m*g,u=d+g,f=0,i=l;i<c;i+=1)if(!(i>=v))for(n=d;n<u;n+=1)n>=_||(r=4*(v*n+i),s+=b[r+0],a+=b[r+1],o+=b[r+2],h+=b[r+3],f+=1);for(s/=f,a/=f,o/=f,h/=f,i=l;i<c;i+=1)if(!(i>=v))for(n=d;n<u;n+=1)n>=_||(r=4*(v*n+i),b[r+0]=s,b[r+1]=a,b[r+2]=o,b[r+3]=h)}},t.Factory.addGetterSetter(i.Node,"pixelSize",8,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),H_}(),L=function(){if(V_)return W_;V_=1,Object.defineProperty(W_,"__esModule",{value:!0}),W_.Posterize=void 0;const t=Vg(),e=tv(),i=Hg();return W_.Posterize=function(t){const e=Math.round(254*this.levels())+1,i=t.data,n=i.length,r=255/e;for(let t=0;t<n;t+=1)i[t]=Math.floor(i[t]/r)*r},t.Factory.addGetterSetter(e.Node,"levels",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),W_}(),I=function(){if(j_)return X_;j_=1,Object.defineProperty(X_,"__esModule",{value:!0}),X_.RGB=void 0;const t=Vg(),e=tv(),i=Hg();return X_.RGB=function(t){const e=t.data,i=e.length,n=this.red(),r=this.green(),s=this.blue();for(let t=0;t<i;t+=4){const i=(.34*e[t]+.5*e[t+1]+.16*e[t+2])/255;e[t]=i*n,e[t+1]=i*r,e[t+2]=i*s,e[t+3]=e[t+3]}},t.Factory.addGetterSetter(e.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"blue",0,i.RGBComponent,t.Factory.afterSetFilter),X_}(),D=function(){if(Y_)return q_;Y_=1,Object.defineProperty(q_,"__esModule",{value:!0}),q_.RGBA=void 0;const t=Vg(),e=tv(),i=Hg();return q_.RGBA=function(t){const e=t.data,i=e.length,n=this.red(),r=this.green(),s=this.blue(),a=this.alpha();for(let t=0;t<i;t+=4){const i=1-a;e[t]=n*a+e[t]*i,e[t+1]=r*a+e[t+1]*i,e[t+2]=s*a+e[t+2]*i}},t.Factory.addGetterSetter(e.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"blue",0,i.RGBComponent,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t})),q_}(),O=(K_||(K_=1,Object.defineProperty(Z_,"__esModule",{value:!0}),Z_.Sepia=void 0,Z_.Sepia=function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=e[t+0],n=e[t+1],r=e[t+2];e[t+0]=Math.min(255,.393*i+.769*n+.189*r),e[t+1]=Math.min(255,.349*i+.686*n+.168*r),e[t+2]=Math.min(255,.272*i+.534*n+.131*r)}}),Z_),N=(J_||(J_=1,Object.defineProperty(Q_,"__esModule",{value:!0}),Q_.Solarize=void 0,Q_.Solarize=function(t){const e=t.data,i=t.width,n=4*i;let r=t.height;do{const t=(r-1)*n;let s=i;do{const i=t+4*(s-1);let n=e[i],r=e[i+1],a=e[i+2];n>127&&(n=255-n),r>127&&(r=255-r),a>127&&(a=255-a),e[i]=n,e[i+1]=r,e[i+2]=a}while(--s)}while(--r)}),Q_),U=function(){if($_)return ey;$_=1,Object.defineProperty(ey,"__esModule",{value:!0}),ey.Threshold=void 0;const t=Vg(),e=tv(),i=Hg();return ey.Threshold=function(t){const e=255*this.threshold(),i=t.data,n=i.length;for(let t=0;t<n;t+=1)i[t]=i[t]<e?0:255},t.Factory.addGetterSetter(e.Node,"threshold",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),ey}();return Pg.Konva=t.Konva.Util._assign(t.Konva,{Arc:e.Arc,Arrow:i.Arrow,Circle:n.Circle,Ellipse:r.Ellipse,Image:s.Image,Label:a.Label,Tag:a.Tag,Line:o.Line,Path:h.Path,Rect:l.Rect,RegularPolygon:c.RegularPolygon,Ring:d.Ring,Sprite:u.Sprite,Star:p.Star,Text:m.Text,TextPath:f.TextPath,Transformer:g.Transformer,Wedge:v.Wedge,Filters:{Blur:_.Blur,Brighten:y.Brighten,Contrast:x.Contrast,Emboss:b.Emboss,Enhance:w.Enhance,Grayscale:S.Grayscale,HSL:M.HSL,HSV:T.HSV,Invert:E.Invert,Kaleidoscope:A.Kaleidoscope,Mask:C.Mask,Noise:R.Noise,Pixelate:P.Pixelate,Posterize:L.Posterize,RGB:I.RGB,RGBA:D.RGBA,Sepia:O.Sepia,Solarize:N.Solarize,Threshold:U.Threshold}}),Pg}var ny,ry=Rg.exports;var sy=Ag(function(){if(ny)return Rg.exports;ny=1,Object.defineProperty(ry,"__esModule",{value:!0});const t=iy();return Rg.exports=t.Konva,Rg.exports}());class ay{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}class oy{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const n=t=>{const e=t.toString(16);return"0"===e?"00":e};return n(t)+n(e)+n(i)}}const hy=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class ly{constructor(t,e=null,i=new ay){var n,r;if(this._worldTransformer=i,e){this._ref=e;let t=this._ref.getAttr("wcsPoints");if(!t){t=[];const e=this._ref.points();let i;for(let n=0;n<e.length;n+=2)i=this._worldTransformer.screenToWorld({x:e[n],y:e[n+1]}),t.push({x:i.x,y:i.y,z:i.z});this._ref.setAttr("wcsPoints",t)}return}t||(t={}),t.points||(t.points=[{x:0,y:0},{x:100,y:100}]);const s=[],a=[];t.points.forEach((t=>{s.push(t.x,t.y);const e=this._worldTransformer.screenToWorld({x:t.x,y:t.y});a.push({x:e.x,y:e.y,z:e.z})})),this._ref=new sy.Line({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(r=t.width)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:s,draggable:!0,strokeScaleEnabled:!1,dash:hy.get(t.type)||[]}),this._ref.setAttr("wcsPoints",a),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),this._ref.on("transformend",(t=>{const e=this._ref.getAbsoluteTransform(),i=[],n=this._ref.points();let r;for(let t=0;t<n.length;t+=2){const s=e.point({x:n[t],y:n[t+1]});r=this._worldTransformer.screenToWorld({x:s.x,y:s.y}),i.push({x:r.x,y:r.y,z:r.z})}this._ref.setAttr("wcsPoints",i)})),this._ref.on("dragend",(t=>{const e=this._ref.getAbsoluteTransform(),i=[],n=this._ref.points();let r;for(let t=0;t<n.length;t+=2){const s=e.point({x:n[t],y:n[t+1]});r=this._worldTransformer.screenToWorld({x:s.x,y:s.y}),i.push({x:r.x,y:r.y,z:r.z})}this._ref.setAttr("wcsPoints",i)})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case hy.get("dot"):t="dot";break;case hy.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=hy.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();const i=this._ref.getAttr("wcsPoints");t.forEach((t=>{e=e.concat([t.x,t.y]);const n=this._worldTransformer.screenToWorld(t);i.push(n)})),this._ref.points(e)}updateScreenCoordinates(){const t=this._ref.getAttr("wcsPoints"),e=[];let i=this._ref.getAbsoluteTransform().copy();i=i.invert(),t.forEach((t=>{let n=this._worldTransformer.worldToScreen(t);n=i.point({x:n.x,y:n.y}),e.push(n.x),e.push(n.y)})),this._ref.points([]),this._ref.points(e),this._ref.clearCache()}}class cy{constructor(t,e=null,i=new ay){var n,r,s;if(this.TEXT_FONT_FAMILY="Calibri",this._worldTransformer=i,e){this._ref=e;this._ref.getAttr("wcsStart")||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()}))}else t||(t={}),t.position||(t.position={x:0,y:0}),t.text||(t.text="default"),this._ref=new sy.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(n=t.fontSize)&&void 0!==n?n:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",align:"left",draggable:!0,rotation:null!==(s=t.rotation)&&void 0!==s?s:0}),this._ref.width(this._ref.getTextWidth()),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY);r<50&&(r=50),s<Math.round(this.getFontSize())&&(s=Math.round(this.getFontSize())),i&&this._ref.width(r),n&&this._ref.height(s),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i))})),this._ref.on("dragend",(t=>{const e=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(e))})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));let e=this._ref.getStage().getAbsoluteTransform().copy();e=e.invert();const i=e.point(t);this._ref.position({x:i.x,y:i.y})}}class dy{constructor(t,e=null,i=new ay){var n,r,s,a;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}}else t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200),this._ref=new sy.Rect({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(s=t.width)&&void 0!==s?s:200,height:null!==(a=t.height)&&void 0!==a?a:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",(t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY);r<50&&(r=50),s<50&&(s=50),i&&this._ref.width(r),n&&this._ref.height(s),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))})),this._ref.on("dragend",(t=>{const e=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(e)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:e.x+this._ref.width(),y:e.y+this._ref.height()}))})),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeigth(){return this._ref.height()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),r=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(r.x-n.x)),this._ref.height(Math.abs(r.y-n.y))}}function uy(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}class py{constructor(t,e=null,i=new ay){var n,r,s;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsPosition"),i=this._ref.getAttr("wcsRadiusX"),n=this._ref.getAttr("wcsRadiusY");return t||this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),i||this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:e.x()+e.radiusX(),y:e.y()})),void(n||this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()+e.radiusY()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(null!==(n=t.radius)&&void 0!==n||(t.radius={x:0,y:0}),t.radius.x=uy(t.position,t.position2),t.position3?t.radius.y=uy(t.position,t.position3):t.radius.x=t.radius.y):t.radius||(t.radius={x:25,y:25}),this._ref=new sy.Ellipse({stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(s=t.lineWidth)&&void 0!==s?s:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t.radius.x,y:this._ref.y()})),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t.radius.y})),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.radiusX();i&&(r*=e.scaleX);let s=this._ref.radiusY();n&&(s*=e.scaleY);r<25&&(r=25),s<25&&(s=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:r,y:r}):this._ref.radius({x:s,y:s}):this._ref.radius({x:r,y:s}),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(t=>{const e=this._ref.getStage().getAbsoluteTransform(),i=e.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(i));const n=e.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(n));const r=e.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(r))})),this._ref.on("dragend",(t=>{const e=this._ref.getStage().getAbsoluteTransform(),i=e.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(i));const n=e.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(n));const r=e.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(r))})),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t,y:e}))}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t,y:this._ref.y()}))}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(t),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t}))}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsPosition")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusX")),i=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusY"));let n=this._ref.getStage().getAbsoluteTransform().copy();n=n.invert();const r=n.point({x:t.x,y:t.y});this._ref.position({x:r.x,y:r.y}),this._ref.radius({x:Math.abs(n.point(e).x-r.x),y:Math.abs(n.point(i).y-r.y)})}}class my{constructor(t,e=null,i=new ay){var n,r;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");return t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.points()[0],y:e.points()[1]})),void(i||this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:e.points()[2],y:e.points()[3]})))}t||(t={}),t.start||(t.start={x:0,y:0}),t.end||(t.end={x:100,y:100}),this._ref=new sy.Arrow({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.start.x,y:t.start.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.end.x,y:t.end.y})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.points(),n=this._ref.getAbsoluteTransform(),r=n.point({x:i[0],y:i[1]}),s=n.point({x:i[2],y:i[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(r)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(s))})),this._ref.on("dragend",(t=>{const e=this._ref.points(),i=t.target.getAbsoluteTransform(),n=i.point({x:e[0],y:e[1]}),r=i.point({x:e[2],y:e[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(n)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(r))})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&(this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t[0].x,y:t[0].y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t[1].x,y:t[1].y})),this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y]))}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]]),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e]),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t,y:e}))}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getAbsoluteTransform().copy();i=i.invert();const n=i.point({x:t.x,y:t.y}),r=i.point({x:e.x,y:e.y});this._ref.points([n.x,n.y,r.x,r.y])}}class fy{constructor(t,e=null,i=new ay){var n,r;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_HEADER_START="data:image/",this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",this._worldTransformer=i,e){e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width();const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}}else t||(t={}),t.position||(t.position={x:0,y:0}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),t.position2&&(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}const e=this._worldTransformer.screenToWorld({x:t.position.x+this._ref.width(),y:t.position.y+this._ref.height()});this._ref.setAttr("wcsEnd",e)},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new sy.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(n=t.width)&&void 0!==n?n:0,height:null!==(r=t.height)&&void 0!==r?r:0,draggable:!0}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(r),this._ref.height(r*this._ratio)):(this._ref.width(s/this._ratio),this._ref.height(s)):(i&&this._ref.width(r),n&&this._ref.height(s)),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(t=>{const e=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(e)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:e.x+this._ref.width(),y:e.y+this._ref.height()}))})),this._ref.on("dragend",(t=>{const e=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(e)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:e.x+this._ref.width(),y:e.y+this._ref.height()}))})),this._ref.id(this._ref._id.toString())}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),r=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(r.x-n.x)),this._ref.height(Math.abs(r.y-n.y))}}class gy{constructor(t,e=null,i=new ay){var n,r,s,a;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200);this._ref=new sy.Shape({x:t.position.x,y:t.position.y,width:null!==(n=t.width)&&void 0!==n?n:200,height:null!==(r=t.height)&&void 0!==r?r:200,stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:null!==(a=t.lineWidth)&&void 0!==a?a:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=this._ref.width(),n=this._ref.height(),r=[{x:0,y:0},{x:0+i,y:0},{x:0+i,y:0+n},{x:0,y:0+n},{x:0,y:0}];function s(s,a){const o={x:(h={x:0,y:0}).x+i/2,y:h.y+n/2};var h;t.beginPath();for(let e=0;e<r.length-1;e++){let i=a;const n=r[e+1].x-r[e].x,h=r[e+1].y-r[e].y,l=Math.sqrt(n*n+h*h),c=Math.floor(l/i);i=a+c/(l%i);let d=r[e].x+n/c/2,u=r[e].y+h/c/2;const p=r[e+1].x,m=r[e+1].y,f=Math.atan((m-u)/(p-d)),g=f+Math.PI,v=d>o.x&&u>o.y;for(let e=0;e<c;e++)v?t.arc(d,u,s,f,g):t.arc(d,u,s,g,f),d+=n/c,u+=h/c}t.closePath(),t.fillStrokeShape(e)}i>=49||n>=49?s(8,15):i>=25||n>=25?s(4,7.5):(t.beginPath(),t.lineTo(r[1].x,r[1].y),t.lineTo(r[2].x,r[2].y),t.lineTo(r[3].x,r[3].y),t.lineTo(r[4].x,r[4].y),t.closePath(),t.fillStrokeShape(e))}}),this._ref.className="Cloud",this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",(t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY),r<50&&(r=50),s<50&&(s=50),i&&this._ref.width(r),n&&this._ref.height(s),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))})),this._ref.on("dragend",(t=>{const e=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(e)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:e.x+this._ref.width(),y:e.y+this._ref.height()}))})),this._ref.getSelfRect=()=>({x:-8,y:-8,width:this._ref.width()+16,height:this._ref.height()+16}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeigth(){return this._ref.height()}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),r=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(r.x-n.x)),this._ref.height(Math.abs(r.y-n.y))}}const vy={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null,...i)=>new ly(e,t,...i)},Text:{name:"Text",initializer:(t,e=null,...i)=>new cy(e,t,...i)},Rectangle:{name:"Rect",initializer:(t,e=null,...i)=>new dy(e,t,...i)},Ellipse:{name:"Ellipse",initializer:(t,e=null,...i)=>new py(e,t,...i)},Arrow:{name:"Arrow",initializer:(t,e=null,...i)=>new my(e,t,...i)},Image:{name:"Image",initializer:(t,e=null,...i)=>new fy(e,t,...i)},Cloud:{name:"Cloud",initializer:(t,e=null,...i)=>new gy(e,t,...i)}};class _y{constructor(){this._markupIsActive=!1,this._markupColor=new oy(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=t=>{if(!t||!t[0]||!t[0].contentRect)return;const{width:e,height:i}=t[0].contentRect;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i),this.getObjects().forEach((t=>{t.updateScreenCoordinates()})))},this.resizeViewer=t=>{const{width:e,height:i}=t;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i),this.getObjects().forEach((t=>{t.updateScreenCoordinates()})))},this.pan=t=>{this.getObjects().forEach((t=>{t.updateScreenCoordinates()}))},this.zoomAt=t=>{this.getObjects().forEach((t=>{t.updateScreenCoordinates()}))},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const i=e.getAbsoluteTransform().copy();return i.invert(),i.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,i,n){if(!sy)throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');this._viewer=i,this._worldTransformer=null!=n?n:new ay,this._container=t,this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";this._container.parentElement.appendChild(this._markupContainer),i?this._viewer.addEventListener("resize",this.resizeViewer):this._resizeObserver=new ResizeObserver(function(t,e){let i=null;return(...n)=>{i&&clearTimeout(i),i=setTimeout((()=>{i=null,t(...n)}),e)}}(this.resizeContainer,100)),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),this.destroyKonva(),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach((t=>t.delete()))}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i),this.redirectToViewer({type:"changemarkupcolor",data:{r:t,g:e,b:i}})}colorizeAllMarkup(t,e,i){this.setMarkupColor(t,e,i);const n=new oy(t,e,i).asHex();this.getObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,n)}))}colorizeSelectedMarkups(t,e,i){const n=new oy(t,e,i).asHex();this.getSelectedObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,n)}))}setViewpoint(t){var e,i,n,r,s,a,o,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach((t=>{const e=[];t.points.forEach((t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)})),this.addLine(e,t.color,t.type,t.width,t.id)})),null===(n=t.texts)||void 0===n||n.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)})),null===(r=t.rectangles)||void 0===r||r.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addRectangle(e,i,t.width,t.height,t.line_width,t.color,t.id)})),null===(s=t.ellipses)||void 0===s||s.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null,n=t.position3?this._worldTransformer.worldToScreen(t.position3):null;this.addEllipse(e,i,n,t.radius,t.line_width,t.color,t.id)})),null===(a=t.arrows)||void 0===a||a.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)})),null===(o=t.clouds)||void 0===o||o.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addCloud(e,i,t.width,t.height,t.line_width,t.color,t.id)})),null===(h=t.images)||void 0===h||h.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addImage(e,i,t.src,t.width,t.height,t.id)}))}getViewpoint(t){return t||(t={}),t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.custom_fields={markup_color:this.getMarkupColor()},t.snapshot={data:this.combineMarkupWithDrawing()},t}enableEditMode(t){return t&&vy[t]?(this._markupMode=t,this._markupContainer.style.pointerEvents="all",this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupContainer.style.pointerEvents="none",this._markupIsActive=!1),this}createObject(t,e){const i=vy[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const n=i.initializer(null,e,this._worldTransformer);return this.addObject(n),n}getObjects(){const t=[];return Object.keys(vy).forEach((e=>{const i=vy[e];this.konvaLayerFind(e).forEach((e=>t.push(i.initializer(e,null,this._worldTransformer))))})),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map((t=>{const e=t.className,i=Object.values(vy).find((t=>t.name===e));return i?i.initializer(t,null,this._worldTransformer):null})).filter((t=>t)):[]}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map((t=>t.ref())));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=vy[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter((t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts)):[]}initializeKonva(){const t=new sy.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new sy.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new sy.Group,e.add(this._groupImages),this._groupGeometry=new sy.Group,e.add(this._groupGeometry),this._groupTexts=new sy.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new sy.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let n,r,s,a=!1;t.on("mousedown touchstart",(e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const s=this.getRelativePointerPosition(t);r=s,a=["Arrow","Cloud","Ellipse","Line","Rectangle"].some((t=>t===this._markupMode)),"Line"===this._markupMode&&(n=this.addLine([s.x,s.y,s.x,s.y]))})),t.on("mouseup touchend",(e=>{if(this._markupIsActive){if(a){const e=this.getRelativePointerPosition(t),i=r&&e.x===r.x&&e.y===r.y,n=i?r.x:Math.min(r.x,e.x),s=i?r.y:Math.min(r.y,e.y),a=i?200:Math.abs(r.x-e.x),o=i?200:Math.abs(r.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:n,y:s},null,a,o):"Ellipse"===this._markupMode?this.addEllipse({x:n,y:s},null,null,{x:a/2,y:o/2}):"Arrow"===this._markupMode?this.addArrow({x:r.x,y:r.y},{x:i?r.x+200:e.x,y:i?s:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:n,y:s},null,Math.max(100,a),Math.max(100,o)))}s=void 0,a=!1}})),t.on("mousemove touchmove",(e=>{if(!this._markupIsActive)return;if(!a)return;const i=this.getRelativePointerPosition(t),o=r&&i.x===r.x&&i.y===r.y,h=o?r.x:Math.min(r.x,i.x),l=o?r.y:Math.min(r.y,i.y),c=o?200:Math.abs(r.x-i.x),d=o?200:Math.abs(r.y-i.y);"Line"===this._markupMode?n.addPoints([{x:i.x,y:i.y}]):"Arrow"===this._markupMode?s?s.setEndPoint(i.x,i.y):s=this.addArrow({x:r.x,y:r.y},{x:i.x,y:i.y}):"Rectangle"===this._markupMode?s?(s.setPosition(h,l),s.setWidth(c),s.setHeight(d)):s=this.addRectangle({x:h,y:l},null,c,d):"Ellipse"===this._markupMode?s?(s.setPosition(h,l),s.setRadiusX(c),s.setRadiusY(d)):s=this.addEllipse({x:h,y:l},null,null,{x:c,y:d}):"Cloud"===this._markupMode&&(s?(s.setPosition(h,l),s.setWidth(Math.max(100,c)),s.setHeight(Math.max(100,d))):s=this.addCloud({x:h,y:l},null,c,d))})),t.on("click tap",(e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=this.getRelativePointerPosition(t);this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,null,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter((t=>"Cloud"===t.className||"Image"===t.className)).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const n=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,r=i.nodes().indexOf(e.target)>=0;if(n||r){if(n&&r){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(n&&!r){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])}));const o=t.container();o.tabIndex=1,o.focus(),o.addEventListener("keydown",(t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach((t=>t.delete())),void this.clearSelected()):void t.preventDefault()}))}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach((e=>{const i=e.getAttr("wcsPoints");if(!i)return;const n=new ly(null,e,this._worldTransformer),r={id:n.id(),points:i,color:n.getColor()||"#ff0000",type:n.getLineType()||this.lineType,width:n.getLineWidth()||this.lineWidth};t.push(r)})),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach((e=>{const i=this._worldTransformer.getScale(),n=e.getAttr("wcsStart"),r=this._konvaStage.getAbsoluteTransform(),s=new cy(null,e,this._worldTransformer),a={id:s.id(),position:n,text:s.getText(),text_size:.02*i.y,angle:s.getRotation(),color:s.getColor(),font_size:s.getFontSize()*r.getMatrix()[0]};t.push(a)})),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach((e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=this._worldTransformer.worldToScreen(i),s=this._worldTransformer.worldToScreen(n),a=new dy(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,width:Math.abs(r.x-s.x),height:Math.abs(r.y-s.y),line_width:a.getLineWidth(),color:a.getColor()};t.push(o)})),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach((e=>{const i=e.getAttr("wcsPosition"),n=e.getAttr("wcsRadiusX"),r=e.getAttr("wcsRadiusY"),s=this._konvaStage.getAbsoluteTransform().getMatrix()[0],a=new py(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,position3:r,radius:{x:e.getRadiusX()*s,y:e.getRadiusY()*s},line_width:a.getLineWidth(),color:a.getColor()};t.push(o)})),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach((e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=new my(null,e,this._worldTransformer),s={id:r.id(),start:i,end:n,color:r.getColor()};t.push(s)})),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach((e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=this._konvaStage.getAbsoluteTransform().getMatrix()[0],s=new fy(null,e,this._worldTransformer),a={id:s.id(),position:i,position2:n,src:s.getSrc(),width:s.getWidth()*r,height:s.getHeight()*r};t.push(a)})),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach((e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=this._worldTransformer.worldToScreen(i),s=this._worldTransformer.worldToScreen(n),a=new gy(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,width:Math.abs(r.x-s.x),height:Math.abs(r.y-s.y),line_width:a.getLineWidth(),color:a.getColor()};t.push(o)})),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,i,n,r){if(!t||0===t.length)return;const s=[];for(let e=0;e<t.length;e+=2)s.push({x:t[e],y:t[e+1]});const a=new ly({points:s,type:i||this.lineType,width:n||this.lineWidth,color:e||this._markupColor.asHex(),id:r},null,this._worldTransformer);return this.addObject(a),a}createTextInput(t,e,i,n,r){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=n,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},r&&(this._textInputRef.value=r),document.body.appendChild(this._textInputRef),setTimeout((()=>{this._textInputRef.focus()}),50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise(((e,i)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>{e(n.result)},n.onerror=t=>{i(t)}}));this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],n=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,n.toString(),0,0)},this._imageInputRef.oncancel=t=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout((()=>{this._imageInputRef.click()}),50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,n,r,s,a){var o;if(!t)return;null===(o=this.getSelectedObjects().at(0))||void 0===o||o.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(r&&r>h&&(!s||s<h)){const t=.02;s=r/(this._worldTransformer.getScale().y/t)/34}const l=new cy({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:s||this.fontSize,color:n||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(l),l}addRectangle(t,e,i,n,r,s,a){if(!t)return;const o=new dy({position:t,position2:e,width:i,height:n,lineWidth:r||this.lineWidth,color:s||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(o),o}addEllipse(t,e,i,n,r,s,a){if(!t)return;const o=new py({position:t,position2:e,position3:i,radius:n,lineWidth:r,color:s||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(o),o}addArrow(t,e,i,n){if(!t||!e)return;const r=new my({start:t,end:e,color:i||this._markupColor.asHex(),id:n},null,this._worldTransformer);return this.addObject(r),r}addCloud(t,e,i,n,r,s,a){if(!t||!i||!n)return;const o=new gy({position:t,position2:e,width:i,height:n,color:s||this._markupColor.asHex(),lineWidth:r||this.lineWidth,id:a},null,this._worldTransformer);return this.addObject(o),o}addImage(t,e,i,n,r,s){var a;if(!t||!i)return;null===(a=this.getSelectedObjects().at(0))||void 0===a||a.delete(),this.clearSelected(),this.removeImageInput();const o=new fy({position:t,position2:e,src:i,width:n,height:r,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:s},null,this._worldTransformer);return this.addObject(o),o}}"undefined"!=typeof window&&(window.THREE=_p),t.CANVAS_EVENTS=v,t.CanvasEvents=g,t.Component=class{constructor(t){this.name=""}dispose(){}},t.Dragger=class{constructor(t){this.name=""}dispose(){}},t.GLTFLoadingManager=lg,t.Loader=c,t.Markup=_y,t.ModelImpl=cg,t.Options=f,t.Viewer=class extends Tg{constructor(t){super(),this._options=new f(this),this.client=t,this.canvasEvents=v,this.canvaseventlistener=t=>this.emit(t),this.loaders=[],this.models=[],this.selected=[],this.extents=new Li,this.target=new Ci,this._activeDragger=null,this._components=[],this.renderTime=0,this.render=this.render.bind(this),this.update=this.update.bind(this),this._markup=new _y}get options(){return this._options}get draggers(){return[...Um.getDraggers().keys()]}get components(){return[...hf.getComponents().keys()]}get markup(){return this._markup}initialize(t,e){this.addEventListener("optionschange",(t=>this.syncOptions(t.data))),this.scene=new es,this.helpers=new es;const i=window.devicePixelRatio,n=t.parentElement.getBoundingClientRect(),r=n.width||1,s=n.height||1,a=r/s;this.camera=new jr(45,a,.01,1e3),this.camera.up.set(0,0,1),this.renderer=new vp({canvas:t,antialias:!0,alpha:!0,preserveDrawingBuffer:!0,powerPreference:"high-performance",logarithmicDepthBuffer:!1}),this.renderer.setPixelRatio(i),this.renderer.setSize(r,s),this.renderer.toneMapping=1,this.canvas=t,this.canvasEvents.forEach((e=>t.addEventListener(e,this.canvaseventlistener))),this._markup.initialize(this.canvas,this.canvasEvents,this,this);for(const t of hf.getComponents().keys())this._components.push(hf.createComponent(t,this));return this.syncOptions(),this.syncOverlay(),this.renderTime=performance.now(),this.render(this.renderTime),"function"==typeof e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:1,total:1})),this.emitEvent({type:"initializeprogress",data:1,loaded:1,total:1}),this.emitEvent({type:"initialize"}),Promise.resolve(this)}dispose(){return this.cancel(),this.clear(),this.emitEvent({type:"dispose"}),this.removeAllListeners(),this.setActiveDragger(),this._components.forEach((t=>t.dispose())),this._components=[],this._markup.dispose(),this.canvas&&(this.canvasEvents.forEach((t=>this.canvas.removeEventListener(t,this.canvaseventlistener))),this.canvas=void 0),this.renderer&&this.renderer.dispose(),this.helpers=void 0,this.scene=void 0,this.renderer=void 0,this.camera=void 0,this}isInitialized(){return!!this.renderer}update(t=!1){this.renderNeeded=!0,t&&this.render(performance.now()),this.emitEvent({type:"update",data:t})}render(t){var e,i;if(!this.renderNeeded)return;if(!this.renderer)return;this.renderNeeded=!1,this.renderer.setViewport(0,0,this.canvas.offsetWidth,this.canvas.offsetHeight),this.renderer.autoClear=!0,this.renderer.render(this.scene,this.camera);const n=this.renderer.clippingPlanes;this.renderer.clippingPlanes=[],this.renderer.autoClear=!1,this.renderer.render(this.helpers,this.camera),this.renderer.clippingPlanes=n,null===(i=null===(e=this._activeDragger)||void 0===e?void 0:e.updatePreview)||void 0===i||i.call(e);const r=(t-this.renderTime)/1e3;this.renderTime=t,this.emitEvent({type:"render",time:t,deltaTime:r})}loadReferences(t){return Promise.resolve(this)}async open(t,e={}){if(!this.renderer)return this;"a"!==e.mode&&"append"!==e.mode&&(this.cancel(),this.clear()),this.emitEvent({type:"open",file:t});let i=t;if(i&&"function"==typeof i.getModels){const e=await i.getModels();i=e.find((t=>t.default))||e[0]||t}if(!i)throw new Error("Format not supported");let n=e.format;n||"string"!=typeof i.type||(n=i.type.split(".").pop()),n||"string"!=typeof t||(n=t.split(".").pop()),!n&&t instanceof globalThis.File&&(n=t.name.split(".").pop());const r=Mg.createLoader(this,i,n);if(!r)throw new Error("Format not supported");this.loaders.push(r),this.emitEvent({type:"geometrystart",file:t,model:i});try{await this.loadReferences(i),await r.load(i,n,e)}catch(e){throw this.emitEvent({type:"geometryerror",data:e,file:t,model:i}),e}return this.emitEvent({type:"geometryend",file:t,model:i}),this}openGltfFile(t,e,i={}){return console.warn("Viewer.openGltfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead."),this.open(t,{...i,format:"gltf",externalFiles:e})}loadGltfFile(t,e,i={}){return console.warn("Viewer.loadGltfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead."),this.open(t,{...i,format:"gltf",externalFiles:e,mode:"append"})}cancel(){return this.loaders.forEach((t=>t.cancel())),this.emitEvent({type:"cancel"}),this}clear(){return this.renderer?(this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.loaders.forEach((t=>t.dispose())),this.loaders=[],this.models.forEach((t=>t.dispose())),this.models=[],this.helpers.clear(),this.scene.clear(),this.syncOptions(),this.syncOverlay(),this.update(!0),this.emitEvent({type:"clear"}),this):this}syncOptions(t=this.options){}syncOverlay(){this.renderer&&(this._markup.syncOverlay(),this.update())}clearOverlay(){this.renderer&&(this._markup.clearOverlay(),this.update())}clearSlices(){this.renderer&&(this.renderer.clippingPlanes=[],this.update())}getSelected(){return this.executeCommand("getSelected")}setSelected(t){this.executeCommand("setSelected",t)}clearSelected(){this.executeCommand("clearSelected")}hideSelected(){this.executeCommand("hideSelected")}isolateSelected(){this.executeCommand("isolateSelected")}showAll(){this.executeCommand("showAll")}explode(t=0){this.executeCommand("explode",t)}collect(){this.executeCommand("collect")}activeDragger(){return this._activeDragger}setActiveDragger(t=""){var e,i;if(!this._activeDragger||this._activeDragger.name!==t){const n=this._activeDragger;let r=null;this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null),this.isInitialized()&&(r=Um.createDragger(t,this),r&&(this._activeDragger=r,null===(i=(e=this._activeDragger).initialize)||void 0===i||i.call(e)));const s=this.canvas;s&&(n&&s.classList.remove(`oda-cursor-${n.name.toLowerCase()}`),r&&s.classList.add(`oda-cursor-${r.name.toLowerCase()}`)),this.emitEvent({type:"changeactivedragger",data:t}),this.update()}return this._activeDragger}resetActiveDragger(){const t=this._activeDragger;t&&(this.setActiveDragger(),this.setActiveDragger(t.name))}getComponent(t){return this._components.find((e=>e.name===t))}is3D(){return!0}screenToWorld(t){if(!this.renderer)return{x:t.x,y:t.y,z:0};const e=this.canvas.getBoundingClientRect(),i=t.x/(e.width/2)-1,n=-t.y/(e.height/2)+1,r=new Ci(i,n,-1);return r.unproject(this.camera),{x:r.x,y:r.y,z:r.z}}worldToScreen(t){if(!this.renderer)return{x:t.x,y:t.y};const e=new Ci(t.x,t.y,t.z);e.project(this.camera);const i=this.canvas.getBoundingClientRect();return{x:(e.x+1)*(i.width/2),y:(1-e.y)*(i.height/2)}}getScale(){return{x:1,y:1,z:1}}executeCommand(t,...e){return Gm.executeCommand(t,this,...e)}drawViewpoint(t){var e,i,n;if(!this.renderer)return;const r=({x:t,y:e,z:i})=>new Ci(t,e,i),s=null===(e=this._activeDragger)||void 0===e?void 0:e.name;this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.showAll(),this.explode(),(t=>{if(t){const e=2*this.extents.getBoundingSphere(new Ki).radius,i=this.renderer.getSize(new $e),n=i.x/i.y;this.camera=new fl,this.camera.top=t.field_height/2,this.camera.bottom=-t.field_height/2,this.camera.left=this.camera.bottom*n,this.camera.right=this.camera.top*n,this.camera.near=0,this.camera.far=100*e,this.camera.zoom=t.view_to_world_scale,this.camera.updateProjectionMatrix(),this.camera.up.copy(r(t.up_vector)),this.camera.position.copy(r(t.view_point)),this.camera.lookAt(r(t.direction).add(this.camera.position)),this.camera.updateMatrixWorld()}})(t.orthogonal_camera),(t=>{if(t){const e=2*this.extents.getBoundingSphere(new Ki).radius,i=this.renderer.getSize(new $e),n=i.x/i.y;this.camera=new jr,this.camera.fov=t.field_of_view,this.camera.aspect=n,this.camera.near=e/100,this.camera.far=100*e,this.camera.updateProjectionMatrix(),this.camera.up.copy(r(t.up_vector)),this.camera.position.copy(r(t.view_point)),this.camera.lookAt(r(t.direction).add(this.camera.position)),this.camera.updateMatrixWorld()}})(t.perspective_camera),(t=>{null==t||t.forEach((t=>{const e=new Js;e.setFromNormalAndCoplanarPoint(r(t.direction),r(t.location)),this.renderer.clippingPlanes.push(e)}))})(t.clipping_planes),(t=>{t&&this.setSelected(t.map((t=>t.handle)))})(t.selection),this._markup.setViewpoint(t),this.target=r(null!==(n=null===(i=t.custom_fields)||void 0===i?void 0:i.camera_target)&&void 0!==n?n:this.target),this.setActiveDragger(s),this.emitEvent({type:"drawviewpoint",data:t}),this.update()}createViewpoint(){if(!this.renderer)return{};const t=({x:t,y:e,z:i})=>({x:t,y:e,z:i}),e={custom_fields:{}};return e.orthogonal_camera=(()=>this.camera.isOrthographicCamera?{view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new Ci)),up_vector:t(this.camera.up),field_width:this.camera.right-this.camera.left,field_height:this.camera.top-this.camera.bottom,view_to_world_scale:this.camera.zoom}:void 0)(),e.perspective_camera=(()=>this.camera.isPerspectiveCamera?{view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new Ci)),up_vector:t(this.camera.up),field_of_view:this.camera.fov}:void 0)(),e.clipping_planes=(()=>{const e=[];return this.renderer.clippingPlanes.forEach((i=>{const n={location:t(i.coplanarPoint(new Ci)),direction:t(i.normal)};e.push(n)})),e})(),e.selection=(()=>this.getSelected().map((t=>({handle:t}))))(),e.description=(new Date).toDateString(),this._markup.getViewpoint(e),e.custom_fields.camera_target=t(this.target),this.emitEvent({type:"createviewpoint",data:e}),e}},t.commands=Gm,t.commandsRegistry=n,t.components=hf,t.componentsRegistry=l,t.defaultOptions=m,t.draggers=Um,t.draggersRegistry=a,t.loaders=Mg,t.loadersRegistry=p}));
|
|
7
|
+
function Uc(){let t=null,e=!1,i=null,n=null;function r(e,s){i(e,s),n=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function Fc(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(i){i.isInterleavedBufferAttribute&&(i=i.data);const n=e.get(i);n&&(t.deleteBuffer(n.buffer),e.delete(i))},update:function(i,n){if(i.isInterleavedBufferAttribute&&(i=i.data),i.isGLBufferAttribute){const t=e.get(i);return void((!t||t.version<i.version)&&e.set(i,{buffer:i.buffer,type:i.type,bytesPerElement:i.elementSize,version:i.version}))}const r=e.get(i);if(void 0===r)e.set(i,function(e,i){const n=e.array,r=e.usage,s=n.byteLength,a=t.createBuffer();let o;if(t.bindBuffer(i,a),t.bufferData(i,n,r),e.onUploadCallback(),n instanceof Float32Array)o=t.FLOAT;else if(n instanceof Uint16Array)o=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(n instanceof Int16Array)o=t.SHORT;else if(n instanceof Uint32Array)o=t.UNSIGNED_INT;else if(n instanceof Int32Array)o=t.INT;else if(n instanceof Int8Array)o=t.BYTE;else if(n instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(n instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+n);o=t.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version,size:s}}(i,n));else if(r.version<i.version){if(r.size!==i.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(e,i,n){const r=i.array,s=i.updateRanges;if(t.bindBuffer(n,e),0===s.length)t.bufferSubData(n,0,r);else{s.sort(((t,e)=>t.start-e.start));let e=0;for(let t=1;t<s.length;t++){const i=s[e],n=s[t];n.start<=i.start+i.count+1?i.count=Math.max(i.count,n.start+n.count-i.start):(++e,s[e]=n)}s.length=e+1;for(let e=0,i=s.length;e<i;e++){const i=s[e];t.bufferSubData(n,i.start*r.BYTES_PER_ELEMENT,r,i.start,i.count)}i.clearUpdateRanges()}i.onUploadCallback()}(r.buffer,i,n),r.version=i.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:_}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=_);const kc={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}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\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\t\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, roughness * 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:"struct 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 * transposeMat3( 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\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\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}\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( 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_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\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\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\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\tfloat hard_shadow = step( compare , distribution.x );\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\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\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}"},Bc={common:{diffuse:{value:new Jn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ti},alphaMap:{value:null},alphaMapTransform:{value:new ti},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ti}},envmap:{envMap:{value:null},envMapRotation:{value:new ti},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ti}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ti}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ti},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ti},normalScale:{value:new $e(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ti},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ti}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ti}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ti}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Jn(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 Jn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ti},alphaTest:{value:0},uvTransform:{value:new ti}},sprite:{diffuse:{value:new Jn(16777215)},opacity:{value:1},center:{value:new $e(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ti},alphaMap:{value:null},alphaMapTransform:{value:new ti},alphaTest:{value:0}}},zc={basic:{uniforms:Fr([Bc.common,Bc.specularmap,Bc.envmap,Bc.aomap,Bc.lightmap,Bc.fog]),vertexShader:kc.meshbasic_vert,fragmentShader:kc.meshbasic_frag},lambert:{uniforms:Fr([Bc.common,Bc.specularmap,Bc.envmap,Bc.aomap,Bc.lightmap,Bc.emissivemap,Bc.bumpmap,Bc.normalmap,Bc.displacementmap,Bc.fog,Bc.lights,{emissive:{value:new Jn(0)}}]),vertexShader:kc.meshlambert_vert,fragmentShader:kc.meshlambert_frag},phong:{uniforms:Fr([Bc.common,Bc.specularmap,Bc.envmap,Bc.aomap,Bc.lightmap,Bc.emissivemap,Bc.bumpmap,Bc.normalmap,Bc.displacementmap,Bc.fog,Bc.lights,{emissive:{value:new Jn(0)},specular:{value:new Jn(1118481)},shininess:{value:30}}]),vertexShader:kc.meshphong_vert,fragmentShader:kc.meshphong_frag},standard:{uniforms:Fr([Bc.common,Bc.envmap,Bc.aomap,Bc.lightmap,Bc.emissivemap,Bc.bumpmap,Bc.normalmap,Bc.displacementmap,Bc.roughnessmap,Bc.metalnessmap,Bc.fog,Bc.lights,{emissive:{value:new Jn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:kc.meshphysical_vert,fragmentShader:kc.meshphysical_frag},toon:{uniforms:Fr([Bc.common,Bc.aomap,Bc.lightmap,Bc.emissivemap,Bc.bumpmap,Bc.normalmap,Bc.displacementmap,Bc.gradientmap,Bc.fog,Bc.lights,{emissive:{value:new Jn(0)}}]),vertexShader:kc.meshtoon_vert,fragmentShader:kc.meshtoon_frag},matcap:{uniforms:Fr([Bc.common,Bc.bumpmap,Bc.normalmap,Bc.displacementmap,Bc.fog,{matcap:{value:null}}]),vertexShader:kc.meshmatcap_vert,fragmentShader:kc.meshmatcap_frag},points:{uniforms:Fr([Bc.points,Bc.fog]),vertexShader:kc.points_vert,fragmentShader:kc.points_frag},dashed:{uniforms:Fr([Bc.common,Bc.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:kc.linedashed_vert,fragmentShader:kc.linedashed_frag},depth:{uniforms:Fr([Bc.common,Bc.displacementmap]),vertexShader:kc.depth_vert,fragmentShader:kc.depth_frag},normal:{uniforms:Fr([Bc.common,Bc.bumpmap,Bc.normalmap,Bc.displacementmap,{opacity:{value:1}}]),vertexShader:kc.meshnormal_vert,fragmentShader:kc.meshnormal_frag},sprite:{uniforms:Fr([Bc.sprite,Bc.fog]),vertexShader:kc.sprite_vert,fragmentShader:kc.sprite_frag},background:{uniforms:{uvTransform:{value:new ti},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:kc.background_vert,fragmentShader:kc.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ti}},vertexShader:kc.backgroundCube_vert,fragmentShader:kc.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:kc.cube_vert,fragmentShader:kc.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:kc.equirect_vert,fragmentShader:kc.equirect_frag},distanceRGBA:{uniforms:Fr([Bc.common,Bc.displacementmap,{referencePosition:{value:new Ci},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:kc.distanceRGBA_vert,fragmentShader:kc.distanceRGBA_frag},shadow:{uniforms:Fr([Bc.lights,Bc.fog,{color:{value:new Jn(0)},opacity:{value:1}}]),vertexShader:kc.shadow_vert,fragmentShader:kc.shadow_frag}};zc.physical={uniforms:Fr([zc.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ti},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ti},clearcoatNormalScale:{value:new $e(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ti},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ti},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ti},sheen:{value:0},sheenColor:{value:new Jn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ti},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ti},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ti},transmissionSamplerSize:{value:new $e},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ti},attenuationDistance:{value:0},attenuationColor:{value:new Jn(0)},specularColor:{value:new Jn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ti},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ti},anisotropyVector:{value:new $e},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ti}}]),vertexShader:kc.meshphysical_vert,fragmentShader:kc.meshphysical_frag};const Gc={r:0,b:0,g:0},Hc=new fn,Vc=new sn;function Wc(t,e,i,n,r,s,a){const o=new Jn(0);let h,l,c=!0===s?0:1,d=null,u=0,p=null;function m(t){let n=!0===t.isScene?t.background:null;if(n&&n.isTexture){n=(t.backgroundBlurriness>0?i:e).get(n)}return n}function f(e,i){e.getRGB(Gc,kr(t)),n.buffers.color.setClear(Gc.r,Gc.g,Gc.b,i,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),c=e,f(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(t){c=t,f(o,c)},render:function(e){let i=!1;const r=m(e);null===r?f(o,c):r&&r.isColor&&(f(r,1),i=!0);const s=t.xr.getEnvironmentBlendMode();"additive"===s?n.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===s&&n.buffers.color.setClear(0,0,0,0,a),(t.autoClear||i)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,i){const n=m(i);n&&(n.isCubeTexture||n.mapping===nt)?(void 0===l&&(l=new Dr(new Nr(1,1,1),new zr({name:"BackgroundCubeMaterial",uniforms:Ur(zc.backgroundCube.uniforms),vertexShader:zc.backgroundCube.vertexShader,fragmentShader:zc.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),Hc.copy(i.backgroundRotation),Hc.x*=-1,Hc.y*=-1,Hc.z*=-1,n.isCubeTexture&&!1===n.isRenderTargetTexture&&(Hc.y*=-1,Hc.z*=-1),l.material.uniforms.envMap.value=n,l.material.uniforms.flipEnvMap.value=n.isCubeTexture&&!1===n.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=i.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Vc.makeRotationFromEuler(Hc)),l.material.toneMapped=ui.getTransfer(n.colorSpace)!==Ae,d===n&&u===n.version&&p===t.toneMapping||(l.material.needsUpdate=!0,d=n,u=n.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null)):n&&n.isTexture&&(void 0===h&&(h=new Dr(new rh(2,2),new zr({name:"BackgroundMaterial",uniforms:Ur(zc.background.uniforms),vertexShader:zc.background.vertexShader,fragmentShader:zc.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=n,h.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,h.material.toneMapped=ui.getTransfer(n.colorSpace)!==Ae,!0===n.matrixAutoUpdate&&n.updateMatrix(),h.material.uniforms.uvTransform.value.copy(n.matrix),d===n&&u===n.version&&p===t.toneMapping||(h.material.needsUpdate=!0,d=n,u=n.version,p=t.toneMapping),h.layers.enableAll(),e.unshift(h,h.geometry,h.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==h&&(h.geometry.dispose(),h.material.dispose(),h=void 0)}}}function jc(t,e){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),n={},r=l(null);let s=r,a=!1;function o(e){return t.bindVertexArray(e)}function h(e){return t.deleteVertexArray(e)}function l(t){const e=[],n=[],r=[];for(let t=0;t<i;t++)e[t]=0,n[t]=0,r[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:n,attributeDivisors:r,object:t,attributes:{},index:null}}function c(){const t=s.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function d(t){u(t,0)}function u(e,i){const n=s.newAttributes,r=s.enabledAttributes,a=s.attributeDivisors;n[e]=1,0===r[e]&&(t.enableVertexAttribArray(e),r[e]=1),a[e]!==i&&(t.vertexAttribDivisor(e,i),a[e]=i)}function p(){const e=s.newAttributes,i=s.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function m(e,i,n,r,s,a,o){!0===o?t.vertexAttribIPointer(e,i,n,s,a):t.vertexAttribPointer(e,i,n,r,s,a)}function f(){g(),a=!0,s!==r&&(s=r,o(s.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(i,r,h,f,g){let v=!1;const _=function(e,i,r){const s=!0===r.wireframe;let a=n[e.id];void 0===a&&(a={},n[e.id]=a);let o=a[i.id];void 0===o&&(o={},a[i.id]=o);let h=o[s];void 0===h&&(h=l(t.createVertexArray()),o[s]=h);return h}(f,h,r);s!==_&&(s=_,o(s.object)),v=function(t,e,i,n){const r=s.attributes,a=e.attributes;let o=0;const h=i.getAttributes();for(const e in h){if(h[e].location>=0){const i=r[e];let n=a[e];if(void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor)),void 0===i)return!0;if(i.attribute!==n)return!0;if(n&&i.data!==n.data)return!0;o++}}return s.attributesNum!==o||s.index!==n}(i,f,h,g),v&&function(t,e,i,n){const r={},a=e.attributes;let o=0;const h=i.getAttributes();for(const e in h){if(h[e].location>=0){let i=a[e];void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor));const n={};n.attribute=i,i&&i.data&&(n.data=i.data),r[e]=n,o++}}s.attributes=r,s.attributesNum=o,s.index=n}(i,f,h,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(v||a)&&(a=!1,function(i,n,r,s){c();const a=s.attributes,o=r.getAttributes(),h=n.defaultAttributeValues;for(const n in o){const r=o[n];if(r.location>=0){let o=a[n];if(void 0===o&&("instanceMatrix"===n&&i.instanceMatrix&&(o=i.instanceMatrix),"instanceColor"===n&&i.instanceColor&&(o=i.instanceColor)),void 0!==o){const n=o.normalized,a=o.itemSize,h=e.get(o);if(void 0===h)continue;const l=h.buffer,c=h.type,p=h.bytesPerElement,f=c===t.INT||c===t.UNSIGNED_INT||o.gpuType===vt;if(o.isInterleavedBufferAttribute){const e=o.data,h=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t<r.locationSize;t++)u(r.location+t,e.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,l);for(let t=0;t<r.locationSize;t++)m(r.location+t,a/r.locationSize,c,n,h*p,(g+a/r.locationSize*t)*p,f)}else{if(o.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)u(r.location+t,o.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,l);for(let t=0;t<r.locationSize;t++)m(r.location+t,a/r.locationSize,c,n,a*p,a/r.locationSize*t*p,f)}}else if(void 0!==h){const e=h[n];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(r.location,e);break;case 3:t.vertexAttrib3fv(r.location,e);break;case 4:t.vertexAttrib4fv(r.location,e);break;default:t.vertexAttrib1fv(r.location,e)}}}}p()}(i,r,h,f),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:f,resetDefaultState:g,dispose:function(){f();for(const t in n){const e=n[t];for(const t in e){const i=e[t];for(const t in i)h(i[t].object),delete i[t];delete e[t]}delete n[t]}},releaseStatesOfGeometry:function(t){if(void 0===n[t.id])return;const e=n[t.id];for(const t in e){const i=e[t];for(const t in i)h(i[t].object),delete i[t];delete e[t]}delete n[t.id]},releaseStatesOfProgram:function(t){for(const e in n){const i=n[e];if(void 0===i[t.id])continue;const r=i[t.id];for(const t in r)h(r[t].object),delete r[t];delete i[t.id]}},initAttributes:c,enableAttribute:d,disableUnusedAttributes:p}}function Xc(t,e,i){let n;function r(e,r,s){0!==s&&(t.drawArraysInstanced(n,e,r,s),i.update(r,n,s))}this.setMode=function(t){n=t},this.render=function(e,r){t.drawArrays(n,e,r),i.update(r,n,1)},this.renderInstances=r,this.renderMultiDraw=function(t,r,s){if(0===s)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,t,0,r,0,s);let a=0;for(let t=0;t<s;t++)a+=r[t];i.update(a,n,1)},this.renderMultiDrawInstances=function(t,s,a,o){if(0===a)return;const h=e.get("WEBGL_multi_draw");if(null===h)for(let e=0;e<t.length;e++)r(t[e],s[e],o[e]);else{h.multiDrawArraysInstancedWEBGL(n,t,0,s,0,o,0,a);let e=0;for(let t=0;t<a;t++)e+=s[t]*o[t];i.update(e,n,1)}}}function Yc(t,e,i,n){let r;function s(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==i.precision?i.precision:"highp";const o=s(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const h=!0===i.logarithmicDepthBuffer,l=!0===i.reverseDepthBuffer&&e.has("EXT_clip_control"),c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),d=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(e){return e===At||n.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(i){const r=i===xt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(i!==pt&&n.convert(i)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&i!==yt&&!r)},precision:a,logarithmicDepthBuffer:h,reverseDepthBuffer:l,maxTextures:c,maxVertexTextures:d,maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:d>0,maxSamples:t.getParameter(t.MAX_SAMPLES)}}function qc(t){const e=this;let i=null,n=0,r=!1,s=!1;const a=new Js,o=new ti,h={value:null,needsUpdate:!1};function l(t,i,n,r){const s=null!==t?t.length:0;let l=null;if(0!==s){if(l=h.value,!0!==r||null===l){const e=n+4*s,r=i.matrixWorldInverse;o.getNormalMatrix(r),(null===l||l.length<e)&&(l=new Float32Array(e));for(let e=0,i=n;e!==s;++e,i+=4)a.copy(t[e]).applyMatrix4(r,o),a.normal.toArray(l,i),l[i+3]=a.constant}h.value=l,h.needsUpdate=!0}return e.numPlanes=s,e.numIntersection=0,l}this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const i=0!==t.length||e||0!==n||r;return r=e,n=t.length,i},this.beginShadows=function(){s=!0,l(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(t,e){i=l(t,e,0)},this.setState=function(a,o,c){const d=a.clippingPlanes,u=a.clipIntersection,p=a.clipShadows,m=t.get(a);if(!r||null===d||0===d.length||s&&!p)s?l(null):function(){h.value!==i&&(h.value=i,h.needsUpdate=n>0);e.numPlanes=n,e.numIntersection=0}();else{const t=s?0:n,e=4*t;let r=m.clippingState||null;h.value=r,r=l(d,o,e,c);for(let t=0;t!==e;++t)r[t]=i[t];m.clippingState=r,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=t}}}function Kc(t){let e=new WeakMap;function i(t,e){return e===et?t.mapping=$:e===it&&(t.mapping=tt),t}function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(s===et||s===it){if(e.has(r)){return i(e.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=new Kr(s.height);return a.fromEquirectangularTexture(t,r),e.set(r,a),r.addEventListener("dispose",n),i(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}const Zc=[.125,.215,.35,.446,.526,.582],Jc=20,Qc=new fl,$c=new Jn;let td=null,ed=0,id=0,nd=!1;const rd=(1+Math.sqrt(5))/2,sd=1/rd,ad=[new Ci(-rd,sd,0),new Ci(rd,sd,0),new Ci(-sd,0,rd),new Ci(sd,0,rd),new Ci(0,rd,-sd),new Ci(0,rd,sd),new Ci(-1,1,-1),new Ci(1,1,-1),new Ci(-1,1,1),new Ci(1,1,1)];class od{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,i=.1,n=100){td=this._renderer.getRenderTarget(),ed=this._renderer.getActiveCubeFace(),id=this._renderer.getActiveMipmapLevel(),nd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,i,n,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=dd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=cd(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(td,ed,id),this._renderer.xr.enabled=nd,t.scissorTest=!1,ld(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===$||t.mapping===tt?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),td=this._renderer.getRenderTarget(),ed=this._renderer.getActiveCubeFace(),id=this._renderer.getActiveMipmapLevel(),nd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:ct,minFilter:ct,generateMipmaps:!1,type:xt,format:At,colorSpace:Te,depthBuffer:!1},n=hd(t,e,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=hd(t,e,i);const{_lodMax:n}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(t){const e=[],i=[],n=[];let r=t;const s=t-4+1+Zc.length;for(let a=0;a<s;a++){const s=Math.pow(2,r);i.push(s);let o=1/s;a>t-4?o=Zc[a-t+4-1]:0===a&&(o=0),n.push(o);const h=1/(s-2),l=-h,c=1+h,d=[l,l,c,l,c,c,l,l,c,c,l,c],u=6,p=6,m=3,f=2,g=1,v=new Float32Array(m*p*u),_=new Float32Array(f*p*u),y=new Float32Array(g*p*u);for(let t=0;t<u;t++){const e=t%3*2/3-1,i=t>2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];v.set(n,m*p*t),_.set(d,f*p*t);const r=[t,t,t,t,t,t];y.set(r,g*p*t)}const x=new br;x.setAttribute("position",new cr(v,m)),x.setAttribute("uv",new cr(_,f)),x.setAttribute("faceIndex",new cr(y,g)),e.push(x),r>4&&r--}return{lodPlanes:e,sizeLods:i,sigmas:n}}(n)),this._blurMaterial=function(t,e,i){const n=new Float32Array(Jc),r=new Ci(0,1,0),s=new zr({name:"SphericalGaussianBlur",defines:{n:Jc,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:ud(),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 s}(n,t,e)}return n}_compileMaterial(t){const e=new Dr(this._lodPlanes[0],t);this._renderer.compile(e,Qc)}_sceneToCubeUV(t,e,i,n){const r=new jr(90,1,e,i),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,h=o.autoClear,l=o.toneMapping;o.getClearColor($c),o.toneMapping=0,o.autoClear=!1;const c=new er({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),d=new Dr(new Nr,c);let u=!1;const p=t.background;p?p.isColor&&(c.color.copy(p),t.background=null,u=!0):(c.color.copy($c),u=!0);for(let e=0;e<6;e++){const i=e%3;0===i?(r.up.set(0,s[e],0),r.lookAt(a[e],0,0)):1===i?(r.up.set(0,0,s[e]),r.lookAt(0,a[e],0)):(r.up.set(0,s[e],0),r.lookAt(0,0,a[e]));const h=this._cubeSize;ld(n,i*h,e>2?h:0,h,h),o.setRenderTarget(n),u&&o.render(d,r),o.render(t,r)}d.geometry.dispose(),d.material.dispose(),o.toneMapping=l,o.autoClear=h,t.background=p}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===$||t.mapping===tt;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=dd()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=cd());const r=n?this._cubemapMaterial:this._equirectMaterial,s=new Dr(this._lodPlanes[0],r);r.uniforms.envMap.value=t;const a=this._cubeSize;ld(e,0,0,3*a,2*a),i.setRenderTarget(e),i.render(s,Qc)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;const n=this._lodPlanes.length;for(let e=1;e<n;e++){const i=Math.sqrt(this._sigmas[e]*this._sigmas[e]-this._sigmas[e-1]*this._sigmas[e-1]),r=ad[(n-e-1)%ad.length];this._blur(t,e-1,e,i,r)}e.autoClear=i}_blur(t,e,i,n,r){const s=this._pingPongRenderTarget;this._halfBlur(t,s,e,i,n,"latitudinal",r),this._halfBlur(s,t,i,i,n,"longitudinal",r)}_halfBlur(t,e,i,n,r,s,a){const o=this._renderer,h=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&console.error("blur direction must be either latitudinal or longitudinal!");const l=new Dr(this._lodPlanes[n],h),c=h.uniforms,d=this._sizeLods[i]-1,u=isFinite(r)?Math.PI/(2*d):2*Math.PI/39,p=r/u,m=isFinite(r)?1+Math.floor(3*p):Jc;m>Jc&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let t=0;t<Jc;++t){const e=t/p,i=Math.exp(-e*e/2);f.push(i),0===t?g+=i:t<m&&(g+=2*i)}for(let t=0;t<f.length;t++)f[t]=f[t]/g;c.envMap.value=t.texture,c.samples.value=m,c.weights.value=f,c.latitudinal.value="latitudinal"===s,a&&(c.poleAxis.value=a);const{_lodMax:v}=this;c.dTheta.value=u,c.mipInt.value=v-i;const _=this._sizeLods[n];ld(e,3*_*(n>v-4?n-v+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(e),o.render(l,Qc)}}function hd(t,e,i){const n=new Mi(t,e,i);return n.texture.mapping=nt,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ld(t,e,i,n,r){t.viewport.set(e,i,n,r),t.scissor.set(e,i,n,r)}function cd(){return new zr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ud(),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 dd(){return new zr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ud(),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 ud(){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 pd(t){let e=new WeakMap,i=null;function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===et||s===it,o=s===$||s===tt;if(a||o){let s=e.get(r);const h=void 0!==s?s.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==h)return null===i&&(i=new od(t)),s=a?i.fromEquirectangular(r,s):i.fromCubemap(r,s),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),s.texture;if(void 0!==s)return s.texture;{const h=r.image;return a&&h&&h.height>0||o&&h&&function(t){let e=0;const i=6;for(let n=0;n<i;n++)void 0!==t[n]&&e++;return e===i}(h)?(null===i&&(i=new od(t)),s=a?i.fromEquirectangular(r):i.fromCubemap(r),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),r.addEventListener("dispose",n),s.texture):null}}}return r},dispose:function(){e=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function md(t){const e={};function i(i){if(void 0!==e[i])return e[i];let n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=t.getExtension(i)}return e[i]=n,n}return{has:function(t){return null!==i(t)},init:function(){i("EXT_color_buffer_float"),i("WEBGL_clip_cull_distance"),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture"),i("WEBGL_render_shared_exponent")},get:function(t){const e=i(t);return null===e&&hi("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function fd(t,e,i,n){const r={},s=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);o.removeEventListener("dispose",a),delete r[o.id];const h=s.get(o);h&&(e.remove(h),s.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(t){const i=[],n=t.index,r=t.attributes.position;let a=0;if(null!==n){const t=n.array;a=n.version;for(let e=0,n=t.length;e<n;e+=3){const n=t[e+0],r=t[e+1],s=t[e+2];i.push(n,r,r,s,s,n)}}else{if(void 0===r)return;{const t=r.array;a=r.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,r=e+2;i.push(t,n,n,r,r,t)}}}const o=new(ii(i)?ur:dr)(i,1);o.version=a;const h=s.get(t);h&&e.remove(h),s.set(t,o)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",a),r[e.id]=!0,i.memory.geometries++),e},update:function(i){const n=i.attributes;for(const i in n)e.update(n[i],t.ARRAY_BUFFER)},getWireframeAttribute:function(t){const e=s.get(t);if(e){const i=t.index;null!==i&&e.version<i.version&&o(t)}else o(t);return s.get(t)}}}function gd(t,e,i){let n,r,s;function a(e,a,o){0!==o&&(t.drawElementsInstanced(n,a,r,e*s,o),i.update(a,n,o))}this.setMode=function(t){n=t},this.setIndex=function(t){r=t.type,s=t.bytesPerElement},this.render=function(e,a){t.drawElements(n,a,r,e*s),i.update(a,n,1)},this.renderInstances=a,this.renderMultiDraw=function(t,s,a){if(0===a)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,s,0,r,t,0,a);let o=0;for(let t=0;t<a;t++)o+=s[t];i.update(o,n,1)},this.renderMultiDrawInstances=function(t,o,h,l){if(0===h)return;const c=e.get("WEBGL_multi_draw");if(null===c)for(let e=0;e<t.length;e++)a(t[e]/s,o[e],l[e]);else{c.multiDrawElementsInstancedWEBGL(n,o,0,r,t,0,l,0,h);let e=0;for(let t=0;t<h;t++)e+=o[t]*l[t];i.update(e,n,1)}}}function vd(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(i,n,r){switch(e.calls++,n){case t.TRIANGLES:e.triangles+=r*(i/3);break;case t.LINES:e.lines+=r*(i/2);break;case t.LINE_STRIP:e.lines+=r*(i-1);break;case t.LINE_LOOP:e.lines+=r*i;break;case t.POINTS:e.points+=r*i;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function _d(t,e,i){const n=new WeakMap,r=new wi;return{update:function(s,a,o){const h=s.morphTargetInfluences,l=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,c=void 0!==l?l.length:0;let d=n.get(a);if(void 0===d||d.count!==c){void 0!==d&&d.texture.dispose();const u=void 0!==a.morphAttributes.position,p=void 0!==a.morphAttributes.normal,m=void 0!==a.morphAttributes.color,f=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],v=a.morphAttributes.color||[];let _=0;!0===u&&(_=1),!0===p&&(_=2),!0===m&&(_=3);let y=a.attributes.position.count*_,x=1;y>e.maxTextureSize&&(x=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const b=new Float32Array(y*x*4*c),w=new Ti(b,y,x,c);w.type=yt,w.needsUpdate=!0;const S=4*_;for(let T=0;T<c;T++){const E=f[T],A=g[T],C=v[T],R=y*x*4*T;for(let P=0;P<E.count;P++){const L=P*S;!0===u&&(r.fromBufferAttribute(E,P),b[R+L+0]=r.x,b[R+L+1]=r.y,b[R+L+2]=r.z,b[R+L+3]=0),!0===p&&(r.fromBufferAttribute(A,P),b[R+L+4]=r.x,b[R+L+5]=r.y,b[R+L+6]=r.z,b[R+L+7]=0),!0===m&&(r.fromBufferAttribute(C,P),b[R+L+8]=r.x,b[R+L+9]=r.y,b[R+L+10]=r.z,b[R+L+11]=4===C.itemSize?r.w:1)}}function M(){w.dispose(),n.delete(a),a.removeEventListener("dispose",M)}d={count:c,texture:w,size:new $e(y,x)},n.set(a,d),a.addEventListener("dispose",M)}if(!0===s.isInstancedMesh&&null!==s.morphTexture)o.getUniforms().setValue(t,"morphTexture",s.morphTexture,i);else{let I=0;for(let O=0;O<h.length;O++)I+=h[O];const D=a.morphTargetsRelative?1:1-I;o.getUniforms().setValue(t,"morphTargetBaseInfluence",D),o.getUniforms().setValue(t,"morphTargetInfluences",h)}o.getUniforms().setValue(t,"morphTargetsTexture",d.texture,i),o.getUniforms().setValue(t,"morphTargetsTextureSize",d.size)}}}function yd(t,e,i,n){let r=new WeakMap;function s(t){const e=t.target;e.removeEventListener("dispose",s),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update:function(a){const o=n.render.frame,h=a.geometry,l=e.get(a,h);if(r.get(l)!==o&&(e.update(l),r.set(l,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",s)&&a.addEventListener("dispose",s),r.get(a)!==o&&(i.update(a.instanceMatrix,t.ARRAY_BUFFER),null!==a.instanceColor&&i.update(a.instanceColor,t.ARRAY_BUFFER),r.set(a,o))),a.isSkinnedMesh){const t=a.skeleton;r.get(t)!==o&&(t.update(),r.set(t,o))}return l},dispose:function(){r=new WeakMap}}}const xd=new bi,bd=new Va(1,1),wd=new Ti,Sd=new Ei,Md=new qr,Td=[],Ed=[],Ad=new Float32Array(16),Cd=new Float32Array(9),Rd=new Float32Array(4);function Pd(t,e,i){const n=t[0];if(n<=0||n>0)return t;const r=e*i;let s=Td[r];if(void 0===s&&(s=new Float32Array(r),Td[r]=s),0!==e){n.toArray(s,0);for(let n=1,r=0;n!==e;++n)r+=i,t[n].toArray(s,r)}return s}function Ld(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function Id(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function Dd(t,e){let i=Ed[e];void 0===i&&(i=new Int32Array(e),Ed[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function Od(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function Nd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Ld(i,e))return;t.uniform2fv(this.addr,e),Id(i,e)}}function Ud(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(Ld(i,e))return;t.uniform3fv(this.addr,e),Id(i,e)}}function Fd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Ld(i,e))return;t.uniform4fv(this.addr,e),Id(i,e)}}function kd(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Ld(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),Id(i,e)}else{if(Ld(i,n))return;Rd.set(n),t.uniformMatrix2fv(this.addr,!1,Rd),Id(i,n)}}function Bd(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Ld(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),Id(i,e)}else{if(Ld(i,n))return;Cd.set(n),t.uniformMatrix3fv(this.addr,!1,Cd),Id(i,n)}}function zd(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Ld(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),Id(i,e)}else{if(Ld(i,n))return;Ad.set(n),t.uniformMatrix4fv(this.addr,!1,Ad),Id(i,n)}}function Gd(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function Hd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Ld(i,e))return;t.uniform2iv(this.addr,e),Id(i,e)}}function Vd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(Ld(i,e))return;t.uniform3iv(this.addr,e),Id(i,e)}}function Wd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Ld(i,e))return;t.uniform4iv(this.addr,e),Id(i,e)}}function jd(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function Xd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Ld(i,e))return;t.uniform2uiv(this.addr,e),Id(i,e)}}function Yd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(Ld(i,e))return;t.uniform3uiv(this.addr,e),Id(i,e)}}function qd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Ld(i,e))return;t.uniform4uiv(this.addr,e),Id(i,e)}}function Kd(t,e,i){const n=this.cache,r=i.allocateTextureUnit();let s;n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),this.type===t.SAMPLER_2D_SHADOW?(bd.compareFunction=515,s=bd):s=xd,i.setTexture2D(e||s,r)}function Zd(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(e||Sd,r)}function Jd(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTextureCube(e||Md,r)}function Qd(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(e||wd,r)}function $d(t,e){t.uniform1fv(this.addr,e)}function tu(t,e){const i=Pd(e,this.size,2);t.uniform2fv(this.addr,i)}function eu(t,e){const i=Pd(e,this.size,3);t.uniform3fv(this.addr,i)}function iu(t,e){const i=Pd(e,this.size,4);t.uniform4fv(this.addr,i)}function nu(t,e){const i=Pd(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function ru(t,e){const i=Pd(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function su(t,e){const i=Pd(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function au(t,e){t.uniform1iv(this.addr,e)}function ou(t,e){t.uniform2iv(this.addr,e)}function hu(t,e){t.uniform3iv(this.addr,e)}function lu(t,e){t.uniform4iv(this.addr,e)}function cu(t,e){t.uniform1uiv(this.addr,e)}function du(t,e){t.uniform2uiv(this.addr,e)}function uu(t,e){t.uniform3uiv(this.addr,e)}function pu(t,e){t.uniform4uiv(this.addr,e)}function mu(t,e,i){const n=this.cache,r=e.length,s=Dd(i,r);Ld(n,s)||(t.uniform1iv(this.addr,s),Id(n,s));for(let t=0;t!==r;++t)i.setTexture2D(e[t]||xd,s[t])}function fu(t,e,i){const n=this.cache,r=e.length,s=Dd(i,r);Ld(n,s)||(t.uniform1iv(this.addr,s),Id(n,s));for(let t=0;t!==r;++t)i.setTexture3D(e[t]||Sd,s[t])}function gu(t,e,i){const n=this.cache,r=e.length,s=Dd(i,r);Ld(n,s)||(t.uniform1iv(this.addr,s),Id(n,s));for(let t=0;t!==r;++t)i.setTextureCube(e[t]||Md,s[t])}function vu(t,e,i){const n=this.cache,r=e.length,s=Dd(i,r);Ld(n,s)||(t.uniform1iv(this.addr,s),Id(n,s));for(let t=0;t!==r;++t)i.setTexture2DArray(e[t]||wd,s[t])}class _u{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return Od;case 35664:return Nd;case 35665:return Ud;case 35666:return Fd;case 35674:return kd;case 35675:return Bd;case 35676:return zd;case 5124:case 35670:return Gd;case 35667:case 35671:return Hd;case 35668:case 35672:return Vd;case 35669:case 35673:return Wd;case 5125:return jd;case 36294:return Xd;case 36295:return Yd;case 36296:return qd;case 35678:case 36198:case 36298:case 36306:case 35682:return Kd;case 35679:case 36299:case 36307:return Zd;case 35680:case 36300:case 36308:case 36293:return Jd;case 36289:case 36303:case 36311:case 36292:return Qd}}(e.type)}}class yu{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return $d;case 35664:return tu;case 35665:return eu;case 35666:return iu;case 35674:return nu;case 35675:return ru;case 35676:return su;case 5124:case 35670:return au;case 35667:case 35671:return ou;case 35668:case 35672:return hu;case 35669:case 35673:return lu;case 5125:return cu;case 36294:return du;case 36295:return uu;case 36296:return pu;case 35678:case 36198:case 36298:case 36306:case 35682:return mu;case 35679:case 36299:case 36307:return fu;case 35680:case 36300:case 36308:case 36293:return gu;case 36289:case 36303:case 36311:case 36292:return vu}}(e.type)}}class xu{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,i){const n=this.seq;for(let r=0,s=n.length;r!==s;++r){const s=n[r];s.setValue(t,e[s.id],i)}}}const bu=/(\w+)(\])?(\[|\.)?/g;function wu(t,e){t.seq.push(e),t.map[e.id]=e}function Su(t,e,i){const n=t.name,r=n.length;for(bu.lastIndex=0;;){const s=bu.exec(n),a=bu.lastIndex;let o=s[1];const h="]"===s[2],l=s[3];if(h&&(o|=0),void 0===l||"["===l&&a+2===r){wu(i,void 0===l?new _u(o,t,e):new yu(o,t,e));break}{let t=i.map[o];void 0===t&&(t=new xu(o),wu(i,t)),i=t}}}class Mu{constructor(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);Su(i,t.getUniformLocation(e,i.name),this)}}setValue(t,e,i,n){const r=this.map[e];void 0!==r&&r.setValue(t,i,n)}setOptional(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)}static upload(t,e,i,n){for(let r=0,s=e.length;r!==s;++r){const s=e[r],a=i[s.id];!1!==a.needsUpdate&&s.setValue(t,a.value,n)}}static seqWithValue(t,e){const i=[];for(let n=0,r=t.length;n!==r;++n){const r=t[n];r.id in e&&i.push(r)}return i}}function Tu(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}let Eu=0;const Au=new ti;function Cu(t,e,i){const n=t.getShaderParameter(e,t.COMPILE_STATUS),r=t.getShaderInfoLog(e).trim();if(n&&""===r)return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const n=parseInt(s[1]);return i.toUpperCase()+"\n\n"+r+"\n\n"+function(t,e){const i=t.split("\n"),n=[],r=Math.max(e-6,0),s=Math.min(e+6,i.length);for(let t=r;t<s;t++){const r=t+1;n.push(`${r===e?">":" "} ${r}: ${i[t]}`)}return n.join("\n")}(t.getShaderSource(e),n)}return r}function Ru(t,e){const i=function(t){ui._getMatrix(Au,ui.workingColorSpace,t);const e=`mat3( ${Au.elements.map((t=>t.toFixed(4)))} )`;switch(ui.getTransfer(t)){case Ee:return[e,"LinearTransferOETF"];case Ae:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${i[1]}( vec4( value.rgb * ${i[0]}, value.a ) );`,"}"].join("\n")}function Pu(t,e){let i;switch(e){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="Cineon";break;case 4:i="ACESFilmic";break;case 6:i="AgX";break;case 7:i="Neutral";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),i="Linear"}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}const Lu=new Ci;function Iu(){ui.getLuminanceCoefficients(Lu);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${Lu.x.toFixed(4)}, ${Lu.y.toFixed(4)}, ${Lu.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function Du(t){return""!==t}function Ou(t,e){const i=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Nu(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Uu=/^[ \t]*#include +<([\w\d./]+)>/gm;function Fu(t){return t.replace(Uu,Bu)}const ku=new Map;function Bu(t,e){let i=kc[e];if(void 0===i){const t=ku.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");i=kc[t],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return Fu(i)}const zu=/#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 Gu(t){return t.replace(zu,Hu)}function Hu(t,e,i,n){let r="";for(let t=parseInt(e);t<parseInt(i);t++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function Vu(t){let e=`precision ${t.precision} float;\n\tprecision ${t.precision} int;\n\tprecision ${t.precision} sampler2D;\n\tprecision ${t.precision} samplerCube;\n\tprecision ${t.precision} sampler3D;\n\tprecision ${t.precision} sampler2DArray;\n\tprecision ${t.precision} sampler2DShadow;\n\tprecision ${t.precision} samplerCubeShadow;\n\tprecision ${t.precision} sampler2DArrayShadow;\n\tprecision ${t.precision} isampler2D;\n\tprecision ${t.precision} isampler3D;\n\tprecision ${t.precision} isamplerCube;\n\tprecision ${t.precision} isampler2DArray;\n\tprecision ${t.precision} usampler2D;\n\tprecision ${t.precision} usampler3D;\n\tprecision ${t.precision} usamplerCube;\n\tprecision ${t.precision} usampler2DArray;\n\t`;return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function Wu(t,e,i,n){const r=t.getContext(),s=i.defines;let a=i.vertexShader,o=i.fragmentShader;const h=function(t){let e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(i),l=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case $:case tt:e="ENVMAP_TYPE_CUBE";break;case nt:e="ENVMAP_TYPE_CUBE_UV"}return e}(i),c=function(t){let e="ENVMAP_MODE_REFLECTION";t.envMap&&t.envMapMode===tt&&(e="ENVMAP_MODE_REFRACTION");return e}(i),d=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(i),u=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const i=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}(i),p=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Du).join("\n")}(i),m=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(s),f=r.createProgram();let g,v,_=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(g=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m].filter(Du).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m].filter(Du).join("\n"),v.length>0&&(v+="\n")):(g=[Vu(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m,i.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",i.batching?"#define USE_BATCHING":"",i.batchingColor?"#define USE_BATCHING_COLOR":"",i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.instancingMorph?"#define USE_INSTANCING_MORPH":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","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(Du).join("\n"),v=[Vu(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+l:"",i.envMap?"#define "+c:"",i.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.dispersion?"#define USE_DISPERSION":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor||i.batchingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?kc.tonemapping_pars_fragment:"",0!==i.toneMapping?Pu("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",kc.colorspace_pars_fragment,Ru("linearToOutputTexel",i.outputColorSpace),Iu(),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(Du).join("\n")),a=Fu(a),a=Ou(a,i),a=Nu(a,i),o=Fu(o),o=Ou(o,i),o=Nu(o,i),a=Gu(a),o=Gu(o),!0!==i.isRawShaderMaterial&&(_="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",i.glslVersion===ke?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===ke?"":"#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);const y=_+g+a,x=_+v+o,b=Tu(r,r.VERTEX_SHADER,y),w=Tu(r,r.FRAGMENT_SHADER,x);function S(e){if(t.debug.checkShaderErrors){const i=r.getProgramInfoLog(f).trim(),n=r.getShaderInfoLog(b).trim(),s=r.getShaderInfoLog(w).trim();let a=!0,o=!0;if(!1===r.getProgramParameter(f,r.LINK_STATUS))if(a=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,f,b,w);else{const t=Cu(r,b,"vertex"),n=Cu(r,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(f,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+i+"\n"+t+"\n"+n)}else""!==i?console.warn("THREE.WebGLProgram: Program Info Log:",i):""!==n&&""!==s||(o=!1);o&&(e.diagnostics={runnable:a,programLog:i,vertexShader:{log:n,prefix:g},fragmentShader:{log:s,prefix:v}})}r.deleteShader(b),r.deleteShader(w),M=new Mu(r,f),T=function(t,e){const i={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const n=t.getActiveAttrib(e,r),s=n.name;let a=1;n.type===t.FLOAT_MAT2&&(a=2),n.type===t.FLOAT_MAT3&&(a=3),n.type===t.FLOAT_MAT4&&(a=4),i[s]={type:n.type,location:t.getAttribLocation(e,s),locationSize:a}}return i}(r,f)}let M,T;r.attachShader(f,b),r.attachShader(f,w),void 0!==i.index0AttributeName?r.bindAttribLocation(f,0,i.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),this.getUniforms=function(){return void 0===M&&S(this),M},this.getAttributes=function(){return void 0===T&&S(this),T};let E=!1===i.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===E&&(E=r.getProgramParameter(f,37297)),E},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(f),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=Eu++,this.cacheKey=e,this.usedTimes=1,this.program=f,this.vertexShader=b,this.fragmentShader=w,this}let ju=0;class Xu{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,i=t.fragmentShader,n=this._getShaderStage(e),r=this._getShaderStage(i),s=this._getShaderCacheForMaterial(t);return!1===s.has(n)&&(s.add(n),n.usedTimes++),!1===s.has(r)&&(s.add(r),r.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let i=e.get(t);return void 0===i&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return void 0===i&&(i=new Yu(t),e.set(t,i)),i}}class Yu{constructor(t){this.id=ju++,this.code=t,this.usedTimes=0}}function qu(t,e,i,n,r,s,a){const o=new gn,h=new Xu,l=new Set,c=[],d=r.logarithmicDepthBuffer,u=r.vertexTextures;let p=r.precision;const m={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 f(t){return l.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(s,o,c,g,v){const _=g.fog,y=v.geometry,x=s.isMeshStandardMaterial?g.environment:null,b=(s.isMeshStandardMaterial?i:e).get(s.envMap||x),w=b&&b.mapping===nt?b.image.height:null,S=m[s.type];null!==s.precision&&(p=r.getMaxPrecision(s.precision),p!==s.precision&&console.warn("THREE.WebGLProgram.getParameters:",s.precision,"not supported, using",p,"instead."));const M=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,T=void 0!==M?M.length:0;let E,A,C,R,P=0;if(void 0!==y.morphAttributes.position&&(P=1),void 0!==y.morphAttributes.normal&&(P=2),void 0!==y.morphAttributes.color&&(P=3),S){const t=zc[S];E=t.vertexShader,A=t.fragmentShader}else E=s.vertexShader,A=s.fragmentShader,h.update(s),C=h.getVertexShaderID(s),R=h.getFragmentShaderID(s);const L=t.getRenderTarget(),I=t.state.buffers.depth.getReversed(),D=!0===v.isInstancedMesh,O=!0===v.isBatchedMesh,N=!!s.map,U=!!s.matcap,F=!!b,k=!!s.aoMap,B=!!s.lightMap,z=!!s.bumpMap,G=!!s.normalMap,H=!!s.displacementMap,V=!!s.emissiveMap,W=!!s.metalnessMap,j=!!s.roughnessMap,X=s.anisotropy>0,Y=s.clearcoat>0,q=s.dispersion>0,K=s.iridescence>0,Z=s.sheen>0,J=s.transmission>0,Q=X&&!!s.anisotropyMap,$=Y&&!!s.clearcoatMap,tt=Y&&!!s.clearcoatNormalMap,et=Y&&!!s.clearcoatRoughnessMap,it=K&&!!s.iridescenceMap,rt=K&&!!s.iridescenceThicknessMap,st=Z&&!!s.sheenColorMap,at=Z&&!!s.sheenRoughnessMap,ot=!!s.specularMap,ht=!!s.specularColorMap,lt=!!s.specularIntensityMap,ct=J&&!!s.transmissionMap,dt=J&&!!s.thicknessMap,ut=!!s.gradientMap,pt=!!s.alphaMap,mt=s.alphaTest>0,ft=!!s.alphaHash,gt=!!s.extensions;let vt=0;s.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(vt=t.toneMapping));const _t={shaderID:S,shaderType:s.type,shaderName:s.name,vertexShader:E,fragmentShader:A,defines:s.defines,customVertexShaderID:C,customFragmentShaderID:R,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,batching:O,batchingColor:O&&null!==v._colorsTexture,instancing:D,instancingColor:D&&null!==v.instanceColor,instancingMorph:D&&null!==v.morphTexture,supportsVertexTextures:u,outputColorSpace:null===L?t.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:Te,alphaToCoverage:!!s.alphaToCoverage,map:N,matcap:U,envMap:F,envMapMode:F&&b.mapping,envMapCubeUVHeight:w,aoMap:k,lightMap:B,bumpMap:z,normalMap:G,displacementMap:u&&H,emissiveMap:V,normalMapObjectSpace:G&&1===s.normalMapType,normalMapTangentSpace:G&&0===s.normalMapType,metalnessMap:W,roughnessMap:j,anisotropy:X,anisotropyMap:Q,clearcoat:Y,clearcoatMap:$,clearcoatNormalMap:tt,clearcoatRoughnessMap:et,dispersion:q,iridescence:K,iridescenceMap:it,iridescenceThicknessMap:rt,sheen:Z,sheenColorMap:st,sheenRoughnessMap:at,specularMap:ot,specularColorMap:ht,specularIntensityMap:lt,transmission:J,transmissionMap:ct,thicknessMap:dt,gradientMap:ut,opaque:!1===s.transparent&&1===s.blending&&!1===s.alphaToCoverage,alphaMap:pt,alphaTest:mt,alphaHash:ft,combine:s.combine,mapUv:N&&f(s.map.channel),aoMapUv:k&&f(s.aoMap.channel),lightMapUv:B&&f(s.lightMap.channel),bumpMapUv:z&&f(s.bumpMap.channel),normalMapUv:G&&f(s.normalMap.channel),displacementMapUv:H&&f(s.displacementMap.channel),emissiveMapUv:V&&f(s.emissiveMap.channel),metalnessMapUv:W&&f(s.metalnessMap.channel),roughnessMapUv:j&&f(s.roughnessMap.channel),anisotropyMapUv:Q&&f(s.anisotropyMap.channel),clearcoatMapUv:$&&f(s.clearcoatMap.channel),clearcoatNormalMapUv:tt&&f(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:et&&f(s.clearcoatRoughnessMap.channel),iridescenceMapUv:it&&f(s.iridescenceMap.channel),iridescenceThicknessMapUv:rt&&f(s.iridescenceThicknessMap.channel),sheenColorMapUv:st&&f(s.sheenColorMap.channel),sheenRoughnessMapUv:at&&f(s.sheenRoughnessMap.channel),specularMapUv:ot&&f(s.specularMap.channel),specularColorMapUv:ht&&f(s.specularColorMap.channel),specularIntensityMapUv:lt&&f(s.specularIntensityMap.channel),transmissionMapUv:ct&&f(s.transmissionMap.channel),thicknessMapUv:dt&&f(s.thicknessMap.channel),alphaMapUv:pt&&f(s.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(G||X),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,pointsUvs:!0===v.isPoints&&!!y.attributes.uv&&(N||pt),fog:!!_,useFog:!0===s.fog,fogExp2:!!_&&_.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:d,reverseDepthBuffer:I,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:T,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:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:t.shadowMap.enabled&&c.length>0,shadowMapType:t.shadowMap.type,toneMapping:vt,decodeVideoTexture:N&&!0===s.map.isVideoTexture&&ui.getTransfer(s.map.colorSpace)===Ae,decodeVideoTextureEmissive:V&&!0===s.emissiveMap.isVideoTexture&&ui.getTransfer(s.emissiveMap.colorSpace)===Ae,premultipliedAlpha:s.premultipliedAlpha,doubleSided:2===s.side,flipSided:1===s.side,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionClipCullDistance:gt&&!0===s.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(gt&&!0===s.extensions.multiDraw||O)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};return _t.vertexUv1s=l.has(1),_t.vertexUv2s=l.has(2),_t.vertexUv3s=l.has(3),l.clear(),_t},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.customVertexShaderID),i.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(i,e),function(t,e){o.disableAll(),e.supportsVertexTextures&&o.enable(0);e.instancing&&o.enable(1);e.instancingColor&&o.enable(2);e.instancingMorph&&o.enable(3);e.matcap&&o.enable(4);e.envMap&&o.enable(5);e.normalMapObjectSpace&&o.enable(6);e.normalMapTangentSpace&&o.enable(7);e.clearcoat&&o.enable(8);e.iridescence&&o.enable(9);e.alphaTest&&o.enable(10);e.vertexColors&&o.enable(11);e.vertexAlphas&&o.enable(12);e.vertexUv1s&&o.enable(13);e.vertexUv2s&&o.enable(14);e.vertexUv3s&&o.enable(15);e.vertexTangents&&o.enable(16);e.anisotropy&&o.enable(17);e.alphaHash&&o.enable(18);e.batching&&o.enable(19);e.dispersion&&o.enable(20);e.batchingColor&&o.enable(21);t.push(o.mask),o.disableAll(),e.fog&&o.enable(0);e.useFog&&o.enable(1);e.flatShading&&o.enable(2);e.logarithmicDepthBuffer&&o.enable(3);e.reverseDepthBuffer&&o.enable(4);e.skinning&&o.enable(5);e.morphTargets&&o.enable(6);e.morphNormals&&o.enable(7);e.morphColors&&o.enable(8);e.premultipliedAlpha&&o.enable(9);e.shadowMapEnabled&&o.enable(10);e.doubleSided&&o.enable(11);e.flipSided&&o.enable(12);e.useDepthPacking&&o.enable(13);e.dithering&&o.enable(14);e.transmission&&o.enable(15);e.sheen&&o.enable(16);e.opaque&&o.enable(17);e.pointsUvs&&o.enable(18);e.decodeVideoTexture&&o.enable(19);e.decodeVideoTextureEmissive&&o.enable(20);e.alphaToCoverage&&o.enable(21);t.push(o.mask)}(i,e),i.push(t.outputColorSpace)),i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=m[t.type];let i;if(e){const t=zc[e];i=Br.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n;for(let t=0,e=c.length;t<e;t++){const e=c[t];if(e.cacheKey===i){n=e,++n.usedTimes;break}}return void 0===n&&(n=new Wu(t,i,e,s),c.push(n)),n},releaseProgram:function(t){if(0==--t.usedTimes){const e=c.indexOf(t);c[e]=c[c.length-1],c.pop(),t.destroy()}},releaseShaderCache:function(t){h.remove(t)},programs:c,dispose:function(){h.dispose()}}}function Ku(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove:function(e){t.delete(e)},update:function(e,i,n){t.get(e)[i]=n},dispose:function(){t=new WeakMap}}}function Zu(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Ju(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Qu(){const t=[];let e=0;const i=[],n=[],r=[];function s(i,n,r,s,a,o){let h=t[e];return void 0===h?(h={id:i.id,object:i,geometry:n,material:r,groupOrder:s,renderOrder:i.renderOrder,z:a,group:o},t[e]=h):(h.id=i.id,h.object=i,h.geometry=n,h.material=r,h.groupOrder=s,h.renderOrder=i.renderOrder,h.z=a,h.group=o),e++,h}return{opaque:i,transmissive:n,transparent:r,init:function(){e=0,i.length=0,n.length=0,r.length=0},push:function(t,e,a,o,h,l){const c=s(t,e,a,o,h,l);a.transmission>0?n.push(c):!0===a.transparent?r.push(c):i.push(c)},unshift:function(t,e,a,o,h,l){const c=s(t,e,a,o,h,l);a.transmission>0?n.unshift(c):!0===a.transparent?r.unshift(c):i.unshift(c)},finish:function(){for(let i=e,n=t.length;i<n;i++){const e=t[i];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){i.length>1&&i.sort(t||Zu),n.length>1&&n.sort(e||Ju),r.length>1&&r.sort(e||Ju)}}}function $u(){let t=new WeakMap;return{get:function(e,i){const n=t.get(e);let r;return void 0===n?(r=new Qu,t.set(e,[r])):i>=n.length?(r=new Qu,n.push(r)):r=n[i],r},dispose:function(){t=new WeakMap}}}function tp(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new Ci,color:new Jn};break;case"SpotLight":i={position:new Ci,direction:new Ci,color:new Jn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Ci,color:new Jn,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Ci,skyColor:new Jn,groundColor:new Jn};break;case"RectAreaLight":i={color:new Jn,position:new Ci,halfWidth:new Ci,halfHeight:new Ci}}return t[e.id]=i,i}}}let ep=0;function ip(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function np(t){const e=new tp,i=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e};break;case"PointLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),n={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 t=0;t<9;t++)n.probe.push(new Ci);const r=new Ci,s=new sn,a=new sn;return{setup:function(r){let s=0,a=0,o=0;for(let t=0;t<9;t++)n.probe[t].set(0,0,0);let h=0,l=0,c=0,d=0,u=0,p=0,m=0,f=0,g=0,v=0,_=0;r.sort(ip);for(let t=0,y=r.length;t<y;t++){const y=r[t],x=y.color,b=y.intensity,w=y.distance,S=y.shadow&&y.shadow.map?y.shadow.map.texture:null;if(y.isAmbientLight)s+=x.r*b,a+=x.g*b,o+=x.b*b;else if(y.isLightProbe){for(let t=0;t<9;t++)n.probe[t].addScaledVector(y.sh.coefficients[t],b);_++}else if(y.isDirectionalLight){const t=e.get(y);if(t.color.copy(y.color).multiplyScalar(y.intensity),y.castShadow){const t=y.shadow,e=i.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,n.directionalShadow[h]=e,n.directionalShadowMap[h]=S,n.directionalShadowMatrix[h]=y.shadow.matrix,p++}n.directional[h]=t,h++}else if(y.isSpotLight){const t=e.get(y);t.position.setFromMatrixPosition(y.matrixWorld),t.color.copy(x).multiplyScalar(b),t.distance=w,t.coneCos=Math.cos(y.angle),t.penumbraCos=Math.cos(y.angle*(1-y.penumbra)),t.decay=y.decay,n.spot[c]=t;const r=y.shadow;if(y.map&&(n.spotLightMap[g]=y.map,g++,r.updateMatrices(y),y.castShadow&&v++),n.spotLightMatrix[c]=r.matrix,y.castShadow){const t=i.get(y);t.shadowIntensity=r.intensity,t.shadowBias=r.bias,t.shadowNormalBias=r.normalBias,t.shadowRadius=r.radius,t.shadowMapSize=r.mapSize,n.spotShadow[c]=t,n.spotShadowMap[c]=S,f++}c++}else if(y.isRectAreaLight){const t=e.get(y);t.color.copy(x).multiplyScalar(b),t.halfWidth.set(.5*y.width,0,0),t.halfHeight.set(0,.5*y.height,0),n.rectArea[d]=t,d++}else if(y.isPointLight){const t=e.get(y);if(t.color.copy(y.color).multiplyScalar(y.intensity),t.distance=y.distance,t.decay=y.decay,y.castShadow){const t=y.shadow,e=i.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,e.shadowCameraNear=t.camera.near,e.shadowCameraFar=t.camera.far,n.pointShadow[l]=e,n.pointShadowMap[l]=S,n.pointShadowMatrix[l]=y.shadow.matrix,m++}n.point[l]=t,l++}else if(y.isHemisphereLight){const t=e.get(y);t.skyColor.copy(y.color).multiplyScalar(b),t.groundColor.copy(y.groundColor).multiplyScalar(b),n.hemi[u]=t,u++}}d>0&&(!0===t.has("OES_texture_float_linear")?(n.rectAreaLTC1=Bc.LTC_FLOAT_1,n.rectAreaLTC2=Bc.LTC_FLOAT_2):(n.rectAreaLTC1=Bc.LTC_HALF_1,n.rectAreaLTC2=Bc.LTC_HALF_2)),n.ambient[0]=s,n.ambient[1]=a,n.ambient[2]=o;const y=n.hash;y.directionalLength===h&&y.pointLength===l&&y.spotLength===c&&y.rectAreaLength===d&&y.hemiLength===u&&y.numDirectionalShadows===p&&y.numPointShadows===m&&y.numSpotShadows===f&&y.numSpotMaps===g&&y.numLightProbes===_||(n.directional.length=h,n.spot.length=c,n.rectArea.length=d,n.point.length=l,n.hemi.length=u,n.directionalShadow.length=p,n.directionalShadowMap.length=p,n.pointShadow.length=m,n.pointShadowMap.length=m,n.spotShadow.length=f,n.spotShadowMap.length=f,n.directionalShadowMatrix.length=p,n.pointShadowMatrix.length=m,n.spotLightMatrix.length=f+g-v,n.spotLightMap.length=g,n.numSpotLightShadowsWithMaps=v,n.numLightProbes=_,y.directionalLength=h,y.pointLength=l,y.spotLength=c,y.rectAreaLength=d,y.hemiLength=u,y.numDirectionalShadows=p,y.numPointShadows=m,y.numSpotShadows=f,y.numSpotMaps=g,y.numLightProbes=_,n.version=ep++)},setupView:function(t,e){let i=0,o=0,h=0,l=0,c=0;const d=e.matrixWorldInverse;for(let e=0,u=t.length;e<u;e++){const u=t[e];if(u.isDirectionalLight){const t=n.directional[i];t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),i++}else if(u.isSpotLight){const t=n.spot[h];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),h++}else if(u.isRectAreaLight){const t=n.rectArea[l];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),a.identity(),s.copy(u.matrixWorld),s.premultiply(d),a.extractRotation(s),t.halfWidth.set(.5*u.width,0,0),t.halfHeight.set(0,.5*u.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),l++}else if(u.isPointLight){const t=n.point[o];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),o++}else if(u.isHemisphereLight){const t=n.hemi[c];t.direction.setFromMatrixPosition(u.matrixWorld),t.direction.transformDirection(d),c++}}},state:n}}function rp(t){const e=new np(t),i=[],n=[];const r={lightsArray:i,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:function(t){r.camera=t,i.length=0,n.length=0},state:r,setupLights:function(){e.setup(i)},setupLightsView:function(t){e.setupView(i,t)},pushLight:function(t){i.push(t)},pushShadow:function(t){n.push(t)}}}function sp(t){let e=new WeakMap;return{get:function(i,n=0){const r=e.get(i);let s;return void 0===r?(s=new rp(t),e.set(i,[s])):n>=r.length?(s=new rp(t),r.push(s)):s=r[n],s},dispose:function(){e=new WeakMap}}}function ap(t,e,i){let n=new ta;const r=new $e,s=new $e,a=new wi,o=new Sh({depthPacking:3201}),h=new Mh,l={},c=i.maxTextureSize,d={[b]:1,[w]:0,[S]:2},u=new zr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $e},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}"}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const m=new br;m.setAttribute("position",new cr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Dr(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function _(i,n){const s=e.update(f);u.defines.VSM_SAMPLES!==i.blurSamples&&(u.defines.VSM_SAMPLES=i.blurSamples,p.defines.VSM_SAMPLES=i.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new Mi(r.x,r.y)),u.uniforms.shadow_pass.value=i.map.texture,u.uniforms.resolution.value=i.mapSize,u.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,s,u,f,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,s,p,f,null)}function y(e,i,n,r){let s=null;const a=!0===n.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===n.isPointLight?h:o,t.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0){const t=s.uuid,e=i.uuid;let n=l[t];void 0===n&&(n={},l[t]=n);let r=n[e];void 0===r&&(r=s.clone(),n[e]=r,i.addEventListener("dispose",M)),s=r}if(s.visible=i.visible,s.wireframe=i.wireframe,s.side=3===r?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:d[i.side],s.alphaMap=i.alphaMap,s.alphaTest=i.alphaTest,s.map=i.map,s.clipShadows=i.clipShadows,s.clippingPlanes=i.clippingPlanes,s.clipIntersection=i.clipIntersection,s.displacementMap=i.displacementMap,s.displacementScale=i.displacementScale,s.displacementBias=i.displacementBias,s.wireframeLinewidth=i.wireframeLinewidth,s.linewidth=i.linewidth,!0===n.isPointLight&&!0===s.isMeshDistanceMaterial){t.properties.get(s).light=n}return s}function x(i,r,s,a,o){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===o)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const n=e.update(i),h=i.material;if(Array.isArray(h)){const e=n.groups;for(let l=0,c=e.length;l<c;l++){const c=e[l],d=h[c.materialIndex];if(d&&d.visible){const e=y(i,d,a,o);i.onBeforeShadow(t,i,r,s,n,e,c),t.renderBufferDirect(s,null,n,e,i,c),i.onAfterShadow(t,i,r,s,n,e,c)}}}else if(h.visible){const e=y(i,h,a,o);i.onBeforeShadow(t,i,r,s,n,e,null),t.renderBufferDirect(s,null,n,e,i,null),i.onAfterShadow(t,i,r,s,n,e,null)}}const h=i.children;for(let t=0,e=h.length;t<e;t++)x(h[t],r,s,a,o)}function M(t){t.target.removeEventListener("dispose",M);for(const e in l){const i=l[e],n=t.target.uuid;if(n in i){i[n].dispose(),delete i[n]}}}this.render=function(e,i,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===e.length)return;const h=t.getRenderTarget(),l=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),u=t.state;u.setBlending(0),u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const p=3!==v&&3===this.type,m=3===v&&3!==this.type;for(let h=0,l=e.length;h<l;h++){const l=e[h],d=l.shadow;if(void 0===d){console.warn("THREE.WebGLShadowMap:",l,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;r.copy(d.mapSize);const f=d.getFrameExtents();if(r.multiply(f),s.copy(d.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(s.x=Math.floor(c/f.x),r.x=s.x*f.x,d.mapSize.x=s.x),r.y>c&&(s.y=Math.floor(c/f.y),r.y=s.y*f.y,d.mapSize.y=s.y)),null===d.map||!0===p||!0===m){const t=3!==this.type?{minFilter:ot,magFilter:ot}:{};null!==d.map&&d.map.dispose(),d.map=new Mi(r.x,r.y,t),d.map.texture.name=l.name+".shadowMap",d.camera.updateProjectionMatrix()}t.setRenderTarget(d.map),t.clear();const g=d.getViewportCount();for(let t=0;t<g;t++){const e=d.getViewport(t);a.set(s.x*e.x,s.y*e.y,s.x*e.z,s.y*e.w),u.viewport(a),d.updateMatrices(l,t),n=d.getFrustum(),x(i,o,d.camera,l,this.type)}!0!==d.isPointLightShadow&&3===this.type&&_(d,o),d.needsUpdate=!1}v=this.type,g.needsUpdate=!1,t.setRenderTarget(h,l,d)}}const op={[H]:1,[W]:6,[X]:7,[j]:5,[V]:0,[q]:2,[K]:4,[Y]:3};function hp(t,e){const i=new function(){let e=!1;const i=new wi;let n=null;const r=new wi(0,0,0,0);return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,s,a,o){!0===o&&(e*=a,n*=a,s*=a),i.set(e,n,s,a),!1===r.equals(i)&&(t.clearColor(e,n,s,a),r.copy(i))},reset:function(){e=!1,n=null,r.set(-1,0,0,0)}}},n=new function(){let i=!1,n=!1,r=null,s=null,a=null;return{setReversed:function(t){if(n!==t){const t=e.get("EXT_clip_control");n?t.clipControlEXT(t.LOWER_LEFT_EXT,t.ZERO_TO_ONE_EXT):t.clipControlEXT(t.LOWER_LEFT_EXT,t.NEGATIVE_ONE_TO_ONE_EXT);const i=a;a=null,this.setClear(i)}n=t},getReversed:function(){return n},setTest:function(e){e?rt(t.DEPTH_TEST):st(t.DEPTH_TEST)},setMask:function(e){r===e||i||(t.depthMask(e),r=e)},setFunc:function(e){if(n&&(e=op[e]),s!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}s=e}},setLocked:function(t){i=t},setClear:function(e){a!==e&&(n&&(e=1-e),t.clearDepth(e),a=e)},reset:function(){i=!1,r=null,s=null,a=null,n=!1}}},r=new function(){let e=!1,i=null,n=null,r=null,s=null,a=null,o=null,h=null,l=null;return{setTest:function(i){e||(i?rt(t.STENCIL_TEST):st(t.STENCIL_TEST))},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,a){n===e&&r===i&&s===a||(t.stencilFunc(e,i,a),n=e,r=i,s=a)},setOp:function(e,i,n){a===e&&o===i&&h===n||(t.stencilOp(e,i,n),a=e,o=i,h=n)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,i=null,n=null,r=null,s=null,a=null,o=null,h=null,l=null}}},s=new WeakMap,a=new WeakMap;let o={},h={},l=new WeakMap,c=[],d=null,u=!1,p=null,m=null,f=null,g=null,v=null,_=null,y=null,x=new Jn(0,0,0),b=0,w=!1,S=null,H=null,V=null,W=null,j=null;const X=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,q=0;const K=t.getParameter(t.VERSION);-1!==K.indexOf("WebGL")?(q=parseFloat(/^WebGL (\d)/.exec(K)[1]),Y=q>=1):-1!==K.indexOf("OpenGL ES")&&(q=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),Y=q>=2);let Z=null,J={};const Q=t.getParameter(t.SCISSOR_BOX),$=t.getParameter(t.VIEWPORT),tt=(new wi).fromArray(Q),et=(new wi).fromArray($);function it(e,i,n,r){const s=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let a=0;a<n;a++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(i,0,t.RGBA,1,1,r,0,t.RGBA,t.UNSIGNED_BYTE,s):t.texImage2D(i+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,s);return a}const nt={};function rt(e){!0!==o[e]&&(t.enable(e),o[e]=!0)}function st(e){!1!==o[e]&&(t.disable(e),o[e]=!1)}nt[t.TEXTURE_2D]=it(t.TEXTURE_2D,t.TEXTURE_2D,1),nt[t.TEXTURE_CUBE_MAP]=it(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),nt[t.TEXTURE_2D_ARRAY]=it(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),nt[t.TEXTURE_3D]=it(t.TEXTURE_3D,t.TEXTURE_3D,1,1),i.setClear(0,0,0,1),n.setClear(1),r.setClear(0),rt(t.DEPTH_TEST),n.setFunc(3),lt(!1),ct(1),rt(t.CULL_FACE),ht(0);const at={[M]:t.FUNC_ADD,[T]:t.FUNC_SUBTRACT,[E]:t.FUNC_REVERSE_SUBTRACT};at[103]=t.MIN,at[104]=t.MAX;const ot={[A]:t.ZERO,[C]:t.ONE,[R]:t.SRC_COLOR,[L]:t.SRC_ALPHA,[F]:t.SRC_ALPHA_SATURATE,[N]:t.DST_COLOR,[D]:t.DST_ALPHA,[P]:t.ONE_MINUS_SRC_COLOR,[I]:t.ONE_MINUS_SRC_ALPHA,[U]:t.ONE_MINUS_DST_COLOR,[O]:t.ONE_MINUS_DST_ALPHA,[k]:t.CONSTANT_COLOR,[B]:t.ONE_MINUS_CONSTANT_COLOR,[z]:t.CONSTANT_ALPHA,[G]:t.ONE_MINUS_CONSTANT_ALPHA};function ht(e,i,n,r,s,a,o,h,l,c){if(0!==e){if(!1===u&&(rt(t.BLEND),u=!0),5===e)s=s||i,a=a||n,o=o||r,i===m&&s===v||(t.blendEquationSeparate(at[i],at[s]),m=i,v=s),n===f&&r===g&&a===_&&o===y||(t.blendFuncSeparate(ot[n],ot[r],ot[a],ot[o]),f=n,g=r,_=a,y=o),!1!==h.equals(x)&&l===b||(t.blendColor(h.r,h.g,h.b,l),x.copy(h),b=l),p=e,w=!1;else if(e!==p||c!==w){if(m===M&&v===M||(t.blendEquation(t.FUNC_ADD),m=M,v=M),c)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}f=null,g=null,_=null,y=null,x.set(0,0,0),b=0,p=e,w=c}}else!0===u&&(st(t.BLEND),u=!1)}function lt(e){S!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),S=e)}function ct(e){0!==e?(rt(t.CULL_FACE),e!==H&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):st(t.CULL_FACE),H=e}function dt(e,i,n){e?(rt(t.POLYGON_OFFSET_FILL),W===i&&j===n||(t.polygonOffset(i,n),W=i,j=n)):st(t.POLYGON_OFFSET_FILL)}return{buffers:{color:i,depth:n,stencil:r},enable:rt,disable:st,bindFramebuffer:function(e,i){return h[e]!==i&&(t.bindFramebuffer(e,i),h[e]=i,e===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=i),e===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=i),!0)},drawBuffers:function(e,i){let n=c,r=!1;if(e){n=l.get(i),void 0===n&&(n=[],l.set(i,n));const s=e.textures;if(n.length!==s.length||n[0]!==t.COLOR_ATTACHMENT0){for(let e=0,i=s.length;e<i;e++)n[e]=t.COLOR_ATTACHMENT0+e;n.length=s.length,r=!0}}else n[0]!==t.BACK&&(n[0]=t.BACK,r=!0);r&&t.drawBuffers(n)},useProgram:function(e){return d!==e&&(t.useProgram(e),d=e,!0)},setBlending:ht,setMaterial:function(e,s){2===e.side?st(t.CULL_FACE):rt(t.CULL_FACE);let a=1===e.side;s&&(a=!a),lt(a),1===e.blending&&!1===e.transparent?ht(0):ht(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),n.setFunc(e.depthFunc),n.setTest(e.depthTest),n.setMask(e.depthWrite),i.setMask(e.colorWrite);const o=e.stencilWrite;r.setTest(o),o&&(r.setMask(e.stencilWriteMask),r.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),r.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),dt(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?rt(t.SAMPLE_ALPHA_TO_COVERAGE):st(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:lt,setCullFace:ct,setLineWidth:function(e){e!==V&&(Y&&t.lineWidth(e),V=e)},setPolygonOffset:dt,setScissorTest:function(e){e?rt(t.SCISSOR_TEST):st(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+X-1),Z!==e&&(t.activeTexture(e),Z=e)},bindTexture:function(e,i,n){void 0===n&&(n=null===Z?t.TEXTURE0+X-1:Z);let r=J[n];void 0===r&&(r={type:void 0,texture:void 0},J[n]=r),r.type===e&&r.texture===i||(Z!==n&&(t.activeTexture(n),Z=n),t.bindTexture(e,i||nt[e]),r.type=e,r.texture=i)},unbindTexture:function(){const e=J[Z];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},updateUBOMapping:function(e,i){let n=a.get(i);void 0===n&&(n=new WeakMap,a.set(i,n));let r=n.get(e);void 0===r&&(r=t.getUniformBlockIndex(i,e.name),n.set(e,r))},uniformBlockBinding:function(e,i){const n=a.get(i).get(e);s.get(i)!==n&&(t.uniformBlockBinding(i,n,e.__bindingPointIndex),s.set(i,n))},texStorage2D:function(){try{t.texStorage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===tt.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),tt.copy(e))},viewport:function(e){!1===et.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),et.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),n.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),o={},Z=null,J={},h={},l=new WeakMap,c=[],d=null,u=!1,p=null,m=null,f=null,g=null,v=null,_=null,y=null,x=new Jn(0,0,0),b=0,w=!1,S=null,H=null,V=null,W=null,j=null,tt.set(0,0,t.canvas.width,t.canvas.height),et.set(0,0,t.canvas.width,t.canvas.height),i.reset(),n.reset(),r.reset()}}}function lp(t,e,i,n,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,h="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),l=new $e,c=new WeakMap;let d;const u=new WeakMap;let p=!1;try{p="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function m(t,e){return p?new OffscreenCanvas(t,e):si("canvas")}function f(t,e,i){let n=1;const r=G(t);if((r.width>i||r.height>i)&&(n=i/Math.max(r.width,r.height)),n<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const i=Math.floor(n*r.width),s=Math.floor(n*r.height);void 0===d&&(d=m(i,s));const a=e?m(i,s):d;a.width=i,a.height=s;return a.getContext("2d").drawImage(t,0,0,i,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+i+"x"+s+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function g(t){return t.generateMipmaps}function v(e){t.generateMipmap(e)}function _(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function y(i,n,r,s,a=!1){if(null!==i){if(void 0!==t[i])return t[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let o=n;if(n===t.RED&&(r===t.FLOAT&&(o=t.R32F),r===t.HALF_FLOAT&&(o=t.R16F),r===t.UNSIGNED_BYTE&&(o=t.R8)),n===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.R8UI),r===t.UNSIGNED_SHORT&&(o=t.R16UI),r===t.UNSIGNED_INT&&(o=t.R32UI),r===t.BYTE&&(o=t.R8I),r===t.SHORT&&(o=t.R16I),r===t.INT&&(o=t.R32I)),n===t.RG&&(r===t.FLOAT&&(o=t.RG32F),r===t.HALF_FLOAT&&(o=t.RG16F),r===t.UNSIGNED_BYTE&&(o=t.RG8)),n===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RG8UI),r===t.UNSIGNED_SHORT&&(o=t.RG16UI),r===t.UNSIGNED_INT&&(o=t.RG32UI),r===t.BYTE&&(o=t.RG8I),r===t.SHORT&&(o=t.RG16I),r===t.INT&&(o=t.RG32I)),n===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGB8UI),r===t.UNSIGNED_SHORT&&(o=t.RGB16UI),r===t.UNSIGNED_INT&&(o=t.RGB32UI),r===t.BYTE&&(o=t.RGB8I),r===t.SHORT&&(o=t.RGB16I),r===t.INT&&(o=t.RGB32I)),n===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(o=t.RGBA16UI),r===t.UNSIGNED_INT&&(o=t.RGBA32UI),r===t.BYTE&&(o=t.RGBA8I),r===t.SHORT&&(o=t.RGBA16I),r===t.INT&&(o=t.RGBA32I)),n===t.RGB&&r===t.UNSIGNED_INT_5_9_9_9_REV&&(o=t.RGB9_E5),n===t.RGBA){const e=a?Ee:ui.getTransfer(s);r===t.FLOAT&&(o=t.RGBA32F),r===t.HALF_FLOAT&&(o=t.RGBA16F),r===t.UNSIGNED_BYTE&&(o=e===Ae?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(o=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(o=t.RGB5_A1)}return o!==t.R16F&&o!==t.R32F&&o!==t.RG16F&&o!==t.RG32F&&o!==t.RGBA16F&&o!==t.RGBA32F||e.get("EXT_color_buffer_float"),o}function x(e,i){let n;return e?null===i||i===_t||i===St?n=t.DEPTH24_STENCIL8:i===yt?n=t.DEPTH32F_STENCIL8:i===gt&&(n=t.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===i||i===_t||i===St?n=t.DEPTH_COMPONENT24:i===yt?n=t.DEPTH_COMPONENT32F:i===gt&&(n=t.DEPTH_COMPONENT16),n}function b(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==ot&&t.minFilter!==ct?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function w(t){const e=t.target;e.removeEventListener("dispose",w),function(t){const e=n.get(t);if(void 0===e.__webglInit)return;const i=t.source,r=u.get(i);if(r){const n=r[e.__cacheKey];n.usedTimes--,0===n.usedTimes&&M(t),0===Object.keys(r).length&&u.delete(i)}n.remove(t)}(e),e.isVideoTexture&&c.delete(e)}function S(e){const i=e.target;i.removeEventListener("dispose",S),function(e){const i=n.get(e);e.depthTexture&&(e.depthTexture.dispose(),n.remove(e.depthTexture));if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(i.__webglFramebuffer[e]))for(let n=0;n<i.__webglFramebuffer[e].length;n++)t.deleteFramebuffer(i.__webglFramebuffer[e][n]);else t.deleteFramebuffer(i.__webglFramebuffer[e]);i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e])}else{if(Array.isArray(i.__webglFramebuffer))for(let e=0;e<i.__webglFramebuffer.length;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer);if(i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(let e=0;e<i.__webglColorRenderbuffer.length;e++)i.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(i.__webglColorRenderbuffer[e]);i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer)}const r=e.textures;for(let e=0,i=r.length;e<i;e++){const i=n.get(r[e]);i.__webglTexture&&(t.deleteTexture(i.__webglTexture),a.memory.textures--),n.remove(r[e])}n.remove(e)}(i)}function M(e){const i=n.get(e);t.deleteTexture(i.__webglTexture);const r=e.source;delete u.get(r)[i.__cacheKey],a.memory.textures--}let T=0;function E(e,r){const s=n.get(e);if(e.isVideoTexture&&function(t){const e=a.render.frame;c.get(t)!==e&&(c.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&e.version>0&&s.__version!==e.version){const t=e.image;if(null===t)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void I(s,e,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const A={[rt]:t.REPEAT,[st]:t.CLAMP_TO_EDGE,[at]:t.MIRRORED_REPEAT},C={[ot]:t.NEAREST,[ht]:t.NEAREST_MIPMAP_NEAREST,[lt]:t.NEAREST_MIPMAP_LINEAR,[ct]:t.LINEAR,[dt]:t.LINEAR_MIPMAP_NEAREST,[ut]:t.LINEAR_MIPMAP_LINEAR},R={[Re]:t.NEVER,[Ue]:t.ALWAYS,[Pe]:t.LESS,[Ie]:t.LEQUAL,[Le]:t.EQUAL,[Ne]:t.GEQUAL,[De]:t.GREATER,[Oe]:t.NOTEQUAL};function P(i,s){if(s.type!==yt||!1!==e.has("OES_texture_float_linear")||s.magFilter!==ct&&s.magFilter!==dt&&s.magFilter!==lt&&s.magFilter!==ut&&s.minFilter!==ct&&s.minFilter!==dt&&s.minFilter!==lt&&s.minFilter!==ut||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(i,t.TEXTURE_WRAP_S,A[s.wrapS]),t.texParameteri(i,t.TEXTURE_WRAP_T,A[s.wrapT]),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,A[s.wrapR]),t.texParameteri(i,t.TEXTURE_MAG_FILTER,C[s.magFilter]),t.texParameteri(i,t.TEXTURE_MIN_FILTER,C[s.minFilter]),s.compareFunction&&(t.texParameteri(i,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(i,t.TEXTURE_COMPARE_FUNC,R[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(s.magFilter===ot)return;if(s.minFilter!==lt&&s.minFilter!==ut)return;if(s.type===yt&&!1===e.has("OES_texture_float_linear"))return;if(s.anisotropy>1||n.get(s).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy}}}function L(e,i){let n=!1;void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",w));const r=i.source;let s=u.get(r);void 0===s&&(s={},u.set(r,s));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(i);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,n=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&M(i)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return n}function I(e,a,o){let h=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(h=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(h=t.TEXTURE_3D);const l=L(e,a),c=a.source;i.bindTexture(h,e.__webglTexture,t.TEXTURE0+o);const d=n.get(c);if(c.version!==d.__version||!0===l){i.activeTexture(t.TEXTURE0+o);const e=ui.getPrimaries(ui.workingColorSpace),n=a.colorSpace===Se?null:ui.getPrimaries(a.colorSpace),u=a.colorSpace===Se||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);let p=f(a.image,!1,r.maxTextureSize);p=z(a,p);const m=s.convert(a.format,a.colorSpace),_=s.convert(a.type);let w,S=y(a.internalFormat,m,_,a.colorSpace,a.isVideoTexture);P(h,a);const M=a.mipmaps,T=!0!==a.isVideoTexture,E=void 0===d.__version||!0===l,A=c.dataReady,C=b(a,p);if(a.isDepthTexture)S=x(a.format===Lt,a.type),E&&(T?i.texStorage2D(t.TEXTURE_2D,1,S,p.width,p.height):i.texImage2D(t.TEXTURE_2D,0,S,p.width,p.height,0,m,_,null));else if(a.isDataTexture)if(M.length>0){T&&E&&i.texStorage2D(t.TEXTURE_2D,C,S,M[0].width,M[0].height);for(let e=0,n=M.length;e<n;e++)w=M[e],T?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,w.width,w.height,m,_,w.data):i.texImage2D(t.TEXTURE_2D,e,S,w.width,w.height,0,m,_,w.data);a.generateMipmaps=!1}else T?(E&&i.texStorage2D(t.TEXTURE_2D,C,S,p.width,p.height),A&&i.texSubImage2D(t.TEXTURE_2D,0,0,0,p.width,p.height,m,_,p.data)):i.texImage2D(t.TEXTURE_2D,0,S,p.width,p.height,0,m,_,p.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){T&&E&&i.texStorage3D(t.TEXTURE_2D_ARRAY,C,S,M[0].width,M[0].height,p.depth);for(let e=0,n=M.length;e<n;e++)if(w=M[e],a.format!==At)if(null!==m)if(T){if(A)if(a.layerUpdates.size>0){const n=Oc(w.width,w.height,a.format,a.type);for(const r of a.layerUpdates){const s=w.data.subarray(r*n/w.data.BYTES_PER_ELEMENT,(r+1)*n/w.data.BYTES_PER_ELEMENT);i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,r,w.width,w.height,1,m,s)}a.clearLayerUpdates()}else i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,p.depth,m,w.data)}else i.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,S,w.width,w.height,p.depth,0,w.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else T?A&&i.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,p.depth,m,_,w.data):i.texImage3D(t.TEXTURE_2D_ARRAY,e,S,w.width,w.height,p.depth,0,m,_,w.data)}else{T&&E&&i.texStorage2D(t.TEXTURE_2D,C,S,M[0].width,M[0].height);for(let e=0,n=M.length;e<n;e++)w=M[e],a.format!==At?null!==m?T?A&&i.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,w.width,w.height,m,w.data):i.compressedTexImage2D(t.TEXTURE_2D,e,S,w.width,w.height,0,w.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):T?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,w.width,w.height,m,_,w.data):i.texImage2D(t.TEXTURE_2D,e,S,w.width,w.height,0,m,_,w.data)}else if(a.isDataArrayTexture)if(T){if(E&&i.texStorage3D(t.TEXTURE_2D_ARRAY,C,S,p.width,p.height,p.depth),A)if(a.layerUpdates.size>0){const e=Oc(p.width,p.height,a.format,a.type);for(const n of a.layerUpdates){const r=p.data.subarray(n*e/p.data.BYTES_PER_ELEMENT,(n+1)*e/p.data.BYTES_PER_ELEMENT);i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,n,p.width,p.height,1,m,_,r)}a.clearLayerUpdates()}else i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,m,_,p.data)}else i.texImage3D(t.TEXTURE_2D_ARRAY,0,S,p.width,p.height,p.depth,0,m,_,p.data);else if(a.isData3DTexture)T?(E&&i.texStorage3D(t.TEXTURE_3D,C,S,p.width,p.height,p.depth),A&&i.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,m,_,p.data)):i.texImage3D(t.TEXTURE_3D,0,S,p.width,p.height,p.depth,0,m,_,p.data);else if(a.isFramebufferTexture){if(E)if(T)i.texStorage2D(t.TEXTURE_2D,C,S,p.width,p.height);else{let e=p.width,n=p.height;for(let r=0;r<C;r++)i.texImage2D(t.TEXTURE_2D,r,S,e,n,0,m,_,null),e>>=1,n>>=1}}else if(M.length>0){if(T&&E){const e=G(M[0]);i.texStorage2D(t.TEXTURE_2D,C,S,e.width,e.height)}for(let e=0,n=M.length;e<n;e++)w=M[e],T?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,m,_,w):i.texImage2D(t.TEXTURE_2D,e,S,m,_,w);a.generateMipmaps=!1}else if(T){if(E){const e=G(p);i.texStorage2D(t.TEXTURE_2D,C,S,e.width,e.height)}A&&i.texSubImage2D(t.TEXTURE_2D,0,0,0,m,_,p)}else i.texImage2D(t.TEXTURE_2D,0,S,m,_,p);g(a)&&v(h),d.__version=c.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function D(e,r,a,h,l,c){const d=s.convert(a.format,a.colorSpace),u=s.convert(a.type),p=y(a.internalFormat,d,u,a.colorSpace),m=n.get(r),f=n.get(a);if(f.__renderTarget=r,!m.__hasExternalTextures){const e=Math.max(1,r.width>>c),n=Math.max(1,r.height>>c);l===t.TEXTURE_3D||l===t.TEXTURE_2D_ARRAY?i.texImage3D(l,c,p,e,n,r.depth,0,d,u,null):i.texImage2D(l,c,p,e,n,0,d,u,null)}i.bindFramebuffer(t.FRAMEBUFFER,e),B(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,h,l,f.__webglTexture,0,k(r)):(l===t.TEXTURE_2D||l>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,h,l,f.__webglTexture,c),i.bindFramebuffer(t.FRAMEBUFFER,null)}function O(e,i,n){if(t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer){const r=i.depthTexture,s=r&&r.isDepthTexture?r.type:null,a=x(i.stencilBuffer,s),h=i.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,l=k(i);B(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,l,a,i.width,i.height):n?t.renderbufferStorageMultisample(t.RENDERBUFFER,l,a,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,a,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,h,t.RENDERBUFFER,e)}else{const e=i.textures;for(let r=0;r<e.length;r++){const a=e[r],h=s.convert(a.format,a.colorSpace),l=s.convert(a.type),c=y(a.internalFormat,h,l,a.colorSpace),d=k(i);n&&!1===B(i)?t.renderbufferStorageMultisample(t.RENDERBUFFER,d,c,i.width,i.height):B(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,d,c,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,c,i.width,i.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function N(e){const r=n.get(e),s=!0===e.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),t){const e=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const s=n.get(r.depthTexture);s.__renderTarget=r,s.__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),E(r.depthTexture,0);const a=s.__webglTexture,h=k(r);if(r.depthTexture.format===Pt)B(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0,h):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==Lt)throw new Error("Unknown depthTexture format");B(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0,h):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0)}}(r.__webglFramebuffer,e)}else if(s){r.__webglDepthbuffer=[];for(let n=0;n<6;n++)if(i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[n]),void 0===r.__webglDepthbuffer[n])r.__webglDepthbuffer[n]=t.createRenderbuffer(),O(r.__webglDepthbuffer[n],e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[n];t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,s)}}else if(i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),O(r.__webglDepthbuffer,e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,n=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,n)}i.bindFramebuffer(t.FRAMEBUFFER,null)}const U=[],F=[];function k(t){return Math.min(r.maxSamples,t.samples)}function B(t){const i=n.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function z(t,e){const i=t.colorSpace,n=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||i!==Te&&i!==Se&&(ui.getTransfer(i)===Ae?n===At&&r===pt||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),e}function G(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(l.width=t.naturalWidth||t.width,l.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(l.width=t.displayWidth,l.height=t.displayHeight):(l.width=t.width,l.height=t.height),l}this.allocateTextureUnit=function(){const t=T;return t>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),T+=1,t},this.resetTextureUnits=function(){T=0},this.setTexture2D=E,this.setTexture2DArray=function(e,r){const s=n.get(e);e.version>0&&s.__version!==e.version?I(s,e,r):i.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r)},this.setTexture3D=function(e,r){const s=n.get(e);e.version>0&&s.__version!==e.version?I(s,e,r):i.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,a){const o=n.get(e);e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const h=L(e,a),l=a.source;i.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const c=n.get(l);if(l.version!==c.__version||!0===h){i.activeTexture(t.TEXTURE0+o);const e=ui.getPrimaries(ui.workingColorSpace),n=a.colorSpace===Se?null:ui.getPrimaries(a.colorSpace),d=a.colorSpace===Se||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const u=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,m=[];for(let t=0;t<6;t++)m[t]=u||p?p?a.image[t].image:a.image[t]:f(a.image[t],!0,r.maxCubemapSize),m[t]=z(a,m[t]);const _=m[0],x=s.convert(a.format,a.colorSpace),w=s.convert(a.type),S=y(a.internalFormat,x,w,a.colorSpace),M=!0!==a.isVideoTexture,T=void 0===c.__version||!0===h,E=l.dataReady;let A,C=b(a,_);if(P(t.TEXTURE_CUBE_MAP,a),u){M&&T&&i.texStorage2D(t.TEXTURE_CUBE_MAP,C,S,_.width,_.height);for(let e=0;e<6;e++){A=m[e].mipmaps;for(let n=0;n<A.length;n++){const r=A[n];a.format!==At?null!==x?M?E&&i.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,r.width,r.height,x,r.data):i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,S,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,r.width,r.height,x,w,r.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,S,r.width,r.height,0,x,w,r.data)}}}else{if(A=a.mipmaps,M&&T){A.length>0&&C++;const e=G(m[0]);i.texStorage2D(t.TEXTURE_CUBE_MAP,C,S,e.width,e.height)}for(let e=0;e<6;e++)if(p){M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,m[e].width,m[e].height,x,w,m[e].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,S,m[e].width,m[e].height,0,x,w,m[e].data);for(let n=0;n<A.length;n++){const r=A[n].image[e].image;M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,r.width,r.height,x,w,r.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,S,r.width,r.height,0,x,w,r.data)}}else{M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,x,w,m[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,S,x,w,m[e]);for(let n=0;n<A.length;n++){const r=A[n];M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,x,w,r.image[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,S,x,w,r.image[e])}}}g(a)&&v(t.TEXTURE_CUBE_MAP),c.__version=l.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(o,e,a):i.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,i,r){const s=n.get(e);void 0!==i&&D(s.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==r&&N(e)},this.setupRenderTarget=function(e){const r=e.texture,o=n.get(e),h=n.get(r);e.addEventListener("dispose",S);const l=e.textures,c=!0===e.isWebGLCubeRenderTarget,d=l.length>1;if(d||(void 0===h.__webglTexture&&(h.__webglTexture=t.createTexture()),h.__version=r.version,a.memory.textures++),c){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let i=0;i<r.mipmaps.length;i++)o.__webglFramebuffer[e][i]=t.createFramebuffer()}else o.__webglFramebuffer[e]=t.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let e=0;e<r.mipmaps.length;e++)o.__webglFramebuffer[e]=t.createFramebuffer()}else o.__webglFramebuffer=t.createFramebuffer();if(d)for(let e=0,i=l.length;e<i;e++){const i=n.get(l[e]);void 0===i.__webglTexture&&(i.__webglTexture=t.createTexture(),a.memory.textures++)}if(e.samples>0&&!1===B(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],i.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let i=0;i<l.length;i++){const n=l[i];o.__webglColorRenderbuffer[i]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,o.__webglColorRenderbuffer[i]);const r=s.convert(n.format,n.colorSpace),a=s.convert(n.type),h=y(n.internalFormat,r,a,n.colorSpace,!0===e.isXRRenderTarget),c=k(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,h,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+i,t.RENDERBUFFER,o.__webglColorRenderbuffer[i])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(o.__webglDepthRenderbuffer=t.createRenderbuffer(),O(o.__webglDepthRenderbuffer,e,!0)),i.bindFramebuffer(t.FRAMEBUFFER,null)}}if(c){i.bindTexture(t.TEXTURE_CUBE_MAP,h.__webglTexture),P(t.TEXTURE_CUBE_MAP,r);for(let i=0;i<6;i++)if(r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)D(o.__webglFramebuffer[i][n],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,n);else D(o.__webglFramebuffer[i],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,0);g(r)&&v(t.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(d){for(let r=0,s=l.length;r<s;r++){const s=l[r],a=n.get(s);i.bindTexture(t.TEXTURE_2D,a.__webglTexture),P(t.TEXTURE_2D,s),D(o.__webglFramebuffer,e,s,t.COLOR_ATTACHMENT0+r,t.TEXTURE_2D,0),g(s)&&v(t.TEXTURE_2D)}i.unbindTexture()}else{let n=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(n=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(n,h.__webglTexture),P(n,r),r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)D(o.__webglFramebuffer[i],e,r,t.COLOR_ATTACHMENT0,n,i);else D(o.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0,n,0);g(r)&&v(n),i.unbindTexture()}e.depthBuffer&&N(e)},this.updateRenderTargetMipmap=function(t){const e=t.textures;for(let r=0,s=e.length;r<s;r++){const s=e[r];if(g(s)){const e=_(t),r=n.get(s).__webglTexture;i.bindTexture(e,r),v(e),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)if(!1===B(e)){const r=e.textures,s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const l=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=n.get(e),d=r.length>1;if(d)for(let e=0;e<r.length;e++)i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);i.bindFramebuffer(t.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let i=0;i<r.length;i++){if(e.resolveDepthBuffer&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&e.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),d){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,c.__webglColorRenderbuffer[i]);const e=n.get(r[i]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,s,a,0,0,s,a,o,t.NEAREST),!0===h&&(U.length=0,F.length=0,U.push(t.COLOR_ATTACHMENT0+i),e.depthBuffer&&!1===e.resolveDepthBuffer&&(U.push(l),F.push(l),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,F)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,U))}if(i.bindFramebuffer(t.READ_FRAMEBUFFER,null),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),d)for(let e=0;e<r.length;e++){i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c.__webglColorRenderbuffer[e]);const s=n.get(r[e]).__webglTexture;i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,s,0)}i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&h){const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[i])}},this.setupDepthRenderbuffer=N,this.setupFrameBufferTexture=D,this.useMultisampledRTT=B}function cp(t,e){return{convert:function(i,n=""){let r;const s=ui.getTransfer(n);if(i===pt)return t.UNSIGNED_BYTE;if(i===bt)return t.UNSIGNED_SHORT_4_4_4_4;if(i===wt)return t.UNSIGNED_SHORT_5_5_5_1;if(i===Mt)return t.UNSIGNED_INT_5_9_9_9_REV;if(i===mt)return t.BYTE;if(i===ft)return t.SHORT;if(i===gt)return t.UNSIGNED_SHORT;if(i===vt)return t.INT;if(i===_t)return t.UNSIGNED_INT;if(i===yt)return t.FLOAT;if(i===xt)return t.HALF_FLOAT;if(i===Tt)return t.ALPHA;if(i===Et)return t.RGB;if(i===At)return t.RGBA;if(i===Ct)return t.LUMINANCE;if(i===Rt)return t.LUMINANCE_ALPHA;if(i===Pt)return t.DEPTH_COMPONENT;if(i===Lt)return t.DEPTH_STENCIL;if(i===It)return t.RED;if(i===Dt)return t.RED_INTEGER;if(i===Ot)return t.RG;if(i===Nt)return t.RG_INTEGER;if(i===Ut)return t.RGBA_INTEGER;if(i===Ft||i===kt||i===Bt||i===zt)if(s===Ae){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(i===Ft)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===kt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Bt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===zt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(i===Ft)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===kt)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Bt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===zt)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===Gt||i===Ht||i===Vt||i===Wt){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(i===Gt)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ht)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Vt)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Wt)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===jt||i===Xt||i===Yt){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(i===jt||i===Xt)return s===Ae?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Yt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(i===qt||i===Kt||i===Zt||i===Jt||i===Qt||i===$t||i===te||i===ee||i===ie||i===ne||i===re||i===se||i===ae||i===oe){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(i===qt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Kt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Zt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Jt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Qt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===$t)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===te)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ee)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ie)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ne)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===re)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===se)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===ae)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===oe)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===he||i===le||i===ce){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(i===he)return s===Ae?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===le)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ce)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(i===de||i===ue||i===pe||i===me){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(i===he)return r.COMPRESSED_RED_RGTC1_EXT;if(i===ue)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===pe)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===me)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===St?t.UNSIGNED_INT_24_8:void 0!==t[i]?t[i]:null}}}class dp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,i){if(null===this.texture){const n=new bi;t.properties.get(n).__webglTexture=e.texture,e.depthNear===i.depthNear&&e.depthFar===i.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,i=new zr({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:e.z},depthHeight:{value:e.w}}});this.mesh=new Dr(new rh(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class up extends Ge{constructor(t,e){super();const i=this;let n=null,r=1,s=null,a="local-floor",o=1,h=null,l=null,c=null,d=null,u=null,p=null;const m=new dp,f=e.getContextAttributes();let g=null,v=null;const _=[],y=[],x=new $e;let b=null;const w=new jr;w.viewport=new wi;const S=new jr;S.viewport=new wi;const M=[w,S],T=new Nl;let E=null,A=null;function C(t){const e=y.indexOf(t.inputSource);if(-1===e)return;const i=_[e];void 0!==i&&(i.update(t.inputSource,t.frame,h||s),i.dispatchEvent({type:t.type,data:t.inputSource}))}function R(){n.removeEventListener("select",C),n.removeEventListener("selectstart",C),n.removeEventListener("selectend",C),n.removeEventListener("squeeze",C),n.removeEventListener("squeezestart",C),n.removeEventListener("squeezeend",C),n.removeEventListener("end",R),n.removeEventListener("inputsourceschange",P);for(let t=0;t<_.length;t++){const e=y[t];null!==e&&(y[t]=null,_[t].disconnect(e))}E=null,A=null,m.reset(),t.setRenderTarget(g),u=null,d=null,c=null,n=null,v=null,N.stop(),i.isPresenting=!1,t.setPixelRatio(b),t.setSize(x.width,x.height,!1),i.dispatchEvent({type:"sessionend"})}function P(t){for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=y.indexOf(i);n>=0&&(y[n]=null,_[n].disconnect(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e];let n=y.indexOf(i);if(-1===n){for(let t=0;t<_.length;t++){if(t>=y.length){y.push(i),n=t;break}if(null===y[t]){y[t]=i,n=t;break}}if(-1===n)break}const r=_[n];r&&r.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=_[t];return void 0===e&&(e=new Qr,_[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=_[t];return void 0===e&&(e=new Qr,_[t]=e),e.getGripSpace()},this.getHand=function(t){let e=_[t];return void 0===e&&(e=new Qr,_[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||s},this.setReferenceSpace=function(t){h=t},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(l){if(n=l,null!==n){g=t.getRenderTarget(),n.addEventListener("select",C),n.addEventListener("selectstart",C),n.addEventListener("selectend",C),n.addEventListener("squeeze",C),n.addEventListener("squeezestart",C),n.addEventListener("squeezeend",C),n.addEventListener("end",R),n.addEventListener("inputsourceschange",P),!0!==f.xrCompatible&&await e.makeXRCompatible(),b=t.getPixelRatio(),t.getSize(x);if("undefined"!=typeof XRWebGLBinding&&"createProjectionLayer"in XRWebGLBinding.prototype){let i=null,s=null,a=null;f.depth&&(a=f.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,i=f.stencil?Lt:Pt,s=f.stencil?St:_t);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};c=new XRWebGLBinding(n,e),d=c.createProjectionLayer(o),n.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),v=new Mi(d.textureWidth,d.textureHeight,{format:At,type:pt,depthTexture:new Va(d.textureWidth,d.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:f.stencil,colorSpace:t.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:!1===d.ignoreDepthValues})}else{const i={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(n,e,i),n.updateRenderState({baseLayer:u}),t.setPixelRatio(1),t.setSize(u.framebufferWidth,u.framebufferHeight,!1),v=new Mi(u.framebufferWidth,u.framebufferHeight,{format:At,type:pt,colorSpace:t.outputColorSpace,stencilBuffer:f.stencil})}v.isXRRenderTarget=!0,this.setFoveation(o),h=null,s=await n.requestReferenceSpace(a),N.setContext(n),N.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};const L=new Ci,I=new Ci;function D(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===n)return;let e=t.near,i=t.far;null!==m.texture&&(m.depthNear>0&&(e=m.depthNear),m.depthFar>0&&(i=m.depthFar)),T.near=S.near=w.near=e,T.far=S.far=w.far=i,E===T.near&&A===T.far||(n.updateRenderState({depthNear:T.near,depthFar:T.far}),E=T.near,A=T.far),w.layers.mask=2|t.layers.mask,S.layers.mask=4|t.layers.mask,T.layers.mask=w.layers.mask|S.layers.mask;const r=t.parent,s=T.cameras;D(T,r);for(let t=0;t<s.length;t++)D(s[t],r);2===s.length?function(t,e,i){L.setFromMatrixPosition(e.matrixWorld),I.setFromMatrixPosition(i.matrixWorld);const n=L.distanceTo(I),r=e.projectionMatrix.elements,s=i.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),h=(r[9]+1)/r[5],l=(r[9]-1)/r[5],c=(r[8]-1)/r[0],d=(s[8]+1)/s[0],u=a*c,p=a*d,m=n/(-c+d),f=m*-c;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(f),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===r[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=a+m,i=o+m,r=u-f,s=p+(n-f),c=h*o/i*e,d=l*o/i*e;t.projectionMatrix.makePerspective(r,s,c,d,e,i),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(T,w,S):T.projectionMatrix.copy(w.projectionMatrix),function(t,e,i){null===i?t.matrix.copy(e.matrixWorld):(t.matrix.copy(i.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld));t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*je*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,T,r)},this.getCamera=function(){return T},this.getFoveation=function(){if(null!==d||null!==u)return o},this.setFoveation=function(t){o=t,null!==d&&(d.fixedFoveation=t),null!==u&&void 0!==u.fixedFoveation&&(u.fixedFoveation=t)},this.hasDepthSensing=function(){return null!==m.texture},this.getDepthSensingMesh=function(){return m.getMesh(T)};let O=null;const N=new Uc;N.setAnimationLoop((function(e,r){if(l=r.getViewerPose(h||s),p=r,null!==l){const e=l.views;null!==u&&(t.setRenderTargetFramebuffer(v,u.framebuffer),t.setRenderTarget(v));let i=!1;e.length!==T.cameras.length&&(T.cameras.length=0,i=!0);for(let n=0;n<e.length;n++){const r=e[n];let s=null;if(null!==u)s=u.getViewport(r);else{const e=c.getViewSubImage(d,r);s=e.viewport,0===n&&(t.setRenderTargetTextures(v,e.colorTexture,d.ignoreDepthValues?void 0:e.depthStencilTexture),t.setRenderTarget(v))}let a=M[n];void 0===a&&(a=new jr,a.layers.enable(n),a.viewport=new wi,M[n]=a),a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(r.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(s.x,s.y,s.width,s.height),0===n&&(T.matrix.copy(a.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),!0===i&&T.cameras.push(a)}const r=n.enabledFeatures;if(r&&r.includes("depth-sensing")&&"gpu-optimized"==n.depthUsage&&c){const i=c.getDepthInformation(e[0]);i&&i.isValid&&i.texture&&m.init(t,i,n.renderState)}}for(let t=0;t<_.length;t++){const e=y[t],i=_[t];null!==e&&void 0!==i&&i.update(e,r,h||s)}O&&O(e,r),r.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:r}),p=null})),this.setAnimationLoop=function(t){O=t},this.dispose=function(){}}}const pp=new fn,mp=new sn;function fp(t,e){function i(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function n(t,n){t.opacity.value=n.opacity,n.color&&t.diffuse.value.copy(n.color),n.emissive&&t.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(t.map.value=n.map,i(n.map,t.mapTransform)),n.alphaMap&&(t.alphaMap.value=n.alphaMap,i(n.alphaMap,t.alphaMapTransform)),n.bumpMap&&(t.bumpMap.value=n.bumpMap,i(n.bumpMap,t.bumpMapTransform),t.bumpScale.value=n.bumpScale,1===n.side&&(t.bumpScale.value*=-1)),n.normalMap&&(t.normalMap.value=n.normalMap,i(n.normalMap,t.normalMapTransform),t.normalScale.value.copy(n.normalScale),1===n.side&&t.normalScale.value.negate()),n.displacementMap&&(t.displacementMap.value=n.displacementMap,i(n.displacementMap,t.displacementMapTransform),t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias),n.emissiveMap&&(t.emissiveMap.value=n.emissiveMap,i(n.emissiveMap,t.emissiveMapTransform)),n.specularMap&&(t.specularMap.value=n.specularMap,i(n.specularMap,t.specularMapTransform)),n.alphaTest>0&&(t.alphaTest.value=n.alphaTest);const r=e.get(n),s=r.envMap,a=r.envMapRotation;s&&(t.envMap.value=s,pp.copy(a),pp.x*=-1,pp.y*=-1,pp.z*=-1,s.isCubeTexture&&!1===s.isRenderTargetTexture&&(pp.y*=-1,pp.z*=-1),t.envMapRotation.value.setFromMatrix4(mp.makeRotationFromEuler(pp)),t.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,t.reflectivity.value=n.reflectivity,t.ior.value=n.ior,t.refractionRatio.value=n.refractionRatio),n.lightMap&&(t.lightMap.value=n.lightMap,t.lightMapIntensity.value=n.lightMapIntensity,i(n.lightMap,t.lightMapTransform)),n.aoMap&&(t.aoMap.value=n.aoMap,t.aoMapIntensity.value=n.aoMapIntensity,i(n.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,i){i.color.getRGB(e.fogColor.value,kr(t)),i.isFog?(e.fogNear.value=i.near,e.fogFar.value=i.far):i.isFogExp2&&(e.fogDensity.value=i.density)},refreshMaterialUniforms:function(t,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?n(t,r):r.isMeshToonMaterial?(n(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(n(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(n(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,i(e.metalnessMap,t.metalnessMapTransform));t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,i(e.roughnessMap,t.roughnessMapTransform));e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,n){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,i(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,i(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,i(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,i(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,i(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),1===e.side&&t.clearcoatNormalScale.value.negate()));e.dispersion>0&&(t.dispersion.value=e.dispersion);e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,i(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,i(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,i(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,i(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,i(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,i(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,i(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(n(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?n(t,r):r.isMeshDistanceMaterial?(n(t,r),function(t,i){const n=e.get(i).light;t.referencePosition.value.setFromMatrixPosition(n.matrixWorld),t.nearDistance.value=n.shadow.camera.near,t.farDistance.value=n.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?n(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,n,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*r,e.map&&(t.map.value=e.map,i(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,a):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function gp(t,e,i,n){let r={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function h(t,e,i,n){const r=t.value,s=e+"_"+i;if(void 0===n[s])return n[s]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const t=n[s];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return n[s]=r,!0}else if(!1===t.equals(r))return t.copy(r),!0}return!1}function l(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),e}function c(e){const i=e.target;i.removeEventListener("dispose",c);const n=a.indexOf(i.__bindingPointIndex);a.splice(n,1),t.deleteBuffer(r[i.id]),delete r[i.id],delete s[i.id]}return{bind:function(t,e){const i=e.program;n.uniformBlockBinding(t,i)},update:function(i,d){let u=r[i.id];void 0===u&&(!function(t){const e=t.uniforms;let i=0;const n=16;for(let t=0,r=e.length;t<r;t++){const r=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=r.length;t<e;t++){const e=r[t],s=Array.isArray(e.value)?e.value:[e.value];for(let t=0,r=s.length;t<r;t++){const r=l(s[t]),a=i%n,o=a%r.boundary,h=a+o;i+=o,0!==h&&n-h<r.storage&&(i+=n-h),e.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=i,i+=r.storage}}}const r=i%n;r>0&&(i+=n-r);t.__size=i,t.__cache={}}(i),u=function(e){const i=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=i;const n=t.createBuffer(),r=e.__size,s=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,r,s),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,i,n),n}(i),r[i.id]=u,i.addEventListener("dispose",c));const p=d.program;n.updateUBOMapping(i,p);const m=e.render.frame;s[i.id]!==m&&(!function(e){const i=r[e.id],n=e.uniforms,s=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,i);for(let e=0,i=n.length;e<i;e++){const i=Array.isArray(n[e])?n[e]:[n[e]];for(let n=0,r=i.length;n<r;n++){const r=i[n];if(!0===h(r,e,n,s)){const e=r.__offset,i=Array.isArray(r.value)?r.value:[r.value];let n=0;for(let s=0;s<i.length;s++){const a=i[s],o=l(a);"number"==typeof a||"boolean"==typeof a?(r.__data[0]=a,t.bufferSubData(t.UNIFORM_BUFFER,e+n,r.__data)):a.isMatrix3?(r.__data[0]=a.elements[0],r.__data[1]=a.elements[1],r.__data[2]=a.elements[2],r.__data[3]=0,r.__data[4]=a.elements[3],r.__data[5]=a.elements[4],r.__data[6]=a.elements[5],r.__data[7]=0,r.__data[8]=a.elements[6],r.__data[9]=a.elements[7],r.__data[10]=a.elements[8],r.__data[11]=0):(a.toArray(r.__data,n),n+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,r.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(i),s[i.id]=m)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);a=[],r={},s={}}}}class vp{constructor(t={}){const{canvas:e=ai(),context:i=null,depth:n=!0,stencil:r=!1,alpha:s=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:h=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:c=!1,reverseDepthBuffer:d=!1}=t;let u;if(this.isWebGLRenderer=!0,null!==i){if("undefined"!=typeof WebGLRenderingContext&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");u=i.getContextAttributes().alpha}else u=s;const p=new Uint32Array(4),m=new Int32Array(4);let f=null,g=null;const v=[],y=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Me,this.toneMapping=0,this.toneMappingExposure=1;const x=this;let b=!1,w=0,S=0,M=null,T=-1,E=null;const A=new wi,C=new wi;let R=null;const P=new Jn(0);let L=0,I=e.width,D=e.height,O=1,N=null,U=null;const F=new wi(0,0,I,D),k=new wi(0,0,I,D);let B=!1;const z=new ta;let G=!1,H=!1;this.transmissionResolutionScale=1;const V=new sn,W=new sn,j=new Ci,X=new wi,Y={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let q=!1;function K(){return null===M?O:1}let Z,J,Q,$,tt,et,it,nt,rt,st,at,ot,ht,lt,ct,dt,mt,ft,vt,yt,Mt,Tt,Et,At,Ct=i;function Rt(t,i){return e.getContext(t,i)}try{const t={alpha:!0,depth:n,stencil:r,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:h,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${_}`),e.addEventListener("webglcontextlost",It,!1),e.addEventListener("webglcontextrestored",Ot,!1),e.addEventListener("webglcontextcreationerror",Ft,!1),null===Ct){const e="webgl2";if(Ct=Rt(e,t),null===Ct)throw Rt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function Pt(){Z=new md(Ct),Z.init(),Tt=new cp(Ct,Z),J=new Yc(Ct,Z,t,Tt),Q=new hp(Ct,Z),J.reverseDepthBuffer&&d&&Q.buffers.depth.setReversed(!0),$=new vd(Ct),tt=new Ku,et=new lp(Ct,Z,Q,tt,J,Tt,$),it=new Kc(x),nt=new pd(x),rt=new Fc(Ct),Et=new jc(Ct,rt),st=new fd(Ct,rt,$,Et),at=new yd(Ct,st,rt,$),vt=new _d(Ct,J,et),dt=new qc(tt),ot=new qu(x,it,nt,Z,J,Et,dt),ht=new fp(x,tt),lt=new $u,ct=new sp(Z),ft=new Wc(x,it,nt,Q,at,u,o),mt=new ap(x,at,J),At=new gp(Ct,$,J,Q),yt=new Xc(Ct,Z,$),Mt=new gd(Ct,Z,$),$.programs=ot.programs,x.capabilities=J,x.extensions=Z,x.properties=tt,x.renderLists=lt,x.shadowMap=mt,x.state=Q,x.info=$}Pt();const Lt=new up(x,Ct);function It(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function Ot(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;const t=$.autoReset,e=mt.enabled,i=mt.autoUpdate,n=mt.needsUpdate,r=mt.type;Pt(),$.autoReset=t,mt.enabled=e,mt.autoUpdate=i,mt.needsUpdate=n,mt.type=r}function Ft(t){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function kt(t){const e=t.target;e.removeEventListener("dispose",kt),function(t){(function(t){const e=tt.get(t).programs;void 0!==e&&(e.forEach((function(t){ot.releaseProgram(t)})),t.isShaderMaterial&&ot.releaseShaderCache(t))})(t),tt.remove(t)}(e)}function Bt(t,e,i){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,Kt(t,e,i),t.side=0,t.needsUpdate=!0,Kt(t,e,i),t.side=2):Kt(t,e,i)}this.xr=Lt,this.getContext=function(){return Ct},this.getContextAttributes=function(){return Ct.getContextAttributes()},this.forceContextLoss=function(){const t=Z.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=Z.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return O},this.setPixelRatio=function(t){void 0!==t&&(O=t,this.setSize(I,D,!1))},this.getSize=function(t){return t.set(I,D)},this.setSize=function(t,i,n=!0){Lt.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(I=t,D=i,e.width=Math.floor(t*O),e.height=Math.floor(i*O),!0===n&&(e.style.width=t+"px",e.style.height=i+"px"),this.setViewport(0,0,t,i))},this.getDrawingBufferSize=function(t){return t.set(I*O,D*O).floor()},this.setDrawingBufferSize=function(t,i,n){I=t,D=i,O=n,e.width=Math.floor(t*n),e.height=Math.floor(i*n),this.setViewport(0,0,t,i)},this.getCurrentViewport=function(t){return t.copy(A)},this.getViewport=function(t){return t.copy(F)},this.setViewport=function(t,e,i,n){t.isVector4?F.set(t.x,t.y,t.z,t.w):F.set(t,e,i,n),Q.viewport(A.copy(F).multiplyScalar(O).round())},this.getScissor=function(t){return t.copy(k)},this.setScissor=function(t,e,i,n){t.isVector4?k.set(t.x,t.y,t.z,t.w):k.set(t,e,i,n),Q.scissor(C.copy(k).multiplyScalar(O).round())},this.getScissorTest=function(){return B},this.setScissorTest=function(t){Q.setScissorTest(B=t)},this.setOpaqueSort=function(t){N=t},this.setTransparentSort=function(t){U=t},this.getClearColor=function(t){return t.copy(ft.getClearColor())},this.setClearColor=function(){ft.setClearColor.apply(ft,arguments)},this.getClearAlpha=function(){return ft.getClearAlpha()},this.setClearAlpha=function(){ft.setClearAlpha.apply(ft,arguments)},this.clear=function(t=!0,e=!0,i=!0){let n=0;if(t){let t=!1;if(null!==M){const e=M.texture.format;t=e===Ut||e===Nt||e===Dt}if(t){const t=M.texture.type,e=t===pt||t===_t||t===gt||t===St||t===bt||t===wt,i=ft.getClearColor(),n=ft.getClearAlpha(),r=i.r,s=i.g,a=i.b;e?(p[0]=r,p[1]=s,p[2]=a,p[3]=n,Ct.clearBufferuiv(Ct.COLOR,0,p)):(m[0]=r,m[1]=s,m[2]=a,m[3]=n,Ct.clearBufferiv(Ct.COLOR,0,m))}else n|=Ct.COLOR_BUFFER_BIT}e&&(n|=Ct.DEPTH_BUFFER_BIT),i&&(n|=Ct.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Ct.clear(n)},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(){e.removeEventListener("webglcontextlost",It,!1),e.removeEventListener("webglcontextrestored",Ot,!1),e.removeEventListener("webglcontextcreationerror",Ft,!1),ft.dispose(),lt.dispose(),ct.dispose(),tt.dispose(),it.dispose(),nt.dispose(),at.dispose(),Et.dispose(),At.dispose(),ot.dispose(),Lt.dispose(),Lt.removeEventListener("sessionstart",Gt),Lt.removeEventListener("sessionend",Ht),Vt.stop()},this.renderBufferDirect=function(t,e,i,n,r,s){null===e&&(e=Y);const a=r.isMesh&&r.matrixWorld.determinant()<0,o=function(t,e,i,n,r){!0!==e.isScene&&(e=Y);et.resetTextureUnits();const s=e.fog,a=n.isMeshStandardMaterial?e.environment:null,o=null===M?x.outputColorSpace:!0===M.isXRRenderTarget?M.texture.colorSpace:Te,h=(n.isMeshStandardMaterial?nt:it).get(n.envMap||a),l=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,c=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),d=!!i.morphAttributes.position,u=!!i.morphAttributes.normal,p=!!i.morphAttributes.color;let m=0;n.toneMapped&&(null!==M&&!0!==M.isXRRenderTarget||(m=x.toneMapping));const f=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,v=void 0!==f?f.length:0,_=tt.get(n),y=g.state.lights;if(!0===G&&(!0===H||t!==E)){const e=t===E&&n.id===T;dt.setState(n,t,e)}let b=!1;n.version===_.__version?_.needsLights&&_.lightsStateVersion!==y.state.version||_.outputColorSpace!==o||r.isBatchedMesh&&!1===_.batching?b=!0:r.isBatchedMesh||!0!==_.batching?r.isBatchedMesh&&!0===_.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===_.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===_.instancing?b=!0:r.isInstancedMesh||!0!==_.instancing?r.isSkinnedMesh&&!1===_.skinning?b=!0:r.isSkinnedMesh||!0!==_.skinning?r.isInstancedMesh&&!0===_.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===_.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===_.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===_.instancingMorph&&null!==r.morphTexture||_.envMap!==h||!0===n.fog&&_.fog!==s?b=!0:void 0===_.numClippingPlanes||_.numClippingPlanes===dt.numPlanes&&_.numIntersection===dt.numIntersection?(_.vertexAlphas!==l||_.vertexTangents!==c||_.morphTargets!==d||_.morphNormals!==u||_.morphColors!==p||_.toneMapping!==m||_.morphTargetsCount!==v)&&(b=!0):b=!0:b=!0:b=!0:b=!0:(b=!0,_.__version=n.version);let w=_.currentProgram;!0===b&&(w=Kt(n,e,r));let S=!1,A=!1,C=!1;const R=w.getUniforms(),P=_.uniforms;Q.useProgram(w.program)&&(S=!0,A=!0,C=!0);n.id!==T&&(T=n.id,A=!0);if(S||E!==t){Q.buffers.depth.getReversed()?(V.copy(t.projectionMatrix),function(t){const e=t.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}(V),function(t){const e=t.elements;-1===e[11]?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=1-e[14])}(V),R.setValue(Ct,"projectionMatrix",V)):R.setValue(Ct,"projectionMatrix",t.projectionMatrix),R.setValue(Ct,"viewMatrix",t.matrixWorldInverse);const e=R.map.cameraPosition;void 0!==e&&e.setValue(Ct,j.setFromMatrixPosition(t.matrixWorld)),J.logarithmicDepthBuffer&&R.setValue(Ct,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&R.setValue(Ct,"isOrthographic",!0===t.isOrthographicCamera),E!==t&&(E=t,A=!0,C=!0)}if(r.isSkinnedMesh){R.setOptional(Ct,r,"bindMatrix"),R.setOptional(Ct,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),R.setValue(Ct,"boneTexture",t.boneTexture,et))}r.isBatchedMesh&&(R.setOptional(Ct,r,"batchingTexture"),R.setValue(Ct,"batchingTexture",r._matricesTexture,et),R.setOptional(Ct,r,"batchingIdTexture"),R.setValue(Ct,"batchingIdTexture",r._indirectTexture,et),R.setOptional(Ct,r,"batchingColorTexture"),null!==r._colorsTexture&&R.setValue(Ct,"batchingColorTexture",r._colorsTexture,et));const L=i.morphAttributes;void 0===L.position&&void 0===L.normal&&void 0===L.color||vt.update(r,i,w);(A||_.receiveShadow!==r.receiveShadow)&&(_.receiveShadow=r.receiveShadow,R.setValue(Ct,"receiveShadow",r.receiveShadow));n.isMeshGouraudMaterial&&null!==n.envMap&&(P.envMap.value=h,P.flipEnvMap.value=h.isCubeTexture&&!1===h.isRenderTargetTexture?-1:1);n.isMeshStandardMaterial&&null===n.envMap&&null!==e.environment&&(P.envMapIntensity.value=e.environmentIntensity);A&&(R.setValue(Ct,"toneMappingExposure",x.toneMappingExposure),_.needsLights&&(N=C,(I=P).ambientLightColor.needsUpdate=N,I.lightProbe.needsUpdate=N,I.directionalLights.needsUpdate=N,I.directionalLightShadows.needsUpdate=N,I.pointLights.needsUpdate=N,I.pointLightShadows.needsUpdate=N,I.spotLights.needsUpdate=N,I.spotLightShadows.needsUpdate=N,I.rectAreaLights.needsUpdate=N,I.hemisphereLights.needsUpdate=N),s&&!0===n.fog&&ht.refreshFogUniforms(P,s),ht.refreshMaterialUniforms(P,n,O,D,g.state.transmissionRenderTarget[t.id]),Mu.upload(Ct,Zt(_),P,et));var I,N;n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Mu.upload(Ct,Zt(_),P,et),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&R.setValue(Ct,"center",r.center);if(R.setValue(Ct,"modelViewMatrix",r.modelViewMatrix),R.setValue(Ct,"normalMatrix",r.normalMatrix),R.setValue(Ct,"modelMatrix",r.matrixWorld),n.isShaderMaterial||n.isRawShaderMaterial){const t=n.uniformsGroups;for(let e=0,i=t.length;e<i;e++){const i=t[e];At.update(i,w),At.bind(i,w)}}return w}(t,e,i,n,r);Q.setMaterial(n,a);let h=i.index,l=1;if(!0===n.wireframe){if(h=st.getWireframeAttribute(i),void 0===h)return;l=2}const c=i.drawRange,d=i.attributes.position;let u=c.start*l,p=(c.start+c.count)*l;null!==s&&(u=Math.max(u,s.start*l),p=Math.min(p,(s.start+s.count)*l)),null!==h?(u=Math.max(u,0),p=Math.min(p,h.count)):null!=d&&(u=Math.max(u,0),p=Math.min(p,d.count));const m=p-u;if(m<0||m===1/0)return;let f;Et.setup(r,n,o,i,h);let v=yt;if(null!==h&&(f=rt.get(h),v=Mt,v.setIndex(f)),r.isMesh)!0===n.wireframe?(Q.setLineWidth(n.wireframeLinewidth*K()),v.setMode(Ct.LINES)):v.setMode(Ct.TRIANGLES);else if(r.isLine){let t=n.linewidth;void 0===t&&(t=1),Q.setLineWidth(t*K()),r.isLineSegments?v.setMode(Ct.LINES):r.isLineLoop?v.setMode(Ct.LINE_LOOP):v.setMode(Ct.LINE_STRIP)}else r.isPoints?v.setMode(Ct.POINTS):r.isSprite&&v.setMode(Ct.TRIANGLES);if(r.isBatchedMesh)if(null!==r._multiDrawInstances)v.renderMultiDrawInstances(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount,r._multiDrawInstances);else if(Z.get("WEBGL_multi_draw"))v.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const t=r._multiDrawStarts,e=r._multiDrawCounts,i=r._multiDrawCount,s=h?rt.get(h).bytesPerElement:1,a=tt.get(n).currentProgram.getUniforms();for(let n=0;n<i;n++)a.setValue(Ct,"_gl_DrawID",n),v.render(t[n]/s,e[n])}else if(r.isInstancedMesh)v.renderInstances(u,m,r.count);else if(i.isInstancedBufferGeometry){const t=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,e=Math.min(i.instanceCount,t);v.renderInstances(u,m,e)}else v.render(u,m)},this.compile=function(t,e,i=null){null===i&&(i=t),g=ct.get(i),g.init(e),y.push(g),i.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))})),t!==i&&t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))})),g.setupLights();const n=new Set;return t.traverse((function(t){if(!(t.isMesh||t.isPoints||t.isLine||t.isSprite))return;const e=t.material;if(e)if(Array.isArray(e))for(let r=0;r<e.length;r++){const s=e[r];Bt(s,i,t),n.add(s)}else Bt(e,i,t),n.add(e)})),y.pop(),g=null,n},this.compileAsync=function(t,e,i=null){const n=this.compile(t,e,i);return new Promise((e=>{function i(){n.forEach((function(t){tt.get(t).currentProgram.isReady()&&n.delete(t)})),0!==n.size?setTimeout(i,10):e(t)}null!==Z.get("KHR_parallel_shader_compile")?i():setTimeout(i,10)}))};let zt=null;function Gt(){Vt.stop()}function Ht(){Vt.start()}const Vt=new Uc;function Wt(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)g.pushLight(t),t.castShadow&&g.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||z.intersectsSprite(t)){n&&X.setFromMatrixPosition(t.matrixWorld).applyMatrix4(W);const e=at.update(t),r=t.material;r.visible&&f.push(t,e,r,i,X.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||z.intersectsObject(t))){const e=at.update(t),r=t.material;if(n&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),X.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),X.copy(e.boundingSphere.center)),X.applyMatrix4(t.matrixWorld).applyMatrix4(W)),Array.isArray(r)){const n=e.groups;for(let s=0,a=n.length;s<a;s++){const a=n[s],o=r[a.materialIndex];o&&o.visible&&f.push(t,e,o,i,X.z,a)}}else r.visible&&f.push(t,e,r,i,X.z,null)}const r=t.children;for(let t=0,s=r.length;t<s;t++)Wt(r[t],e,i,n)}function jt(t,e,i,n){const r=t.opaque,s=t.transmissive,a=t.transparent;g.setupLightsView(i),!0===G&&dt.setGlobalState(x.clippingPlanes,i),n&&Q.viewport(A.copy(n)),r.length>0&&Yt(r,e,i),s.length>0&&Yt(s,e,i),a.length>0&&Yt(a,e,i),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function Xt(t,e,i,n){if(null!==(!0===i.isScene?i.overrideMaterial:null))return;void 0===g.state.transmissionRenderTarget[n.id]&&(g.state.transmissionRenderTarget[n.id]=new Mi(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")||Z.has("EXT_color_buffer_float")?xt:pt,minFilter:ut,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ui.workingColorSpace}));const s=g.state.transmissionRenderTarget[n.id],a=n.viewport||A;s.setSize(a.z*x.transmissionResolutionScale,a.w*x.transmissionResolutionScale);const o=x.getRenderTarget();x.setRenderTarget(s),x.getClearColor(P),L=x.getClearAlpha(),L<1&&x.setClearColor(16777215,.5),x.clear(),q&&ft.render(i);const h=x.toneMapping;x.toneMapping=0;const l=n.viewport;if(void 0!==n.viewport&&(n.viewport=void 0),g.setupLightsView(n),!0===G&&dt.setGlobalState(x.clippingPlanes,n),Yt(t,i,n),et.updateMultisampleRenderTarget(s),et.updateRenderTargetMipmap(s),!1===Z.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,s=e.length;r<s;r++){const s=e[r],a=s.object,o=s.geometry,h=s.material,l=s.group;if(2===h.side&&a.layers.test(n.layers)){const e=h.side;h.side=1,h.needsUpdate=!0,qt(a,i,n,o,h,l),h.side=e,h.needsUpdate=!0,t=!0}}!0===t&&(et.updateMultisampleRenderTarget(s),et.updateRenderTargetMipmap(s))}x.setRenderTarget(o),x.setClearColor(P,L),void 0!==l&&(n.viewport=l),x.toneMapping=h}function Yt(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let r=0,s=t.length;r<s;r++){const s=t[r],a=s.object,o=s.geometry,h=null===n?s.material:n,l=s.group;a.layers.test(i.layers)&&qt(a,e,i,o,h,l)}}function qt(t,e,i,n,r,s){t.onBeforeRender(x,e,i,n,r,s),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),r.onBeforeRender(x,e,i,n,t,s),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,x.renderBufferDirect(i,e,n,r,t,s),r.side=0,r.needsUpdate=!0,x.renderBufferDirect(i,e,n,r,t,s),r.side=2):x.renderBufferDirect(i,e,n,r,t,s),t.onAfterRender(x,e,i,n,r,s)}function Kt(t,e,i){!0!==e.isScene&&(e=Y);const n=tt.get(t),r=g.state.lights,s=g.state.shadowsArray,a=r.state.version,o=ot.getParameters(t,r.state,s,e,i),h=ot.getProgramCacheKey(o);let l=n.programs;n.environment=t.isMeshStandardMaterial?e.environment:null,n.fog=e.fog,n.envMap=(t.isMeshStandardMaterial?nt:it).get(t.envMap||n.environment),n.envMapRotation=null!==n.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===l&&(t.addEventListener("dispose",kt),l=new Map,n.programs=l);let c=l.get(h);if(void 0!==c){if(n.currentProgram===c&&n.lightsStateVersion===a)return Jt(t,o),c}else o.uniforms=ot.getUniforms(t),t.onBeforeCompile(o,x),c=ot.acquireProgram(o,h),l.set(h,c),n.uniforms=o.uniforms;const d=n.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(d.clippingPlanes=dt.uniform),Jt(t,o),n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=a,n.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),n.currentProgram=c,n.uniformsList=null,c}function Zt(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=Mu.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function Jt(t,e){const i=tt.get(t);i.outputColorSpace=e.outputColorSpace,i.batching=e.batching,i.batchingColor=e.batchingColor,i.instancing=e.instancing,i.instancingColor=e.instancingColor,i.instancingMorph=e.instancingMorph,i.skinning=e.skinning,i.morphTargets=e.morphTargets,i.morphNormals=e.morphNormals,i.morphColors=e.morphColors,i.morphTargetsCount=e.morphTargetsCount,i.numClippingPlanes=e.numClippingPlanes,i.numIntersection=e.numClipIntersection,i.vertexAlphas=e.vertexAlphas,i.vertexTangents=e.vertexTangents,i.toneMapping=e.toneMapping}Vt.setAnimationLoop((function(t){zt&&zt(t)})),"undefined"!=typeof self&&Vt.setContext(self),this.setAnimationLoop=function(t){zt=t,Lt.setAnimationLoop(t),null===t?Vt.stop():Vt.start()},Lt.addEventListener("sessionstart",Gt),Lt.addEventListener("sessionend",Ht),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===b)return;if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===Lt.enabled&&!0===Lt.isPresenting&&(!0===Lt.cameraAutoUpdate&&Lt.updateCamera(e),e=Lt.getCamera()),!0===t.isScene&&t.onBeforeRender(x,t,e,M),g=ct.get(t,y.length),g.init(e),y.push(g),W.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),z.setFromProjectionMatrix(W),H=this.localClippingEnabled,G=dt.init(this.clippingPlanes,H),f=lt.get(t,v.length),f.init(),v.push(f),!0===Lt.enabled&&!0===Lt.isPresenting){const t=x.xr.getDepthSensingMesh();null!==t&&Wt(t,e,-1/0,x.sortObjects)}Wt(t,e,0,x.sortObjects),f.finish(),!0===x.sortObjects&&f.sort(N,U),q=!1===Lt.enabled||!1===Lt.isPresenting||!1===Lt.hasDepthSensing(),q&&ft.addToRenderList(f,t),this.info.render.frame++,!0===G&&dt.beginShadows();const i=g.state.shadowsArray;mt.render(i,t,e),!0===G&&dt.endShadows(),!0===this.info.autoReset&&this.info.reset();const n=f.opaque,r=f.transmissive;if(g.setupLights(),e.isArrayCamera){const i=e.cameras;if(r.length>0)for(let e=0,s=i.length;e<s;e++){Xt(n,r,t,i[e])}q&&ft.render(t);for(let e=0,n=i.length;e<n;e++){const n=i[e];jt(f,t,n,n.viewport)}}else r.length>0&&Xt(n,r,t,e),q&&ft.render(t),jt(f,t,e);null!==M&&0===S&&(et.updateMultisampleRenderTarget(M),et.updateRenderTargetMipmap(M)),!0===t.isScene&&t.onAfterRender(x,t,e),Et.resetDefaultState(),T=-1,E=null,y.pop(),y.length>0?(g=y[y.length-1],!0===G&&dt.setGlobalState(x.clippingPlanes,g.state.camera)):g=null,v.pop(),f=v.length>0?v[v.length-1]:null},this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return S},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(t,e,i){tt.get(t.texture).__webglTexture=e,tt.get(t.depthTexture).__webglTexture=i;const n=tt.get(t);n.__hasExternalTextures=!0,n.__autoAllocateDepthBuffer=void 0===i,n.__autoAllocateDepthBuffer||!0===Z.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),n.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(t,e){const i=tt.get(t);i.__webglFramebuffer=e,i.__useDefaultFramebuffer=void 0===e};const Qt=Ct.createFramebuffer();this.setRenderTarget=function(t,e=0,i=0){M=t,w=e,S=i;let n=!0,r=null,s=!1,a=!1;if(t){const o=tt.get(t);if(void 0!==o.__useDefaultFramebuffer)Q.bindFramebuffer(Ct.FRAMEBUFFER,null),n=!1;else if(void 0===o.__webglFramebuffer)et.setupRenderTarget(t);else if(o.__hasExternalTextures)et.rebindTextures(t,tt.get(t.texture).__webglTexture,tt.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(o.__boundDepthTexture!==e){if(null!==e&&tt.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");et.setupDepthRenderbuffer(t)}}const h=t.texture;(h.isData3DTexture||h.isDataArrayTexture||h.isCompressedArrayTexture)&&(a=!0);const l=tt.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=Array.isArray(l[e])?l[e][i]:l[e],s=!0):r=t.samples>0&&!1===et.useMultisampledRTT(t)?tt.get(t).__webglMultisampledFramebuffer:Array.isArray(l)?l[i]:l,A.copy(t.viewport),C.copy(t.scissor),R=t.scissorTest}else A.copy(F).multiplyScalar(O).floor(),C.copy(k).multiplyScalar(O).floor(),R=B;0!==i&&(r=Qt);if(Q.bindFramebuffer(Ct.FRAMEBUFFER,r)&&n&&Q.drawBuffers(t,r),Q.viewport(A),Q.scissor(C),Q.setScissorTest(R),s){const n=tt.get(t.texture);Ct.framebufferTexture2D(Ct.FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.__webglTexture,i)}else if(a){const n=tt.get(t.texture),r=e;Ct.framebufferTextureLayer(Ct.FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,n.__webglTexture,i,r)}else if(null!==t&&0!==i){const e=tt.get(t.texture);Ct.framebufferTexture2D(Ct.FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_2D,e.__webglTexture,i)}T=-1},this.readRenderTargetPixels=function(t,e,i,n,r,s,a){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=tt.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){Q.bindFramebuffer(Ct.FRAMEBUFFER,o);try{const a=t.texture,o=a.format,h=a.type;if(!J.textureFormatReadable(o))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!J.textureTypeReadable(h))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&Ct.readPixels(e,i,n,r,Tt.convert(o),Tt.convert(h),s)}finally{const t=null!==M?tt.get(M).__webglFramebuffer:null;Q.bindFramebuffer(Ct.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,i,n,r,s,a){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=tt.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){const a=t.texture,h=a.format,l=a.type;if(!J.textureFormatReadable(h))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!J.textureTypeReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r){Q.bindFramebuffer(Ct.FRAMEBUFFER,o);const t=Ct.createBuffer();Ct.bindBuffer(Ct.PIXEL_PACK_BUFFER,t),Ct.bufferData(Ct.PIXEL_PACK_BUFFER,s.byteLength,Ct.STREAM_READ),Ct.readPixels(e,i,n,r,Tt.convert(h),Tt.convert(l),0);const a=null!==M?tt.get(M).__webglFramebuffer:null;Q.bindFramebuffer(Ct.FRAMEBUFFER,a);const c=Ct.fenceSync(Ct.SYNC_GPU_COMMANDS_COMPLETE,0);return Ct.flush(),await function(t,e,i){return new Promise((function(n,r){setTimeout((function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(s,i);break;default:n()}}),i)}))}(Ct,c,4),Ct.bindBuffer(Ct.PIXEL_PACK_BUFFER,t),Ct.getBufferSubData(Ct.PIXEL_PACK_BUFFER,0,s),Ct.deleteBuffer(t),Ct.deleteSync(c),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,i=0){!0!==t.isTexture&&(hi("WebGLRenderer: copyFramebufferToTexture function signature has changed."),e=arguments[0]||null,t=arguments[1]);const n=Math.pow(2,-i),r=Math.floor(t.image.width*n),s=Math.floor(t.image.height*n),a=null!==e?e.x:0,o=null!==e?e.y:0;et.setTexture2D(t,0),Ct.copyTexSubImage2D(Ct.TEXTURE_2D,i,0,0,a,o,r,s),Q.unbindTexture()};const $t=Ct.createFramebuffer(),te=Ct.createFramebuffer();this.copyTextureToTexture=function(t,e,i=null,n=null,r=0,s=null){let a,o,h,l,c,d,u,p,m;!0!==t.isTexture&&(hi("WebGLRenderer: copyTextureToTexture function signature has changed."),n=arguments[0]||null,t=arguments[1],e=arguments[2],s=arguments[3]||0,i=null),null===s&&(0!==r?(hi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),s=r,r=0):s=0);const f=t.isCompressedTexture?t.mipmaps[s]:t.image;if(null!==i)a=i.max.x-i.min.x,o=i.max.y-i.min.y,h=i.isBox3?i.max.z-i.min.z:1,l=i.min.x,c=i.min.y,d=i.isBox3?i.min.z:0;else{const e=Math.pow(2,-r);a=Math.floor(f.width*e),o=Math.floor(f.height*e),h=t.isDataArrayTexture?f.depth:t.isData3DTexture?Math.floor(f.depth*e):1,l=0,c=0,d=0}null!==n?(u=n.x,p=n.y,m=n.z):(u=0,p=0,m=0);const g=Tt.convert(e.format),v=Tt.convert(e.type);let _;e.isData3DTexture?(et.setTexture3D(e,0),_=Ct.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(et.setTexture2DArray(e,0),_=Ct.TEXTURE_2D_ARRAY):(et.setTexture2D(e,0),_=Ct.TEXTURE_2D),Ct.pixelStorei(Ct.UNPACK_FLIP_Y_WEBGL,e.flipY),Ct.pixelStorei(Ct.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),Ct.pixelStorei(Ct.UNPACK_ALIGNMENT,e.unpackAlignment);const y=Ct.getParameter(Ct.UNPACK_ROW_LENGTH),x=Ct.getParameter(Ct.UNPACK_IMAGE_HEIGHT),b=Ct.getParameter(Ct.UNPACK_SKIP_PIXELS),w=Ct.getParameter(Ct.UNPACK_SKIP_ROWS),S=Ct.getParameter(Ct.UNPACK_SKIP_IMAGES);Ct.pixelStorei(Ct.UNPACK_ROW_LENGTH,f.width),Ct.pixelStorei(Ct.UNPACK_IMAGE_HEIGHT,f.height),Ct.pixelStorei(Ct.UNPACK_SKIP_PIXELS,l),Ct.pixelStorei(Ct.UNPACK_SKIP_ROWS,c),Ct.pixelStorei(Ct.UNPACK_SKIP_IMAGES,d);const M=t.isDataArrayTexture||t.isData3DTexture,T=e.isDataArrayTexture||e.isData3DTexture;if(t.isDepthTexture){const i=tt.get(t),n=tt.get(e),f=tt.get(i.__renderTarget),g=tt.get(n.__renderTarget);Q.bindFramebuffer(Ct.READ_FRAMEBUFFER,f.__webglFramebuffer),Q.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let i=0;i<h;i++)M&&(Ct.framebufferTextureLayer(Ct.READ_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,tt.get(t).__webglTexture,r,d+i),Ct.framebufferTextureLayer(Ct.DRAW_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,tt.get(e).__webglTexture,s,m+i)),Ct.blitFramebuffer(l,c,a,o,u,p,a,o,Ct.DEPTH_BUFFER_BIT,Ct.NEAREST);Q.bindFramebuffer(Ct.READ_FRAMEBUFFER,null),Q.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,null)}else if(0!==r||t.isRenderTargetTexture||tt.has(t)){const i=tt.get(t),n=tt.get(e);Q.bindFramebuffer(Ct.READ_FRAMEBUFFER,$t),Q.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,te);for(let t=0;t<h;t++)M?Ct.framebufferTextureLayer(Ct.READ_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,i.__webglTexture,r,d+t):Ct.framebufferTexture2D(Ct.READ_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_2D,i.__webglTexture,r),T?Ct.framebufferTextureLayer(Ct.DRAW_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,n.__webglTexture,s,m+t):Ct.framebufferTexture2D(Ct.DRAW_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_2D,n.__webglTexture,s),0!==r?Ct.blitFramebuffer(l,c,a,o,u,p,a,o,Ct.COLOR_BUFFER_BIT,Ct.NEAREST):T?Ct.copyTexSubImage3D(_,s,u,p,m+t,l,c,a,o):Ct.copyTexSubImage2D(_,s,u,p,l,c,a,o);Q.bindFramebuffer(Ct.READ_FRAMEBUFFER,null),Q.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,null)}else T?t.isDataTexture||t.isData3DTexture?Ct.texSubImage3D(_,s,u,p,m,a,o,h,g,v,f.data):e.isCompressedArrayTexture?Ct.compressedTexSubImage3D(_,s,u,p,m,a,o,h,g,f.data):Ct.texSubImage3D(_,s,u,p,m,a,o,h,g,v,f):t.isDataTexture?Ct.texSubImage2D(Ct.TEXTURE_2D,s,u,p,a,o,g,v,f.data):t.isCompressedTexture?Ct.compressedTexSubImage2D(Ct.TEXTURE_2D,s,u,p,f.width,f.height,g,f.data):Ct.texSubImage2D(Ct.TEXTURE_2D,s,u,p,a,o,g,v,f);Ct.pixelStorei(Ct.UNPACK_ROW_LENGTH,y),Ct.pixelStorei(Ct.UNPACK_IMAGE_HEIGHT,x),Ct.pixelStorei(Ct.UNPACK_SKIP_PIXELS,b),Ct.pixelStorei(Ct.UNPACK_SKIP_ROWS,w),Ct.pixelStorei(Ct.UNPACK_SKIP_IMAGES,S),0===s&&e.generateMipmaps&&Ct.generateMipmap(_),Q.unbindTexture()},this.copyTextureToTexture3D=function(t,e,i=null,n=null,r=0){return!0!==t.isTexture&&(hi("WebGLRenderer: copyTextureToTexture3D function signature has changed."),i=arguments[0]||null,n=arguments[1]||null,t=arguments[2],e=arguments[3],r=arguments[4]||0),hi('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(t,e,i,n,r)},this.initRenderTarget=function(t){void 0===tt.get(t).__webglFramebuffer&&et.setupRenderTarget(t)},this.initTexture=function(t){t.isCubeTexture?et.setTextureCube(t,0):t.isData3DTexture?et.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?et.setTexture2DArray(t,0):et.setTexture2D(t,0),Q.unbindTexture()},this.resetState=function(){w=0,S=0,M=null,Q.reset(),Et.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Be}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorspace=ui._getDrawingBufferColorSpace(t),e.unpackColorSpace=ui._getUnpackColorSpace()}}var _p=Object.freeze({__proto__:null,ACESFilmicToneMapping:4,AddEquation:M,AddOperation:2,AdditiveAnimationBlendMode:we,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:Tt,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:_l,AnimationAction:ec,AnimationClip:jh,AnimationLoader:class extends Zh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new $h(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}}),i,n)}parse(t){const e=[];for(let i=0;i<t.length;i++){const n=jh.parse(t[i]);e.push(n)}return e}},AnimationMixer:class extends Ge{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,r=n.length,s=t._propertyBindings,a=t._interpolants,o=i.uuid,h=this._bindingsByRootAndName;let l=h[o];void 0===l&&(l={},h[o]=l);for(let t=0;t!==r;++t){const r=n[t],h=r.name;let c=l[h];if(void 0!==c)++c.referenceCount,s[t]=c;else{if(c=s[t],void 0!==c){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,o,h));continue}const n=e&&e._propertyBindings[t].binding.parsedPath;c=new Yl(tc.create(i,h,n),r.ValueTypeName,r.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,o,h),s[t]=c}a[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,i){const n=this._actions,r=this._actionsByClip;let s=r[e];if(void 0===s)s={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=s;else{const e=s.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=n.length,n.push(t),s.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,s=this._actionsByClip,a=s[r],o=a.knownActions,h=o[o.length-1],l=t._byClipCacheIndex;h._byClipCacheIndex=l,o[l]=h,o.pop(),t._byClipCacheIndex=null;delete a.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete s[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_addInactiveBinding(t,e,i){const n=this._bindingsByRootAndName,r=this._bindings;let s=n[e];void 0===s&&(s={},n[e]=s),s[i]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,r=i.path,s=this._bindingsByRootAndName,a=s[n],o=e[e.length-1],h=t._cacheIndex;o._cacheIndex=h,e[h]=o,e.pop(),delete a[r],0===Object.keys(a).length&&delete s[n]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return void 0===i&&(i=new Nh(new Float32Array(2),new Float32Array(2),1,ic),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,r=e[n];t.__cacheIndex=n,e[n]=t,r.__cacheIndex=i,e[i]=r}clipAction(t,e,i){const n=e||this._root,r=n.uuid;let s="string"==typeof t?jh.findByName(n,t):t;const a=null!==s?s.uuid:t,o=this._actionsByClip[a];let h=null;if(void 0===i&&(i=null!==s?s.blendMode:be),void 0!==o){const t=o.actionByRoot[r];if(void 0!==t&&t.blendMode===i)return t;h=o.knownActions[0],null===s&&(s=h._clip)}if(null===s)return null;const l=new ec(this,s,e,i);return this._bindAction(l,h),this._addInactiveAction(l,a,r),l}existingAction(t,e){const i=e||this._root,n=i.uuid,r="string"==typeof t?jh.findByName(i,t):t,s=r?r.uuid:t,a=this._actionsByClip[s];return void 0!==a&&a.actionByRoot[n]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let a=0;a!==i;++a){e[a]._update(n,t,r,s)}const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(s);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){const t=r.knownActions;for(let i=0,n=t.length;i!==n;++i){const n=t[i];this._deactivateAction(n);const r=n._cacheIndex,s=e[e.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,s._cacheIndex=r,e[r]=s,e.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const t in i){const n=i[t].actionByRoot[e];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[e];if(void 0!==n)for(const t in n){const e=n[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}},AnimationObjectGroup:class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Xe(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,i=arguments.length;e!==i;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,i=this._paths,n=this._parsedPaths,r=this._bindings,s=r.length;let a,o=t.length,h=this.nCachedObjects_;for(let l=0,c=arguments.length;l!==c;++l){const c=arguments[l],d=c.uuid;let u=e[d];if(void 0===u){u=o++,e[d]=u,t.push(c);for(let t=0,e=s;t!==e;++t)r[t].push(new tc(c,i[t],n[t]))}else if(u<h){a=t[u];const o=--h,l=t[o];e[l.uuid]=u,t[u]=l,e[d]=o,t[o]=c;for(let t=0,e=s;t!==e;++t){const e=r[t],s=e[o];let a=e[u];e[u]=s,void 0===a&&(a=new tc(c,i[t],n[t])),e[o]=a}}else t[u]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=h}remove(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_;for(let s=0,a=arguments.length;s!==a;++s){const a=arguments[s],o=a.uuid,h=e[o];if(void 0!==h&&h>=r){const s=r++,l=t[s];e[l.uuid]=h,t[h]=l,e[o]=s,t[s]=a;for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[s],r=e[h];e[h]=n,e[s]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,s=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,h=e[o];if(void 0!==h)if(delete e[o],h<r){const a=--r,o=t[a],l=--s,c=t[l];e[o.uuid]=h,t[h]=o,e[c.uuid]=a,t[a]=c,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[a],r=e[l];e[h]=n,e[a]=r,e.pop()}}else{const r=--s,a=t[r];r>0&&(e[a.uuid]=h),t[h]=a,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t];e[h]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const i=this._bindingsIndicesByPath;let n=i[t];const r=this._bindings;if(void 0!==n)return r[n];const s=this._paths,a=this._parsedPaths,o=this._objects,h=o.length,l=this.nCachedObjects_,c=new Array(h);n=r.length,i[t]=n,s.push(t),a.push(e),r.push(c);for(let i=l,n=o.length;i!==n;++i){const n=o[i];c[i]=new tc(n,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const n=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];e[t[a]]=i,s[i]=o,s.pop(),r[i]=r[a],r.pop(),n[i]=n[a],n.pop()}}},AnimationUtils:Ih,ArcCurve:Xa,ArrayCamera:Nl,ArrowHelper:class extends In{constructor(t=new Ci(0,0,1),e=new Ci(0,0,0),i=1,n=16776960,r=.2*i,s=.2*r){super(),this.type="ArrowHelper",void 0===Lc&&(Lc=new br,Lc.setAttribute("position",new pr([0,0,0,0,1,0],3)),Ic=new go(0,.5,1,5,1),Ic.translate(0,-.5,0)),this.position.copy(e),this.line=new Aa(Lc,new ya({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Dr(Ic,new er({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,r,s)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Pc.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Pc,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},AttachedBindMode:Z,Audio:Hl,AudioAnalyser:class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let i=0;i<e.length;i++)t+=e[i];return t/e.length}},AudioContext:Ll,AudioListener:class extends In{constructor(){super(),this.type="AudioListener",this.context=Ll.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Ul}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(kl,Bl,zl),Gl.set(0,0,-1).applyQuaternion(Bl),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(kl.x,t),e.positionY.linearRampToValueAtTime(kl.y,t),e.positionZ.linearRampToValueAtTime(kl.z,t),e.forwardX.linearRampToValueAtTime(Gl.x,t),e.forwardY.linearRampToValueAtTime(Gl.y,t),e.forwardZ.linearRampToValueAtTime(Gl.z,t),e.upX.linearRampToValueAtTime(i.x,t),e.upY.linearRampToValueAtTime(i.y,t),e.upZ.linearRampToValueAtTime(i.z,t)}else e.setPosition(kl.x,kl.y,kl.z),e.setOrientation(Gl.x,Gl.y,Gl.z,i.x,i.y,i.z)}},AudioLoader:class extends Zh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new $h(this.manager);function a(e){n?n(e):console.error(e),r.manager.itemError(t)}s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(t){try{const i=t.slice(0);Ll.getContext().decodeAudioData(i,(function(t){e(t)})).catch(a)}catch(t){a(t)}}),i,n)}},AxesHelper:class extends La{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new br;i.setAttribute("position",new pr(e,3)),i.setAttribute("color",new pr([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(i,new ya({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){const n=new Jn,r=this.geometry.attributes.color.array;return n.set(t),n.toArray(r,0),n.toArray(r,3),n.set(e),n.toArray(r,6),n.toArray(r,9),n.set(i),n.toArray(r,12),n.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BackSide:1,BasicDepthPacking:3200,BasicShadowMap:0,BatchedMesh:_a,Bone:Os,BooleanKeyframeTrack:kh,Box2:class{constructor(t=new $e(1/0,1/0),e=new $e(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=uc.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,uc).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},Box3:Li,Box3Helper:class extends La{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new br;n.setIndex(new cr(i,1)),n.setAttribute("position",new pr([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new ya({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}},BoxGeometry:Nr,BoxHelper:class extends La{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),r=new br;r.setIndex(new cr(i,1)),r.setAttribute("position",new cr(n,3)),super(r,new ya({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(void 0!==t&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&Rc.setFromObject(this.object),Rc.isEmpty())return;const e=Rc.min,i=Rc.max,n=this.geometry.attributes.position,r=n.array;r[0]=i.x,r[1]=i.y,r[2]=i.z,r[3]=e.x,r[4]=i.y,r[5]=i.z,r[6]=e.x,r[7]=e.y,r[8]=i.z,r[9]=i.x,r[10]=e.y,r[11]=i.z,r[12]=i.x,r[13]=i.y,r[14]=e.z,r[15]=e.x,r[16]=i.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=i.x,r[22]=e.y,r[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BufferAttribute:cr,BufferGeometry:br,BufferGeometryLoader:Tl,ByteType:mt,Cache:Yh,Camera:Gr,CameraHelper:class extends La{constructor(t){const e=new br,i=new ya({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],s={};function a(t,e){o(t),o(e)}function o(t){n.push(0,0,0),r.push(0,0,0),void 0===s[t]&&(s[t]=[]),s[t].push(n.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),e.setAttribute("position",new pr(n,3)),e.setAttribute("color",new pr(r,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();const h=new Jn(16755200),l=new Jn(16711680),c=new Jn(43775),d=new Jn(16777215),u=new Jn(3355443);this.setColors(h,l,c,d,u)}setColors(t,e,i,n,r){const s=this.geometry.getAttribute("color");s.setXYZ(0,t.r,t.g,t.b),s.setXYZ(1,t.r,t.g,t.b),s.setXYZ(2,t.r,t.g,t.b),s.setXYZ(3,t.r,t.g,t.b),s.setXYZ(4,t.r,t.g,t.b),s.setXYZ(5,t.r,t.g,t.b),s.setXYZ(6,t.r,t.g,t.b),s.setXYZ(7,t.r,t.g,t.b),s.setXYZ(8,t.r,t.g,t.b),s.setXYZ(9,t.r,t.g,t.b),s.setXYZ(10,t.r,t.g,t.b),s.setXYZ(11,t.r,t.g,t.b),s.setXYZ(12,t.r,t.g,t.b),s.setXYZ(13,t.r,t.g,t.b),s.setXYZ(14,t.r,t.g,t.b),s.setXYZ(15,t.r,t.g,t.b),s.setXYZ(16,t.r,t.g,t.b),s.setXYZ(17,t.r,t.g,t.b),s.setXYZ(18,t.r,t.g,t.b),s.setXYZ(19,t.r,t.g,t.b),s.setXYZ(20,t.r,t.g,t.b),s.setXYZ(21,t.r,t.g,t.b),s.setXYZ(22,t.r,t.g,t.b),s.setXYZ(23,t.r,t.g,t.b),s.setXYZ(24,e.r,e.g,e.b),s.setXYZ(25,e.r,e.g,e.b),s.setXYZ(26,e.r,e.g,e.b),s.setXYZ(27,e.r,e.g,e.b),s.setXYZ(28,e.r,e.g,e.b),s.setXYZ(29,e.r,e.g,e.b),s.setXYZ(30,e.r,e.g,e.b),s.setXYZ(31,e.r,e.g,e.b),s.setXYZ(32,i.r,i.g,i.b),s.setXYZ(33,i.r,i.g,i.b),s.setXYZ(34,i.r,i.g,i.b),s.setXYZ(35,i.r,i.g,i.b),s.setXYZ(36,i.r,i.g,i.b),s.setXYZ(37,i.r,i.g,i.b),s.setXYZ(38,n.r,n.g,n.b),s.setXYZ(39,n.r,n.g,n.b),s.setXYZ(40,r.r,r.g,r.b),s.setXYZ(41,r.r,r.g,r.b),s.setXYZ(42,r.r,r.g,r.b),s.setXYZ(43,r.r,r.g,r.b),s.setXYZ(44,r.r,r.g,r.b),s.setXYZ(45,r.r,r.g,r.b),s.setXYZ(46,r.r,r.g,r.b),s.setXYZ(47,r.r,r.g,r.b),s.setXYZ(48,r.r,r.g,r.b),s.setXYZ(49,r.r,r.g,r.b),s.needsUpdate=!0}update(){const t=this.geometry,e=this.pointMap;Ac.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);const i=this.camera.coordinateSystem===Be?-1:0;Cc("c",e,t,Ac,0,0,i),Cc("t",e,t,Ac,0,0,1),Cc("n1",e,t,Ac,-1,-1,i),Cc("n2",e,t,Ac,1,-1,i),Cc("n3",e,t,Ac,-1,1,i),Cc("n4",e,t,Ac,1,1,i),Cc("f1",e,t,Ac,-1,-1,1),Cc("f2",e,t,Ac,1,-1,1),Cc("f3",e,t,Ac,-1,1,1),Cc("f4",e,t,Ac,1,1,1),Cc("u1",e,t,Ac,.7,1.1,i),Cc("u2",e,t,Ac,-.7,1.1,i),Cc("u3",e,t,Ac,0,2,i),Cc("cf1",e,t,Ac,-1,0,1),Cc("cf2",e,t,Ac,1,0,1),Cc("cf3",e,t,Ac,0,-1,1),Cc("cf4",e,t,Ac,0,1,1),Cc("cn1",e,t,Ac,-1,0,i),Cc("cn2",e,t,Ac,1,0,i),Cc("cn3",e,t,Ac,0,-1,i),Cc("cn4",e,t,Ac,0,1,i),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:Ha,CapsuleGeometry:mo,CatmullRomCurve3:Qa,CineonToneMapping:3,CircleGeometry:fo,ClampToEdgeWrapping:st,Clock:Ul,Color:Jn,ColorKeyframeTrack:Bh,ColorManagement:ui,CompressedArrayTexture:class extends Ga{constructor(t,e,i,n,r,s){super(t,e,i,r,s),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=st,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},CompressedCubeTexture:class extends Ga{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,$),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},CompressedTexture:Ga,CompressedTextureLoader:class extends Zh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=[],a=new Ga,o=new $h(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials);let h=0;function l(l){o.load(t[l],(function(t){const i=r.parse(t,!0);s[l]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},h+=1,6===h&&(1===i.mipmapCount&&(a.minFilter=ct),a.image=s,a.format=i.format,a.needsUpdate=!0,e&&e(a))}),i,n)}if(Array.isArray(t))for(let e=0,i=t.length;e<i;++e)l(e);else o.load(t,(function(t){const i=r.parse(t,!0);if(i.isCubemap){const t=i.mipmaps.length/i.mipmapCount;for(let e=0;e<t;e++){s[e]={mipmaps:[]};for(let t=0;t<i.mipmapCount;t++)s[e].mipmaps.push(i.mipmaps[e*i.mipmapCount+t]),s[e].format=i.format,s[e].width=i.width,s[e].height=i.height}a.image=s}else a.image.width=i.width,a.image.height=i.height,a.mipmaps=i.mipmaps;1===i.mipmapCount&&(a.minFilter=ct),a.format=i.format,a.needsUpdate=!0,e&&e(a)}),i,n);return a}},ConeGeometry:vo,ConstantAlphaFactor:213,ConstantColorFactor:211,Controls:Dc,CubeCamera:Yr,CubeReflectionMapping:$,CubeRefractionMapping:tt,CubeTexture:qr,CubeTextureLoader:class extends Zh{constructor(t){super(t)}load(t,e,i,n){const r=new qr;r.colorSpace=Me;const s=new tl(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let a=0;function o(i){s.load(t[i],(function(t){r.images[i]=t,a++,6===a&&(r.needsUpdate=!0,e&&e(r))}),void 0,n)}for(let e=0;e<t.length;++e)o(e);return r}},CubeUVReflectionMapping:nt,CubicBezierCurve:io,CubicBezierCurve3:no,CubicInterpolant:Oh,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:Wa,CurvePath:co,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:go,Cylindrical:class{constructor(t=1,e=0,i=0){return this.radius=t,this.theta=e,this.y=i,this}set(t,e,i){return this.radius=t,this.theta=e,this.y=i,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+i*i),this.theta=Math.atan2(t,i),this.y=e,this}clone(){return(new this.constructor).copy(this)}},Data3DTexture:Ei,DataArrayTexture:Ti,DataTexture:Ns,DataTextureLoader:class extends Zh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new Ns,a=new $h(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(t,(function(t){let i;try{i=r.parse(t)}catch(t){if(void 0===n)return void console.error(t);n(t)}void 0!==i.image?s.image=i.image:void 0!==i.data&&(s.image.width=i.width,s.image.height=i.height,s.image.data=i.data),s.wrapS=void 0!==i.wrapS?i.wrapS:st,s.wrapT=void 0!==i.wrapT?i.wrapT:st,s.magFilter=void 0!==i.magFilter?i.magFilter:ct,s.minFilter=void 0!==i.minFilter?i.minFilter:ct,s.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.colorSpace&&(s.colorSpace=i.colorSpace),void 0!==i.flipY&&(s.flipY=i.flipY),void 0!==i.format&&(s.format=i.format),void 0!==i.type&&(s.type=i.type),void 0!==i.mipmaps&&(s.mipmaps=i.mipmaps,s.minFilter=ut),1===i.mipmapCount&&(s.minFilter=ct),void 0!==i.generateMipmaps&&(s.generateMipmaps=i.generateMipmaps),s.needsUpdate=!0,e&&e(s,i)}),i,n),s}},DataUtils:ar,DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:Kh,DepthFormat:Pt,DepthStencilFormat:Lt,DepthTexture:Va,DetachedBindMode:J,DirectionalLight:vl,DirectionalLightHelper:class extends In{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",void 0===e&&(e=1);let n=new br;n.setAttribute("position",new pr([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const r=new ya({fog:!1,toneMapped:!1});this.lightPlane=new Aa(n,r),this.add(this.lightPlane),n=new br,n.setAttribute("position",new pr([0,0,0,0,0,1],3)),this.targetLine=new Aa(n,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Sc.setFromMatrixPosition(this.light.matrixWorld),Mc.setFromMatrixPosition(this.light.target.matrixWorld),Tc.subVectors(Mc,Sc),this.lightPlane.lookAt(Mc),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Mc),this.targetLine.scale.z=Tc.length()}},DiscreteInterpolant:Uh,DodecahedronGeometry:yo,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:35048,DynamicReadUsage:35049,EdgesGeometry:Mo,EllipseCurve:ja,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:et,EquirectangularRefractionMapping:it,Euler:fn,EventDispatcher:Ge,ExtrudeGeometry:th,FileLoader:$h,Float16BufferAttribute:class extends cr{constructor(t,e,i){super(new Uint16Array(t),e,i),this.isFloat16BufferAttribute=!0}getX(t){let e=sr(this.array[t*this.itemSize]);return this.normalized&&(e=Ze(e,this.array)),e}setX(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize]=rr(e),this}getY(t){let e=sr(this.array[t*this.itemSize+1]);return this.normalized&&(e=Ze(e,this.array)),e}setY(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+1]=rr(e),this}getZ(t){let e=sr(this.array[t*this.itemSize+2]);return this.normalized&&(e=Ze(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+2]=rr(e),this}getW(t){let e=sr(this.array[t*this.itemSize+3]);return this.normalized&&(e=Ze(e,this.array)),e}setW(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+3]=rr(e),this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),i=Je(i,this.array)),this.array[t+0]=rr(e),this.array[t+1]=rr(i),this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),i=Je(i,this.array),n=Je(n,this.array)),this.array[t+0]=rr(e),this.array[t+1]=rr(i),this.array[t+2]=rr(n),this}setXYZW(t,e,i,n,r){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),i=Je(i,this.array),n=Je(n,this.array),r=Je(r,this.array)),this.array[t+0]=rr(e),this.array[t+1]=rr(i),this.array[t+2]=rr(n),this.array[t+3]=rr(r),this}},Float32BufferAttribute:pr,FloatType:yt,Fog:ts,FogExp2:$r,FramebufferTexture:class extends bi{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=ot,this.minFilter=ot,this.generateMipmaps=!1,this.needsUpdate=!0}},FrontSide:0,Frustum:ta,GLBufferAttribute:class{constructor(t,e,i,n,r){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=i,this.elementSize=n,this.count=r,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}},GLSL1:"100",GLSL3:ke,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:518,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:class extends La{constructor(t=10,e=10,i=4473924,n=8947848){i=new Jn(i),n=new Jn(n);const r=e/2,s=t/e,a=t/2,o=[],h=[];for(let t=0,l=0,c=-a;t<=e;t++,c+=s){o.push(-a,0,c,a,0,c),o.push(c,0,-a,c,0,a);const e=t===r?i:n;e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3}const l=new br;l.setAttribute("position",new pr(o,3)),l.setAttribute("color",new pr(h,3));super(l,new ya({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Group:Zr,HalfFloatType:xt,HemisphereLight:nl,HemisphereLightHelper:class extends In{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new nh(e);n.rotateY(.5*Math.PI),this.material=new er({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=n.getAttribute("position"),s=new Float32Array(3*r.count);n.setAttribute("color",new cr(s,3)),this.add(new Dr(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");bc.copy(this.light.color),wc.copy(this.light.groundColor);for(let t=0,i=e.count;t<i;t++){const n=t<i/2?bc:wc;e.setXYZ(t,n.r,n.g,n.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(xc.setFromMatrixPosition(this.light.matrixWorld).negate())}},IcosahedronGeometry:ih,ImageBitmapLoader:Rl,ImageLoader:tl,ImageUtils:gi,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:Bs,InstancedBufferGeometry:Ml,InstancedInterleavedBuffer:sc,InstancedMesh:Ys,Int16BufferAttribute:class extends cr{constructor(t,e,i){super(new Int16Array(t),e,i)}},Int32BufferAttribute:class extends cr{constructor(t,e,i){super(new Int32Array(t),e,i)}},Int8BufferAttribute:class extends cr{constructor(t,e,i){super(new Int8Array(t),e,i)}},IntType:vt,InterleavedBuffer:is,InterleavedBufferAttribute:rs,Interpolant:Dh,InterpolateDiscrete:fe,InterpolateLinear:ge,InterpolateSmooth:ve,InvertStencilOp:5386,KeepStencilOp:Ce,KeyframeTrack:Fh,LOD:Ss,LatheGeometry:po,Layers:gn,LessCompare:513,LessDepth:2,LessEqualCompare:515,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:il,LightProbe:bl,Line:Aa,Line3:class{constructor(t=new Ci,e=new Ci){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){pc.subVectors(t,this.start),mc.subVectors(this.end,this.start);const i=mc.dot(mc);let n=mc.dot(pc)/i;return e&&(n=Ye(n,0,1)),n}closestPointToPoint(t,e,i){const n=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(n).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}},LineBasicMaterial:ya,LineCurve:ro,LineCurve3:so,LineDashedMaterial:Eh,LineLoop:Ia,LineSegments:La,LinearFilter:ct,LinearInterpolant:Nh,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:ut,LinearMipmapNearestFilter:dt,LinearSRGBColorSpace:Te,LinearToneMapping:1,LinearTransfer:Ee,Loader:Zh,LoaderUtils:Sl,LoadingManager:qh,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,LuminanceAlphaFormat:Rt,LuminanceFormat:Ct,MOUSE:y,Material:tr,MaterialLoader:wl,MathUtils:Qe,Matrix2:dc,Matrix3:ti,Matrix4:sn,MaxEquation:104,Mesh:Dr,MeshBasicMaterial:er,MeshDepthMaterial:Sh,MeshDistanceMaterial:Mh,MeshLambertMaterial:wh,MeshMatcapMaterial:Th,MeshNormalMaterial:bh,MeshPhongMaterial:yh,MeshPhysicalMaterial:_h,MeshStandardMaterial:vh,MeshToonMaterial:xh,MinEquation:103,MirroredRepeatWrapping:at,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:ot,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:lt,NearestMipmapNearestFilter:ht,NeutralToneMapping:7,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:Se,NoToneMapping:0,NormalAnimationBlendMode:be,NormalBlending:1,NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:zh,Object3D:In,ObjectLoader:class extends Zh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=""===this.path?Sl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||s;const a=new $h(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,(function(i){let s=null;try{s=JSON.parse(i)}catch(e){return void 0!==n&&n(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}const a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void 0!==n&&n(new Error("THREE.ObjectLoader: Can't load "+t)),void console.error("THREE.ObjectLoader: Can't load "+t);r.parse(s,e)}),i,n)}async loadAsync(t,e){const i=""===this.path?Sl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;const n=new $h(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);const r=await n.loadAsync(t,e),s=JSON.parse(r),a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(s)}parse(t,e){const i=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,n),s=this.parseImages(t.images,(function(){void 0!==e&&e(h)})),a=this.parseTextures(t.textures,s),o=this.parseMaterials(t.materials,a),h=this.parseObject(t.object,r,o,a,i),l=this.parseSkeletons(t.skeletons,h);if(this.bindSkeletons(h,l),this.bindLightTargets(h),void 0!==e){let t=!1;for(const e in s)if(s[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(h)}return h}async parseAsync(t){const e=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),n=this.parseGeometries(t.geometries,i),r=await this.parseImagesAsync(t.images),s=this.parseTextures(t.textures,r),a=this.parseMaterials(t.materials,s),o=this.parseObject(t.object,n,a,s,e),h=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,h),this.bindLightTargets(o),o}parseShapes(t){const e={};if(void 0!==t)for(let i=0,n=t.length;i<n;i++){const n=(new To).fromJSON(t[i]);e[n.uuid]=n}return e}parseSkeletons(t,e){const i={},n={};if(e.traverse((function(t){t.isBone&&(n[t.uuid]=t)})),void 0!==t)for(let e=0,r=t.length;e<r;e++){const r=(new ks).fromJSON(t[e],n);i[r.uuid]=r}return i}parseGeometries(t,e){const i={};if(void 0!==t){const n=new Tl;for(let r=0,s=t.length;r<s;r++){let s;const a=t[r];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":s=n.parse(a);break;default:a.type in mh?s=mh[a.type].fromJSON(a,e):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${a.type}"`)}s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),void 0!==a.userData&&(s.userData=a.userData),i[a.uuid]=s}}return i}parseMaterials(t,e){const i={},n={};if(void 0!==t){const r=new wl;r.setTextures(e);for(let e=0,s=t.length;e<s;e++){const s=t[e];void 0===i[s.uuid]&&(i[s.uuid]=r.parse(s)),n[s.uuid]=i[s.uuid]}}return n}parseAnimations(t){const e={};if(void 0!==t)for(let i=0;i<t.length;i++){const n=t[i],r=jh.parse(n);e[r.uuid]=r}return e}parseImages(t,e){const i=this,n={};let r;function s(t){if("string"==typeof t){const e=t;return function(t){return i.manager.itemStart(t),r.load(t,(function(){i.manager.itemEnd(t)}),void 0,(function(){i.manager.itemError(t),i.manager.itemEnd(t)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:i.resourcePath+e)}return t.data?{data:ri(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const i=new qh(e);r=new tl(i),r.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],r=i.url;if(Array.isArray(r)){const t=[];for(let e=0,i=r.length;e<i;e++){const i=s(r[e]);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new Ns(i.data,i.width,i.height)))}n[i.uuid]=new _i(t)}else{const t=s(i.url);n[i.uuid]=new _i(t)}}}return n}async parseImagesAsync(t){const e=this,i={};let n;async function r(t){if("string"==typeof t){const i=t,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(i)?i:e.resourcePath+i;return await n.loadAsync(r)}return t.data?{data:ri(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){n=new tl(this.manager),n.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],s=n.url;if(Array.isArray(s)){const t=[];for(let e=0,i=s.length;e<i;e++){const i=s[e],n=await r(i);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new Ns(n.data,n.width,n.height)))}i[n.uuid]=new _i(t)}else{const t=await r(n.url);i[n.uuid]=new _i(t)}}}return i}parseTextures(t,e){function i(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const n={};if(void 0!==t)for(let r=0,s=t.length;r<s;r++){const s=t[r];void 0===s.image&&console.warn('THREE.ObjectLoader: No "image" specified for',s.uuid),void 0===e[s.image]&&console.warn("THREE.ObjectLoader: Undefined image",s.image);const a=e[s.image],o=a.data;let h;Array.isArray(o)?(h=new qr,6===o.length&&(h.needsUpdate=!0)):(h=o&&o.data?new Ns:new bi,o&&(h.needsUpdate=!0)),h.source=a,h.uuid=s.uuid,void 0!==s.name&&(h.name=s.name),void 0!==s.mapping&&(h.mapping=i(s.mapping,El)),void 0!==s.channel&&(h.channel=s.channel),void 0!==s.offset&&h.offset.fromArray(s.offset),void 0!==s.repeat&&h.repeat.fromArray(s.repeat),void 0!==s.center&&h.center.fromArray(s.center),void 0!==s.rotation&&(h.rotation=s.rotation),void 0!==s.wrap&&(h.wrapS=i(s.wrap[0],Al),h.wrapT=i(s.wrap[1],Al)),void 0!==s.format&&(h.format=s.format),void 0!==s.internalFormat&&(h.internalFormat=s.internalFormat),void 0!==s.type&&(h.type=s.type),void 0!==s.colorSpace&&(h.colorSpace=s.colorSpace),void 0!==s.minFilter&&(h.minFilter=i(s.minFilter,Cl)),void 0!==s.magFilter&&(h.magFilter=i(s.magFilter,Cl)),void 0!==s.anisotropy&&(h.anisotropy=s.anisotropy),void 0!==s.flipY&&(h.flipY=s.flipY),void 0!==s.generateMipmaps&&(h.generateMipmaps=s.generateMipmaps),void 0!==s.premultiplyAlpha&&(h.premultiplyAlpha=s.premultiplyAlpha),void 0!==s.unpackAlignment&&(h.unpackAlignment=s.unpackAlignment),void 0!==s.compareFunction&&(h.compareFunction=s.compareFunction),void 0!==s.userData&&(h.userData=s.userData),n[s.uuid]=h}return n}parseObject(t,e,i,n,r){let s,a,o;function h(t){return void 0===e[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),e[t]}function l(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let n=0,r=t.length;n<r;n++){const r=t[n];void 0===i[r]&&console.warn("THREE.ObjectLoader: Undefined material",r),e.push(i[r])}return e}return void 0===i[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),i[t]}}function c(t){return void 0===n[t]&&console.warn("THREE.ObjectLoader: Undefined texture",t),n[t]}switch(t.type){case"Scene":s=new es,void 0!==t.background&&(Number.isInteger(t.background)?s.background=new Jn(t.background):s.background=c(t.background)),void 0!==t.environment&&(s.environment=c(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?s.fog=new ts(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(s.fog=new $r(t.fog.color,t.fog.density)),""!==t.fog.name&&(s.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(s.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(s.backgroundIntensity=t.backgroundIntensity),void 0!==t.backgroundRotation&&s.backgroundRotation.fromArray(t.backgroundRotation),void 0!==t.environmentIntensity&&(s.environmentIntensity=t.environmentIntensity),void 0!==t.environmentRotation&&s.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":s=new jr(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(s.focus=t.focus),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.filmGauge&&(s.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(s.filmOffset=t.filmOffset),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"OrthographicCamera":s=new fl(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"AmbientLight":s=new _l(t.color,t.intensity);break;case"DirectionalLight":s=new vl(t.color,t.intensity),s.target=t.target||"";break;case"PointLight":s=new ml(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":s=new yl(t.color,t.intensity,t.width,t.height);break;case"SpotLight":s=new ll(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),s.target=t.target||"";break;case"HemisphereLight":s=new nl(t.color,t.groundColor,t.intensity);break;case"LightProbe":s=(new bl).fromJSON(t);break;case"SkinnedMesh":a=h(t.geometry),o=l(t.material),s=new Ds(a,o),void 0!==t.bindMode&&(s.bindMode=t.bindMode),void 0!==t.bindMatrix&&s.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(s.skeleton=t.skeleton);break;case"Mesh":a=h(t.geometry),o=l(t.material),s=new Dr(a,o);break;case"InstancedMesh":a=h(t.geometry),o=l(t.material);const e=t.count,i=t.instanceMatrix,n=t.instanceColor;s=new Ys(a,o,e),s.instanceMatrix=new Bs(new Float32Array(i.array),16),void 0!==n&&(s.instanceColor=new Bs(new Float32Array(n.array),n.itemSize));break;case"BatchedMesh":a=h(t.geometry),o=l(t.material),s=new _a(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,o),s.geometry=a,s.perObjectFrustumCulled=t.perObjectFrustumCulled,s.sortObjects=t.sortObjects,s._drawRanges=t.drawRanges,s._reservedRanges=t.reservedRanges,s._visibility=t.visibility,s._active=t.active,s._bounds=t.bounds.map((t=>{const e=new Li;e.min.fromArray(t.boxMin),e.max.fromArray(t.boxMax);const i=new Ki;return i.radius=t.sphereRadius,i.center.fromArray(t.sphereCenter),{boxInitialized:t.boxInitialized,box:e,sphereInitialized:t.sphereInitialized,sphere:i}})),s._maxInstanceCount=t.maxInstanceCount,s._maxVertexCount=t.maxVertexCount,s._maxIndexCount=t.maxIndexCount,s._geometryInitialized=t.geometryInitialized,s._geometryCount=t.geometryCount,s._matricesTexture=c(t.matricesTexture.uuid),void 0!==t.colorsTexture&&(s._colorsTexture=c(t.colorsTexture.uuid));break;case"LOD":s=new Ss;break;case"Line":s=new Aa(h(t.geometry),l(t.material));break;case"LineLoop":s=new Ia(h(t.geometry),l(t.material));break;case"LineSegments":s=new La(h(t.geometry),l(t.material));break;case"PointCloud":case"Points":s=new ka(h(t.geometry),l(t.material));break;case"Sprite":s=new ys(l(t.material));break;case"Group":s=new Zr;break;case"Bone":s=new Os;break;default:s=new In}if(s.uuid=t.uuid,void 0!==t.name&&(s.name=t.name),void 0!==t.matrix?(s.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(s.matrixAutoUpdate=t.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==t.position&&s.position.fromArray(t.position),void 0!==t.rotation&&s.rotation.fromArray(t.rotation),void 0!==t.quaternion&&s.quaternion.fromArray(t.quaternion),void 0!==t.scale&&s.scale.fromArray(t.scale)),void 0!==t.up&&s.up.fromArray(t.up),void 0!==t.castShadow&&(s.castShadow=t.castShadow),void 0!==t.receiveShadow&&(s.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(s.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(s.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(s.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(s.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&s.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(s.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(s.visible=t.visible),void 0!==t.frustumCulled&&(s.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(s.renderOrder=t.renderOrder),void 0!==t.userData&&(s.userData=t.userData),void 0!==t.layers&&(s.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)s.add(this.parseObject(a[t],e,i,n,r))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const i=e[t];s.animations.push(r[i])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(s.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const i=e[t],n=s.getObjectByProperty("uuid",i.object);void 0!==n&&s.addLevel(n,i.distance,i.hysteresis)}}return s}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse((function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const i=e[t.skeleton];void 0===i?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(i,t.bindMatrix)}}))}bindLightTargets(t){t.traverse((function(e){if(e.isDirectionalLight||e.isSpotLight){const i=e.target,n=t.getObjectByProperty("uuid",i);e.target=void 0!==n?n:new In}}))}},ObjectSpaceNormalMap:1,OctahedronGeometry:nh,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:I,OneMinusSrcColorFactor:203,OrthographicCamera:fl,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:od,Path:uo,PerspectiveCamera:jr,Plane:Js,PlaneGeometry:rh,PlaneHelper:class extends Aa{constructor(t,e=1,i=16776960){const n=i,r=new br;r.setAttribute("position",new pr([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new ya({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const s=new br;s.setAttribute("position",new pr([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.add(new Dr(s,new er({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},PointLight:ml,PointLightHelper:class extends Dr{constructor(t,e,i){super(new oh(e,4,2),new er({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Points:ka,PointsMaterial:Da,PolarGridHelper:class extends La{constructor(t=10,e=16,i=8,n=64,r=4473924,s=8947848){r=new Jn(r),s=new Jn(s);const a=[],o=[];if(e>1)for(let i=0;i<e;i++){const n=i/e*(2*Math.PI),h=Math.sin(n)*t,l=Math.cos(n)*t;a.push(0,0,0),a.push(h,0,l);const c=1&i?r:s;o.push(c.r,c.g,c.b),o.push(c.r,c.g,c.b)}for(let e=0;e<i;e++){const h=1&e?r:s,l=t-t/i*e;for(let t=0;t<n;t++){let e=t/n*(2*Math.PI),i=Math.sin(e)*l,r=Math.cos(e)*l;a.push(i,0,r),o.push(h.r,h.g,h.b),e=(t+1)/n*(2*Math.PI),i=Math.sin(e)*l,r=Math.cos(e)*l,a.push(i,0,r),o.push(h.r,h.g,h.b)}}const h=new br;h.setAttribute("position",new pr(a,3)),h.setAttribute("color",new pr(o,3));super(h,new ya({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},PolyhedronGeometry:_o,PositionalAudio:class extends Hl{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,i){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=i,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(Vl,Wl,jl),Xl.set(0,0,1).applyQuaternion(Wl);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(Vl.x,t),e.positionY.linearRampToValueAtTime(Vl.y,t),e.positionZ.linearRampToValueAtTime(Vl.z,t),e.orientationX.linearRampToValueAtTime(Xl.x,t),e.orientationY.linearRampToValueAtTime(Xl.y,t),e.orientationZ.linearRampToValueAtTime(Xl.z,t)}else e.setPosition(Vl.x,Vl.y,Vl.z),e.setOrientation(Xl.x,Xl.y,Xl.z)}},PropertyBinding:tc,PropertyMixer:Yl,QuadraticBezierCurve:ao,QuadraticBezierCurve3:oo,Quaternion:Ai,QuaternionKeyframeTrack:Hh,QuaternionLinearInterpolant:Gh,RED_GREEN_RGTC2_Format:pe,RED_RGTC1_Format:de,REVISION:_,RGBADepthPacking:3201,RGBAFormat:At,RGBAIntegerFormat:Ut,RGBA_ASTC_10x10_Format:se,RGBA_ASTC_10x5_Format:ie,RGBA_ASTC_10x6_Format:ne,RGBA_ASTC_10x8_Format:re,RGBA_ASTC_12x10_Format:ae,RGBA_ASTC_12x12_Format:oe,RGBA_ASTC_4x4_Format:qt,RGBA_ASTC_5x4_Format:Kt,RGBA_ASTC_5x5_Format:Zt,RGBA_ASTC_6x5_Format:Jt,RGBA_ASTC_6x6_Format:Qt,RGBA_ASTC_8x5_Format:$t,RGBA_ASTC_8x6_Format:te,RGBA_ASTC_8x8_Format:ee,RGBA_BPTC_Format:he,RGBA_ETC2_EAC_Format:Yt,RGBA_PVRTC_2BPPV1_Format:Wt,RGBA_PVRTC_4BPPV1_Format:Vt,RGBA_S3TC_DXT1_Format:kt,RGBA_S3TC_DXT3_Format:Bt,RGBA_S3TC_DXT5_Format:zt,RGBDepthPacking:3202,RGBFormat:Et,RGBIntegerFormat:1032,RGB_BPTC_SIGNED_Format:le,RGB_BPTC_UNSIGNED_Format:ce,RGB_ETC1_Format:jt,RGB_ETC2_Format:Xt,RGB_PVRTC_2BPPV1_Format:Ht,RGB_PVRTC_4BPPV1_Format:Gt,RGB_S3TC_DXT1_Format:Ft,RGDepthPacking:3203,RGFormat:Ot,RGIntegerFormat:Nt,RawShaderMaterial:gh,Ray:rn,Raycaster:oc,RectAreaLight:yl,RedFormat:It,RedIntegerFormat:Dt,ReinhardToneMapping:2,RenderTarget:Si,RenderTarget3D:class extends Si{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isRenderTarget3D=!0,this.depth=i,this.texture=new Ei(null,t,e,i),this.texture.isRenderTargetTexture=!0}},RenderTargetArray:class extends Si{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isRenderTargetArray=!0,this.depth=i,this.texture=new Ti(null,t,e,i),this.texture.isRenderTargetTexture=!0}},RepeatWrapping:rt,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:sh,SIGNED_RED_GREEN_RGTC2_Format:me,SIGNED_RED_RGTC1_Format:ue,SRGBColorSpace:Me,SRGBTransfer:Ae,Scene:es,ShaderChunk:kc,ShaderLib:zc,ShaderMaterial:zr,ShadowMaterial:fh,Shape:To,ShapeGeometry:ah,ShapePath:class{constructor(){this.type="ShapePath",this.color=new Jn,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new uo,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,n){return this.currentPath.quadraticCurveTo(t,e,i,n),this}bezierCurveTo(t,e,i,n,r,s){return this.currentPath.bezierCurveTo(t,e,i,n,r,s),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const i=e.length;let n=!1;for(let r=i-1,s=0;s<i;r=s++){let i=e[r],a=e[s],o=a.x-i.x,h=a.y-i.y;if(Math.abs(h)>Number.EPSILON){if(h<0&&(i=e[s],o=-o,a=e[r],h=-h),t.y<i.y||t.y>a.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=h*(t.x-i.x)-o*(t.y-i.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==i.y)continue;if(a.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=a.x)return!0}}return n}const i=Jo.isClockWise,n=this.subPaths;if(0===n.length)return[];let r,s,a;const o=[];if(1===n.length)return s=n[0],a=new To,a.curves=s.curves,o.push(a),o;let h=!i(n[0].getPoints());h=t?!h:h;const l=[],c=[];let d,u,p=[],m=0;c[m]=void 0,p[m]=[];for(let e=0,a=n.length;e<a;e++)s=n[e],d=s.getPoints(),r=i(d),r=t?!r:r,r?(!h&&c[m]&&m++,c[m]={s:new To,p:d},c[m].s.curves=s.curves,h&&m++,p[m]=[]):p[m].push({h:s,p:d[0]});if(!c[0])return function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i],r=new To;r.curves=n.curves,e.push(r)}return e}(n);if(c.length>1){let t=!1,i=0;for(let t=0,e=c.length;t<e;t++)l[t]=[];for(let n=0,r=c.length;n<r;n++){const r=p[n];for(let s=0;s<r.length;s++){const a=r[s];let o=!0;for(let r=0;r<c.length;r++)e(a.p,c[r].p)&&(n!==r&&i++,o?(o=!1,l[r].push(a)):t=!0);o&&l[n].push(a)}}i>0&&!1===t&&(p=l)}for(let t=0,e=c.length;t<e;t++){a=c[t].s,o.push(a),u=p[t];for(let t=0,e=u.length;t<e;t++)a.holes.push(u[t].h)}return o}},ShapeUtils:Jo,ShortType:ft,Skeleton:ks,SkeletonHelper:class extends La{constructor(t){const e=yc(t),i=new br,n=[],r=[],s=new Jn(0,0,1),a=new Jn(0,1,0);for(let t=0;t<e.length;t++){const i=e[t];i.parent&&i.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),r.push(s.r,s.g,s.b),r.push(a.r,a.g,a.b))}i.setAttribute("position",new pr(n,3)),i.setAttribute("color",new pr(r,3));super(i,new ya({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(t){const e=this.bones,i=this.geometry,n=i.getAttribute("position");_c.copy(this.root.matrixWorld).invert();for(let t=0,i=0;t<e.length;t++){const r=e[t];r.parent&&r.parent.isBone&&(vc.multiplyMatrices(_c,r.matrixWorld),gc.setFromMatrixPosition(vc),n.setXYZ(i,gc.x,gc.y,gc.z),vc.multiplyMatrices(_c,r.parent.matrixWorld),gc.setFromMatrixPosition(vc),n.setXYZ(i+1,gc.x,gc.y,gc.z),i+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose()}},SkinnedMesh:Ds,Source:_i,Sphere:Ki,SphereGeometry:oh,Spherical:cc,SphericalHarmonics3:xl,SplineCurve:ho,SpotLight:ll,SpotLightHelper:class extends In{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new br,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,i=32;t<i;t++,e++){const r=t/i*Math.PI*2,s=e/i*Math.PI*2;n.push(Math.cos(r),Math.sin(r),1,Math.cos(s),Math.sin(s),1)}i.setAttribute("position",new pr(n,3));const r=new ya({fog:!1,toneMapped:!1});this.cone=new La(i,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),fc.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(fc),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:ys,SpriteMaterial:ss,SrcAlphaFactor:L,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:Fe,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new jr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new jr,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,Ol.copy(t.projectionMatrix);const i=e.eyeSep/2,n=i*e.near/e.focus,r=e.near*Math.tan(We*e.fov*.5)/e.zoom;let s,a;Dl.elements[12]=-i,Il.elements[12]=i,s=-r*e.aspect+n,a=r*e.aspect+n,Ol.elements[0]=2*e.near/(a-s),Ol.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(Ol),s=-r*e.aspect-n,a=r*e.aspect-n,Ol.elements[0]=2*e.near/(a-s),Ol.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(Ol)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(Dl),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Il)}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:Vh,SubtractEquation:101,SubtractiveBlending:3,TOUCH:x,TangentSpaceNormalMap:0,TetrahedronGeometry:hh,Texture:bi,TextureLoader:el,TextureUtils:Nc,TimestampQuery:{COMPUTE:"compute",RENDER:"render"},TorusGeometry:lh,TorusKnotGeometry:ch,Triangle:Xn,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:dh,UVMapping:Q,Uint16BufferAttribute:dr,Uint32BufferAttribute:ur,Uint8BufferAttribute:class extends cr{constructor(t,e,i){super(new Uint8Array(t),e,i)}},Uint8ClampedBufferAttribute:class extends cr{constructor(t,e,i){super(new Uint8ClampedArray(t),e,i)}},Uniform:nc,UniformsGroup:class extends Ge{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:rc++}),this.name="",this.usage=Fe,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return-1!==e&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let t=0,i=e.length;t<i;t++){const i=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0;t<i.length;t++)this.uniforms.push(i[t].clone())}return this}clone(){return(new this.constructor).copy(this)}},UniformsLib:Bc,UniformsUtils:Br,UnsignedByteType:pt,UnsignedInt248Type:St,UnsignedInt5999Type:Mt,UnsignedIntType:_t,UnsignedShort4444Type:bt,UnsignedShort5551Type:wt,UnsignedShortType:gt,VSMShadowMap:3,Vector2:$e,Vector3:Ci,Vector4:wi,VectorKeyframeTrack:Wh,VideoFrameTexture:class extends za{constructor(t,e,i,n,r,s,a,o){super({},t,e,i,n,r,s,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return(new this.constructor).copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}},VideoTexture:za,WebGL3DRenderTarget:class extends Mi{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Ei(null,t,e,i),this.texture.isRenderTargetTexture=!0}},WebGLArrayRenderTarget:class extends Mi{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Ti(null,t,e,i),this.texture.isRenderTargetTexture=!0}},WebGLCoordinateSystem:Be,WebGLCubeRenderTarget:Kr,WebGLRenderTarget:Mi,WebGLRenderer:vp,WebGLUtils:cp,WebGPUCoordinateSystem:ze,WebXRController:Qr,WireframeGeometry:uh,WrapAroundEnding:xe,ZeroCurvatureEnding:_e,ZeroFactor:200,ZeroSlopeEnding:ye,ZeroStencilOp:0,createCanvasElement:ai});const yp=new oc,xp=new Ci,bp=new Ci,wp=new Ai,Sp={X:new Ci(1,0,0),Y:new Ci(0,1,0),Z:new Ci(0,0,1)},Mp={type:"change"},Tp={type:"mouseDown",mode:null},Ep={type:"mouseUp",mode:null},Ap={type:"objectChange"};class Cp extends Dc{constructor(t,e=null){super(void 0,e);const i=new Kp(this);this._root=i;const n=new Zp;this._gizmo=n,i.add(n);const r=new Jp;this._plane=r,i.add(r);const s=this;function a(t,e){let i=e;Object.defineProperty(s,t,{get:function(){return void 0!==i?i:e},set:function(e){i!==e&&(i=e,r[t]=e,n[t]=e,s.dispatchEvent({type:t+"-changed",value:e}),s.dispatchEvent(Mp))}}),s[t]=e,r[t]=e,n[t]=e}a("camera",t),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const o=new Ci,h=new Ci,l=new Ai,c=new Ai,d=new Ci,u=new Ai,p=new Ci,m=new Ci,f=new Ci,g=new Ci;a("worldPosition",o),a("worldPositionStart",h),a("worldQuaternion",l),a("worldQuaternionStart",c),a("cameraPosition",d),a("cameraQuaternion",u),a("pointStart",p),a("pointEnd",m),a("rotationAxis",f),a("rotationAngle",0),a("eye",g),this._offset=new Ci,this._startNorm=new Ci,this._endNorm=new Ci,this._cameraScale=new Ci,this._parentPosition=new Ci,this._parentQuaternion=new Ai,this._parentQuaternionInv=new Ai,this._parentScale=new Ci,this._worldScaleStart=new Ci,this._worldQuaternionInv=new Ai,this._worldScale=new Ci,this._positionStart=new Ci,this._quaternionStart=new Ai,this._scaleStart=new Ci,this._getPointer=Rp.bind(this),this._onPointerDown=Lp.bind(this),this._onPointerHover=Pp.bind(this),this._onPointerMove=Ip.bind(this),this._onPointerUp=Dp.bind(this),null!==e&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;null!==t&&yp.setFromCamera(t,this.camera);const e=Op(this._gizmo.picker[this.mode],yp);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&(null==t||0===t.button)&&null!==this.axis){null!==t&&yp.setFromCamera(t,this.camera);const e=Op(this._plane,yp,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,Tp.mode=this.mode,this.dispatchEvent(Tp)}}pointerMove(t){const e=this.axis,i=this.mode,n=this.object;let r=this.space;if("scale"===i?r="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(r="world"),void 0===n||null===e||!1===this.dragging||null!==t&&-1!==t.button)return;null!==t&&yp.setFromCamera(t,this.camera);const s=Op(this._plane,yp,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===i)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===r&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(n.position.applyQuaternion(wp.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),"world"===r&&(n.parent&&n.position.add(xp.setFromMatrixPosition(n.parent.matrixWorld)),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(xp.setFromMatrixPosition(n.parent.matrixWorld)))),n.position.x=Math.max(this.minX,Math.min(this.maxX,n.position.x)),n.position.y=Math.max(this.minY,Math.min(this.maxY,n.position.y)),n.position.z=Math.max(this.minZ,Math.min(this.maxZ,n.position.z));else if("scale"===i){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),bp.set(t,t,t)}else xp.copy(this.pointStart),bp.copy(this.pointEnd),xp.applyQuaternion(this._worldQuaternionInv),bp.applyQuaternion(this._worldQuaternionInv),bp.divide(xp),-1===e.search("X")&&(bp.x=1),-1===e.search("Y")&&(bp.y=1),-1===e.search("Z")&&(bp.z=1);n.scale.copy(this._scaleStart).multiply(bp),this.scaleSnap&&(-1!==e.search("X")&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(xp.setFromMatrixPosition(this.camera.matrixWorld));let i=!1;"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(xp.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(Sp[e]),xp.copy(Sp[e]),"local"===r&&xp.applyQuaternion(this.worldQuaternion),xp.cross(this.eye),0===xp.length()?i=!0:this.rotationAngle=this._offset.dot(xp.normalize())*t),("E"===e||i)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==e&&"XYZE"!==e?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(wp.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(wp.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Mp),this.dispatchEvent(Ap)}}pointerUp(t){null!==t&&0!==t.button||(this.dragging&&null!==this.axis&&(Ep.mode=this.mode,this.dispatchEvent(Ep)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Mp),this.dispatchEvent(Ap),this.pointStart.copy(this.pointEnd))}getRaycaster(){return yp}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}}function Rp(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};{const e=this.domElement.getBoundingClientRect();return{x:(t.clientX-e.left)/e.width*2-1,y:-(t.clientY-e.top)/e.height*2+1,button:t.button}}}function Pp(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(t))}}function Lp(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(t)),this.pointerDown(this._getPointer(t)))}function Ip(t){this.enabled&&this.pointerMove(this._getPointer(t))}function Dp(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(t)))}function Op(t,e,i){const n=e.intersectObject(t,!0);for(let t=0;t<n.length;t++)if(n[t].object.visible||i)return n[t];return!1}const Np=new fn,Up=new Ci(0,1,0),Fp=new Ci(0,0,0),kp=new sn,Bp=new Ai,zp=new Ai,Gp=new Ci,Hp=new sn,Vp=new Ci(1,0,0),Wp=new Ci(0,1,0),jp=new Ci(0,0,1),Xp=new Ci,Yp=new Ci,qp=new Ci;class Kp extends In{constructor(t){super(),this.isTransformControlsRoot=!0,this.controls=t,this.visible=!1}updateMatrixWorld(t){const e=this.controls;void 0!==e.object&&(e.object.updateMatrixWorld(),null===e.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):e.object.parent.matrixWorld.decompose(e._parentPosition,e._parentQuaternion,e._parentScale),e.object.matrixWorld.decompose(e.worldPosition,e.worldQuaternion,e._worldScale),e._parentQuaternionInv.copy(e._parentQuaternion).invert(),e._worldQuaternionInv.copy(e.worldQuaternion).invert()),e.camera.updateMatrixWorld(),e.camera.matrixWorld.decompose(e.cameraPosition,e.cameraQuaternion,e._cameraScale),e.camera.isOrthographicCamera?e.camera.getWorldDirection(e.eye).negate():e.eye.copy(e.cameraPosition).sub(e.worldPosition).normalize(),super.updateMatrixWorld(t)}dispose(){this.traverse((function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()}))}}class Zp extends In{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new er({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new ya({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=t.clone();i.opacity=.15;const n=e.clone();n.opacity=.5;const r=t.clone();r.color.setHex(16711680);const s=t.clone();s.color.setHex(65280);const a=t.clone();a.color.setHex(255);const o=t.clone();o.color.setHex(16711680),o.opacity=.5;const h=t.clone();h.color.setHex(65280),h.opacity=.5;const l=t.clone();l.color.setHex(255),l.opacity=.5;const c=t.clone();c.opacity=.25;const d=t.clone();d.color.setHex(16776960),d.opacity=.25;t.clone().color.setHex(16776960);const u=t.clone();u.color.setHex(7895160);const p=new go(0,.04,.1,12);p.translate(0,.05,0);const m=new Nr(.08,.08,.08);m.translate(0,.04,0);const f=new br;f.setAttribute("position",new pr([0,0,0,1,0,0],3));const g=new go(.0075,.0075,.5,3);function v(t,e){const i=new lh(t,.0075,3,64,e*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}g.translate(0,.25,0);const _={X:[[new Dr(p,r),[.5,0,0],[0,0,-Math.PI/2]],[new Dr(p,r),[-.5,0,0],[0,0,Math.PI/2]],[new Dr(g,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Dr(p,s),[0,.5,0]],[new Dr(p,s),[0,-.5,0],[Math.PI,0,0]],[new Dr(g,s)]],Z:[[new Dr(p,a),[0,0,.5],[Math.PI/2,0,0]],[new Dr(p,a),[0,0,-.5],[-Math.PI/2,0,0]],[new Dr(g,a),null,[Math.PI/2,0,0]]],XYZ:[[new Dr(new nh(.1,0),c.clone()),[0,0,0]]],XY:[[new Dr(new Nr(.15,.15,.01),l.clone()),[.15,.15,0]]],YZ:[[new Dr(new Nr(.15,.15,.01),o.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Dr(new Nr(.15,.15,.01),h.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},y={X:[[new Dr(new go(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Dr(new go(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Dr(new go(.2,0,.6,4),i),[0,.3,0]],[new Dr(new go(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Dr(new go(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Dr(new go(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Dr(new nh(.2,0),i)]],XY:[[new Dr(new Nr(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Dr(new Nr(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Dr(new Nr(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},x={START:[[new Dr(new nh(.01,2),n),null,null,null,"helper"]],END:[[new Dr(new nh(.01,2),n),null,null,null,"helper"]],DELTA:[[new Aa(function(){const t=new br;return t.setAttribute("position",new pr([0,0,0,1,1,1],3)),t}(),n),null,null,null,"helper"]],X:[[new Aa(f,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Aa(f,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Aa(f,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},b={XYZE:[[new Dr(v(.5,1),u),null,[0,Math.PI/2,0]]],X:[[new Dr(v(.5,.5),r)]],Y:[[new Dr(v(.5,.5),s),null,[0,0,-Math.PI/2]]],Z:[[new Dr(v(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new Dr(v(.75,1),d),null,[0,Math.PI/2,0]]]},w={AXIS:[[new Aa(f,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},S={XYZE:[[new Dr(new oh(.25,10,8),i)]],X:[[new Dr(new lh(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Dr(new lh(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Dr(new lh(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Dr(new lh(.75,.1,2,24),i)]]},M={X:[[new Dr(m,r),[.5,0,0],[0,0,-Math.PI/2]],[new Dr(g,r),[0,0,0],[0,0,-Math.PI/2]],[new Dr(m,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Dr(m,s),[0,.5,0]],[new Dr(g,s)],[new Dr(m,s),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Dr(m,a),[0,0,.5],[Math.PI/2,0,0]],[new Dr(g,a),[0,0,0],[Math.PI/2,0,0]],[new Dr(m,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Dr(new Nr(.15,.15,.01),l),[.15,.15,0]]],YZ:[[new Dr(new Nr(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Dr(new Nr(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Dr(new Nr(.1,.1,.1),c.clone())]]},T={X:[[new Dr(new go(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Dr(new go(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Dr(new go(.2,0,.6,4),i),[0,.3,0]],[new Dr(new go(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Dr(new go(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Dr(new go(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Dr(new Nr(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Dr(new Nr(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Dr(new Nr(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Dr(new Nr(.2,.2,.2),i),[0,0,0]]]},E={X:[[new Aa(f,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Aa(f,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Aa(f,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function A(t){const e=new In;for(const i in t)for(let n=t[i].length;n--;){const r=t[i][n][0].clone(),s=t[i][n][1],a=t[i][n][2],o=t[i][n][3],h=t[i][n][4];r.name=i,r.tag=h,s&&r.position.set(s[0],s[1],s[2]),a&&r.rotation.set(a[0],a[1],a[2]),o&&r.scale.set(o[0],o[1],o[2]),r.updateMatrix();const l=r.geometry.clone();l.applyMatrix4(r.matrix),r.geometry=l,r.renderOrder=1/0,r.position.set(0,0,0),r.rotation.set(0,0,0),r.scale.set(1,1,1),e.add(r)}return e}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=A(_)),this.add(this.gizmo.rotate=A(b)),this.add(this.gizmo.scale=A(M)),this.add(this.picker.translate=A(y)),this.add(this.picker.rotate=A(S)),this.add(this.picker.scale=A(T)),this.add(this.helper.translate=A(x)),this.add(this.helper.rotate=A(w)),this.add(this.helper.scale=A(E)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const e="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:zp;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let t=0;t<i.length;t++){const n=i[t];let r;if(n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition),r=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(r*this.size/4),"helper"!==n.tag){if(n.quaternion.copy(e),"translate"===this.mode||"scale"===this.mode){const t=.99,i=.2;"X"===n.name&&Math.abs(Up.copy(Vp).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Y"===n.name&&Math.abs(Up.copy(Wp).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Z"===n.name&&Math.abs(Up.copy(jp).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XY"===n.name&&Math.abs(Up.copy(jp).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"YZ"===n.name&&Math.abs(Up.copy(Vp).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XZ"===n.name&&Math.abs(Up.copy(Wp).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)}else"rotate"===this.mode&&(Bp.copy(e),Up.copy(this.eye).applyQuaternion(wp.copy(e).invert()),-1!==n.name.search("E")&&n.quaternion.setFromRotationMatrix(kp.lookAt(this.eye,Fp,Wp)),"X"===n.name&&(wp.setFromAxisAngle(Vp,Math.atan2(-Up.y,Up.z)),wp.multiplyQuaternions(Bp,wp),n.quaternion.copy(wp)),"Y"===n.name&&(wp.setFromAxisAngle(Wp,Math.atan2(Up.x,Up.z)),wp.multiplyQuaternions(Bp,wp),n.quaternion.copy(wp)),"Z"===n.name&&(wp.setFromAxisAngle(jp,Math.atan2(Up.y,Up.x)),wp.multiplyQuaternions(Bp,wp),n.quaternion.copy(wp)));n.visible=n.visible&&(-1===n.name.indexOf("X")||this.showX),n.visible=n.visible&&(-1===n.name.indexOf("Y")||this.showY),n.visible=n.visible&&(-1===n.name.indexOf("Z")||this.showZ),n.visible=n.visible&&(-1===n.name.indexOf("E")||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some((function(t){return n.name===t})))&&(n.material.color.setHex(16776960),n.material.opacity=1)}else n.visible=!1,"AXIS"===n.name?(n.visible=!!this.axis,"X"===this.axis&&(wp.setFromEuler(Np.set(0,0,0)),n.quaternion.copy(e).multiply(wp),Math.abs(Up.copy(Vp).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Y"===this.axis&&(wp.setFromEuler(Np.set(0,0,Math.PI/2)),n.quaternion.copy(e).multiply(wp),Math.abs(Up.copy(Wp).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Z"===this.axis&&(wp.setFromEuler(Np.set(0,Math.PI/2,0)),n.quaternion.copy(e).multiply(wp),Math.abs(Up.copy(jp).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"XYZE"===this.axis&&(wp.setFromEuler(Np.set(0,Math.PI/2,0)),Up.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(kp.lookAt(Fp,Up,Wp)),n.quaternion.multiply(wp),n.visible=this.dragging),"E"===this.axis&&(n.visible=!1)):"START"===n.name?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):"END"===n.name?(n.position.copy(this.worldPosition),n.visible=this.dragging):"DELTA"===n.name?(n.position.copy(this.worldPositionStart),n.quaternion.copy(this.worldQuaternionStart),xp.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),xp.applyQuaternion(this.worldQuaternionStart.clone().invert()),n.scale.copy(xp),n.visible=this.dragging):(n.quaternion.copy(e),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=-1!==this.axis.search(n.name)))}super.updateMatrixWorld(t)}}class Jp extends Dr{constructor(){super(new rh(1e5,1e5,2,2),new er({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),Xp.copy(Vp).applyQuaternion("local"===e?this.worldQuaternion:zp),Yp.copy(Wp).applyQuaternion("local"===e?this.worldQuaternion:zp),qp.copy(jp).applyQuaternion("local"===e?this.worldQuaternion:zp),Up.copy(Yp),this.mode){case"translate":case"scale":switch(this.axis){case"X":Up.copy(this.eye).cross(Xp),Gp.copy(Xp).cross(Up);break;case"Y":Up.copy(this.eye).cross(Yp),Gp.copy(Yp).cross(Up);break;case"Z":Up.copy(this.eye).cross(qp),Gp.copy(qp).cross(Up);break;case"XY":Gp.copy(qp);break;case"YZ":Gp.copy(Xp);break;case"XZ":Up.copy(qp),Gp.copy(Yp);break;case"XYZ":case"E":Gp.set(0,0,0)}break;default:Gp.set(0,0,0)}0===Gp.length()?this.quaternion.copy(this.cameraQuaternion):(Hp.lookAt(xp.set(0,0,0),Gp,Up),this.quaternion.setFromRotationMatrix(Hp)),super.updateMatrixWorld(t)}}class Qp extends Aa{constructor(t,e=1,i=16776960,n=new Ci){const r=new br;r.setAttribute("position",new pr([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new ya({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e,this.offset=n;const s=new br;s.setAttribute("position",new pr([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.helper=new Dr(s,new er({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1,side:2})),this.add(this.helper)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}updateMatrixWorld(t){this.position.set(0,0,0),this.lookAt(this.plane.normal),this.position.copy(this.offset),this.translateZ(-(this.offset.dot(this.plane.normal)+this.plane.constant)),this.scale.set(.5*this.size,.5*this.size,1),super.updateMatrixWorld(t)}}const $p={type:"change"},tm={type:"start"},em={type:"end"},im=-1,nm=0,rm=1,sm=2,am=3,om=4,hm=5,lm=6;class cm extends Ge{constructor(t,e){super(),this.object=t,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Ci,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:y.ROTATE,MIDDLE:y.DOLLY,RIGHT:y.PAN},this.touches={ONE:x.ROTATE,TWO:x.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return r.phi},this.getAzimuthalAngle=function(){return r.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",C),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",C),this._domElementKeyEvents=null},this.saveState=function(){i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=function(){i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent($p),i.update(),i.state=im},this.update=function(){const e=new Ci,a=(new Ai).setFromUnitVectors(t.up,new Ci(0,1,0)),h=a.clone().invert(),l=new Ci,c=new Ai,d=new Ci,u=2*Math.PI;return function(){const t=i.object.position;e.copy(t).sub(i.target),e.applyQuaternion(a),r.setFromVector3(e),i.autoRotate&&i.state===im&&o(2*Math.PI/60/60*i.autoRotateSpeed),i.enableDamping?(r.theta+=s.theta*i.dampingFactor,r.phi+=s.phi*i.dampingFactor):(r.theta+=s.theta,r.phi+=s.phi);let p=i.minAzimuthAngle,m=i.maxAzimuthAngle;return isFinite(p)&&isFinite(m)&&(p<-Math.PI?p+=u:p>Math.PI&&(p-=u),m<-Math.PI?m+=u:m>Math.PI&&(m-=u),r.theta=p<=m?Math.max(p,Math.min(m,r.theta)):r.theta>(p+m)/2?Math.max(p,r.theta):Math.min(m,r.theta)),r.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,r.phi)),r.makeSafe(),r.radius*=i.scale,r.radius=Math.max(i.minDistance,Math.min(i.maxDistance,r.radius)),!0===i.enableDamping?i.target.addScaledVector(i.panOffset,i.dampingFactor):i.target.add(i.panOffset),e.setFromSpherical(r),e.applyQuaternion(h),t.copy(i.target).add(e),i.object.lookAt(i.target),!0===i.enableDamping?(s.theta*=1-i.dampingFactor,s.phi*=1-i.dampingFactor,i.panOffset.multiplyScalar(1-i.dampingFactor)):(s.set(0,0,0),i.panOffset.set(0,0,0)),i.scale=1,!!(i.zoomChanged||l.distanceToSquared(i.object.position)>n||8*(1-c.dot(i.object.quaternion))>n||d.distanceToSquared(i.target)>0)&&(i.dispatchEvent($p),l.copy(i.object.position),c.copy(i.object.quaternion),d.copy(i.target),i.zoomChanged=!1,!0)}}(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",R),i.domElement.removeEventListener("pointerdown",M),i.domElement.removeEventListener("pointercancel",E),i.domElement.removeEventListener("wheel",A),i.domElement.removeEventListener("pointermove",T),i.domElement.removeEventListener("pointerup",E),null!==i._domElementKeyEvents&&(i._domElementKeyEvents.removeEventListener("keydown",C),i._domElementKeyEvents=null)};const i=this;i.state=im;const n=1e-6,r=new cc,s=new cc;function a(){return Math.pow(.95,i.zoomSpeed)}function o(t){s.theta-=t}function h(t){s.phi-=t}i.scale=1,i.panOffset=new Ci,i.zoomChanged=!1,i.rotateStart=new $e,i.rotateEnd=new $e,i.rotateDelta=new $e,i.panStart=new $e,i.panEnd=new $e,i.panDelta=new $e,i.dollyStart=new $e,i.dollyEnd=new $e,i.dollyDelta=new $e,i.dollyScale=0,i.pointers=[],i.pointerPositions={};const l=function(){const t=new Ci;return function(e,n){t.setFromMatrixColumn(n,0),t.multiplyScalar(-e),i.panOffset.add(t)}}(),c=function(){const t=new Ci;return function(e,n){!0===i.screenSpacePanning?t.setFromMatrixColumn(n,1):(t.setFromMatrixColumn(n,0),t.crossVectors(i.object.up,t)),t.multiplyScalar(e),i.panOffset.add(t)}}(),d=function(){const t=new Ci;return function(e,n){const r=i.domElement;if(i.object.isPerspectiveCamera){const s=i.object.position;t.copy(s).sub(i.target);let a=t.length();a*=Math.tan(i.object.fov/2*Math.PI/180),l(2*e*a/r.clientHeight,i.object.matrix),c(2*n*a/r.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(l(e*(i.object.right-i.object.left)/i.object.zoom/r.clientWidth,i.object.matrix),c(n*(i.object.top-i.object.bottom)/i.object.zoom/r.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}}();function u(t){i.object.isPerspectiveCamera?i.scale/=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom*t)),i.object.updateProjectionMatrix(),i.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function p(t){i.object.isPerspectiveCamera?i.scale*=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/t)),i.object.updateProjectionMatrix(),i.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function m(t){i.rotateStart.set(t.clientX,t.clientY)}function f(t){i.panStart.set(t.clientX,t.clientY)}function g(){if(1===i.pointers.length)i.rotateStart.set(i.pointers[0].pageX,i.pointers[0].pageY);else{const t=.5*(i.pointers[0].pageX+i.pointers[1].pageX),e=.5*(i.pointers[0].pageY+i.pointers[1].pageY);i.rotateStart.set(t,e)}}function v(){if(1===i.pointers.length)i.panStart.set(i.pointers[0].pageX,i.pointers[0].pageY);else{const t=.5*(i.pointers[0].pageX+i.pointers[1].pageX),e=.5*(i.pointers[0].pageY+i.pointers[1].pageY);i.panStart.set(t,e)}}function _(){const t=i.pointers[0].pageX-i.pointers[1].pageX,e=i.pointers[0].pageY-i.pointers[1].pageY,n=Math.sqrt(t*t+e*e);i.dollyStart.set(0,n)}function b(t){if(1==i.pointers.length)i.rotateEnd.set(t.pageX,t.pageY);else{const e=L(t),n=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);i.rotateEnd.set(n,r)}i.rotateDelta.subVectors(i.rotateEnd,i.rotateStart).multiplyScalar(i.rotateSpeed);const e=i.domElement;o(2*Math.PI*i.rotateDelta.x/e.clientHeight),h(2*Math.PI*i.rotateDelta.y/e.clientHeight),i.rotateStart.copy(i.rotateEnd)}function w(t){if(1===i.pointers.length)i.panEnd.set(t.pageX,t.pageY);else{const e=L(t),n=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);i.panEnd.set(n,r)}i.panDelta.subVectors(i.panEnd,i.panStart).multiplyScalar(i.panSpeed),d(i.panDelta.x,i.panDelta.y),i.panStart.copy(i.panEnd)}function S(t){const e=L(t),n=t.pageX-e.x,r=t.pageY-e.y,s=Math.sqrt(n*n+r*r);i.dollyEnd.set(0,s),i.dollyDelta.set(0,Math.pow(i.dollyEnd.y/i.dollyStart.y,i.zoomSpeed)),u(i.dollyDelta.y),i.dollyStart.copy(i.dollyEnd)}function M(t){!1!==i.enabled&&(0===i.pointers.length&&(i.domElement.setPointerCapture(t.pointerId),i.domElement.addEventListener("pointermove",T),i.domElement.addEventListener("pointerup",E)),function(t){i.pointers.push(t)}(t),"touch"===t.pointerType?function(t){switch(P(t),i.pointers.length){case 1:switch(i.touches.ONE){case x.ROTATE:if(!1===i.enableRotate)return;g(),i.state=am;break;case x.PAN:if(!1===i.enablePan)return;v(),i.state=om;break;default:i.state=im}break;case 2:switch(i.touches.TWO){case x.DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;i.enableZoom&&_(),i.enablePan&&v(),i.state=hm;break;case x.DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;i.enableZoom&&_(),i.enableRotate&&g(),i.state=lm;break;default:i.state=im}break;default:i.state=im}i.state!==im&&i.dispatchEvent(tm)}(t):function(t){let e;switch(t.button){case 0:e=i.mouseButtons.LEFT;break;case 1:e=i.mouseButtons.MIDDLE;break;case 2:e=i.mouseButtons.RIGHT;break;default:e=-1}switch(e){case y.DOLLY:if(!1===i.enableZoom)return;!function(t){i.dollyStart.set(t.clientX,t.clientY)}(t),i.state=rm;break;case y.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enablePan)return;f(t),i.state=sm}else{if(!1===i.enableRotate)return;m(t),i.state=nm}break;case y.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enableRotate)return;m(t),i.state=nm}else{if(!1===i.enablePan)return;f(t),i.state=sm}break;default:i.state=im}i.state!==im&&i.dispatchEvent(tm)}(t))}function T(t){!1!==i.enabled&&("touch"===t.pointerType?function(t){switch(P(t),i.state){case am:if(!1===i.enableRotate)return;b(t),i.update();break;case om:if(!1===i.enablePan)return;w(t),i.update();break;case hm:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(t){i.enableZoom&&S(t),i.enablePan&&w(t)}(t),i.update();break;case lm:if(!1===i.enableZoom&&!1===i.enableRotate)return;!function(t){i.enableZoom&&S(t),i.enableRotate&&b(t)}(t),i.update();break;default:i.state=im}}(t):function(t){switch(i.state){case nm:if(!1===i.enableRotate)return;!function(t){i.rotateEnd.set(t.clientX,t.clientY),i.rotateDelta.subVectors(i.rotateEnd,i.rotateStart).multiplyScalar(i.rotateSpeed);const e=i.domElement;o(2*Math.PI*i.rotateDelta.x/e.clientHeight),h(2*Math.PI*i.rotateDelta.y/e.clientHeight),i.rotateStart.copy(i.rotateEnd),i.update()}(t);break;case rm:if(!1===i.enableZoom)return;!function(t){i.dollyEnd.set(t.clientX,t.clientY),i.dollyDelta.subVectors(i.dollyEnd,i.dollyStart),i.dollyDelta.y<0?(i.dollyScale=1/a(),u(a())):i.dollyDelta.y>0&&(i.dollyScale=a(),p(a())),i.dollyStart.copy(i.dollyEnd),i.update()}(t);break;case sm:if(!1===i.enablePan)return;!function(t){i.panEnd.set(t.clientX,t.clientY),i.panDelta.subVectors(i.panEnd,i.panStart).multiplyScalar(i.panSpeed),d(i.panDelta.x,i.panDelta.y),i.panStart.copy(i.panEnd),i.update()}(t)}}(t))}function E(t){!function(t){delete i.pointerPositions[t.pointerId];for(let e=0;e<i.pointers.length;e++)if(i.pointers[e].pointerId==t.pointerId)return void i.pointers.splice(e,1)}(t),0===i.pointers.length&&(i.domElement.releasePointerCapture(t.pointerId),i.domElement.removeEventListener("pointermove",T),i.domElement.removeEventListener("pointerup",E)),i.dispatchEvent(em),i.state=im}function A(t){!1!==i.enabled&&!1!==i.enableZoom&&i.state===im&&(t.preventDefault(),i.dispatchEvent(tm),function(t){i.dollyEnd.set(i.domElement.clientWidth/2,i.domElement.clientHeight/2),i.dollyDelta.set(t.deltaX,t.deltaY),t.deltaY<0?(i.dollyScale=1/a(),p(a())):t.deltaY>0&&(i.dollyScale=a(),u(a())),i.dollyStart.copy(i.dollyEnd),i.update(),0!==t.deltaY&&(i.state=rm,i.dispatchEvent($p),i.state=im)}(t),i.dispatchEvent(em))}function C(t){!1!==i.enabled&&!1!==i.enablePan&&function(t){let e=!1;switch(t.code){case i.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?h(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(0,i.keyPanSpeed),e=!0;break;case i.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?h(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(0,-i.keyPanSpeed),e=!0;break;case i.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?o(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(i.keyPanSpeed,0),e=!0;break;case i.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?o(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(-i.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),i.update())}(t)}function R(t){!1!==i.enabled&&t.preventDefault()}function P(t){let e=i.pointerPositions[t.pointerId];void 0===e&&(e=new $e,i.pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}function L(t){const e=t.pointerId===i.pointers[0].pointerId?i.pointers[1]:i.pointers[0];return i.pointerPositions[e.pointerId]}i.domElement.addEventListener("contextmenu",R),i.domElement.addEventListener("pointerdown",M),i.domElement.addEventListener("pointercancel",E),i.domElement.addEventListener("wheel",A,{passive:!1}),this.update()}}class dm{constructor(t){this.updateControls=()=>{this.orbit.maxDistance=this.viewer.camera.far,this.orbit.minDistance=this.viewer.camera.near,this.orbit.object=this.viewer.camera,this.orbit.target.copy(this.viewer.target),this.orbit.update()},this.controlsStart=()=>{this.changed=!1},this.controlsChange=()=>{switch(this.viewer.target.copy(this.orbit.target),this.viewer.update(),this.orbit.state){case sm:case om:this.viewer.emitEvent({type:"pan",x:this.orbit.panEnd.x,y:this.orbit.panEnd.y,dX:this.orbit.panDelta.x,dY:this.orbit.panDelta.y});break;case rm:this.viewer.emitEvent({type:"zoomat",data:this.orbit.dollyScale,x:this.orbit.dollyEnd.x,y:this.orbit.dollyEnd.y})}this.changed=!0},this.stopContextMenu=t=>{this.changed&&(t.preventDefault(),t.stopPropagation())},this.orbit=new cm(t.camera,t.canvas),this.orbit.mouseButtons={LEFT:y.ROTATE,MIDDLE:y.PAN,RIGHT:y.PAN},this.orbit.touches={ONE:x.ROTATE,TWO:x.DOLLY_PAN},this.orbit.screenSpacePanning=!0,this.orbit.rotateSpeed=.33,this.orbit.addEventListener("start",this.controlsStart),this.orbit.addEventListener("change",this.controlsChange),this.changed=!1,this.viewer=t,this.viewer.addEventListener("databasechunk",this.updateControls),this.viewer.on("viewposition",this.updateControls),this.viewer.addEventListener("zoom",this.updateControls),this.viewer.addEventListener("drawviewpoint",this.updateControls),this.viewer.addEventListener("contextmenu",this.stopContextMenu),this.updateControls()}initialize(){}dispose(){this.viewer.removeEventListener("databasechunk",this.updateControls),this.viewer.off("viewposition",this.updateControls),this.viewer.removeEventListener("zoom",this.updateControls),this.viewer.removeEventListener("drawviewpoint",this.updateControls),this.viewer.removeEventListener("contextmenu",this.stopContextMenu),this.orbit.removeEventListener("start",this.controlsStart),this.orbit.removeEventListener("change",this.controlsChange),this.orbit.dispose()}}class um extends dm{constructor(t,e,i){super(t),this.transformChange=()=>{this.plane.constant=-this.planeCenter.position.dot(this.plane.normal),this.viewer.update()},this.transformDrag=t=>{this.orbit.enabled=!t.value},this.updatePlaneSize=()=>{this.planeHelper.size=this.viewer.extents.getSize(new Ci).length(),this.viewer.update()},this.onDoubleClick=t=>{t.stopPropagation(),this.plane.negate(),this.viewer.update()};const n=t.extents.getSize(new Ci).length(),r=t.extents.getCenter(new Ci),s=-r.dot(e);this.plane=new Js(e,s),t.renderer.clippingPlanes||(t.renderer.clippingPlanes=[]),t.renderer.clippingPlanes.push(this.plane),this.planeHelper=new Qp(this.plane,n,i,r),this.viewer.helpers.add(this.planeHelper),this.planeCenter=new In,this.planeCenter.position.copy(t.extents.getCenter(new Ci)),this.viewer.helpers.add(this.planeCenter),this.transform=new Cp(t.camera,t.canvas),this.transform.showX=!!e.x,this.transform.showY=!!e.y,this.transform.showZ=!!e.z,this.transform.attach(this.planeCenter),this.transform.addEventListener("change",this.transformChange),this.transform.addEventListener("dragging-changed",this.transformDrag),this.viewer.helpers.add(this.transform.getHelper()),this.viewer.on("explode",this.updatePlaneSize),this.viewer.on("show",this.updatePlaneSize),this.viewer.on("showall",this.updatePlaneSize),this.viewer.canvas.addEventListener("dblclick",this.onDoubleClick,!0),this.viewer.update()}dispose(){this.viewer.off("explode",this.updatePlaneSize),this.viewer.off("show",this.updatePlaneSize),this.viewer.off("showAll",this.updatePlaneSize),this.viewer.canvas.removeEventListener("dblclick",this.onDoubleClick,!0),this.transform.removeEventListener("change",this.transformChange),this.transform.removeEventListener("dragging-changed",this.transformDrag),this.transform.getHelper().removeFromParent(),this.transform.detach(),this.transform.dispose(),this.planeHelper.removeFromParent(),this.planeHelper.dispose(),this.planeCenter.removeFromParent(),super.dispose()}}class pm extends um{constructor(t){super(t,new Ci(1,0,0),16711680)}}class mm extends um{constructor(t){super(t,new Ci(0,1,0),65280)}}class fm extends um{constructor(t){super(t,new Ci(0,0,1),255)}}class gm extends dm{constructor(t){super(t),this.onPointerDown=t=>{0===t.button&&(this.line.startPoint=this.snapper.getSnapPoint(t),this.line.render(),this.viewer.canvas.setPointerCapture(t.pointerId),this.orbit.enabled=!this.line.startPoint)},this.onPointerMove=t=>{this.orbit.enabled&&-1!==this.orbit.state||(this.line.endPoint=this.snapper.getSnapPoint(t),this.line.render(),this.line.startPoint&&(this.changed=!0))},this.onPointerUp=t=>{this.line.startPoint&&this.line.endPoint&&this.line.getDistance()>=.01?(this.line=new xm(this.overlay),this.overlay.addLine(this.line)):(this.line.startPoint=void 0,this.line.endPoint=void 0,this.line.render()),this.viewer.canvas.releasePointerCapture(t.pointerId),this.orbit.enabled=!0},this.onPointerCancel=t=>{this.viewer.canvas.dispatchEvent(new PointerEvent("pointerup",t))},this.onPointerLeave=()=>{this.line.endPoint=void 0,this.line.render()},this.renderOverlay=()=>{this.overlay.render()},this.updateSnapper=()=>{this.snapper.update(this.viewer.scene)},this.overlay=new _m(t.camera,t.canvas),this.overlay.attach(),this.line=new xm(this.overlay),this.overlay.addLine(this.line),this.snapper=new vm(t.camera,t.canvas),this.snapper.update(t.scene),this.viewer.canvas.addEventListener("pointerdown",this.onPointerDown),this.viewer.canvas.addEventListener("pointermove",this.onPointerMove),this.viewer.canvas.addEventListener("pointerup",this.onPointerUp),this.viewer.canvas.addEventListener("pointercancel",this.onPointerCancel),this.viewer.canvas.addEventListener("pointerleave",this.onPointerLeave),this.viewer.addEventListener("render",this.renderOverlay),this.viewer.addEventListener("hide",this.updateSnapper),this.viewer.addEventListener("isolate",this.updateSnapper),this.viewer.addEventListener("show",this.updateSnapper),this.viewer.addEventListener("showall",this.updateSnapper)}dispose(){this.viewer.canvas.removeEventListener("pointerdown",this.onPointerDown),this.viewer.canvas.removeEventListener("pointermove",this.onPointerMove),this.viewer.canvas.removeEventListener("pointerup",this.onPointerUp),this.viewer.canvas.removeEventListener("pointercancel",this.onPointerCancel),this.viewer.canvas.removeEventListener("pointerleave",this.onPointerLeave),this.viewer.removeEventListener("render",this.renderOverlay),this.viewer.removeEventListener("hide",this.updateSnapper),this.viewer.removeEventListener("isolate",this.updateSnapper),this.viewer.removeEventListener("show",this.updateSnapper),this.viewer.removeEventListener("showall",this.updateSnapper),this.overlay.detach(),this.overlay.dispose(),super.dispose()}}class vm{constructor(t,e){this.objects=[],this.camera=t,this.canvas=e,this.raycaster=new oc}getSnapPoint(t){const e=new $e(t.clientX,t.clientY),i=this.canvas.getBoundingClientRect(),n=(e.x-i.left)/i.width*2-1,r=-(e.y-i.top)/i.height*2+1,s=new $e(n,r);this.raycaster.setFromCamera(s,this.camera),this.raycaster.params={Mesh:{},Line:{threshold:.25},Line2:{threshold:.25},LOD:{},Points:{threshold:.1},Sprite:{}};const a=this.raycaster.intersectObjects(this.objects,!1);if(0!==a.length)return a[0].point}update(t){this.objects=[],t.traverseVisible((t=>this.objects.push(t)))}}class _m{constructor(t,e){this.lines=[],this.camera=t,this.canvas=e,this.projector=new Lm(t,e)}attach(){this.container=document.createElement("div"),this.container.id="measure-container",this.container.style.background="rgba(0,0,0,0)",this.container.style.position="absolute",this.container.style.top="0px",this.container.style.left="0px",this.container.style.width="100%",this.container.style.height="100%",this.container.style.outline="none",this.container.style.pointerEvents="none",this.container.style.overflow="hidden",this.canvas.parentElement.appendChild(this.container)}dispose(){this.clear()}detach(){this.container.remove(),this.container=void 0}clear(){this.lines.forEach((t=>t.dispose())),this.lines=[]}render(){this.projector.updateProjectionMatrix(),this.lines.forEach((t=>t.render()))}update(){this.lines.forEach((t=>t.update()))}addLine(t){this.lines.push(t)}removeLine(t){this.lines=this.lines.filter((e=>e!==t))}}const ym=new Ci;class xm{constructor(t){this.id=Date.now(),this.unit="",this.scale=1,this.size=10,this.lineWidth=2,this.style={border:"2px solid #FFFFFF",background:"#009bff",boxShadow:"0 0 10px rgba(0,0,0,0.5)",color:"white",font:"1rem system-ui"},this.overlay=t,this.elementStartPoint=t.container.appendChild(document.createElement("div")),this.elementEndPoint=t.container.appendChild(document.createElement("div")),this.elementLine=t.container.appendChild(document.createElement("div")),this.elementLabel=t.container.appendChild(document.createElement("div")),this.update()}dispose(){this.elementStartPoint.remove(),this.elementEndPoint.remove(),this.elementLine.remove(),this.elementLabel.remove()}render(){const t=this.overlay.projector;if(this.startPoint){const{point:e,visible:i}=t.projectPoint(this.startPoint);this.elementStartPoint.style.display=i?"block":"none",this.elementStartPoint.style.left=`${e.x}px`,this.elementStartPoint.style.top=`${e.y}px`}else this.elementStartPoint.style.display="none";if(this.endPoint){const{point:e,visible:i}=t.projectPoint(this.endPoint);this.elementEndPoint.style.display=i?"block":"none",this.elementEndPoint.style.left=`${e.x}px`,this.elementEndPoint.style.top=`${e.y}px`}else this.elementEndPoint.style.display="none";if(this.startPoint&&this.endPoint){const{point1:e,point2:i,visible:n}=t.projectLine(this.startPoint,this.endPoint);i.sub(e);const r=i.angle(),s=i.length();this.elementLine.style.display=n?"block":"none",this.elementLine.style.left=`${e.x}px`,this.elementLine.style.top=`${e.y}px`,this.elementLine.style.width=`${s}px`,this.elementLine.style.transform=`translate(0px, ${-this.lineWidth/2}px) rotate(${r}rad)`}else this.elementLine.style.display="none";if(this.startPoint&&this.endPoint){ym.lerpVectors(this.startPoint,this.endPoint,.5);const{point:e,visible:i}=t.projectPoint(ym),n=this.getDistance();this.elementLabel.style.display=i&&n>=.01?"block":"none",this.elementLabel.style.left=`${e.x}px`,this.elementLabel.style.top=`${e.y}px`,this.elementLabel.innerHTML=`${n.toFixed(2)} ${this.unit}`}else this.elementLabel.style.display="none"}update(){this.elementStartPoint.id=`markup-dot-start-${this.id}`,this.elementStartPoint.style.position="absolute",this.elementStartPoint.style.zIndex="2",this.elementStartPoint.style.width=`${this.size}px`,this.elementStartPoint.style.height=`${this.size}px`,this.elementStartPoint.style.border=this.style.border,this.elementStartPoint.style.borderRadius=`${this.size}px`,this.elementStartPoint.style.background=this.style.background,this.elementStartPoint.style.boxShadow=this.style.boxShadow,this.elementStartPoint.style.transform="translate(-50%, -50%)",this.elementEndPoint.id=`markup-dot-end-${this.id}`,this.elementEndPoint.style.position="absolute",this.elementEndPoint.style.zIndex="2",this.elementEndPoint.style.width=`${this.size}px`,this.elementEndPoint.style.height=`${this.size}px`,this.elementEndPoint.style.border=this.style.border,this.elementEndPoint.style.borderRadius=`${this.size}px`,this.elementEndPoint.style.background=this.style.background,this.elementEndPoint.style.boxShadow=this.style.boxShadow,this.elementEndPoint.style.transform="translate(-50%, -50%)",this.elementLine.id=`markup-line-${this.id}`,this.elementLine.style.position="absolute",this.elementLine.style.zIndex="1",this.elementLine.style.height=`${this.lineWidth}px`,this.elementLine.style.background=this.style.background,this.elementLine.style.boxShadow=this.style.boxShadow,this.elementLine.style.transformOrigin=`0px ${this.lineWidth/2}px`,this.elementLabel.id=`markup-label-${this.id}`,this.elementLabel.style.position="absolute",this.elementLabel.style.zIndex="3",this.elementLabel.style.padding="2px",this.elementLabel.style.paddingInline="5px",this.elementLabel.style.borderRadius="5px",this.elementLabel.style.background=this.style.background,this.elementLabel.style.boxShadow=this.style.boxShadow,this.elementLabel.style.color=this.style.color,this.elementLabel.style.font=this.style.font,this.elementLabel.style.transform="translate(-50%, -50%)"}getDistance(){return this.startPoint.distanceTo(this.endPoint)/this.scale}}let bm,wm;const Sm=new sn,Mm=new sn,Tm=new Ci,Em=new wi,Am=new wi,Cm=new $e,Rm=new $e,Pm=new $e;class Lm{constructor(t,e){this.camera=t,this.canvas=e}updateProjectionMatrix(){const t=this.canvas.getBoundingClientRect();bm=t.width/2,wm=t.height/2,Sm.copy(this.camera.matrixWorldInverse),Mm.multiplyMatrices(this.camera.projectionMatrix,Sm)}projectPoint(t){Tm.copy(t).applyMatrix4(Mm);const e=Tm.z>=-1&&Tm.z<=1;return Cm.x=(Tm.x+1)*bm,Cm.y=(1-Tm.y)*wm,{point:Cm,visible:e}}projectLine(t,e){let i;Em.copy(t).applyMatrix4(Mm),Am.copy(e).applyMatrix4(Mm);const n=Em.z+Em.w,r=Am.z+Am.w,s=-Em.z+Em.w,a=-Am.z+Am.w;if(n>=0&&r>=0&&s>=0&&a>=0)i=!0;else if(n<0&&r<0||s<0&&a<0)i=!1;else{let t=0,e=1;n<0?t=Math.max(t,n/(n-r)):r<0&&(e=Math.min(e,n/(n-r))),s<0?t=Math.max(t,s/(s-a)):a<0&&(e=Math.min(e,s/(s-a))),i=e>=t,i&&(Em.lerp(Am,t),Am.lerp(Em,1-e))}return Em.multiplyScalar(1/Em.w),Am.multiplyScalar(1/Am.w),Rm.x=(Em.x+1)*bm,Rm.y=(1-Em.y)*wm,Pm.x=(Am.x+1)*bm,Pm.y=(1-Am.y)*wm,{point1:Rm,point2:Pm,visible:i}}}class Im extends dm{constructor(t){super(t),this.orbit.mouseButtons={LEFT:y.PAN,MIDDLE:y.PAN,RIGHT:y.PAN}}}class Dm extends Dc{constructor(t,e){super(t,e),this.movementSpeed=.2,this.lookSpeed=5,this.multiplier=5,this.moveWheel=0,this.mouseDragOn=!1,this.onPointerDown=t=>{0===t.button&&(this.domElement.setPointerCapture(t.pointerId),this.downPosition.set(t.clientX,t.clientY),this.quaternion.copy(this.object.quaternion),this.mouseDragOn=!0)},this.onPointerMove=t=>{if(!this.mouseDragOn)return;const e=new $e(t.clientX,t.clientY);0!==this.downPosition.distanceTo(e)&&(this.rotateDelta.copy(this.downPosition).sub(e),this.rotateCamera(this.rotateDelta),this.dispatchEvent({type:"change"}))},this.onPointerUp=t=>{this.domElement.releasePointerCapture(t.pointerId),this.mouseDragOn=!1},this.onPointerCancel=t=>{this.domElement.dispatchEvent(new PointerEvent("pointerup",t))},this.onWheel=t=>{this.moveWheel=t.deltaY,this.update()},this.onKeyDown=t=>{switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"KeyW":case"KeyS":case"KeyA":case"KeyD":case"KeyQ":case"KeyE":this.moveKeys.add(t.code),this.update()}},this.onKeyUp=t=>{this.moveKeys.delete(t.code)&&this.update()},this.moveKeys=new Set,this.moveClock=new Ul,this.quaternion=t.quaternion.clone(),this.downPosition=new $e(0,0),this.rotateDelta=new $e(0,0),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onWheel),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}dispose(){this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onWheel),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),super.dispose()}update(){if(this.moveKeys.size>0){const t=this.moveClock.getDelta()*this.movementSpeed*this.multiplier;this.moveKeys.has("KeyW")&&this.object.translateZ(-t),this.moveKeys.has("KeyS")&&this.object.translateZ(t),this.moveKeys.has("KeyA")&&this.object.translateX(-t),this.moveKeys.has("KeyD")&&this.object.translateX(t),this.moveKeys.has("KeyQ")&&this.object.translateY(t),this.moveKeys.has("KeyE")&&this.object.translateY(-t);const e=this.lookSpeed+(this.multiplier-1);this.moveKeys.has("ArrowUp")&&this.rotateCamera(this.rotateDelta.add(new $e(0,-e/2))),this.moveKeys.has("ArrowDown")&&this.rotateCamera(this.rotateDelta.add(new $e(0,e/2))),this.moveKeys.has("ArrowLeft")&&this.rotateCamera(this.rotateDelta.add(new $e(e,0))),this.moveKeys.has("ArrowRight")&&this.rotateCamera(this.rotateDelta.add(new $e(-e,0))),this.moveWheel=0,this.dispatchEvent({type:"change"})}if(0!==this.moveWheel){const t=1e-4*this.moveWheel*this.movementSpeed*this.multiplier;this.object.translateZ(-t),this.moveWheel+=-1*Math.sign(this.moveWheel),this.dispatchEvent({type:"change"})}0===this.moveKeys.size&&0===this.moveWheel&&(this.moveClock.stop(),this.moveClock.autoStart=!0)}rotateCamera(t){const e=Math.PI*t.x/this.domElement.clientWidth,i=Math.PI*t.y/this.domElement.clientHeight,n=new Ai;n.setFromAxisAngle(this.object.up,e);const r=new Ai;r.setFromAxisAngle(new Ci(1,0,0),i);const s=this.quaternion.clone();s.premultiply(n).multiply(r).normalize(),this.object.setRotationFromQuaternion(s)}}class Om{constructor(t){this.updateControls=()=>{const t=this.viewer.extents.getSize(new Ci);this.controls.movementSpeed=Math.min(t.x,t.y,t.z)/2},this.controlsChange=()=>{this.viewer.update()},this.walkspeedChange=t=>{this.viewer.emitEvent(t)},this.viewerRender=()=>{this.controls.update()},this.viewerZoom=()=>{this.controls.rotateDelta.set(0,0)},this.controls=new Dm(t.camera,t.canvas),this.controls.addEventListener("change",this.controlsChange),this.controls.addEventListener("walkspeedchange",this.walkspeedChange),this.viewer=t,this.viewer.on("render",this.viewerRender),this.viewer.on("zoom",this.viewerZoom),this.updateControls()}dispose(){this.viewer.off("render",this.viewerRender),this.viewer.off("zoom",this.viewerZoom),this.controls.removeEventListener("walkspeedchange",this.walkspeedChange),this.controls.removeEventListener("change",this.controlsChange),this.controls.dispose()}}class Nm extends dm{constructor(t){super(t),this.orbit.mouseButtons={LEFT:y.DOLLY,MIDDLE:y.PAN,RIGHT:y.PAN}}}const Um=a("threejs");function Fm(t,e=0){t.models.forEach((t=>t.explode(e))),t.update(),t.emitEvent({type:"explode",data:e})}function km(t,e){if(e.isEmpty())return;const i=e.getCenter(new Ci),n=e.getBoundingSphere(new Ki),r=t.renderer.getSize(new $e),s=r.x/r.y,a=t.camera;if(a.isPerspectiveCamera){const t=new Ci(0,0,1);t.applyQuaternion(a.quaternion),t.multiplyScalar(n.radius/Math.tan(Qe.DEG2RAD*a.fov*.5)),a.position.copy(i).add(t),a.updateMatrixWorld()}if(a.isOrthographicCamera){a.top=n.radius,a.bottom=-n.radius,a.left=a.bottom*s,a.right=a.top*s,a.zoom=1,a.updateProjectionMatrix();const e=new Ci(0,0,1);e.applyQuaternion(a.quaternion),e.multiplyScalar(3*t.extents.getBoundingSphere(new Ki).radius),a.position.copy(i).add(e),a.updateMatrixWorld()}t.target.copy(i),t.update(),t.emitEvent({type:"zoom"})}Um.registerDragger("Pan",(t=>new Im(t))),Um.registerDragger("Orbit",(t=>new dm(t))),Um.registerDragger("Zoom",(t=>new Nm(t))),Um.registerDragger("MeasureLine",(t=>new gm(t))),Um.registerDragger("CuttingPlaneXAxis",(t=>new pm(t))),Um.registerDragger("CuttingPlaneYAxis",(t=>new mm(t))),Um.registerDragger("CuttingPlaneZAxis",(t=>new fm(t))),Um.registerDragger("Walk",(t=>new Om(t)));const Bm={top:new Ci(0,0,1),bottom:new Ci(0,0,-1),left:new Ci(-1,0,0),right:new Ci(1,0,0),front:new Ci(0,-1,0),back:new Ci(0,1,0),sw:new Ci(-.5,-.5,1).normalize(),se:new Ci(.5,-.5,1).normalize(),ne:new Ci(.5,.5,1).normalize(),nw:new Ci(-.5,.5,1).normalize()};function zm(t,e){const i=Bm[e]||Bm.sw,n=t.extents.getCenter(new Ci),r=t.extents.getBoundingSphere(new Ki),s=i.clone().multiplyScalar(r.radius),a=t.camera;a.position.copy(n).add(s),a.lookAt(n),a.updateMatrixWorld(),t.target.copy(n),t.update(),t.emit({type:"viewposition",data:e}),km(t,t.extents)}const Gm=n("threejs");Gm.registerCommand("applyModelTransform",(function(t,e){console.warn("applyModelTransform not implemented")})),Gm.registerCommand("clearMarkup",(function(t){t.clearOverlay()})),Gm.registerCommand("clearSelected",(function(t){t.getComponent("SelectionComponent").clearSelection(),t.update(),t.emitEvent({type:"select",data:void 0,handles:[]})})),Gm.registerCommand("clearSlices",(function(t){t.clearSlices()})),Gm.registerCommand("createPreview",(function(t,e="image/jpeg",i=.25){return t.update(!0),t.canvas.toDataURL(e,i)})),Gm.registerCommand("explode",Fm),Gm.registerCommand("collect",(function(t){Fm(t,0)})),Gm.registerCommand("getDefaultViewPositions",(function(){return Object.keys(Bm)})),Gm.registerCommand("getModels",(function(t){return t.models.map((t=>t.handle))})),Gm.registerCommand("getSelected",(function(t){const e=[];return t.models.forEach((i=>e.push(...i.getHandlesByObjects(t.selected)))),e})),Gm.registerCommand("hideSelected",(function(t){t.models.forEach((e=>e.hideObjects(t.selected))),t.getComponent("SelectionComponent").clearSelection(),t.update(),t.emitEvent({type:"hide"}),t.emitEvent({type:"select",data:void 0,handles:[]})})),Gm.registerCommand("isolateSelected",(function(t){t.models.forEach((e=>e.isolateObjects(t.selected))),t.update(),t.emitEvent({type:"isolate"})})),Gm.registerCommand("regenerateAll",(function(t){t.emit({type:"regenerateall"})})),Gm.registerCommand("resetView",(function(t){t.executeCommand("setActiveDragger"),t.executeCommand("clearSlices"),t.executeCommand("clearOverlay"),t.executeCommand("setMarkupColor"),t.executeCommand("clearSelected"),t.executeCommand("showAll"),t.executeCommand("explode",0),t.executeCommand("zoomToExtents",!0),t.executeCommand("k3DViewSW"),t.emit({type:"resetview"})})),Gm.registerCommand("selectModel",(function(t,e){const i=t.getComponent("SelectionComponent");i.clearSelection(),t.models.filter((t=>t.handle===e)).forEach((t=>i.select(t.getObjects(),t))),t.update(),t.emit({type:"select",data:[]})})),Gm.registerCommand("setActiveDragger",(function(t,e=""){t.setActiveDragger(e)})),Gm.registerCommand("setDefaultViewPosition",zm),Gm.registerCommand("setMarkupColor",(function(t,e=255,i=0,n=0){t.markup.setMarkupColor(e,i,n)})),Gm.registerCommand("setSelected",(function(t,e=[]){const i=t.getComponent("SelectionComponent");i.clearSelection(),t.models.forEach((t=>{const n=t.getObjectsByHandles(e);i.select(n,t)})),t.update(),t.emitEvent({type:"show"}),t.emitEvent({type:"select",data:void 0,handles:e})})),Gm.registerCommand("showAll",(function(t){t.models.forEach((t=>t.showAllObjects())),t.update(),t.emitEvent({type:"showall"})})),Gm.registerCommand("zoomToExtents",(function(t){km(t,t.extents)})),Gm.registerCommand("zoomToObjects",(function(t,e=[]){const i=new Set(e),n=[];t.scene.traverseVisible((t=>{var e;i.has(null===(e=t.userData)||void 0===e?void 0:e.handle)&&n.push(t)}));const r=n.reduce(((t,e)=>t.expandByObject(e)),new Li);r.isEmpty()&&r.copy(t.extents),km(t,r)})),Gm.registerCommand("zoomToSelected",(function(t){const e=t.selected.reduce(((t,e)=>t.expandByObject(e)),new Li);e.isEmpty()&&e.copy(t.extents),km(t,e)})),Gm.registerCommand("top",(t=>zm(t,"top"))),Gm.registerCommand("bottom",(t=>zm(t,"bottom"))),Gm.registerCommand("left",(t=>zm(t,"left"))),Gm.registerCommand("right",(t=>zm(t,"right"))),Gm.registerCommand("front",(t=>zm(t,"front"))),Gm.registerCommand("back",(t=>zm(t,"back"))),Gm.registerCommand("sw",(t=>zm(t,"sw"))),Gm.registerCommand("se",(t=>zm(t,"se"))),Gm.registerCommand("ne",(t=>zm(t,"ne"))),Gm.registerCommand("nw",(t=>zm(t,"nw"))),Gm.registerCommandAlias("clearMarkup","clearOverlay"),Gm.registerCommandAlias("clearSelected","unselect"),Gm.registerCommandAlias("zoomToExtents","zoomExtents"),Gm.registerCommandAlias("top","k3DViewTop"),Gm.registerCommandAlias("bottom","k3DViewBottom"),Gm.registerCommandAlias("left","k3DViewLeft"),Gm.registerCommandAlias("right","k3DViewRight"),Gm.registerCommandAlias("front","k3DViewFront"),Gm.registerCommandAlias("back","k3DViewBack"),Gm.registerCommandAlias("se","k3DViewSE"),Gm.registerCommandAlias("sw","k3DViewSW"),Gm.registerCommandAlias("ne","k3DViewNE"),Gm.registerCommandAlias("nw","k3DViewNW");class Hm{constructor(t){this.syncOptions=()=>{this.backgroundColor.setHex(16777215),this.viewer.renderer.setClearColor(this.backgroundColor)},this.viewer=t,this.backgroundColor=new Jn(16777215),this.viewer.renderer.setClearColor(this.backgroundColor),this.viewer.scene.background=this.backgroundColor,this.viewer.addEventListener("optionschange",this.syncOptions)}dispose(){this.viewer.removeEventListener("optionschange",this.syncOptions),this.viewer.scene.background=void 0}}class Vm{constructor(t){this.geometryEnd=()=>{const t=this.viewer.extents.getCenter(new Ci),e=2*this.viewer.extents.getBoundingSphere(new Ki).radius,i=this.viewer.renderer.getSize(new $e),n=i.x/i.y;let r;this.viewer.scene.traverse((t=>{t.isCamera&&(r?t.isPerspectiveCamera&&r.isOrthographicCamera&&(r=t):r=t)})),r&&(this.viewer.camera=r.clone(),this.viewer.camera.scale.set(1,1,1));const s=this.viewer.camera;s.isPerspectiveCamera&&(s.aspect=n,s.near=e/100,s.far=100*e,s.updateProjectionMatrix()),s.isOrthographicCamera&&(s.left=s.bottom*n,s.right=s.top*n,s.near=0,s.far=100*e,s.updateProjectionMatrix()),this.viewer.target.copy(t),r||this.viewer.executeCommand("setDefaultViewPosition")},this.viewer=t,this.viewer.addEventListener("databasechunk",this.geometryEnd)}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd)}}class Wm{constructor(t){this.syncExtents=()=>{const t=new Li;this.viewer.models.forEach((e=>e.getExtents(t))),this.viewer.extents.copy(t)},this.viewer=t,this.viewer.addEventListener("databasechunk",this.syncExtents),this.viewer.addEventListener("clear",this.syncExtents),this.viewer.on("explode",this.syncExtents),this.viewer.on("hide",this.syncExtents),this.viewer.on("isolate",this.syncExtents),this.viewer.on("show",this.syncExtents),this.viewer.on("showall",this.syncExtents)}dispose(){this.viewer.removeEventListener("databasechunk",this.syncExtents),this.viewer.removeEventListener("clear",this.syncExtents),this.viewer.off("explode",this.syncExtents),this.viewer.off("hide",this.syncExtents),this.viewer.off("isolate",this.syncExtents),this.viewer.off("show",this.syncExtents),this.viewer.off("showall",this.syncExtents)}}class jm{constructor(t){this.geometryEnd=()=>{if(this.ambientLight.removeFromParent(),this.directionalLight.removeFromParent(),this.frontLight.removeFromParent(),this.hemisphereLight.removeFromParent(),this.viewer.extents.isEmpty())return;const t=this.viewer.extents.getCenter(new Ci),e=this.viewer.extents.getBoundingSphere(new Ki).radius;this.directionalLight.position.set(.5,0,.866).multiplyScalar(2*e).add(t),this.directionalLight.target.position.copy(t),this.frontLight.position.set(0,2*e,0).add(t),this.frontLight.target.position.copy(t),this.hemisphereLight.position.set(0,3*e,0).add(t),this.viewer.scene.add(this.ambientLight),this.viewer.scene.add(this.directionalLight),this.viewer.scene.add(this.frontLight),this.viewer.scene.add(this.hemisphereLight)},this.viewer=t,this.ambientLight=new _l(16777215,1),this.viewer.scene.add(this.ambientLight),this.directionalLight=new vl(16777215,1),this.directionalLight.position.set(.5,0,.866),this.viewer.scene.add(this.directionalLight),this.frontLight=new vl(16777215,1.25),this.frontLight.position.set(0,1,0),this.viewer.scene.add(this.frontLight),this.hemisphereLight=new nl(16777215,4473924,1.25),this.hemisphereLight.position.set(0,0,1),this.viewer.scene.add(this.hemisphereLight),this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("clear",this.geometryEnd)}dispose(){this.ambientLight.removeFromParent(),this.ambientLight.dispose(),this.directionalLight.removeFromParent(),this.directionalLight.dispose(),this.frontLight.removeFromParent(),this.frontLight.dispose(),this.hemisphereLight.removeFromParent(),this.hemisphereLight.dispose(),this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("clear",this.geometryEnd)}}class Xm{constructor(t){this.animate=(t=0)=>{this.requestId=requestAnimationFrame(this.animate),this.viewer.render(t),this.viewer.emitEvent({type:"animate",time:t})},this.viewer=t,this.animate()}dispose(){cancelAnimationFrame(this.requestId)}}class Ym{constructor(t){this.resizeViewer=t=>{const{width:e,height:i}=t[0].contentRect;if(!e||!i)return;const n=this.viewer.camera,r=e/i;n.isPerspectiveCamera&&(n.aspect=r,n.updateProjectionMatrix()),n.isOrthographicCamera&&(n.left=n.bottom*r,n.right=n.top*r,n.updateProjectionMatrix()),this.viewer.renderer.setSize(e,i,!0),this.viewer.update(!0),this.viewer.emitEvent({type:"resize",width:e,height:i})},this.viewer=t,this.resizeObserver=new ResizeObserver(this.resizeViewer),this.resizeObserver.observe(t.canvas.parentElement)}dispose(){this.resizeObserver.disconnect()}}const qm=new Li,Km=new Ci;class Zm extends Ml{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new pr([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new pr([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,i=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),i.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new sc(e,6,1);return this.setAttribute("instanceStart",new rs(i,3,0)),this.setAttribute("instanceEnd",new rs(i,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new sc(e,6,1);return this.setAttribute("instanceColorStart",new rs(i,3,0)),this.setAttribute("instanceColorEnd",new rs(i,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new uh(t.geometry)),this}fromLineSegments(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Li);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),qm.setFromBufferAttribute(e),this.boundingBox.union(qm))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Ki),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let n=0;for(let r=0,s=t.count;r<s;r++)Km.fromBufferAttribute(t,r),n=Math.max(n,i.distanceToSquared(Km)),Km.fromBufferAttribute(e,r),n=Math.max(n,i.distanceToSquared(Km));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(t){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(t)}}Bc.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new $e(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},zc.line={uniforms:Br.merge([Bc.common,Bc.fog,Bc.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class Jm extends zr{constructor(t){super({type:"LineMaterial",uniforms:Br.clone(zc.line.uniforms),vertexShader:zc.line.vertexShader,fragmentShader:zc.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(t)}get color(){return this.uniforms.diffuse.value}set color(t){this.uniforms.diffuse.value=t}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(t){this.uniforms.linewidth&&(this.uniforms.linewidth.value=t)}get dashed(){return"USE_DASH"in this.defines}set dashed(t){!0===t!==this.dashed&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(t){this.uniforms.dashScale.value=t}get dashSize(){return this.uniforms.dashSize.value}set dashSize(t){this.uniforms.dashSize.value=t}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(t){this.uniforms.dashOffset.value=t}get gapSize(){return this.uniforms.gapSize.value}set gapSize(t){this.uniforms.gapSize.value=t}get opacity(){return this.uniforms.opacity.value}set opacity(t){this.uniforms&&(this.uniforms.opacity.value=t)}get resolution(){return this.uniforms.resolution.value}set resolution(t){this.uniforms.resolution.value.copy(t)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(t){this.defines&&(!0===t!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===t?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const Qm=new Ci,$m=new Ci,tf=new wi;class ef extends Dr{constructor(t=new Zm,e=new Jm({color:16777215*Math.random()})){super(t,e),this.isWireframe=!0,this.type="Wireframe"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,n=new Float32Array(2*e.count);for(let t=0,r=0,s=e.count;t<s;t++,r+=2)Qm.fromBufferAttribute(e,t),$m.fromBufferAttribute(i,t),n[r]=0===r?0:n[r-1],n[r+1]=n[r]+Qm.distanceTo($m);const r=new sc(n,2,1);return t.setAttribute("instanceDistanceStart",new rs(r,1,0)),t.setAttribute("instanceDistanceEnd",new rs(r,1,1)),this}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(tf),this.material.uniforms.resolution.value.set(tf.z,tf.w))}}class nf{static isBreak(t,e){return isNaN(t[e])||isNaN(t[e+1])||isNaN(t[e+2])||t[e]===1/0||t[e]===-1/0||t[e+1]===1/0||t[e+1]===-1/0||t[e+2]===1/0||t[e+2]===-1/0}static fromIndexedLine(t,e){const i=new Zm,n=[];for(let i=0;i<e.length;i+=2){const r=3*e[i],s=3*e[i+1];-1!==e[i]&&-1!==e[i+1]&&n.push(t[r],t[r+1],t[r+2],t[s],t[s+1],t[s+2])}return 0===n.length?null:(i.setPositions(n),i)}static fromNonIndexedLine(t,e){const i=new Zm,n=[];if(e)for(let e=0;e<t.length&&!(e+5>=t.length);e+=6)nf.isBreak(t,e)||nf.isBreak(t,e+3)||n.push(t[e],t[e+1],t[e+2],t[e+3],t[e+4],t[e+5]);else{let e=-1;for(let i=0;i<t.length;i+=3)nf.isBreak(t,i)?e=-1:(-1!==e&&n.push(t[e],t[e+1],t[e+2],t[i],t[i+1],t[i+2]),e=i)}return 0===n.length?null:(i.setPositions(n),i)}}class rf{constructor(t){this.geometryEnd=()=>{const{facesColor:t,facesTransparancy:e,edgesColor:i}=this.viewer.options;this.highlightMaterial=new er({color:new Jn(t.r/255,t.g/255,t.b/255),transparent:!0,opacity:(255-e)/255,depthTest:!1,depthWrite:!1}),this.outlineMaterial=new Jm({color:new Jn(i.r/255,i.g/255,i.b/255),linewidth:1.5,depthTest:!1,depthWrite:!1,resolution:new $e(window.innerWidth,window.innerHeight)}),this.highlightLineMaterial=new ya({color:new Jn(t.r/255,t.g/255,t.b/255),depthTest:!1,depthWrite:!1}),this.highlightLineGlowMaterial=new Jm({color:new Jn(t.r/255,t.g/255,t.b/255),linewidth:5,transparent:!0,opacity:.8,depthTest:!0,depthWrite:!0,resolution:new $e(window.innerWidth,window.innerHeight)})},this.optionsChange=()=>{const{facesColor:t,facesTransparancy:e,edgesColor:i}=this.viewer.options;this.highlightMaterial.color.setRGB(t.r/255,t.g/255,t.b/255),this.highlightMaterial.opacity=(255-e)/255,this.outlineMaterial.color.setRGB(i.r/255,i.g/255,i.b/255),this.highlightLineMaterial.color.setRGB(t.r/255,t.g/255,t.b/255),this.highlightLineGlowMaterial.color.setRGB(t.r/255,t.g/255,t.b/255),this.viewer.update()},this.viewer=t;if(t.canvas.getContext("webgl2")){const e=t.renderer.getSize(new $e);this.renderTarget=new Mi(e.x,e.y,{format:At,stencilBuffer:!1,samples:4,type:pt})}this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("resize",this.viewerResize),this.geometryEnd()}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("resize",this.viewerResize)}highlight(t){Array.isArray(t)||(t=[t]),t.length&&t.forEach((t=>{if(!t.isHighlighted)if(t.isLine||t.isLineSegments){const e=t.geometry.attributes.position.array,i=t.geometry.index?t.geometry.index.array:null,n=i?nf.fromIndexedLine(e,i):nf.fromNonIndexedLine(e,t.isLineSegments),r=new ef(n,this.highlightLineGlowMaterial);r.position.copy(t.position),r.rotation.copy(t.rotation),r.scale.copy(t.scale),t.parent.add(r),t.userData.highlightwireframe=r,t.userData.originalMaterial=t.material,t.material=this.highlightLineMaterial,t.isHighlighted=!0}else if(t.isMesh){const e=new Mo(t.geometry,30),i=(new Zm).fromEdgesGeometry(e),n=new ef(i,this.outlineMaterial);n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),t.parent.add(n),t.userData.highlightwireframe=n,t.userData.originalMaterial=t.material,t.material=this.highlightMaterial,t.isHighlighted=!0}}))}unhighlight(t){Array.isArray(t)||(t=[t]),t.length&&t.forEach((t=>{t.isHighlighted&&(t.isHighlighted=!1,t.material=t.userData.originalMaterial,t.userData.highlightwireframe.removeFromParent(),delete t.userData.originalMaterial,delete t.userData.highlightwireframe)}))}viewerResize(t){var e,i;null===(e=this.renderTarget)||void 0===e||e.setSize(t.width,t.height),null===(i=this.outlineMaterial)||void 0===i||i.resolution.set(t.width,t.height)}}class sf{constructor(t){this.onPointerDown=t=>{t.isPrimary&&0===t.button&&this.getMousePosition(t,this.downPosition)},this.onPointerUp=t=>{if(!t.isPrimary)return;const e=this.getMousePosition(t,new $e);if(0!==e.distanceTo(this.downPosition))return;let i=[];if(this.viewer.models.forEach((t=>{const n=t.getVisibleObjects(),r=this.getPointerIntersects(e,n);i.push(...r.map((e=>({...e,model:t}))))})),i=i.sort(((t,e)=>t.distance-e.distance)),t.shiftKey||this.clearSelection(),i.length>0){const e=i[0].model,n=e.getHandlesByObjects(i[0].object),r=e.getObjectsByHandles(n);t.shiftKey?this.toggleSelection(r,e):this.select(r,e)}this.viewer.update(),this.viewer.emitEvent({type:"select",data:void 0,handles:this.viewer.getSelected()})},this.onDoubleClick=t=>{0===t.button&&this.viewer.executeCommand("zoomToSelected")},this.initHighlighter=()=>{this.highlighter=this.viewer.getComponent("HighlighterComponent")},this.viewer=t,this.raycaster=new oc,this.downPosition=new $e,this.viewer.addEventListener("pointerdown",this.onPointerDown),this.viewer.addEventListener("pointerup",this.onPointerUp),this.viewer.addEventListener("dblclick",this.onDoubleClick),this.viewer.addEventListener("initialize",this.initHighlighter)}dispose(){this.viewer.removeEventListener("pointerdown",this.onPointerDown),this.viewer.removeEventListener("pointerup",this.onPointerUp),this.viewer.removeEventListener("dblclick",this.onDoubleClick),this.viewer.removeEventListener("initialize",this.initHighlighter)}getMousePosition(t,e){return e.set(t.clientX,t.clientY)}getPointerIntersects(t,e){const i=this.viewer.canvas.getBoundingClientRect(),n=(t.x-i.left)/i.width*2-1,r=-(t.y-i.top)/i.height*2+1,s=new $e(n,r);return this.raycaster.setFromCamera(s,this.viewer.camera),this.raycaster.params=this.raycaster.params={Mesh:{},Line:{threshold:.25},Line2:{threshold:.25},LOD:{},Points:{threshold:.1},Sprite:{}},this.raycaster.intersectObjects(e,!1)}select(t,e){e?(Array.isArray(t)||(t=[t]),t.length&&(e.showObjects(t),e.showOriginalObjects(t),this.highlighter.highlight(t),t.forEach((t=>this.viewer.selected.push(t))),t.forEach((t=>t.isSelected=!0)))):this.viewer.models.forEach((e=>this.select(t,e)))}deselect(t,e){e?(Array.isArray(t)||(t=[t]),t.length&&(this.highlighter.unhighlight(t),e.hideOriginalObjects(t),this.viewer.selected=this.viewer.selected.filter((e=>!t.includes(e))),t.forEach((t=>t.isSelected=!1)))):this.viewer.models.forEach((e=>this.select(t,e)))}toggleSelection(t,e){Array.isArray(t)||(t=[t]),t.length&&(t[0].isSelected?this.deselect(t,e):this.select(t,e))}clearSelection(){this.viewer.selected.length&&(this.highlighter.unhighlight(this.viewer.selected),this.viewer.models.forEach((t=>t.hideOriginalObjects(this.viewer.selected))),this.viewer.selected.forEach((t=>t.isSelected=!1)),this.viewer.selected.length=0)}}class af extends In{constructor(t){super(),this.camera=t,this.size=160,this.orthoCamera=new fl(-2,2,2,-2,0,4),this.orthoCamera.position.set(0,0,2);const e=new er({toneMapped:!1,color:"#aa0000"}),i=new er({toneMapped:!1,color:"#00aa00"}),n=new er({toneMapped:!1,color:"#0000aa"}),r=this.getSpriteMaterial(e.color,"X"),s=this.getSpriteMaterial(i.color,"Y"),a=this.getSpriteMaterial(n.color,"Z"),o=new go(.01,.01,1,3);o.translate(0,.5,0);const h=new go(0,.1,.25,12);h.translate(0,.625,0);const l={X:[[new Dr(h,e),[.5,0,0],[0,0,-Math.PI/2]],[new Dr(o,e),[0,0,0],[0,0,-Math.PI/2]],[new ys(r),[1.55,0,0]]],Y:[[new Dr(h,i),[0,.5,0],null],[new Dr(o,i),null,null],[new ys(s),[0,1.55,0]]],Z:[[new Dr(h,n),[0,0,.5],[Math.PI/2,0,0]],[new Dr(o,n),null,[Math.PI/2,0,0]],[new ys(a),[0,0,1.55]]]};Object.keys(l).forEach((t=>{l[t].forEach((e=>{const i=e[0],n=e[1],r=e[2];i.name=t,n&&i.position.set(n[0],n[1],n[2]),r&&i.rotation.set(r[0],r[1],r[2]),i.updateMatrixWorld(),this.add(i)}))}))}dispose(){this.traverse((t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()}))}getSpriteMaterial(t,e){const i=document.createElement("canvas");i.width=64,i.height=64;const n=i.getContext("2d");n.clearRect(0,0,64,64),n.font="24px Arial",n.textAlign="center",n.fillStyle=t.getStyle(),n.fillText(e,32,41);const r=new Ha(i);return r.colorSpace=Me,new ss({map:r,toneMapped:!1})}render(t){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld();const e=t.clippingPlanes,i=t.getViewport(new wi);t.setViewport(this.position.x,this.position.y,this.size,this.size),t.clippingPlanes=[],t.clearDepth(),t.render(this,this.orthoCamera),t.setViewport(i),t.clippingPlanes=e}}class of{constructor(t){this.geometryEnd=()=>{this.wcsHelper.dispose(),this.wcsHelper=new af(this.viewer.camera)},this.viewerRender=()=>{this.viewer.options.showWCS&&this.wcsHelper.render(this.viewer.renderer)},this.wcsHelper=new af(t.camera),this.viewer=t,this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("drawviewpoint",this.geometryEnd),this.viewer.addEventListener("render",this.viewerRender)}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("drawviewpoint",this.geometryEnd),this.viewer.removeEventListener("render",this.viewerRender),this.wcsHelper.dispose()}}const hf=l("threejs");function lf(t,e=!1){const i=null!==t[0].index,n=new Set(Object.keys(t[0].attributes)),r=new Set(Object.keys(t[0].morphAttributes)),s={},a={},o=t[0].morphTargetsRelative,h=new br;let l=0;for(let c=0;c<t.length;++c){const d=t[c];let u=0;if(i!==(null!==d.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const t in d.attributes){if(!n.has(t))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+t+'" attribute exists among all geometries, or in none of them.'),null;void 0===s[t]&&(s[t]=[]),s[t].push(d.attributes[t]),u++}if(u!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const t in d.morphAttributes){if(!r.has(t))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;void 0===a[t]&&(a[t]=[]),a[t].push(d.morphAttributes[t])}if(e){let t;if(i)t=d.index.count;else{if(void 0===d.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;t=d.attributes.position.count}h.addGroup(l,t,c),l+=t}}if(i){let e=0;const i=[];for(let n=0;n<t.length;++n){const r=t[n].index;for(let t=0;t<r.count;++t)i.push(r.getX(t)+e);e+=t[n].attributes.position.count}h.setIndex(i)}for(const t in s){const e=cf(s[t]);if(!e)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+t+" attribute."),null;h.setAttribute(t,e)}for(const t in a){const e=a[t][0].length;if(0===e)break;h.morphAttributes=h.morphAttributes||{},h.morphAttributes[t]=[];for(let i=0;i<e;++i){const e=[];for(let n=0;n<a[t].length;++n)e.push(a[t][n][i]);const n=cf(e);if(!n)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+t+" morphAttribute."),null;h.morphAttributes[t].push(n)}}return h}function cf(t){let e,i,n,r=-1,s=0;for(let a=0;a<t.length;++a){const o=t[a];if(void 0===e&&(e=o.array.constructor),e!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===i&&(i=o.itemSize),i!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===n&&(n=o.normalized),n!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===r&&(r=o.gpuType),r!==o.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=o.count*i}const a=new e(s),o=new cr(a,i,n);let h=0;for(let e=0;e<t.length;++e){const n=t[e];if(n.isInterleavedBufferAttribute){const t=h/i;for(let e=0,r=n.count;e<r;e++)for(let r=0;r<i;r++){const i=n.getComponent(e,r);o.setComponent(e+t,r,i)}}else a.set(n.array,h);h+=n.count*i}return void 0!==r&&(o.gpuType=r),o}function df(t,e){if(0===e)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(2===e||1===e){let i=t.getIndex();if(null===i){const e=[],n=t.getAttribute("position");if(void 0===n)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<n.count;t++)e.push(t);t.setIndex(e),i=t.getIndex()}const n=i.count-2,r=[];if(2===e)for(let t=1;t<=n;t++)r.push(i.getX(0)),r.push(i.getX(t)),r.push(i.getX(t+1));else for(let t=0;t<n;t++)t%2==0?(r.push(i.getX(t)),r.push(i.getX(t+1)),r.push(i.getX(t+2))):(r.push(i.getX(t+2)),r.push(i.getX(t+1)),r.push(i.getX(t)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=t.clone();return s.setIndex(r),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),t}hf.registerComponent("ExtentsComponent",(t=>new Wm(t))),hf.registerComponent("CameraComponent",(t=>new Vm(t))),hf.registerComponent("BackgroundComponent",(t=>new Hm(t))),hf.registerComponent("LightComponent",(t=>new jm(t))),hf.registerComponent("ResizeCanvasComponent",(t=>new Ym(t))),hf.registerComponent("RenderLoopComponent",(t=>new Xm(t))),hf.registerComponent("HighlighterComponent",(t=>new rf(t))),hf.registerComponent("SelectionComponent",(t=>new sf(t))),hf.registerComponent("WCSHelperComponent",(t=>new of(t)));class uf extends Zh{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(t){return new _f(t)})),this.register((function(t){return new yf(t)})),this.register((function(t){return new Cf(t)})),this.register((function(t){return new Rf(t)})),this.register((function(t){return new Pf(t)})),this.register((function(t){return new bf(t)})),this.register((function(t){return new wf(t)})),this.register((function(t){return new Sf(t)})),this.register((function(t){return new Mf(t)})),this.register((function(t){return new vf(t)})),this.register((function(t){return new Tf(t)})),this.register((function(t){return new xf(t)})),this.register((function(t){return new Af(t)})),this.register((function(t){return new Ef(t)})),this.register((function(t){return new ff(t)})),this.register((function(t){return new Lf(t)})),this.register((function(t){return new If(t)}))}load(t,e,i,n){const r=this;let s;if(""!==this.resourcePath)s=this.resourcePath;else if(""!==this.path){const e=Sl.extractUrlBase(t);s=Sl.resolveURL(e,this.path)}else s=Sl.extractUrlBase(t);this.manager.itemStart(t);const a=function(e){n?n(e):console.error(e),r.manager.itemError(t),r.manager.itemEnd(t)},o=new $h(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(i){try{r.parse(i,s,(function(i){e(i),r.manager.itemEnd(t)}),a)}catch(t){a(t)}}),i,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,i,n){let r;const s={},a={},o=new TextDecoder;if("string"==typeof t)r=JSON.parse(t);else if(t instanceof ArrayBuffer){if(o.decode(new Uint8Array(t,0,4))===Df){try{s[mf.KHR_BINARY_GLTF]=new Uf(t)}catch(t){return void(n&&n(t))}r=JSON.parse(s[mf.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(t))}else r=t;if(void 0===r.asset||r.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const h=new og(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](h);e.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[e.name]=e,s[e.name]=!0}if(r.extensionsUsed)for(let t=0;t<r.extensionsUsed.length;++t){const e=r.extensionsUsed[t],i=r.extensionsRequired||[];switch(e){case mf.KHR_MATERIALS_UNLIT:s[e]=new gf;break;case mf.KHR_DRACO_MESH_COMPRESSION:s[e]=new Ff(r,this.dracoLoader);break;case mf.KHR_TEXTURE_TRANSFORM:s[e]=new kf;break;case mf.KHR_MESH_QUANTIZATION:s[e]=new Bf;break;default:i.indexOf(e)>=0&&void 0===a[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}h.setExtensions(s),h.setPlugins(a),h.parse(i,n)}parseAsync(t,e){const i=this;return new Promise((function(n,r){i.parse(t,e,n,r)}))}}function pf(){let t={};return{get:function(e){return t[e]},add:function(e,i){t[e]=i},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const mf={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ff{constructor(t){this.parser=t,this.name=mf.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let i=0,n=e.length;i<n;i++){const n=e[i];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&t._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(t){const e=this.parser,i="light:"+t;let n=e.cache.get(i);if(n)return n;const r=e.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let a;const o=new Jn(16777215);void 0!==s.color&&o.setRGB(s.color[0],s.color[1],s.color[2],Te);const h=void 0!==s.range?s.range:0;switch(s.type){case"directional":a=new vl(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new ml(o),a.distance=h;break;case"spot":a=new ll(o),a.distance=h,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,a.angle=s.spot.outerConeAngle,a.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return a.position.set(0,0,0),eg(a,s),void 0!==s.intensity&&(a.intensity=s.intensity),a.name=e.createUniqueName(s.name||"light_"+t),n=Promise.resolve(a),e.cache.add(i,n),n}getDependency(t,e){if("light"===t)return this._loadLight(e)}createNodeAttachment(t){const e=this,i=this.parser,n=i.json.nodes[t],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(t){return i._getNodeRef(e.cache,r,t)}))}}class gf{constructor(){this.name=mf.KHR_MATERIALS_UNLIT}getMaterialType(){return er}extendParams(t,e,i){const n=[];t.color=new Jn(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const e=r.baseColorFactor;t.color.setRGB(e[0],e[1],e[2],Te),t.opacity=e[3]}void 0!==r.baseColorTexture&&n.push(i.assignTexture(t,"map",r.baseColorTexture,Me))}return Promise.all(n)}}class vf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name].emissiveStrength;return void 0!==n&&(e.emissiveIntensity=n),Promise.resolve()}}class _f{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];if(void 0!==s.clearcoatFactor&&(e.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&r.push(i.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&r.push(i.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(r.push(i.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const t=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new $e(t,t)}return Promise.all(r)}}class yf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_DISPERSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name];return e.dispersion=void 0!==n.dispersion?n.dispersion:0,Promise.resolve()}}class xf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return void 0!==s.iridescenceFactor&&(e.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&r.push(i.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(e.iridescenceIOR=s.iridescenceIor),void 0===e.iridescenceThicknessRange&&(e.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&r.push(i.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class bf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_SHEEN}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new Jn(0,0,0),e.sheenRoughness=0,e.sheen=1;const s=n.extensions[this.name];if(void 0!==s.sheenColorFactor){const t=s.sheenColorFactor;e.sheenColor.setRGB(t[0],t[1],t[2],Te)}return void 0!==s.sheenRoughnessFactor&&(e.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&r.push(i.assignTexture(e,"sheenColorMap",s.sheenColorTexture,Me)),void 0!==s.sheenRoughnessTexture&&r.push(i.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class wf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return void 0!==s.transmissionFactor&&(e.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(i.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class Sf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_VOLUME}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];e.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&r.push(i.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return e.attenuationColor=(new Jn).setRGB(a[0],a[1],a[2],Te),Promise.all(r)}}class Mf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_IOR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name];return e.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class Tf{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_SPECULAR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];e.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&r.push(i.assignTexture(e,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return e.specularColor=(new Jn).setRGB(a[0],a[1],a[2],Te),void 0!==s.specularColorTexture&&r.push(i.assignTexture(e,"specularColorMap",s.specularColorTexture,Me)),Promise.all(r)}}class Ef{constructor(t){this.parser=t,this.name=mf.EXT_MATERIALS_BUMP}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return e.bumpScale=void 0!==s.bumpFactor?s.bumpFactor:1,void 0!==s.bumpTexture&&r.push(i.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(r)}}class Af{constructor(t){this.parser=t,this.name=mf.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?_h:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return void 0!==s.anisotropyStrength&&(e.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(e.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&r.push(i.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class Cf{constructor(t){this.parser=t,this.name=mf.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,i=e.json,n=i.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],s=e.options.ktx2Loader;if(!s){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class Rf{constructor(t){this.parser=t,this.name=mf.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let o=i.textureLoader;if(a.uri){const t=i.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(t,s.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class Pf{constructor(t){this.parser=t,this.name=mf.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let o=i.textureLoader;if(a.uri){const t=i.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(t,s.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class Lf{constructor(t){this.name=mf.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,i=e.bufferViews[t];if(i.extensions&&i.extensions[this.name]){const t=i.extensions[this.name],n=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then((function(e){const i=t.byteOffset||0,n=t.byteLength||0,s=t.count,a=t.byteStride,o=new Uint8Array(e,i,n);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,t.mode,t.filter).then((function(t){return t.buffer})):r.ready.then((function(){const e=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(e),s,a,o,t.mode,t.filter),e}))}))}return null}}class If{constructor(t){this.name=mf.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,i=e.nodes[t];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;const n=e.meshes[i.mesh];for(const t of n.primitives)if(t.mode!==Vf.TRIANGLES&&t.mode!==Vf.TRIANGLE_STRIP&&t.mode!==Vf.TRIANGLE_FAN&&void 0!==t.mode)return null;const r=i.extensions[this.name].attributes,s=[],a={};for(const t in r)s.push(this.parser.getDependency("accessor",r[t]).then((e=>(a[t]=e,a[t]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(t)),Promise.all(s).then((t=>{const e=t.pop(),i=e.isGroup?e.children:[e],n=t[0].count,r=[];for(const t of i){const e=new sn,i=new Ci,s=new Ai,o=new Ci(1,1,1),h=new Ys(t.geometry,t.material,n);for(let t=0;t<n;t++)a.TRANSLATION&&i.fromBufferAttribute(a.TRANSLATION,t),a.ROTATION&&s.fromBufferAttribute(a.ROTATION,t),a.SCALE&&o.fromBufferAttribute(a.SCALE,t),h.setMatrixAt(t,e.compose(i,s,o));for(const e in a)if("_COLOR_0"===e){const t=a[e];h.instanceColor=new Bs(t.array,t.itemSize,t.normalized)}else"TRANSLATION"!==e&&"ROTATION"!==e&&"SCALE"!==e&&t.geometry.setAttribute(e,a[e]);In.prototype.copy.call(h,t),this.parser.assignFinalMaterial(h),r.push(h)}return e.isGroup?(e.clear(),e.add(...r),e):r[0]})))}}const Df="glTF",Of=1313821514,Nf=5130562;class Uf{constructor(t){this.name=mf.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Df)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(t,12);let s=0;for(;s<n;){const e=r.getUint32(s,!0);s+=4;const n=r.getUint32(s,!0);if(s+=4,n===Of){const n=new Uint8Array(t,12+s,e);this.content=i.decode(n)}else if(n===Nf){const i=12+s;this.body=t.slice(i,i+e)}s+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Ff{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=mf.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const i=this.json,n=this.dracoLoader,r=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,a={},o={},h={};for(const t in s){const e=qf[t]||t.toLowerCase();a[e]=s[t]}for(const e in t.attributes){const n=qf[e]||e.toLowerCase();if(void 0!==s[e]){const r=i.accessors[t.attributes[e]],s=Wf[r.componentType];h[n]=s.name,o[n]=!0===r.normalized}}return e.getDependency("bufferView",r).then((function(t){return new Promise((function(e,i){n.decodeDracoFile(t,(function(t){for(const e in t.attributes){const i=t.attributes[e],n=o[e];void 0!==n&&(i.normalized=n)}e(t)}),a,h,Te,i)}))}))}}class kf{constructor(){this.name=mf.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return void 0!==e.texCoord&&e.texCoord!==t.channel||void 0!==e.offset||void 0!==e.rotation||void 0!==e.scale?(t=t.clone(),void 0!==e.texCoord&&(t.channel=e.texCoord),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0,t):t}}class Bf{constructor(){this.name=mf.KHR_MESH_QUANTIZATION}}class zf extends Dh{constructor(t,e,i,n){super(t,e,i,n)}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=t*n*3+n;for(let t=0;t!==n;t++)e[t]=i[r+t];return e}interpolate_(t,e,i,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=2*a,h=3*a,l=n-e,c=(i-e)/l,d=c*c,u=d*c,p=t*h,m=p-h,f=-2*u+3*d,g=u-d,v=1-f,_=g-d+c;for(let t=0;t!==a;t++){const e=s[m+t+a],i=s[m+t+o]*l,n=s[p+t+a],h=s[p+t]*l;r[t]=v*e+_*i+f*n+g*h}return r}}const Gf=new Ai;class Hf extends zf{interpolate_(t,e,i,n){const r=super.interpolate_(t,e,i,n);return Gf.fromArray(r).normalize().toArray(r),r}}const Vf={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Wf={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},jf={9728:ot,9729:ct,9984:ht,9985:dt,9986:lt,9987:ut},Xf={33071:st,33648:at,10497:rt},Yf={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qf={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Kf={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Zf={CUBICSPLINE:void 0,LINEAR:ge,STEP:fe},Jf="OPAQUE",Qf="MASK",$f="BLEND";function tg(t,e,i){for(const n in i.extensions)void 0===t[n]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=i.extensions[n])}function eg(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ig(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let i=0,n=e.weights.length;i<n;i++)t.morphTargetInfluences[i]=e.weights[i];if(e.extras&&Array.isArray(e.extras.targetNames)){const i=e.extras.targetNames;if(t.morphTargetInfluences.length===i.length){t.morphTargetDictionary={};for(let e=0,n=i.length;e<n;e++)t.morphTargetDictionary[i[e]]=e}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ng(t){let e;const i=t.extensions&&t.extensions[mf.KHR_DRACO_MESH_COMPRESSION];if(e=i?"draco:"+i.bufferView+":"+i.indices+":"+rg(i.attributes):t.indices+":"+rg(t.attributes)+":"+t.mode,void 0!==t.targets)for(let i=0,n=t.targets.length;i<n;i++)e+=":"+rg(t.targets[i]);return e}function rg(t){let e="";const i=Object.keys(t).sort();for(let n=0,r=i.length;n<r;n++)e+=i[n]+":"+t[i[n]]+";";return e}function sg(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const ag=new sn;class og{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new pf,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,n=-1,r=!1,s=-1;if("undefined"!=typeof navigator){const t=navigator.userAgent;i=!0===/^((?!chrome|android).)*safari/i.test(t);const e=t.match(/Version\/(\d+)/);n=i&&e?parseInt(e[1],10):-1,r=t.indexOf("Firefox")>-1,s=r?t.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||i&&n<17||r&&s<98?this.textureLoader=new el(this.options.manager):this.textureLoader=new Rl(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new $h(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])})).then((function(e){const s={scene:e[0][n.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:n.asset,parser:i,userData:{}};return tg(r,s,n),eg(s,n),Promise.all(i._invokeAll((function(t){return t.afterRoot&&t.afterRoot(s)}))).then((function(){for(const t of s.scenes)t.updateMatrixWorld();t(s)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],i=this.json.meshes||[];for(let i=0,n=e.length;i<n;i++){const n=e[i].joints;for(let e=0,i=n.length;e<i;e++)t[n[e]].isBone=!0}for(let e=0,n=t.length;e<n;e++){const n=t[e];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(i[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,i){if(t.refs[e]<=1)return i;const n=i.clone(),r=(t,e)=>{const i=this.associations.get(t);null!=i&&this.associations.set(e,i);for(const[i,n]of t.children.entries())r(n,e.children[i])};return r(i,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let i=0;i<e.length;i++){const n=t(e[i]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const i=[];for(let n=0;n<e.length;n++){const r=t(e[n]);r&&i.push(r)}return i}getDependency(t,e){const i=t+":"+e;let n=this.cache.get(i);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne((function(t){return t.loadNode&&t.loadNode(e)}));break;case"mesh":n=this._invokeOne((function(t){return t.loadMesh&&t.loadMesh(e)}));break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne((function(t){return t.loadBufferView&&t.loadBufferView(e)}));break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne((function(t){return t.loadMaterial&&t.loadMaterial(e)}));break;case"texture":n=this._invokeOne((function(t){return t.loadTexture&&t.loadTexture(e)}));break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne((function(t){return t.loadAnimation&&t.loadAnimation(e)}));break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne((function(i){return i!=this&&i.getDependency&&i.getDependency(t,e)})),!n)throw new Error("Unknown type: "+t)}this.cache.add(i,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const i=this,n=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(n.map((function(e,n){return i.getDependency(t,n)}))),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],i=this.fileLoader;if(e.type&&"arraybuffer"!==e.type)throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(void 0===e.uri&&0===t)return Promise.resolve(this.extensions[mf.KHR_BINARY_GLTF].body);const n=this.options;return new Promise((function(t,r){i.load(Sl.resolveURL(e.uri,n.path),t,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))}))}))}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then((function(t){const i=e.byteLength||0,n=e.byteOffset||0;return t.slice(n,n+i)}))}loadAccessor(t){const e=this,i=this.json,n=this.json.accessors[t];if(void 0===n.bufferView&&void 0===n.sparse){const t=Yf[n.type],e=Wf[n.componentType],i=!0===n.normalized,r=new e(n.count*t);return Promise.resolve(new cr(r,t,i))}const r=[];return void 0!==n.bufferView?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),void 0!==n.sparse&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then((function(t){const r=t[0],s=Yf[n.type],a=Wf[n.componentType],o=a.BYTES_PER_ELEMENT,h=o*s,l=n.byteOffset||0,c=void 0!==n.bufferView?i.bufferViews[n.bufferView].byteStride:void 0,d=!0===n.normalized;let u,p;if(c&&c!==h){const t=Math.floor(l/c),i="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+t+":"+n.count;let h=e.cache.get(i);h||(u=new a(r,t*c,n.count*c/o),h=new is(u,c/o),e.cache.add(i,h)),p=new rs(h,s,l%c/o,d)}else u=null===r?new a(n.count*s):new a(r,l,n.count*s),p=new cr(u,s,d);if(void 0!==n.sparse){const e=Yf.SCALAR,i=Wf[n.sparse.indices.componentType],o=n.sparse.indices.byteOffset||0,h=n.sparse.values.byteOffset||0,l=new i(t[1],o,n.sparse.count*e),c=new a(t[2],h,n.sparse.count*s);null!==r&&(p=new cr(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let t=0,e=l.length;t<e;t++){const e=l[t];if(p.setX(e,c[t*s]),s>=2&&p.setY(e,c[t*s+1]),s>=3&&p.setZ(e,c[t*s+2]),s>=4&&p.setW(e,c[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=d}return p}))}loadTexture(t){const e=this.json,i=this.options,n=e.textures[t].source,r=e.images[n];let s=this.textureLoader;if(r.uri){const t=i.manager.getHandler(r.uri);null!==t&&(s=t)}return this.loadTextureImage(t,n,s)}loadTextureImage(t,e,i){const n=this,r=this.json,s=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const h=this.loadImageSource(e,i).then((function(e){e.flipY=!1,e.name=s.name||a.name||"",""===e.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(e.name=a.uri);const i=(r.samplers||{})[s.sampler]||{};return e.magFilter=jf[i.magFilter]||ct,e.minFilter=jf[i.minFilter]||ut,e.wrapS=Xf[i.wrapS]||rt,e.wrapT=Xf[i.wrapT]||rt,e.generateMipmaps=!e.isCompressedTexture&&e.minFilter!==ot&&e.minFilter!==ct,n.associations.set(e,{textures:t}),e})).catch((function(){return null}));return this.textureCache[o]=h,h}loadImageSource(t,e){const i=this,n=this.json,r=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((t=>t.clone()));const s=n.images[t],a=self.URL||self.webkitURL;let o=s.uri||"",h=!1;if(void 0!==s.bufferView)o=i.getDependency("bufferView",s.bufferView).then((function(t){h=!0;const e=new Blob([t],{type:s.mimeType});return o=a.createObjectURL(e),o}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const l=Promise.resolve(o).then((function(t){return new Promise((function(i,n){let s=i;!0===e.isImageBitmapLoader&&(s=function(t){const e=new bi(t);e.needsUpdate=!0,i(e)}),e.load(Sl.resolveURL(t,r.path),s,void 0,n)}))})).then((function(t){var e;return!0===h&&a.revokeObjectURL(o),eg(t,s),t.userData.mimeType=s.mimeType||((e=s.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":e.search(/\.ktx2($|\?)/i)>0||0===e.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),t})).catch((function(t){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),t}));return this.sourceCache[t]=l,l}assignTexture(t,e,i,n){const r=this;return this.getDependency("texture",i.index).then((function(s){if(!s)return null;if(void 0!==i.texCoord&&i.texCoord>0&&((s=s.clone()).channel=i.texCoord),r.extensions[mf.KHR_TEXTURE_TRANSFORM]){const t=void 0!==i.extensions?i.extensions[mf.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(s);s=r.extensions[mf.KHR_TEXTURE_TRANSFORM].extendTexture(s,t),r.associations.set(s,e)}}return void 0!==n&&(s.colorSpace=n),t[e]=s,s}))}assignFinalMaterial(t){const e=t.geometry;let i=t.material;const n=void 0===e.attributes.tangent,r=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+i.uuid;let e=this.cache.get(t);e||(e=new Da,tr.prototype.copy.call(e,i),e.color.copy(i.color),e.map=i.map,e.sizeAttenuation=!1,this.cache.add(t,e)),i=e}else if(t.isLine){const t="LineBasicMaterial:"+i.uuid;let e=this.cache.get(t);e||(e=new ya,tr.prototype.copy.call(e,i),e.color.copy(i.color),e.map=i.map,this.cache.add(t,e)),i=e}if(n||r||s){let t="ClonedMaterial:"+i.uuid+":";n&&(t+="derivative-tangents:"),r&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=i.clone(),r&&(e.vertexColors=!0),s&&(e.flatShading=!0),n&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(i))),i=e}t.material=i}getMaterialType(){return vh}loadMaterial(t){const e=this,i=this.json,n=this.extensions,r=i.materials[t];let s;const a={},o=[];if((r.extensions||{})[mf.KHR_MATERIALS_UNLIT]){const t=n[mf.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),o.push(t.extendParams(a,r,e))}else{const i=r.pbrMetallicRoughness||{};if(a.color=new Jn(1,1,1),a.opacity=1,Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;a.color.setRGB(t[0],t[1],t[2],Te),a.opacity=t[3]}void 0!==i.baseColorTexture&&o.push(e.assignTexture(a,"map",i.baseColorTexture,Me)),a.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,a.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(o.push(e.assignTexture(a,"metalnessMap",i.metallicRoughnessTexture)),o.push(e.assignTexture(a,"roughnessMap",i.metallicRoughnessTexture))),s=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),o.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)}))))}!0===r.doubleSided&&(a.side=2);const h=r.alphaMode||Jf;if(h===$f?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Qf&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==er&&(o.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new $e(1,1),void 0!==r.normalTexture.scale)){const t=r.normalTexture.scale;a.normalScale.set(t,t)}if(void 0!==r.occlusionTexture&&s!==er&&(o.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==er){const t=r.emissiveFactor;a.emissive=(new Jn).setRGB(t[0],t[1],t[2],Te)}return void 0!==r.emissiveTexture&&s!==er&&o.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,Me)),Promise.all(o).then((function(){const i=new s(a);return r.name&&(i.name=r.name),eg(i,r),e.associations.set(i,{materials:t}),r.extensions&&tg(n,i,r),i}))}createUniqueName(t){const e=tc.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,i=this.extensions,n=this.primitiveCache;function r(t){return i[mf.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(i){return hg(i,t,e)}))}const s=[];for(let i=0,a=t.length;i<a;i++){const a=t[i],o=ng(a),h=n[o];if(h)s.push(h.promise);else{let t;t=a.extensions&&a.extensions[mf.KHR_DRACO_MESH_COMPRESSION]?r(a):hg(new br,a,e),n[o]={primitive:a,promise:t},s.push(t)}}return Promise.all(s)}loadMesh(t){const e=this,i=this.json,n=this.extensions,r=i.meshes[t],s=r.primitives,a=[];for(let t=0,e=s.length;t<e;t++){const e=void 0===s[t].material?(void 0===(o=this.cache).DefaultMaterial&&(o.DefaultMaterial=new vh({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),o.DefaultMaterial):this.getDependency("material",s[t].material);a.push(e)}var o;return a.push(e.loadGeometries(s)),Promise.all(a).then((function(i){const a=i.slice(0,i.length-1),o=i[i.length-1],h=[];for(let i=0,l=o.length;i<l;i++){const l=o[i],c=s[i];let d;const u=a[i];if(c.mode===Vf.TRIANGLES||c.mode===Vf.TRIANGLE_STRIP||c.mode===Vf.TRIANGLE_FAN||void 0===c.mode)d=!0===r.isSkinnedMesh?new Ds(l,u):new Dr(l,u),!0===d.isSkinnedMesh&&d.normalizeSkinWeights(),c.mode===Vf.TRIANGLE_STRIP?d.geometry=df(d.geometry,1):c.mode===Vf.TRIANGLE_FAN&&(d.geometry=df(d.geometry,2));else if(c.mode===Vf.LINES)d=new La(l,u);else if(c.mode===Vf.LINE_STRIP)d=new Aa(l,u);else if(c.mode===Vf.LINE_LOOP)d=new Ia(l,u);else{if(c.mode!==Vf.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+c.mode);d=new ka(l,u)}Object.keys(d.geometry.morphAttributes).length>0&&ig(d,r),d.name=e.createUniqueName(r.name||"mesh_"+t),eg(d,r),c.extensions&&tg(n,d,c),e.assignFinalMaterial(d),h.push(d)}for(let i=0,n=h.length;i<n;i++)e.associations.set(h[i],{meshes:t,primitives:i});if(1===h.length)return r.extensions&&tg(n,h[0],r),h[0];const l=new Zr;r.extensions&&tg(n,l,r),e.associations.set(l,{meshes:t});for(let t=0,e=h.length;t<e;t++)l.add(h[t]);return l}))}loadCamera(t){let e;const i=this.json.cameras[t],n=i[i.type];if(n)return"perspective"===i.type?e=new jr(Qe.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===i.type&&(e=new fl(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(e.name=this.createUniqueName(i.name)),eg(e,i),Promise.resolve(e);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const e=this.json.skins[t],i=[];for(let t=0,n=e.joints.length;t<n;t++)i.push(this._loadNodeShallow(e.joints[t]));return void 0!==e.inverseBindMatrices?i.push(this.getDependency("accessor",e.inverseBindMatrices)):i.push(null),Promise.all(i).then((function(t){const i=t.pop(),n=t,r=[],s=[];for(let t=0,a=n.length;t<a;t++){const a=n[t];if(a){r.push(a);const e=new sn;null!==i&&e.fromArray(i.array,16*t),s.push(e)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[t])}return new ks(r,s)}))}loadAnimation(t){const e=this.json,i=this,n=e.animations[t],r=n.name?n.name:"animation_"+t,s=[],a=[],o=[],h=[],l=[];for(let t=0,e=n.channels.length;t<e;t++){const e=n.channels[t],i=n.samplers[e.sampler],r=e.target,c=r.node,d=void 0!==n.parameters?n.parameters[i.input]:i.input,u=void 0!==n.parameters?n.parameters[i.output]:i.output;void 0!==r.node&&(s.push(this.getDependency("node",c)),a.push(this.getDependency("accessor",d)),o.push(this.getDependency("accessor",u)),h.push(i),l.push(r))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(h),Promise.all(l)]).then((function(t){const e=t[0],n=t[1],s=t[2],a=t[3],o=t[4],h=[];for(let t=0,r=e.length;t<r;t++){const r=e[t],l=n[t],c=s[t],d=a[t],u=o[t];if(void 0===r)continue;r.updateMatrix&&r.updateMatrix();const p=i._createAnimationTracks(r,l,c,d,u);if(p)for(let t=0;t<p.length;t++)h.push(p[t])}return new jh(r,void 0,h)}))}createNodeMesh(t){const e=this.json,i=this,n=e.nodes[t];return void 0===n.mesh?null:i.getDependency("mesh",n.mesh).then((function(t){const e=i._getNodeRef(i.meshCache,n.mesh,t);return void 0!==n.weights&&e.traverse((function(t){if(t.isMesh)for(let e=0,i=n.weights.length;e<i;e++)t.morphTargetInfluences[e]=n.weights[e]})),e}))}loadNode(t){const e=this,i=this.json.nodes[t],n=e._loadNodeShallow(t),r=[],s=i.children||[];for(let t=0,i=s.length;t<i;t++)r.push(e.getDependency("node",s[t]));const a=void 0===i.skin?Promise.resolve(null):e.getDependency("skin",i.skin);return Promise.all([n,Promise.all(r),a]).then((function(t){const e=t[0],i=t[1],n=t[2];null!==n&&e.traverse((function(t){t.isSkinnedMesh&&t.bind(n,ag)}));for(let t=0,n=i.length;t<n;t++)e.add(i[t]);return e}))}_loadNodeShallow(t){const e=this.json,i=this.extensions,n=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const r=e.nodes[t],s=r.name?n.createUniqueName(r.name):"",a=[],o=n._invokeOne((function(e){return e.createNodeMesh&&e.createNodeMesh(t)}));return o&&a.push(o),void 0!==r.camera&&a.push(n.getDependency("camera",r.camera).then((function(t){return n._getNodeRef(n.cameraCache,r.camera,t)}))),n._invokeAll((function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)})).forEach((function(t){a.push(t)})),this.nodeCache[t]=Promise.all(a).then((function(e){let a;if(a=!0===r.isBone?new Os:e.length>1?new Zr:1===e.length?e[0]:new In,a!==e[0])for(let t=0,i=e.length;t<i;t++)a.add(e[t]);if(r.name&&(a.userData.name=r.name,a.name=s),eg(a,r),r.extensions&&tg(i,a,r),void 0!==r.matrix){const t=new sn;t.fromArray(r.matrix),a.applyMatrix4(t)}else void 0!==r.translation&&a.position.fromArray(r.translation),void 0!==r.rotation&&a.quaternion.fromArray(r.rotation),void 0!==r.scale&&a.scale.fromArray(r.scale);return n.associations.has(a)||n.associations.set(a,{}),n.associations.get(a).nodes=t,a})),this.nodeCache[t]}loadScene(t){const e=this.extensions,i=this.json.scenes[t],n=this,r=new Zr;i.name&&(r.name=n.createUniqueName(i.name)),eg(r,i),i.extensions&&tg(e,r,i);const s=i.nodes||[],a=[];for(let t=0,e=s.length;t<e;t++)a.push(n.getDependency("node",s[t]));return Promise.all(a).then((function(t){for(let e=0,i=t.length;e<i;e++)r.add(t[e]);return n.associations=(t=>{const e=new Map;for(const[t,i]of n.associations)(t instanceof tr||t instanceof bi)&&e.set(t,i);return t.traverse((t=>{const i=n.associations.get(t);null!=i&&e.set(t,i)})),e})(r),r}))}_createAnimationTracks(t,e,i,n,r){const s=[],a=t.name?t.name:t.uuid,o=[];let h;switch(Kf[r.path]===Kf.weights?t.traverse((function(t){t.morphTargetInfluences&&o.push(t.name?t.name:t.uuid)})):o.push(a),Kf[r.path]){case Kf.weights:h=zh;break;case Kf.rotation:h=Hh;break;case Kf.position:case Kf.scale:h=Wh;break;default:if(1===i.itemSize)h=zh;else h=Wh}const l=void 0!==n.interpolation?Zf[n.interpolation]:ge,c=this._getArrayFromAccessor(i);for(let t=0,i=o.length;t<i;t++){const i=new h(o[t]+"."+Kf[r.path],e.array,c,l);"CUBICSPLINE"===n.interpolation&&this._createCubicSplineTrackInterpolant(i),s.push(i)}return s}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const t=sg(e.constructor),i=new Float32Array(e.length);for(let n=0,r=e.length;n<r;n++)i[n]=e[n]*t;e=i}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(t){return new(this instanceof Hh?Hf:zf)(this.times,this.values,this.getValueSize()/3,t)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function hg(t,e,i){const n=e.attributes,r=[];function s(e,n){return i.getDependency("accessor",e).then((function(e){t.setAttribute(n,e)}))}for(const e in n){const i=qf[e]||e.toLowerCase();i in t.attributes||r.push(s(n[e],i))}if(void 0!==e.indices&&!t.index){const n=i.getDependency("accessor",e.indices).then((function(e){t.setIndex(e)}));r.push(n)}return ui.workingColorSpace!==Te&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ui.workingColorSpace}" not supported.`),eg(t,e),function(t,e,i){const n=e.attributes,r=new Li;if(void 0===n.POSITION)return;{const t=i.json.accessors[n.POSITION],e=t.min,s=t.max;if(void 0===e||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new Ci(e[0],e[1],e[2]),new Ci(s[0],s[1],s[2])),t.normalized){const e=sg(Wf[t.componentType]);r.min.multiplyScalar(e),r.max.multiplyScalar(e)}}const s=e.targets;if(void 0!==s){const t=new Ci,e=new Ci;for(let n=0,r=s.length;n<r;n++){const r=s[n];if(void 0!==r.POSITION){const n=i.json.accessors[r.POSITION],s=n.min,a=n.max;if(void 0!==s&&void 0!==a){if(e.setX(Math.max(Math.abs(s[0]),Math.abs(a[0]))),e.setY(Math.max(Math.abs(s[1]),Math.abs(a[1]))),e.setZ(Math.max(Math.abs(s[2]),Math.abs(a[2]))),n.normalized){const t=sg(Wf[n.componentType]);e.multiplyScalar(t)}t.max(e)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(t)}t.boundingBox=r;const a=new Ki;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,t.boundingSphere=a}(t,e,i),Promise.all(r).then((function(){return void 0!==e.targets?function(t,e,i){let n=!1,r=!1,s=!1;for(let t=0,i=e.length;t<i;t++){const i=e[t];if(void 0!==i.POSITION&&(n=!0),void 0!==i.NORMAL&&(r=!0),void 0!==i.COLOR_0&&(s=!0),n&&r&&s)break}if(!n&&!r&&!s)return Promise.resolve(t);const a=[],o=[],h=[];for(let l=0,c=e.length;l<c;l++){const c=e[l];if(n){const e=void 0!==c.POSITION?i.getDependency("accessor",c.POSITION):t.attributes.position;a.push(e)}if(r){const e=void 0!==c.NORMAL?i.getDependency("accessor",c.NORMAL):t.attributes.normal;o.push(e)}if(s){const e=void 0!==c.COLOR_0?i.getDependency("accessor",c.COLOR_0):t.attributes.color;h.push(e)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(h)]).then((function(e){const i=e[0],a=e[1],o=e[2];return n&&(t.morphAttributes.position=i),r&&(t.morphAttributes.normal=a),s&&(t.morphAttributes.color=o),t.morphTargetsRelative=!0,t}))}(t,e.targets,i):t}))}class lg extends qh{constructor(t,e={}){super(),this.path="",this.resourcePath="",this.fileURL="",this.dataURLs=new Map,this.path=e.path||"";const i=e.externalFiles||new Map;"string"==typeof t?(this.fileURL=t,this.resourcePath=Sl.extractUrlBase(t)):(i.forEach(((e,i)=>this.fileURL=e===t?i:this.fileURL)),i.set(this.fileURL,t)),i.forEach(((t,e)=>{let i;i="string"==typeof t?t:URL.createObjectURL(new Blob([t])),this.dataURLs.set(e,i)})),this.setURLModifier((t=>{const e=decodeURI(t).replace(this.path,"").replace(this.resourcePath,"").replace(/^(\.?\/)/,""),i=this.dataURLs.get(e);return null!=i?i:t}))}dispose(){this.dataURLs.forEach(URL.revokeObjectURL)}}class cg{constructor(t){this.handle="1",this.scene=t}dispose(){this.scene.traverse((function(t){var e;t.geometry&&t.geometry.dispose(),t.material&&(e=t.material,(Array.isArray(e)?e:[e]).forEach((t=>function(t){t.dispose()}(t))))})),this.scene.clear()}getExtents(t){return this.scene.traverseVisible((e=>!e.children.length&&t.expandByObject(e))),t}getObjects(){const t=[];return this.scene.traverse((e=>t.push(e))),t}getVisibleObjects(){const t=[];return this.scene.traverseVisible((e=>t.push(e))),t}hasObject(t){for(;t;){if(t===this.scene)return!0;t=t.parent}return!1}getOwnObjects(t){return Array.isArray(t)||(t=[t]),t.filter((t=>this.hasObject(t)))}getObjectsByHandles(t){const e=new Set(t),i=[];return this.scene.traverse((t=>e.has(t.userData.handle)&&i.push(t))),i}getHandlesByObjects(t){Array.isArray(t)||(t=[t]);const e=new Set;return this.getOwnObjects(t).forEach((t=>e.add(t.userData.handle))),Array.from(e)}hideObjects(t){return Array.isArray(t)||(t=[t]),this.getOwnObjects(t).forEach((t=>t.visible=!1)),this}hideAllObjects(){return this.isolateObjects([])}isolateObjects(t){Array.isArray(t)||(t=[t]);const e=new Set(t);return this.getOwnObjects(t).forEach((t=>t.traverseAncestors((t=>e.add(t))))),this.scene.traverse((t=>t.visible=e.has(t))),this}showObjects(t){return Array.isArray(t)||(t=[t]),this.getOwnObjects(t).forEach((t=>{t.visible=!0,t.traverseAncestors((t=>t.visible=!0))})),this}showAllObjects(){return this.scene.traverse((t=>t.visible=!0)),this}showOriginalObjects(t){return this}hideOriginalObjects(t){return this}explode(t=0,e=4){t/=100,this.scene.userData.explodeDepth||(this.scene.userData.explodeDepth=function t(e,i){let n=i;return e.children.forEach((e=>{const r=t(e,i+1);n<r&&(n=r)})),e.userData.originalPosition=e.position.clone(),e.userData.originalCenter=(new Li).setFromObject(e).getCenter(new Ci),e.userData.isExplodeLocked=i>2&&0===e.children.length,n}(this.scene,1));const i=this.scene.userData.explodeDepth,n=t*i+1,r=0|n,s=n-r;return function i(n,a){if(n.position.copy(n.userData.originalPosition),a>0&&a<=r&&!n.userData.isExplodeLocked){let i=t*e;a===r&&(i*=s);const o=n.parent.userData.originalCenter,h=n.userData.originalCenter.clone().sub(o).multiplyScalar(i);n.position.add(h)}n.children.forEach((t=>i(t,a+1)))}(this.scene,0),this.scene.updateMatrixWorld(),this}}class dg extends c{constructor(t){super(),this.viewer=t}isSupport(t,e){return("string"==typeof t||t instanceof globalThis.File||t instanceof ArrayBuffer)&&/(gltf|glb)$/i.test(e)}async load(t,e,i){const n=new lg(t,i),r=new uf(n);r.setPath(n.path),r.setCrossOrigin(i.crossOrigin||r.crossOrigin),r.setWithCredentials(i.withCredentials||r.withCredentials);const s=await r.loadAsync(n.fileURL,(e=>{const{lengthComputable:i,loaded:n,total:r}=e,s=i?n/r:1;this.viewer.emitEvent({type:"geometryprogress",data:s,file:t})}));if(!this.viewer.scene)return this;const a=new cg(s.scene);return a.loader=this,a.viewer=this.viewer,this.viewer.scene.add(s.scene),this.viewer.models.push(a),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.update(),this.viewer.emitEvent({type:"databasechunk",data:s.scene,file:t}),this}}class ug extends cg{getExtents(t){return t.union(this.gltfLoader.getTotalGeometryExtent())}getObjects(){const t=[];return this.gltfLoader.originalObjects.forEach((e=>{t.push(e)})),t}getVisibleObjects(){return this.gltfLoader.getOriginalObjectForSelect()}hasObject(t){return this.gltfLoader.originalObjects.has(t)}getObjectsByHandles(t){const e=new Set(t),i=[];return e.forEach((t=>{const e=this.gltfLoader.handleToObjects.get(t)||[];i.push(...Array.from(e))})),i}hideObjects(t){return this.getOwnObjects(t).map((t=>t.userData.handle)).forEach((t=>this.gltfLoader.hiddenHandles.add(t))),this.gltfLoader.syncHiddenObjects(),this}isolateObjects(t){const e=this.getHandlesByObjects(t);return this.gltfLoader.isolateObjects(new Set(e)),this}showObjects(t){return this.getOwnObjects(t).map((t=>t.userData.handle)).forEach((t=>this.gltfLoader.hiddenHandles.delete(t))),this.gltfLoader.syncHiddenObjects(),this}showAllObjects(){return this.gltfLoader.hiddenHandles.clear(),this.gltfLoader.syncHiddenObjects(),this}showOriginalObjects(t){return this.getOwnObjects(t).forEach((t=>t.visible=!0)),this}hideOriginalObjects(t){return this.getOwnObjects(t).forEach((t=>t.visible=!1)),this}}const pg={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},mg=0,fg=1,gg=2,vg=3,_g=4,yg=5,xg=6;class bg{constructor(t){this.id=`${t}`,this.json=null,this.baseUrl="",this.loadController=null,this.batchDelay=10,this.maxBatchSize=5242880,this.maxRangesPerRequest=512,this.pendingRequests=[],this.batchTimeout=null,this.textureLoader=new el,this.materials=new Map,this.textureCache=new Map}async initialize(t){this.json=await t.loadJson(),this.baseUrl=await t.baseUrl(),this.loadController=t}clear(){this.json=null,this.baseUrl="",this.loadController=null,this.pendingRequests=[],this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=null),this.disposeMaterials(),this.textureCache.clear(),this.materials.clear()}getJson(){return this.json}scheduleRequest(t){return this.pendingRequests.push(t),this.batchTimeout&&clearTimeout(this.batchTimeout),this.batchTimeout=setTimeout((()=>this.processBatch()),this.batchDelay),new Promise(((e,i)=>{t.resolve=e,t.reject=i}))}async processBatch(){if(0===this.pendingRequests.length)return;const t=[...this.pendingRequests];this.pendingRequests=[],this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=null);try{for(let e=0;e<t.length;e+=this.maxRangesPerRequest){const i=t.slice(e,e+this.maxRangesPerRequest),n=await this.loadController.loadBinaryData(i);let r=0;i.forEach((t=>{const e=this.createTypedArray(n,r,t.length,t.componentType);t.resolve(e),r+=t.length}))}}catch(e){console.error("Error processing batch:",e),t.forEach((t=>t.reject(e)))}this.pendingRequests.length>0&&(this.batchTimeout=setTimeout((()=>this.processBatch()),this.batchDelay))}getBufferView(t,e,i){return this.scheduleRequest({offset:t,length:e,componentType:i})}createTypedArray(t,e,i,n){try{if(!(t&&t instanceof ArrayBuffer))throw new Error("Invalid buffer");let r;switch(n){case 5120:case 5121:r=1;break;case 5122:case 5123:r=2;break;case 5125:case 5126:r=4;break;default:throw new Error(`Unsupported component type: ${n}`)}const s=i/r;if(!Number.isInteger(s))throw new Error(`Invalid length ${i} for component type ${n}`);if(i>t.byteLength)throw new Error(`Buffer too small: need ${i} bytes, but buffer is ${t.byteLength} bytes`);return new(0,pg[n])(t,e,s)}catch(r){throw"AbortError"!==r.name&&console.error("Error creating typed array:",{bufferSize:t?.byteLength,offset:e,length:i,componentType:n,error:r}),r}}async createBufferAttribute(t){if(!this.json)throw new Error("No GLTF structure loaded");const e=this.json,i=e.accessors[t],n=e.bufferViews[i.bufferView];try{const t=(n.byteOffset||0)+(i.byteOffset||0),e=this.getNumComponents(i.type),r=i.count*e*this.getComponentSize(i.componentType),s=await this.getBufferView(t,r,i.componentType),a=new cr(s,e);return void 0!==i.min&&(a.min=i.min),void 0!==i.max&&(a.max=i.max),a}catch(t){throw"AbortError"!==t.name&&console.error("Error creating buffer attribute:",{error:t,accessor:i,bufferView:n}),t}}getComponentSize(t){switch(t){case 5120:case 5121:return 1;case 5122:case 5123:return 2;case 5125:case 5126:return 4;default:throw new Error(`Unknown component type: ${t}`)}}getNumComponents(t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:throw new Error(`Unknown type: ${t}`)}}async loadTextures(){if(!this.json.textures)return;const t=async t=>{const e=this.json.images[t];if(e.uri){if(e.uri.startsWith("data:"))return await this.textureLoader.loadAsync(e.uri);{const t=this.baseUrl+e.uri;return await this.textureLoader.loadAsync(t)}}if(void 0!==e.bufferView){const t=this.json.bufferViews[e.bufferView],i=await this.getBufferView(t.byteOffset||0,t.byteLength,5121),n=new Blob([i],{type:e.mimeType}),r=URL.createObjectURL(n),s=await this.textureLoader.loadAsync(r);return URL.revokeObjectURL(r),s.flipY=!1,s}},e=[];for(let i=0;i<this.json.textures.length;i++)e.push(t(this.json.textures[i].source).then((t=>this.textureCache.set(i,t))));await Promise.all(e)}loadMaterials(){if(!this.json.materials)return this.materials;for(let t=0;t<this.json.materials.length;t++){const e=this.json.materials[t],i=this.createMaterial(e);this.materials.set(t,i)}return this.materials}createMaterial(t){const e=new vh;if(t.pbrMetallicRoughness){const i=t.pbrMetallicRoughness;i.baseColorFactor&&(e.color.fromArray(i.baseColorFactor),e.opacity=i.baseColorFactor[3]),i.baseColorTexture&&(e.map=this.textureCache.get(i.baseColorTexture.index)),void 0!==i.metallicFactor&&(e.metalness=i.metallicFactor),void 0!==i.roughnessFactor&&(e.roughness=i.roughnessFactor),i.metallicRoughnessTexture&&(e.metalnessMap=this.textureCache.get(i.metallicRoughnessTexture.index),e.roughnessMap=e.metalnessMap)}return t.normalTexture&&(e.normalMap=this.textureCache.get(t.normalTexture.index),void 0!==t.normalTexture.scale&&e.normalScale.set(t.normalTexture.scale,t.normalTexture.scale)),t.emissiveFactor&&e.emissive.fromArray(t.emissiveFactor),t.emissiveTexture&&(e.emissiveMap=this.textureCache.get(t.emissiveTexture.index)),t.occlusionTexture&&(e.aoMap=this.textureCache.get(t.occlusionTexture.index),void 0!==t.occlusionTexture.strength&&(e.aoMapIntensity=t.occlusionTexture.strength)),"BLEND"===t.alphaMode?e.transparent=!0:"MASK"===t.alphaMode&&(e.alphaTest=void 0!==t.alphaCutoff?t.alphaCutoff:.5),e.side=t.doubleSided?2:0,e.name=t.name,e}disposeMaterials(){this.textureCache.forEach((t=>t.dispose())),this.textureCache.clear(),this.materials.forEach((t=>{t.map&&t.map.dispose(),t.lightMap&&t.lightMap.dispose(),t.bumpMap&&t.bumpMap.dispose(),t.normalMap&&t.normalMap.dispose(),t.specularMap&&t.specularMap.dispose(),t.envMap&&t.envMap.dispose(),t.aoMap&&t.aoMap.dispose(),t.metalnessMap&&t.metalnessMap.dispose(),t.roughnessMap&&t.roughnessMap.dispose(),t.emissiveMap&&t.emissiveMap.dispose(),t.dispose()})),this.materials.clear()}estimateNodeSize(t){if(!this.json.meshes)return 0;const e=this.json.meshes[t];if(!e||!e.primitives)return 0;let i=0;for(const t of e.primitives){if(t.attributes)for(const[,e]of Object.entries(t.attributes)){if(void 0===e)continue;const t=this.json.accessors[e];if(!t)continue;const n=this.getNumComponents(t.type),r=this.getComponentSize(t.componentType);i+=t.count*n*r}if(void 0!==t.indices){const e=this.json.accessors[t.indices];if(e){const t=this.getComponentSize(e.componentType);i+=e.count*t}}}return i}}class wg{constructor(t,e,i){this.camera=t,this.scene=e,this.renderer=i,this.eventHandlers={geometryprogress:[],databasechunk:[],geometryend:[],geometryerror:[],update:[],geometrymemory:[]},this.loadDistance=100,this.unloadDistance=150,this.checkInterval=1e3,this.nodes=new Map,this.loadedMeshes=new Map,this.nodesToLoad=[],this.edgeNodes=[],this.structures=[],this.structureRoots=new Map,this.memoryLimit=this.getAvailableMemory(),this.loadedGeometrySize=0,this.geometryCache=new Map,this.materialCache=new Map,this.textureCache=new Map,this.currentMemoryUsage=0,this.updateMemoryIndicator(),this.loadedMaterials=new Map,this.abortController=new AbortController,this.batchSize=1e4,this.frameDelay=0,this.graphicsObjectLimit=1e4,this.totalLoadedObjects=0,this.lastUpdateTime=0,this.updateInterval=1e3,this.handleToObjects=new Map,this.originalObjects=new Set,this.originalObjectsToSelection=new Set,this.optimizedOriginalMap=new Map,this.mergedMesh=new Set,this.mergedLines=new Set,this.mergedLineSegments=new Set,this.mergedPoints=new Set,this.isolatedObjects=[],this.useVAO=!!window.WebGL2RenderingContext&&this.renderer.getContext()instanceof WebGL2RenderingContext,this.handleToOptimizedObjects=new Map,this.hiddenHandles=new Set,this.newOptimizedObjects=new Set,this.oldOptimizeObjects=new Set}getAvailableMemory(){let t=6442450944;try{if(navigator.deviceMemory)t=1024*navigator.deviceMemory*1024*1024;else if(performance.memory){const e=performance.memory.jsHeapSizeLimit;e&&(t=Math.min(t,e))}t=Math.min(t,17179869184),t=Math.max(t,2147483648),console.log(`Available memory set to ${Math.round(t/1073741824)}GB`)}catch(t){console.warn("Error detecting available memory:",t)}return t}getAbortController(){return this.abortController}abortLoading(){this.abortController.abort()}updateMemoryIndicator(){this.dispatchEvent("geometrymemory",{currentUsage:this.currentMemoryUsage,limit:this.memoryLimit})}setMemoryLimit(t){}estimateGeometrySize(t){let e=0;return t.traverse((t=>{if(t.geometry){if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const i=t.geometry;i.attributes&&Object.values(i.attributes).forEach((t=>{t&&t.array&&(e+=t.array.byteLength)})),i.index&&i.index.array&&(e+=i.index.array.byteLength)}})),e}recalculateScene(){const t=[];if(this.scene.traverse((e=>{if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");if(e.geometry&&!this.geometryCache.has(e.geometry.uuid)){const i=this.estimateGeometrySize(e);this.geometryCache.set(e.geometry.uuid,i),t.push({object:e,size:i,distance:e.position.distanceTo(this.camera.position)})}})),this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");t.sort(((t,e)=>e.distance-t.distance));let e=0;for(const i of t)e+=i.size;if(e>this.memoryLimit){console.log(`Memory usage (${Math.round(e/1048576)}MB) exceeds limit`);for(const i of t){if(e<=this.memoryLimit)break;if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const t=i.object;t.geometry&&(e-=i.size,this.geometryCache.delete(t.geometry.uuid),t.geometry.dispose(),t.visible=!1)}}this.currentMemoryUsage=e,this.updateMemoryIndicator(),console.log(`Final memory usage: ${Math.round(e/1048576)}MB`)}async loadNode(t){const e=this.nodes.get(t);if(!e||e.loaded||e.loading)return;e.loading=!0;const i=e.structure.getJson().meshes[e.meshIndex];try{for(const t of i.primitives){const n=t.attributes.POSITION,r=new br,s=new Map;s.set("position",e.structure.createBufferAttribute(n)),void 0!==t.attributes.NORMAL&&s.set("normal",e.structure.createBufferAttribute(t.attributes.NORMAL)),void 0!==t.attributes.TEXCOORD_0&&s.set("uv",e.structure.createBufferAttribute(t.attributes.TEXCOORD_0));if((await Promise.all([...s.entries()].map((async([t,e])=>[t,await e])))).forEach((([t,e])=>{r.setAttribute(t,e)})),void 0!==t.indices){const i=await e.structure.createBufferAttribute(t.indices);r.setIndex(i)}let a,o;if(this.currentPrimitiveMode=t.mode,a=void 0!==t.material&&e.structure.materials.get(t.material)||this.createDefaultMaterial(),t.mode===mg){const t=new Da;tr.prototype.copy.call(t,a),t.color.copy(a.color),t.map=a.map,t.sizeAttenuation=!1,o=new ka(r,t)}else t.mode===_g||t.mode===yg||t.mode===xg||void 0===t.mode?(o=new Dr(r,a),t.mode===yg?o.drawMode=1:t.mode===xg&&(o.drawMode=2)):t.mode===fg?o=new La(r,a):t.mode===vg?o=new Aa(r,a):t.mode===gg&&(o=new Ia(r,a));e.extras&&(o.userData={...o.userData,...e.extras}),i.extras&&(o.userData={...o.userData,...i.extras}),t.extras&&(o.userData={...o.userData,...t.extras}),e.handle?o.userData.handle=e.handle:o.userData.handle=`${e.structure.id}_${o.userData.handle}`,"edges"===o.material.name?o.userData.isEdge=!0:o.userData.isEdge=!1,this.registerObjectWithHandle(o,o.userData.handle),o.position.copy(e.position),r.attributes.normal||r.computeVertexNormals(),a.aoMap&&r.attributes.uv&&r.setAttribute("uv2",r.attributes.uv),e.group?e.group.add(o):this.scene.add(o),e.object=o,this.totalLoadedObjects++,o.visible=this.totalLoadedObjects<this.graphicsObjectLimit}e.loaded=!0,e.loading=!1;const t=this.estimateGeometrySize(e.object);this.geometryCache.set(e.object.uuid,t),this.currentMemoryUsage+=t}catch(i){"AbortError"!==i.name&&console.error(`Error loading node ${t}:`,i),e.loading=!1}}unloadNode(t){const e=this.nodes.get(t);e&&e.loaded&&e.object&&(e.object.parent?e.object.parent.remove(e.object):this.scene.remove(e.object),e.object.traverse((t=>{if(t.geometry){const e=this.geometryCache.get(t.geometry.uuid)||0;this.currentMemoryUsage-=e,this.geometryCache.delete(t.geometry.uuid),t.geometry.dispose()}})),e.object=null,e.loaded=!1,this.updateMemoryIndicator(),console.log(`Unloaded node: ${t}`))}checkDistances(){const t=this.camera.position;this.nodes.forEach(((e,i)=>{const n=t.distanceTo(e.position);e.loaded?n>this.unloadDistance&&this.unloadNode(i):e.loading||n<this.loadDistance&&this.loadNode(i)}))}async loadStructure(t){this.clear();const e=Array.isArray(t)?t:[t];for(const t of e)this.structures.push(t);for(const t of this.structures)try{await t.loadTextures(),await t.loadMaterials()}catch(t){throw console.error("Error loading materials:",t),t}await this.processSceneHierarchy()}async processSceneHierarchy(){if(0===this.structures.length)throw new Error("No GLTF structures loaded");this.nodesToLoad=[];let t=0;for(const e of this.structures){const i=e.getJson();if(!i.scenes||!i.scenes.length){console.warn("No scenes found in GLTF structure");continue}t+=i.buffers[0].byteLength;const n=new Zr;n.name=`structure_${e.id}_root`,this.scene.add(n),this.structureRoots.set(e.id,n);const r=i.scenes[i.scene||0];for(const t of r.nodes)await this.processNodeHierarchy(e,t,n)}const e=2*t>this.memoryLimit;this.nodesToLoad.sort(((t,e)=>{const i=this.nodes.get(t),n=this.nodes.get(e);if(!i?.geometryExtents||!n?.geometryExtents)return 0;const r=i.geometryExtents.getSize(new Ci),s=n.geometryExtents.getSize(new Ci),a=r.x*r.y*r.z;return s.x*s.y*s.z-a})),e||this.nodesToLoad.push(...this.edgeNodes),this.dispatchEvent("databasechunk",{totalNodes:this.nodesToLoad.length,structures:this.structures.map((t=>({id:t.id,nodeCount:this.nodesToLoad.filter((e=>e.startsWith(t.id))).length})))})}async processNodeHierarchy(t,e,i){const n=t.json.nodes[e];let r=null,s=null;if(n.extras?.handle&&(s=`${t.id}_${n.extras.handle}`),void 0!==n.camera){const e=this.loadCamera(t,n.camera,n);return n.extras&&(e.userData={...e.userData,...n.extras}),void this.scene.add(e)}if(this.needsGroupForNode(t,n)){if(r=new Zr,r.name=n.name||`node_${e}`,n.extras&&(r.userData={...n.extras},r.userData.handle&&(r.userData.handle=`${t.id}_${r.userData.handle}`)),n.matrix)r.matrix.fromArray(n.matrix),r.matrixAutoUpdate=!1;else if(n.translation||n.rotation||n.scale){const t=n.translation?(new Ci).fromArray(n.translation):new Ci,e=n.rotation?(new Ai).fromArray(n.rotation):new Ai,i=n.scale?(new Ci).fromArray(n.scale):new Ci(1,1,1);r.matrix.compose(t,e,i),r.matrixAutoUpdate=!1}i&&i.add(r)}if(void 0!==n.mesh){const a=new sn,o=`${t.id}_${e}`,h=t.json.meshes[n.mesh],l=new Li;for(const e of h.primitives){const i=t.json.accessors[e.attributes.POSITION];if(i&&i.min&&i.max){const t=new Li((new Ci).fromArray(i.min),(new Ci).fromArray(i.max));l.union(t)}}let c=!1;if(void 0!==h.primitives[0].material){const e=t.json.materials[h.primitives[0].material];"edges"===e?.name&&(c=!0)}c?this.edgeNodes.push(o):this.nodesToLoad.push(o),this.nodes.set(o,{position:r?r.position.clone():(new Ci).setFromMatrixPosition(a),nodeIndex:e,meshIndex:n.mesh,loaded:!1,loading:!1,object:null,group:r||i,structure:t,extras:n.extras,geometryExtents:l,handle:s})}if(n.children)for(const e of n.children)await this.processNodeHierarchy(t,e,r||i);return r}needsGroupForNode(t,e){const i=e.matrix||e.translation||e.rotation||e.scale,n=void 0!==e.mesh&&t.json.meshes[e.mesh].primitives.length>1;return void 0!==i||n}async processNodes(){const t=this.nodesToLoad;let e=0;const i=t.length;try{for(;e<i;){const n=t.slice(e,e+this.batchSize),r=[];for(const t of n){if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const i=await this.estimateNodeSize(t);if(this.currentMemoryUsage+i>this.memoryLimit)return console.log(`Memory limit reached after loading ${e} nodes`),this.dispatchEvent("geometryerror",{message:"Memory limit reached"}),this.dispatchEvent("update"),e;r.push(this.loadNode(t))}await Promise.all(r),e+=n.length,this.updateMemoryIndicator(),this.dispatchEvent("geometryprogress",{percentage:Math.round(e/i*100),loaded:e,total:i});const s=Date.now();s-this.lastUpdateTime>=this.updateInterval&&(this.dispatchEvent("update"),this.lastUpdateTime=s),await new Promise((t=>{setTimeout(t,0)}))}return this.dispatchEvent("geometryend",{totalLoaded:e,totalNodes:i}),e}catch(t){throw this.dispatchEvent("geometryerror",{error:t}),t}}async loadNodes(){console.time("process nodes"),await this.processNodes(),console.timeEnd("process nodes"),console.time("optimize scene"),await this.optimizeScene(),console.timeEnd("optimize scene")}cleanupPartialLoad(){this.nodesToLoad.forEach((t=>{const e=this.nodes.get(t);e&&e.loading&&this.unloadNode(t)}))}createDefaultMaterial(){return this.currentPrimitiveMode===mg?new Da({color:new Jn(8421504),size:.05,sizeAttenuation:!0,alphaTest:.5,transparent:!0,vertexColors:!1,blending:1,depthWrite:!1,depthTest:!0}):new vh({color:8421504,metalness:0,roughness:1,side:2})}async estimateNodeSize(t){const e=this.nodes.get(t);return e?await e.structure.estimateNodeSize(e.meshIndex):0}getTotalGeometryExtent(){const t=new Li;for(const e of this.nodes.values()){if(!e.geometryExtents)continue;if(e.object&&this.hiddenHandles.has(e.object.userData.handle))continue;const i=e.geometryExtents.clone();e.group&&e.group.matrix&&(i.applyMatrix4(e.group.matrix),e.group.parent&&e.group.parent.matrix&&i.applyMatrix4(e.group.parent.matrix)),t.union(i)}return t}loadCamera(t,e,i){const n=t.getJson().cameras[e],r=n[n.type];let s;return"perspective"===n.type?s=new jr(Qe.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(s=new fl(r.xmag/-2,r.xmag/2,r.ymag/2,r.ymag/-2,r.znear,r.zfar)),i.matrix?(s.matrix.fromArray(i.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale)):(i.translation&&s.position.fromArray(i.translation),i.rotation&&s.quaternion.fromArray(i.rotation),i.scale&&s.scale.fromArray(i.scale)),s}clearNodesToLoad(){this.nodesToLoad=[]}async addStructure(t){const e=new bg;return await e.initialize(t),this.structures.push(e),e}removeOptimization(){this.originalObjects.forEach((t=>t.visible=!0));const t=t=>{t.parent&&t.parent.remove(t),t.geometry&&t.geometry.dispose()};if(this.structureGroups)for(const e of this.structureGroups.values())e.meshes.forEach(t),e.lines.forEach(t),e.lineSegments.forEach(t),e.meshes.clear(),e.lines.clear(),e.lineSegments.clear();this.optimizedOriginalMap.clear(),this.mergedMesh.clear(),this.mergedLines.clear(),this.mergedLineSegments.clear(),this.originalObjects.clear(),this.originalObjectsToSelection.clear()}clear(){this.structures.forEach((t=>{t&&t.clear()})),this.structures=[],this.nodes.forEach((t=>{t.object&&(t.object.parent&&t.object.parent.remove(t.object),t.object.geometry&&t.object.geometry.dispose(),t.object.material&&(Array.isArray(t.object.material)?t.object.material.forEach((t=>t.dispose())):t.object.material.dispose()))})),this.nodes.clear(),this.loadedMeshes.forEach((t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach((t=>t.dispose())):t.material.dispose())})),this.loadedMeshes.clear(),this.structureRoots.forEach((t=>{t&&(t.traverse((t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach((t=>t.dispose())):t.material.dispose())})),t.parent&&t.parent.remove(t))})),this.structureRoots.clear(),this.mergedMesh.forEach((t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach((t=>t.dispose())):t.material.dispose()),t.parent&&t.parent.remove(t)})),this.mergedMesh.clear(),this.mergedLines.forEach((t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)})),this.mergedLines.clear(),this.mergedLineSegments.forEach((t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)})),this.mergedLineSegments.clear(),this.mergedPoints.forEach((t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)})),this.mergedPoints.clear(),this.geometryCache.clear(),this.materialCache.clear(),this.textureCache.clear(),this.loadedMaterials.clear(),this.nodesToLoad=[],this.handleToObjects.clear(),this.originalObjects.clear(),this.originalObjectsToSelection.clear(),this.optimizedOriginalMap.clear(),this.handleToOptimizedObjects.clear(),this.hiddenHandles.clear(),this.newOptimizedObjects.clear(),this.oldOptimizeObjects.clear(),this.isolatedObjects=[],this.totalLoadedObjects=0,this.lastUpdateTime=0,this.currentMemoryUsage=0,this.loadedGeometrySize=0,this.abortController=new AbortController,this.updateMemoryIndicator()}setStructureTransform(t,e){const i=this.structureRoots.get(t);return!!i&&(i.matrix.copy(e),i.matrix.decompose(i.position,i.quaternion,i.scale),!0)}getStructureRootGroup(t){return this.structureRoots.get(t)}addEventListener(t,e){this.eventHandlers[t]&&this.eventHandlers[t].push(e)}removeEventListener(t,e){this.eventHandlers[t]&&(this.eventHandlers[t]=this.eventHandlers[t].filter((t=>t!==e)))}dispatchEvent(t,e){this.eventHandlers[t]&&this.eventHandlers[t].forEach((t=>t(e)))}registerObjectWithHandle(t,e){if(!e)return;const i=t.userData.handle;this.handleToObjects.has(i)||this.handleToObjects.set(i,new Set),this.handleToObjects.get(i).add(t),t.userData.structureId=t.userData.handle.split("_")[0]}getObjectsByHandle(t){return t?Array.from(this.handleToObjects.get(t)||[]):[]}getHandlesByObjects(t){if(!t.length)return[];const e=new Set;return t.forEach((t=>{this.originalObjects.has(t)&&e.add(t.userData.handle)})),Array.from(e)}getMaterialId(t,e){const i={type:t.type,color:t.color?.getHex(),map:t.map?.uuid,transparent:t.transparent,opacity:t.opacity,side:t.side,index:e?1:0};return JSON.stringify(i)}addToMaterialGroup(t,e,i){const n=t.geometry.attributes.position.count,r=t.geometry.index?t.geometry.index.count:0,s=t.material;let a,o=this.getMaterialId(s,null!==t.geometry.index);if(e.has(o))if(a=e.get(o),a.totalVertices+n>1e5||a.totalIndices+r>1e5){const a={material:s,objects:[t],totalVertices:n,totalIndices:r};o=this.getMaterialId(s,null!==t.geometry.index),e.set(o,a),i.push(a)}else a.objects.push(t),a.totalVertices+=n,a.totalIndices+=r;else a={material:s,objects:[t],totalVertices:n,totalIndices:r},e.set(o,a),i.push(a);this.originalObjects.add(t)}optimizeScene(){this.originalObjects.clear(),this.originalObjectsToSelection.clear();const t=new Map;this.scene.traverse((e=>{if(e.userData.structureId){const i=e.userData.structureId;t.has(i)||t.set(i,{mapMeshes:new Map,mapLines:new Map,mapLineSegments:new Map,mapPoints:new Map,meshes:[],lines:[],lineSegments:[],points:[],rootGroup:this.structureRoots.get(i)});const n=t.get(i);e instanceof Dr?this.addToMaterialGroup(e,n.mapMeshes,n.meshes):e instanceof La?this.addToMaterialGroup(e,n.mapLineSegments,n.lineSegments):e instanceof Aa?this.addToMaterialGroup(e,n.mapLines,n.lines):e instanceof ka&&this.addToMaterialGroup(e,n.mapPoints,n.points)}}));for(const e of t.values())e.mapMeshes.clear(),e.mapLines.clear(),e.mapLineSegments.clear(),e.mapPoints.clear(),this.mergeMeshGroups(e.meshes,e.rootGroup),this.mergeLineGroups(e.lines,e.rootGroup),this.mergeLineSegmentGroups(e.lineSegments,e.rootGroup),this.mergePointsGroups(e.points,e.rootGroup);this.originalObjects.forEach((t=>{t.visible=!1,t instanceof ka||t.userData.isEdge||this.originalObjectsToSelection.add(t)})),this.dispatchEvent("update")}mergeMeshGroups(t,e){for(const i of t)try{const t=[],n=new Set,r=[];for(const e of i.objects){const i=e.geometry.clone();e.updateWorldMatrix(!0,!1),i.applyMatrix4(e.matrixWorld),t.push(i),r.push(e),n.add(e.userData.handle)}const s=[];if(t.length>0){const n=lf(t);this.useVAO&&this.createVAO(n);const a=new Dr(n,i.material);e.add(a),this.mergedMesh.add(a),this.optimizedOriginalMap.set(a,r),s.push(a),t.forEach((t=>{t.dispose()}))}n.forEach((t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...s),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,s)}))}catch(t){console.error("Failed to merge meshes for material:",t),i.objects.forEach((t=>{t.visible=!0}))}}mergeLineGroups(t,e){for(const i of t){if(0===i.objects.length)continue;const t=new Set;let n=0;i.objects.map((e=>{t.add(e.userData.handle),n+=e.geometry.attributes.position.count}));const r=new Float32Array(3*n);let s=0;const a=[];let o=0;i.objects.forEach((t=>{const e=t.geometry.attributes.position,i=e.count;t.updateWorldMatrix(!0,!1);const n=t.matrixWorld,h=new Ci;for(let t=0;t<i;t++)h.fromBufferAttribute(e,t),h.applyMatrix4(n),r[s++]=h.x,r[s++]=h.y,r[s++]=h.z;for(let t=0;t<i-1;t++)a.push(o+t,o+t+1);o+=i}));const h=new br;h.setAttribute("position",new cr(r,3)),h.setIndex(a),h.computeBoundingSphere(),h.computeBoundingBox();const l=new La(h,i.material),c=[l];this.useVAO&&this.createVAO(l),e.add(l),this.mergedLines.add(l),this.optimizedOriginalMap.set(l,i.objects),t.forEach((t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...c),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,c)}))}}mergeLineSegmentGroups(t,e){for(const i of t)try{const t=[],n=[],r=new Set;for(const e of i.objects){const i=e.geometry.clone();e.updateWorldMatrix(!0,!1),i.applyMatrix4(e.matrixWorld),t.push(i),n.push(e),r.add(e.userData.handle)}const s=[];if(t.length>0){const r=lf(t,!1),a=new La(r,i.material);this.useVAO&&this.createVAO(a),e.add(a),this.mergedLineSegments.add(a),this.optimizedOriginalMap.set(a,n),s.push(a),t.forEach((t=>{t.dispose()}))}r.forEach((t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...s),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,s)}))}catch(t){console.warn("Failed to merge line segments for material:",t),i.objects.forEach((t=>{t.visible=!0}))}}mergePointsGroups(t,e){for(const i of t)try{const t=[],n=[],r=new Set;for(const e of i.objects){const i=e.geometry.clone();e.updateWorldMatrix(!0,!1),i.applyMatrix4(e.matrixWorld),t.push(i),n.push(e),r.add(e.userData.handle)}const s=[];if(t.length>0){const r=lf(t,!1),a=new ka(r,i.material);this.useVAO&&this.createVAO(a),e.add(a),this.mergedPoints.add(a),this.optimizedOriginalMap.set(a,n),s.push(a),t.forEach((t=>{t.dispose()}))}r.forEach((t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...s),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,s)}))}catch(t){console.warn("Failed to merge points for material:",t),i.objects.forEach((t=>{t.visible=!0}))}}mergeInSingleSegment(t,e){const i=[...this.mergedLineSegments,...this.mergedLines].filter((e=>e.userData.structureId===t));if(0!==i.length)try{const n=[],r=i.some((t=>void 0!==t.geometry.attributes.normal));i.forEach((t=>{const e=t.geometry.clone();t.updateWorldMatrix(!0,!1),e.applyMatrix4(t.matrixWorld),r&&!e.attributes.normal&&e.computeVertexNormals(),!r&&e.attributes.normal&&e.deleteAttribute("normal");const i=new Float32Array(3*e.attributes.position.count);for(let e=0;e<i.length;e+=3)i[e]=t.material.color.r,i[e+1]=t.material.color.g,i[e+2]=t.material.color.b;if(e.setAttribute("color",new cr(i,3)),!e.index){const t=[],i=e.attributes.position.count;for(let e=0;e<i-1;e+=2)t.push(e,e+1);e.setIndex(t)}n.push(e)}));const s=lf(n,!1),a=new ya({vertexColors:!0});this.useVAO&&this.createVAO(s);const o=new La(s,a);o.userData.structureId=t,e.add(o),this.mergedLineSegments.add(o),i.forEach((t=>{t.parent&&t.parent.remove(t),t.geometry.dispose()}))}catch(t){console.error("Failed to merge geometries:",t),i.forEach((t=>{t.visible=!0,e.add(t)}))}}showOriginalObjects(t){t.forEach((t=>{this.originalObjects.has(t)&&(t.visible=!0)}))}hideOriginalObjects(t){t.forEach((t=>{this.originalObjects.has(t)&&(t.visible=!1)}))}createVAO(t){if(!this.useVAO)return;if(t.attributes?.position?.count<1e3)return;const e=this.renderer.getContext(),i=e.createVertexArray();e.bindVertexArray(i);for(const i in t.attributes){const n=t.attributes[i],r=this.renderer.properties.get(n).buffer;e.bindBuffer(e.ARRAY_BUFFER,r),e.enableVertexAttribArray(n.itemSize),e.vertexAttribPointer(n.itemSize,n.itemSize,e.FLOAT,!1,0,0)}if(t.index){const i=this.renderer.properties.get(t.index).buffer;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,i)}e.bindVertexArray(null),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),t.vao=i}getOriginalObjectForSelect(){const t=[];for(const e of this.originalObjectsToSelection)this.hiddenHandles.has(e.userData.handle)||t.push(e);return t}isolateObjects(t){0!==this.hiddenHandles.size&&(this.hiddenHandles.clear(),this.syncHiddenObjects());for(const e of this.handleToOptimizedObjects.keys())t.has(e)||this.hiddenHandles.add(e);this.syncHiddenObjects()}showAllHiddenObjects(){this.hiddenHandles.clear(),this.syncHiddenObjects()}hideObjects(t){t.forEach((t=>{this.hiddenHandles.add(t)})),this.syncHiddenObjects()}showObjects(t){t.forEach((t=>{this.hiddenHandles.delete(t)})),this.syncHiddenObjects()}syncHiddenObjects(){if(0!==this.oldOptimizeObjects.size){for(const t of this.oldOptimizeObjects)t.visible=!0;this.oldOptimizeObjects.clear()}if(0!==this.newOptimizedObjects.size){for(const t of this.newOptimizedObjects)t.visible=!1,t.geometry.dispose(),t.parent.remove(t);this.newOptimizedObjects.clear()}0!==this.hiddenHandles.size&&(this.hiddenHandles.forEach((t=>{const e=this.handleToOptimizedObjects.get(t);e&&e.forEach((t=>this.oldOptimizeObjects.add(t)))})),this.oldOptimizeObjects.forEach((t=>{t.visible=!1;const e=this.optimizedOriginalMap.get(t),i=[];e.forEach((t=>{this.hiddenHandles.has(t.userData.handle)||i.push(t)}));const n=i[0];if(n instanceof Dr||n instanceof La){const e=i.map((t=>{const e=t.geometry.clone();return t.updateWorldMatrix(!0,!1),e.applyMatrix4(t.matrixWorld),e})),r=lf(e),s=n instanceof Dr?new Dr(r,t.material):new La(r,t.material);s.visible=!0,t.parent.add(s),this.newOptimizedObjects.add(s),e.forEach((t=>{t.dispose()}))}else if(n instanceof Aa){let e=0;i.map((t=>{e+=t.geometry.attributes.position.count}));const n=new Float32Array(3*e);let r=0;const s=[];let a=0;i.forEach((t=>{const e=t.geometry.attributes.position,i=e.count;t.updateWorldMatrix(!0,!1);const o=t.matrixWorld,h=new Ci;for(let t=0;t<i;t++)h.fromBufferAttribute(e,t),h.applyMatrix4(o),n[r++]=h.x,n[r++]=h.y,n[r++]=h.z;for(let t=0;t<i-1;t++)s.push(a+t,a+t+1);a+=i}));const o=new br;o.setAttribute("position",new cr(n,3)),o.setIndex(s),o.computeBoundingSphere(),o.computeBoundingBox();const h=new La(o,t.material);h.visible=!0,t.parent.add(h),this.newOptimizedObjects.add(h)}})))}}class Sg{constructor(t){this.requestId=0,this.viewer=t,this.scene=new Zr}dispose(){this.gltfLoader&&this.gltfLoader.clear()}isSupport(t){return"object"==typeof t&&"string"==typeof t.database&&"function"==typeof t.downloadResource&&"function"==typeof t.downloadResourceRange&&/.gltf$/i.test(t.database)}async load(t,e,i){this.gltfLoader=new wg(this.viewer.camera,this.viewer.scene,this.viewer.renderer),this.gltfLoader.memoryLimit=this.viewer.options.memoryLimit,this.gltfLoader.addEventListener("databasechunk",(e=>{const i=new ug(this.scene);i.loader=this,i.gltfLoader=this.gltfLoader,i.viewer=this.viewer,this.viewer.scene.add(this.scene),this.viewer.models.push(i),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.update(),this.viewer.emitEvent({type:"databasechunk",data:e,file:t.file,model:t})})),this.gltfLoader.addEventListener("geometryprogress",(e=>{const i=e.loaded/e.total;this.viewer.emitEvent({type:"geometryprogress",data:i,file:t.file,model:t})})),this.gltfLoader.addEventListener("geometrymemory",(t=>{this.viewer.emit({type:"geometryprogress",data:t})})),this.gltfLoader.addEventListener("geometryerror",(e=>{this.viewer.emitEvent({type:"geometryerror",data:e,file:t.file,model:t})})),this.gltfLoader.addEventListener("update",(t=>{this.viewer.update()}));const n={loadJson:async()=>{const e=await t.downloadResource(t.database,(e=>{this.viewer.emitEvent({type:"geometryprogress",data:e,file:t})}),this.gltfLoader.getAbortController().signal),i=(new TextDecoder).decode(e);return JSON.parse(i)},loadBinaryData:e=>{const i=e.map((t=>({begin:t.offset,end:t.offset+t.length-1,requestId:this.requestId++})));return t.downloadResourceRange(t.geometry[0],void 0,i,void 0,this.gltfLoader.getAbortController().signal)},baseUrl:()=>Promise.resolve(`${t.httpClient.serverUrl}${t.path}/`)},r=new bg(1);return await r.initialize(n),await this.gltfLoader.loadStructure(r),await this.gltfLoader.loadNodes(),this}cancel(){this.gltfLoader&&this.gltfLoader.abortLoading()}}const Mg=p("threejs");Mg.registerLoader("gltf-file",(t=>new dg(t))),Mg.registerLoader("gltf-cloud",(t=>new Sg(t)));class Tg{constructor(){this._listeners={}}addEventListener(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners[t])return this;const i=this._listeners[t].filter((t=>t!==e));return 0!==i.length?this._listeners[t]=i:delete this._listeners[t],this}removeAllListeners(t){return t?delete this._listeners[t]:this._listeners={},this}emitEvent(t){if(void 0===this._listeners[t.type])return!1;return this._listeners[t.type].slice().forEach((e=>e.call(this,t))),!0}on(t,e){return this.addEventListener(t,e)}off(t,e){return this.removeEventListener(t,e)}emit(t,...e){return"string"==typeof t?this.emitEvent({type:t,args:e}):"object"==typeof t&&this.emitEvent(t)}}var Eg="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ag(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Cg,Rg={exports:{}},Pg={},Lg={},Ig={};function Dg(){return Cg||(Cg=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t._registerNode=t.Konva=t.glob=void 0;const e=Math.PI/180;t.glob=void 0!==Eg?Eg:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.18",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:i=>t.Konva.angleDeg?i*e:i,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(Ig)),Ig}var Og,Ng={};function Ug(){return Og||(Og=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=Dg();class i{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new i(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.m[0]*e+this.m[2]*i,r=this.m[1]*e+this.m[3]*i,s=this.m[0]*-i+this.m[2]*e,a=this.m[1]*-i+this.m[3]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=s,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,n=this.m[1]+this.m[3]*e,r=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=n,this.m[2]=r,this.m[3]=s,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],n=this.m[0]*t.m[2]+this.m[2]*t.m[3],r=this.m[1]*t.m[2]+this.m[3]*t.m[3],s=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=r,this.m[4]=s,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,n=-this.m[2]*t,r=this.m[0]*t,s=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=r,this.m[4]=s,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const e=this.m[0],i=this.m[1],n=this.m[2],r=this.m[3],s=e*r-i*n,a={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=i){const t=Math.sqrt(e*e+i*i);a.rotation=i>0?Math.acos(e/t):-Math.acos(e/t),a.scaleX=t,a.scaleY=s/t,a.skewX=(e*n+i*r)/s,a.skewY=0}else if(0!=n||0!=r){const t=Math.sqrt(n*n+r*r);a.rotation=Math.PI/2-(r>0?Math.acos(-n/t):-Math.acos(n/t)),a.scaleX=s/t,a.scaleY=t,a.skewX=0,a.skewY=(e*n+i*r)/s}return a.rotation=t.Util._getRotation(a.rotation),a}}t.Transform=i;const n=Math.PI/180,r=180/Math.PI,s="Konva error: ",a={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},o=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let h=[];const l="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};t.Util={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){h.push(t),1===h.length&&l((function(){const t=h;h=[],t.forEach((function(t){t()}))}))},createCanvasElement(){const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(e,i){const n=t.Util.createImageElement();n.onload=function(){i(n)},n.src=e},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return"#"+t},getRGB(t){let e;return t in a?(e=a[t],{r:e[0],g:e[1],b:e[2]}):"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=o.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",t.Util._namedColorToRBA(e)||t.Util._hex3ColorToRGBA(e)||t.Util._hex4ColorToRGBA(e)||t.Util._hex6ColorToRGBA(e)||t.Util._hex8ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)),_namedColorToRBA(t){const e=a[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map(((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t)));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),n=Number(i[0])/360,r=Number(i[1])/100,s=Number(i[2])/100;let a,o,h;if(0===r)return h=255*s,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};a=s<.5?s*(1+r):s+r-s*r;const l=2*s-a,c=[0,0,0];for(let t=0;t<3;t++)o=n+1/3*-(t-1),o<0&&o++,o>1&&o--,h=6*o<1?l+6*(a-l)*o:2*o<1?a:3*o<2?l+(a-l)*(2/3-o)*6:l,c[t]=255*h;return{r:Math.round(c[0]),g:Math.round(c[1]),b:Math.round(c[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){const e={};for(const i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*n,radToDeg:t=>t*r,_degToRad:e=>(t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),t.Util.degToRad(e)),_radToDeg:e=>(t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),t.Util.radToDeg(e)),_getRotation:i=>e.Konva.angleDeg?t.Util.radToDeg(i):i,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(s+t)},error(t){console.error(s+t)},warn(t){e.Konva.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,n,r,s){let a,o,h;const l=(t-i)*(t-i)+(e-n)*(e-n);if(0==l)a=t,o=e,h=(r-i)*(r-i)+(s-n)*(s-n);else{const c=((r-t)*(i-t)+(s-e)*(n-e))/l;c<0?(a=t,o=e,h=(t-r)*(t-r)+(e-s)*(e-s)):c>1?(a=i,o=n,h=(i-r)*(i-r)+(n-s)*(n-s)):(a=t+c*(i-t),o=e+c*(n-e),h=(a-r)*(a-r)+(o-s)*(o-s))}return[a,o,h]},_getProjectionToLine(e,i,n){const r=t.Util.cloneObject(e);let s=Number.MAX_VALUE;return i.forEach((function(a,o){if(!n&&o===i.length-1)return;const h=i[(o+1)%i.length],l=t.Util._getProjectionToSegment(a.x,a.y,h.x,h.y,e.x,e.y),c=l[0],d=l[1],u=l[2];u<s&&(r.x=c,r.y=d,s=u)})),r},_prepareArrayForTween(e,i,n){const r=[],s=[];if(e.length>i.length){const t=i;i=e,e=t}for(let t=0;t<e.length;t+=2)r.push({x:e[t],y:e[t+1]});for(let t=0;t<i.length;t+=2)s.push({x:i[t],y:i[t+1]});const a=[];return s.forEach((function(e){const i=t.Util._getProjectionToLine(e,r,n);a.push(i.x),a.push(i.y)})),a},_prepareToStringify(e){let i;e.visitedByCircularReferenceRemoval=!0;for(const n in e)if(e.hasOwnProperty(n)&&e[n]&&"object"==typeof e[n])if(i=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||t.Util._isElement(e[n])){if(!i.configurable)return null;delete e[n]}else if(null===t.Util._prepareToStringify(e[n])){if(!i.configurable)return null;delete e[n]}return delete e.visitedByCircularReferenceRemoval,e},_assign(t,e){for(const i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){e.Konva.releaseCanvasOnDestroy&&t.forEach((t=>{t.width=0,t.height=0}))},drawRoundedRectPath(t,e,i,n){let r=0,s=0,a=0,o=0;"number"==typeof n?r=s=a=o=Math.min(n,e/2,i/2):(r=Math.min(n[0]||0,e/2,i/2),s=Math.min(n[1]||0,e/2,i/2),o=Math.min(n[2]||0,e/2,i/2),a=Math.min(n[3]||0,e/2,i/2)),t.moveTo(r,0),t.lineTo(e-s,0),t.arc(e-s,s,s,3*Math.PI/2,0,!1),t.lineTo(e,i-o),t.arc(e-o,i-o,o,0,Math.PI/2,!1),t.lineTo(a,i),t.arc(a,i-a,a,Math.PI/2,Math.PI,!1),t.lineTo(0,r),t.arc(r,r,r,Math.PI,3*Math.PI/2,!1)}}}(Ng)),Ng}var Fg,kg,Bg={},zg={},Gg={};function Hg(){if(Fg)return Gg;Fg=1,Object.defineProperty(Gg,"__esModule",{value:!0}),Gg.RGBComponent=function(t){if(t>255)return 255;if(t<0)return 0;return Math.round(t)},Gg.alphaComponent=function(t){if(t>1)return 1;if(t<1e-4)return 1e-4;return t},Gg.getNumberValidator=function(){if(t.Konva.isUnminified)return function(t,n){return e.Util._isNumber(t)||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a number.'),t}},Gg.getNumberOrArrayOfNumbersValidator=function(n){if(t.Konva.isUnminified)return function(t,r){let s=e.Util._isNumber(t),a=e.Util._isArray(t)&&t.length==n;return s||a||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a number or Array<number>('+n+")"),t}},Gg.getNumberOrAutoValidator=function(){if(t.Konva.isUnminified)return function(t,n){return e.Util._isNumber(t)||"auto"===t||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or "auto".'),t}},Gg.getStringValidator=function(){if(t.Konva.isUnminified)return function(t,n){return e.Util._isString(t)||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a string.'),t}},Gg.getStringOrGradientValidator=function(){if(t.Konva.isUnminified)return function(t,n){const r=e.Util._isString(t),s="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return r||s||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a string or a native gradient.'),t}},Gg.getFunctionValidator=function(){if(t.Konva.isUnminified)return function(t,n){return e.Util._isFunction(t)||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a function.'),t}},Gg.getNumberArrayValidator=function(){if(t.Konva.isUnminified)return function(t,n){const r=Int8Array?Object.getPrototypeOf(Int8Array):null;return r&&t instanceof r||(e.Util._isArray(t)?t.forEach((function(t){e.Util._isNumber(t)||e.Util.warn('"'+n+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a array of numbers.')),t}},Gg.getBooleanValidator=function(){if(t.Konva.isUnminified)return function(t,n){return!0===t||!1===t||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a boolean.'),t}},Gg.getComponentValidator=function(n){if(t.Konva.isUnminified)return function(t,r){return null==t||e.Util.isObject(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be an object with properties '+n),t}};const t=Dg(),e=Ug();function i(t){return e.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||e.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}return Gg}function Vg(){return kg||(kg=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=Ug(),i=Hg(),n="get",r="set";t.Factory={addGetterSetter(e,i,n,r,s){t.Factory.addGetter(e,i,n),t.Factory.addSetter(e,i,r,s),t.Factory.addOverloadedGetterSetter(e,i)},addGetter(t,i,r){var s=n+e.Util._capitalize(i);t.prototype[s]=t.prototype[s]||function(){const t=this.attrs[i];return void 0===t?r:t}},addSetter(i,n,s,a){var o=r+e.Util._capitalize(n);i.prototype[o]||t.Factory.overWriteSetter(i,n,s,a)},overWriteSetter(t,i,n,s){var a=r+e.Util._capitalize(i);t.prototype[a]=function(t){return n&&null!=t&&(t=n.call(this,t,i)),this._setAttr(i,t),s&&s.call(this),this}},addComponentsGetterSetter(s,a,o,h,l){const c=o.length,d=e.Util._capitalize,u=n+d(a),p=r+d(a);s.prototype[u]=function(){const t={};for(let e=0;e<c;e++){const i=o[e];t[i]=this.getAttr(a+d(i))}return t};const m=(0,i.getComponentValidator)(o);s.prototype[p]=function(t){const e=this.attrs[a];h&&(t=h.call(this,t,a)),m&&m.call(this,t,a);for(const e in t)t.hasOwnProperty(e)&&this._setAttr(a+d(e),t[e]);return t||o.forEach((t=>{this._setAttr(a+d(t),void 0)})),this._fireChangeEvent(a,e,t),l&&l.call(this),this},t.Factory.addOverloadedGetterSetter(s,a)},addOverloadedGetterSetter(t,i){var s=e.Util._capitalize(i),a=r+s,o=n+s;t.prototype[i]=function(){return arguments.length?(this[a](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(i,r,s,a){e.Util.error("Adding deprecated "+r);const o=n+e.Util._capitalize(r),h=r+" property is deprecated and will be removed soon. Look at Konva change log for more information.";i.prototype[o]=function(){e.Util.error(h);const t=this.attrs[r];return void 0===t?s:t},t.Factory.addSetter(i,r,a,(function(){e.Util.error(h)})),t.Factory.addOverloadedGetterSetter(i,r)},backCompat(t,i){e.Util.each(i,(function(i,s){const a=t.prototype[s],o=n+e.Util._capitalize(i),h=r+e.Util._capitalize(i);function l(){a.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+s+'" instead.')}t.prototype[i]=l,t.prototype[o]=l,t.prototype[h]=l}))},afterSetFilter(){this._filterUpToDate=!1}}}(zg)),zg}var Wg,jg,Xg={},Yg={};function qg(){if(Wg)return Yg;Wg=1,Object.defineProperty(Yg,"__esModule",{value:!0}),Yg.HitContext=Yg.SceneContext=Yg.Context=void 0;const t=Ug(),e=Dg();const i=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];let n=class{constructor(t){this.canvas=t,e.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(e,i){let n,r,s,a,o=this.traceArr,h=o.length,l="";for(n=0;n<h;n++)r=o[n],s=r.method,s?(a=r.args,l+=s,e?l+="()":t.Util._isArray(a[0])?l+="(["+a.join(",")+"])":(i&&(a=a.map((t=>"number"==typeof t?Math.floor(t):t))),l+="("+a.join(",")+")")):(l+=r.property,e||(l+="="+r.val)),l+=";";return l}clearTrace(){this.traceArr=[]}_trace(t){let e,i=this.traceArr;i.push(t),e=i.length,e>=100&&i.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,n,r,s){this._context.arc(t,e,i,n,r,s)}arcTo(t,e,i,n,r){this._context.arcTo(t,e,i,n,r)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,n,r,s){this._context.bezierCurveTo(t,e,i,n,r,s)}clearRect(t,e,i,n){this._context.clearRect(t,e,i,n)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,n){return this._context.createLinearGradient(t,e,i,n)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,n,r,s){return this._context.createRadialGradient(t,e,i,n,r,s)}drawImage(t,e,i,n,r,s,a,o,h){const l=arguments,c=this._context;3===l.length?c.drawImage(t,e,i):5===l.length?c.drawImage(t,e,i,n,r):9===l.length&&c.drawImage(t,e,i,n,r,s,a,o,h)}ellipse(t,e,i,n,r,s,a,o){this._context.ellipse(t,e,i,n,r,s,a,o)}isPointInPath(t,e,i,n){return i?this._context.isPointInPath(i,t,e,n):this._context.isPointInPath(t,e,n)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,n){this._context.fillRect(t,e,i,n)}strokeRect(t,e,i,n){this._context.strokeRect(t,e,i,n)}fillText(t,e,i,n){n?this._context.fillText(t,e,i,n):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,n){return this._context.getImageData(t,e,i,n)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,n){this._context.rect(t,e,i,n)}roundRect(t,e,i,n,r){this._context.roundRect(t,e,i,n,r)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,n){this._context.quadraticCurveTo(t,e,i,n)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,n,r,s){this._context.setTransform(t,e,i,n,r,s)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,n){this._context.strokeText(t,e,i,n)}transform(t,e,i,n,r,s){this._context.transform(t,e,i,n,r,s)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let e,n,r=this,s=i.length,a=this.setAttr;const o=function(e){let i,s=r[e];r[e]=function(){return n=function(e){const i=[],n=e.length,r=t.Util;for(let t=0;t<n;t++){let n=e[t];r._isNumber(n)?n=Math.round(1e3*n)/1e3:r._isString(n)||(n+=""),i.push(n)}return i}(Array.prototype.slice.call(arguments,0)),i=s.apply(r,arguments),r._trace({method:e,args:n}),i}};for(e=0;e<s;e++)o(i[e]);r.setAttr=function(){a.apply(r,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),r._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}};Yg.Context=n,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(n.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}));Yg.SceneContext=class extends n{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){const e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const n=t.getFillPatternImage();if(n&&"pattern"===i)return void this._fillPattern(t);const r=t.getFillLinearGradientColorStops();if(r&&"linear-gradient"===i)return void this._fillLinearGradient(t);const s=t.getFillRadialGradientColorStops();s&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):n?this._fillPattern(t):r?this._fillLinearGradient(t):s&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),n=t.getStrokeLinearGradientColorStops(),r=this.createLinearGradient(e.x,e.y,i.x,i.y);if(n){for(let t=0;t<n.length;t+=2)r.addColorStop(n[t],n[t+1]);this.setAttr("strokeStyle",r)}}_stroke(t){const e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,n;const r=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",s=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,a=null!==(n=t.getShadowOffset())&&void 0!==n?n:{x:0,y:0},o=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=o.x*h,c=o.y*h;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",s*Math.min(Math.abs(l),Math.abs(c))),this.setAttr("shadowOffsetX",a.x*l),this.setAttr("shadowOffsetY",a.y*c)}};return Yg.HitContext=class extends n{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const e=t.getStrokeScaleEnabled();if(!e){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t);const i=t.hitStrokeWidth(),n="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}},Yg}function Kg(){if(jg)return Xg;jg=1,Object.defineProperty(Xg,"__esModule",{value:!0}),Xg.HitCanvas=Xg.SceneCanvas=Xg.Canvas=void 0;const t=Ug(),e=qg(),i=Dg(),n=Vg(),r=Hg();let s;let a=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const n=(e||{}).pixelRatio||i.Konva.pixelRatio||function(){if(s)return s;const e=t.Util.createCanvasElement(),n=e.getContext("2d");return s=(i.Konva._global.devicePixelRatio||1)/(n.webkitBackingStorePixelRatio||n.mozBackingStorePixelRatio||n.msBackingStorePixelRatio||n.oBackingStorePixelRatio||n.backingStorePixelRatio||1),t.Util.releaseCanvas(e),s}();this.pixelRatio=n,this._canvas=t.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){const e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(e,i){try{return this._canvas.toDataURL(e,i)}catch(e){try{return this._canvas.toDataURL()}catch(e){return t.Util.error("Unable to get data URL. "+e.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}};Xg.Canvas=a,n.Factory.addGetterSetter(a,"pixelRatio",void 0,(0,r.getNumberValidator)());Xg.SceneCanvas=class extends a{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new e.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};return Xg.HitCanvas=class extends a{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new e.HitContext(this),this.setSize(t.width,t.height)}},Xg}var Zg,Jg,Qg={};function $g(){return Zg||(Zg=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=Dg(),i=Ug();t.DD={get isDragging(){let e=!1;return t.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){let e;return t.DD._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const n=[];t.DD._dragElements.forEach(((t,r)=>{const{node:s}=t,a=s.getStage();a.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=i.Util._getFirstPointerId(e));const o=a._changedPointerPositions.find((e=>e.id===t.pointerId));if(o){if("dragging"!==t.dragStatus){const i=s.dragDistance();if(Math.max(Math.abs(o.x-t.startPointerPos.x),Math.abs(o.y-t.startPointerPos.y))<i)return;if(s.startDrag({evt:e}),!s.isDragging())return}s._setDragPosition(e,t),n.push(s)}})),n.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(i){const n=[];t.DD._dragElements.forEach((r=>{const{node:s}=r,a=s.getStage();i&&a.setPointersPositions(i);if(!a._changedPointerPositions.find((t=>t.id===r.pointerId)))return;"dragging"!==r.dragStatus&&"stopped"!==r.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,r.dragStatus="stopped");const o=r.node.getLayer()||r.node instanceof e.Konva.Stage&&r.node;o&&-1===n.indexOf(o)&&n.push(o)})),n.forEach((t=>{t.draw()}))},_endDragAfter(e){t.DD._dragElements.forEach(((i,n)=>{"stopped"===i.dragStatus&&i.node.fire("dragend",{type:"dragend",target:i.node,evt:e},!0),"dragging"!==i.dragStatus&&t.DD._dragElements.delete(n)}))}},e.Konva.isBrowser&&(window.addEventListener("mouseup",t.DD._endDragBefore,!0),window.addEventListener("touchend",t.DD._endDragBefore,!0),window.addEventListener("touchcancel",t.DD._endDragBefore,!0),window.addEventListener("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1),window.addEventListener("touchcancel",t.DD._endDragAfter,!1))}(Qg)),Qg}function tv(){if(Jg)return Bg;Jg=1,Object.defineProperty(Bg,"__esModule",{value:!0}),Bg.Node=void 0;const t=Ug(),e=Vg(),i=Kg(),n=Dg(),r=$g(),s=Hg(),a="absoluteOpacity",o="allEventListeners",h="absoluteTransform",l="absoluteScale",c="canvas",d="listening",u="mouseenter",p="mouseleave",m="Shape",f=" ",g="stage",v="transform",_="visible",y=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(f);let x=1,b=class e{constructor(t){this._id=x++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==v&&t!==h||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let i=this._cache.get(t);return(void 0===i||(t===v||t===h)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map((t=>t+"Change.konva")).join(f);this.on(i,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(c)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===h&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(c)){const{scene:e,filter:i,hit:n}=this._cache.get(c);t.Util.releaseCanvas(e,i,n),this._cache.delete(c)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){const n=e||{};let r={};void 0!==n.x&&void 0!==n.y&&void 0!==n.width&&void 0!==n.height||(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let s=Math.ceil(n.width||r.width),o=Math.ceil(n.height||r.height),h=n.pixelRatio,d=void 0===n.x?Math.floor(r.x):n.x,u=void 0===n.y?Math.floor(r.y):n.y,p=n.offset||0,m=n.drawBorder||!1,f=n.hitCanvasPixelRatio||1;if(!s||!o)return void t.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");s+=2*p+(Math.abs(Math.round(r.x)-d)>.5?1:0),o+=2*p+(Math.abs(Math.round(r.y)-u)>.5?1:0),d-=p,u-=p;const g=new i.SceneCanvas({pixelRatio:h,width:s,height:o}),v=new i.SceneCanvas({pixelRatio:h,width:0,height:0,willReadFrequently:!0}),_=new i.HitCanvas({pixelRatio:f,width:s,height:o}),y=g.getContext(),x=_.getContext();return _.isCache=!0,g.isCache=!0,this._cache.delete(c),this._filterUpToDate=!1,!1===n.imageSmoothingEnabled&&(g.getContext()._context.imageSmoothingEnabled=!1,v.getContext()._context.imageSmoothingEnabled=!1),y.save(),x.save(),y.translate(-d,-u),x.translate(-d,-u),this._isUnderCache=!0,this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(l),this.drawScene(g,this),this.drawHit(_,this),this._isUnderCache=!1,y.restore(),x.restore(),m&&(y.save(),y.beginPath(),y.rect(0,0,s,o),y.closePath(),y.setAttr("strokeStyle","red"),y.setAttr("lineWidth",5),y.stroke(),y.restore()),this._cache.set(c,{scene:g,filter:v,hit:_,x:d,y:u}),this._requestDraw(),this}isCached(){return this._cache.has(c)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let n=1/0,r=1/0,s=-1/0,a=-1/0;const o=this.getAbsoluteTransform(e);return i.forEach((function(t){const e=o.point(t);void 0===n&&(n=s=e.x,r=a=e.y),n=Math.min(n,e.x),r=Math.min(r,e.y),s=Math.max(s,e.x),a=Math.max(a,e.y)})),{x:n,y:r,width:s-n,height:a-r}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const i=this._getCachedSceneCanvas(),n=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/n,i.height/n),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){let e,i,n,r,s=this.filters(),a=this._getCanvasCache(),o=a.scene,h=a.filter,l=h.getContext();if(s){if(!this._filterUpToDate){const a=o.pixelRatio;h.setSize(o.width/o.pixelRatio,o.height/o.pixelRatio);try{for(e=s.length,l.clear(),l.drawImage(o._canvas,0,0,o.getWidth()/a,o.getHeight()/a),i=l.getImageData(0,0,h.getWidth(),h.getHeight()),n=0;n<e;n++)r=s[n],"function"==typeof r?(r.call(this,i),l.putImageData(i,0,0)):t.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(e){t.Util.error("Unable to apply filter. "+e.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return h}return o}on(t,e){if(this._cache&&this._cache.delete(o),3===arguments.length)return this._delegate.apply(this,arguments);let i,n,r,s,a,h=t.split(f),l=h.length;for(i=0;i<l;i++)n=h[i],r=n.split("."),s=r[0],a=r[1]||"",this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:a,handler:e});return this}off(t,e){let i,n,r,s,a,h,l=(t||"").split(f),c=l.length;if(this._cache&&this._cache.delete(o),!t)for(n in this.eventListeners)this._off(n);for(i=0;i<c;i++)if(r=l[i],s=r.split("."),a=s[0],h=s[1],a)this.eventListeners[a]&&this._off(a,h,e);else for(n in this.eventListeners)this._off(n,h,e);return this}dispatchEvent(t){const e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,(function(t){e.call(this,t.evt)})),this}removeEventListener(t){return this.off(t),this}_delegate(e,i,n){const r=this;this.on(e,(function(e){const s=e.target.findAncestors(i,!0,r);for(let i=0;i<s.length;i++)(e=t.Util.cloneObject(e)).currentTarget=s[i],n.call(s[i],e)}))}remove(){return this.isDragging()&&this.stopDrag(),r.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(h),this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(g),this._clearSelfAndDescendantCache(_),this._clearSelfAndDescendantCache(d)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){const i="get"+t.Util._capitalize(e);return t.Util._isFunction(this[i])?this[i]():this.attrs[e]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges((()=>{let i,n;if(!e)return this;for(i in e)"children"!==i&&(n="set"+t.Util._capitalize(i),t.Util._isFunction(this[n])?this[n](e[i]):this._setAttr(i,e[i]))})),this}isListening(){return this._getCache(d,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(_,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const i=this.getLayer();let s=!1;r.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(s=!0)}));const a=!e&&!n.Konva.hitOnDragEnabled&&(s||n.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!a}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,n,r=this.getDepth(),s=this,a=0;const o=this.getStage();return"Stage"!==s.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)n=h[i],a++,n.nodeType!==m&&(t=t.concat(n.getChildren().slice())),n._id===s._id&&(i=e);t.length>0&&t[0].getDepth()<=r&&o(t)}(o.getChildren()),a}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(v),this._clearSelfAndDescendantCache(h)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges((()=>{this.x(t.x),this.y(t.y)})),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(e){let i=!1,n=this.parent;for(;n;){if(n.isCached()){i=!0;break}n=n.parent}i&&!e&&(e=!0);const r=this.getAbsoluteTransform(e).getMatrix(),s=new t.Transform,a=this.offset();return s.m=r.slice(),s.translate(a.x,a.y),s.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...n}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(v);const r=this._getAbsoluteTransform().copy();return r.invert(),r.translate(t.x,t.y),t={x:this.attrs.x+r.getTranslation().x,y:this.attrs.y+r.getTranslation().y},this._setTransform(n),this.setPosition({x:t.x,y:t.y}),this._clearCache(v),this._clearSelfAndDescendantCache(h),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,i=t.y,n=this.x(),r=this.y();return void 0!==e&&(n+=e),void 0!==i&&(r+=i),this.setPosition({x:n,y:r}),this}_eachAncestorReverse(t,e){let i,n,r=[],s=this.getParent();if(!e||e._id!==this._id){for(r.unshift(this);s&&(!e||s._id!==e._id);)r.unshift(s),s=s.parent;for(i=r.length,n=0;n<i;n++)t(r[n])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return t.Util.warn("Node has no parent. moveToTop function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return t.Util.warn("Node has no parent. moveUp function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return t.Util.warn("Node has no parent. moveDown function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return t.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return t.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&t.Util.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const i=this.index;return this.parent.children.splice(i,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(a,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let e,i,n,r,s,a=this.getAttrs();const o={attrs:{},className:this.getClassName()};for(e in a)i=a[e],s=t.Util.isObject(i)&&!t.Util._isPlainObject(i)&&!t.Util._isArray(i),s||(n="function"==typeof this[e]&&this[e],delete a[e],r=n?n.call(this):null,a[e]=i,r!==i&&(o.attrs[e]=i));return t.Util._prepareToStringify(o)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const n=[];e&&this._isMatch(t)&&n.push(this);let r=this.parent;for(;r;){if(r===i)return n;r._isMatch(t)&&n.push(r),r=r.parent}return n}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(e){if(!e)return!1;if("function"==typeof e)return e(this);let i,n,r=e.replace(/ /g,"").split(","),s=r.length;for(i=0;i<s;i++)if(n=r[i],t.Util.isValidSelector(n)||(t.Util.warn('Selector "'+n+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),t.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),t.Util.warn("Konva is awesome, right?")),"#"===n.charAt(0)){if(this.id()===n.slice(1))return!0}else if("."===n.charAt(0)){if(this.hasName(n.slice(1)))return!0}else if(this.className===n||this.nodeType===n)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(g,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(h,this._getAbsoluteTransform)}_getAbsoluteTransform(e){let i;if(e)return i=new t.Transform,this._eachAncestorReverse((function(t){const e=t.transformsEnabled();"all"===e?i.multiply(t.getTransform()):"position"===e&&i.translate(t.x()-t.offsetX(),t.y()-t.offsetY())}),e),i;{i=this._cache.get(h)||new t.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(i):i.reset();const e=this.transformsEnabled();if("all"===e)i.multiply(this.getTransform());else if("position"===e){const t=this.attrs.x||0,e=this.attrs.y||0,n=this.attrs.offsetX||0,r=this.attrs.offsetY||0;i.translate(t-n,e-r)}return i.dirty=!1,i}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(v,this._getTransform)}_getTransform(){var e,i;const r=this._cache.get(v)||new t.Transform;r.reset();const s=this.x(),a=this.y(),o=n.Konva.getAngle(this.rotation()),h=null!==(e=this.attrs.scaleX)&&void 0!==e?e:1,l=null!==(i=this.attrs.scaleY)&&void 0!==i?i:1,c=this.attrs.skewX||0,d=this.attrs.skewY||0,u=this.attrs.offsetX||0,p=this.attrs.offsetY||0;return 0===s&&0===a||r.translate(s,a),0!==o&&r.rotate(o),0===c&&0===d||r.skew(c,d),1===h&&1===l||r.scale(h,l),0===u&&0===p||r.translate(-1*u,-1*p),r.dirty=!1,r}clone(e){let i,n,r,s,a,o=t.Util.cloneObject(this.attrs);for(i in e)o[i]=e[i];const h=new this.constructor(o);for(i in this.eventListeners)for(n=this.eventListeners[i],r=n.length,s=0;s<r;s++)a=n[s],a.name.indexOf("konva")<0&&(h.eventListeners[i]||(h.eventListeners[i]=[]),h.eventListeners[i].push(a));return h}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),n=this.getStage(),r=void 0!==t.x?t.x:Math.floor(e.x),s=void 0!==t.y?t.y:Math.floor(e.y),a=t.pixelRatio||1,o=new i.SceneCanvas({width:t.width||Math.ceil(e.width)||(n?n.width():0),height:t.height||Math.ceil(e.height)||(n?n.height():0),pixelRatio:a}),h=o.getContext(),l=new i.SceneCanvas({width:o.width/o.pixelRatio+Math.abs(r),height:o.height/o.pixelRatio+Math.abs(s),pixelRatio:o.pixelRatio});return!1===t.imageSmoothingEnabled&&(h._context.imageSmoothingEnabled=!1),h.save(),(r||s)&&h.translate(-1*r,-1*s),this.drawScene(o,void 0,l),h.restore(),o}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,n=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(n),n}toImage(e){return new Promise(((i,n)=>{try{const n=null==e?void 0:e.callback;n&&delete e.callback,t.Util._urlToImage(this.toDataURL(e),(function(t){i(t),null==n||n(t)}))}catch(t){n(t)}}))}toBlob(t){return new Promise(((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob((t=>{e(t),null==i||i(t)}),null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}}))}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():n.Konva.dragDistance}_off(t,e,i){let n,r,s,a=this.eventListeners[t];for(n=0;n<a.length;n++)if(r=a[n].name,s=a[n].handler,!("konva"===r&&"konva"!==e||e&&r!==e||i&&i!==s)){if(a.splice(n,1),0===a.length){delete this.eventListeners[t];break}n--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){const e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();if(!e)return!1;return-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){const e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(e,i){const n=this["set"+t.Util._capitalize(e)];return t.Util._isFunction(n)?n.call(this,i):this._setAttr(e,i),this}_requestDraw(){if(n.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(e,i){const n=this.attrs[e];(n!==i||t.Util.isObject(i))&&(null==i?delete this.attrs[e]:this.attrs[e]=i,this._shouldFireChangeEvents&&this._fireChangeEvent(e,n,i),this._requestDraw())}_setComponentAttr(t,e,i){let n;void 0!==i&&(n=this.attrs[t],n||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,n,i))}_fireAndBubble(t,e,i){e&&this.nodeType===m&&(e.target=this);if(!((t===u||t===p)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const n=(t===u||t===p)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!n&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,n;const r=null!==(e=this._cache.get(o))&&void 0!==e?e:{};let s=null==r?void 0:r[t];if(void 0===s){s=[];let e=Object.getPrototypeOf(this);for(;e;){const r=null!==(n=null===(i=e.eventListeners)||void 0===i?void 0:i[t])&&void 0!==n?n:[];s.push(...r),e=Object.getPrototypeOf(e)}r[t]=s,this._cache.set(o,r)}return s}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(var n=0;n<i.length;n++)i[n].handler.call(this,e);const r=this.eventListeners[t];if(r)for(n=0;n<r.length;n++)r[n].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,i=this.getStage(),n=this.getAbsolutePosition();if(!i)return;const s=i._getPointerById(e)||i._changedPointerPositions[0]||n;r.DD._dragElements.set(this._id,{node:this,startPointerPos:s,offset:{x:s.x-n.x,y:s.y-n.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){r.DD._dragElements.has(this._id)||this._createDragElement(t);r.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(e,i){const n=this.getStage()._getPointerById(i.pointerId);if(!n)return;let r={x:n.x-i.offset.x,y:n.y-i.offset.y};const s=this.dragBoundFunc();if(void 0!==s){const i=s.call(this,r,e);i?r=i:t.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}stopDrag(t){const e=r.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),r.DD._endDragBefore(t),r.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=r.DD._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(t){if(!(!(void 0!==t.evt.button)||n.Konva.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;r.DD._dragElements.forEach((t=>{this.isAncestorOf(t.node)&&(e=!0)})),e||this._createDragElement(t)}))}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=r.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&r.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const i=this.getStage();if(!i)return!1;const n={x:-e.x,y:-e.y,width:i.width()+2*e.x,height:i.height()+2*e.y};return t.Util.haveIntersection(n,this.getClientRect())}static create(e,i){return t.Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,i)}static _createNode(i,r){let s,a,o,h=e.prototype.getClassName.call(i),l=i.children;r&&(i.attrs.container=r),n.Konva[h]||(t.Util.warn('Can not find a node with class name "'+h+'". Fallback to "Shape".'),h="Shape");if(s=new(0,n.Konva[h])(i.attrs),l)for(a=l.length,o=0;o<a;o++)s.add(e._createNode(l[o]));return s}};Bg.Node=b,b.prototype.nodeType="Node",b.prototype._attrsAffectingSize=[],b.prototype.eventListeners={},b.prototype.on.call(b.prototype,y,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(v),this._clearSelfAndDescendantCache(h))})),b.prototype.on.call(b.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(_)})),b.prototype.on.call(b.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(d)})),b.prototype.on.call(b.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(a)}));const w=e.Factory.addGetterSetter;return w(b,"zIndex"),w(b,"absolutePosition"),w(b,"position"),w(b,"x",0,(0,s.getNumberValidator)()),w(b,"y",0,(0,s.getNumberValidator)()),w(b,"globalCompositeOperation","source-over",(0,s.getStringValidator)()),w(b,"opacity",1,(0,s.getNumberValidator)()),w(b,"name","",(0,s.getStringValidator)()),w(b,"id","",(0,s.getStringValidator)()),w(b,"rotation",0,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(b,"scale",["x","y"]),w(b,"scaleX",1,(0,s.getNumberValidator)()),w(b,"scaleY",1,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(b,"skew",["x","y"]),w(b,"skewX",0,(0,s.getNumberValidator)()),w(b,"skewY",0,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(b,"offset",["x","y"]),w(b,"offsetX",0,(0,s.getNumberValidator)()),w(b,"offsetY",0,(0,s.getNumberValidator)()),w(b,"dragDistance",void 0,(0,s.getNumberValidator)()),w(b,"width",0,(0,s.getNumberValidator)()),w(b,"height",0,(0,s.getNumberValidator)()),w(b,"listening",!0,(0,s.getBooleanValidator)()),w(b,"preventDefault",!0,(0,s.getBooleanValidator)()),w(b,"filters",void 0,(function(t){return this._filterUpToDate=!1,t})),w(b,"visible",!0,(0,s.getBooleanValidator)()),w(b,"transformsEnabled","all",(0,s.getStringValidator)()),w(b,"size"),w(b,"dragBoundFunc"),w(b,"draggable",!1,(0,s.getBooleanValidator)()),e.Factory.backCompat(b,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"}),Bg}var ev,iv={};function nv(){if(ev)return iv;ev=1,Object.defineProperty(iv,"__esModule",{value:!0}),iv.Container=void 0;const t=Vg(),e=tv(),i=Hg();let n=class extends e.Node{constructor(){super(...arguments),this.children=[]}getChildren(t){if(!t)return this.children||[];const e=this.children||[],i=[];return e.forEach((function(e){t(e)&&i.push(e)})),i}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.remove()})),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.destroy()})),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e<t.length;e++)this.add(t[e]);return this}const e=t[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){const e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){const i=[];return this._descendants((n=>{const r=n._isMatch(t);return r&&i.push(n),!(!r||!e)})),i}_descendants(t){let e=!1;const i=this.getChildren();for(const n of i){if(e=t(n),e)return!0;if(n.hasChildren()&&(e=n._descendants(t),e))return!0}return!1}toObject(){const t=e.Node.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach((e=>{t.children.push(e.toObject())})),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const i=e.Node.prototype.clone.call(this,t);return this.getChildren().forEach((function(t){i.add(t.clone())})),i}getAllIntersections(t){const e=[];return this.find("Shape").forEach((i=>{i.isVisible()&&i.intersects(t)&&e.push(i)})),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach((function(e){e._clearSelfAndDescendantCache(t)}))}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach((function(t,e){t.index=e})),this._requestDraw()}drawScene(t,e,i){const n=this.getLayer(),r=t||n&&n.getCanvas(),s=r&&r.getContext(),a=this._getCanvasCache(),o=a&&a.scene,h=r&&r.isCache;if(!this.isVisible()&&!h)return this;if(o){s.save();const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(s),s.restore()}else this._drawChildren("drawScene",r,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),n=t||i&&i.hitCanvas,r=n&&n.getContext(),s=this._getCanvasCache();if(s&&s.hit){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(r),r.restore()}else this._drawChildren("drawHit",n,e);return this}_drawChildren(t,e,i,n){var r;const s=e&&e.getContext(),a=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l="number"==typeof a&&"number"==typeof o||h,c=i===this;if(l){s.save();const t=this.getAbsoluteTransform(i);let e,n=t.getMatrix();if(s.transform(n[0],n[1],n[2],n[3],n[4],n[5]),s.beginPath(),h)e=h.call(this,s,this);else{const t=this.clipX(),e=this.clipY();s.rect(t||0,e||0,a,o)}s.clip.apply(s,e),n=t.copy().invert().getMatrix(),s.transform(n[0],n[1],n[2],n[3],n[4],n[5])}const d=!c&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;d&&(s.save(),s._applyGlobalCompositeOperation(this)),null===(r=this.children)||void 0===r||r.forEach((function(r){r[t](e,i,n)})),d&&s.restore(),l&&s.restore()}getClientRect(t={}){var e;const i=t.skipTransform,n=t.relativeTo;let r,s,a,o,h={x:1/0,y:1/0,width:0,height:0};const l=this;null===(e=this.children)||void 0===e||e.forEach((function(e){if(!e.visible())return;const i=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===i.width&&0===i.height||(void 0===r?(r=i.x,s=i.y,a=i.x+i.width,o=i.y+i.height):(r=Math.min(r,i.x),s=Math.min(s,i.y),a=Math.max(a,i.x+i.width),o=Math.max(o,i.y+i.height)))}));const c=this.find("Shape");let d=!1;for(let t=0;t<c.length;t++){if(c[t]._isVisible(this)){d=!0;break}}return h=d&&void 0!==r?{x:r,y:s,width:a-r,height:o-s}:{x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,n)}};return iv.Container=n,t.Factory.addComponentsGetterSetter(n,"clip",["x","y","width","height"]),t.Factory.addGetterSetter(n,"clipX",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"clipY",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"clipWidth",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"clipHeight",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"clipFunc"),iv}var rv,sv,av={},ov={};function hv(){if(rv)return ov;rv=1,Object.defineProperty(ov,"__esModule",{value:!0}),ov.getCapturedShape=function(t){return e.get(t)},ov.createEvent=n,ov.hasPointerCapture=function(t,i){return e.get(t)===i},ov.setPointerCapture=function(t,s){r(t);if(!s.getStage())return;e.set(t,s),i&&s._fire("gotpointercapture",n(new PointerEvent("gotpointercapture")))},ov.releaseCapture=r;const t=Dg(),e=new Map,i=void 0!==t.Konva._global.PointerEvent;function n(t){return{evt:t,pointerId:t.pointerId}}function r(t,r){const s=e.get(t);if(!s)return;const a=s.getStage();a&&a.content,e.delete(t),i&&s._fire("lostpointercapture",n(new PointerEvent("lostpointercapture")))}return ov}var lv,cv,dv={},uv={};function pv(){return lv||(lv=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=Dg(),i=Ug(),n=Vg(),r=tv(),s=Hg(),a=Dg(),o=hv(),h="hasShadow",l="shadowRGBA",c="patternImage",d="linearGradient",u="radialGradient";let p;function m(){return p||(p=i.Util.createCanvasElement().getContext("2d"),p)}t.shapes={};class f extends r.Node{constructor(e){let n;for(super(e);n=i.Util.getRandomColor(),!n||n in t.shapes;);this.colorKey=n,t.shapes[n]=this}getContext(){return i.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return i.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(h,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(c,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=m().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const n=new i.Transform;n.translate(this.fillPatternX(),this.fillPatternY()),n.rotate(e.Konva.getAngle(this.fillPatternRotation())),n.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),n.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const r=n.getMatrix(),s="undefined"==typeof DOMMatrix?{a:r[0],b:r[1],c:r[2],d:r[3],e:r[4],f:r[5]}:new DOMMatrix(r);t.setTransform(s)}return t}}_getLinearGradient(){return this._getCache(d,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=m(),i=this.fillLinearGradientStartPoint(),n=this.fillLinearGradientEndPoint(),r=e.createLinearGradient(i.x,i.y,n.x,n.y);for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}_getRadialGradient(){return this._getCache(u,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=m(),i=this.fillRadialGradientStartPoint(),n=this.fillRadialGradientEndPoint(),r=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),n.x,n.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}getShadowRGBA(){return this._getCache(l,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=i.Util.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return r.Node.prototype.destroy.call(this),delete t.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),n=this.hasStroke(),r=1!==this.getAbsoluteOpacity();if(i&&n&&r)return!0;const s=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(i&&n&&s&&a)}setStrokeHitEnabled(t){i.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const n=t.skipTransform,r=t.relativeTo||e&&this.getStage()||void 0,s=this.getSelfRect(),a=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=s.width+a,h=s.height+a,l=!t.skipShadow&&this.hasShadow(),c=l?this.shadowOffsetX():0,d=l?this.shadowOffsetY():0,u=o+Math.abs(c),p=h+Math.abs(d),m=l&&this.shadowBlur()||0,f={width:u+2*m,height:p+2*m,x:-(a/2+m)+Math.min(c,0)+s.x,y:-(a/2+m)+Math.min(d,0)+s.y};return n?f:this._transformedRect(f,r)}drawScene(t,e,i){const n=this.getLayer();let r,s,a=t||n.getCanvas(),o=a.getContext(),h=this._getCanvasCache(),l=this.getSceneFunc(),c=this.hasShadow();const d=a.isCache,u=e===this;if(!this.isVisible()&&!u)return this;if(h){o.save();const t=this.getAbsoluteTransform(e).getMatrix();return o.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!l)return this;if(o.save(),this._useBufferCanvas()&&!d){r=this.getStage();const t=i||r.bufferCanvas;s=t.getContext(),s.clear(),s.save(),s._applyLineJoin(this);var p=this.getAbsoluteTransform(e).getMatrix();s.transform(p[0],p[1],p[2],p[3],p[4],p[5]),l.call(this,s,this),s.restore();const n=t.pixelRatio;c&&o._applyShadow(this),o._applyOpacity(this),o._applyGlobalCompositeOperation(this),o.drawImage(t._canvas,0,0,t.width/n,t.height/n)}else{if(o._applyLineJoin(this),!u){p=this.getAbsoluteTransform(e).getMatrix();o.transform(p[0],p[1],p[2],p[3],p[4],p[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}c&&o._applyShadow(this),l.call(this,o,this)}return o.restore(),this}drawHit(t,e,n=!1){if(!this.shouldDrawHit(e,n))return this;const r=this.getLayer(),s=t||r.hitCanvas,a=s&&s.getContext(),o=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),l=h&&h.hit;if(this.colorKey||i.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){a.save();const t=this.getAbsoluteTransform(e).getMatrix();return a.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!o)return this;a.save(),a._applyLineJoin(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();a.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return o.call(this,a,this),a.restore(),this}drawHitFromCache(t=0){const e=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=e.hit,s=r.getContext(),a=r.getWidth(),o=r.getHeight();s.clear(),s.drawImage(n._canvas,0,0,a,o);try{const e=s.getImageData(0,0,a,o),n=e.data,r=n.length,h=i.Util._hexToRgb(this.colorKey);for(let e=0;e<r;e+=4){n[e+3]>t?(n[e]=h.r,n[e+1]=h.g,n[e+2]=h.b,n[e+3]=255):n[e+3]=0}s.putImageData(e,0,0)}catch(t){i.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return o.hasPointerCapture(t,this)}setPointerCapture(t){o.setPointerCapture(t,this)}releaseCapture(t){o.releaseCapture(t,this)}}t.Shape=f,f.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},f.prototype._strokeFunc=function(t){t.stroke()},f.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},f.prototype._strokeFuncHit=function(t){t.stroke()},f.prototype._centroid=!1,f.prototype.nodeType="Shape",(0,a._registerNode)(f),f.prototype.eventListeners={},f.prototype.on.call(f.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(h)})),f.prototype.on.call(f.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(l)})),f.prototype.on.call(f.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(c)})),f.prototype.on.call(f.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(d)})),f.prototype.on.call(f.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(u)})),n.Factory.addGetterSetter(f,"stroke",void 0,(0,s.getStringOrGradientValidator)()),n.Factory.addGetterSetter(f,"strokeWidth",2,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"fillAfterStrokeEnabled",!1),n.Factory.addGetterSetter(f,"hitStrokeWidth","auto",(0,s.getNumberOrAutoValidator)()),n.Factory.addGetterSetter(f,"strokeHitEnabled",!0,(0,s.getBooleanValidator)()),n.Factory.addGetterSetter(f,"perfectDrawEnabled",!0,(0,s.getBooleanValidator)()),n.Factory.addGetterSetter(f,"shadowForStrokeEnabled",!0,(0,s.getBooleanValidator)()),n.Factory.addGetterSetter(f,"lineJoin"),n.Factory.addGetterSetter(f,"lineCap"),n.Factory.addGetterSetter(f,"sceneFunc"),n.Factory.addGetterSetter(f,"hitFunc"),n.Factory.addGetterSetter(f,"dash"),n.Factory.addGetterSetter(f,"dashOffset",0,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"shadowColor",void 0,(0,s.getStringValidator)()),n.Factory.addGetterSetter(f,"shadowBlur",0,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"shadowOpacity",1,(0,s.getNumberValidator)()),n.Factory.addComponentsGetterSetter(f,"shadowOffset",["x","y"]),n.Factory.addGetterSetter(f,"shadowOffsetX",0,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"shadowOffsetY",0,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"fillPatternImage"),n.Factory.addGetterSetter(f,"fill",void 0,(0,s.getStringOrGradientValidator)()),n.Factory.addGetterSetter(f,"fillPatternX",0,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"fillPatternY",0,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"fillLinearGradientColorStops"),n.Factory.addGetterSetter(f,"strokeLinearGradientColorStops"),n.Factory.addGetterSetter(f,"fillRadialGradientStartRadius",0),n.Factory.addGetterSetter(f,"fillRadialGradientEndRadius",0),n.Factory.addGetterSetter(f,"fillRadialGradientColorStops"),n.Factory.addGetterSetter(f,"fillPatternRepeat","repeat"),n.Factory.addGetterSetter(f,"fillEnabled",!0),n.Factory.addGetterSetter(f,"strokeEnabled",!0),n.Factory.addGetterSetter(f,"shadowEnabled",!0),n.Factory.addGetterSetter(f,"dashEnabled",!0),n.Factory.addGetterSetter(f,"strokeScaleEnabled",!0),n.Factory.addGetterSetter(f,"fillPriority","color"),n.Factory.addComponentsGetterSetter(f,"fillPatternOffset",["x","y"]),n.Factory.addGetterSetter(f,"fillPatternOffsetX",0,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"fillPatternOffsetY",0,(0,s.getNumberValidator)()),n.Factory.addComponentsGetterSetter(f,"fillPatternScale",["x","y"]),n.Factory.addGetterSetter(f,"fillPatternScaleX",1,(0,s.getNumberValidator)()),n.Factory.addGetterSetter(f,"fillPatternScaleY",1,(0,s.getNumberValidator)()),n.Factory.addComponentsGetterSetter(f,"fillLinearGradientStartPoint",["x","y"]),n.Factory.addComponentsGetterSetter(f,"strokeLinearGradientStartPoint",["x","y"]),n.Factory.addGetterSetter(f,"fillLinearGradientStartPointX",0),n.Factory.addGetterSetter(f,"strokeLinearGradientStartPointX",0),n.Factory.addGetterSetter(f,"fillLinearGradientStartPointY",0),n.Factory.addGetterSetter(f,"strokeLinearGradientStartPointY",0),n.Factory.addComponentsGetterSetter(f,"fillLinearGradientEndPoint",["x","y"]),n.Factory.addComponentsGetterSetter(f,"strokeLinearGradientEndPoint",["x","y"]),n.Factory.addGetterSetter(f,"fillLinearGradientEndPointX",0),n.Factory.addGetterSetter(f,"strokeLinearGradientEndPointX",0),n.Factory.addGetterSetter(f,"fillLinearGradientEndPointY",0),n.Factory.addGetterSetter(f,"strokeLinearGradientEndPointY",0),n.Factory.addComponentsGetterSetter(f,"fillRadialGradientStartPoint",["x","y"]),n.Factory.addGetterSetter(f,"fillRadialGradientStartPointX",0),n.Factory.addGetterSetter(f,"fillRadialGradientStartPointY",0),n.Factory.addComponentsGetterSetter(f,"fillRadialGradientEndPoint",["x","y"]),n.Factory.addGetterSetter(f,"fillRadialGradientEndPointX",0),n.Factory.addGetterSetter(f,"fillRadialGradientEndPointY",0),n.Factory.addGetterSetter(f,"fillPatternRotation",0),n.Factory.addGetterSetter(f,"fillRule",void 0,(0,s.getStringValidator)()),n.Factory.backCompat(f,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})}(uv)),uv}function mv(){if(cv)return dv;cv=1,Object.defineProperty(dv,"__esModule",{value:!0}),dv.Layer=void 0;const t=Ug(),e=nv(),i=tv(),n=Vg(),r=Kg(),s=Hg(),a=pv(),o=Dg(),h=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],l=h.length;let c=class extends e.Container{constructor(t){super(t),this.canvas=new r.SceneCanvas,this.hitCanvas=new r.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){i.Node.prototype.moveToTop.call(this);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!i.Node.prototype.moveUp.call(this))return!1;const t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(i.Node.prototype.moveDown.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(i.Node.prototype.moveToBottom.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const e=this.getNativeCanvasElement();return i.Node.prototype.remove.call(this),e&&e.parentNode&&t.Util._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(e){const i=e.getType();"Group"!==i&&"Shape"!==i&&t.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t=t||{}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),i.Node.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){t.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){t.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,t.Util.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,i=!1;for(;;){for(let n=0;n<l;n++){const r=h[n],s=this._getIntersection({x:t.x+r.x*e,y:t.y+r.y*e}),a=s.shape;if(a)return a;if(i=!!s.antialiased,!s.antialiased)break}if(!i)return null;e+=1}}_getIntersection(e){const i=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*i),Math.round(e.y*i),1,1).data,r=n[3];if(255===r){const e=t.Util._rgbToHex(n[0],n[1],n[2]),i=a.shapes["#"+e];return i?{shape:i}:{antialiased:!0}}return r>0?{antialiased:!0}:{}}drawScene(t,i){const n=this.getLayer(),r=t||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),e.Container.prototype.drawScene.call(this,r,i),this._fire("draw",{node:this}),this}drawHit(t,i){const n=this.getLayer(),r=t||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),e.Container.prototype.drawHit.call(this,r,i),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return t.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};return dv.Layer=c,c.prototype.nodeType="Layer",(0,o._registerNode)(c),n.Factory.addGetterSetter(c,"imageSmoothingEnabled",!0),n.Factory.addGetterSetter(c,"clearBeforeDraw",!0),n.Factory.addGetterSetter(c,"hitGraphEnabled",!0,(0,s.getBooleanValidator)()),dv}var fv,gv={};var vv,_v={};function yv(){if(vv)return _v;vv=1,Object.defineProperty(_v,"__esModule",{value:!0}),_v.Group=void 0;const t=Ug(),e=nv(),i=Dg();let n=class extends e.Container{_validateAdd(e){const i=e.getType();"Group"!==i&&"Shape"!==i&&t.Util.throw("You may only add groups and shapes to groups.")}};return _v.Group=n,n.prototype.nodeType="Group",(0,i._registerNode)(n),_v}var xv,bv={};function wv(){if(xv)return bv;xv=1,Object.defineProperty(bv,"__esModule",{value:!0}),bv.Animation=void 0;const t=Dg(),e=Ug(),i=t.glob.performance&&t.glob.performance.now?function(){return t.glob.performance.now()}:function(){return(new Date).getTime()};let n=class t{constructor(e,n){this.id=t.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:i(),frameRate:0},this.func=e,this.setLayers(n)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let n=0;n<i;n++)if(e[n]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const e=t.animations,i=e.length;for(let t=0;t<i;t++)if(e[t].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=i(),t._addAnimation(this),this}stop(){return t._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,n=i.length;for(let t=0;t<n;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let n=0;n<e.length;n++){const r=e[n],s=r.layers,a=r.func;r._updateFrameObject(i());const o=s.length;let h;if(h=!a||!1!==a.call(r,r.frame),h)for(let e=0;e<o;e++){const i=s[e];void 0!==i._id&&(t[i._id]=i)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const i=t;i.animations.length?(i._runFrames(),e.Util.requestAnimFrame(i._animationLoop)):i.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,e.Util.requestAnimFrame(this._animationLoop))}};return bv.Animation=n,n.animations=[],n.animIdCounter=0,n.animRunning=!1,bv}var Sv,Mv,Tv={};function Ev(){return Mv||(Mv=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=Dg(),i=Ug(),n=tv(),r=nv(),s=(sv||(sv=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=Ug(),i=Vg(),n=nv(),r=Dg(),s=Kg(),a=$g(),o=Dg(),h=hv(),l="mouseleave",c="mouseover",d="mouseenter",u="mousemove",p="mousedown",m="mouseup",f="pointermove",g="pointerdown",v="pointerup",_="pointercancel",y="pointerout",x="pointerleave",b="pointerover",w="pointerenter",S="contextmenu",M="touchstart",T="touchend",E="touchmove",A="touchcancel",C="wheel",R=[[d,"_pointerenter"],[p,"_pointerdown"],[u,"_pointermove"],[m,"_pointerup"],[l,"_pointerleave"],[M,"_pointerdown"],[E,"_pointermove"],[T,"_pointerup"],[A,"_pointercancel"],[c,"_pointerover"],[C,"_wheel"],[S,"_contextmenu"],[g,"_pointerdown"],[f,"_pointermove"],[v,"_pointerup"],[_,"_pointercancel"],["lostpointercapture","_lostpointercapture"]],P={mouse:{[y]:"mouseout",[x]:l,[b]:c,[w]:d,[f]:u,[g]:p,[v]:m,[_]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[y]:"touchout",[x]:"touchleave",[b]:"touchover",[w]:"touchenter",[f]:E,[g]:M,[v]:T,[_]:A,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[y]:y,[x]:x,[b]:b,[w]:w,[f]:f,[g]:g,[v]:v,[_]:_,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},L=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",I=t=>{const e=L(t);return"pointer"===e?r.Konva.pointerEventsEnabled&&P.pointer:"touch"===e?P.touch:"mouse"===e?P.mouse:void 0};function D(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}t.stages=[];class O extends n.Container{constructor(e){super(D(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),t.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{D(this.attrs)})),this._checkVisibility()}_validateAdd(t){const i="Layer"===t.getType(),n="FastLayer"===t.getType();i||n||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else{var e;e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e)}if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const t=this.children,e=t.length;for(let i=0;i<e;i++)t[i].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),n.Container.prototype.clone.call(this,t)}destroy(){super.destroy();const i=this.content;i&&e.Util._isInDocument(i)&&this.container().removeChild(i);const n=t.stages.indexOf(this);return n>-1&&t.stages.splice(n,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(e.Util.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find((e=>e.id===t))}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t=t||{}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new s.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,n=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),n.forEach((function(e){if(!e.isVisible())return;const n=e._toKonvaCanvas(t);i.drawImage(n._canvas,t.x,t.y,n.getWidth()/n.getPixelRatio(),n.getHeight()/n.getPixelRatio())})),e}getIntersection(t){if(!t)return null;const e=this.children;for(let i=e.length-1;i>=0;i--){const n=e[i].getIntersection(t);if(n)return n}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach((i=>{i.setSize({width:t,height:e}),i.draw()}))}add(t,...i){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const n=this.children.length;return n>5&&e.Util.warn("The stage has "+n+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),r.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return h.hasPointerCapture(t,this)}setPointerCapture(t){h.setPointerCapture(t,this)}releaseCapture(t){h.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){r.Konva.isBrowser&&R.forEach((([t,e])=>{this.content.addEventListener(t,(t=>{this[e](t)}),{passive:!1})}))}_pointerenter(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=I(t.type),i=L(t.type);if(!e)return;this.setPointersPositions(t);const n=this._getTargetShape(i),s=!(r.Konva.isDragging()||r.Konva.isTransforming())||r.Konva.hitOnDragEnabled;n&&s?(n._fireAndBubble(e.pointerout,{evt:t}),n._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):s&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=I(t.type),i=L(t.type);if(!e)return;this.setPointersPositions(t);let n=!1;this._changedPointerPositions.forEach((s=>{const o=this.getIntersection(s);if(a.DD.justDragged=!1,r.Konva["_"+i+"ListenClick"]=!0,!o||!o.isListening())return void(this[i+"ClickStartShape"]=void 0);r.Konva.capturePointerEventsEnabled&&o.setPointerCapture(s.id),this[i+"ClickStartShape"]=o,o._fireAndBubble(e.pointerdown,{evt:t,pointerId:s.id}),n=!0;const h=t.type.indexOf("touch")>=0;o.preventDefault()&&t.cancelable&&h&&t.preventDefault()})),n||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=I(t.type),i=L(t.type);if(!e)return;if(r.Konva.isDragging()&&a.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),(r.Konva.isDragging()||r.Konva.isTransforming())&&!r.Konva.hitOnDragEnabled)return;const n={};let s=!1;const o=this._getTargetShape(i);this._changedPointerPositions.forEach((r=>{const a=h.getCapturedShape(r.id)||this.getIntersection(r),l=r.id,c={evt:t,pointerId:l},d=o!==a;if(d&&o&&(o._fireAndBubble(e.pointerout,{...c},a),o._fireAndBubble(e.pointerleave,{...c},a)),a){if(n[a._id])return;n[a._id]=!0}a&&a.isListening()?(s=!0,d&&(a._fireAndBubble(e.pointerover,{...c},o),a._fireAndBubble(e.pointerenter,{...c},o),this[i+"targetShape"]=a),a._fireAndBubble(e.pointermove,{...c})):o&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:l}),this[i+"targetShape"]=null)})),s||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=I(t.type),i=L(t.type);if(!e)return;this.setPointersPositions(t);const n=this[i+"ClickStartShape"],s=this[i+"ClickEndShape"],o={};let l=!1;this._changedPointerPositions.forEach((c=>{const d=h.getCapturedShape(c.id)||this.getIntersection(c);if(d){if(d.releaseCapture(c.id),o[d._id])return;o[d._id]=!0}const u=c.id,p={evt:t,pointerId:u};let m=!1;r.Konva["_"+i+"InDblClickWindow"]?(m=!0,clearTimeout(this[i+"DblTimeout"])):a.DD.justDragged||(r.Konva["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout((function(){r.Konva["_"+i+"InDblClickWindow"]=!1}),r.Konva.dblClickWindow),d&&d.isListening()?(l=!0,this[i+"ClickEndShape"]=d,d._fireAndBubble(e.pointerup,{...p}),r.Konva["_"+i+"ListenClick"]&&n&&n===d&&(d._fireAndBubble(e.pointerclick,{...p}),m&&s&&s===d&&d._fireAndBubble(e.pointerdblclick,{...p}))):(this[i+"ClickEndShape"]=null,r.Konva["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:u}),m&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:u}))})),l||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),r.Konva["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&"pointer"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(S,{evt:t}):this._fire(S,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(C,{evt:t}):this._fire(C,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=h.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(v,h.createEvent(t)),h.releaseCapture(t.pointerId)}_lostpointercapture(t){h.releaseCapture(t.pointerId)}setPointersPositions(t){const i=this._getContentPosition();let n=null,r=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,(t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})})),Array.prototype.forEach.call(t.changedTouches||t.touches,(t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})}))):(n=(t.clientX-i.left)/i.scaleX,r=(t.clientY-i.top)/i.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:e.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:n,y:r,id:e.Util._getFirstPointerId(t)}])}_setPointerPosition(t){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new s.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new s.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!r.Konva.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}cache(){return e.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach((function(t){t.batchDraw()})),this}}t.Stage=O,O.prototype.nodeType="Stage",(0,o._registerNode)(O),i.Factory.addGetterSetter(O,"container"),r.Konva.isBrowser&&document.addEventListener("visibilitychange",(()=>{t.stages.forEach((t=>{t.batchDraw()}))}))}(av)),av),a=mv(),o=function(){if(fv)return gv;fv=1,Object.defineProperty(gv,"__esModule",{value:!0}),gv.FastLayer=void 0;const t=Ug(),e=mv(),i=Dg();let n=class extends e.Layer{constructor(e){super(e),this.listening(!1),t.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};return gv.FastLayer=n,n.prototype.nodeType="FastLayer",(0,i._registerNode)(n),gv}(),h=yv(),l=$g(),c=pv(),d=wv(),u=(Sv||(Sv=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=Ug(),i=wv(),n=tv(),r=Dg(),s={node:1,duration:1,easing:1,onFinish:1,yoyo:1},a=["fill","stroke","shadowColor"];let o=0;class h{constructor(t,e,i,n,r,s,a){this.prop=t,this.propFunc=e,this.begin=n,this._pos=n,this.duration=s,this._change=0,this.prevPos=0,this.yoyo=a,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=r-this.begin,this.pause()}fire(t){const e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class l{constructor(n){const a=this,c=n.node,d=c._id,u=n.easing||t.Easings.Linear,p=!!n.yoyo;let m,f;m=void 0===n.duration?.3:0===n.duration?.001:n.duration,this.node=c,this._id=o++;const g=c.getLayer()||(c instanceof r.Konva.Stage?c.getLayers():null);for(f in g||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new i.Animation((function(){a.tween.onEnterFrame()}),g),this.tween=new h(f,(function(t){a._tweenFunc(t)}),u,0,1,1e3*m,p),this._addListeners(),l.attrs[d]||(l.attrs[d]={}),l.attrs[d][this._id]||(l.attrs[d][this._id]={}),l.tweens[d]||(l.tweens[d]={}),n)void 0===s[f]&&this._addAttr(f,n[f]);this.reset(),this.onFinish=n.onFinish,this.onReset=n.onReset,this.onUpdate=n.onUpdate}_addAttr(t,i){const n=this.node,r=n._id;let s,o,h,c,d;const u=l.tweens[r][t];u&&delete l.attrs[r][u][t];let p=n.getAttr(t);if(e.Util._isArray(i))if(s=[],o=Math.max(i.length,p.length),"points"===t&&i.length!==p.length&&(i.length>p.length?(c=p,p=e.Util._prepareArrayForTween(p,i,n.closed())):(h=i,i=e.Util._prepareArrayForTween(i,p,n.closed()))),0===t.indexOf("fill"))for(let t=0;t<o;t++)if(t%2==0)s.push(i[t]-p[t]);else{const n=e.Util.colorToRGBA(p[t]);d=e.Util.colorToRGBA(i[t]),p[t]=n,s.push({r:d.r-n.r,g:d.g-n.g,b:d.b-n.b,a:d.a-n.a})}else for(let t=0;t<o;t++)s.push(i[t]-p[t]);else-1!==a.indexOf(t)?(p=e.Util.colorToRGBA(p),d=e.Util.colorToRGBA(i),s={r:d.r-p.r,g:d.g-p.g,b:d.b-p.b,a:d.a-p.a}):s=i-p;l.attrs[r][this._id][t]={start:p,diff:s,end:i,trueEnd:h,trueStart:c},l.tweens[r][t]=this._id}_tweenFunc(t){const i=this.node,n=l.attrs[i._id][this._id];let r,s,o,h,c,d,u,p;for(r in n){if(s=n[r],o=s.start,h=s.diff,p=s.end,e.Util._isArray(o))if(c=[],u=Math.max(o.length,p.length),0===r.indexOf("fill"))for(d=0;d<u;d++)d%2==0?c.push((o[d]||0)+h[d]*t):c.push("rgba("+Math.round(o[d].r+h[d].r*t)+","+Math.round(o[d].g+h[d].g*t)+","+Math.round(o[d].b+h[d].b*t)+","+(o[d].a+h[d].a*t)+")");else for(d=0;d<u;d++)c.push((o[d]||0)+h[d]*t);else c=-1!==a.indexOf(r)?"rgba("+Math.round(o.r+h.r*t)+","+Math.round(o.g+h.g*t)+","+Math.round(o.b+h.b*t)+","+(o.a+h.a*t)+")":o+h*t;i.setAttr(r,c)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=l.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=l.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,e=this._id,i=l.tweens[t];this.pause();for(const e in i)delete l.tweens[t][e];delete l.attrs[t][e]}}t.Tween=l,l.attrs={},l.tweens={},n.Node.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new l(t).play()},t.Easings={BackEaseIn(t,e,i,n){const r=1.70158;return i*(t/=n)*t*((r+1)*t-r)+e},BackEaseOut(t,e,i,n){const r=1.70158;return i*((t=t/n-1)*t*((r+1)*t+r)+1)+e},BackEaseInOut(t,e,i,n){let r=1.70158;return(t/=n/2)<1?i/2*(t*t*((1+(r*=1.525))*t-r))+e:i/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},ElasticEaseIn(t,e,i,n,r,s){let a=0;return 0===t?e:1==(t/=n)?e+i:(s||(s=.3*n),!r||r<Math.abs(i)?(r=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/r),-r*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/s)+e)},ElasticEaseOut(t,e,i,n,r,s){let a=0;return 0===t?e:1==(t/=n)?e+i:(s||(s=.3*n),!r||r<Math.abs(i)?(r=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/r),r*Math.pow(2,-10*t)*Math.sin((t*n-a)*(2*Math.PI)/s)+i+e)},ElasticEaseInOut(t,e,i,n,r,s){let a=0;return 0===t?e:2==(t/=n/2)?e+i:(s||(s=n*(.3*1.5)),!r||r<Math.abs(i)?(r=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/r),t<1?r*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/s)*-.5+e:r*Math.pow(2,-10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/s)*.5+i+e)},BounceEaseOut:(t,e,i,n)=>(t/=n)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(e,i,n,r)=>n-t.Easings.BounceEaseOut(r-e,0,n,r)+i,BounceEaseInOut:(e,i,n,r)=>e<r/2?.5*t.Easings.BounceEaseIn(2*e,0,n,r)+i:.5*t.Easings.BounceEaseOut(2*e-r,0,n,r)+.5*n+i,EaseIn:(t,e,i,n)=>i*(t/=n)*t+e,EaseOut:(t,e,i,n)=>-i*(t/=n)*(t-2)+e,EaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,n)=>i*(t/=n)*t*t*t*t+e,StrongEaseOut:(t,e,i,n)=>i*((t=t/n-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,n)=>i*t/n+e}}(Tv)),Tv),p=qg(),m=Kg();t.Konva=i.Util._assign(e.Konva,{Util:i.Util,Transform:i.Transform,Node:n.Node,Container:r.Container,Stage:s.Stage,stages:s.stages,Layer:a.Layer,FastLayer:o.FastLayer,Group:h.Group,DD:l.DD,Shape:c.Shape,shapes:c.shapes,Animation:d.Animation,Tween:u.Tween,Easings:u.Easings,Context:p.Context,Canvas:m.Canvas}),t.default=t.Konva}(Lg)),Lg}var Av,Cv={};var Rv,Pv={},Lv={};function Iv(){if(Rv)return Lv;Rv=1,Object.defineProperty(Lv,"__esModule",{value:!0}),Lv.Line=void 0;const t=Vg(),e=Dg(),i=pv(),n=Hg();function r(t,e,i,n,r,s,a){const o=Math.sqrt(Math.pow(i-t,2)+Math.pow(n-e,2)),h=Math.sqrt(Math.pow(r-i,2)+Math.pow(s-n,2)),l=a*o/(o+h),c=a*h/(o+h);return[i-l*(r-t),n-l*(s-e),i+c*(r-t),n+c*(s-e)]}function s(t,e){const i=t.length,n=[];for(let s=2;s<i-2;s+=2){const i=r(t[s-2],t[s-1],t[s],t[s+1],t[s+2],t[s+3],e);isNaN(i[0])||(n.push(i[0]),n.push(i[1]),n.push(t[s]),n.push(t[s+1]),n.push(i[2]),n.push(i[3]))}return n}let a=class extends i.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(t){let e,i,n,r=this.points(),s=r.length,a=this.tension(),o=this.closed(),h=this.bezier();if(s){if(t.beginPath(),t.moveTo(r[0],r[1]),0!==a&&s>4){for(e=this.getTensionPoints(),i=e.length,n=o?0:4,o||t.quadraticCurveTo(e[0],e[1],e[2],e[3]);n<i-2;)t.bezierCurveTo(e[n++],e[n++],e[n++],e[n++],e[n++],e[n++]);o||t.quadraticCurveTo(e[i-2],e[i-1],r[s-2],r[s-1])}else if(h)for(n=2;n<s;)t.bezierCurveTo(r[n++],r[n++],r[n++],r[n++],r[n++],r[n++]);else for(n=2;n<s;n+=2)t.lineTo(r[n],r[n+1]);o?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():s(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,i=this.tension(),n=r(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),a=r(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),o=s(t,i);return[n[2],n[3]].concat(o).concat([a[0],a[1],t[e-2],t[e-1],a[2],a[3],n[0],n[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points();let e,i,n=t[0],r=t[0],s=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),r=Math.max(r,e),s=Math.min(s,i),a=Math.max(a,i);return{x:n,y:s,width:r-n,height:a-s}}};return Lv.Line=a,a.prototype.className="Line",a.prototype._attrsAffectingSize=["points","bezier","tension"],(0,e._registerNode)(a),t.Factory.addGetterSetter(a,"closed",!1),t.Factory.addGetterSetter(a,"bezier",!1),t.Factory.addGetterSetter(a,"tension",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(a,"points",[],(0,n.getNumberArrayValidator)()),Lv}var Dv,Ov,Nv,Uv={},Fv={};function kv(){if(Ov)return Uv;Ov=1,Object.defineProperty(Uv,"__esModule",{value:!0}),Uv.Path=void 0;const t=Vg(),e=pv(),i=Dg(),n=(Dv||(Dv=1,function(t){function e(t,e,n){const r=i(1,n,t),s=i(1,n,e),a=r*r+s*s;return Math.sqrt(a)}Object.defineProperty(t,"__esModule",{value:!0}),t.t2length=t.getQuadraticArcLength=t.getCubicArcLength=t.binomialCoefficients=t.cValues=t.tValues=void 0,t.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],t.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],t.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]],t.getCubicArcLength=(i,n,r)=>{let s,a;const o=r/2;s=0;for(let r=0;r<20;r++)a=o*t.tValues[20][r]+o,s+=t.cValues[20][r]*e(i,n,a);return o*s},t.getQuadraticArcLength=(t,e,i)=>{void 0===i&&(i=1);const n=t[0]-2*t[1]+t[2],r=e[0]-2*e[1]+e[2],s=2*t[1]-2*t[0],a=2*e[1]-2*e[0],o=4*(n*n+r*r),h=4*(n*s+r*a),l=s*s+a*a;if(0===o)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const c=h/(2*o),d=i+c,u=l/o-c*c,p=d*d+u>0?Math.sqrt(d*d+u):0,m=c*c+u>0?Math.sqrt(c*c+u):0,f=c+Math.sqrt(c*c+u)!==0?u*Math.log(Math.abs((d+p)/(c+m))):0;return Math.sqrt(o)/2*(d*p-c*m+f)};const i=(e,n,r)=>{const s=r.length-1;let a,o;if(0===s)return 0;if(0===e){o=0;for(let e=0;e<=s;e++)o+=t.binomialCoefficients[s][e]*Math.pow(1-n,s-e)*Math.pow(n,e)*r[e];return o}a=new Array(s);for(let t=0;t<s;t++)a[t]=s*(r[t+1]-r[t]);return i(e-1,n,a)};t.t2length=(t,e,i)=>{let n=1,r=t/e,s=(t-i(r))/e,a=0;for(;n>.001;){const o=i(r+s),h=Math.abs(t-o)/e;if(h<n)n=h,r+=s;else{const a=i(r-s),o=Math.abs(t-a)/e;o<n?(n=o,r-=s):s/=2}if(a++,a>500)break}return r}}(Fv)),Fv);let r=class t extends e.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute()}))}_readDataAttribute(){this.dataArray=t.parsePathData(this.data()),this.pathLength=t.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let m=0;m<e.length;m++){const f=e[m].command,g=e[m].points;switch(f){case"L":t.lineTo(g[0],g[1]);break;case"M":t.moveTo(g[0],g[1]);break;case"C":t.bezierCurveTo(g[0],g[1],g[2],g[3],g[4],g[5]);break;case"Q":t.quadraticCurveTo(g[0],g[1],g[2],g[3]);break;case"A":var n=g[0],r=g[1],s=g[2],a=g[3],o=g[4],h=g[5],l=g[6],c=g[7],d=s>a?s:a,u=s>a?1:s/a,p=s>a?a/s:1;t.translate(n,r),t.rotate(l),t.scale(u,p),t.arc(0,0,d,o,o+h,1-c),t.scale(1/u,1/p),t.rotate(-l),t.translate(-n,-r);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let e=[];this.dataArray.forEach((function(i){if("A"===i.command){const n=i.points[4],r=i.points[5],s=i.points[4]+r;let a=Math.PI/180;if(Math.abs(n-s)<a&&(a=Math.abs(n-s)),r<0)for(let r=n-a;r>s;r-=a){const n=t.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],r,0);e.push(n.x,n.y)}else for(let r=n+a;r<s;r+=a){const n=t.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],r,0);e.push(n.x,n.y)}}else if("C"===i.command)for(let n=0;n<=1;n+=.01){const r=t.getPointOnCubicBezier(n,i.start.x,i.start.y,i.points[0],i.points[1],i.points[2],i.points[3],i.points[4],i.points[5]);e.push(r.x,r.y)}else e=e.concat(i.points)}));let i,n,r=e[0],s=e[0],a=e[1],o=e[1];for(let t=0;t<e.length/2;t++)i=e[2*t],n=e[2*t+1],isNaN(i)||(r=Math.min(r,i),s=Math.max(s,i)),isNaN(n)||(a=Math.min(a,n),o=Math.max(o,n));return{x:r,y:a,width:s-r,height:o-a}}getLength(){return this.pathLength}getPointAtLength(e){return t.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(t,e,i,n){return Math.sqrt((i-t)*(i-t)+(n-e)*(n-e))}static getPathLength(t){let e=0;for(let i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(e,i){let r,s=0,a=i.length;if(!a)return null;for(;s<a&&e>i[s].pathLength;)e-=i[s].pathLength,++s;if(s===a)return r=i[s-1].points.slice(-2),{x:r[0],y:r[1]};if(e<.01)return r=i[s].points.slice(0,2),{x:r[0],y:r[1]};const o=i[s],h=o.points;switch(o.command){case"L":return t.getPointOnLine(e,o.start.x,o.start.y,h[0],h[1]);case"C":return t.getPointOnCubicBezier((0,n.t2length)(e,t.getPathLength(i),(t=>(0,n.getCubicArcLength)([o.start.x,h[0],h[2],h[4]],[o.start.y,h[1],h[3],h[5]],t))),o.start.x,o.start.y,h[0],h[1],h[2],h[3],h[4],h[5]);case"Q":return t.getPointOnQuadraticBezier((0,n.t2length)(e,t.getPathLength(i),(t=>(0,n.getQuadraticArcLength)([o.start.x,h[0],h[2]],[o.start.y,h[1],h[3]],t))),o.start.x,o.start.y,h[0],h[1],h[2],h[3]);case"A":var l=h[0],c=h[1],d=h[2],u=h[3],p=h[4],m=h[5],f=h[6];return p+=m*e/o.pathLength,t.getPointOnEllipticalArc(l,c,d,u,p,f)}return null}static getPointOnLine(t,e,i,n,r,s,a){s=null!=s?s:e,a=null!=a?a:i;const o=this.getLineLength(e,i,n,r);if(o<1e-10)return{x:e,y:i};if(n===e)return{x:s,y:a+(r>i?t:-t)};const h=(r-i)/(n-e),l=Math.sqrt(t*t/(1+h*h))*(n<e?-1:1),c=h*l;if(Math.abs(a-i-h*(s-e))<1e-10)return{x:s+l,y:a+c};const d=((s-e)*(n-e)+(a-i)*(r-i))/(o*o),u=e+d*(n-e),p=i+d*(r-i),m=this.getLineLength(s,a,u,p),f=Math.sqrt(t*t-m*m),g=Math.sqrt(f*f/(1+h*h))*(n<e?-1:1);return{x:u+g,y:p+h*g}}static getPointOnCubicBezier(t,e,i,n,r,s,a,o,h){function l(t){return t*t*t}function c(t){return 3*t*t*(1-t)}function d(t){return 3*t*(1-t)*(1-t)}function u(t){return(1-t)*(1-t)*(1-t)}return{x:o*l(t)+s*c(t)+n*d(t)+e*u(t),y:h*l(t)+a*c(t)+r*d(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,n,r,s,a){function o(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:s*o(t)+n*h(t)+e*l(t),y:a*o(t)+r*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,n,r,s){const a=Math.cos(s),o=Math.sin(s),h=i*Math.cos(r),l=n*Math.sin(r);return{x:t+(h*a-l*o),y:e+(h*o+l*a)}}static parsePathData(t){if(!t)return[];let e=t;const i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(var n=0;n<i.length;n++)e=e.replace(new RegExp(i[n],"g"),"|"+i[n]);const r=e.split("|"),s=[],a=[];let o=0,h=0;const l=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let c;for(n=1;n<r.length;n++){let t=r[n],e=t.charAt(0);for(t=t.slice(1),a.length=0;c=l.exec(t);)a.push(c[0]);const i=[];for(let t=0,e=a.length;t<e;t++){if("00"===a[t]){i.push(0,0);continue}const e=parseFloat(a[t]);isNaN(e)?i.push(0):i.push(e)}for(;i.length>0&&!isNaN(i[0]);){let t="",n=[];const r=o,a=h;var d,u,p,m,f,g,v,_,y,x;switch(e){case"l":o+=i.shift(),h+=i.shift(),t="L",n.push(o,h);break;case"L":o=i.shift(),h=i.shift(),n.push(o,h);break;case"m":var b=i.shift(),w=i.shift();if(o+=b,h+=w,t="M",s.length>2&&"z"===s[s.length-1].command)for(let t=s.length-2;t>=0;t--)if("M"===s[t].command){o=s[t].points[0]+b,h=s[t].points[1]+w;break}n.push(o,h),e="l";break;case"M":o=i.shift(),h=i.shift(),t="M",n.push(o,h),e="L";break;case"h":o+=i.shift(),t="L",n.push(o,h);break;case"H":o=i.shift(),t="L",n.push(o,h);break;case"v":h+=i.shift(),t="L",n.push(o,h);break;case"V":h=i.shift(),t="L",n.push(o,h);break;case"C":n.push(i.shift(),i.shift(),i.shift(),i.shift()),o=i.shift(),h=i.shift(),n.push(o,h);break;case"c":n.push(o+i.shift(),h+i.shift(),o+i.shift(),h+i.shift()),o+=i.shift(),h+=i.shift(),t="C",n.push(o,h);break;case"S":u=o,p=h,"C"===(d=s[s.length-1]).command&&(u=o+(o-d.points[2]),p=h+(h-d.points[3])),n.push(u,p,i.shift(),i.shift()),o=i.shift(),h=i.shift(),t="C",n.push(o,h);break;case"s":u=o,p=h,"C"===(d=s[s.length-1]).command&&(u=o+(o-d.points[2]),p=h+(h-d.points[3])),n.push(u,p,o+i.shift(),h+i.shift()),o+=i.shift(),h+=i.shift(),t="C",n.push(o,h);break;case"Q":n.push(i.shift(),i.shift()),o=i.shift(),h=i.shift(),n.push(o,h);break;case"q":n.push(o+i.shift(),h+i.shift()),o+=i.shift(),h+=i.shift(),t="Q",n.push(o,h);break;case"T":u=o,p=h,"Q"===(d=s[s.length-1]).command&&(u=o+(o-d.points[0]),p=h+(h-d.points[1])),o=i.shift(),h=i.shift(),t="Q",n.push(u,p,o,h);break;case"t":u=o,p=h,"Q"===(d=s[s.length-1]).command&&(u=o+(o-d.points[0]),p=h+(h-d.points[1])),o+=i.shift(),h+=i.shift(),t="Q",n.push(u,p,o,h);break;case"A":m=i.shift(),f=i.shift(),g=i.shift(),v=i.shift(),_=i.shift(),y=o,x=h,o=i.shift(),h=i.shift(),t="A",n=this.convertEndpointToCenterParameterization(y,x,o,h,v,_,m,f,g);break;case"a":m=i.shift(),f=i.shift(),g=i.shift(),v=i.shift(),_=i.shift(),y=o,x=h,o+=i.shift(),h+=i.shift(),t="A",n=this.convertEndpointToCenterParameterization(y,x,o,h,v,_,m,f,g)}s.push({command:t||e,points:n,start:{x:r,y:a},pathLength:this.calcLength(r,a,t||e,n)})}"z"!==e&&"Z"!==e||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(e,i,r,s){let a,o,h,l;const c=t;switch(r){case"L":return c.getLineLength(e,i,s[0],s[1]);case"C":return(0,n.getCubicArcLength)([e,s[0],s[2],s[4]],[i,s[1],s[3],s[5]],1);case"Q":return(0,n.getQuadraticArcLength)([e,s[0],s[2]],[i,s[1],s[3]],1);case"A":a=0;var d=s[4],u=s[5],p=s[4]+u,m=Math.PI/180;if(Math.abs(d-p)<m&&(m=Math.abs(d-p)),o=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],d,0),u<0)for(l=d-m;l>p;l-=m)h=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],l,0),a+=c.getLineLength(o.x,o.y,h.x,h.y),o=h;else for(l=d+m;l<p;l+=m)h=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],l,0),a+=c.getLineLength(o.x,o.y,h.x,h.y),o=h;return h=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],p,0),a+=c.getLineLength(o.x,o.y,h.x,h.y),a}return 0}static convertEndpointToCenterParameterization(t,e,i,n,r,s,a,o,h){const l=h*(Math.PI/180),c=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-n)/2,d=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-n)/2,u=c*c/(a*a)+d*d/(o*o);u>1&&(a*=Math.sqrt(u),o*=Math.sqrt(u));let p=Math.sqrt((a*a*(o*o)-a*a*(d*d)-o*o*(c*c))/(a*a*(d*d)+o*o*(c*c)));r===s&&(p*=-1),isNaN(p)&&(p=0);const m=p*a*d/o,f=p*-o*c/a,g=(t+i)/2+Math.cos(l)*m-Math.sin(l)*f,v=(e+n)/2+Math.sin(l)*m+Math.cos(l)*f,_=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},y=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(_(t)*_(e))},x=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y(t,e))},b=x([1,0],[(c-m)/a,(d-f)/o]),w=[(c-m)/a,(d-f)/o],S=[(-1*c-m)/a,(-1*d-f)/o];let M=x(w,S);return y(w,S)<=-1&&(M=Math.PI),y(w,S)>=1&&(M=0),0===s&&M>0&&(M-=2*Math.PI),1===s&&M<0&&(M+=2*Math.PI),[g,v,a,o,b,M,l,s]}};return Uv.Path=r,r.prototype.className="Path",r.prototype._attrsAffectingSize=["data"],(0,i._registerNode)(r),t.Factory.addGetterSetter(r,"data"),Uv}var Bv,zv={};var Gv,Hv={};var Vv,Wv={};var jv,Xv={};var Yv,qv={};function Kv(){if(Yv)return qv;Yv=1,Object.defineProperty(qv,"__esModule",{value:!0}),qv.Rect=void 0;const t=Vg(),e=pv(),i=Dg(),n=Ug(),r=Hg();let s=class extends e.Shape{_sceneFunc(t){const e=this.cornerRadius(),i=this.width(),r=this.height();t.beginPath(),e?n.Util.drawRoundedRectPath(t,i,r,e):t.rect(0,0,i,r),t.closePath(),t.fillStrokeShape(this)}};return qv.Rect=s,s.prototype.className="Rect",(0,i._registerNode)(s),t.Factory.addGetterSetter(s,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),qv}var Zv,Jv={};var Qv,$v={};var t_,e_={};var i_,n_={};var r_,s_={};function a_(){if(r_)return s_;r_=1,Object.defineProperty(s_,"__esModule",{value:!0}),s_.Text=void 0,s_.stringToArray=a;const t=Ug(),e=Vg(),i=pv(),n=Dg(),r=Hg(),s=Dg();function a(t){return[...t].reduce(((t,e,i,n)=>{if(/\p{Emoji}/u.test(e)){const r=n[i+1];r&&/\p{Emoji_Modifier}|\u200D/u.test(r)?(t.push(e+r),n[i+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(n[i+1]||""))?t.push(e+n[i+1]):i>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:e&&t.push(e);return t}),[])}const o="auto",h="inherit",l="justify",c="left",d="middle",u="normal",p=" ",m="none",f=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],g=f.length;let v;function _(){return v||(v=t.Util.createCanvasElement().getContext("2d"),v)}let y=class extends i.Shape{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<g;t++)this.on(f[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){const e=this.textArr,i=e.length;if(!this.text())return;let r,s=this.padding(),o=this.fontSize(),u=this.lineHeight()*o,p=this.verticalAlign(),m=this.direction(),f=0,g=this.align(),v=this.getWidth(),_=this.letterSpacing(),y=this.fill(),x=this.textDecoration(),b=-1!==x.indexOf("underline"),w=-1!==x.indexOf("line-through");m=m===h?t.direction:m;let S=u/2,M=d;if(n.Konva._fixTextRendering){const t=this.measureSize("M");M="alphabetic",S=(t.fontBoundingBoxAscent-t.fontBoundingBoxDescent)/2+u/2}var T=0,E=0;for("rtl"===m&&t.setAttr("direction",m),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",M),t.setAttr("textAlign",c),p===d?f=(this.getHeight()-i*u-2*s)/2:"bottom"===p&&(f=this.getHeight()-i*u-2*s),t.translate(s,f+s),r=0;r<i;r++){T=0,E=0;var A,C,R=e[r],P=R.text,L=R.width,I=R.lastInParagraph;if(t.save(),"right"===g?T+=v-L-2*s:"center"===g&&(T+=(v-L-2*s)/2),b){t.save(),t.beginPath();const e=T,i=S+E+(n.Konva._fixTextRendering?Math.round(o/4):Math.round(o/2));t.moveTo(e,i),A=P.split(" ").length-1,C=g!==l||I?L:v-2*s,t.lineTo(e+Math.round(C),i),t.lineWidth=o/15;const r=this._getLinearGradient();t.strokeStyle=r||y,t.stroke(),t.restore()}if(w){t.save(),t.beginPath();const e=n.Konva._fixTextRendering?-Math.round(o/4):0;t.moveTo(T,S+E+e),A=P.split(" ").length-1,C=g!==l||I?L:v-2*s,t.lineTo(T+Math.round(C),S+E+e),t.lineWidth=o/15;const i=this._getLinearGradient();t.strokeStyle=i||y,t.stroke(),t.restore()}if("rtl"===m||0===_&&g!==l)0!==_&&t.setAttr("letterSpacing",`${_}px`),this._partialTextX=T,this._partialTextY=S+E,this._partialText=P,t.fillStrokeShape(this);else{A=P.split(" ").length-1;const e=a(P);for(let i=0;i<e.length;i++){const n=e[i];" "!==n||I||g!==l||(T+=(v-2*s-L)/A),this._partialTextX=T,this._partialTextY=S+E,this._partialText=n,t.fillStrokeShape(this),T+=this.measureSize(n).width+_}}t.restore(),i>1&&(S+=u)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(e){const i=t.Util._isString(e)?e:null==e?"":e+"";return this._setAttr("text",i),this}getWidth(){return this.attrs.width===o||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===o||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,n,r,s,a,o,h,l,c,d;let u,p=_(),m=this.fontSize();p.save(),p.font=this._getContextFont(),u=p.measureText(t),p.restore();const f=m/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*f,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(n=u.actualBoundingBoxLeft)&&void 0!==n?n:-7.421875*f,actualBoundingBoxRight:null!==(r=u.actualBoundingBoxRight)&&void 0!==r?r:75.732421875*f,alphabeticBaseline:null!==(s=u.alphabeticBaseline)&&void 0!==s?s:0,emHeightAscent:null!==(a=u.emHeightAscent)&&void 0!==a?a:100*f,emHeightDescent:null!==(o=u.emHeightDescent)&&void 0!==o?o:-20*f,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*f,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*f,hangingBaseline:null!==(c=u.hangingBaseline)&&void 0!==c?c:72.80000305175781*f,ideographicBaseline:null!==(d=u.ideographicBaseline)&&void 0!==d?d:-21*f,width:u.width,height:m}}_getContextFont(){return this.fontStyle()+p+this.fontVariant()+p+(this.fontSize()+"px ")+this.fontFamily().split(",").map((t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t})).join(", ")}_addTextLine(t){this.align()===l&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),i=t.length;return _().measureText(t).width+e*i}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,n=this.lineHeight()*e,r=this.attrs.width,s=this.attrs.height,h=r!==o&&void 0!==r,l=s!==o&&void 0!==s,c=this.padding(),d=r-2*c,u=s-2*c,f=0,g=this.wrap(),v="char"!==g&&g!==m,y=this.ellipsis();this.textArr=[],_().font=this._getContextFont();const x=y?this._getTextWidth("…"):0;for(let e=0,r=t.length;e<r;++e){let s=t[e],o=this._getTextWidth(s);if(h&&o>d)for(;s.length>0;){let t=0,e=a(s).length,r="",h=0;for(;t<e;){const i=t+e>>>1,n=a(s).slice(0,i+1).join(""),o=this._getTextWidth(n)+x;o<=d?(t=i+1,r=n,h=o):e=i}if(!r)break;if(v){const e=a(s),i=a(r),n=e[i.length];let o;if((n===p||"-"===n)&&h<=d)o=i.length;else{const t=i.lastIndexOf(p),e=i.lastIndexOf("-");o=Math.max(t,e)+1}o>0&&(t=o,r=e.slice(0,t).join(""),h=this._getTextWidth(r))}r=r.trimRight(),this._addTextLine(r),i=Math.max(i,h),f+=n;if(this._shouldHandleEllipsis(f)){this._tryToAddEllipsisToLastLine();break}if(s=a(s).slice(t).join("").trimLeft(),s.length>0&&(o=this._getTextWidth(s),o<=d)){this._addTextLine(s),f+=n,i=Math.max(i,o);break}}else this._addTextLine(s),f+=n,i=Math.max(i,o),this._shouldHandleEllipsis(f)&&e<r-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),l&&f+n>u)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,n=this.attrs.height,r=n!==o&&void 0!==n,s=n-2*this.padding();return!(this.wrap()!==m)||r&&t+i>s}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==o&&void 0!==t,i=t-2*this.padding(),n=this.ellipsis(),r=this.textArr[this.textArr.length-1];if(r&&n){if(e){this._getTextWidth(r.text+"…")<i||(r.text=r.text.slice(0,r.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(r.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}};return s_.Text=y,y.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},y.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},y.prototype.className="Text",y.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,s._registerNode)(y),e.Factory.overWriteSetter(y,"width",(0,r.getNumberOrAutoValidator)()),e.Factory.overWriteSetter(y,"height",(0,r.getNumberOrAutoValidator)()),e.Factory.addGetterSetter(y,"direction",h),e.Factory.addGetterSetter(y,"fontFamily","Arial"),e.Factory.addGetterSetter(y,"fontSize",12,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"fontStyle",u),e.Factory.addGetterSetter(y,"fontVariant",u),e.Factory.addGetterSetter(y,"padding",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"align",c),e.Factory.addGetterSetter(y,"verticalAlign","top"),e.Factory.addGetterSetter(y,"lineHeight",1,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"wrap","word"),e.Factory.addGetterSetter(y,"ellipsis",!1,(0,r.getBooleanValidator)()),e.Factory.addGetterSetter(y,"letterSpacing",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"text","",(0,r.getStringValidator)()),e.Factory.addGetterSetter(y,"textDecoration",""),s_}var o_,h_={};var l_,c_={};function d_(){if(l_)return c_;l_=1,Object.defineProperty(c_,"__esModule",{value:!0}),c_.Transformer=void 0;const t=Ug(),e=Vg(),i=tv(),n=pv(),r=Kv(),s=yv(),a=Dg(),o=Hg(),h=Dg(),l="tr-konva",c=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((t=>t+`.${l}`)).join(" "),d="nodesRect",u=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],p={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},m="ontouchstart"in a.Konva._global;const f=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function g(t,e,i){const n=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),r=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:n,y:r}}function v(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return g(t,e,i)}let _=0,y=class extends s.Group{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(c,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(e){return t.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return l+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const i=e.filter((e=>!e.isAncestorOf(this)||(t.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));this._nodes=e=i,1===e.length&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()},i=t._attrsAffectingSize.map((t=>t+"Change."+this._getEventNamespace())).join(" ");t.on(i,e),t.on(u.map((t=>t+`.${this._getEventNamespace()}`)).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)})),this._resetTransformCache();return!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,(i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)})),t.on(`dragmove.${this._getEventNamespace()}`,(i=>{if(!e)return;const n=t.getAbsolutePosition(),r=n.x-e.x,s=n.y-e.y;this.nodes().forEach((e=>{if(e===t)return;if(e.isDragging())return;const n=e.getAbsolutePosition();e.setAbsolutePosition({x:n.x+r,y:n.y+s}),e.startDrag(i)})),e=null}))}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach((t=>{t.off("."+this._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(d),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(d,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){const n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=t.getAbsoluteScale(i),s=t.getAbsolutePosition(i),o=n.x*r.x-t.offsetX()*r.x,h=n.y*r.y-t.offsetY()*r.y,l=(a.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return g({x:s.x+o*Math.cos(l)+h*Math.sin(-l),y:s.y+h*Math.cos(l)+o*Math.sin(l),width:n.width*r.x,height:n.height*r.y,rotation:l},-a.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map((t=>{const i=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),n=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],r=t.getAbsoluteTransform();n.forEach((function(t){const i=r.point(t);e.push(i)}))}));const i=new t.Transform;i.rotate(-a.Konva.getAngle(this.rotation()));let n=1/0,r=1/0,s=-1/0,o=-1/0;e.forEach((function(t){const e=i.point(t);void 0===n&&(n=s=e.x,r=o=e.y),n=Math.min(n,e.x),r=Math.min(r,e.y),s=Math.max(s,e.x),o=Math.max(o,e.y)})),i.invert();const h=i.point({x:n,y:r});return{x:h.x,y:h.y,width:s-n,height:o-r,rotation:a.Konva.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),f.forEach((t=>{this._createAnchor(t)})),this._createAnchor("rotater")}_createAnchor(e){const i=new r.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:m?10:"auto"}),n=this;i.on("mousedown touchstart",(function(t){n._handleMouseDown(t)})),i.on("dragstart",(t=>{i.stopDrag(),t.cancelBubble=!0})),i.on("dragend",(t=>{t.cancelBubble=!0})),i.on("mouseenter",(()=>{const n=a.Konva.getAngle(this.rotation()),r=this.rotateAnchorCursor(),s=function(e,i,n){if("rotater"===e)return n;i+=t.Util.degToRad(p[e]||0);const r=(t.Util.radToDeg(i)%360+360)%360;return t.Util._inRange(r,337.5,360)||t.Util._inRange(r,0,22.5)?"ns-resize":t.Util._inRange(r,22.5,67.5)?"nesw-resize":t.Util._inRange(r,67.5,112.5)?"ew-resize":t.Util._inRange(r,112.5,157.5)?"nwse-resize":t.Util._inRange(r,157.5,202.5)?"ns-resize":t.Util._inRange(r,202.5,247.5)?"nesw-resize":t.Util._inRange(r,247.5,292.5)?"ew-resize":t.Util._inRange(r,292.5,337.5)?"nwse-resize":(t.Util.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}(e,n,r);i.getStage().content&&(i.getStage().content.style.cursor=s),this._cursorChange=!0})),i.on("mouseout",(()=>{i.getStage().content&&(i.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(i)}_createBack(){const e=new n.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(e,i){const n=i.getParent(),r=n.padding();e.beginPath(),e.rect(-r,-r,i.width()+2*r,i.height()+2*r),e.moveTo(i.width()/2,-r),n.rotateEnabled()&&n.rotateLineVisible()&&e.lineTo(i.width()/2,-n.rotateAnchorOffset()*t.Util._sign(i.height())-r),e.fillStrokeShape(i)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}});this.add(e),this._proxyDrag(e),e.on("dragstart",(t=>{t.cancelBubble=!0})),e.on("dragmove",(t=>{t.cancelBubble=!0})),e.on("dragend",(t=>{t.cancelBubble=!0})),this.on("dragmove",(t=>{this.update()}))}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const e=this._getNodeRect(),i=e.width,n=e.height,r=Math.sqrt(Math.pow(i,2)+Math.pow(n,2));this.sin=Math.abs(n/r),this.cos=Math.abs(i/r),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const s=t.target.getAbsolutePosition(),a=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:a.x-s.x,y:a.y-s.y},_++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach((e=>{e._fire("transformstart",{evt:t.evt,target:e})}))}_handleMouseMove(t){let e,i,n;const r=this.findOne("."+this._movingAnchorName),s=r.getStage();s.setPointersPositions(t);const o=s.getPointerPosition();let h={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y};const l=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(h=this.anchorDragBoundFunc()(l,h,t)),r.setAbsolutePosition(h);const c=r.getAbsolutePosition();if(l.x===c.x&&l.y===c.y)return;if("rotater"===this._movingAnchorName){const n=this._getNodeRect();e=r.x()-n.width/2,i=-r.y()+n.height/2;let s=Math.atan2(-i,e)+Math.PI/2;n.height<0&&(s-=Math.PI);const o=a.Konva.getAngle(this.rotation())+s,h=a.Konva.getAngle(this.rotationSnapTolerance()),l=function(t,e,i){let n=e;for(let r=0;r<t.length;r++){const s=a.Konva.getAngle(t[r]),o=Math.abs(s-e)%(2*Math.PI);Math.min(o,2*Math.PI-o)<i&&(n=s)}return n}(this.rotationSnaps(),o,h),c=v(n,l-n.rotation);return void this._fitNodesInto(c,t)}const d=this.shiftBehavior();let u;u="inverted"===d?this.keepRatio()&&!t.shiftKey:"none"===d?this.keepRatio():this.keepRatio()||t.shiftKey;var p=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(u){var m=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};n=Math.sqrt(Math.pow(m.x-r.x(),2)+Math.pow(m.y-r.y(),2));var f=this.findOne(".top-left").x()>m.x?-1:1,g=this.findOne(".top-left").y()>m.y?-1:1;e=n*this.cos*f,i=n*this.sin*g,this.findOne(".top-left").x(m.x-e),this.findOne(".top-left").y(m.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(r.y());else if("top-right"===this._movingAnchorName){if(u){m=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};n=Math.sqrt(Math.pow(r.x()-m.x,2)+Math.pow(m.y-r.y(),2));f=this.findOne(".top-right").x()<m.x?-1:1,g=this.findOne(".top-right").y()>m.y?-1:1;e=n*this.cos*f,i=n*this.sin*g,this.findOne(".top-right").x(m.x+e),this.findOne(".top-right").y(m.y-i)}var _=r.position();this.findOne(".top-left").y(_.y),this.findOne(".bottom-right").x(_.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(r.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(r.x());else if("bottom-left"===this._movingAnchorName){if(u){m=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};n=Math.sqrt(Math.pow(m.x-r.x(),2)+Math.pow(r.y()-m.y,2));f=m.x<r.x()?-1:1,g=r.y()<m.y?-1:1;e=n*this.cos*f,i=n*this.sin*g,r.x(m.x-e),r.y(m.y+i)}_=r.position(),this.findOne(".top-left").x(_.x),this.findOne(".bottom-right").y(_.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(r.y());else if("bottom-right"===this._movingAnchorName){if(u){m=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};n=Math.sqrt(Math.pow(r.x()-m.x,2)+Math.pow(r.y()-m.y,2));f=this.findOne(".bottom-right").x()<m.x?-1:1,g=this.findOne(".bottom-right").y()<m.y?-1:1;e=n*this.cos*f,i=n*this.sin*g,this.findOne(".bottom-right").x(m.x+e),this.findOne(".bottom-right").y(m.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(p=this.centeredScaling()||t.altKey){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),i=t.x(),n=t.y(),r=this.getWidth()-e.x(),s=this.getHeight()-e.y();e.move({x:-i,y:-n}),t.move({x:r,y:s})}const y=this.findOne(".top-left").getAbsolutePosition();e=y.x,i=y.y;const x=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),b=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:x,height:b,rotation:a.Konva.getAngle(this.rotation())},t)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const i=this.getNode();_--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&this._nodes.forEach((e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this._movingAnchorName=null}}_fitNodesInto(e,i){const n=this._getNodeRect();if(t.Util._inRange(e.width,2*-this.padding()-1,1))return void this.update();if(t.Util._inRange(e.height,2*-this.padding()-1,1))return void this.update();const r=new t.Transform;if(r.rotate(a.Konva.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const t=r.point({x:2*-this.padding(),y:0});e.x+=t.x,e.y+=t.y,e.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const t=r.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=2*this.padding()}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const t=r.point({x:0,y:2*-this.padding()});e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const t=r.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}if(this.boundBoxFunc()){const i=this.boundBoxFunc()(n,e);i?e=i:t.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const s=1e7,o=new t.Transform;o.translate(n.x,n.y),o.rotate(n.rotation),o.scale(n.width/s,n.height/s);const h=new t.Transform,l=e.width/s,c=e.height/s;!1===this.flipEnabled()?(h.translate(e.x,e.y),h.rotate(e.rotation),h.translate(e.width<0?e.width:0,e.height<0?e.height:0),h.scale(Math.abs(l),Math.abs(c))):(h.translate(e.x,e.y),h.rotate(e.rotation),h.scale(l,c));const d=h.multiply(o.invert());this._nodes.forEach((e=>{var i;const n=e.getParent().getAbsoluteTransform(),r=e.getTransform().copy();r.translate(e.offsetX(),e.offsetY());const s=new t.Transform;s.multiply(n.copy().invert()).multiply(d).multiply(n).multiply(r);const a=s.decompose();e.setAttrs(a),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this.rotation(t.Util._getRotation(e.rotation)),this._nodes.forEach((t=>{this._fire("transform",{evt:i,target:t}),t._fire("transform",{evt:i,target:t})})),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var e;const i=this._getNodeRect();this.rotation(t.Util._getRotation(i.rotation));const n=i.width,r=i.height,s=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),h=this.anchorSize(),l=this.find("._anchor");l.forEach((t=>{t.setAttrs({width:h,height:h,offsetX:h/2,offsetY:h/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:h/2+o,offsetY:h/2+o,visible:a&&s.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:h/2+o,visible:a&&s.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:h/2-o,offsetY:h/2+o,visible:a&&s.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:h/2+o,visible:a&&s.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:h/2-o,visible:a&&s.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:h/2+o,offsetY:h/2-o,visible:a&&s.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:h/2-o,visible:a&&s.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:h/2-o,offsetY:h/2-o,visible:a&&s.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:n/2,y:-this.rotateAnchorOffset()*t.Util._sign(r)-o,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const c=this.anchorStyleFunc();c&&l.forEach((t=>{c(t)})),null===(e=this.getLayer())||void 0===e||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),s.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return i.Node.prototype.toObject.call(this)}clone(t){return i.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};return c_.Transformer=y,y.isTransforming=()=>_>0,y.prototype.className="Transformer",(0,h._registerNode)(y),e.Factory.addGetterSetter(y,"enabledAnchors",f,(function(e){return e instanceof Array||t.Util.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach((function(e){-1===f.indexOf(e)&&t.Util.warn("Unknown anchor name: "+e+". Available names are: "+f.join(", "))})),e||[]})),e.Factory.addGetterSetter(y,"flipEnabled",!0,(0,o.getBooleanValidator)()),e.Factory.addGetterSetter(y,"resizeEnabled",!0),e.Factory.addGetterSetter(y,"anchorSize",10,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"rotateEnabled",!0),e.Factory.addGetterSetter(y,"rotateLineVisible",!0),e.Factory.addGetterSetter(y,"rotationSnaps",[]),e.Factory.addGetterSetter(y,"rotateAnchorOffset",50,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"rotateAnchorCursor","crosshair"),e.Factory.addGetterSetter(y,"rotationSnapTolerance",5,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderEnabled",!0),e.Factory.addGetterSetter(y,"anchorStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(y,"anchorStrokeWidth",1,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"anchorFill","white"),e.Factory.addGetterSetter(y,"anchorCornerRadius",0,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(y,"borderStrokeWidth",1,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderDash"),e.Factory.addGetterSetter(y,"keepRatio",!0),e.Factory.addGetterSetter(y,"shiftBehavior","default"),e.Factory.addGetterSetter(y,"centeredScaling",!1),e.Factory.addGetterSetter(y,"ignoreStroke",!1),e.Factory.addGetterSetter(y,"padding",0,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"nodes"),e.Factory.addGetterSetter(y,"node"),e.Factory.addGetterSetter(y,"boundBoxFunc"),e.Factory.addGetterSetter(y,"anchorDragBoundFunc"),e.Factory.addGetterSetter(y,"anchorStyleFunc"),e.Factory.addGetterSetter(y,"shouldOverdrawWholeArea",!1),e.Factory.addGetterSetter(y,"useSingleNodeRotation",!0),e.Factory.backCompat(y,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"}),c_}var u_,p_={};var m_,f_={};function g_(){if(m_)return f_;m_=1,Object.defineProperty(f_,"__esModule",{value:!0}),f_.Blur=void 0;const t=Vg(),e=tv(),i=Hg();function n(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}const r=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],s=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];return f_.Blur=function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const i=t.data,a=t.width,o=t.height;let h,l,c,d,u,p,m,f,g,v,_,y,x,b,w,S,M,T,E,A,C,R,P,L;const I=e+e+1,D=a-1,O=o-1,N=e+1,U=N*(N+1)/2,F=new n,k=r[e],B=s[e];let z=null,G=F,H=null,V=null;for(c=1;c<I;c++)G=G.next=new n,c===N&&(z=G);for(G.next=F,m=p=0,l=0;l<o;l++){for(S=M=T=E=f=g=v=_=0,y=N*(A=i[p]),x=N*(C=i[p+1]),b=N*(R=i[p+2]),w=N*(P=i[p+3]),f+=U*A,g+=U*C,v+=U*R,_+=U*P,G=F,c=0;c<N;c++)G.r=A,G.g=C,G.b=R,G.a=P,G=G.next;for(c=1;c<N;c++)d=p+((D<c?D:c)<<2),f+=(G.r=A=i[d])*(L=N-c),g+=(G.g=C=i[d+1])*L,v+=(G.b=R=i[d+2])*L,_+=(G.a=P=i[d+3])*L,S+=A,M+=C,T+=R,E+=P,G=G.next;for(H=F,V=z,h=0;h<a;h++)i[p+3]=P=_*k>>B,0!==P?(P=255/P,i[p]=(f*k>>B)*P,i[p+1]=(g*k>>B)*P,i[p+2]=(v*k>>B)*P):i[p]=i[p+1]=i[p+2]=0,f-=y,g-=x,v-=b,_-=w,y-=H.r,x-=H.g,b-=H.b,w-=H.a,d=m+((d=h+e+1)<D?d:D)<<2,S+=H.r=i[d],M+=H.g=i[d+1],T+=H.b=i[d+2],E+=H.a=i[d+3],f+=S,g+=M,v+=T,_+=E,H=H.next,y+=A=V.r,x+=C=V.g,b+=R=V.b,w+=P=V.a,S-=A,M-=C,T-=R,E-=P,V=V.next,p+=4;m+=a}for(h=0;h<a;h++){for(M=T=E=S=g=v=_=f=0,p=h<<2,y=N*(A=i[p]),x=N*(C=i[p+1]),b=N*(R=i[p+2]),w=N*(P=i[p+3]),f+=U*A,g+=U*C,v+=U*R,_+=U*P,G=F,c=0;c<N;c++)G.r=A,G.g=C,G.b=R,G.a=P,G=G.next;for(u=a,c=1;c<=e;c++)p=u+h<<2,f+=(G.r=A=i[p])*(L=N-c),g+=(G.g=C=i[p+1])*L,v+=(G.b=R=i[p+2])*L,_+=(G.a=P=i[p+3])*L,S+=A,M+=C,T+=R,E+=P,G=G.next,c<O&&(u+=a);for(p=h,H=F,V=z,l=0;l<o;l++)d=p<<2,i[d+3]=P=_*k>>B,P>0?(P=255/P,i[d]=(f*k>>B)*P,i[d+1]=(g*k>>B)*P,i[d+2]=(v*k>>B)*P):i[d]=i[d+1]=i[d+2]=0,f-=y,g-=x,v-=b,_-=w,y-=H.r,x-=H.g,b-=H.b,w-=H.a,d=h+((d=l+N)<O?d:O)*a<<2,f+=S+=H.r=i[d],g+=M+=H.g=i[d+1],v+=T+=H.b=i[d+2],_+=E+=H.a=i[d+3],H=H.next,y+=A=V.r,x+=C=V.g,b+=R=V.b,w+=P=V.a,S-=A,M-=C,T-=R,E-=P,V=V.next,p+=a}}(t,e)},t.Factory.addGetterSetter(e.Node,"blurRadius",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),f_}var v_,__={};var y_,x_={};var b_,w_={};var S_,M_={};var T_,E_={};var A_,C_={};var R_,P_={};var L_,I_={};var D_,O_={};function N_(){if(D_)return O_;D_=1,Object.defineProperty(O_,"__esModule",{value:!0}),O_.Kaleidoscope=void 0;const t=Vg(),e=tv(),i=Ug(),n=Hg();return O_.Kaleidoscope=function(t){const e=t.width,n=t.height;let r,s,a,o,h,l,c,d,u,p,m=Math.round(this.kaleidoscopePower());const f=Math.round(this.kaleidoscopeAngle()),g=Math.floor(e*(f%360)/360);if(m<1)return;const v=i.Util.createCanvasElement();v.width=e,v.height=n;const _=v.getContext("2d").getImageData(0,0,e,n);i.Util.releaseCanvas(v),function(t,e,i){const n=t.data,r=e.data,s=t.width,a=t.height,o=i.polarCenterX||s/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),c=s-o,d=a-h;const u=Math.sqrt(c*c+d*d);l=u>l?u:l;const p=a,m=s,f=360/m*Math.PI/180;for(let t=0;t<m;t+=1){const e=Math.sin(t*f),i=Math.cos(t*f);for(let a=0;a<p;a+=1){c=Math.floor(o+l*a/p*i),d=Math.floor(h+l*a/p*e);let u=4*(d*s+c);const m=n[u+0],f=n[u+1],g=n[u+2],v=n[u+3];u=4*(t+a*s),r[u+0]=m,r[u+1]=f,r[u+2]=g,r[u+3]=v}}}(t,_,{polarCenterX:e/2,polarCenterY:n/2});let y=e/Math.pow(2,m);for(;y<=8;)y*=2,m-=1;y=Math.ceil(y);let x=y,b=0,w=x,S=1;for(g+y>e&&(b=x,w=0,S=-1),s=0;s<n;s+=1)for(r=b;r!==w;r+=S)a=Math.round(r+g)%e,u=4*(e*s+a),h=_.data[u+0],l=_.data[u+1],c=_.data[u+2],d=_.data[u+3],p=4*(e*s+r),_.data[p+0]=h,_.data[p+1]=l,_.data[p+2]=c,_.data[p+3]=d;for(s=0;s<n;s+=1)for(x=Math.floor(y),o=0;o<m;o+=1){for(r=0;r<x+1;r+=1)u=4*(e*s+r),h=_.data[u+0],l=_.data[u+1],c=_.data[u+2],d=_.data[u+3],p=4*(e*s+2*x-r-1),_.data[p+0]=h,_.data[p+1]=l,_.data[p+2]=c,_.data[p+3]=d;x*=2}!function(t,e,i){const n=t.data,r=e.data,s=t.width,a=t.height,o=i.polarCenterX||s/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),c=s-o,d=a-h;const u=Math.sqrt(c*c+d*d);l=u>l?u:l;const p=a,m=s;let f,g;for(c=0;c<s;c+=1)for(d=0;d<a;d+=1){const t=c-o,e=d-h,i=Math.sqrt(t*t+e*e)*p/l;let a=(180*Math.atan2(e,t)/Math.PI+360+0)%360;a=a*m/360,f=Math.floor(a),g=Math.floor(i);let u=4*(g*s+f);const v=n[u+0],_=n[u+1],y=n[u+2],x=n[u+3];u=4*(d*s+c),r[u+0]=v,r[u+1]=_,r[u+2]=y,r[u+3]=x}}(_,t,{})},t.Factory.addGetterSetter(e.Node,"kaleidoscopePower",2,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"kaleidoscopeAngle",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),O_}var U_,F_={};function k_(){if(U_)return F_;U_=1,Object.defineProperty(F_,"__esModule",{value:!0}),F_.Mask=void 0;const t=Vg(),e=tv(),i=Hg();function n(t,e,i){let n=4*(i*t.width+e);const r=[];return r.push(t.data[n++],t.data[n++],t.data[n++],t.data[n++]),r}function r(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}return F_.Mask=function(t){let e=function(t,e){const i=n(t,0,0),s=n(t,t.width-1,0),a=n(t,0,t.height-1),o=n(t,t.width-1,t.height-1),h=e||10;if(r(i,s)<h&&r(s,o)<h&&r(o,a)<h&&r(a,i)<h){const e=function(t){const e=[0,0,0];for(let i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([s,i,o,a]),n=[];for(let i=0;i<t.width*t.height;i++){const s=r(e,[t.data[4*i],t.data[4*i+1],t.data[4*i+2]]);n[i]=s<h?0:255}return n}}(t,this.threshold());return e&&(e=function(t,e,i){const n=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(n.length)),s=Math.floor(r/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<r;a++)for(let l=0;l<r;l++){const d=o+a-s,u=h+l-s;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*r+l];c+=t[d*e+u]*i}}a[l]=2040===c?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(n.length)),s=Math.floor(r/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<r;a++)for(let l=0;l<r;l++){const d=o+a-s,u=h+l-s;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*r+l];c+=t[d*e+u]*i}}a[l]=c>=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],r=Math.round(Math.sqrt(n.length)),s=Math.floor(r/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<r;a++)for(let l=0;l<r;l++){const d=o+a-s,u=h+l-s;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*r+l];c+=t[d*e+u]*i}}a[l]=c}return a}(e,t.width,t.height),function(t,e){for(let i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e)),t},t.Factory.addGetterSetter(e.Node,"threshold",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),F_}var B_,z_={};var G_,H_={};var V_,W_={};var j_,X_={};var Y_,q_={};var K_,Z_={};var J_,Q_={};var $_,ty,ey={};function iy(){if(ty)return Pg;ty=1,Object.defineProperty(Pg,"__esModule",{value:!0}),Pg.Konva=void 0;const t=Ev(),e=function(){if(Av)return Cv;Av=1,Object.defineProperty(Cv,"__esModule",{value:!0}),Cv.Arc=void 0;const t=Vg(),e=pv(),i=Dg(),n=Hg(),r=Dg();let s=class extends e.Shape{_sceneFunc(t){const e=i.Konva.getAngle(this.angle()),n=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,n),t.arc(0,0,this.innerRadius(),e,0,!n),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),n=this.clockwise(),r=i.Konva.getAngle(n?360-this.angle():this.angle()),s=Math.cos(Math.min(r,Math.PI)),a=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),o=Math.sin(Math.min(r,Math.PI/2)),h=s*(s>0?t:e),l=a*(a>0?t:e),c=o*(o>0?e:t);return{x:h,y:n?-1*c:l,width:1*e-h,height:c-l}}};return Cv.Arc=s,s.prototype._centroid=!0,s.prototype.className="Arc",s.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"innerRadius",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"outerRadius",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"angle",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"clockwise",!1,(0,n.getBooleanValidator)()),Cv}(),i=function(){if(Nv)return Pv;Nv=1,Object.defineProperty(Pv,"__esModule",{value:!0}),Pv.Arrow=void 0;const t=Vg(),e=Iv(),i=Hg(),n=Dg(),r=kv();let s=class extends e.Line{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let n=i;const s=0!==this.tension()&&i.length>4;s&&(n=this.getTensionPoints());const a=this.pointerLength(),o=i.length;let h,l;if(s){const t=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],i[o-2],i[o-1]],e=r.Path.calcLength(n[n.length-4],n[n.length-3],"C",t),s=r.Path.getPointOnQuadraticBezier(Math.min(1,1-a/e),t[0],t[1],t[2],t[3],t[4],t[5]);h=i[o-2]-s.x,l=i[o-1]-s.y}else h=i[o-2]-i[o-4],l=i[o-1]-i[o-3];const c=(Math.atan2(l,h)+e)%e,d=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[o-2],i[o-1]),t.rotate(c),t.moveTo(0,0),t.lineTo(-a,d/2),t.lineTo(-a,-d/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),s?(h=(n[0]+n[2])/2-i[0],l=(n[1]+n[3])/2-i[1]):(h=i[2]-i[0],l=i[3]-i[1]),t.rotate((Math.atan2(-l,-h)+e)%e),t.moveTo(0,0),t.lineTo(-a,d/2),t.lineTo(-a,-d/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x,y:t.y-e,width:t.width,height:t.height+2*e}}};return Pv.Arrow=s,s.prototype.className="Arrow",(0,n._registerNode)(s),t.Factory.addGetterSetter(s,"pointerLength",10,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"pointerWidth",10,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"pointerAtBeginning",!1),t.Factory.addGetterSetter(s,"pointerAtEnding",!0),Pv}(),n=function(){if(Bv)return zv;Bv=1,Object.defineProperty(zv,"__esModule",{value:!0}),zv.Circle=void 0;const t=Vg(),e=pv(),i=Hg(),n=Dg();let r=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}};return zv.Circle=r,r.prototype._centroid=!0,r.prototype.className="Circle",r.prototype._attrsAffectingSize=["radius"],(0,n._registerNode)(r),t.Factory.addGetterSetter(r,"radius",0,(0,i.getNumberValidator)()),zv}(),r=function(){if(Gv)return Hv;Gv=1,Object.defineProperty(Hv,"__esModule",{value:!0}),Hv.Ellipse=void 0;const t=Vg(),e=pv(),i=Hg(),n=Dg();let r=class extends e.Shape{_sceneFunc(t){const e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}};return Hv.Ellipse=r,r.prototype.className="Ellipse",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,n._registerNode)(r),t.Factory.addComponentsGetterSetter(r,"radius",["x","y"]),t.Factory.addGetterSetter(r,"radiusX",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"radiusY",0,(0,i.getNumberValidator)()),Hv}(),s=function(){if(Vv)return Wv;Vv=1,Object.defineProperty(Wv,"__esModule",{value:!0}),Wv.Image=void 0;const t=Ug(),e=Vg(),i=pv(),n=Dg(),r=Hg();class s extends i.Shape{constructor(t){super(t),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(e){const i=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),s=this.attrs.image;let a;if(s){const t=this.attrs.cropWidth,e=this.attrs.cropHeight;a=t&&e?[s,this.cropX(),this.cropY(),t,e,0,0,i,n]:[s,0,0,i,n]}(this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?t.Util.drawRoundedRectPath(e,i,n,r):e.rect(0,0,i,n),e.closePath(),e.fillStrokeShape(this)),s&&(r&&e.clip(),e.drawImage.apply(e,a))}_hitFunc(e){const i=this.width(),n=this.height(),r=this.cornerRadius();e.beginPath(),r?t.Util.drawRoundedRectPath(e,i,n,r):e.rect(0,0,i,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(e,i,n=null){const r=t.Util.createImageElement();r.onload=function(){const t=new s({image:r});i(t)},r.onerror=n,r.crossOrigin="Anonymous",r.src=e}}return Wv.Image=s,s.prototype.className="Image",(0,n._registerNode)(s),e.Factory.addGetterSetter(s,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),e.Factory.addGetterSetter(s,"image"),e.Factory.addComponentsGetterSetter(s,"crop",["x","y","width","height"]),e.Factory.addGetterSetter(s,"cropX",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropY",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropWidth",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropHeight",0,(0,r.getNumberValidator)()),Wv}(),a=function(){if(jv)return Xv;jv=1,Object.defineProperty(Xv,"__esModule",{value:!0}),Xv.Tag=Xv.Label=void 0;const t=Vg(),e=pv(),i=yv(),n=Hg(),r=Dg(),s=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],a="up",o="right",h="down",l="left",c=s.length;let d=class extends i.Group{constructor(t){super(t),this.on("add.konva",(function(t){this._addListeners(t.child),this._sync()}))}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,i=this;const n=function(){i._sync()};for(e=0;e<c;e++)t.on(s[e]+"Change.konva",n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,i,n,r,s,c,d=this.getText(),u=this.getTag();if(d&&u){switch(t=d.width(),e=d.height(),i=u.pointerDirection(),n=u.pointerWidth(),c=u.pointerHeight(),r=0,s=0,i){case a:r=t/2,s=-1*c;break;case o:r=t+n,s=e/2;break;case h:r=t/2,s=e+c;break;case l:r=-1*n,s=e/2}u.setAttrs({x:-1*r,y:-1*s,width:t,height:e}),d.setAttrs({x:-1*r,y:-1*s})}}};Xv.Label=d,d.prototype.className="Label",(0,r._registerNode)(d);class u extends e.Shape{_sceneFunc(t){const e=this.width(),i=this.height(),n=this.pointerDirection(),r=this.pointerWidth(),s=this.pointerHeight(),c=this.cornerRadius();let d=0,u=0,p=0,m=0;"number"==typeof c?d=u=p=m=Math.min(c,e/2,i/2):(d=Math.min(c[0]||0,e/2,i/2),u=Math.min(c[1]||0,e/2,i/2),m=Math.min(c[2]||0,e/2,i/2),p=Math.min(c[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(d,0),n===a&&(t.lineTo((e-r)/2,0),t.lineTo(e/2,-1*s),t.lineTo((e+r)/2,0)),t.lineTo(e-u,0),t.arc(e-u,u,u,3*Math.PI/2,0,!1),n===o&&(t.lineTo(e,(i-s)/2),t.lineTo(e+r,i/2),t.lineTo(e,(i+s)/2)),t.lineTo(e,i-m),t.arc(e-m,i-m,m,0,Math.PI/2,!1),n===h&&(t.lineTo((e+r)/2,i),t.lineTo(e/2,i+s),t.lineTo((e-r)/2,i)),t.lineTo(p,i),t.arc(p,i-p,p,Math.PI/2,Math.PI,!1),n===l&&(t.lineTo(0,(i+s)/2),t.lineTo(-1*r,i/2),t.lineTo(0,(i-s)/2)),t.lineTo(0,d),t.arc(d,d,d,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,i=this.pointerWidth(),n=this.pointerHeight(),r=this.pointerDirection(),s=this.width(),c=this.height();return r===a?(e-=n,c+=n):r===h?c+=n:r===l?(t-=1.5*i,s+=i):r===o&&(s+=1.5*i),{x:t,y:e,width:s,height:c}}}return Xv.Tag=u,u.prototype.className="Tag",(0,r._registerNode)(u),t.Factory.addGetterSetter(u,"pointerDirection","none"),t.Factory.addGetterSetter(u,"pointerWidth",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(u,"pointerHeight",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(u,"cornerRadius",0,(0,n.getNumberOrArrayOfNumbersValidator)(4)),Xv}(),o=Iv(),h=kv(),l=Kv(),c=function(){if(Zv)return Jv;Zv=1,Object.defineProperty(Jv,"__esModule",{value:!0}),Jv.RegularPolygon=void 0;const t=Vg(),e=pv(),i=Hg(),n=Dg();let r=class extends e.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y);t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(let n=0;n<t;n++)i.push({x:e*Math.sin(2*n*Math.PI/t),y:-1*e*Math.cos(2*n*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();let e=t[0].x,i=t[0].y,n=t[0].x,r=t[0].y;return t.forEach((t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),r=Math.max(r,t.y)})),{x:e,y:n,width:i-e,height:r-n}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}};return Jv.RegularPolygon=r,r.prototype.className="RegularPolygon",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["radius"],(0,n._registerNode)(r),t.Factory.addGetterSetter(r,"radius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"sides",0,(0,i.getNumberValidator)()),Jv}(),d=function(){if(Qv)return $v;Qv=1,Object.defineProperty($v,"__esModule",{value:!0}),$v.Ring=void 0;const t=Vg(),e=pv(),i=Hg(),n=Dg(),r=2*Math.PI;let s=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,r,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),r,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}};return $v.Ring=s,s.prototype.className="Ring",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,n._registerNode)(s),t.Factory.addGetterSetter(s,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"outerRadius",0,(0,i.getNumberValidator)()),$v}(),u=function(){if(t_)return e_;t_=1,Object.defineProperty(e_,"__esModule",{value:!0}),e_.Sprite=void 0;const t=Vg(),e=pv(),i=wv(),n=Hg(),r=Dg();let s=class extends e.Shape{constructor(t){super(t),this._updated=!0,this.anim=new i.Animation((()=>{const t=this._updated;return this._updated=!1,t})),this.on("animationChange.konva",(function(){this.frameIndex(0)})),this.on("frameIndexChange.konva",(function(){this._updated=!0})),this.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}))}_sceneFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,r=this.animations()[e],s=this.frameOffsets(),a=r[n+0],o=r[n+1],h=r[n+2],l=r[n+3],c=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),c)if(s){const n=s[e],r=2*i;t.drawImage(c,a,o,h,l,n[r+0],n[r+1],h,l)}else t.drawImage(c,a,o,h,l,0,0,h,l)}_hitFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,r=this.animations()[e],s=this.frameOffsets(),a=r[n+2],o=r[n+3];if(t.beginPath(),s){const n=s[e],r=2*i;t.rect(n[r+0],n[r+1],a,o)}else t.rect(0,0,a,o);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval((function(){t._updateIndex()}),1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}};return e_.Sprite=s,s.prototype.className="Sprite",(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"animation"),t.Factory.addGetterSetter(s,"animations"),t.Factory.addGetterSetter(s,"frameOffsets"),t.Factory.addGetterSetter(s,"image"),t.Factory.addGetterSetter(s,"frameIndex",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"frameRate",17,(0,n.getNumberValidator)()),t.Factory.backCompat(s,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"}),e_}(),p=function(){if(i_)return n_;i_=1,Object.defineProperty(n_,"__esModule",{value:!0}),n_.Star=void 0;const t=Vg(),e=pv(),i=Hg(),n=Dg();let r=class extends e.Shape{_sceneFunc(t){const e=this.innerRadius(),i=this.outerRadius(),n=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(let r=1;r<2*n;r++){const s=r%2==0?i:e,a=s*Math.sin(r*Math.PI/n),o=-1*s*Math.cos(r*Math.PI/n);t.lineTo(a,o)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}};return n_.Star=r,r.prototype.className="Star",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,n._registerNode)(r),t.Factory.addGetterSetter(r,"numPoints",5,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"outerRadius",0,(0,i.getNumberValidator)()),n_}(),m=a_(),f=function(){if(o_)return h_;o_=1,Object.defineProperty(h_,"__esModule",{value:!0}),h_.TextPath=void 0;const t=Ug(),e=Vg(),i=pv(),n=kv(),r=a_(),s=Hg(),a=Dg(),o="normal";function h(t){t.fillText(this.partialText,0,0)}function l(t){t.strokeText(this.partialText,0,0)}let c=class extends i.Shape{constructor(e){super(e),this.dummyCanvas=t.Util.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute(),this._setTextData()})),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return n.Path.getPathLength(this.dataArray)}_getPointAtLength(t){return this.attrs.data?t-1>this.pathLength?null:n.Path.getPointAtLengthOfDataArray(t,this.dataArray):null}_readDataAttribute(){this.dataArray=n.Path.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),i=this.fill(),n=this.fontSize(),r=this.glyphInfo;"underline"===e&&t.beginPath();for(let i=0;i<r.length;i++){t.save();const s=r[i].p0;t.translate(s.x,s.y),t.rotate(r[i].rotation),this.partialText=r[i].text,t.fillStrokeShape(this),"underline"===e&&(0===i&&t.moveTo(0,n/2+1),t.lineTo(n,n/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=i,t.lineWidth=n/20,t.stroke()),t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const i=e[0].p0;t.moveTo(i.x,i.y)}for(let i=0;i<e.length;i++){const n=e[i].p1;t.lineTo(n.x,n.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return r.Text.prototype.setText.call(this,t)}_getContextFont(){return r.Text.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let h=0;"center"===s&&(h=Math.max(0,this.pathLength/2-o/2)),"right"===s&&(h=Math.max(0,this.pathLength-o));const l=(0,r.stringToArray)(this.text());let c=h;for(let t=0;t<l.length;t++){const e=this._getPointAtLength(c);if(!e)return;let r=this._getTextSize(l[t]).width+i;if(" "===l[t]&&"justify"===s){const t=this.text().split(" ").length-1;r+=(this.pathLength-o)/t}const h=this._getPointAtLength(c+r);if(!h)return;const d=n.Path.getLineLength(e.x,e.y,h.x,h.y);let u=0;if(a)try{u=a(l[t-1],l[t])*this.fontSize()}catch(t){u=0}e.x+=u,h.x+=u,this.textWidth+=u;const p=n.Path.getPointOnLine(u+d/2,e.x,e.y,h.x,h.y),m=Math.atan2(h.y-e.y,h.x-e.x);this.glyphInfo.push({transposeX:p.x,transposeY:p.y,text:l[t],rotation:m,p0:e,p1:h}),c+=r}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const t=[];this.glyphInfo.forEach((function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)}));let e,i,n=t[0]||0,r=t[0]||0,s=t[1]||0,a=t[1]||0;for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),r=Math.max(r,e),s=Math.min(s,i),a=Math.max(a,i);const o=this.fontSize();return{x:n-o/2,y:s-o/2,width:r-n+o,height:a-s+o}}destroy(){return t.Util.releaseCanvas(this.dummyCanvas),super.destroy()}};return h_.TextPath=c,c.prototype._fillFunc=h,c.prototype._strokeFunc=l,c.prototype._fillFuncHit=h,c.prototype._strokeFuncHit=l,c.prototype.className="TextPath",c.prototype._attrsAffectingSize=["text","fontSize","data"],(0,a._registerNode)(c),e.Factory.addGetterSetter(c,"data"),e.Factory.addGetterSetter(c,"fontFamily","Arial"),e.Factory.addGetterSetter(c,"fontSize",12,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(c,"fontStyle",o),e.Factory.addGetterSetter(c,"align","left"),e.Factory.addGetterSetter(c,"letterSpacing",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(c,"textBaseline","middle"),e.Factory.addGetterSetter(c,"fontVariant",o),e.Factory.addGetterSetter(c,"text",""),e.Factory.addGetterSetter(c,"textDecoration",""),e.Factory.addGetterSetter(c,"kerningFunc",void 0),h_}(),g=d_(),v=function(){if(u_)return p_;u_=1,Object.defineProperty(p_,"__esModule",{value:!0}),p_.Wedge=void 0;const t=Vg(),e=pv(),i=Dg(),n=Hg(),r=Dg();let s=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,i.Konva.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}};return p_.Wedge=s,s.prototype.className="Wedge",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["radius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"radius",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"angle",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"clockwise",!1),t.Factory.backCompat(s,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"}),p_}(),_=g_(),y=function(){if(v_)return __;v_=1,Object.defineProperty(__,"__esModule",{value:!0}),__.Brighten=void 0;const t=Vg(),e=tv(),i=Hg();return __.Brighten=function(t){const e=255*this.brightness(),i=t.data,n=i.length;for(let t=0;t<n;t+=4)i[t]+=e,i[t+1]+=e,i[t+2]+=e},t.Factory.addGetterSetter(e.Node,"brightness",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),__}(),x=function(){if(y_)return x_;y_=1,Object.defineProperty(x_,"__esModule",{value:!0}),x_.Contrast=void 0;const t=Vg(),e=tv(),i=Hg();return x_.Contrast=function(t){const e=Math.pow((this.contrast()+100)/100,2),i=t.data,n=i.length;let r=150,s=150,a=150;for(let t=0;t<n;t+=4)r=i[t],s=i[t+1],a=i[t+2],r/=255,r-=.5,r*=e,r+=.5,r*=255,s/=255,s-=.5,s*=e,s+=.5,s*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,r=r<0?0:r>255?255:r,s=s<0?0:s>255?255:s,a=a<0?0:a>255?255:a,i[t]=r,i[t+1]=s,i[t+2]=a},t.Factory.addGetterSetter(e.Node,"contrast",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),x_}(),b=function(){if(b_)return w_;b_=1,Object.defineProperty(w_,"__esModule",{value:!0}),w_.Emboss=void 0;const t=Vg(),e=tv(),i=Ug(),n=Hg();return w_.Emboss=function(t){const e=10*this.embossStrength(),n=255*this.embossWhiteLevel(),r=this.embossDirection(),s=this.embossBlend(),a=t.data,o=t.width,h=t.height,l=4*o;let c=0,d=0,u=h;switch(r){case"top-left":c=-1,d=-1;break;case"top":c=-1,d=0;break;case"top-right":c=-1,d=1;break;case"right":c=0,d=1;break;case"bottom-right":c=1,d=1;break;case"bottom":c=1,d=0;break;case"bottom-left":c=1,d=-1;break;case"left":c=0,d=-1;break;default:i.Util.error("Unknown emboss direction: "+r)}do{const t=(u-1)*l;let i=c;u+i<1&&(i=0),u+i>h&&(i=0);const r=(u-1+i)*o*4;let p=o;do{const i=t+4*(p-1);let h=d;p+h<1&&(h=0),p+h>o&&(h=0);const l=r+4*(p-1+h),c=a[i]-a[l],u=a[i+1]-a[l+1],m=a[i+2]-a[l+2];let f=c;const g=f>0?f:-f;if((u>0?u:-u)>g&&(f=u),(m>0?m:-m)>g&&(f=m),f*=e,s){const t=a[i]+f,e=a[i+1]+f,n=a[i+2]+f;a[i]=t>255?255:t<0?0:t,a[i+1]=e>255?255:e<0?0:e,a[i+2]=n>255?255:n<0?0:n}else{let t=n-f;t<0?t=0:t>255&&(t=255),a[i]=a[i+1]=a[i+2]=t}}while(--p)}while(--u)},t.Factory.addGetterSetter(e.Node,"embossStrength",.5,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossWhiteLevel",.5,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossDirection","top-left",void 0,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossBlend",!1,void 0,t.Factory.afterSetFilter),w_}(),w=function(){if(S_)return M_;S_=1,Object.defineProperty(M_,"__esModule",{value:!0}),M_.Enhance=void 0;const t=Vg(),e=tv(),i=Hg();function n(t,e,i,n,r){const s=i-e,a=r-n;if(0===s)return n+a/2;if(0===a)return n;let o=(t-e)/s;return o=a*o+n,o}return M_.Enhance=function(t){const e=t.data,i=e.length;let r,s,a,o=e[0],h=o,l=e[1],c=l,d=e[2],u=d;const p=this.enhance();if(0===p)return;for(let t=0;t<i;t+=4)r=e[t+0],r<o?o=r:r>h&&(h=r),s=e[t+1],s<l?l=s:s>c&&(c=s),a=e[t+2],a<d?d=a:a>u&&(u=a);let m,f,g,v,_,y,x,b,w;h===o&&(h=255,o=0),c===l&&(c=255,l=0),u===d&&(u=255,d=0),p>0?(f=h+p*(255-h),g=o-p*(o-0),_=c+p*(255-c),y=l-p*(l-0),b=u+p*(255-u),w=d-p*(d-0)):(m=.5*(h+o),f=h+p*(h-m),g=o+p*(o-m),v=.5*(c+l),_=c+p*(c-v),y=l+p*(l-v),x=.5*(u+d),b=u+p*(u-x),w=d+p*(d-x));for(let t=0;t<i;t+=4)e[t+0]=n(e[t+0],o,h,g,f),e[t+1]=n(e[t+1],l,c,y,_),e[t+2]=n(e[t+2],d,u,w,b)},t.Factory.addGetterSetter(e.Node,"enhance",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),M_}(),S=(T_||(T_=1,Object.defineProperty(E_,"__esModule",{value:!0}),E_.Grayscale=void 0,E_.Grayscale=function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=.34*e[t]+.5*e[t+1]+.16*e[t+2];e[t]=i,e[t+1]=i,e[t+2]=i}}),E_),M=function(){if(A_)return C_;A_=1,Object.defineProperty(C_,"__esModule",{value:!0}),C_.HSL=void 0;const t=Vg(),e=tv(),i=Hg();return t.Factory.addGetterSetter(e.Node,"hue",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"luminance",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),C_.HSL=function(t){const e=t.data,i=e.length,n=Math.pow(2,this.saturation()),r=Math.abs(this.hue()+360)%360,s=127*this.luminance(),a=1*n*Math.cos(r*Math.PI/180),o=1*n*Math.sin(r*Math.PI/180),h=.299+.701*a+.167*o,l=.587-.587*a+.33*o,c=.114-.114*a-.497*o,d=.299-.299*a-.328*o,u=.587+.413*a+.035*o,p=.114-.114*a+.293*o,m=.299-.3*a+1.25*o,f=.587-.586*a-1.05*o,g=.114+.886*a-.2*o;let v,_,y,x;for(let t=0;t<i;t+=4)v=e[t+0],_=e[t+1],y=e[t+2],x=e[t+3],e[t+0]=h*v+l*_+c*y+s,e[t+1]=d*v+u*_+p*y+s,e[t+2]=m*v+f*_+g*y+s,e[t+3]=x},C_}(),T=function(){if(R_)return P_;R_=1,Object.defineProperty(P_,"__esModule",{value:!0}),P_.HSV=void 0;const t=Vg(),e=tv(),i=Hg();return P_.HSV=function(t){const e=t.data,i=e.length,n=Math.pow(2,this.value()),r=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,a=n*r*Math.cos(s*Math.PI/180),o=n*r*Math.sin(s*Math.PI/180),h=.299*n+.701*a+.167*o,l=.587*n-.587*a+.33*o,c=.114*n-.114*a-.497*o,d=.299*n-.299*a-.328*o,u=.587*n+.413*a+.035*o,p=.114*n-.114*a+.293*o,m=.299*n-.3*a+1.25*o,f=.587*n-.586*a-1.05*o,g=.114*n+.886*a-.2*o;let v,_,y,x;for(let t=0;t<i;t+=4)v=e[t+0],_=e[t+1],y=e[t+2],x=e[t+3],e[t+0]=h*v+l*_+c*y,e[t+1]=d*v+u*_+p*y,e[t+2]=m*v+f*_+g*y,e[t+3]=x},t.Factory.addGetterSetter(e.Node,"hue",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"value",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),P_}(),E=(L_||(L_=1,Object.defineProperty(I_,"__esModule",{value:!0}),I_.Invert=void 0,I_.Invert=function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]}),I_),A=N_(),C=k_(),R=function(){if(B_)return z_;B_=1,Object.defineProperty(z_,"__esModule",{value:!0}),z_.Noise=void 0;const t=Vg(),e=tv(),i=Hg();return z_.Noise=function(t){const e=255*this.noise(),i=t.data,n=i.length,r=e/2;for(let t=0;t<n;t+=4)i[t+0]+=r-2*r*Math.random(),i[t+1]+=r-2*r*Math.random(),i[t+2]+=r-2*r*Math.random()},t.Factory.addGetterSetter(e.Node,"noise",.2,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),z_}(),P=function(){if(G_)return H_;G_=1,Object.defineProperty(H_,"__esModule",{value:!0}),H_.Pixelate=void 0;const t=Vg(),e=Ug(),i=tv(),n=Hg();return H_.Pixelate=function(t){let i,n,r,s,a,o,h,l,c,d,u,p,m,f,g=Math.ceil(this.pixelSize()),v=t.width,_=t.height,y=Math.ceil(v/g),x=Math.ceil(_/g),b=t.data;if(g<=0)e.Util.error("pixelSize value can not be <= 0");else for(p=0;p<y;p+=1)for(m=0;m<x;m+=1){for(s=0,a=0,o=0,h=0,l=p*g,c=l+g,d=m*g,u=d+g,f=0,i=l;i<c;i+=1)if(!(i>=v))for(n=d;n<u;n+=1)n>=_||(r=4*(v*n+i),s+=b[r+0],a+=b[r+1],o+=b[r+2],h+=b[r+3],f+=1);for(s/=f,a/=f,o/=f,h/=f,i=l;i<c;i+=1)if(!(i>=v))for(n=d;n<u;n+=1)n>=_||(r=4*(v*n+i),b[r+0]=s,b[r+1]=a,b[r+2]=o,b[r+3]=h)}},t.Factory.addGetterSetter(i.Node,"pixelSize",8,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),H_}(),L=function(){if(V_)return W_;V_=1,Object.defineProperty(W_,"__esModule",{value:!0}),W_.Posterize=void 0;const t=Vg(),e=tv(),i=Hg();return W_.Posterize=function(t){const e=Math.round(254*this.levels())+1,i=t.data,n=i.length,r=255/e;for(let t=0;t<n;t+=1)i[t]=Math.floor(i[t]/r)*r},t.Factory.addGetterSetter(e.Node,"levels",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),W_}(),I=function(){if(j_)return X_;j_=1,Object.defineProperty(X_,"__esModule",{value:!0}),X_.RGB=void 0;const t=Vg(),e=tv(),i=Hg();return X_.RGB=function(t){const e=t.data,i=e.length,n=this.red(),r=this.green(),s=this.blue();for(let t=0;t<i;t+=4){const i=(.34*e[t]+.5*e[t+1]+.16*e[t+2])/255;e[t]=i*n,e[t+1]=i*r,e[t+2]=i*s,e[t+3]=e[t+3]}},t.Factory.addGetterSetter(e.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"blue",0,i.RGBComponent,t.Factory.afterSetFilter),X_}(),D=function(){if(Y_)return q_;Y_=1,Object.defineProperty(q_,"__esModule",{value:!0}),q_.RGBA=void 0;const t=Vg(),e=tv(),i=Hg();return q_.RGBA=function(t){const e=t.data,i=e.length,n=this.red(),r=this.green(),s=this.blue(),a=this.alpha();for(let t=0;t<i;t+=4){const i=1-a;e[t]=n*a+e[t]*i,e[t+1]=r*a+e[t+1]*i,e[t+2]=s*a+e[t+2]*i}},t.Factory.addGetterSetter(e.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"blue",0,i.RGBComponent,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t})),q_}(),O=(K_||(K_=1,Object.defineProperty(Z_,"__esModule",{value:!0}),Z_.Sepia=void 0,Z_.Sepia=function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=e[t+0],n=e[t+1],r=e[t+2];e[t+0]=Math.min(255,.393*i+.769*n+.189*r),e[t+1]=Math.min(255,.349*i+.686*n+.168*r),e[t+2]=Math.min(255,.272*i+.534*n+.131*r)}}),Z_),N=(J_||(J_=1,Object.defineProperty(Q_,"__esModule",{value:!0}),Q_.Solarize=void 0,Q_.Solarize=function(t){const e=t.data,i=t.width,n=4*i;let r=t.height;do{const t=(r-1)*n;let s=i;do{const i=t+4*(s-1);let n=e[i],r=e[i+1],a=e[i+2];n>127&&(n=255-n),r>127&&(r=255-r),a>127&&(a=255-a),e[i]=n,e[i+1]=r,e[i+2]=a}while(--s)}while(--r)}),Q_),U=function(){if($_)return ey;$_=1,Object.defineProperty(ey,"__esModule",{value:!0}),ey.Threshold=void 0;const t=Vg(),e=tv(),i=Hg();return ey.Threshold=function(t){const e=255*this.threshold(),i=t.data,n=i.length;for(let t=0;t<n;t+=1)i[t]=i[t]<e?0:255},t.Factory.addGetterSetter(e.Node,"threshold",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),ey}();return Pg.Konva=t.Konva.Util._assign(t.Konva,{Arc:e.Arc,Arrow:i.Arrow,Circle:n.Circle,Ellipse:r.Ellipse,Image:s.Image,Label:a.Label,Tag:a.Tag,Line:o.Line,Path:h.Path,Rect:l.Rect,RegularPolygon:c.RegularPolygon,Ring:d.Ring,Sprite:u.Sprite,Star:p.Star,Text:m.Text,TextPath:f.TextPath,Transformer:g.Transformer,Wedge:v.Wedge,Filters:{Blur:_.Blur,Brighten:y.Brighten,Contrast:x.Contrast,Emboss:b.Emboss,Enhance:w.Enhance,Grayscale:S.Grayscale,HSL:M.HSL,HSV:T.HSV,Invert:E.Invert,Kaleidoscope:A.Kaleidoscope,Mask:C.Mask,Noise:R.Noise,Pixelate:P.Pixelate,Posterize:L.Posterize,RGB:I.RGB,RGBA:D.RGBA,Sepia:O.Sepia,Solarize:N.Solarize,Threshold:U.Threshold}}),Pg}var ny,ry=Rg.exports;var sy=Ag(function(){if(ny)return Rg.exports;ny=1,Object.defineProperty(ry,"__esModule",{value:!0});const t=iy();return Rg.exports=t.Konva,Rg.exports}());class ay{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}class oy{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const n=t=>{const e=t.toString(16);return"0"===e?"00":e};return n(t)+n(e)+n(i)}}const hy=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class ly{constructor(t,e=null,i=new ay){var n,r;if(this._worldTransformer=i,e){this._ref=e;let t=this._ref.getAttr("wcsPoints");if(!t){t=[];const e=this._ref.points();let i;for(let n=0;n<e.length;n+=2)i=this._worldTransformer.screenToWorld({x:e[n],y:e[n+1]}),t.push({x:i.x,y:i.y,z:i.z});this._ref.setAttr("wcsPoints",t)}return}t||(t={}),t.points||(t.points=[{x:0,y:0},{x:100,y:100}]);const s=[],a=[];t.points.forEach((t=>{s.push(t.x,t.y);const e=this._worldTransformer.screenToWorld({x:t.x,y:t.y});a.push({x:e.x,y:e.y,z:e.z})})),this._ref=new sy.Line({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(r=t.width)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:s,draggable:!0,strokeScaleEnabled:!1,dash:hy.get(t.type)||[]}),this._ref.setAttr("wcsPoints",a),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),this._ref.on("transformend",(()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let n;for(let r=0;r<i.length;r+=2){const s=t.point({x:i[r],y:i[r+1]});n=this._worldTransformer.screenToWorld({x:s.x,y:s.y}),e.push({x:n.x,y:n.y,z:n.z})}this._ref.setAttr("wcsPoints",e)})),this._ref.on("dragend",(()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let n;for(let r=0;r<i.length;r+=2){const s=t.point({x:i[r],y:i[r+1]});n=this._worldTransformer.screenToWorld({x:s.x,y:s.y}),e.push({x:n.x,y:n.y,z:n.z})}this._ref.setAttr("wcsPoints",e)})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case hy.get("dot"):t="dot";break;case hy.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=hy.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();const i=this._ref.getAttr("wcsPoints");t.forEach((t=>{e=e.concat([t.x,t.y]);const n=this._worldTransformer.screenToWorld(t);i.push(n)})),this._ref.points(e)}updateScreenCoordinates(){const t=this._ref.getAttr("wcsPoints"),e=[];let i=this._ref.getAbsoluteTransform().copy();i=i.invert(),t.forEach((t=>{let n=this._worldTransformer.worldToScreen(t);n=i.point({x:n.x,y:n.y}),e.push(n.x),e.push(n.y)})),this._ref.points([]),this._ref.points(e),this._ref.clearCache()}}class cy{constructor(t,e=null,i=new ay){var n,r,s;if(this.TEXT_FONT_FAMILY="Calibri",this._worldTransformer=i,e){this._ref=e;this._ref.getAttr("wcsStart")||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()}))}else t||(t={}),t.position||(t.position={x:0,y:0}),t.text||(t.text="default"),this._ref=new sy.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(n=t.fontSize)&&void 0!==n?n:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",align:"left",draggable:!0,rotation:null!==(s=t.rotation)&&void 0!==s?s:0}),this._ref.width(this._ref.getTextWidth()),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY);r<50&&(r=50),s<Math.round(this.getFontSize())&&(s=Math.round(this.getFontSize())),i&&this._ref.width(r),n&&this._ref.height(s),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t))})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));let e=this._ref.getStage().getAbsoluteTransform().copy();e=e.invert();const i=e.point(t);this._ref.position({x:i.x,y:i.y})}}class dy{constructor(t,e=null,i=new ay){var n,r,s,a;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}}else t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200),this._ref=new sy.Rect({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(s=t.width)&&void 0!==s?s:200,height:null!==(a=t.height)&&void 0!==a?a:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",(t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY);r<50&&(r=50),s<50&&(s=50),i&&this._ref.width(r),n&&this._ref.height(s),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))})),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeight(){return this._ref.height()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),r=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(r.x-n.x)),this._ref.height(Math.abs(r.y-n.y))}}function uy(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}class py{constructor(t,e=null,i=new ay){var n,r,s;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsPosition"),i=this._ref.getAttr("wcsRadiusX"),n=this._ref.getAttr("wcsRadiusY");return t||this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),i||this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:e.x()+e.radiusX(),y:e.y()})),void(n||this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()+e.radiusY()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(null!==(n=t.radius)&&void 0!==n||(t.radius={x:0,y:0}),t.radius.x=uy(t.position,t.position2),t.position3?t.radius.y=uy(t.position,t.position3):t.radius.x=t.radius.y):t.radius||(t.radius={x:25,y:25}),this._ref=new sy.Ellipse({stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(s=t.lineWidth)&&void 0!==s?s:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t.radius.x,y:this._ref.y()})),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t.radius.y})),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.radiusX();i&&(r*=e.scaleX);let s=this._ref.radiusY();n&&(s*=e.scaleY);r<25&&(r=25),s<25&&(s=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:r,y:r}):this._ref.radius({x:s,y:s}):this._ref.radius({x:r,y:s}),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const n=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(n))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const n=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(n))})),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t,y:e}))}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t,y:this._ref.y()}))}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(t),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t}))}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsPosition")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusX")),i=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusY"));let n=this._ref.getStage().getAbsoluteTransform().copy();n=n.invert();const r=n.point({x:t.x,y:t.y});this._ref.position({x:r.x,y:r.y}),this._ref.radius({x:Math.abs(n.point(e).x-r.x),y:Math.abs(n.point(i).y-r.y)})}}class my{constructor(t,e=null,i=new ay){var n,r;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");return t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.points()[0],y:e.points()[1]})),void(i||this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:e.points()[2],y:e.points()[3]})))}t||(t={}),t.start||(t.start={x:0,y:0}),t.end||(t.end={x:100,y:100}),this._ref=new sy.Arrow({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.start.x,y:t.start.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.end.x,y:t.end.y})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.points(),n=this._ref.getAbsoluteTransform(),r=n.point({x:i[0],y:i[1]}),s=n.point({x:i[2],y:i[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(r)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(s))})),this._ref.on("dragend",(t=>{const e=this._ref.points(),i=t.target.getAbsoluteTransform(),n=i.point({x:e[0],y:e[1]}),r=i.point({x:e[2],y:e[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(n)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(r))})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&(this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t[0].x,y:t[0].y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t[1].x,y:t[1].y})),this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y]))}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]]),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e]),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t,y:e}))}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getAbsoluteTransform().copy();i=i.invert();const n=i.point({x:t.x,y:t.y}),r=i.point({x:e.x,y:e.y});this._ref.points([n.x,n.y,r.x,r.y])}}class fy{constructor(t,e=null,i=new ay){var n,r;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_HEADER_START="data:image/",this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",this._worldTransformer=i,e){e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width();const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}}else t||(t={}),t.position||(t.position={x:0,y:0}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),t.position2&&(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}const e=this._worldTransformer.screenToWorld({x:t.position.x+this._ref.width(),y:t.position.y+this._ref.height()});this._ref.setAttr("wcsEnd",e)},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new sy.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(n=t.width)&&void 0!==n?n:0,height:null!==(r=t.height)&&void 0!==r?r:0,draggable:!0}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(r),this._ref.height(r*this._ratio)):(this._ref.width(s/this._ratio),this._ref.height(s)):(i&&this._ref.width(r),n&&this._ref.height(s)),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))})),this._ref.id(this._ref._id.toString())}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),r=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(r.x-n.x)),this._ref.height(Math.abs(r.y-n.y))}}class gy{constructor(t,e=null,i=new ay){var n,r,s,a;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200);this._ref=new sy.Shape({x:t.position.x,y:t.position.y,width:null!==(n=t.width)&&void 0!==n?n:200,height:null!==(r=t.height)&&void 0!==r?r:200,stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:null!==(a=t.lineWidth)&&void 0!==a?a:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=this._ref.width(),n=this._ref.height(),r=[{x:0,y:0},{x:0+i,y:0},{x:0+i,y:0+n},{x:0,y:0+n},{x:0,y:0}];function s(s,a){const o={x:(h={x:0,y:0}).x+i/2,y:h.y+n/2};var h;t.beginPath();for(let e=0;e<r.length-1;e++){let i=a;const n=r[e+1].x-r[e].x,h=r[e+1].y-r[e].y,l=Math.sqrt(n*n+h*h),c=Math.floor(l/i);i=a+c/(l%i);let d=r[e].x+n/c/2,u=r[e].y+h/c/2;const p=r[e+1].x,m=r[e+1].y,f=Math.atan((m-u)/(p-d)),g=f+Math.PI,v=d>o.x&&u>o.y;for(let e=0;e<c;e++)v?t.arc(d,u,s,f,g):t.arc(d,u,s,g,f),d+=n/c,u+=h/c}t.closePath(),t.fillStrokeShape(e)}i>=49||n>=49?s(8,15):i>=25||n>=25?s(4,7.5):(t.beginPath(),t.lineTo(r[1].x,r[1].y),t.lineTo(r[2].x,r[2].y),t.lineTo(r[3].x,r[3].y),t.lineTo(r[4].x,r[4].y),t.closePath(),t.fillStrokeShape(e))}}),this._ref.className="Cloud",this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",(t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let s=this._ref.height();n&&(s*=e.scaleY),r<50&&(r=50),s<50&&(s=50),i&&this._ref.width(r),n&&this._ref.height(s),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))})),this._ref.getSelfRect=()=>({x:-8,y:-8,width:this._ref.width()+16,height:this._ref.height()+16}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),r=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(r.x-n.x)),this._ref.height(Math.abs(r.y-n.y))}}const vy={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null,...i)=>new ly(e,t,...i)},Text:{name:"Text",initializer:(t,e=null,...i)=>new cy(e,t,...i)},Rectangle:{name:"Rect",initializer:(t,e=null,...i)=>new dy(e,t,...i)},Ellipse:{name:"Ellipse",initializer:(t,e=null,...i)=>new py(e,t,...i)},Arrow:{name:"Arrow",initializer:(t,e=null,...i)=>new my(e,t,...i)},Image:{name:"Image",initializer:(t,e=null,...i)=>new fy(e,t,...i)},Cloud:{name:"Cloud",initializer:(t,e=null,...i)=>new gy(e,t,...i)}};class _y{constructor(){this._markupIsActive=!1,this._markupColor=new oy(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=t=>{if(!t||!t[0]||!t[0].contentRect)return;const{width:e,height:i}=t[0].contentRect;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i),this.getObjects().forEach((t=>{t.updateScreenCoordinates()})))},this.resizeViewer=t=>{const{width:e,height:i}=t;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i),this.getObjects().forEach((t=>{t.updateScreenCoordinates()})))},this.pan=()=>{this.getObjects().forEach((t=>{t.updateScreenCoordinates()}))},this.zoomAt=()=>{this.getObjects().forEach((t=>{t.updateScreenCoordinates()}))},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const i=e.getAbsoluteTransform().copy();return i.invert(),i.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,i,n){if(!sy)throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');this._viewer=i,this._worldTransformer=null!=n?n:new ay,this._container=t,this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";this._container.parentElement.appendChild(this._markupContainer),i?this._viewer.addEventListener("resize",this.resizeViewer):this._resizeObserver=new ResizeObserver(function(t,e){let i=null;return(...n)=>{i&&clearTimeout(i),i=setTimeout((()=>{i=null,t(...n)}),e)}}(this.resizeContainer,100)),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),this.destroyKonva(),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach((t=>t.delete()))}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i),this.redirectToViewer({type:"changemarkupcolor",data:{r:t,g:e,b:i}})}colorizeAllMarkup(t,e,i){this.setMarkupColor(t,e,i);const n=new oy(t,e,i).asHex();this.getObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,n)}))}colorizeSelectedMarkups(t,e,i){const n=new oy(t,e,i).asHex();this.getSelectedObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,n)}))}setViewpoint(t){var e,i,n,r,s,a,o,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach((t=>{const e=[];t.points.forEach((t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)})),this.addLine(e,t.color,t.type,t.width,t.id)})),null===(n=t.texts)||void 0===n||n.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)})),null===(r=t.rectangles)||void 0===r||r.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addRectangle(e,i,t.width,t.height,t.line_width,t.color,t.id)})),null===(s=t.ellipses)||void 0===s||s.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null,n=t.position3?this._worldTransformer.worldToScreen(t.position3):null;this.addEllipse(e,i,n,t.radius,t.line_width,t.color,t.id)})),null===(a=t.arrows)||void 0===a||a.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)})),null===(o=t.clouds)||void 0===o||o.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addCloud(e,i,t.width,t.height,t.line_width,t.color,t.id)})),null===(h=t.images)||void 0===h||h.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addImage(e,i,t.src,t.width,t.height,t.id)}))}getViewpoint(t){return t||(t={}),t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.custom_fields={markup_color:this.getMarkupColor()},t.snapshot={data:this.combineMarkupWithDrawing()},t}enableEditMode(t){return t&&vy[t]?(this._markupMode=t,this._markupContainer.style.pointerEvents="all",this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupContainer.style.pointerEvents="none",this._markupIsActive=!1),this}createObject(t,e){const i=vy[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const n=i.initializer(null,e,this._worldTransformer);return this.addObject(n),n}getObjects(){const t=[];return Object.keys(vy).forEach((e=>{const i=vy[e];this.konvaLayerFind(e).forEach((e=>t.push(i.initializer(e,null,this._worldTransformer))))})),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map((t=>{const e=t.className,i=Object.values(vy).find((t=>t.name===e));return i?i.initializer(t,null,this._worldTransformer):null})).filter((t=>t)):[]}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map((t=>t.ref())));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=vy[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter((t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts)):[]}initializeKonva(){const t=new sy.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new sy.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new sy.Group,e.add(this._groupImages),this._groupGeometry=new sy.Group,e.add(this._groupGeometry),this._groupTexts=new sy.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new sy.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let n,r,s,a=!1;t.on("mousedown touchstart",(e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const s=this.getRelativePointerPosition(t);r=s,a=["Arrow","Cloud","Ellipse","Line","Rectangle"].some((t=>t===this._markupMode)),"Line"===this._markupMode&&(n=this.addLine([s.x,s.y,s.x,s.y]))})),t.on("mouseup touchend",(()=>{if(this._markupIsActive){if(a){const e=this.getRelativePointerPosition(t),i=r&&e.x===r.x&&e.y===r.y,n=i?r.x:Math.min(r.x,e.x),s=i?r.y:Math.min(r.y,e.y),a=i?200:Math.abs(r.x-e.x),o=i?200:Math.abs(r.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:n,y:s},null,a,o):"Ellipse"===this._markupMode?this.addEllipse({x:n,y:s},null,null,{x:a/2,y:o/2}):"Arrow"===this._markupMode?this.addArrow({x:r.x,y:r.y},{x:i?r.x+200:e.x,y:i?s:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:n,y:s},null,Math.max(100,a),Math.max(100,o)))}s=void 0,a=!1}})),t.on("mousemove touchmove",(()=>{if(!this._markupIsActive)return;if(!a)return;const e=this.getRelativePointerPosition(t),i=r&&e.x===r.x&&e.y===r.y,o=i?r.x:Math.min(r.x,e.x),h=i?r.y:Math.min(r.y,e.y),l=i?200:Math.abs(r.x-e.x),c=i?200:Math.abs(r.y-e.y);"Line"===this._markupMode?n.addPoints([{x:e.x,y:e.y}]):"Arrow"===this._markupMode?s?s.setEndPoint(e.x,e.y):s=this.addArrow({x:r.x,y:r.y},{x:e.x,y:e.y}):"Rectangle"===this._markupMode?s?(s.setPosition(o,h),s.setWidth(l),s.setHeight(c)):s=this.addRectangle({x:o,y:h},null,l,c):"Ellipse"===this._markupMode?s?(s.setPosition(o,h),s.setRadiusX(l),s.setRadiusY(c)):s=this.addEllipse({x:o,y:h},null,null,{x:l,y:c}):"Cloud"===this._markupMode&&(s?(s.setPosition(o,h),s.setWidth(Math.max(100,l)),s.setHeight(Math.max(100,c))):s=this.addCloud({x:o,y:h},null,l,c))})),t.on("click tap",(e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=this.getRelativePointerPosition(t);this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,null,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter((t=>"Cloud"===t.className||"Image"===t.className)).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const n=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,r=i.nodes().indexOf(e.target)>=0;if(n||r){if(n&&r){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(n&&!r){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])}));const o=t.container();o.tabIndex=1,o.focus(),o.addEventListener("keydown",(t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach((t=>t.delete())),void this.clearSelected()):void t.preventDefault()}))}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach((e=>{const i=e.getAttr("wcsPoints");if(!i)return;const n=new ly(null,e,this._worldTransformer),r={id:n.id(),points:i,color:n.getColor()||"#ff0000",type:n.getLineType()||this.lineType,width:n.getLineWidth()||this.lineWidth};t.push(r)})),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach((e=>{const i=this._worldTransformer.getScale(),n=e.getAttr("wcsStart"),r=this._konvaStage.getAbsoluteTransform(),s=new cy(null,e,this._worldTransformer),a={id:s.id(),position:n,text:s.getText(),text_size:.02*i.y,angle:s.getRotation(),color:s.getColor(),font_size:s.getFontSize()*r.getMatrix()[0]};t.push(a)})),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach((e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=this._worldTransformer.worldToScreen(i),s=this._worldTransformer.worldToScreen(n),a=new dy(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,width:Math.abs(r.x-s.x),height:Math.abs(r.y-s.y),line_width:a.getLineWidth(),color:a.getColor()};t.push(o)})),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach((e=>{const i=e.getAttr("wcsPosition"),n=e.getAttr("wcsRadiusX"),r=e.getAttr("wcsRadiusY"),s=this._konvaStage.getAbsoluteTransform().getMatrix()[0],a=new py(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,position3:r,radius:{x:e.getRadiusX()*s,y:e.getRadiusY()*s},line_width:a.getLineWidth(),color:a.getColor()};t.push(o)})),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach((e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=new my(null,e,this._worldTransformer),s={id:r.id(),start:i,end:n,color:r.getColor()};t.push(s)})),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach((e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=this._konvaStage.getAbsoluteTransform().getMatrix()[0],s=new fy(null,e,this._worldTransformer),a={id:s.id(),position:i,position2:n,src:s.getSrc(),width:s.getWidth()*r,height:s.getHeight()*r};t.push(a)})),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach((e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),r=this._worldTransformer.worldToScreen(i),s=this._worldTransformer.worldToScreen(n),a=new gy(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,width:Math.abs(r.x-s.x),height:Math.abs(r.y-s.y),line_width:a.getLineWidth(),color:a.getColor()};t.push(o)})),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,i,n,r){if(!t||0===t.length)return;const s=[];for(let e=0;e<t.length;e+=2)s.push({x:t[e],y:t[e+1]});const a=new ly({points:s,type:i||this.lineType,width:n||this.lineWidth,color:e||this._markupColor.asHex(),id:r},null,this._worldTransformer);return this.addObject(a),a}createTextInput(t,e,i,n,r){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=n,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},r&&(this._textInputRef.value=r),document.body.appendChild(this._textInputRef),setTimeout((()=>{this._textInputRef.focus()}),50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise(((e,i)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>{e(n.result)},n.onerror=t=>{i(t)}}));this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],n=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,n.toString(),0,0)},this._imageInputRef.oncancel=()=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout((()=>{this._imageInputRef.click()}),50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,n,r,s,a){var o;if(!t)return;null===(o=this.getSelectedObjects().at(0))||void 0===o||o.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(r&&r>h&&(!s||s<h)){const t=.02;s=r/(this._worldTransformer.getScale().y/t)/34}const l=new cy({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:s||this.fontSize,color:n||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(l),l}addRectangle(t,e,i,n,r,s,a){if(!t)return;const o=new dy({position:t,position2:e,width:i,height:n,lineWidth:r||this.lineWidth,color:s||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(o),o}addEllipse(t,e,i,n,r,s,a){if(!t)return;const o=new py({position:t,position2:e,position3:i,radius:n,lineWidth:r,color:s||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(o),o}addArrow(t,e,i,n){if(!t||!e)return;const r=new my({start:t,end:e,color:i||this._markupColor.asHex(),id:n},null,this._worldTransformer);return this.addObject(r),r}addCloud(t,e,i,n,r,s,a){if(!t||!i||!n)return;const o=new gy({position:t,position2:e,width:i,height:n,color:s||this._markupColor.asHex(),lineWidth:r||this.lineWidth,id:a},null,this._worldTransformer);return this.addObject(o),o}addImage(t,e,i,n,r,s){var a;if(!t||!i)return;null===(a=this.getSelectedObjects().at(0))||void 0===a||a.delete(),this.clearSelected(),this.removeImageInput();const o=new fy({position:t,position2:e,src:i,width:n,height:r,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:s},null,this._worldTransformer);return this.addObject(o),o}}"undefined"!=typeof window&&(window.THREE=_p),t.CANVAS_EVENTS=v,t.CanvasEvents=g,t.Component=class{constructor(t){this.name=""}dispose(){}},t.Dragger=class{constructor(t){this.name=""}dispose(){}},t.GLTFLoadingManager=lg,t.Loader=c,t.Markup=_y,t.ModelImpl=cg,t.Options=f,t.Viewer=class extends Tg{constructor(t){super(),this._options=new f(this),this.client=t,this.canvasEvents=v,this.canvaseventlistener=t=>this.emit(t),this.loaders=[],this.models=[],this.selected=[],this.extents=new Li,this.target=new Ci,this._activeDragger=null,this._components=[],this.renderTime=0,this.render=this.render.bind(this),this.update=this.update.bind(this),this._markup=new _y}get options(){return this._options}get draggers(){return[...Um.getDraggers().keys()]}get components(){return[...hf.getComponents().keys()]}get markup(){return this._markup}initialize(t,e){this.addEventListener("optionschange",(t=>this.syncOptions(t.data))),this.scene=new es,this.helpers=new es,this.target=new Ci;const i=window.devicePixelRatio,n=t.parentElement.getBoundingClientRect(),r=n.width||1,s=n.height||1,a=r/s;this.camera=new jr(45,a,.01,1e3),this.camera.up.set(0,1,0),this.camera.position.set(0,0,1),this.camera.lookAt(this.target),this.camera.updateProjectionMatrix(),this.renderer=new vp({canvas:t,antialias:!0,alpha:!0,preserveDrawingBuffer:!0,powerPreference:"high-performance",logarithmicDepthBuffer:!1}),this.renderer.setPixelRatio(i),this.renderer.setSize(r,s),this.renderer.toneMapping=1,this.canvas=t,this.canvasEvents.forEach((e=>t.addEventListener(e,this.canvaseventlistener))),this._markup.initialize(this.canvas,this.canvasEvents,this,this);for(const t of hf.getComponents().keys())this._components.push(hf.createComponent(t,this));return this.syncOptions(),this.syncOverlay(),this.renderTime=performance.now(),this.render(this.renderTime),"function"==typeof e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:1,total:1})),this.emitEvent({type:"initializeprogress",data:1,loaded:1,total:1}),this.emitEvent({type:"initialize"}),Promise.resolve(this)}dispose(){return this.cancel(),this.clear(),this.emitEvent({type:"dispose"}),this.removeAllListeners(),this.setActiveDragger(),this._components.forEach((t=>t.dispose())),this._components=[],this._markup.dispose(),this.canvas&&(this.canvasEvents.forEach((t=>this.canvas.removeEventListener(t,this.canvaseventlistener))),this.canvas=void 0),this.renderer&&this.renderer.dispose(),this.helpers=void 0,this.scene=void 0,this.renderer=void 0,this.camera=void 0,this}isInitialized(){return!!this.renderer}update(t=!1){this.renderNeeded=!0,t&&this.render(performance.now()),this.emitEvent({type:"update",data:t})}render(t){var e,i;if(!this.renderNeeded)return;if(!this.renderer)return;this.renderNeeded=!1,this.renderer.setViewport(0,0,this.canvas.offsetWidth,this.canvas.offsetHeight),this.renderer.autoClear=!0,this.renderer.render(this.scene,this.camera);const n=this.renderer.clippingPlanes;this.renderer.clippingPlanes=[],this.renderer.autoClear=!1,this.renderer.render(this.helpers,this.camera),this.renderer.clippingPlanes=n,null===(i=null===(e=this._activeDragger)||void 0===e?void 0:e.updatePreview)||void 0===i||i.call(e);const r=(t-this.renderTime)/1e3;this.renderTime=t,this.emitEvent({type:"render",time:t,deltaTime:r})}loadReferences(t){return Promise.resolve(this)}async open(t,e={}){if(!this.renderer)return this;"a"!==e.mode&&"append"!==e.mode&&(this.cancel(),this.clear()),this.emitEvent({type:"open",file:t});let i=t;if(i&&"function"==typeof i.getModels){const e=await i.getModels();i=e.find((t=>t.default))||e[0]||t}if(!i)throw new Error("Format not supported");let n=e.format;n||"string"!=typeof i.type||(n=i.type.split(".").pop()),n||"string"!=typeof t||(n=t.split(".").pop()),!n&&t instanceof globalThis.File&&(n=t.name.split(".").pop());const r=Mg.createLoader(this,i,n);if(!r)throw new Error("Format not supported");this.loaders.push(r),this.emitEvent({type:"geometrystart",file:t,model:i});try{await this.loadReferences(i),await r.load(i,n,e)}catch(e){throw this.emitEvent({type:"geometryerror",data:e,file:t,model:i}),e}return this.emitEvent({type:"geometryend",file:t,model:i}),this}openGltfFile(t,e,i={}){return console.warn("Viewer.openGltfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead."),this.open(t,{...i,format:"gltf",externalFiles:e})}loadGltfFile(t,e,i={}){return console.warn("Viewer.loadGltfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead."),this.open(t,{...i,format:"gltf",externalFiles:e,mode:"append"})}cancel(){return this.loaders.forEach((t=>t.cancel())),this.emitEvent({type:"cancel"}),this}clear(){return this.renderer?(this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.loaders.forEach((t=>t.dispose())),this.loaders=[],this.models.forEach((t=>t.dispose())),this.models=[],this.helpers.clear(),this.scene.clear(),this.syncOptions(),this.syncOverlay(),this.update(!0),this.emitEvent({type:"clear"}),this):this}syncOptions(t=this.options){}syncOverlay(){this.renderer&&(this._markup.syncOverlay(),this.update())}clearOverlay(){this.renderer&&(this._markup.clearOverlay(),this.update())}clearSlices(){this.renderer&&(this.renderer.clippingPlanes=[],this.update())}getSelected(){return this.executeCommand("getSelected")}setSelected(t){this.executeCommand("setSelected",t)}clearSelected(){this.executeCommand("clearSelected")}hideSelected(){this.executeCommand("hideSelected")}isolateSelected(){this.executeCommand("isolateSelected")}showAll(){this.executeCommand("showAll")}explode(t=0){this.executeCommand("explode",t)}collect(){this.executeCommand("collect")}activeDragger(){return this._activeDragger}setActiveDragger(t=""){var e,i;if(!this._activeDragger||this._activeDragger.name!==t){const n=this._activeDragger;let r=null;this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null),this.isInitialized()&&(r=Um.createDragger(t,this),r&&(this._activeDragger=r,null===(i=(e=this._activeDragger).initialize)||void 0===i||i.call(e)));const s=this.canvas;s&&(n&&s.classList.remove(`oda-cursor-${n.name.toLowerCase()}`),r&&s.classList.add(`oda-cursor-${r.name.toLowerCase()}`)),this.emitEvent({type:"changeactivedragger",data:t}),this.update()}return this._activeDragger}resetActiveDragger(){const t=this._activeDragger;t&&(this.setActiveDragger(),this.setActiveDragger(t.name))}getComponent(t){return this._components.find((e=>e.name===t))}is3D(){return!0}screenToWorld(t){if(!this.renderer)return{x:t.x,y:t.y,z:0};const e=this.canvas.getBoundingClientRect(),i=t.x/(e.width/2)-1,n=-t.y/(e.height/2)+1,r=new Ci(i,n,-1);return r.unproject(this.camera),{x:r.x,y:r.y,z:r.z}}worldToScreen(t){if(!this.renderer)return{x:t.x,y:t.y};const e=new Ci(t.x,t.y,t.z);e.project(this.camera);const i=this.canvas.getBoundingClientRect();return{x:(e.x+1)*(i.width/2),y:(1-e.y)*(i.height/2)}}getScale(){return{x:1,y:1,z:1}}executeCommand(t,...e){return Gm.executeCommand(t,this,...e)}drawViewpoint(t){var e,i,n;if(!this.renderer)return;const r=({x:t,y:e,z:i})=>new Ci(t,e,i),s=null===(e=this._activeDragger)||void 0===e?void 0:e.name;this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.showAll(),this.explode(),(t=>{if(t){const e=2*this.extents.getBoundingSphere(new Ki).radius,i=this.renderer.getSize(new $e),n=i.x/i.y;this.camera=new fl,this.camera.top=t.field_height/2,this.camera.bottom=-t.field_height/2,this.camera.left=this.camera.bottom*n,this.camera.right=this.camera.top*n,this.camera.near=0,this.camera.far=100*e,this.camera.zoom=t.view_to_world_scale,this.camera.updateProjectionMatrix(),this.camera.up.copy(r(t.up_vector)),this.camera.position.copy(r(t.view_point)),this.camera.lookAt(r(t.direction).add(this.camera.position)),this.camera.updateMatrixWorld()}})(t.orthogonal_camera),(t=>{if(t){const e=2*this.extents.getBoundingSphere(new Ki).radius,i=this.renderer.getSize(new $e),n=i.x/i.y;this.camera=new jr,this.camera.fov=t.field_of_view,this.camera.aspect=n,this.camera.near=e/100,this.camera.far=100*e,this.camera.updateProjectionMatrix(),this.camera.up.copy(r(t.up_vector)),this.camera.position.copy(r(t.view_point)),this.camera.lookAt(r(t.direction).add(this.camera.position)),this.camera.updateMatrixWorld()}})(t.perspective_camera),(t=>{null==t||t.forEach((t=>{const e=new Js;e.setFromNormalAndCoplanarPoint(r(t.direction),r(t.location)),this.renderer.clippingPlanes.push(e)}))})(t.clipping_planes),(t=>{t&&this.setSelected(t.map((t=>t.handle)))})(t.selection),this._markup.setViewpoint(t),this.target=r(null!==(n=null===(i=t.custom_fields)||void 0===i?void 0:i.camera_target)&&void 0!==n?n:this.target),this.setActiveDragger(s),this.emitEvent({type:"drawviewpoint",data:t}),this.update()}createViewpoint(){if(!this.renderer)return{};const t=({x:t,y:e,z:i})=>({x:t,y:e,z:i}),e={custom_fields:{}};return e.orthogonal_camera=(()=>this.camera.isOrthographicCamera?{view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new Ci)),up_vector:t(this.camera.up),field_width:this.camera.right-this.camera.left,field_height:this.camera.top-this.camera.bottom,view_to_world_scale:this.camera.zoom}:void 0)(),e.perspective_camera=(()=>this.camera.isPerspectiveCamera?{view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new Ci)),up_vector:t(this.camera.up),field_of_view:this.camera.fov}:void 0)(),e.clipping_planes=(()=>{const e=[];return this.renderer.clippingPlanes.forEach((i=>{const n={location:t(i.coplanarPoint(new Ci)),direction:t(i.normal)};e.push(n)})),e})(),e.selection=(()=>this.getSelected().map((t=>({handle:t}))))(),e.description=(new Date).toDateString(),this._markup.getViewpoint(e),e.custom_fields.camera_target=t(this.target),this.emitEvent({type:"createviewpoint",data:e}),e}},t.commands=Gm,t.commandsRegistry=n,t.components=hf,t.componentsRegistry=l,t.defaultOptions=m,t.draggers=Um,t.draggersRegistry=a,t.loaders=Mg,t.loadersRegistry=p}));
|