shaders 2.0.626 → 2.0.628

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/vue/index.js CHANGED
@@ -393,7 +393,7 @@ struct ${e} {
393
393
  ${t}
394
394
  };`}_getWGSLStructBinding(e,t,n,r=0,i=0){let a=e+`Struct`,o=this._getWGSLStruct(a,t);return`${o}
395
395
  @binding( ${r} ) @group( ${i} )
396
- var<${n}> ${e} : ${a};`}},cj=class{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture===null?e.depth&&e.stencil?t=L.Depth24PlusStencil8:e.depth&&(t=L.Depth24Plus):t=this.getTextureFormatGPU(e.depthTexture),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let e=this.backend.renderer,n=e.getRenderTarget();t=n?n.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t||=1;let n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0,r=n?1:t;return{samples:t,primarySamples:r,isMSAA:n}}getCurrentColorFormat(e){let t;return t=e.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(e.textures[0]),t}getCurrentColorSpace(e){return e.textures===null?this.backend.renderer.outputColorSpace:e.textures[0].colorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return fA.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return fA.LineList;if(e.isLine)return fA.LineStrip;if(e.isMesh)return fA.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=2**Math.floor(Math.log2(e)),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures===null?this.getSampleCount(this.backend.renderer.samples):this.getSampleCount(e.sampleCount)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===st)return L.BGRA8Unorm;if(e===mt)return L.RGBA16Float;throw Error(`Unsupported outputType`)}};const lj=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]),uj=new Map([[ja,[`float16`]]]),dj=new Map([[Int32Array,`sint32`],[Int16Array,`sint32`],[Uint32Array,`uint32`],[Uint16Array,`uint32`],[Float32Array,`float32`]]);var fj=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this._getBufferAttribute(e),r=this.backend,i=r.get(n),a=i.buffer;if(a===void 0){let o=r.device,s=n.array;if(e.normalized===!1){if(s.constructor===Int16Array||s.constructor===Int8Array)s=new Int32Array(s);else if((s.constructor===Uint16Array||s.constructor===Uint8Array)&&(s=new Uint32Array(s),t&GPUBufferUsage.INDEX))for(let e=0;e<s.length;e++)s[e]===65535&&(s[e]=4294967295)}if(n.array=s,(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3){s=new s.constructor(n.count*4);for(let e=0;e<n.count;e++)s.set(n.array.subarray(e*3,e*3+3),e*4);n.itemSize=4,n.array=s,i._force3to4BytesAlignment=!0}let c=s.byteLength,l=c+(4-c%4)%4;a=o.createBuffer({label:n.name,size:l,usage:t,mappedAtCreation:!0}),new s.constructor(a.getMappedRange()).set(s),a.unmap(),i.buffer=a}}updateAttribute(e){let t=this._getBufferAttribute(e),n=this.backend,r=n.device,i=n.get(t),a=n.get(t).buffer,o=t.array;if(i._force3to4BytesAlignment===!0){o=new o.constructor(t.count*4);for(let e=0;e<t.count;e++)o.set(t.array.subarray(e*3,e*3+3),e*4);t.array=o}let s=this._isTypedArray(o),c=t.updateRanges;if(c.length===0)r.queue.writeBuffer(a,0,o,0);else{let e=s?1:o.BYTES_PER_ELEMENT;for(let t=0,n=c.length;t<n;t++){let n=c[t],l,u;if(i._force3to4BytesAlignment===!0){let t=Math.floor(n.start/3),r=Math.ceil(n.count/3);l=t*4*e,u=r*4*e}else l=n.start*e,u=n.count*e;let d=l*(s?o.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(a,d,o,l,u)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){let t=e.getAttributes(),n=new Map;for(let e=0;e<t.length;e++){let r=t[e],i=r.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(r),o=n.get(a);if(o===void 0){let e,t;r.isInterleavedBufferAttribute===!0?(e=r.data.stride*i,t=r.data.isInstancedInterleavedBuffer?MA.Instance:MA.Vertex):(e=r.itemSize*i,t=r.isInstancedBufferAttribute?MA.Instance:MA.Vertex),r.normalized===!1&&(r.array.constructor===Int16Array||r.array.constructor===Uint16Array)&&(e=4),o={arrayStride:e,attributes:[],stepMode:t},n.set(a,o)}let s=this._getVertexFormat(r),c=r.isInterleavedBufferAttribute===!0?r.offset*i:0;o.attributes.push({shaderLocation:e,offset:c,format:s})}return Array.from(n.values())}destroyAttribute(e){let t=this.backend,n=t.get(this._getBufferAttribute(e));n.buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){let t=this.backend,n=t.device,r=t.get(this._getBufferAttribute(e)),i=r.buffer,a=i.size,o=n.createBuffer({label:`${e.name}_readback`,size:a,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),s=n.createCommandEncoder({label:`readback_encoder_${e.name}`});s.copyBufferToBuffer(i,0,o,0,a);let c=s.finish();n.queue.submit([c]),await o.mapAsync(GPUMapMode.READ);let l=o.getMappedRange(),u=new e.array.constructor(l.slice(0));return o.unmap(),u.buffer}_getVertexFormat(e){let{itemSize:t,normalized:n}=e,r=e.array.constructor,i=e.constructor,a;if(t===1)a=dj.get(r);else{let e=uj.get(i)||lj.get(r),o=e[n?1:0];if(o){let e=r.BYTES_PER_ELEMENT*t,n=Math.floor((e+3)/4)*4,i=n/r.BYTES_PER_ELEMENT;if(i%1)throw Error(`THREE.WebGPUAttributeUtils: Bad vertex format item size.`);a=`${o}x${i}`}}return a||console.error(`THREE.WebGPUAttributeUtils: Vertex format not supported yet.`),a}_isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},pj=class{constructor(e){this.backend=e,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(e){let t=this.backend,n=t.device,r=[],i=0;for(let n of e.bindings){let e={binding:i++,visibility:n.visibility};if(n.isUniformBuffer||n.isStorageBuffer){let t={};n.isStorageBuffer&&(n.visibility&4&&(n.access===vc.READ_WRITE||n.access===vc.WRITE_ONLY)?t.type=TA.Storage:t.type=TA.ReadOnlyStorage),e.buffer=t}else if(n.isSampler){let r={};n.texture.isDepthTexture&&(n.texture.compareFunction===null?t.compatibilityMode&&(r.type=DA.NonFiltering):r.type=DA.Comparison),e.sampler=r}else if(n.isSampledTexture&&n.texture.isVideoTexture)e.externalTexture={};else if(n.isSampledTexture&&n.store){let t={};t.format=this.backend.get(n.texture).texture.format;let r=n.access;r===vc.READ_WRITE?t.access=EA.ReadWrite:r===vc.WRITE_ONLY?t.access=EA.WriteOnly:t.access=EA.ReadOnly,e.storageTexture=t}else if(n.isSampledTexture){let r={},{primarySamples:i}=t.utils.getTextureSampleData(n.texture);if(i>1&&(r.multisampled=!0,n.texture.isDepthTexture||(r.sampleType=OA.UnfilterableFloat)),n.texture.isDepthTexture)t.compatibilityMode&&n.texture.compareFunction===null?r.sampleType=OA.UnfilterableFloat:r.sampleType=OA.Depth;else if(n.texture.isDataTexture||n.texture.isDataArrayTexture||n.texture.isData3DTexture){let e=n.texture.type;e===dt?r.sampleType=OA.SInt:e===ft?r.sampleType=OA.UInt:e===pt&&(this.backend.hasFeature(`float32-filterable`)?r.sampleType=OA.Float:r.sampleType=OA.UnfilterableFloat)}n.isSampledCubeTexture?r.viewDimension=AA.Cube:n.texture.isArrayTexture||n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?r.viewDimension=AA.TwoDArray:n.isSampledTexture3D&&(r.viewDimension=AA.ThreeD),e.texture=r}else console.error(`WebGPUBindingUtils: Unsupported binding "${n}".`);r.push(e)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){let{backend:i,bindGroupLayoutCache:a}=this,o=i.get(e),s=a.get(e.bindingsReference);s===void 0&&(s=this.createBindingsLayout(e),a.set(e.bindingsReference,s));let c;n>0&&(o.groups===void 0&&(o.groups=[],o.versions=[]),o.versions[n]===r&&(c=o.groups[n])),c===void 0&&(c=this.createBindGroup(e,s),n>0&&(o.groups[n]=c,o.versions[n]=r)),o.group=c,o.layout=s}updateBinding(e){let t=this.backend,n=t.device,r=e.buffer,i=t.get(e).buffer;n.queue.writeBuffer(i,0,r,0)}createBindGroupIndex(e,t){let n=this.backend,r=n.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=e[0],o=r.createBuffer({label:`bindingCameraIndex_`+a,size:16,usage:i});r.queue.writeBuffer(o,0,e,0);let s=[{binding:0,resource:{buffer:o}}];return r.createBindGroup({label:`bindGroupCameraIndex_`+a,layout:t,entries:s})}createBindGroup(e,t){let n=this.backend,r=n.device,i=0,a=[];for(let t of e.bindings){if(t.isUniformBuffer){let e=n.get(t);if(e.buffer===void 0){let n=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=r.createBuffer({label:`bindingBuffer_`+t.name,size:n,usage:i});e.buffer=a}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){let e=n.get(t);if(e.buffer===void 0){let r=t.attribute;e.buffer=n.get(r).buffer}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){let e=n.get(t.texture);a.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){let e=n.get(t.texture),o;if(e.externalTexture!==void 0)o=r.importExternalTexture({source:e.externalTexture});else{let n=t.store?1:e.texture.mipLevelCount,r=`view-${e.texture.width}-${e.texture.height}-${n}`;if(o=e[r],o===void 0){let i=jA.All,a;a=t.isSampledCubeTexture?AA.Cube:t.isSampledTexture3D?AA.ThreeD:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?AA.TwoDArray:AA.TwoD,o=e[r]=e.texture.createView({aspect:i,dimension:a,mipLevelCount:n})}}a.push({binding:i,resource:o})}i++}return r.createBindGroup({label:`bindGroup_`+e.name,layout:t,entries:a})}},mj=class{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){let n=this._activePipelines.get(e);n!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:n,material:r,geometry:i,pipeline:a}=e,{vertexProgram:o,fragmentProgram:s}=a,c=this.backend,l=c.device,u=c.utils,d=c.get(a),f=[];for(let t of e.getBindings()){let e=c.get(t);f.push(e.layout)}let p=c.attributeUtils.createShaderVertexBuffers(e),m;r.blending!==ae&&(r.blending!==oe||r.transparent!==!1)&&(m=this._getBlending(r));let h={};r.stencilWrite===!0&&(h={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});let g=this._getColorWriteMask(r),_=[];if(e.context.textures!==null){let t=e.context.textures;for(let e=0;e<t.length;e++){let n=u.getTextureFormatGPU(t[e]);_.push({format:n,blend:m,writeMask:g})}}else{let t=u.getCurrentColorFormat(e.context);_.push({format:t,blend:m,writeMask:g})}let v=c.get(o).module,y=c.get(s).module,b=this._getPrimitiveState(n,i,r),x=this._getDepthCompare(r),S=u.getCurrentDepthStencilFormat(e.context),ee=this._getSampleCount(e.context),te={label:`renderPipeline_${r.name||r.type}_${r.id}`,vertex:Object.assign({},v,{buffers:p}),fragment:Object.assign({},y,{targets:_}),primitive:b,multisample:{count:ee,alphaToCoverageEnabled:r.alphaToCoverage&&ee>1},layout:l.createPipelineLayout({bindGroupLayouts:f})},ne={},re=e.context.depth,ie=e.context.stencil;if((re===!0||ie===!0)&&(re===!0&&(ne.format=S,ne.depthWriteEnabled=r.depthWrite,ne.depthCompare=x),ie===!0&&(ne.stencilFront=h,ne.stencilBack={},ne.stencilReadMask=r.stencilFuncMask,ne.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&(ne.depthBias=r.polygonOffsetUnits,ne.depthBiasSlopeScale=r.polygonOffsetFactor,ne.depthBiasClamp=0),te.depthStencil=ne),t===null)d.pipeline=l.createRenderPipeline(te);else{let e=new Promise(e=>{l.createRenderPipelineAsync(te).then(t=>{d.pipeline=t,e()})});t.push(e)}}createBundleEncoder(e,t=`renderBundleEncoder`){let n=this.backend,{utils:r,device:i}=n,a=r.getCurrentDepthStencilFormat(e),o=r.getCurrentColorFormat(e),s=this._getSampleCount(e),c={label:t,colorFormats:[o],depthStencilFormat:a,sampleCount:s};return i.createRenderBundleEncoder(c)}createComputePipeline(e,t){let n=this.backend,r=n.device,i=n.get(e.computeProgram).module,a=n.get(e),o=[];for(let e of t){let t=n.get(e);o.push(t.layout)}a.pipeline=r.createComputePipeline({compute:i,layout:r.createPipelineLayout({bindGroupLayouts:o})})}_getBlending(e){let t,n,r=e.blending,i=e.blendSrc,a=e.blendDst,o=e.blendEquation;if(r===ue){let r=e.blendSrcAlpha===null?i:e.blendSrcAlpha,s=e.blendDstAlpha===null?a:e.blendDstAlpha,c=e.blendEquationAlpha===null?o:e.blendEquationAlpha;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(o)},n={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(c)}}else{let i=e.premultipliedAlpha,a=(e,r,i,a)=>{t={srcFactor:e,dstFactor:r,operation:SA.Add},n={srcFactor:i,dstFactor:a,operation:SA.Add}};if(i)switch(r){case oe:a(xA.One,xA.OneMinusSrcAlpha,xA.One,xA.OneMinusSrcAlpha);break;case se:a(xA.One,xA.One,xA.One,xA.One);break;case ce:a(xA.Zero,xA.OneMinusSrc,xA.Zero,xA.One);break;case le:a(xA.Zero,xA.Src,xA.Zero,xA.SrcAlpha);break}else switch(r){case oe:a(xA.SrcAlpha,xA.OneMinusSrcAlpha,xA.One,xA.OneMinusSrcAlpha);break;case se:a(xA.SrcAlpha,xA.One,xA.SrcAlpha,xA.One);break;case ce:a(xA.Zero,xA.OneMinusSrc,xA.Zero,xA.One);break;case le:a(xA.Zero,xA.Src,xA.Zero,xA.Src);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error(`THREE.WebGPURenderer: Invalid blending: `,r)}_getBlendFactor(e){let t;switch(e){case ge:t=xA.Zero;break;case _e:t=xA.One;break;case ve:t=xA.Src;break;case ye:t=xA.OneMinusSrc;break;case be:t=xA.SrcAlpha;break;case xe:t=xA.OneMinusSrcAlpha;break;case we:t=xA.Dst;break;case Te:t=xA.OneMinusDst;break;case Se:t=xA.DstAlpha;break;case Ce:t=xA.OneMinusDstAlpha;break;case Ee:t=xA.SrcAlphaSaturated;break;case qb:t=xA.Constant;break;case Jb:t=xA.OneMinusConstant;break;default:console.error(`THREE.WebGPURenderer: Blend factor not supported.`,e)}return t}_getStencilCompare(e){let t,n=e.stencilFunc;switch(n){case On:t=pA.Never;break;case Fn:t=pA.Always;break;case kn:t=pA.Less;break;case jn:t=pA.LessEqual;break;case An:t=pA.Equal;break;case Pn:t=pA.GreaterEqual;break;case Mn:t=pA.Greater;break;case Nn:t=pA.NotEqual;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil function.`,n)}return t}_getStencilOperation(e){let t;switch(e){case xn:t=wA.Keep;break;case bn:t=wA.Zero;break;case Sn:t=wA.Replace;break;case Dn:t=wA.Invert;break;case Cn:t=wA.IncrementClamp;break;case wn:t=wA.DecrementClamp;break;case Tn:t=wA.IncrementWrap;break;case En:t=wA.DecrementWrap;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil operation.`,t)}return t}_getBlendOperation(e){let t;switch(e){case de:t=SA.Add;break;case fe:t=SA.Subtract;break;case pe:t=SA.ReverseSubtract;break;case me:t=SA.Min;break;case he:t=SA.Max;break;default:console.error(`THREE.WebGPUPipelineUtils: Blend equation not supported.`,e)}return t}_getPrimitiveState(e,t,n){let r={},i=this.backend.utils;switch(r.topology=i.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?vA.Uint16:vA.Uint32),n.side){case ne:r.frontFace=gA.CCW,r.cullMode=_A.Back;break;case re:r.frontFace=gA.CCW,r.cullMode=_A.Front;break;case ie:r.frontFace=gA.CCW,r.cullMode=_A.None;break;default:console.error(`THREE.WebGPUPipelineUtils: Unknown material.side value.`,n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?CA.All:CA.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=pA.Always;else{let n=e.depthFunc;switch(n){case De:t=pA.Never;break;case Oe:t=pA.Always;break;case ke:t=pA.Less;break;case Ae:t=pA.LessEqual;break;case je:t=pA.Equal;break;case Me:t=pA.GreaterEqual;break;case Ne:t=pA.Greater;break;case Pe:t=pA.NotEqual;break;default:console.error(`THREE.WebGPUPipelineUtils: Invalid depth function.`,n)}}return t}},hj=class extends cA{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:`timestamp`,count:this.maxQueries,label:`queryset_global_timestamp_${t}`});let r=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return Mr(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{let e=await this.pendingResolve;return e}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!==`unmapped`)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder();r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);let i=r.finish();if(this.device.queue.submit([i]),this.resultBuffer.mapState!==`unmapped`)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue;let a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),o=0;for(let[,t]of e){let e=a[t],n=a[t+1],r=Number(n-e)/1e6;o+=r}return this.resultBuffer.unmap(),this.lastValue=o,o}catch(e){return console.error(`Error resolving queries:`,e),this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error(`Error waiting for pending resolve:`,e)}if(this.resultBuffer&&this.resultBuffer.mapState===`mapped`)try{this.resultBuffer.unmap()}catch(e){console.error(`Error unmapping buffer:`,e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}},gj=class extends Wk{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.compatibilityMode=e.compatibilityMode===void 0?!1:e.compatibilityMode,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new cj(this),this.attributeUtils=new fj(this),this.bindingUtils=new pj(this),this.pipelineUtils=new mj(this),this.textureUtils=new HA(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);let t=this.parameters,n;if(t.device===void 0){let e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?`compatibility`:void 0},r=typeof navigator<`u`?await navigator.gpu.requestAdapter(e):null;if(r===null)throw Error(`WebGPUBackend: Unable to create WebGPU adapter.`);let i=Object.values(NA),a=[];for(let e of i)r.features.has(e)&&a.push(e);let o={requiredFeatures:a,requiredLimits:t.requiredLimits};n=await r.requestDevice(o)}else n=t.device;n.lost.then(t=>{let n={api:`WebGPU`,message:t.message||`Unknown reason`,reason:t.reason||null,originalEvent:t};e.onDeviceLost(n)});let r=t.context===void 0?e.domElement.getContext(`webgpu`):t.context;this.device=n,this.context=r;let i=t.alpha?`premultiplied`:`opaque`;this.trackTimestamp=this.trackTimestamp&&this.hasFeature(NA.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return qn}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){let t=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});let n=e.colorAttachments[0];this.renderer.samples>0?n.view=this.colorBuffer.createView():n.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}let t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){let n=e.renderTarget,r=this.get(n),i=r.descriptors;if(i===void 0||r.width!==n.width||r.height!==n.height||r.dimensions!==n.dimensions||r.activeMipmapLevel!==e.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==n.samples){i={},r.descriptors=i;let e=()=>{n.removeEventListener(`dispose`,e),this.delete(n)};n.hasEventListener(`dispose`,e)===!1&&n.addEventListener(`dispose`,e)}let a=e.getCacheKey(),o=i[a];if(o===void 0){let t=e.textures,s=[],c,l=this._isRenderCameraDepthArray(e);for(let r=0;r<t.length;r++){let i=this.get(t[r]),a={label:`colorAttachment_${r}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:AA.TwoD};if(n.isRenderTarget3D)c=e.activeCubeFace,a.baseArrayLayer=0,a.dimension=AA.ThreeD,a.depthOrArrayLayers=t[r].image.depth;else if(n.isRenderTarget&&t[r].image.depth>1)if(l===!0){let t=e.camera.cameras;for(let e=0;e<t.length;e++){let t={...a,baseArrayLayer:e,arrayLayerCount:1,dimension:AA.TwoD},n=i.texture.createView(t);s.push({view:n,resolveTarget:void 0,depthSlice:void 0})}}else a.dimension=AA.TwoDArray,a.depthOrArrayLayers=t[r].image.depth;if(l!==!0){let e=i.texture.createView(a),t,n;i.msaaTexture===void 0?(t=e,n=void 0):(t=i.msaaTexture.createView(),n=e),s.push({view:t,resolveTarget:n,depthSlice:c})}}if(o={textureViews:s},e.depth){let t=this.get(e.depthTexture),n={};e.depthTexture.isArrayTexture&&(n.dimension=AA.TwoD,n.arrayLayerCount=1,n.baseArrayLayer=e.activeCubeFace),o.depthStencilView=t.texture.createView(n)}i[a]=o,r.width=n.width,r.height=n.height,r.samples=n.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace,r.dimensions=n.dimensions}let s={colorAttachments:[]};for(let e=0;e<o.textureViews.length;e++){let n=o.textureViews[e],r={r:0,g:0,b:0,a:1};e===0&&t.clearValue&&(r=t.clearValue),s.colorAttachments.push({view:n.view,depthSlice:n.depthSlice,resolveTarget:n.resolveTarget,loadOp:t.loadOp||hA.Load,storeOp:t.storeOp||mA.Store,clearValue:r})}return o.depthStencilView&&(s.depthStencilAttachment={view:o.depthStencilView}),s}beginRender(e){let t=this.get(e),n=this.device,r=e.occlusionQueryCount,i;r>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=n.createQuerySet({type:`occlusion`,count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=Array(r),t.lastOcclusionObject=null);let a;a=e.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:hA.Load}),this.initTimestampQuery(e,a),a.occlusionQuerySet=i;let o=a.depthStencilAttachment;if(e.textures!==null){let t=a.colorAttachments;for(let n=0;n<t.length;n++){let r=t[n];e.clearColor?(r.clearValue=n===0?e.clearColorValue:{r:0,g:0,b:0,a:1},r.loadOp=hA.Clear):r.loadOp=hA.Load,r.storeOp=mA.Store}}else{let t=a.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=hA.Clear):t.loadOp=hA.Load,t.storeOp=mA.Store}e.depth&&(e.clearDepth?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=hA.Clear):o.depthLoadOp=hA.Load,o.depthStoreOp=mA.Store),e.stencil&&(e.clearStencil?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=hA.Clear):o.stencilLoadOp=hA.Load,o.stencilStoreOp=mA.Store);let s=n.createCommandEncoder({label:`renderContext_`+e.id});if(this._isRenderCameraDepthArray(e)===!0){let n=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==n.length?this._createDepthLayerDescriptors(e,t,a,n):this._updateDepthLayerDescriptors(e,t,n),t.bundleEncoders=[],t.bundleSets=[];for(let r=0;r<n.length;r++){let n=this.pipelineUtils.createBundleEncoder(e,`renderBundleArrayCamera_`+r),i={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(n),t.bundleSets.push(i)}t.currentPass=null}else{let n=s.beginRenderPass(a);if(t.currentPass=n,e.viewport&&this.updateViewport(e),e.scissor){let{x:t,y:r,width:i,height:a}=e.scissorValue;n.setScissorRect(t,r,i,a)}}t.descriptor=a,t.encoder=s,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,n,r){let i=n.depthStencilAttachment;t.layerDescriptors=[];let a=this.get(e.depthTexture);a.viewCache||=[];for(let o=0;o<r.length;o++){let r={...n,colorAttachments:[{...n.colorAttachments[0],view:n.colorAttachments[o].view}]};if(n.depthStencilAttachment){let t=o;a.viewCache[t]||(a.viewCache[t]=a.texture.createView({dimension:AA.TwoD,baseArrayLayer:o,arrayLayerCount:1})),r.depthStencilAttachment={view:a.viewCache[t],depthLoadOp:i.depthLoadOp||hA.Clear,depthStoreOp:i.depthStoreOp||mA.Store,depthClearValue:i.depthClearValue||1},e.stencil&&(r.depthStencilAttachment.stencilLoadOp=i.stencilLoadOp,r.depthStencilAttachment.stencilStoreOp=i.stencilStoreOp,r.depthStencilAttachment.stencilClearValue=i.stencilClearValue)}else r.depthStencilAttachment={...i};t.layerDescriptors.push(r)}}_updateDepthLayerDescriptors(e,t,n){for(let r=0;r<n.length;r++){let n=t.layerDescriptors[r];if(n.depthStencilAttachment){let t=n.depthStencilAttachment;e.depth&&(e.clearDepth?(t.depthClearValue=e.clearDepthValue,t.depthLoadOp=hA.Clear):t.depthLoadOp=hA.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=hA.Clear):t.stencilLoadOp=hA.Load)}}}finishRender(e){let t=this.get(e),n=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let n=[];for(let e=0;e<t.bundleEncoders.length;e++){let r=t.bundleEncoders[e];n.push(r.finish())}for(let i=0;i<t.layerDescriptors.length;i++)if(i<n.length){let a=t.layerDescriptors[i],o=r.beginRenderPass(a);if(e.viewport){let{x:t,y:n,width:r,height:i,minDepth:a,maxDepth:s}=e.viewportValue;o.setViewport(t,n,r,i,a,s)}if(e.scissor){let{x:t,y:n,width:r,height:i}=e.scissorValue;o.setScissorRect(t,n,r,i)}o.executeBundles([n[i]]),o.end()}}else t.currentPass&&t.currentPass.end();if(n>0){let r=n*8,i=this.occludedResolveCache.get(r);i===void 0&&(i=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,i));let a=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,i,0),t.encoder.copyBufferToBuffer(i,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){let t=e.textures;for(let e=0;e<t.length;e++){let n=t[e];n.generateMipmaps===!0&&this.textureUtils.generateMipmaps(n)}}}isOccluded(e,t){let n=this.get(e);return n.occluded&&n.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:n,currentOcclusionQueryObjects:r}=t;if(n&&r){let e=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await n.mapAsync(GPUMapMode.READ);let i=n.getMappedRange(),a=new BigUint64Array(i);for(let t=0;t<r.length;t++)a[t]===BigInt(0)&&e.add(r[t]);n.destroy(),t.occluded=e}}updateViewport(e){let{currentPass:t}=this.get(e),{x:n,y:r,width:i,height:a,minDepth:o,maxDepth:s}=e.viewportValue;t.setViewport(n,r,i,a,o,s)}getClearColor(){let e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,n,r=null){let i=this.device,a=this.renderer,o=[],s,c,l,u;if(e){let e=this.getClearColor();c={r:e.r,g:e.g,b:e.b,a:e.a}}if(r===null){l=a.depth,u=a.stencil;let t=this._getDefaultRenderPassDescriptor();if(e){o=t.colorAttachments;let e=o[0];e.clearValue=c,e.loadOp=hA.Clear,e.storeOp=mA.Store}(l||u)&&(s=t.depthStencilAttachment)}else{l=r.depth,u=r.stencil;let i={loadOp:e?hA.Clear:hA.Load,clearValue:e?c:void 0};l&&(i.depthLoadOp=t?hA.Clear:hA.Load,i.depthClearValue=t?a.getClearDepth():void 0,i.depthStoreOp=mA.Store),u&&(i.stencilLoadOp=n?hA.Clear:hA.Load,i.stencilClearValue=n?a.getClearStencil():void 0,i.stencilStoreOp=mA.Store);let d=this._getRenderPassDescriptor(r,i);o=d.colorAttachments,s=d.depthStencilAttachment}l&&s&&s.depthLoadOp===void 0&&(t?(s.depthLoadOp=hA.Clear,s.depthClearValue=a.getClearDepth(),s.depthStoreOp=mA.Store):(s.depthLoadOp=hA.Load,s.depthStoreOp=mA.Store)),u&&s&&s.stencilLoadOp===void 0&&(n?(s.stencilLoadOp=hA.Clear,s.stencilClearValue=a.getClearStencil(),s.stencilStoreOp=mA.Store):(s.stencilLoadOp=hA.Load,s.stencilStoreOp=mA.Store));let d=i.createCommandEncoder({label:`clear`}),f=d.beginRenderPass({colorAttachments:o,depthStencilAttachment:s});f.end(),i.queue.submit([d.finish()])}beginCompute(e){let t=this.get(e),n={label:`computeGroup_`+e.id};this.initTimestampQuery(e,n),t.cmdEncoderGPU=this.device.createCommandEncoder({label:`computeGroup_`+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(n)}compute(e,t,n,r){let{passEncoderGPU:i}=this.get(e),a=this.get(r).pipeline;this.pipelineUtils.setPipeline(i,a);for(let e=0,t=n.length;e<t;e++){let t=n[e],r=this.get(t);i.setBindGroup(e,r.group)}let o=this.device.limits.maxComputeWorkgroupsPerDimension,s=this.get(t);s.dispatchSize===void 0&&(s.dispatchSize={x:0,y:1,z:1});let{dispatchSize:c}=s;t.dispatchCount>o?(c.x=Math.min(t.dispatchCount,o),c.y=Math.ceil(t.dispatchCount/o)):c.x=t.dispatchCount,i.dispatchWorkgroups(c.x,c.y,c.z)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){let{object:n,material:r,context:i,pipeline:a}=e,o=e.getBindings(),s=this.get(i),c=this.get(a).pipeline,l=e.getIndex(),u=l!==null,d=e.getDrawParameters();if(d===null)return;let f=(t,n)=>{this.pipelineUtils.setPipeline(t,c),n.pipeline=c;let a=n.bindingGroups;for(let e=0,n=o.length;e<n;e++){let n=o[e],r=this.get(n);a[n.index]!==n.id&&(t.setBindGroup(n.index,r.group),a[n.index]=n.id)}if(u===!0&&n.index!==l){let e=this.get(l).buffer,r=l.array instanceof Uint16Array?vA.Uint16:vA.Uint32;t.setIndexBuffer(e,r),n.index=l}let d=e.getVertexBuffers();for(let e=0,r=d.length;e<r;e++){let r=d[e];if(n.attributes[e]!==r){let i=this.get(r).buffer;t.setVertexBuffer(e,i),n.attributes[e]=r}}i.stencil===!0&&r.stencilWrite===!0&&s.currentStencilRef!==r.stencilRef&&(t.setStencilReference(r.stencilRef),s.currentStencilRef=r.stencilRef)},p=(r,i)=>{if(f(r,i),n.isBatchedMesh===!0){let e=n._multiDrawStarts,i=n._multiDrawCounts,a=n._multiDrawCount,o=n._multiDrawInstances;o!==null&&Mr(`THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`);for(let s=0;s<a;s++){let a=o?o[s]:1,c=a>1?0:s;u===!0?r.drawIndexed(i[s],a,e[s]/l.array.BYTES_PER_ELEMENT,0,c):r.draw(i[s],a,e[s],c),t.update(n,i[s],a)}}else if(u===!0){let{vertexCount:i,instanceCount:a,firstVertex:o}=d,s=e.getIndirect();if(s!==null){let e=this.get(s).buffer;r.drawIndexedIndirect(e,0)}else r.drawIndexed(i,a,o,0,0);t.update(n,i,a)}else{let{vertexCount:i,instanceCount:a,firstVertex:o}=d,s=e.getIndirect();if(s!==null){let e=this.get(s).buffer;r.drawIndirect(e,0)}else r.draw(i,a,o,0);t.update(n,i,a)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let t=this.get(e.camera),r=e.camera.cameras,a=e.getBindingGroup(`cameraIndex`);if(t.indexesGPU===void 0||t.indexesGPU.length!==r.length){let e=this.get(a),n=[],i=new Uint32Array([0,0,0,0]);for(let t=0,a=r.length;t<a;t++){i[0]=t;let r=this.bindingUtils.createBindGroupIndex(i,e.layout);n.push(r)}t.indexesGPU=n}let o=this.renderer.getPixelRatio();for(let e=0,c=r.length;e<c;e++){let c=r[e];if(n.layers.test(c.layers)){let n=c.viewport,r=s.currentPass,l=s.currentSets;if(s.bundleEncoders){let t=s.bundleEncoders[e],n=s.bundleSets[e];r=t,l=n}n&&r.setViewport(Math.floor(n.x*o),Math.floor(n.y*o),Math.floor(n.width*o),Math.floor(n.height*o),i.viewportValue.minDepth,i.viewportValue.maxDepth),a&&t.indexesGPU&&(r.setBindGroup(a.index,t.indexesGPU[e]),l.bindingGroups[a.index]=a.id),p(r,l)}}}else if(s.currentPass){if(s.occlusionQuerySet!==void 0){let e=s.lastOcclusionObject;e!==n&&(e!==null&&e.occlusionTest===!0&&(s.currentPass.endOcclusionQuery(),s.occlusionQueryIndex++),n.occlusionTest===!0&&(s.currentPass.beginOcclusionQuery(s.occlusionQueryIndex),s.occlusionQueryObjects[s.occlusionQueryIndex]=n),s.lastOcclusionObject=n)}p(s.currentPass,s.currentSets)}}needsRenderUpdate(e){let t=this.get(e),{object:n,material:r}=e,i=this.utils,a=i.getSampleCountRenderContext(e.context),o=i.getCurrentColorSpace(e.context),s=i.getCurrentColorFormat(e.context),c=i.getCurrentDepthStencilFormat(e.context),l=i.getPrimitiveTopology(n,r),u=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==o||t.colorFormat!==s||t.depthStencilFormat!==c||t.primitiveTopology!==l||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=o,t.colorFormat=s,t.depthStencilFormat=c,t.primitiveTopology=l,t.clippingContextCacheKey=e.clippingContextCacheKey,u=!0),u}getRenderCacheKey(e){let{object:t,material:n}=e,r=this.utils,i=e.context;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,r.getSampleCountRenderContext(i),r.getCurrentColorSpace(i),r.getCurrentColorFormat(i),r.getCurrentDepthStencilFormat(i),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}async copyTextureToBuffer(e,t,n,r,i,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,a)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;let n=e.isComputeNode?`compute`:`render`;this.timestampQueryPool[n]||(this.timestampQueryPool[n]=new hj(this.device,n,2048));let r=this.timestampQueryPool[n],i=r.allocateQueriesForContext(e);t.timestampWrites={querySet:r.querySet,beginningOfPassWriteIndex:i,endOfPassWriteIndex:i+1}}createNodeBuilder(e,t){return new sj(e,t)}createProgram(e){let t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name===``?``:`_${e.name}`)}),entryPoint:`main`}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){let t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){let n=this.get(e),r=n.currentPass,i=r.finish();this.get(t).bundleGPU=i,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){let n=this.get(e);n.renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){let o=0,s=0,c=0,l=0,u=0,d=0,f=e.image.width,p=e.image.height,m=1;n!==null&&(n.isBox3===!0?(l=n.min.x,u=n.min.y,d=n.min.z,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=n.max.z-n.min.z):(l=n.min.x,u=n.min.y,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=1)),r!==null&&(o=r.x,s=r.y,c=r.z||0);let h=this.device.createCommandEncoder({label:`copyTextureToTexture_`+e.id+`_`+t.id}),g=this.get(e).texture,_=this.get(t).texture;h.copyTextureToTexture({texture:g,mipLevel:i,origin:{x:l,y:u,z:d}},{texture:_,mipLevel:a,origin:{x:o,y:s,z:c}},[f,p,m]),this.device.queue.submit([h.finish()]),a===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,n){let r=this.get(t),i=null;i=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();let a=this.get(e).texture;if(i.format!==a.format){console.error(`WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.`,i.format,a.format);return}let o;if(r.currentPass?(r.currentPass.end(),o=r.encoder):o=this.device.createCommandEncoder({label:`copyFramebufferToTexture_`+e.id}),o.copyTextureToTexture({texture:i,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),r.currentPass){let{descriptor:e}=r;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=hA.Load;if(t.depth&&(e.depthStencilAttachment.depthLoadOp=hA.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=hA.Load),r.currentPass=o.beginRenderPass(e),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor){let{x:e,y:n,width:i,height:a}=t.scissorValue;r.currentPass.setScissorRect(e,n,i,a)}}else this.device.queue.submit([o.finish()]);e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}},_j=class extends Es{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},vj=class extends Es{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}},yj=class extends YO{constructor(){super(),this.addMaterial(xv,`MeshPhongMaterial`),this.addMaterial(_b,`MeshStandardMaterial`),this.addMaterial(yb,`MeshPhysicalMaterial`),this.addMaterial(Cb,`MeshToonMaterial`),this.addMaterial(dv,`MeshBasicMaterial`),this.addMaterial(yv,`MeshLambertMaterial`),this.addMaterial(X_,`MeshNormalMaterial`),this.addMaterial(Db,`MeshMatcapMaterial`),this.addMaterial(V_,`LineBasicMaterial`),this.addMaterial(U_,`LineDashedMaterial`),this.addMaterial(Nb,`PointsMaterial`),this.addMaterial(jb,`SpriteMaterial`),this.addMaterial(Ib,`ShadowMaterial`),this.addLight(YT,js),this.addLight(bO,Ps),this.addLight(wO,Is),this.addLight(TO,Es),this.addLight(kO,Fs),this.addLight(AO,bs),this.addLight(jO,Rs),this.addLight(EO,_j),this.addLight(OO,vj),this.addToneMapping(zC,ze),this.addToneMapping(BC,Be),this.addToneMapping(VC,Ve),this.addToneMapping(UC,He),this.addToneMapping(qC,Ue),this.addToneMapping(JC,We)}},bj=class extends vk{constructor(e={}){let t;e.forceWebGL?t=dA:(t=gj,e.getFallback=()=>(console.warn(`THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.`),new dA(e)));let n=new t(e);super(n,e),this.library=new yj,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}},xj={};_(xj,{BRDF_GGX:()=>Sj,BRDF_Lambert:()=>Cj,BasicShadowFilter:()=>wj,Break:()=>Tj,Const:()=>_te,Continue:()=>Ej,DFGApprox:()=>Dj,D_GGX:()=>Oj,Discard:()=>kj,EPSILON:()=>Aj,F_Schlick:()=>jj,Fn:()=>Mj,INFINITY:()=>Nj,If:()=>Pj,Loop:()=>Ij,NodeAccess:()=>Bj,NodeShaderStage:()=>Lj,NodeType:()=>Rj,NodeUpdateType:()=>zj,PCFShadowFilter:()=>Vj,PCFSoftShadowFilter:()=>Hj,PI:()=>Uj,PI2:()=>Wj,Return:()=>Gj,Schlick_to_F0:()=>Kj,ScriptableNodeResources:()=>qj,ShaderNode:()=>Jj,Switch:()=>Fj,TBNViewMatrix:()=>Yj,VSMShadowFilter:()=>Xj,V_GGX_SmithCorrelated:()=>Zj,Var:()=>oF,abs:()=>Qj,acesFilmicToneMapping:()=>$j,acos:()=>eM,add:()=>tM,addNodeElement:()=>nM,agxToneMapping:()=>rM,all:()=>iM,alphaT:()=>aM,and:()=>oM,anisotropy:()=>sM,anisotropyB:()=>cM,anisotropyT:()=>lM,any:()=>uM,append:()=>dM,array:()=>fM,arrayBuffer:()=>pM,asin:()=>mM,assign:()=>hM,atan:()=>gM,atan2:()=>_M,atomicAdd:()=>vM,atomicAnd:()=>yM,atomicFunc:()=>bM,atomicLoad:()=>DM,atomicMax:()=>xM,atomicMin:()=>SM,atomicOr:()=>CM,atomicStore:()=>wM,atomicSub:()=>TM,atomicXor:()=>EM,attenuationColor:()=>pee,attenuationDistance:()=>mee,attribute:()=>hee,attributeArray:()=>gee,backgroundBlurriness:()=>_ee,backgroundIntensity:()=>vee,backgroundRotation:()=>yee,batch:()=>bee,billboarding:()=>xee,bitAnd:()=>See,bitNot:()=>Cee,bitOr:()=>wee,bitXor:()=>Tee,bitangentGeometry:()=>Eee,bitangentLocal:()=>Dee,bitangentView:()=>Oee,bitangentWorld:()=>kee,bitcast:()=>Aee,blendBurn:()=>jee,blendColor:()=>Mee,blendDodge:()=>Nee,blendOverlay:()=>Pee,blendScreen:()=>Fee,blur:()=>Iee,bool:()=>Lee,buffer:()=>Ree,bufferAttribute:()=>zee,bumpMap:()=>Bee,burn:()=>Vee,bvec2:()=>Hee,bvec3:()=>Uee,bvec4:()=>Wee,bypass:()=>Gee,cache:()=>Kee,call:()=>qee,cameraFar:()=>Jee,cameraIndex:()=>Yee,cameraNear:()=>Xee,cameraNormalMatrix:()=>Zee,cameraPosition:()=>Qee,cameraProjectionMatrix:()=>$ee,cameraProjectionMatrixInverse:()=>ete,cameraViewMatrix:()=>tte,cameraWorldMatrix:()=>nte,cbrt:()=>rte,cdl:()=>ite,ceil:()=>ate,checker:()=>ote,cineonToneMapping:()=>ste,clamp:()=>OM,clearcoat:()=>cte,clearcoatRoughness:()=>lte,code:()=>ute,color:()=>dte,colorSpaceToWorking:()=>fte,colorToDirection:()=>pte,compute:()=>mte,computeSkinning:()=>hte,cond:()=>gte,context:()=>vte,convert:()=>yte,convertColorSpace:()=>bte,convertToTexture:()=>xte,cos:()=>kM,cross:()=>Ste,cubeTexture:()=>Cte,dFdx:()=>wte,dFdy:()=>Tte,dashSize:()=>Ete,debug:()=>Dte,decrement:()=>Ote,decrementBefore:()=>kte,defaultBuildStages:()=>Ate,defaultShaderStages:()=>jte,defined:()=>Mte,degrees:()=>Nte,deltaTime:()=>Pte,densityFog:()=>Fte,densityFogFactor:()=>Ite,depth:()=>Lte,depthPass:()=>Rte,difference:()=>zte,diffuseColor:()=>Bte,directPointLight:()=>Vte,directionToColor:()=>Hte,dispersion:()=>Ute,distance:()=>Wte,div:()=>Gte,dodge:()=>Kte,dot:()=>AM,drawIndex:()=>qte,dynamicBufferAttribute:()=>Jte,element:()=>Yte,emissive:()=>Xte,equal:()=>Zte,equals:()=>Qte,equirectUV:()=>$te,exp:()=>ene,exp2:()=>tne,expression:()=>nne,faceDirection:()=>rne,faceForward:()=>ine,faceforward:()=>ane,float:()=>jM,floor:()=>one,fog:()=>sne,fract:()=>MM,frameGroup:()=>cne,frameId:()=>lne,frontFacing:()=>une,fwidth:()=>dne,gain:()=>fne,gapSize:()=>pne,getConstNodeType:()=>mne,getCurrentStack:()=>hne,getDirection:()=>gne,getDistanceAttenuation:()=>_ne,getGeometryRoughness:()=>vne,getNormalFromDepth:()=>yne,getParallaxCorrectNormal:()=>bne,getRoughness:()=>xne,getScreenPosition:()=>Sne,getShIrradianceAt:()=>Cne,getShadowMaterial:()=>Ene,getShadowRenderObjectFunction:()=>Dne,getTextureIndex:()=>wne,getViewPosition:()=>Tne,globalId:()=>yre,glsl:()=>One,glslFn:()=>kne,grayscale:()=>Ane,greaterThan:()=>jne,greaterThanEqual:()=>Mne,hash:()=>Nne,highpModelNormalViewMatrix:()=>Pne,highpModelViewMatrix:()=>Fne,hue:()=>Ine,increment:()=>Lne,incrementBefore:()=>Rne,instance:()=>zne,instanceIndex:()=>Bne,instancedArray:()=>Vne,instancedBufferAttribute:()=>Hne,instancedDynamicBufferAttribute:()=>Une,instancedMesh:()=>Wne,int:()=>Gne,inverseSqrt:()=>Kne,inversesqrt:()=>qne,invocationLocalIndex:()=>Jne,invocationSubgroupIndex:()=>Yne,ior:()=>Xne,iridescence:()=>Zne,iridescenceIOR:()=>Qne,iridescenceThickness:()=>$ne,ivec2:()=>ere,ivec3:()=>tre,ivec4:()=>nre,js:()=>rre,label:()=>ire,length:()=>are,lengthSq:()=>ore,lessThan:()=>sre,lessThanEqual:()=>cre,lightPosition:()=>lre,lightProjectionUV:()=>GM,lightShadowMatrix:()=>ure,lightTargetDirection:()=>dre,lightTargetPosition:()=>fre,lightViewPosition:()=>pre,lightingContext:()=>mre,lights:()=>hre,linearDepth:()=>gre,linearToneMapping:()=>_re,localId:()=>vre,log:()=>bre,log2:()=>xre,logarithmicDepthToViewZ:()=>Sre,loop:()=>Cre,luminance:()=>wre,mat2:()=>Ere,mat3:()=>Dre,mat4:()=>Ore,matcapUV:()=>kre,materialAO:()=>Are,materialAlphaTest:()=>jre,materialAnisotropy:()=>Mre,materialAnisotropyVector:()=>Nre,materialAttenuationColor:()=>Pre,materialAttenuationDistance:()=>Fre,materialClearcoat:()=>Ire,materialClearcoatNormal:()=>Lre,materialClearcoatRoughness:()=>Rre,materialColor:()=>zre,materialDispersion:()=>Bre,materialEmissive:()=>Vre,materialIOR:()=>Hre,materialIridescence:()=>Ure,materialIridescenceIOR:()=>Wre,materialIridescenceThickness:()=>Gre,materialLightMap:()=>Kre,materialLineDashOffset:()=>qre,materialLineDashSize:()=>Jre,materialLineGapSize:()=>Yre,materialLineScale:()=>Xre,materialLineWidth:()=>Zre,materialMetalness:()=>Qre,materialNormal:()=>$re,materialOpacity:()=>eie,materialPointSize:()=>tie,materialReference:()=>nie,materialReflectivity:()=>rie,materialRefractionRatio:()=>iie,materialRotation:()=>aie,materialRoughness:()=>oie,materialSheen:()=>sie,materialSheenRoughness:()=>cie,materialShininess:()=>lie,materialSpecular:()=>uie,materialSpecularColor:()=>die,materialSpecularIntensity:()=>fie,materialSpecularStrength:()=>pie,materialThickness:()=>mie,materialTransmission:()=>hie,max:()=>NM,maxMipLevel:()=>gie,mediumpModelViewMatrix:()=>Tre,metalness:()=>_ie,min:()=>vie,mix:()=>PM,mixElement:()=>yie,mod:()=>bie,modInt:()=>xie,modelDirection:()=>Sie,modelNormalMatrix:()=>Cie,modelPosition:()=>wie,modelRadius:()=>Tie,modelScale:()=>Eie,modelViewMatrix:()=>Die,modelViewPosition:()=>Oie,modelViewProjection:()=>kie,modelWorldMatrix:()=>Aie,modelWorldMatrixInverse:()=>jie,morphReference:()=>Mie,mrt:()=>Nie,mul:()=>FM,mx_aastep:()=>Pie,mx_cell_noise_float:()=>Fie,mx_contrast:()=>Iie,mx_fractal_noise_float:()=>Lie,mx_fractal_noise_vec2:()=>Rie,mx_fractal_noise_vec3:()=>zie,mx_fractal_noise_vec4:()=>Bie,mx_hsvtorgb:()=>Vie,mx_noise_float:()=>Hie,mx_noise_vec3:()=>Uie,mx_noise_vec4:()=>Wie,mx_ramplr:()=>Gie,mx_ramptb:()=>Kie,mx_rgbtohsv:()=>qie,mx_safepower:()=>Jie,mx_splitlr:()=>Yie,mx_splittb:()=>Xie,mx_srgb_texture_to_lin_rec709:()=>Zie,mx_transform_uv:()=>Qie,mx_worley_noise_float:()=>$ie,mx_worley_noise_vec2:()=>eae,mx_worley_noise_vec3:()=>tae,namespace:()=>nae,negate:()=>rae,neutralToneMapping:()=>iae,nodeArray:()=>aae,nodeImmutable:()=>oae,nodeObject:()=>sae,nodeObjects:()=>cae,nodeProxy:()=>lae,normalFlat:()=>uae,normalGeometry:()=>dae,normalLocal:()=>fae,normalMap:()=>pae,normalView:()=>mae,normalWorld:()=>hae,normalize:()=>gae,not:()=>_ae,notEqual:()=>vae,numWorkgroups:()=>yae,objectDirection:()=>bae,objectGroup:()=>xae,objectPosition:()=>Sae,objectRadius:()=>Cae,objectScale:()=>wae,objectViewPosition:()=>Tae,objectWorldMatrix:()=>Eae,oneMinus:()=>Dae,or:()=>Oae,orthographicDepthToViewZ:()=>kae,oscSawtooth:()=>Aae,oscSine:()=>jae,oscSquare:()=>Mae,oscTriangle:()=>Nae,output:()=>Pae,outputStruct:()=>Fae,overlay:()=>Iae,overloadingFn:()=>Lae,parabola:()=>Rae,parallaxDirection:()=>zae,parallaxUV:()=>Bae,parameter:()=>Vae,pass:()=>Hae,passTexture:()=>Uae,pcurve:()=>Wae,perspectiveDepthToViewZ:()=>Gae,pmremTexture:()=>Kae,pointShadow:()=>kN,pointUV:()=>qae,pointWidth:()=>Jae,positionGeometry:()=>Yae,positionLocal:()=>Xae,positionPrevious:()=>Zae,positionView:()=>Qae,positionViewDirection:()=>$ae,positionWorld:()=>eoe,positionWorldDirection:()=>toe,posterize:()=>noe,pow:()=>IM,pow2:()=>roe,pow3:()=>ioe,pow4:()=>aoe,premult:()=>LM,property:()=>RM,radians:()=>zM,rand:()=>BM,range:()=>VM,rangeFog:()=>HM,rangeFogFactor:()=>UM,reciprocal:()=>WM,reference:()=>KM,referenceBuffer:()=>qM,reflect:()=>JM,reflectVector:()=>YM,reflectView:()=>XM,reflector:()=>ZM,refract:()=>QM,refractVector:()=>$M,refractView:()=>eN,reinhardToneMapping:()=>tN,remainder:()=>nN,remap:()=>rN,remapClamp:()=>iN,renderGroup:()=>aN,renderOutput:()=>oN,rendererReference:()=>sN,rotate:()=>cN,rotateUV:()=>lN,roughness:()=>uN,round:()=>dN,rtt:()=>fN,sRGBTransferEOTF:()=>pN,sRGBTransferOETF:()=>mN,sampler:()=>hN,samplerComparison:()=>gN,saturate:()=>_N,saturation:()=>vN,screen:()=>yN,screenCoordinate:()=>bN,screenSize:()=>xN,screenUV:()=>SN,scriptable:()=>CN,scriptableValue:()=>wN,select:()=>TN,setCurrentStack:()=>EN,shaderStages:()=>DN,shadow:()=>ON,shadowPositionWorld:()=>AN,shapeCircle:()=>MN,sharedUniformGroup:()=>jN,sheen:()=>NN,sheenRoughness:()=>PN,shiftLeft:()=>FN,shiftRight:()=>IN,shininess:()=>LN,sign:()=>RN,sin:()=>zN,sinc:()=>BN,skinning:()=>VN,smoothstep:()=>HN,smoothstepElement:()=>UN,specularColor:()=>WN,specularF90:()=>GN,spherizeUV:()=>KN,split:()=>qN,spritesheetUV:()=>JN,sqrt:()=>YN,stack:()=>XN,step:()=>ZN,storage:()=>QN,storageBarrier:()=>$N,storageObject:()=>eP,storageTexture:()=>tP,string:()=>nP,struct:()=>rP,sub:()=>iP,subgroupIndex:()=>aP,subgroupSize:()=>oP,tan:()=>sP,tangentGeometry:()=>cP,tangentLocal:()=>lP,tangentView:()=>uP,tangentWorld:()=>dP,temp:()=>fP,texture:()=>pP,texture3D:()=>mP,textureBarrier:()=>hP,textureBicubic:()=>gP,textureCubeUV:()=>_P,textureLoad:()=>vP,textureSize:()=>yP,textureStore:()=>bP,thickness:()=>xP,time:()=>SP,timerDelta:()=>CP,timerGlobal:()=>wP,timerLocal:()=>TP,toneMapping:()=>EP,toneMappingExposure:()=>DP,toonOutlinePass:()=>OP,transformDirection:()=>kP,transformNormal:()=>AP,transformNormalToView:()=>jP,transformedBentNormalView:()=>MP,transformedBitangentView:()=>NP,transformedBitangentWorld:()=>PP,transformedClearcoatNormalView:()=>FP,transformedNormalView:()=>IP,transformedNormalWorld:()=>LP,transformedTangentView:()=>RP,transformedTangentWorld:()=>zP,transmission:()=>BP,transpose:()=>VP,triNoise3D:()=>HP,triplanarTexture:()=>UP,triplanarTextures:()=>WP,trunc:()=>GP,tslFn:()=>KP,uint:()=>qP,uniform:()=>JP,uniformArray:()=>XP,uniformCubeTexture:()=>YP,uniformGroup:()=>ZP,uniformTexture:()=>QP,uniforms:()=>$P,unpremult:()=>eF,userData:()=>tF,uv:()=>nF,uvec2:()=>rF,uvec3:()=>iF,uvec4:()=>aF,varying:()=>sF,varyingProperty:()=>cF,vec2:()=>lF,vec3:()=>uF,vec4:()=>dF,vectorComponents:()=>fF,velocity:()=>pF,vertexColor:()=>mF,vertexIndex:()=>hF,vibrance:()=>gF,viewZToLogarithmicDepth:()=>_F,viewZToOrthographicDepth:()=>vF,viewZToPerspectiveDepth:()=>yF,viewport:()=>bF,viewportBottomLeft:()=>xF,viewportCoordinate:()=>SF,viewportDepthTexture:()=>CF,viewportLinearDepth:()=>wF,viewportMipTexture:()=>TF,viewportResolution:()=>EF,viewportSafeUV:()=>DF,viewportSharedTexture:()=>OF,viewportSize:()=>kF,viewportTexture:()=>AF,viewportTopLeft:()=>jF,viewportUV:()=>MF,wgsl:()=>NF,wgslFn:()=>PF,workgroupArray:()=>FF,workgroupBarrier:()=>IF,workgroupId:()=>LF,workingToColorSpace:()=>RF,xor:()=>zF});const Sj=I.BRDF_GGX,Cj=I.BRDF_Lambert,wj=I.BasicShadowFilter,Tj=I.Break,Ej=I.Continue,Dj=I.DFGApprox,Oj=I.D_GGX,kj=I.Discard,Aj=I.EPSILON,jj=I.F_Schlick,Mj=I.Fn,Nj=I.INFINITY,Pj=I.If,Fj=I.Switch,Ij=I.Loop,Lj=I.NodeShaderStage,Rj=I.NodeType,zj=I.NodeUpdateType,Bj=I.NodeAccess,Vj=I.PCFShadowFilter,Hj=I.PCFSoftShadowFilter,Uj=I.PI,Wj=I.PI2,Gj=I.Return,Kj=I.Schlick_to_F0,qj=I.ScriptableNodeResources,Jj=I.ShaderNode,Yj=I.TBNViewMatrix,Xj=I.VSMShadowFilter,Zj=I.V_GGX_SmithCorrelated,Qj=I.abs,$j=I.acesFilmicToneMapping,eM=I.acos,tM=I.add,nM=I.addNodeElement,rM=I.agxToneMapping,iM=I.all,aM=I.alphaT,oM=I.and,sM=I.anisotropy,cM=I.anisotropyB,lM=I.anisotropyT,uM=I.any,dM=I.append,fM=I.array,pM=I.arrayBuffer,mM=I.asin,hM=I.assign,gM=I.atan,_M=I.atan2,vM=I.atomicAdd,yM=I.atomicAnd,bM=I.atomicFunc,xM=I.atomicMax,SM=I.atomicMin,CM=I.atomicOr,wM=I.atomicStore,TM=I.atomicSub,EM=I.atomicXor,DM=I.atomicLoad,pee=I.attenuationColor,mee=I.attenuationDistance,hee=I.attribute,gee=I.attributeArray,_ee=I.backgroundBlurriness,vee=I.backgroundIntensity,yee=I.backgroundRotation,bee=I.batch,xee=I.billboarding,See=I.bitAnd,Cee=I.bitNot,wee=I.bitOr,Tee=I.bitXor,Eee=I.bitangentGeometry,Dee=I.bitangentLocal,Oee=I.bitangentView,kee=I.bitangentWorld,Aee=I.bitcast,jee=I.blendBurn,Mee=I.blendColor,Nee=I.blendDodge,Pee=I.blendOverlay,Fee=I.blendScreen,Iee=I.blur,Lee=I.bool,Ree=I.buffer,zee=I.bufferAttribute,Bee=I.bumpMap,Vee=I.burn,Hee=I.bvec2,Uee=I.bvec3,Wee=I.bvec4,Gee=I.bypass,Kee=I.cache,qee=I.call,Jee=I.cameraFar,Yee=I.cameraIndex,Xee=I.cameraNear,Zee=I.cameraNormalMatrix,Qee=I.cameraPosition,$ee=I.cameraProjectionMatrix,ete=I.cameraProjectionMatrixInverse,tte=I.cameraViewMatrix,nte=I.cameraWorldMatrix,rte=I.cbrt,ite=I.cdl,ate=I.ceil,ote=I.checker,ste=I.cineonToneMapping,OM=I.clamp,cte=I.clearcoat,lte=I.clearcoatRoughness,ute=I.code,dte=I.color,fte=I.colorSpaceToWorking,pte=I.colorToDirection,mte=I.compute,hte=I.computeSkinning,gte=I.cond,_te=I.Const,vte=I.context,yte=I.convert,bte=I.convertColorSpace,xte=I.convertToTexture,kM=I.cos,Ste=I.cross,Cte=I.cubeTexture,wte=I.dFdx,Tte=I.dFdy,Ete=I.dashSize,Dte=I.debug,Ote=I.decrement,kte=I.decrementBefore,Ate=I.defaultBuildStages,jte=I.defaultShaderStages,Mte=I.defined,Nte=I.degrees,Pte=I.deltaTime,Fte=I.densityFog,Ite=I.densityFogFactor,Lte=I.depth,Rte=I.depthPass,zte=I.difference,Bte=I.diffuseColor,Vte=I.directPointLight,Hte=I.directionToColor,Ute=I.dispersion,Wte=I.distance,Gte=I.div,Kte=I.dodge,AM=I.dot,qte=I.drawIndex,Jte=I.dynamicBufferAttribute,Yte=I.element,Xte=I.emissive,Zte=I.equal,Qte=I.equals,$te=I.equirectUV,ene=I.exp,tne=I.exp2,nne=I.expression,rne=I.faceDirection,ine=I.faceForward,ane=I.faceforward,jM=I.float,one=I.floor,sne=I.fog,MM=I.fract,cne=I.frameGroup,lne=I.frameId,une=I.frontFacing,dne=I.fwidth,fne=I.gain,pne=I.gapSize,mne=I.getConstNodeType,hne=I.getCurrentStack,gne=I.getDirection,_ne=I.getDistanceAttenuation,vne=I.getGeometryRoughness,yne=I.getNormalFromDepth,bne=I.getParallaxCorrectNormal,xne=I.getRoughness,Sne=I.getScreenPosition,Cne=I.getShIrradianceAt,wne=I.getTextureIndex,Tne=I.getViewPosition,Ene=I.getShadowMaterial,Dne=I.getShadowRenderObjectFunction,One=I.glsl,kne=I.glslFn,Ane=I.grayscale,jne=I.greaterThan,Mne=I.greaterThanEqual,Nne=I.hash,Pne=I.highpModelNormalViewMatrix,Fne=I.highpModelViewMatrix,Ine=I.hue,Lne=I.increment,Rne=I.incrementBefore,zne=I.instance,Bne=I.instanceIndex,Vne=I.instancedArray,Hne=I.instancedBufferAttribute,Une=I.instancedDynamicBufferAttribute,Wne=I.instancedMesh,Gne=I.int,Kne=I.inverseSqrt,qne=I.inversesqrt,Jne=I.invocationLocalIndex,Yne=I.invocationSubgroupIndex,Xne=I.ior,Zne=I.iridescence,Qne=I.iridescenceIOR,$ne=I.iridescenceThickness,ere=I.ivec2,tre=I.ivec3,nre=I.ivec4,rre=I.js,ire=I.label,are=I.length,ore=I.lengthSq,sre=I.lessThan,cre=I.lessThanEqual,lre=I.lightPosition,ure=I.lightShadowMatrix,dre=I.lightTargetDirection,fre=I.lightTargetPosition,pre=I.lightViewPosition,mre=I.lightingContext,hre=I.lights,gre=I.linearDepth,_re=I.linearToneMapping,vre=I.localId,yre=I.globalId,bre=I.log,xre=I.log2,Sre=I.logarithmicDepthToViewZ,Cre=I.loop,wre=I.luminance,Tre=I.mediumpModelViewMatrix,Ere=I.mat2,Dre=I.mat3,Ore=I.mat4,kre=I.matcapUV,Are=I.materialAO,jre=I.materialAlphaTest,Mre=I.materialAnisotropy,Nre=I.materialAnisotropyVector,Pre=I.materialAttenuationColor,Fre=I.materialAttenuationDistance,Ire=I.materialClearcoat,Lre=I.materialClearcoatNormal,Rre=I.materialClearcoatRoughness,zre=I.materialColor,Bre=I.materialDispersion,Vre=I.materialEmissive,Hre=I.materialIOR,Ure=I.materialIridescence,Wre=I.materialIridescenceIOR,Gre=I.materialIridescenceThickness,Kre=I.materialLightMap,qre=I.materialLineDashOffset,Jre=I.materialLineDashSize,Yre=I.materialLineGapSize,Xre=I.materialLineScale,Zre=I.materialLineWidth,Qre=I.materialMetalness,$re=I.materialNormal,eie=I.materialOpacity,tie=I.materialPointSize,nie=I.materialReference,rie=I.materialReflectivity,iie=I.materialRefractionRatio,aie=I.materialRotation,oie=I.materialRoughness,sie=I.materialSheen,cie=I.materialSheenRoughness,lie=I.materialShininess,uie=I.materialSpecular,die=I.materialSpecularColor,fie=I.materialSpecularIntensity,pie=I.materialSpecularStrength,mie=I.materialThickness,hie=I.materialTransmission,NM=I.max,gie=I.maxMipLevel,_ie=I.metalness,vie=I.min,PM=I.mix,yie=I.mixElement,bie=I.mod,xie=I.modInt,Sie=I.modelDirection,Cie=I.modelNormalMatrix,wie=I.modelPosition,Tie=I.modelRadius,Eie=I.modelScale,Die=I.modelViewMatrix,Oie=I.modelViewPosition,kie=I.modelViewProjection,Aie=I.modelWorldMatrix,jie=I.modelWorldMatrixInverse,Mie=I.morphReference,Nie=I.mrt,FM=I.mul,Pie=I.mx_aastep,Fie=I.mx_cell_noise_float,Iie=I.mx_contrast,Lie=I.mx_fractal_noise_float,Rie=I.mx_fractal_noise_vec2,zie=I.mx_fractal_noise_vec3,Bie=I.mx_fractal_noise_vec4,Vie=I.mx_hsvtorgb,Hie=I.mx_noise_float,Uie=I.mx_noise_vec3,Wie=I.mx_noise_vec4,Gie=I.mx_ramplr,Kie=I.mx_ramptb,qie=I.mx_rgbtohsv,Jie=I.mx_safepower,Yie=I.mx_splitlr,Xie=I.mx_splittb,Zie=I.mx_srgb_texture_to_lin_rec709,Qie=I.mx_transform_uv,$ie=I.mx_worley_noise_float,eae=I.mx_worley_noise_vec2,tae=I.mx_worley_noise_vec3,nae=I.namespace,rae=I.negate,iae=I.neutralToneMapping,aae=I.nodeArray,oae=I.nodeImmutable,sae=I.nodeObject,cae=I.nodeObjects,lae=I.nodeProxy,uae=I.normalFlat,dae=I.normalGeometry,fae=I.normalLocal,pae=I.normalMap,mae=I.normalView,hae=I.normalWorld,gae=I.normalize,_ae=I.not,vae=I.notEqual,yae=I.numWorkgroups,bae=I.objectDirection,xae=I.objectGroup,Sae=I.objectPosition,Cae=I.objectRadius,wae=I.objectScale,Tae=I.objectViewPosition,Eae=I.objectWorldMatrix,Dae=I.oneMinus,Oae=I.or,kae=I.orthographicDepthToViewZ,Aae=I.oscSawtooth,jae=I.oscSine,Mae=I.oscSquare,Nae=I.oscTriangle,Pae=I.output,Fae=I.outputStruct,Iae=I.overlay,Lae=I.overloadingFn,Rae=I.parabola,zae=I.parallaxDirection,Bae=I.parallaxUV,Vae=I.parameter,Hae=I.pass,Uae=I.passTexture,Wae=I.pcurve,Gae=I.perspectiveDepthToViewZ,Kae=I.pmremTexture,qae=I.pointUV,Jae=I.pointWidth,Yae=I.positionGeometry,Xae=I.positionLocal,Zae=I.positionPrevious,Qae=I.positionView,$ae=I.positionViewDirection,eoe=I.positionWorld,toe=I.positionWorldDirection,noe=I.posterize,IM=I.pow,roe=I.pow2,ioe=I.pow3,aoe=I.pow4,LM=I.premult,RM=I.property,zM=I.radians,BM=I.rand,VM=I.range,HM=I.rangeFog,UM=I.rangeFogFactor,WM=I.reciprocal,GM=I.lightProjectionUV,KM=I.reference,qM=I.referenceBuffer,JM=I.reflect,YM=I.reflectVector,XM=I.reflectView,ZM=I.reflector,QM=I.refract,$M=I.refractVector,eN=I.refractView,tN=I.reinhardToneMapping,nN=I.remainder,rN=I.remap,iN=I.remapClamp,aN=I.renderGroup,oN=I.renderOutput,sN=I.rendererReference,cN=I.rotate,lN=I.rotateUV,uN=I.roughness,dN=I.round,fN=I.rtt,pN=I.sRGBTransferEOTF,mN=I.sRGBTransferOETF,hN=I.sampler,gN=I.samplerComparison,_N=I.saturate,vN=I.saturation,yN=I.screen,bN=I.screenCoordinate,xN=I.screenSize,SN=I.screenUV,CN=I.scriptable,wN=I.scriptableValue,TN=I.select,EN=I.setCurrentStack,DN=I.shaderStages,ON=I.shadow,kN=I.pointShadow,AN=I.shadowPositionWorld,jN=I.sharedUniformGroup,MN=I.shapeCircle,NN=I.sheen,PN=I.sheenRoughness,FN=I.shiftLeft,IN=I.shiftRight,LN=I.shininess,RN=I.sign,zN=I.sin,BN=I.sinc,VN=I.skinning,HN=I.smoothstep,UN=I.smoothstepElement,WN=I.specularColor,GN=I.specularF90,KN=I.spherizeUV,qN=I.split,JN=I.spritesheetUV,YN=I.sqrt,XN=I.stack,ZN=I.step,QN=I.storage,$N=I.storageBarrier,eP=I.storageObject,tP=I.storageTexture,nP=I.string,rP=I.struct,iP=I.sub,aP=I.subgroupIndex,oP=I.subgroupSize,sP=I.tan,cP=I.tangentGeometry,lP=I.tangentLocal,uP=I.tangentView,dP=I.tangentWorld,fP=I.temp,pP=I.texture,mP=I.texture3D,hP=I.textureBarrier,gP=I.textureBicubic,_P=I.textureCubeUV,vP=I.textureLoad,yP=I.textureSize,bP=I.textureStore,xP=I.thickness,SP=I.time,CP=I.timerDelta,wP=I.timerGlobal,TP=I.timerLocal,EP=I.toneMapping,DP=I.toneMappingExposure,OP=I.toonOutlinePass,kP=I.transformDirection,AP=I.transformNormal,jP=I.transformNormalToView,MP=I.transformedBentNormalView,NP=I.transformedBitangentView,PP=I.transformedBitangentWorld,FP=I.transformedClearcoatNormalView,IP=I.transformedNormalView,LP=I.transformedNormalWorld,RP=I.transformedTangentView,zP=I.transformedTangentWorld,BP=I.transmission,VP=I.transpose,HP=I.triNoise3D,UP=I.triplanarTexture,WP=I.triplanarTextures,GP=I.trunc,KP=I.tslFn,qP=I.uint,JP=I.uniform,YP=I.uniformCubeTexture,XP=I.uniformArray,ZP=I.uniformGroup,QP=I.uniformTexture,$P=I.uniforms,eF=I.unpremult,tF=I.userData,nF=I.uv,rF=I.uvec2,iF=I.uvec3,aF=I.uvec4,oF=I.Var,sF=I.varying,cF=I.varyingProperty,lF=I.vec2,uF=I.vec3,dF=I.vec4,fF=I.vectorComponents,pF=I.velocity,mF=I.vertexColor,hF=I.vertexIndex,gF=I.vibrance,_F=I.viewZToLogarithmicDepth,vF=I.viewZToOrthographicDepth,yF=I.viewZToPerspectiveDepth,bF=I.viewport,xF=I.viewportBottomLeft,SF=I.viewportCoordinate,CF=I.viewportDepthTexture,wF=I.viewportLinearDepth,TF=I.viewportMipTexture,EF=I.viewportResolution,DF=I.viewportSafeUV,OF=I.viewportSharedTexture,kF=I.viewportSize,AF=I.viewportTexture,jF=I.viewportTopLeft,MF=I.viewportUV,NF=I.wgsl,PF=I.wgslFn,FF=I.workgroupArray,IF=I.workgroupBarrier,LF=I.workgroupId,RF=I.workingToColorSpace,zF=I.xor;function BF(e,t,n=1){let r=e.rgb,i=t.rgb,a=FM(r,i),o=FM(t.a,n),s=PM(r,a,o),c=NM(e.a,FM(t.a,n));return dF(s,c)}function VF(e,t,n=1){let r=FM(t.a,n),i=tM(r,FM(e.a,iP(1,r))),a=tM(FM(t.rgb,r),FM(e.rgb,FM(e.a,iP(1,r))));return dF(a,i)}const HF={normal:VF,multiply:BF};function UF(e,t,n=`normal`,r=1){let i=HF[n]||HF.normal;return i(e,t,r)}function WF(e,t){let n=FM(e.a,t.a);return dF(e.rgb,n)}function GF(e,t){let n=iP(1,t.a),r=FM(e.a,n);return dF(e.rgb,r)}function KF(e,t){let n=uF(.2126,.7152,.0722),r=AM(t.rgb,n),i=FM(e.a,r);return dF(e.rgb,i)}function qF(e,t){let n=uF(.2126,.7152,.0722),r=AM(t.rgb,n),i=iP(1,r),a=FM(e.a,i);return dF(e.rgb,a)}const JF={alpha:WF,alphaInverted:GF,luminance:KF,luminanceInverted:qF};function YF(e,t,n=`alpha`){let r=JF[n]||JF.alpha;return r(e,t)}const XF={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1};let ZF=null,QF=!1;const $F=()=>{try{if(XF!==void 0){let{MODE:e,DEV:t}=XF;return t||e===`development`}if(typeof window<`u`&&window.location){let e=window.location.hostname;return e===`localhost`||e===`127.0.0.1`||e.endsWith(`.local`)||e.includes(`dev.`)||e.startsWith(`dev-`)}return!1}catch{return!1}};function eI(){let e,t,n,r,i,a={nodes:new Map,rootId:null,idToNodeId:new Map},o=null,s=null,c=null,l=!1,u=!1,d=null,f=!1,p=!0,m=0,h=0,g=0,_=0,v=8,y=.5,b=.5,x=!1,S=!1,ee=()=>{var e,t,n;return(e=t=(n=window).matchMedia)?.call(n,`(prefers-reduced-motion: reduce)`).matches??!1},te=(n,i)=>{if(n===m&&i===h)return;let o=performance.now();if(o-g<v)return;m=n,h=i,g=o,e.setSize(n,i,!1);let s=n/i,c=2,l=c*s;t.left=-l/2,t.right=l/2,t.top=c/2,t.bottom=-c/2,t.updateProjectionMatrix(),r.scale.set(l,c,1),a.rootId&&ie(),ge().catch(console.warn)},ne=n=>{if(!e||!t||!r)return;let i=n[0];if(!i)return;let{width:a,height:o}=i.contentRect,s=Math.round(a),c=Math.round(o);te(s,c)},re=e=>{let t=e[0];t&&(f=t.isIntersecting,f?(i&&l&&a.rootId&&ie(),p&&_e()):ve())},ie=()=>{if(!a.rootId||!i||S)return;let e=a.nodes.get(a.rootId);if(e){S=!0;try{let e=le(a.rootId);e&&i&&(i.fragmentNode=e,i.needsUpdate=!0)}catch(e){console.error(`Error composing shader tree:`,e)}finally{S=!1}f&&ge()}},ae=e=>{let t=[];return a.nodes.forEach(n=>{n.parentId===e&&t.push(n)}),t},oe=e=>{for(let[t,n]of a.nodes.entries())if(n.metadata.id===e)return t;return null},se=(e,t,n,r)=>{var i,a;if(!(i=a=t.metadata.mask)?.source)return e;let o=t.metadata.mask.source,s=oe(o);if(!s)return e;if(r.has(s))return console.error(`Uh oh, looks like you've got a circular dependency in your shader masks.`),e;let c=new Set(r);c.add(n);let l=le(s,c),u=t.metadata.mask.type||`alpha`;return YF(e,l,u)},ce=e=>{var t,n;let r=a.nodes.get(e);if(!r||!r.metadata.id)return!1;let i=r.metadata.id;for(let e of a.nodes.values())if((t=n=e.metadata.mask)?.source===i)return!0;return!1},le=(e,t=new Set)=>{let n=a.nodes.get(e);if(!n)return dF(0,0,0,0);let r=e=>{n.cleanupCallbacks.push(e)},i=e=>{n.beforeRenderCallbacks.push(e)},o=e=>{n.afterRenderCallbacks.push(e)},s=ae(e);if(s.length===0){let a=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:void 0,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:ZF});return se(a,n,e,t)}else{let a=[...s].sort((e,t)=>e.metadata.renderOrder-t.metadata.renderOrder),u=n.parentId===null;if(u){let s;for(let e of a){var c;if(e.metadata.opacity===0&&!ce(e.id))continue;let n=le(e.id,t),r=((c=e.uniforms)==null||(c=c.opacity)==null||(c=c.uniform)==null?void 0:c.value)>0,i=ce(e.id)&&!r?0:e.metadata.opacity;s=s===void 0?n:UF(s,n,e.metadata.blendMode,i)}let l=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:s,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:ZF});return se(l,n,e,t)}else{let s;for(let e of a){var l;let n=le(e.id,t);if(e.metadata.opacity===0&&!ce(e.id))continue;let r=((l=e.uniforms)==null||(l=l.opacity)==null||(l=l.uniform)==null?void 0:l.value)>0,i=ce(e.id)&&!r?0:e.metadata.opacity;s=s===void 0?n:UF(s,n,e.metadata.blendMode,i)}let c=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:s,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:ZF});return se(c,n,e,t)}}},ue=(e,t,n,r,o={})=>{let s=0;if(n!==null){let e=Array.from(a.nodes.values()).filter(e=>e.parentId===n);e.length>0&&(s=Math.max(...e.map(e=>e.metadata.renderOrder))+1)}let c={id:e,fragmentNodeFunc:t,parentId:n,metadata:{blendMode:r?.blendMode||`normal`,opacity:r?.opacity===void 0?1:r?.opacity,id:r?.id,mask:r?.mask,renderOrder:r?.renderOrder===void 0?s:r?.renderOrder},uniforms:o,cleanupCallbacks:[],beforeRenderCallbacks:[],afterRenderCallbacks:[]};a.nodes.set(e,c),n===null&&(a.rootId=e),i&&l&&ie()},de=(e,t,n)=>{let r=a.nodes.get(e);if(!r||!r.uniforms){console.warn(`Node or uniforms not found for ID: ${e}`);return}let i=r.uniforms[t];if(!i||!i.uniform){console.warn(`Uniform ${t} not found in node: ${e}`);return}i.uniform.value=n,f&&ge()},fe=(e,t)=>{var n,r,o,s,c,u,d,p;let m=a.nodes.get(e);if(!m)return;let h=!1;t.blendMode!==void 0&&m.metadata.blendMode!==t.blendMode&&(m.metadata.blendMode=t.blendMode,h=!0),t.opacity!==void 0&&m.metadata.opacity!==t.opacity&&(m.metadata.opacity=t.opacity,h=!0),t.renderOrder!==void 0&&m.metadata.renderOrder!==t.renderOrder&&(m.metadata.renderOrder=t.renderOrder,h=!0),t.id!==void 0&&m.metadata.id!==t.id&&(m.metadata.id=t.id,h=!0),t.mask!==void 0&&((n=c=m.metadata.mask)?.source!==(r=u=t.mask)?.source||(o=d=m.metadata.mask)?.type!==(s=p=t.mask)?.type)&&(m.metadata.mask=t.mask,h=!0),h&&i&&l?ie():f&&ge()},pe=e=>{if(!a.nodes.has(e))return;let t=a.nodes.get(e);if(t&&t.cleanupCallbacks.length>0)for(let n of t.cleanupCallbacks)try{n()}catch(t){console.error(`Error executing cleanup callback for node ${e}:`,t)}let n=ae(e);for(let e of n)pe(e.id);a.rootId===e&&(a.rootId=null),a.nodes.delete(e),i&&l&&ie()},me=e=>{let t={deltaTime:e,pointer:{x:y,y:b},pointerActive:x,dimensions:{width:m,height:h}};for(let e of a.nodes.values())if(e.beforeRenderCallbacks.length>0)for(let n of e.beforeRenderCallbacks)try{n(t)}catch(t){console.error(`Error executing before render callback for node ${e.id}:`,t)}},he=e=>{let t={deltaTime:e,pointer:{x:y,y:b},pointerActive:x,dimensions:{width:m,height:h}};for(let e of a.nodes.values())if(e.afterRenderCallbacks.length>0)for(let n of e.afterRenderCallbacks)try{n(t)}catch(t){console.error(`Error executing after render callback for node ${e.id}:`,t)}},ge=async()=>{if(!l||!e||!n||!t||!i)return;let r=performance.now(),a=_>0?(r-_)/1e3:.016,o=Math.min(a,.1);_=r,me(o);try{if(S)return;e instanceof bj?await e.renderAsync(n,t).then(()=>{l&&he(o)}).catch(e=>{console.error(`WebGPU render error:`,e)}):(e.render(n,t),he(o))}catch(e){console.error(`Render frame error:`,e)}},_e=()=>{if(o||!p||!f)return;let e=()=>{o=requestAnimationFrame(e),ge()};e()},ve=()=>{o&&(cancelAnimationFrame(o),o=null)},ye=e=>{if(!ZF)return;let t,n;if(`touches`in e){if(e.touches.length===0)return;t=e.touches[0].clientX,n=e.touches[0].clientY}else t=e.clientX,n=e.clientY;let r=ZF.getBoundingClientRect(),i=(t-r.left)/r.width,a=(n-r.top)/r.height;y=Math.max(0,Math.min(1,i)),b=Math.max(0,Math.min(1,a))},be=e=>{ye(e)},xe=e=>{ye(e)},Se=async({canvas:o})=>{if(l||u)return;u=!0,d=new AbortController;let m=d;try{if(ZF=o,n=new xo,n.background=null,t=new Ms(-1,1,1,-1,.1,10),t.position.z=1,t.lookAt(0,0,0),window.addEventListener(`mousemove`,be),window.addEventListener(`touchmove`,xe),o.addEventListener(`mousedown`,()=>{x=!0,ge()}),o.addEventListener(`touchstart`,()=>{x=!0,ge()}),window.addEventListener(`mouseup`,()=>{x=!1,ge()}),window.addEventListener(`touchend`,()=>{x=!1,ge()}),m.signal.aborted)return;try{if(e=new bj({canvas:o,antialias:!0,alpha:!0,depth:!1,powerPreference:`high-performance`}),await e.init(),m.signal.aborted){e.dispose();return}}catch(e){if(m.signal.aborted)return;console.error(`[Shaders] WebGPU initialization error:`,e);return}if(m.signal.aborted){e&&e.dispose();return}e.setPixelRatio(Math.min(window.devicePixelRatio,2)),e.outputColorSpace=gn,i=new dv({transparent:!0}),a.nodes.size===0?i.fragmentNode=dF(0,0,0,0):ie();let u=new Uo(2,2);r=new Qa(u,i),n.add(r),s=new ResizeObserver(ne),s.observe(o),c=new IntersectionObserver(re,{threshold:0}),c.observe(o),p=!ee();let{width:d,height:h}=o.getBoundingClientRect();te(Math.round(d),Math.round(h)),await ge(),p&&f&&_e(),m.signal.aborted||(l=!0)}catch(e){console.error(`[Shaders] Initialization error:`,e)}finally{u=!1,d===m&&(d=null)}},Ce=()=>{!$F()||QF||(console.warn(`Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production.`),QF=!0)},we=()=>{if(d&&d.abort(),s&&(s.disconnect(),s=null),c&&(c.disconnect(),c=null),ZF&&(ZF.removeEventListener(`mousedown`,()=>{x=!0}),ZF.removeEventListener(`touchstart`,()=>{x=!0})),window&&(window.removeEventListener(`mousemove`,be),window.removeEventListener(`touchmove`,xe),window.removeEventListener(`mouseup`,()=>{x=!1}),window.removeEventListener(`touchend`,()=>{x=!1})),ve(),a.nodes.clear(),a.rootId=null,a.idToNodeId.clear(),r&&(n&&n.remove(r),r.geometry&&r.geometry.dispose(),r.material instanceof ya&&r.material.dispose()),e)try{e.dispose()}catch(e){console.warn(`Error disposing renderer:`,e)}ZF=null,e=null,t=null,n=null,r=null,i=null,l=!1,u=!1,d=null,m=0,h=0,f=!1,p=!0,y=.5,b=.5,x=!1};return{initialize:Se,cleanup:we,registerNode:ue,removeNode:pe,updateUniformValue:de,updateNodeMetadata:fe,showLicenseWarning:Ce}}const{uniform:tI}=xj;function nI(e,t,n){let r={};return Object.entries(e.props).forEach(([e,i])=>{let a=t[e],o=a;i.transform&&(o=i.transform(a)),r[e]={uniform:tI(o).label(`${e}_${n}`),transform:i.transform||void 0}}),r}const{vec2:rI,fract:iI,sin:ooe,dot:aI}=xj,oI=e=>iI(ooe(aI(e,rI(12.12345,78.12345))).mul(40000.12345)),soe=(e=.03)=>t=>oI(t).mul(e).mul(.10012345),{vec2:sI}=xj,coe=(e=sI(0),t=.02,n=1,r=1)=>{let{vec2:i,sin:a,cos:o,time:s}=xj,c=r*1.618033988749895,l=r*2.718281828459045,u=(Math.sin(r)+2)*5,d=(Math.cos(r)+2)*5,f=i(a(e.x.mul(n).mul(u).add(s.mul(.1)).add(c)),o(e.y.mul(n).mul(u).add(s.mul(.1)).add(l))),p=i(a(e.y.mul(n).mul(d).add(s.mul(.05)).add(l)),o(e.x.mul(n).mul(d).add(s.mul(.05)).add(c))),m=f.add(p).mul(t);return e.add(m)},loe=(e,t,n=.6,r=.3,i=1)=>{let{max:a,smoothstep:o,vec4:s}=xj,c=a(a(e.r,e.g),e.b),l=o(n,n+r,c).mul(i).mul(1),u=e.rgb.add(t.rgb.mul(l));return s(u,e.a)},uoe=(e={})=>{let{inset:t=.4,softness:n=.5,offsetX:r=0,offsetY:i=0}=e,{float:a,smoothstep:o,uv:s}=xj,c=s(),l=c.x.sub(.5).sub(a(r)).mul(2),u=c.y.sub(.5).add(a(i)).mul(2),d=l.mul(l).add(u.mul(u)).sqrt();return a(1).sub(o(a(1).sub(a(t)),a(1).sub(a(t)).add(a(n)),d.mul(a(1).add(a(n)))))};var cI=function(exports){"use strict";function t(e){"@babel/helpers - typeof";return t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t(e)}function n(e,n){if(t(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(t(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function r(e){var r=n(e,`string`);return t(r)==`symbol`?r:r+``}function i(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return exports.defineProperty=i,exports}({}),lI,uI;function dI(e,t){let n=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let r=t[0].length,i=t[0].map((e,n)=>t.map(e=>e[n])),a=e.map(e=>i.map(t=>{let n=0;if(!Array.isArray(e)){for(let r of t)n+=e*r;return n}for(let r=0;r<e.length;r++)n+=e[r]*(t[r]||0);return n}));return n===1&&(a=a[0]),r===1?a.map(e=>e[0]):a}function fI(e){return pI(e)===`string`}function pI(e){let t=Object.prototype.toString.call(e);return(t.match(/^\[object\s+(.*?)\]$/)[1]||``).toLowerCase()}function mI(e,{precision:t,unit:n}){return hI(e)?`none`:_I(e,t)+(n??``)}function hI(e){return Number.isNaN(e)||e instanceof Number&&e?.none}function gI(e){return hI(e)?0:e}function _I(e,t){if(e===0)return 0;let n=~~e,r=0;n&&t&&(r=~~Math.log10(Math.abs(n))+1);let i=10**(t-r);return Math.floor(e*i+.5)/i}const vI={deg:1,grad:.9,rad:180/Math.PI,turn:360};function yI(e){if(!e)return;e=e.trim();let t=/^([a-z]+)\((.+?)\)$/i,n=/^-?[\d.]+$/,r=/%|deg|g?rad|turn$/,i=/\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g,a=e.match(t);if(a){let e=[];return a[2].replace(i,(t,i)=>{let a=i.match(r),o=i;if(a){let e=a[0],t=o.slice(0,-e.length);e===`%`?(o=new Number(t/100),o.type=`<percentage>`):(o=new Number(t*vI[e]),o.type=`<angle>`,o.unit=e)}else n.test(o)?(o=new Number(o),o.type=`<number>`):o===`none`&&(o=new Number(NaN),o.none=!0);t.startsWith(`/`)&&(o=o instanceof Number?o:new Number(o),o.alpha=!0),typeof o==`object`&&o instanceof Number&&(o.raw=i),e.push(o)}),{name:a[1].toLowerCase(),rawName:a[1],rawArgs:a[2],args:e}}}function bI(e){return e[e.length-1]}function xI(e,t,n){return isNaN(e)?t:isNaN(t)?e:e+(t-e)*n}function SI(e,t,n){return(n-e)/(t-e)}function CI(e,t,n){return xI(t[0],t[1],SI(e[0],e[1],n))}function wI(e){return e.map(e=>e.split(`|`).map(e=>{e=e.trim();let t=e.match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);if(t){let e=new String(t[1]);return e.range=[+t[2],+t[3]],e}return e}))}function TI(e,t,n){return Math.max(Math.min(n,t),e)}function EI(e,t){return Math.sign(e)===Math.sign(t)?e:-e}function DI(e,t){return EI(Math.abs(e)**t,e)}function OI(e,t){return t===0?0:e/t}function kI(e,t,n=0,r=e.length){for(;n<r;){let i=n+r>>1;e[i]<t?n=i+1:r=i}return n}var AI=Object.freeze({__proto__:null,bisectLeft:kI,clamp:TI,copySign:EI,interpolate:xI,interpolateInv:SI,isNone:hI,isString:fI,last:bI,mapRange:CI,multiplyMatrices:dI,parseCoordGrammar:wI,parseFunction:yI,serializeNumber:mI,skipNone:gI,spow:DI,toPrecision:_I,type:pI,zdiv:OI}),jI=class{add(e,t,n){if(typeof arguments[0]!=`string`){for(var e in arguments[0])this.add(e,arguments[0][e],arguments[1]);return}(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][n?`unshift`:`push`](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}};const MI=new jI;var NI={gamut_mapping:`css`,precision:5,deltaE:`76`,verbose:((lI=globalThis)==null||(lI=lI.process)==null||(lI=lI.env)==null||(lI=lI.NODE_ENV)==null?void 0:lI.toLowerCase())!==`test`,warn:function(e){var t,n;this.verbose&&((t=globalThis)==null||(t=t.console)==null||(n=t.warn)==null||n.call(t,e))}};const PI={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function FI(e){return Array.isArray(e)?e:PI[e]}function II(e,t,n,r={}){if(e=FI(e),t=FI(t),!e||!t)throw TypeError(`Missing white point to convert ${e?``:`from`}${!e&&!t?`/`:``}${t?``:`to`}`);if(e===t)return n;let i={W1:e,W2:t,XYZ:n,options:r};if(MI.run(`chromatic-adaptation-start`,i),i.M||(i.W1===PI.D65&&i.W2===PI.D50?i.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:i.W1===PI.D50&&i.W2===PI.D65&&(i.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),MI.run(`chromatic-adaptation-end`,i),i.M)return dI(i.M,i.XYZ);throw TypeError(`Only Bradford CAT with white points D50 and D65 supported for now.`)}const LI=new Set([`<number>`,`<percentage>`,`<angle>`]);function RI(e,t,n,r){let i=Object.entries(e.coords).map(([e,i],a)=>{let o=t.coordGrammar[a],s=r[a],c=s?.type,l;if(l=s.none?o.find(e=>LI.has(e)):o.find(e=>e==c),!l){let t=i.name||e;throw TypeError(`${c??s.raw} not allowed for ${t} in ${n}()`)}let u=l.range;c===`<percentage>`&&(u||=[0,1]);let d=i.range||i.refRange;return u&&d&&(r[a]=CI(u,d,r[a])),l});return i}function zI(e,{meta:t}={}){var n,r;let i={str:(n=r=String(e))?.trim()};if(MI.run(`parse-start`,i),i.color)return i.color;if(i.parsed=yI(i.str),i.parsed){let e=i.parsed.name;if(e===`color`){let e=i.parsed.args.shift(),n=e.startsWith(`--`)?e.substring(2):`--${e}`,r=[e,n],c=i.parsed.rawArgs.indexOf(`/`)>0?i.parsed.args.pop():1;for(let n of HI.all){let s=n.getFormat(`color`);if(s){var a,o;if(r.includes(s.id)||(a=o=s.ids)?.filter(e=>r.includes(e)).length){let r=Object.keys(n.coords).map((e,t)=>i.parsed.args[t]||0),a;return s.coordGrammar&&(a=RI(n,s,`color`,r)),t&&Object.assign(t,{formatId:`color`,types:a}),s.id.startsWith(`--`)&&!e.startsWith(`--`)&&NI.warn(`${n.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${s.id}) instead of color(${e}).`),e.startsWith(`--`)&&!s.id.startsWith(`--`)&&NI.warn(`${n.name} is a standard space and supported in the CSS spec. Use color(${s.id}) instead of prefixed color(${e}).`),{spaceId:n.id,coords:r,alpha:c}}}}let l=``,u=e in HI.registry?e:n;if(u in HI.registry){var s;let e=(s=HI.registry[u].formats)==null||(s=s.color)==null?void 0:s.id;e&&(l=`Did you mean color(${e})?`)}throw TypeError(`Cannot parse color(${e}). `+(l||`Missing a plugin?`))}else for(let n of HI.all){let r=n.getFormat(e);if(r&&r.type===`function`){let a=1;(r.lastAlpha||bI(i.parsed.args).alpha)&&(a=i.parsed.args.pop());let o=i.parsed.args,s;return r.coordGrammar&&(s=RI(n,r,e,o)),t&&Object.assign(t,{formatId:r.name,types:s}),{spaceId:n.id,coords:o,alpha:a}}}}else for(let e of HI.all)for(let n in e.formats){let r=e.formats[n];if(r.type!==`custom`||r.test&&!r.test(i.str))continue;let a=r.parse(i.str);if(a)return a.alpha??=1,t&&(t.formatId=n),a}throw TypeError(`Could not parse ${e} as a color. Missing a plugin?`)}function BI(e){if(Array.isArray(e))return e.map(BI);if(!e)throw TypeError(`Empty color reference`);fI(e)&&(e=zI(e));let t=e.space||e.spaceId;return t instanceof HI||(e.space=HI.get(t)),e.alpha===void 0&&(e.alpha=1),e}const VI=75e-6;var HI=(uI=class e{constructor(t){var n,r;this.id=t.id,this.name=t.name,this.base=t.base?e.get(t.base):null,this.aliases=t.aliases,this.base&&(this.fromBase=t.fromBase,this.toBase=t.toBase);let i=t.coords??this.base.coords;for(let e in i)`name`in i[e]||(i[e].name=e);this.coords=i;let a=t.white??this.base.white??`D65`;for(let e in this.white=FI(a),this.formats=t.formats??{},this.formats){let t=this.formats[e];t.type||=`function`,t.name||=e}(n=r=this.formats.color)?.id||(this.formats.color={...this.formats.color??{},id:t.cssId||this.id}),t.gamutSpace?this.gamutSpace=t.gamutSpace===`self`?this:e.get(t.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(e,t)=>!0),this.referred=t.referred,Object.defineProperty(this,`path`,{value:UI(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),MI.run(`colorspace-init-end`,this)}inGamut(e,{epsilon:t=VI}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:t});let n=Object.values(this.coords);return e.every((e,r)=>{let i=n[r];if(i.type!==`angle`&&i.range){if(Number.isNaN(e))return!0;let[n,r]=i.range;return(n===void 0||e>=n-t)&&(r===void 0||e<=r+t)}return!0})}get isUnbounded(){return Object.values(this.coords).every(e=>!(`range`in e))}get cssId(){var e;return((e=this.formats)==null||(e=e.color)==null?void 0:e.id)||this.id}get isPolar(){for(let e in this.coords)if(this.coords[e].type===`angle`)return!0;return!1}getFormat(e){if(typeof e==`object`)return e=WI(e,this),e;let t;return t=e===`default`?Object.values(this.formats)[0]:this.formats[e],t?(t=WI(t,this),t):null}equals(e){return e?this===e||this.id===e||this.id===e.id:!1}to(t,n){if(arguments.length===1){let e=BI(t);[t,n]=[e.space,e.coords]}if(t=e.get(t),this.equals(t))return n;n=n.map(e=>Number.isNaN(e)?0:e);let r=this.path,i=t.path,a,o;for(let e=0;e<r.length&&r[e].equals(i[e]);e++)a=r[e],o=e;if(!a)throw Error(`Cannot convert between color spaces ${this} and ${t}: no connection space was found`);for(let e=r.length-1;e>o;e--)n=r[e].toBase(n);for(let e=o+1;e<i.length;e++)n=i[e].fromBase(n);return n}from(t,n){if(arguments.length===1){let e=BI(t);[t,n]=[e.space,e.coords]}return t=e.get(t),t.to(this,n)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let t in this.coords){let n=this.coords[t],r=n.range||n.refRange;e.push(r?.min??0)}return e}static get all(){return[...new Set(Object.values(e.registry))]}static register(e,t){if(arguments.length===1&&(t=arguments[0],e=t.id),t=this.get(t),this.registry[e]&&this.registry[e]!==t)throw Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=t,arguments.length===1&&t.aliases)for(let e of t.aliases)this.register(e,t);return t}static get(t,...n){if(!t||t instanceof e)return t;let r=pI(t);if(r===`string`){let n=e.registry[t.toLowerCase()];if(!n)throw TypeError(`No color space found with id = "${t}"`);return n}if(n.length)return e.get(...n);throw TypeError(`${t} is not a valid color space`)}static resolveCoord(t,n){let r=pI(t),i,a;if(r===`string`?t.includes(`.`)?[i,a]=t.split(`.`):[i,a]=[,t]:Array.isArray(t)?[i,a]=t:(i=t.space,a=t.coordId),i=e.get(i),i||=n,!i)throw TypeError(`Cannot resolve coordinate reference ${t}: No color space specified and relative references are not allowed here`);if(r=pI(a),r===`number`||r===`string`&&a>=0){let e=Object.entries(i.coords)[a];if(e)return{space:i,id:e[0],index:a,...e[1]}}i=e.get(i);let o=a.toLowerCase(),s=0;for(let e in i.coords){var c,l;let t=i.coords[e];if(e.toLowerCase()===o||(c=l=t.name)?.toLowerCase()===o)return{space:i,id:e,index:s,...t};s++}throw TypeError(`No "${a}" coordinate found in ${i.name}. Its coordinates are: ${Object.keys(i.coords).join(`, `)}`)}},cI.defineProperty(uI,`registry`,{}),cI.defineProperty(uI,`DEFAULT_FORMAT`,{type:`functions`,name:`color`}),uI);function UI(e){let t=[e];for(let n=e;n=n.base;)t.push(n);return t}function WI(e,{coords:t}={}){if(e.coords&&!e.coordGrammar){e.type||=`function`,e.name||=`color`,e.coordGrammar=wI(e.coords);let n=Object.entries(t).map(([t,n],r)=>{let i=e.coordGrammar[r][0],a=n.range||n.refRange,o=i.range,s=``;return i==`<percentage>`?(o=[0,100],s=`%`):i==`<angle>`&&(s=`deg`),{fromRange:a,toRange:o,suffix:s}});e.serializeCoords=(e,t)=>e.map((e,r)=>{let{fromRange:i,toRange:a,suffix:o}=n[r];return i&&a&&(e=CI(i,a,e)),e=mI(e,{precision:t,unit:o}),e})}return e}var GI=new HI({id:`xyz-d65`,name:`XYZ D65`,coords:{x:{name:`X`},y:{name:`Y`},z:{name:`Z`}},white:`D65`,formats:{color:{ids:[`xyz-d65`,`xyz`]}},aliases:[`xyz`]}),KI=class extends HI{constructor(e){e.coords||={r:{range:[0,1],name:`Red`},g:{range:[0,1],name:`Green`},b:{range:[0,1],name:`Blue`}},e.base||=GI,e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??=t=>{let n=dI(e.toXYZ_M,t);return this.white!==this.base.white&&(n=II(this.white,this.base.white,n)),n},e.fromBase??=t=>(t=II(this.base.white,this.white,t),dI(e.fromXYZ_M,t))),e.referred??=`display`,super(e)}};function qI(e,t){return e=BI(e),!t||e.space.equals(t)?e.coords.slice():(t=HI.get(t),t.from(e))}function JI(e,t){e=BI(e);let{space:n,index:r}=HI.resolveCoord(t,e.space),i=qI(e,n);return i[r]}function YI(e,t,n){return e=BI(e),t=HI.get(t),e.coords=t.to(e.space,n),e}YI.returns=`color`;function XI(e,t,n){if(e=BI(e),arguments.length===2&&pI(arguments[1])===`object`){let t=arguments[1];for(let n in t)XI(e,n,t[n])}else{typeof n==`function`&&(n=n(JI(e,t)));let{space:r,index:i}=HI.resolveCoord(t,e.space),a=qI(e,r);a[i]=n,YI(e,r,a)}return e}XI.returns=`color`;var ZI=new HI({id:`xyz-d50`,name:`XYZ D50`,white:`D50`,base:GI,fromBase:e=>II(GI.white,`D50`,e),toBase:e=>II(`D50`,GI.white,e)});const QI=216/24389,$I=24/116,eL=24389/27;let tL=PI.D50;var nL=new HI({id:`lab`,name:`Lab`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:tL,base:ZI,fromBase(e){let t=e.map((e,t)=>e/tL[t]),n=t.map(e=>e>QI?Math.cbrt(e):(eL*e+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(e){let t=[];t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200;let n=[t[0]>$I?t[0]**3:(116*t[0]-16)/eL,e[0]>8?((e[0]+16)/116)**3:e[0]/eL,t[2]>$I?t[2]**3:(116*t[2]-16)/eL];return n.map((e,t)=>e*tL[t])},formats:{lab:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function rL(e){return(e%360+360)%360}function iL(e,t){if(e===`raw`)return t;let[n,r]=t.map(rL),i=r-n;return e===`increasing`?i<0&&(r+=360):e===`decreasing`?i>0&&(n+=360):e===`longer`?-180<i&&i<180&&(i>0?n+=360:r+=360):e===`shorter`&&(i>180?n+=360:i<-180&&(r+=360)),[n,r]}var aL=new HI({id:`lch`,name:`LCH`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,150],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:nL,fromBase(e){let[t,n,r]=e,i,a=.02;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),rL(i)]},toBase(e){let[t,n,r]=e;return n<0&&(n=0),isNaN(r)&&(r=0),[t,n*Math.cos(r*Math.PI/180),n*Math.sin(r*Math.PI/180)]},formats:{lch:{coords:[`<number> | <percentage>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const oL=25**7,sL=Math.PI,cL=180/sL,lL=sL/180;function uL(e){let t=e*e,n=t*t*t*e;return n}function dL(e,t,{kL:n=1,kC:r=1,kH:i=1}={}){[e,t]=BI([e,t]);let[a,o,s]=nL.from(e),c=aL.from(nL,[a,o,s])[1],[l,u,d]=nL.from(t),f=aL.from(nL,[l,u,d])[1];c<0&&(c=0),f<0&&(f=0);let p=(c+f)/2,m=uL(p),h=.5*(1-Math.sqrt(m/(m+oL))),g=(1+h)*o,_=(1+h)*u,v=Math.sqrt(g**2+s**2),y=Math.sqrt(_**2+d**2),b=g===0&&s===0?0:Math.atan2(s,g),x=_===0&&d===0?0:Math.atan2(d,_);b<0&&(b+=2*sL),x<0&&(x+=2*sL),b*=cL,x*=cL;let S=l-a,ee=y-v,te=x-b,ne=b+x,re=Math.abs(te),ie;v*y===0?ie=0:re<=180?ie=te:te>180?ie=te-360:te<-180?ie=te+360:NI.warn(`the unthinkable has happened`);let ae=2*Math.sqrt(y*v)*Math.sin(ie*lL/2),oe=(a+l)/2,se=(v+y)/2,ce=uL(se),le;le=v*y===0?ne:re<=180?ne/2:ne<360?(ne+360)/2:(ne-360)/2;let ue=(oe-50)**2,de=1+.015*ue/Math.sqrt(20+ue),fe=1+.045*se,pe=1;pe-=.17*Math.cos((le-30)*lL),pe+=.24*Math.cos(2*le*lL),pe+=.32*Math.cos((3*le+6)*lL),pe-=.2*Math.cos((4*le-63)*lL);let me=1+.015*se*pe,he=30*Math.exp(-1*((le-275)/25)**2),ge=2*Math.sqrt(ce/(ce+oL)),_e=-1*Math.sin(2*he*lL)*ge,ve=(S/(n*de))**2;return ve+=(ee/(r*fe))**2,ve+=(ae/(i*me))**2,ve+=_e*(ee/(r*fe))*(ae/(i*me)),Math.sqrt(ve)}const fL=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],pL=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],mL=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],hL=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var gL=new HI({id:`oklab`,name:`Oklab`,coords:{l:{refRange:[0,1],name:`Lightness`},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:`D65`,base:GI,fromBase(e){let t=dI(fL,e),n=t.map(e=>Math.cbrt(e));return dI(mL,n)},toBase(e){let t=dI(hL,e),n=t.map(e=>e**3);return dI(pL,n)},formats:{oklab:{coords:[`<percentage> | <number>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function _L(e,t){[e,t]=BI([e,t]);let[n,r,i]=gL.from(e),[a,o,s]=gL.from(t),c=n-a,l=r-o,u=i-s;return Math.sqrt(c**2+l**2+u**2)}const vL=75e-6;function yL(e,t,{epsilon:n=vL}={}){e=BI(e),t||=e.space,t=HI.get(t);let r=e.coords;return t!==e.space&&(r=t.from(e)),t.inGamut(r,{epsilon:n})}function bL(e){return{space:e.space,coords:e.coords.slice(),alpha:e.alpha}}function xL(e,t,n=`lab`){n=HI.get(n);let r=n.from(e),i=n.from(t);return Math.sqrt(r.reduce((e,t,n)=>{let r=i[n];return isNaN(t)||isNaN(r)?e:e+(r-t)**2},0))}function SL(e,t){return xL(e,t,`lab`)}const CL=Math.PI,wL=CL/180;function TL(e,t,{l:n=2,c:r=1}={}){[e,t]=BI([e,t]);let[i,a,o]=nL.from(e),[,s,c]=aL.from(nL,[i,a,o]),[l,u,d]=nL.from(t),f=aL.from(nL,[l,u,d])[1];s<0&&(s=0),f<0&&(f=0);let p=i-l,m=s-f,h=a-u,g=o-d,_=h**2+g**2-m**2,v=.511;i>=16&&(v=.040975*i/(1+.01765*i));let y=.0638*s/(1+.0131*s)+.638,b;Number.isNaN(c)&&(c=0),b=c>=164&&c<=345?.56+Math.abs(.2*Math.cos((c+168)*wL)):.36+Math.abs(.4*Math.cos((c+35)*wL));let x=s**4,S=Math.sqrt(x/(x+1900)),ee=y*(S*b+1-S),te=(p/(n*v))**2;return te+=(m/(r*y))**2,te+=_/ee**2,Math.sqrt(te)}const EL=203;var DL=new HI({id:`xyz-abs-d65`,cssId:`--xyz-abs-d65`,name:`Absolute XYZ D65`,coords:{x:{refRange:[0,9504.7],name:`Xa`},y:{refRange:[0,1e4],name:`Ya`},z:{refRange:[0,10888.3],name:`Za`}},base:GI,fromBase(e){return e.map(e=>Math.max(e*EL,0))},toBase(e){return e.map(e=>Math.max(e/EL,0))}});const OL=1.15,kL=.66,AL=2610/2**14,jL=2**14/2610,ML=3424/2**12,NL=2413/2**7,PL=2392/2**7,FL=1.7*2523/2**5,IL=2**5/(1.7*2523),LL=-.56,RL=16295499532821565e-27,zL=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],BL=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],VL=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],HL=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var UL=new HI({id:`jzazbz`,name:`Jzazbz`,coords:{jz:{refRange:[0,1],name:`Jz`},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:DL,fromBase(e){let[t,n,r]=e,i=OL*t-(OL-1)*r,a=kL*n-(kL-1)*t,o=dI(zL,[i,a,r]),s=o.map(function(e){let t=ML+NL*(e/1e4)**AL,n=1+PL*(e/1e4)**AL;return(t/n)**FL}),[c,l,u]=dI(VL,s),d=(1+LL)*c/(1+LL*c)-RL;return[d,l,u]},toBase(e){let[t,n,r]=e,i=(t+RL)/(1+LL-LL*(t+RL)),a=dI(HL,[i,n,r]),o=a.map(function(e){let t=ML-e**IL,n=PL*e**IL-NL,r=1e4*(t/n)**jL;return r}),[s,c,l]=dI(BL,o),u=(s+(OL-1)*l)/OL,d=(c+(kL-1)*u)/kL;return[u,d,l]},formats:{color:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),WL=new HI({id:`jzczhz`,name:`JzCzHz`,coords:{jz:{refRange:[0,1],name:`Jz`},cz:{refRange:[0,1],name:`Chroma`},hz:{refRange:[0,360],type:`angle`,name:`Hue`}},base:UL,fromBase(e){let[t,n,r]=e,i,a=2e-4;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),rL(i)]},toBase(e){return[e[0],e[1]*Math.cos(e[2]*Math.PI/180),e[1]*Math.sin(e[2]*Math.PI/180)]}});function GL(e,t){[e,t]=BI([e,t]);let[n,r,i]=WL.from(e),[a,o,s]=WL.from(t),c=n-a,l=r-o;Number.isNaN(i)&&Number.isNaN(s)?(i=0,s=0):Number.isNaN(i)?i=s:Number.isNaN(s)&&(s=i);let u=i-s,d=2*Math.sqrt(r*o)*Math.sin(u/2*(Math.PI/180));return Math.sqrt(c**2+l**2+d**2)}const KL=3424/4096,qL=2413/128,JL=2392/128,YL=2610/16384,XL=2523/32,ZL=16384/2610,QL=32/2523,$L=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],eR=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],tR=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],nR=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var rR=new HI({id:`ictcp`,name:`ICTCP`,coords:{i:{refRange:[0,1],name:`I`},ct:{refRange:[-.5,.5],name:`CT`},cp:{refRange:[-.5,.5],name:`CP`}},base:DL,fromBase(e){let t=dI($L,e);return iR(t)},toBase(e){let t=aR(e);return dI(nR,t)}});function iR(e){let t=e.map(function(e){let t=KL+qL*(e/1e4)**YL,n=1+JL*(e/1e4)**YL;return(t/n)**XL});return dI(eR,t)}function aR(e){let t=dI(tR,e),n=t.map(function(e){let t=Math.max(e**QL-KL,0),n=qL-JL*e**QL;return 1e4*(t/n)**ZL});return n}function oR(e,t){[e,t]=BI([e,t]);let[n,r,i]=rR.from(e),[a,o,s]=rR.from(t);return 720*Math.sqrt((n-a)**2+.25*(r-o)**2+(i-s)**2)}const sR=PI.D65,cR=.42,lR=1/cR,uR=2*Math.PI,dR=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],fR=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],pR=[[460,451,288],[460,-891,-261],[460,-220,-6300]],mR={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},hR={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},gR=180/Math.PI,_R=Math.PI/180;function vR(e,t){let n=e.map(e=>{let n=DI(t*Math.abs(e)*.01,cR);return 400*EI(n,e)/(n+27.13)});return n}function yR(e,t){let n=100/t*27.13**lR;return e.map(e=>{let t=Math.abs(e);return EI(n*DI(t/(400-t),lR),e)})}function bR(e){let t=rL(e);t<=hR.h[0]&&(t+=360);let n=kI(hR.h,t)-1,[r,i]=hR.h.slice(n,n+2),[a,o]=hR.e.slice(n,n+2),s=hR.H[n],c=(t-r)/a;return s+100*c/(c+(i-t)/o)}function xR(e){let t=(e%400+400)%400,n=Math.floor(.01*t);t%=100;let[r,i]=hR.h.slice(n,n+2),[a,o]=hR.e.slice(n,n+2);return rL((t*(o*r-a*i)-100*r*o)/(t*(o-a)-100*o))}function SR(e,t,n,r,i){let a={};a.discounting=i,a.refWhite=e,a.surround=r;let o=e.map(e=>e*100);a.la=t,a.yb=n;let s=o[1],c=dI(dR,o);r=mR[a.surround];let l=r[0];a.c=r[1],a.nc=r[2];let u=1/(5*a.la+1),d=u**4;a.fl=d*a.la+.1*(1-d)*(1-d)*Math.cbrt(5*a.la),a.flRoot=a.fl**.25,a.n=a.yb/s,a.z=1.48+Math.sqrt(a.n),a.nbb=.725*a.n**-.2,a.ncb=a.nbb;let f=i?1:Math.max(Math.min(l*(1-1/3.6*Math.exp((-a.la-42)/92)),1),0);a.dRgb=c.map(e=>xI(1,s/e,f)),a.dRgbInv=a.dRgb.map(e=>1/e);let p=c.map((e,t)=>e*a.dRgb[t]),m=vR(p,a.fl);return a.aW=a.nbb*(2*m[0]+m[1]+.05*m[2]),a}const CR=SR(sR,64/Math.PI*.2,20,`average`,!1);function wR(e,t){if(!(e.J!==void 0^e.Q!==void 0))throw Error(`Conversion requires one and only one: 'J' or 'Q'`);if(!(e.C!==void 0^e.M!==void 0^e.s!==void 0))throw Error(`Conversion requires one and only one: 'C', 'M' or 's'`);if(!(e.h!==void 0^e.H!==void 0))throw Error(`Conversion requires one and only one: 'h' or 'H'`);if(e.J===0||e.Q===0)return[0,0,0];let n=0;n=e.h===void 0?xR(e.H)*_R:rL(e.h)*_R;let r=Math.cos(n),i=Math.sin(n),a=0;e.J===void 0?e.Q!==void 0&&(a=.25*t.c*e.Q/((t.aW+4)*t.flRoot)):a=DI(e.J,1/2)*.1;let o=0;e.C===void 0?e.M===void 0?e.s!==void 0&&(o=4e-4*e.s**2*(t.aW+4)/t.c):o=e.M/t.flRoot/a:o=e.C/a;let s=DI(o*(1.64-.29**t.n)**-.73,10/9),c=.25*(Math.cos(n+2)+3.8),l=t.aW*DI(a,2/t.c/t.z),u=5e4/13*t.nc*t.ncb*c,d=l/t.nbb,f=23*(d+.305)*OI(s,23*u+s*(11*r+108*i)),p=f*r,m=f*i,h=yR(dI(pR,[d,p,m]).map(e=>e*1/1403),t.fl);return dI(fR,h.map((e,n)=>e*t.dRgbInv[n])).map(e=>e/100)}function TR(e,t){let n=e.map(e=>e*100),r=vR(dI(dR,n).map((e,n)=>e*t.dRgb[n]),t.fl),i=r[0]+(-12*r[1]+r[2])/11,a=(r[0]+r[1]-2*r[2])/9,o=(Math.atan2(a,i)%uR+uR)%uR,s=.25*(Math.cos(o+2)+3.8),c=5e4/13*t.nc*t.ncb*OI(s*Math.sqrt(i**2+a**2),r[0]+r[1]+1.05*r[2]+.305),l=DI(c,.9)*(1.64-.29**t.n)**.73,u=t.nbb*(2*r[0]+r[1]+.05*r[2]),d=DI(u/t.aW,.5*t.c*t.z),f=100*DI(d,2),p=4/t.c*d*(t.aW+4)*t.flRoot,m=l*d,h=m*t.flRoot,g=rL(o*gR),_=bR(g),v=50*DI(t.c*l/(t.aW+4),1/2);return{J:f,C:m,h:g,s:v,Q:p,M:h,H:_}}var ER=new HI({id:`cam16-jmh`,cssId:`--cam16-jmh`,name:`CAM16-JMh`,coords:{j:{refRange:[0,100],name:`J`},m:{refRange:[0,105],name:`Colorfulness`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:GI,fromBase(e){let t=TR(e,CR);return[t.J,t.M,t.h]},toBase(e){return wR({J:e[0],M:e[1],h:e[2]},CR)}});const DR=PI.D65,OR=216/24389,kR=24389/27;function AR(e){let t=e>OR?Math.cbrt(e):(kR*e+16)/116;return 116*t-16}function jR(e){return e>8?((e+16)/116)**3:e/kR}function MR(e,t){let[n,r,i]=e,a=[],o=0;if(i===0)return[0,0,0];let s=jR(i);o=i>0?.00379058511492914*i**2+.608983189401032*i+.9155088574762233:9514440756550361e-21*i**2+.08693057439788597*i-21.928975842194614;let c=2e-12,l=15,u=0,d=1/0;for(;u<=l;){a=wR({J:o,C:r,h:n},t);let e=Math.abs(a[1]-s);if(e<d){if(e<=c)return a;d=e}o-=(a[1]-s)*o/(2*a[1]),u+=1}return wR({J:o,C:r,h:n},t)}function NR(e,t){let n=AR(e[1]);if(n===0)return[0,0,0];let r=TR(e,PR);return[rL(r.h),r.C,n]}const PR=SR(DR,200/Math.PI*jR(50),jR(50)*100,`average`,!1);var FR=new HI({id:`hct`,name:`HCT`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},c:{refRange:[0,145],name:`Colorfulness`},t:{refRange:[0,100],name:`Tone`}},base:GI,fromBase(e){return NR(e)},toBase(e){return MR(e,PR)},formats:{color:{id:`--hct`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const IR=Math.PI/180,LR=[1,.007,.0228];function RR(e){e[1]<0&&(e=FR.fromBase(FR.toBase(e)));let t=Math.log(Math.max(1+LR[2]*e[1]*PR.flRoot,1))/LR[2],n=e[0]*IR,r=t*Math.cos(n),i=t*Math.sin(n);return[e[2],r,i]}function zR(e,t){[e,t]=BI([e,t]);let[n,r,i]=RR(FR.from(e)),[a,o,s]=RR(FR.from(t));return Math.sqrt((n-a)**2+(r-o)**2+(i-s)**2)}var BR={deltaE76:SL,deltaECMC:TL,deltaE2000:dL,deltaEJz:GL,deltaEITP:oR,deltaEOK:_L,deltaEHCT:zR};function VR(e){let t=e?Math.floor(Math.log10(Math.abs(e))):0;return Math.max(parseFloat(`1e${t-2}`),1e-6)}const HR={hct:{method:`hct.c`,jnd:2,deltaEMethod:`hct`,blackWhiteClamp:{}},"hct-tonal":{method:`hct.c`,jnd:0,deltaEMethod:`hct`,blackWhiteClamp:{channel:`hct.t`,min:0,max:100}}};function UR(e,{method:t=NI.gamut_mapping,space:n=void 0,deltaEMethod:r=``,jnd:i=2,blackWhiteClamp:a={}}={}){if(e=BI(e),fI(arguments[1])?n=arguments[1]:n||=e.space,n=HI.get(n),yL(e,n,{epsilon:0}))return e;let o;if(t===`css`)o=GR(e,{space:n});else{if(t!==`clip`&&!yL(e,n)){Object.prototype.hasOwnProperty.call(HR,t)&&({method:t,jnd:i,deltaEMethod:r,blackWhiteClamp:a}=HR[t]);let s=dL;if(r!==``){for(let e in BR)if(`deltae`+r.toLowerCase()===e.toLowerCase()){s=BR[e];break}}let c=UR(KR(e,n),{method:`clip`,space:n});if(s(e,c)>i){if(Object.keys(a).length===3){let t=HI.resolveCoord(a.channel),n=JI(KR(e,t.space),t.id);if(hI(n)&&(n=0),n>=a.max)return KR({space:`xyz-d65`,coords:PI.D65},e.space);if(n<=a.min)return KR({space:`xyz-d65`,coords:[0,0,0]},e.space)}let r=HI.resolveCoord(t),c=r.space,l=r.id,u=KR(e,c);u.coords.forEach((e,t)=>{hI(e)&&(u.coords[t]=0)});let d=r.range||r.refRange,f=d[0],p=VR(i),m=f,h=JI(u,l);for(;h-m>p;){let e=bL(u);e=UR(e,{space:n,method:`clip`});let t=s(u,e);t-i<p?m=JI(u,l):h=JI(u,l),XI(u,l,(m+h)/2)}o=KR(u,n)}else o=c}else o=KR(e,n);if(t===`clip`||!yL(o,n,{epsilon:0})){let e=Object.values(n.coords).map(e=>e.range||[]);o.coords=o.coords.map((t,n)=>{let[r,i]=e[n];return r!==void 0&&(t=Math.max(r,t)),i!==void 0&&(t=Math.min(t,i)),t})}}return n!==e.space&&(o=KR(o,e.space)),e.coords=o.coords,e}UR.returns=`color`;const WR={WHITE:{space:gL,coords:[1,0,0]},BLACK:{space:gL,coords:[0,0,0]}};function GR(e,{space:t}={}){let n=.02,r=1e-4;e=BI(e),t||=e.space,t=HI.get(t);let i=HI.get(`oklch`);if(t.isUnbounded)return KR(e,t);let a=KR(e,i),o=a.coords[0];if(o>=1){let n=KR(WR.WHITE,t);return n.alpha=e.alpha,KR(n,t)}if(o<=0){let n=KR(WR.BLACK,t);return n.alpha=e.alpha,KR(n,t)}if(yL(a,t,{epsilon:0}))return KR(a,t);function s(e){let n=KR(e,t),r=Object.values(t.coords);return n.coords=n.coords.map((e,t)=>{if(`range`in r[t]){let[n,i]=r[t].range;return TI(n,e,i)}return e}),n}let c=0,l=a.coords[1],u=!0,d=bL(a),f=s(d),p=_L(f,d);if(p<n)return f;for(;l-c>r;){let e=(c+l)/2;if(d.coords[1]=e,u&&yL(d,t,{epsilon:0}))c=e;else if(f=s(d),p=_L(f,d),p<n){if(n-p<r)break;u=!1,c=e}else l=e}return f}function KR(e,t,{inGamut:n}={}){e=BI(e),t=HI.get(t);let r=t.from(e),i={space:t,coords:r,alpha:e.alpha};return n&&(i=UR(i,n===!0?void 0:n)),i}KR.returns=`color`;function qR(e,{precision:t=NI.precision,format:n=`default`,inGamut:r=!0,...i}={}){let a;e=BI(e);let o=n;n=e.space.getFormat(n)??e.space.getFormat(`default`)??HI.DEFAULT_FORMAT;let s=e.coords.slice();if(r||=n.toGamut,r&&!yL(e)&&(s=UR(bL(e),r===!0?void 0:r).coords),n.type===`custom`)if(i.precision=t,n.serialize)a=n.serialize(s,e.alpha,i);else throw TypeError(`format ${o} can only be used to parse colors, not for serialization`);else{let r=n.name||`color`;n.serializeCoords?s=n.serializeCoords(s,t):t!==null&&(s=s.map(e=>mI(e,{precision:t})));let i=[...s];if(r===`color`){var c,l;let t=n.id||(c=l=n.ids)?.[0]||e.space.id;i.unshift(t)}let o=e.alpha;t!==null&&(o=mI(o,{precision:t}));let u=e.alpha>=1||n.noAlpha?``:`${n.commas?`,`:` /`} ${o}`;a=`${r}(${i.join(n.commas?`, `:` `)}${u})`}return a}const JR=[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],YR=[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]];var XR=new KI({id:`rec2020-linear`,cssId:`--rec2020-linear`,name:`Linear REC.2020`,white:`D65`,toXYZ_M:JR,fromXYZ_M:YR});const ZR=1.09929682680944,QR=.018053968510807;var $R=new KI({id:`rec2020`,name:`REC.2020`,base:XR,toBase(e){return e.map(function(e){return e<QR*4.5?e/4.5:((e+ZR-1)/ZR)**(1/.45)})},fromBase(e){return e.map(function(e){return e>=QR?ZR*e**.45-(ZR-1):4.5*e})}});const ez=[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],tz=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]];var nz=new KI({id:`p3-linear`,cssId:`--display-p3-linear`,name:`Linear P3`,white:`D65`,toXYZ_M:ez,fromXYZ_M:tz});const rz=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],iz=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var az=new KI({id:`srgb-linear`,name:`Linear sRGB`,white:`D65`,toXYZ_M:rz,fromXYZ_M:iz}),oz={aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aqua:[0,1,1],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],black:[0,0,0],blanchedalmond:[1,235/255,205/255],blue:[0,0,1],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[153/255,50/255,204/255],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],fuchsia:[1,0,1],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],gray:[128/255,128/255,128/255],green:[0,128/255,0],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,153/255],lightslategrey:[119/255,136/255,153/255],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],lime:[0,1,0],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],maroon:[128/255,0,0],mediumaquamarine:[102/255,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,204/255],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],navy:[0,0,128/255],oldlace:[253/255,245/255,230/255],olive:[128/255,128/255,0],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],purple:[128/255,0,128/255],rebeccapurple:[102/255,51/255,153/255],red:[1,0,0],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],silver:[192/255,192/255,192/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],teal:[0,128/255,128/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],white:[1,1,1],whitesmoke:[245/255,245/255,245/255],yellow:[1,1,0],yellowgreen:[154/255,205/255,50/255]};let sz=[,,,].fill(`<percentage> | <number>[0, 255]`),cz=[,,,].fill(`<number>[0, 255]`);var lz=new KI({id:`srgb`,name:`sRGB`,base:az,fromBase:e=>e.map(e=>{let t=e<0?-1:1,n=e*t;return n>.0031308?t*(1.055*n**(1/2.4)-.055):12.92*e}),toBase:e=>e.map(e=>{let t=e<0?-1:1,n=e*t;return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4}),formats:{rgb:{coords:sz},rgb_number:{name:`rgb`,commas:!0,coords:cz,noAlpha:!0},color:{},rgba:{coords:sz,commas:!0,lastAlpha:!0},rgba_number:{name:`rgba`,commas:!0,coords:cz},hex:{type:`custom`,toGamut:!0,test:e=>/^#([a-f0-9]{3,4}){1,2}$/i.test(e),parse(e){e.length<=5&&(e=e.replace(/[a-f0-9]/gi,`$&$&`));let t=[];return e.replace(/[a-f0-9]{2}/gi,e=>{t.push(parseInt(e,16)/255)}),{spaceId:`srgb`,coords:t.slice(0,3),alpha:t.slice(3)[0]}},serialize:(e,t,{collapse:n=!0}={})=>{t<1&&e.push(t),e=e.map(e=>Math.round(e*255));let r=n&&e.every(e=>e%17==0),i=e.map(e=>r?(e/17).toString(16):e.toString(16).padStart(2,`0`)).join(``);return`#`+i}},keyword:{type:`custom`,test:e=>/^[a-z]+$/i.test(e),parse(e){e=e.toLowerCase();let t={spaceId:`srgb`,coords:null,alpha:1};if(e===`transparent`?(t.coords=oz.black,t.alpha=0):t.coords=oz[e],t.coords)return t}}}}),uz=new KI({id:`p3`,cssId:`display-p3`,name:`P3`,base:nz,fromBase:lz.fromBase,toBase:lz.toBase});NI.display_space=lz;let dz;if(typeof CSS<`u`&&CSS.supports)for(let e of[nL,$R,uz]){let t=e.getMinCoords(),n={space:e,coords:t,alpha:1},r=qR(n);if(CSS.supports(`color`,r)){NI.display_space=e;break}}function fz(e,{space:t=NI.display_space,...n}={}){let r=qR(e,n);if(typeof CSS>`u`||CSS.supports(`color`,r)||!NI.display_space)r=new String(r),r.color=e;else{let i=e,a=e.coords.some(hI)||hI(e.alpha);if(a&&!(dz??=CSS.supports(`color`,`hsl(none 50% 50%)`))&&(i=bL(e),i.coords=i.coords.map(gI),i.alpha=gI(i.alpha),r=qR(i,n),CSS.supports(`color`,r)))return r=new String(r),r.color=i,r;i=KR(i,t),r=new String(qR(i,n)),r.color=i}return r}function pz(e,t){return e=BI(e),t=BI(t),e.space===t.space&&e.alpha===t.alpha&&e.coords.every((e,n)=>e===t.coords[n])}function mz(e){return JI(e,[GI,`y`])}function hz(e,t){XI(e,[GI,`y`],t)}function gz(e){Object.defineProperty(e.prototype,`luminance`,{get(){return mz(this)},set(e){hz(this,e)}})}var _z=Object.freeze({__proto__:null,getLuminance:mz,register:gz,setLuminance:hz});function vz(e,t){e=BI(e),t=BI(t);let n=Math.max(mz(e),0),r=Math.max(mz(t),0);return r>n&&([n,r]=[r,n]),(n+.05)/(r+.05)}const yz=.56,bz=.57,xz=.62,Sz=.65,Cz=.022,wz=1.414,Tz=.1,Ez=5e-4,Dz=1.14,Oz=.027,kz=1.14;function Az(e){return e>=Cz?e:e+(Cz-e)**wz}function jz(e){let t=e<0?-1:1,n=Math.abs(e);return t*n**2.4}function Mz(e,t){t=BI(t),e=BI(e);let n,r,i,a,o,s;t=KR(t,`srgb`),[a,o,s]=t.coords;let c=jz(a)*.2126729+jz(o)*.7151522+jz(s)*.072175;e=KR(e,`srgb`),[a,o,s]=e.coords;let l=jz(a)*.2126729+jz(o)*.7151522+jz(s)*.072175,u=Az(c),d=Az(l),f=d>u;return Math.abs(d-u)<Ez?r=0:f?(n=d**yz-u**bz,r=n*Dz):(n=d**Sz-u**xz,r=n*kz),i=Math.abs(r)<Tz?0:r>0?r-Oz:r+Oz,i*100}function Nz(e,t){e=BI(e),t=BI(t);let n=Math.max(mz(e),0),r=Math.max(mz(t),0);r>n&&([n,r]=[r,n]);let i=n+r;return i===0?0:(n-r)/i}const Pz=5e4;function Fz(e,t){e=BI(e),t=BI(t);let n=Math.max(mz(e),0),r=Math.max(mz(t),0);return r>n&&([n,r]=[r,n]),r===0?Pz:(n-r)/r}function Iz(e,t){e=BI(e),t=BI(t);let n=JI(e,[nL,`l`]),r=JI(t,[nL,`l`]);return Math.abs(n-r)}const Lz=216/24389,Rz=24/116,zz=24389/27;let Bz=PI.D65;var Vz=new HI({id:`lab-d65`,name:`Lab D65`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:Bz,base:GI,fromBase(e){let t=e.map((e,t)=>e/Bz[t]),n=t.map(e=>e>Lz?Math.cbrt(e):(zz*e+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(e){let t=[];t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200;let n=[t[0]>Rz?t[0]**3:(116*t[0]-16)/zz,e[0]>8?((e[0]+16)/116)**3:e[0]/zz,t[2]>Rz?t[2]**3:(116*t[2]-16)/zz];return n.map((e,t)=>e*Bz[t])},formats:{"lab-d65":{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});const Hz=5**.5*.5+.5;function Uz(e,t){e=BI(e),t=BI(t);let n=JI(e,[Vz,`l`]),r=JI(t,[Vz,`l`]),i=Math.abs(n**+Hz-r**+Hz),a=i**(1/Hz)*Math.SQRT2-40;return a<7.5?0:a}var Wz=Object.freeze({__proto__:null,contrastAPCA:Mz,contrastDeltaPhi:Uz,contrastLstar:Iz,contrastMichelson:Nz,contrastWCAG21:vz,contrastWeber:Fz});function Gz(e,t,n={}){fI(n)&&(n={algorithm:n});let{algorithm:r,...i}=n;if(!r){let e=Object.keys(Wz).map(e=>e.replace(/^contrast/,``)).join(`, `);throw TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${e}`)}for(let n in e=BI(e),t=BI(t),Wz)if(`contrast`+r.toLowerCase()===n.toLowerCase())return Wz[n](e,t,i);throw TypeError(`Unknown contrast algorithm: ${r}`)}function Kz(e){let[t,n,r]=qI(e,GI),i=t+15*n+3*r;return[4*t/i,9*n/i]}function qz(e){let[t,n,r]=qI(e,GI),i=t+n+r;return[t/i,n/i]}function Jz(e){Object.defineProperty(e.prototype,`uv`,{get(){return Kz(this)}}),Object.defineProperty(e.prototype,`xy`,{get(){return qz(this)}})}var Yz=Object.freeze({__proto__:null,register:Jz,uv:Kz,xy:qz});function Xz(e,t,n={}){fI(n)&&(n={method:n});let{method:r=NI.deltaE,...i}=n;for(let n in BR)if(`deltae`+r.toLowerCase()===n.toLowerCase())return BR[n](e,t,i);throw TypeError(`Unknown deltaE method: ${r}`)}function Zz(e,t=.25){let n=HI.get(`oklch`,`lch`),r=[n,`l`];return XI(e,r,e=>e*(1+t))}function Qz(e,t=.25){let n=HI.get(`oklch`,`lch`),r=[n,`l`];return XI(e,r,e=>e*(1-t))}var $z=Object.freeze({__proto__:null,darken:Qz,lighten:Zz});function eB(e,t,n=.5,r={}){[e,t]=[BI(e),BI(t)],pI(n)===`object`&&([n,r]=[.5,n]);let i=nB(e,t,r);return i(n)}function tB(e,t,n={}){let r;rB(e)&&([r,n]=[e,t],[e,t]=r.rangeArgs.colors);let{maxDeltaE:i,deltaEMethod:a,steps:o=2,maxSteps:s=1e3,...c}=n;r||([e,t]=[BI(e),BI(t)],r=nB(e,t,c));let l=Xz(e,t),u=i>0?Math.max(o,Math.ceil(l/i)+1):o,d=[];if(s!==void 0&&(u=Math.min(u,s)),u===1)d=[{p:.5,color:r(.5)}];else{let e=1/(u-1);d=Array.from({length:u},(t,n)=>{let i=n*e;return{p:i,color:r(i)}})}if(i>0){let e=d.reduce((e,t,n)=>{if(n===0)return 0;let r=Xz(t.color,d[n-1].color,a);return Math.max(e,r)},0);for(;e>i;){e=0;for(let t=1;t<d.length&&d.length<s;t++){let n=d[t-1],i=d[t],a=(i.p+n.p)/2,o=r(a);e=Math.max(e,Xz(o,n.color),Xz(o,i.color)),d.splice(t,0,{p:a,color:r(a)}),t++}}}return d=d.map(e=>e.color),d}function nB(e,t,n={}){if(rB(e)){let[n,r]=[e,t];return nB(...n.rangeArgs.colors,{...n.rangeArgs.options,...r})}let{space:r,outputSpace:i,progression:a,premultiplied:o}=n;e=BI(e),t=BI(t),e=bL(e),t=bL(t);let s={colors:[e,t],options:n};if(r=r?HI.get(r):HI.registry[NI.interpolationSpace]||e.space,i=i?HI.get(i):r,e=KR(e,r),t=KR(t,r),e=UR(e),t=UR(t),r.coords.h&&r.coords.h.type===`angle`){let i=n.hue=n.hue||`shorter`,a=[r,`h`],[o,s]=[JI(e,a),JI(t,a)];isNaN(o)&&!isNaN(s)?o=s:isNaN(s)&&!isNaN(o)&&(s=o),[o,s]=iL(i,[o,s]),XI(e,a,o),XI(t,a,s)}return o&&(e.coords=e.coords.map(t=>t*e.alpha),t.coords=t.coords.map(e=>e*t.alpha)),Object.assign(n=>{n=a?a(n):n;let s=e.coords.map((e,r)=>{let i=t.coords[r];return xI(e,i,n)}),c=xI(e.alpha,t.alpha,n),l={space:r,coords:s,alpha:c};return o&&(l.coords=l.coords.map(e=>e/c)),i!==r&&(l=KR(l,i)),l},{rangeArgs:s})}function rB(e){return pI(e)===`function`&&!!e.rangeArgs}NI.interpolationSpace=`lab`;function iB(e){e.defineFunction(`mix`,eB,{returns:`color`}),e.defineFunction(`range`,nB,{returns:`function<color>`}),e.defineFunction(`steps`,tB,{returns:`array<color>`})}var aB=Object.freeze({__proto__:null,isRange:rB,mix:eB,range:nB,register:iB,steps:tB}),oB=new HI({id:`hsl`,name:`HSL`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:lz,fromBase:e=>{let t=Math.max(...e),n=Math.min(...e),[r,i,a]=e,[o,s,c]=[NaN,0,(n+t)/2],l=t-n;if(l!==0){switch(s=c===0||c===1?0:(t-c)/Math.min(c,1-c),t){case r:o=(i-a)/l+(i<a?6:0);break;case i:o=(a-r)/l+2;break;case a:o=(r-i)/l+4}o*=60}return s<0&&(o+=180,s=Math.abs(s)),o>=360&&(o-=360),[o,s*100,c*100]},toBase:e=>{let[t,n,r]=e;t%=360,t<0&&(t+=360),n/=100,r/=100;function i(e){let i=(e+t/30)%12,a=n*Math.min(r,1-r);return r-a*Math.max(-1,Math.min(i-3,9-i,1))}return[i(0),i(8),i(4)]},formats:{hsl:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`]},hsla:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`],commas:!0,lastAlpha:!0}}}),sB=new HI({id:`hsv`,name:`HSV`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},v:{range:[0,100],name:`Value`}},base:oB,fromBase(e){let[t,n,r]=e;n/=100,r/=100;let i=r+n*Math.min(r,1-r);return[t,i===0?0:200*(1-r/i),100*i]},toBase(e){let[t,n,r]=e;n/=100,r/=100;let i=r*(1-n/2);return[t,i===0||i===1?0:(r-i)/Math.min(i,1-i)*100,i*100]},formats:{color:{id:`--hsv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}}),cB=new HI({id:`hwb`,name:`HWB`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},w:{range:[0,100],name:`Whiteness`},b:{range:[0,100],name:`Blackness`}},base:sB,fromBase(e){let[t,n,r]=e;return[t,r*(100-n)/100,100-r]},toBase(e){let[t,n,r]=e;n/=100,r/=100;let i=n+r;if(i>=1){let e=n/i;return[t,0,e*100]}let a=1-r,o=a===0?0:1-n/a;return[t,o*100,a*100]},formats:{hwb:{coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const lB=[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],uB=[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]];var dB=new KI({id:`a98rgb-linear`,cssId:`--a98-rgb-linear`,name:`Linear Adobe® 98 RGB compatible`,white:`D65`,toXYZ_M:lB,fromXYZ_M:uB}),fB=new KI({id:`a98rgb`,cssId:`a98-rgb`,name:`Adobe® 98 RGB compatible`,base:dB,toBase:e=>e.map(e=>Math.abs(e)**(563/256)*Math.sign(e)),fromBase:e=>e.map(e=>Math.abs(e)**(256/563)*Math.sign(e))});const pB=[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],mB=[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]];var hB=new KI({id:`prophoto-linear`,cssId:`--prophoto-rgb-linear`,name:`Linear ProPhoto`,white:`D50`,base:ZI,toXYZ_M:pB,fromXYZ_M:mB});const gB=1/512,_B=16/512;var vB=new KI({id:`prophoto`,cssId:`prophoto-rgb`,name:`ProPhoto`,base:hB,toBase(e){return e.map(e=>e<_B?e/16:e**1.8)},fromBase(e){return e.map(e=>e>=gB?e**(1/1.8):16*e)}}),yB=new HI({id:`oklch`,name:`Oklch`,coords:{l:{refRange:[0,1],name:`Lightness`},c:{refRange:[0,.4],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},white:`D65`,base:gL,fromBase(e){let[t,n,r]=e,i,a=2e-4;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),rL(i)]},toBase(e){let[t,n,r]=e,i,a;return isNaN(r)?(i=0,a=0):(i=n*Math.cos(r*Math.PI/180),a=n*Math.sin(r*Math.PI/180)),[t,i,a]},formats:{oklch:{coords:[`<percentage> | <number>`,`<number> | <percentage>[0,1]`,`<number> | <angle>`]}}});let bB=PI.D65;const xB=216/24389,SB=24389/27,[CB,wB]=Kz({space:GI,coords:bB});var TB=new HI({id:`luv`,name:`Luv`,coords:{l:{refRange:[0,100],name:`Lightness`},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:bB,base:GI,fromBase(e){let t=[gI(e[0]),gI(e[1]),gI(e[2])],n=t[1],[r,i]=Kz({space:GI,coords:t});if(!Number.isFinite(r)||!Number.isFinite(i))return[0,0,0];let a=n<=xB?SB*n:116*Math.cbrt(n)-16;return[a,13*a*(r-CB),13*a*(i-wB)]},toBase(e){let[t,n,r]=e;if(t===0||hI(t))return[0,0,0];n=gI(n),r=gI(r);let i=n/(13*t)+CB,a=r/(13*t)+wB,o=t<=8?t/SB:((t+16)/116)**3;return[o*(9*i/(4*a)),o,o*((12-3*i-20*a)/(4*a))]},formats:{color:{id:`--luv`,coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),EB=new HI({id:`lchuv`,name:`LChuv`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,220],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:TB,fromBase(e){let[t,n,r]=e,i,a=.02;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),rL(i)]},toBase(e){let[t,n,r]=e;return n<0&&(n=0),isNaN(r)&&(r=0),[t,n*Math.cos(r*Math.PI/180),n*Math.sin(r*Math.PI/180)]},formats:{color:{id:`--lchuv`,coords:[`<number> | <percentage>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const DB=216/24389,OB=24389/27,kB=iz[0][0],AB=iz[0][1],jB=iz[0][2],MB=iz[1][0],NB=iz[1][1],PB=iz[1][2],FB=iz[2][0],IB=iz[2][1],LB=iz[2][2];function RB(e,t,n){let r=t/(Math.sin(n)-e*Math.cos(n));return r<0?1/0:r}function zB(e){let t=(e+16)**3/1560896,n=t>DB?t:e/OB,r=n*(284517*kB-94839*jB),i=n*(838422*jB+769860*AB+731718*kB),a=n*(632260*jB-126452*AB),o=n*(284517*MB-94839*PB),s=n*(838422*PB+769860*NB+731718*MB),c=n*(632260*PB-126452*NB),l=n*(284517*FB-94839*LB),u=n*(838422*LB+769860*IB+731718*FB),d=n*(632260*LB-126452*IB);return{r0s:r/a,r0i:i*e/a,r1s:r/(a+126452),r1i:(i-769860)*e/(a+126452),g0s:o/c,g0i:s*e/c,g1s:o/(c+126452),g1i:(s-769860)*e/(c+126452),b0s:l/d,b0i:u*e/d,b1s:l/(d+126452),b1i:(u-769860)*e/(d+126452)}}function BB(e,t){let n=t/360*Math.PI*2,r=RB(e.r0s,e.r0i,n),i=RB(e.r1s,e.r1i,n),a=RB(e.g0s,e.g0i,n),o=RB(e.g1s,e.g1i,n),s=RB(e.b0s,e.b0i,n),c=RB(e.b1s,e.b1i,n);return Math.min(r,i,a,o,s,c)}var VB=new HI({id:`hsluv`,name:`HSLuv`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:EB,gamutSpace:lz,fromBase(e){let[t,n,r]=[gI(e[0]),gI(e[1]),gI(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=zB(t),a=BB(e,r);i=n/a*100}return[r,i,t]},toBase(e){let[t,n,r]=[gI(e[0]),gI(e[1]),gI(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=zB(r),a=BB(e,t);i=a/100*n}return[r,i,t]},formats:{color:{id:`--hsluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});iz[0][0],iz[0][1],iz[0][2],iz[1][0],iz[1][1],iz[1][2],iz[2][0],iz[2][1],iz[2][2];function HB(e,t){return Math.abs(t)/Math.sqrt(e**2+1)}function UB(e){let t=HB(e.r0s,e.r0i),n=HB(e.r1s,e.r1i),r=HB(e.g0s,e.g0i),i=HB(e.g1s,e.g1i),a=HB(e.b0s,e.b0i),o=HB(e.b1s,e.b1i);return Math.min(t,n,r,i,a,o)}var WB=new HI({id:`hpluv`,name:`HPLuv`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:EB,gamutSpace:`self`,fromBase(e){let[t,n,r]=[gI(e[0]),gI(e[1]),gI(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=zB(t),r=UB(e);i=n/r*100}return[r,i,t]},toBase(e){let[t,n,r]=[gI(e[0]),gI(e[1]),gI(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=zB(r),t=UB(e);i=t/100*n}return[r,i,t]},formats:{color:{id:`--hpluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const GB=203,KB=2610/2**14,qB=2**14/2610,JB=2523/2**5,YB=2**5/2523,XB=3424/2**12,ZB=2413/2**7,QB=2392/2**7;var $B=new KI({id:`rec2100pq`,cssId:`rec2100-pq`,name:`REC.2100-PQ`,base:XR,toBase(e){return e.map(function(e){let t=(Math.max(e**YB-XB,0)/(ZB-QB*e**YB))**qB;return t*1e4/GB})},fromBase(e){return e.map(function(e){let t=Math.max(e*GB/1e4,0),n=XB+ZB*t**KB,r=1+QB*t**KB;return(n/r)**JB})}});const eV=.17883277,tV=.28466892,nV=.55991073,rV=3.7743;var iV=new KI({id:`rec2100hlg`,cssId:`rec2100-hlg`,name:`REC.2100-HLG`,referred:`scene`,base:XR,toBase(e){return e.map(function(e){return e<=.5?e**2/3*rV:(Math.exp((e-nV)/eV)+tV)/12*rV})},fromBase(e){return e.map(function(e){return e/=rV,e<=1/12?Math.sqrt(3*e):eV*Math.log(12*e-tV)+nV})}});const aV={};MI.add(`chromatic-adaptation-start`,e=>{e.options.method&&(e.M=sV(e.W1,e.W2,e.options.method))}),MI.add(`chromatic-adaptation-end`,e=>{e.M||=sV(e.W1,e.W2,e.options.method)});function oV({id:e,toCone_M:t,fromCone_M:n}){aV[e]=arguments[0]}function sV(e,t,n=`Bradford`){let r=aV[n],[i,a,o]=dI(r.toCone_M,e),[s,c,l]=dI(r.toCone_M,t),u=[[s/i,0,0],[0,c/a,0],[0,0,l/o]],d=dI(u,r.toCone_M),f=dI(r.fromCone_M,d);return f}oV({id:`von Kries`,toCone_M:[[.40024,.7076,-.08081],[-.2263,1.16532,.0457],[0,0,.91822]],fromCone_M:[[1.8599363874558397,-1.1293816185800916,.21989740959619328],[.3611914362417676,.6388124632850422,-6370596838649899e-21],[0,0,1.0890636230968613]]}),oV({id:`Bradford`,toCone_M:[[.8951,.2664,-.1614],[-.7502,1.7135,.0367],[.0389,-.0685,1.0296]],fromCone_M:[[.9869929054667121,-.14705425642099013,.15996265166373122],[.4323052697233945,.5183602715367774,.049291228212855594],[-.00852866457517732,.04004282165408486,.96848669578755]]}),oV({id:`CAT02`,toCone_M:[[.7328,.4296,-.1624],[-.7036,1.6975,.0061],[.003,.0136,.9834]],fromCone_M:[[1.0961238208355142,-.27886900021828726,.18274517938277307],[.4543690419753592,.4735331543074117,.07209780371722911],[-.009627608738429355,-.00569803121611342,1.0153256399545427]]}),oV({id:`CAT16`,toCone_M:[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],fromCone_M:[[1.862067855087233,-1.0112546305316845,.14918677544445172],[.3875265432361372,.6214474419314753,-.008973985167612521],[-.01584149884933386,-.03412293802851557,1.0499644368778496]]}),Object.assign(PI,{A:[1.0985,1,.35585],C:[.98074,1,1.18232],D55:[.95682,1,.92149],D75:[.94972,1,1.22638],E:[1,1,1],F2:[.99186,1,.67393],F7:[.95041,1,1.08747],F11:[1.00962,1,.6435]}),PI.ACES=[.32168/.33767,1,.34065/.33767];const cV=[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],lV=[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]];var uV=new KI({id:`acescg`,cssId:`--acescg`,name:`ACEScg`,coords:{r:{range:[0,65504],name:`Red`},g:{range:[0,65504],name:`Green`},b:{range:[0,65504],name:`Blue`}},referred:`scene`,white:PI.ACES,toXYZ_M:cV,fromXYZ_M:lV});const dV=2**-16,fV=-.35828683,pV=(Math.log2(65504)+9.72)/17.52;var mV=new KI({id:`acescc`,cssId:`--acescc`,name:`ACEScc`,coords:{r:{range:[fV,pV],name:`Red`},g:{range:[fV,pV],name:`Green`},b:{range:[fV,pV],name:`Blue`}},referred:`scene`,base:uV,toBase(e){let t=-5.279999999999999/17.52;return e.map(function(e){return e<=t?(2**(e*17.52-9.72)-dV)*2:e<pV?2**(e*17.52-9.72):65504})},fromBase(e){return e.map(function(e){return e<=0?(Math.log2(dV)+9.72)/17.52:e<dV?(Math.log2(dV+e*.5)+9.72)/17.52:(Math.log2(e)+9.72)/17.52})}}),hV=Object.freeze({__proto__:null,A98RGB:fB,A98RGB_Linear:dB,ACEScc:mV,ACEScg:uV,CAM16_JMh:ER,HCT:FR,HPLuv:WB,HSL:oB,HSLuv:VB,HSV:sB,HWB:cB,ICTCP:rR,JzCzHz:WL,Jzazbz:UL,LCH:aL,LCHuv:EB,Lab:nL,Lab_D65:Vz,Luv:TB,OKLCH:yB,OKLab:gL,P3:uz,P3_Linear:nz,ProPhoto:vB,ProPhoto_Linear:hB,REC_2020:$R,REC_2020_Linear:XR,REC_2100_HLG:iV,REC_2100_PQ:$B,XYZ_ABS_D65:DL,XYZ_D50:ZI,XYZ_D65:GI,sRGB:lz,sRGB_Linear:az}),gV=class e{constructor(...e){let t;e.length===1&&(t=BI(e[0]));let n,r,i;t?(n=t.space||t.spaceId,r=t.coords,i=t.alpha):[n,r,i]=e,Object.defineProperty(this,`space`,{value:HI.get(n),writable:!1,enumerable:!0,configurable:!0}),this.coords=r?r.slice():[0,0,0],this.alpha=i>1||i===void 0?1:i<0?0:i;for(let e=0;e<this.coords.length;e++)this.coords[e]===`NaN`&&(this.coords[e]=NaN);for(let e in this.space.coords)Object.defineProperty(this,e,{get:()=>this.get(e),set:t=>this.set(e,t)})}get spaceId(){return this.space.id}clone(){return new e(this.space,this.coords,this.alpha)}toJSON(){return{spaceId:this.spaceId,coords:this.coords,alpha:this.alpha}}display(...t){let n=fz(this,...t);return n.color=new e(n.color),n}static get(t,...n){return t instanceof e?t:new e(t,...n)}static defineFunction(t,n,r=n){let{instance:i=!0,returns:a}=r,o=function(...t){let r=n(...t);if(a===`color`)r=e.get(r);else if(a===`function<color>`){let t=r;r=function(...n){let r=t(...n);return e.get(r)},Object.assign(r,t)}else a===`array<color>`&&(r=r.map(t=>e.get(t)));return r};t in e||(e[t]=o),i&&(e.prototype[t]=function(...e){return o(this,...e)})}static defineFunctions(t){for(let n in t)e.defineFunction(n,t[n],t[n])}static extend(exports){if(exports.register)exports.register(e);else for(let n in exports)e.defineFunction(n,exports[n])}};gV.defineFunctions({get:JI,getAll:qI,set:XI,setAll:YI,to:KR,equals:pz,inGamut:yL,toGamut:UR,distance:xL,toString:qR}),Object.assign(gV,{util:AI,hooks:MI,WHITES:PI,Space:HI,spaces:HI.registry,parse:zI,defaults:NI});for(let e of Object.keys(hV))HI.register(hV[e]);for(let e in HI.registry)_V(e,HI.registry[e]);MI.add(`colorspace-init-end`,e=>{var t,n;_V(e.id,e),(t=n=e.aliases)?.forEach(t=>{_V(t,e)})});function _V(e,t){let n=e.replace(/-/g,`_`);Object.defineProperty(gV.prototype,n,{get(){let n=this.getAll(e);return typeof Proxy>`u`?n:new Proxy(n,{has:(e,n)=>{try{return HI.resolveCoord([t,n]),!0}catch{}return Reflect.has(e,n)},get:(e,n,r)=>{if(n&&typeof n!=`symbol`&&!(n in e)){let{index:r}=HI.resolveCoord([t,n]);if(r>=0)return e[r]}return Reflect.get(e,n,r)},set:(n,r,i,a)=>{if(r&&typeof r!=`symbol`&&!(r in n)||r>=0){let{index:a}=HI.resolveCoord([t,r]);if(a>=0)return n[a]=i,this.setAll(e,n),!0}return Reflect.set(n,r,i,a)}})},set(t){this.setAll(e,t)},configurable:!0,enumerable:!0})}gV.extend(BR),gV.extend({deltaE:Xz}),Object.assign(gV,{deltaEMethods:BR}),gV.extend($z),gV.extend({contrast:Gz}),gV.extend(Yz),gV.extend(_z),gV.extend(aB),gV.extend(Wz);const{vec2:vV,vec4:yV}=xj,bV=e=>{let t=new gV(e);return yV(...t.to(`p3-linear`).coords,t.alpha).value},xV=e=>{let t=.5,n=.5;if(typeof e==`string`){let r=e.toLowerCase().trim().split(/\s+/);r.includes(`left`)?t=0:r.includes(`right`)?t=1:(r.includes(`center`)||r.length===1&&(r[0]===`top`||r[0]===`bottom`))&&(t=.5),r.includes(`top`)?n=0:r.includes(`bottom`)?n=1:(r.includes(`center`)||r.length===1&&(r[0]===`left`||r[0]===`right`))&&(n=.5),r.length===1&&r[0]===`center`&&(t=.5,n=.5)}else typeof e==`object`&&e?(t=e.x,n=e.y):console.warn(`Invalid position value provided: ${e}. Defaulting to center.`);return vV(t,1-n).value},{vec2:SV,viewportSize:CV}=xj,wV=(e=SV(0))=>{let t=CV,n=t.x.div(t.y),r=e.x.mul(n);return SV(r,e.y)},TV={name:`Circle`,props:{color:{type:String,default:`#ffffff`,transform:bV,description:`The color of the circle`},backgroundColor:{type:String,default:`transparent`,transform:bV,description:`The background color`},radius:{type:Number,default:1,description:`The radius of the circle`},softness:{type:Number,default:0,description:`Edge softness (0 = sharp, 1 = soft)`},center:{type:Object,default:{x:.5,y:.5},transform:xV}},fragmentNode:({uniforms:e})=>{let{vec2:t,vec4:n,length:r,mix:i,smoothstep:a,uv:o}=xj,s=t(e.center.uniform.x.mul(.5).add(.25),e.center.uniform.y.mul(.5).add(.25)),c=wV(o()),l=wV(s),u=r(c.sub(l)),d=e.softness.uniform,f=e.radius.uniform.mul(.25),p=a(f,f.sub(d),u);return n(i(e.backgroundColor.uniform,e.color.uniform,p),1)}};var EV=r({__name:`Circle`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},backgroundColor:{},radius:{},softness:{},center:{}},{blendMode:`normal`,opacity:1,...Object.entries(TV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${TV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(TV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(TV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(TV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,TV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),DV=EV;const OV={name:`DotGrid`,props:{color:{type:String,default:`#ffffff`,description:`Dot color`,transform:bV},density:{type:Number,default:100,description:`Grid density (number of dots)`},dotSize:{type:Number,default:.2,description:`Size of each dot (0-1)`}},fragmentNode:({uniforms:e})=>{let{viewportUV:t,vec4:n,vec3:r,vec2:i,smoothstep:a,length:o,floor:s,float:c,viewportSize:l}=xj,u=t,d=e.density.uniform,f=e.dotSize.uniform,p=e.color.uniform,m=l,h=m.x.div(m.y),g=i(u.x.mul(h),u.y),_=g.mul(d),v=_.sub(s(_)),y=o(v.sub(.5)),b=c(1).sub(a(f.mul(.45),f.mul(.5),y)),x=r(p).mul(b);return n(x,b)}};var kV=r({__name:`DotGrid`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},density:{},dotSize:{}},{blendMode:`normal`,opacity:1,...Object.entries(OV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${OV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(OV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(OV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(OV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,OV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),AV=kV;const jV={name:`FilmGrain`,props:{intensity:{type:Number,default:.25,description:`Grain intensity (0-1)`},power:{type:Number,default:.645,description:`Controls blending based on brightness`},speed:{type:Number,default:.5,description:`Animation speed of grain noise`}},fragmentNode:({uniforms:e,childNode:t})=>{let n=t||dF(0,0,0,0),r=nF(),i=e=>MM(zN(AM(e,lF(12.9898,78.233))).mul(43758.5453)),a=e=>AM(e,dF(.299,.587,.114,0)),o=i(r).add(SP.mul(e.speed.uniform)),s=MM(zN(o.mul(43758.5453))),c=PM(jM(.5),jM(.75),s).mul(e.intensity.uniform),l=IM(a(n),e.power.uniform),u=n.mul(c),d=OM(l,0,1),f=PM(u,n,d);return dF(f.x,f.y,f.z,n.w)}};var MV=r({__name:`FilmGrain`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{},power:{},speed:{}},{blendMode:`normal`,opacity:1,...Object.entries(jV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${jV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(jV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(jV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(jV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,jV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),NV=MV;const PV=new WeakMap,FV={name:`glassTiles`,props:{intensity:{type:Number,default:1,description:`The intensity of the glass tiles effect`},tileCount:{type:Number,default:100,description:`Number of tiles across the shortest dimension`}},fragmentNode:({uniforms:e,childNode:t,onCleanup:n,canvas:r})=>{let{vec2:i,vec4:a,floor:o,mul:s,div:c,sub:l,add:u,convertToTexture:d,uv:f,uniform:p}=xj;if(!t)return console.error(`You must pass a child component into the Glass Tiles shader.`),a(0);let m=d(t),h=p(1),g=()=>{r&&(h.value=r.clientWidth/r.clientHeight)};g();let _=PV.get(r);_||(_=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect,i=window.devicePixelRatio||1;m.setSize(n*i,r*i),g()}),_.observe(r),PV.set(r,_)),n(()=>{let e=PV.get(r);e&&(e.disconnect(),PV.delete(r))});let v=f(),y=e.intensity.uniform,b=e.tileCount.uniform,x=i(h.greaterThanEqual(1).select(s(b,h),b),h.lessThan(1).select(c(b,h),b)),S=c(o(s(v,x)),x),ee=l(v,S),te=i(.5,.5),ne=s(y,.025),re=c(ee,c(i(1),x)),ie=l(re,te),ae=s(ie,ne),oe=u(ee,ae),se=u(oe,S);return a(m.sample(se))}};var IV=r({__name:`GlassTiles`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{},tileCount:{}},{blendMode:`normal`,opacity:1,...Object.entries(FV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${FV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(FV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(FV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(FV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,FV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),LV=IV;const RV={VERTEX:`vertex`,FRAGMENT:`fragment`},zV={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},BV=[`fragment`,`vertex`],doe=[...BV,`compute`],VV=[`x`,`y`,`z`,`w`],HV=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`);let UV=1234567;const WV=Math.PI/180,GV=180/Math.PI;function KV(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=HV[e&255]+HV[e>>8&255]+HV[e>>16&255]+HV[e>>24&255]+`-`+HV[t&255]+HV[t>>8&255]+`-`+HV[t>>16&15|64]+HV[t>>24&255]+`-`+HV[n&63|128]+HV[n>>8&255]+`-`+HV[n>>16&255]+HV[n>>24&255]+HV[r&255]+HV[r>>8&255]+HV[r>>16&255]+HV[r>>24&255];return i.toLowerCase()}function qV(e,t,n){return Math.max(t,Math.min(n,e))}function JV(e,t){return(e%t+t)%t}function YV(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function XV(e,t,n){return e===t?0:(n-e)/(t-e)}function ZV(e,t,n){return(1-n)*e+n*t}function QV(e,t,n,r){return ZV(e,t,1-Math.exp(-n*r))}function $V(e,t=1){return t-Math.abs(JV(e,t*2)-t)}function eH(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function tH(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function nH(e,t){return e+Math.floor(Math.random()*(t-e+1))}function rH(e,t){return e+Math.random()*(t-e)}function iH(e){return e*(.5-Math.random())}function aH(e){e!==void 0&&(UV=e);let t=UV+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function oH(e){return e*WV}function sH(e){return e*GV}function cH(e){return(e&e-1)==0&&e!==0}function lH(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function uH(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function dH(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function fH(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function pH(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const mH={DEG2RAD:WV,RAD2DEG:GV,generateUUID:KV,clamp:qV,euclideanModulo:JV,mapLinear:YV,inverseLerp:XV,lerp:ZV,damp:QV,pingpong:$V,smoothstep:eH,smootherstep:tH,randInt:nH,randFloat:rH,randFloatSpread:iH,seededRandom:aH,degToRad:oH,radToDeg:sH,isPowerOfTwo:cH,ceilPowerOfTwo:lH,floorPowerOfTwo:uH,setQuaternionFromProperEuler:dH,normalize:pH,denormalize:fH},hH=0,gH=1015,_H=``,vH=`srgb`,yH=`srgb-linear`,bH=`linear`,xH=`srgb`,SH=35044,CH=2e3,wH=2001;var TH=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(EH.makeScale(e,t)),this}rotate(e){return this.premultiply(EH.makeRotation(-e)),this}translate(e,t){return this.premultiply(EH.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const EH=new TH,DH={};function OH(e){e in DH||(DH[e]=!0,console.warn(e))}const kH=new TH().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),AH=new TH().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function jH(){let e={enabled:!0,workingColorSpace:yH,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===xH&&(e.r=NH(e.r),e.g=NH(e.g),e.b=NH(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===xH&&(e.r=PH(e.r),e.g=PH(e.g),e.b=PH(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===_H?bH:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return OH(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return OH(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[yH]:{primaries:t,whitePoint:r,transfer:bH,toXYZ:kH,fromXYZ:AH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:vH},outputColorSpaceConfig:{drawingBufferColorSpace:vH}},[vH]:{primaries:t,whitePoint:r,transfer:xH,toXYZ:kH,fromXYZ:AH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:vH}}}),e}const MH=jH();function NH(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function PH(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}const FH={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},IH={h:0,s:0,l:0},LH={h:0,s:0,l:0};function RH(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var zH=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=vH){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,MH.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=MH.workingColorSpace){return this.r=e,this.g=t,this.b=n,MH.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=MH.workingColorSpace){if(e=JV(e,1),t=qV(t,0,1),n=qV(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=RH(i,r,e+1/3),this.g=RH(i,r,e),this.b=RH(i,r,e-1/3)}return MH.colorSpaceToWorking(this,r),this}setStyle(e,t=vH){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=vH){let n=FH[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=NH(e.r),this.g=NH(e.g),this.b=NH(e.b),this}copyLinearToSRGB(e){return this.r=PH(e.r),this.g=PH(e.g),this.b=PH(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=vH){return MH.workingToColorSpace(BH.copy(this),e),Math.round(qV(BH.r*255,0,255))*65536+Math.round(qV(BH.g*255,0,255))*256+Math.round(qV(BH.b*255,0,255))}getHexString(e=vH){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=MH.workingColorSpace){MH.workingToColorSpace(BH.copy(this),t);let n=BH.r,r=BH.g,i=BH.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=MH.workingColorSpace){return MH.workingToColorSpace(BH.copy(this),t),e.r=BH.r,e.g=BH.g,e.b=BH.b,e}getStyle(e=vH){MH.workingToColorSpace(BH.copy(this),e);let t=BH.r,n=BH.g,r=BH.b;return e===vH?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(IH),this.setHSL(IH.h+e,IH.s+t,IH.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(IH),e.getHSL(LH);let n=ZV(IH.h,LH.h,t),r=ZV(IH.s,LH.s,t),i=ZV(IH.l,LH.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const BH=new zH;zH.NAMES=FH;var VH=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}},HH=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(qV(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},UH=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(GH.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(GH.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=qV(this.x,e.x,t.x),this.y=qV(this.y,e.y,t.y),this.z=qV(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=qV(this.x,e,t),this.y=qV(this.y,e,t),this.z=qV(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return WH.copy(this).projectOnVector(e),this.sub(WH)}reflect(e){return this.sub(WH.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(qV(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const WH=new UH,GH=new HH;var KH=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/qH.setFromMatrixColumn(e,0).length(),i=1/qH.setFromMatrixColumn(e,1).length(),a=1/qH.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(YH,e,XH)}lookAt(e,t,n){let r=this.elements;return $H.subVectors(e,t),$H.lengthSq()===0&&($H.z=1),$H.normalize(),ZH.crossVectors(n,$H),ZH.lengthSq()===0&&(Math.abs(n.z)===1?$H.x+=1e-4:$H.z+=1e-4,$H.normalize(),ZH.crossVectors(n,$H)),ZH.normalize(),QH.crossVectors($H,ZH),r[0]=ZH.x,r[4]=QH.x,r[8]=$H.x,r[1]=ZH.y,r[5]=QH.y,r[9]=$H.y,r[2]=ZH.z,r[6]=QH.z,r[10]=$H.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=qH.set(r[0],r[1],r[2]).length(),a=qH.set(r[4],r[5],r[6]).length(),o=qH.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],JH.copy(this);let c=1/i,l=1/a,u=1/o;return JH.elements[0]*=c,JH.elements[1]*=c,JH.elements[2]*=c,JH.elements[4]*=l,JH.elements[5]*=l,JH.elements[6]*=l,JH.elements[8]*=u,JH.elements[9]*=u,JH.elements[10]*=u,t.setFromRotationMatrix(JH),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=CH){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===CH)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===wH)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=CH){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===CH)p=(a+i)*u,m=-2*u;else if(o===wH)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const qH=new UH,JH=new KH,YH=new UH(0,0,0),XH=new UH(1,1,1),ZH=new UH,QH=new UH,$H=new UH;var eU=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=qV(this.x,e.x,t.x),this.y=qV(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=qV(this.x,e,t),this.y=qV(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(qV(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},tU=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=qV(this.x,e.x,t.x),this.y=qV(this.y,e.y,t.y),this.z=qV(this.z,e.z,t.z),this.w=qV(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=qV(this.x,e,t),this.y=qV(this.y,e,t),this.z=qV(this.z,e,t),this.w=qV(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};function nU(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}const rU=(...e)=>nU(e);function iU(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of aU(e))n.push(nU(r.slice(0,-4)),i.getCacheKey(t));return nU(n)}function*aU(e,t=!1){for(let n in e){if(n.startsWith(`_`)===!0)continue;let r=e[n];if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)yield{property:n,childNode:r};else if(typeof r==`object`)for(let e in r){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}}}function oU(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function sU(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new zH(...t):n===`vec2`?new eU(...t):n===`vec3`?new UH(...t):n===`vec4`?new tU(...t):n===`mat2`?new VH(...t):n===`mat3`?new TH(...t):n===`mat4`?new KH(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?lU(t[0]):null}function cU(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function lU(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var uU=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const dU={analyze:`setup`,generate:`analyze`};let fU=0;var pU=class extends uU{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=zV.NONE,this.updateBeforeType=zV.NONE,this.updateAfterType=zV.NONE,this.uuid=mH.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:fU++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,zV.FRAME)}onRenderUpdate(e){return this.onUpdate(e,zV.RENDER)}onObjectUpdate(e){return this.onUpdate(e,zV.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of aU(this))yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e||=this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=rU(iU(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e),n=e.getElementType(t);return n}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t);return n||this}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn(`Abstract function.`)}updateAfter(){console.warn(`Abstract function.`)}update(){console.warn(`Abstract function.`)}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=dU[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){let n=this.generate.length===1;if(n){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(console.warn(`THREE.Node: Recursion detected.`,this),a=``):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return aU(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n]){let a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}},mU=pU,hU=class extends mU{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){let n=e.getBuildStage();if(n===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},gU=hU,_U=class extends mU{static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){let t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`);return`${n}[ ${r} ]`}},vU=_U,yU=class extends mU{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},bU=yU,xU=class extends gU{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;s+c>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i);let u=e.getComponentType(i);u!==a&&(l=e.format(l,u,a)),o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}},SU=xU;const CU=VV.join(``);var wU=class extends mU{static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(VV.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null,o=this.getVectorLength();o>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let s=n.build(e,a);i=this.components.length===r&&this.components===CU.slice(0,this.components.length)?e.format(s,a,t):e.format(`${s}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},TU=wU,EU=class extends gU{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=VV[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},DU=EU,OU=class extends gU{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=VV[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},kU=OU,AU=class extends mU{static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?oU(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=oU(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=cU(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?sU(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn(`Abstract function.`)}},jU=AU;const MU=/float|u?int/;var NU=class extends jU{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return MU.test(n)&&MU.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},PU=NU,FU=class extends mU{static get type(){return`MemberNode`}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){let t=this.node.build(e);return t+`.`+this.property}},IU=FU;let LU=null;const RU=new Map;function R(e,t){if(RU.has(e)){console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);RU.set(e,t)}const zU=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),BU=e=>zU(e).split(``).sort().join(``),VU={setup(e,t){let n=t.shift();return e(fW(n),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(LU.assign(n,...e),n);if(RU.has(t)){let r=RU.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}else if(t===`self`)return e;else if(t.endsWith(`Assign`)&&RU.has(t.slice(0,t.length-6))){let r=RU.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}else if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=zU(t),dW(new TU(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=BU(t.slice(3).toLowerCase()),n=>dW(new DU(e,t,dW(n)));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=BU(t.slice(4).toLowerCase()),()=>dW(new kU(dW(e),t));else if(t===`width`||t===`height`||t===`depth`)return t===`width`?t=`x`:t===`height`?t=`y`:t===`depth`&&(t=`z`),dW(new TU(e,t));else if(/^\d+$/.test(t)===!0)return dW(new vU(n,new PU(Number(t),`uint`)));else if(/^get$/.test(t)===!0)return e=>dW(new IU(n,e))}return Reflect.get(e,t,n)},set(e,t,n,r){return typeof t==`string`&&e[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t===`width`||t===`height`||t===`depth`||/^\d+$/.test(t)===!0)?(r[t].assign(n),!0):Reflect.set(e,t,n,r)}},HU=new WeakMap,UU=new WeakMap,WU=function(e,t=null){let n=oU(e);if(n===`node`){let t=HU.get(e);return t===void 0&&(t=new Proxy(e,VU),HU.set(e,t),HU.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return dW(oW(e,t));else if(n===`shader`)return hW(e);return e},GU=function(e,t=null){for(let n in e)e[n]=dW(e[n],t);return e},KU=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=dW(e[r],t);return e},qU=function(e,t=null,n=null,r=null){let i=e=>dW(r===null?e:Object.assign(e,r)),a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(console.error(`THREE.TSL: "${n}" parameter length is less than minimum required.`),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(console.error(`THREE.TSL: "${n}" parameter length exceeds limit.`),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...pW(l(t)))):n===null?a=(...n)=>i(new e(t,...pW(l(n)))):(n=dW(n),a=(...r)=>i(new e(t,...pW(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a};var JU=class extends mU{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace(`once`):`once`;if(r[i])return r[i];let a=null;if(t.layout){let r=UU.get(e.constructor);r===void 0&&(r=new WeakMap,UU.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=dW(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i),a=dW(i.call(n))}else{let r=t.jsFunc,i=n!==null||r.length>1?r(n||[],e):r(e);a=dW(i)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(r===`setup`){let t=e.getNamespace(`initialized`);i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return n}},YU=class extends mU{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return fW(e),dW(new JU(this,e))}setup(){return this.call()}};const XU=[!1,!0],ZU=[0,1,2,3],QU=[-1,-2],$U=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],eW=new Map;for(let e of XU)eW.set(e,new PU(e));const tW=new Map;for(let e of ZU)tW.set(e,new PU(e,`uint`));const nW=new Map([...tW].map(e=>new PU(e.value,`int`)));for(let e of QU)nW.set(e,new PU(e,`int`));const rW=new Map([...nW].map(e=>new PU(e.value)));for(let e of $U)rW.set(e,new PU(e));for(let e of $U)rW.set(-e,new PU(-e));const iW={bool:eW,uint:tW,ints:nW,float:rW},aW=new Map([...eW,...rW]),oW=(e,t)=>aW.has(e)?aW.get(e):e.isNode===!0?e:new PU(e,t),sW=e=>{try{return e.getNodeType()}catch{return}},cW=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[sU(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return dW(t.get(n[0]));if(n.length===1){let t=oW(n[0],e);return sW(t)===e?dW(t):dW(new bU(t,e))}let r=n.map(e=>oW(e));return dW(new SU(r,e))}},lW=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function uW(e,t){return new Proxy(new YU(e,t),VU)}const dW=(e,t=null)=>WU(e,t),fW=(e,t=null)=>new GU(e,t),pW=(e,t=null)=>new KU(e,t),z=(...e)=>new qU(...e);let mW=0;const hW=(e,t=null)=>{let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:console.error(`THREE.TSL: Invalid layout type.`),t=null));let r=new uW(e,n),i=(...e)=>{let t;fW(e);let i=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype);t=i?[...e]:e[0];let a=r.call(t);return n===`void`&&a.toStack(),a};if(i.shaderNode=r,i.id=r.id,i.getNodeType=(...e)=>r.getNodeType(...e),i.getCacheKey=(...e)=>r.getCacheKey(...e),i.setLayout=e=>(r.setLayout(e),i),i.once=(e=null)=>(r.once=!0,r.namespace=e,i),t!==null){if(typeof t.inputs!=`object`){let e={name:`fn`+ mW++,type:n,inputs:[]};for(let n in t){if(n===`return`)continue;e.inputs.push({name:n,type:t[n]})}t=e}i.setLayout(t)}return i};function gW(e){return LU&&LU.add(e),e}R(`toStack`,gW);const _W=new cW(`color`),vW=new cW(`float`,iW.float),yW=new cW(`int`,iW.ints),bW=new cW(`uint`,iW.uint),xW=new cW(`bool`,iW.bool),SW=new cW(`vec2`),CW=new cW(`ivec2`),wW=new cW(`uvec2`),TW=new cW(`bvec2`),EW=new cW(`vec3`),DW=new cW(`ivec3`),OW=new cW(`uvec3`),kW=new cW(`bvec3`),AW=new cW(`vec4`),jW=new cW(`ivec4`),MW=new cW(`uvec4`),NW=new cW(`bvec4`),PW=new cW(`mat2`),FW=new cW(`mat3`),IW=new cW(`mat4`);R(`toColor`,_W),R(`toFloat`,vW),R(`toInt`,yW),R(`toUint`,bW),R(`toBool`,xW),R(`toVec2`,SW),R(`toIVec2`,CW),R(`toUVec2`,wW),R(`toBVec2`,TW),R(`toVec3`,EW),R(`toIVec3`,DW),R(`toUVec3`,OW),R(`toBVec3`,kW),R(`toVec4`,AW),R(`toIVec4`,jW),R(`toUVec4`,MW),R(`toBVec4`,NW),R(`toMat2`,PW),R(`toMat3`,FW),R(`toMat4`,IW);const LW=z(vU).setParameterLength(2),RW=(e,t)=>dW(new bU(dW(e),t));R(`element`,LW),R(`convert`,RW),R(`append`,e=>(console.warn(`THREE.TSL: .append() has been renamed to .toStack().`),gW(e)));const zW={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var BW=class e extends gU{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(zW[this.op],t)}getNodeType(e){let t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i===`void`||a===`void`)return`void`;if(t===`%`)return i;if(t===`~`||t===`&`||t===`|`||t===`^`||t===`>>`||t===`<<`)return e.getIntegerType(i);if(t===`!`||t===`&&`||t===`||`||t===`^^`)return`bool`;if(t===`==`||t===`!=`||t===`<`||t===`>`||t===`<=`||t===`>=`){let t=Math.max(e.getTypeLength(i),e.getTypeLength(a));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(i)){if(a===`float`)return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i===`float`)return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===CH;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const VW=z(BW,`+`).setParameterLength(2,1/0).setName(`add`),HW=z(BW,`-`).setParameterLength(2,1/0).setName(`sub`),UW=z(BW,`*`).setParameterLength(2,1/0).setName(`mul`),WW=z(BW,`/`).setParameterLength(2,1/0).setName(`div`),GW=z(BW,`%`).setParameterLength(2).setName(`mod`),KW=z(BW,`==`).setParameterLength(2).setName(`equal`),qW=z(BW,`!=`).setParameterLength(2).setName(`notEqual`),JW=z(BW,`<`).setParameterLength(2).setName(`lessThan`),YW=z(BW,`>`).setParameterLength(2).setName(`greaterThan`),XW=z(BW,`<=`).setParameterLength(2).setName(`lessThanEqual`),ZW=z(BW,`>=`).setParameterLength(2).setName(`greaterThanEqual`),QW=z(BW,`&&`).setParameterLength(2,1/0).setName(`and`),$W=z(BW,`||`).setParameterLength(2,1/0).setName(`or`),eG=z(BW,`!`).setParameterLength(1).setName(`not`),tG=z(BW,`^^`).setParameterLength(2).setName(`xor`),nG=z(BW,`&`).setParameterLength(2).setName(`bitAnd`),rG=z(BW,`~`).setParameterLength(2).setName(`bitNot`),iG=z(BW,`|`).setParameterLength(2).setName(`bitOr`),aG=z(BW,`^`).setParameterLength(2).setName(`bitXor`),oG=z(BW,`<<`).setParameterLength(2).setName(`shiftLeft`),sG=z(BW,`>>`).setParameterLength(2).setName(`shiftRight`),cG=hW(([e])=>(e.addAssign(1),e)),lG=hW(([e])=>(e.subAssign(1),e)),uG=hW(([e])=>{let t=yW(e).toConst();return e.addAssign(1),t}),dG=hW(([e])=>{let t=yW(e).toConst();return e.subAssign(1),t});R(`add`,VW),R(`sub`,HW),R(`mul`,UW),R(`div`,WW),R(`mod`,GW),R(`equal`,KW),R(`notEqual`,qW),R(`lessThan`,JW),R(`greaterThan`,YW),R(`lessThanEqual`,XW),R(`greaterThanEqual`,ZW),R(`and`,QW),R(`or`,$W),R(`not`,eG),R(`xor`,tG),R(`bitAnd`,nG),R(`bitNot`,rG),R(`bitOr`,iG),R(`bitXor`,aG),R(`shiftLeft`,oG),R(`shiftRight`,sG),R(`incrementBefore`,cG),R(`decrementBefore`,lG),R(`increment`,uG),R(`decrement`,dG);const fG=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),GW(e,t)),pG=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),GW(yW(e),yW(t)));R(`remainder`,fG),R(`modInt`,pG);var B=class e extends gU{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=HW(1,n);else if(i===e.RECIPROCAL)a=WW(1,n);else if(i===e.DIFFERENCE)a=FG(HW(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=AW(EW(i),0):e=AW(EW(e),0);let o=UW(e,i).xyz;a=DG(o)}return a===null?super.setup(t):a}generate(t,n){let r=t.getNodeProperties(this);if(r.outputNode)return super.generate(t,n);let i=this.method,a=this.getNodeType(t),o=this.getInputType(t),s=this.aNode,c=this.bNode,l=this.cNode,u=t.renderer.coordinateSystem;if(i===e.NEGATE)return t.format(`( - `+s.build(t,o)+` )`,a,n);{let r=[];return i===e.CROSS?r.push(s.build(t,a),c.build(t,a)):u===CH&&i===e.STEP?r.push(s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:o),c.build(t,o)):u===CH&&(i===e.MIN||i===e.MAX)?r.push(s.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:o)):i===e.REFRACT?r.push(s.build(t,o),c.build(t,o),l.build(t,`float`)):i===e.MIX?r.push(s.build(t,o),c.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?`float`:o)):(u===wH&&i===e.ATAN&&c!==null&&(i=`atan2`),t.shaderStage!==`fragment`&&(i===e.DFDX||i===e.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i=`/*`+i+`*/`),r.push(s.build(t,o)),c!==null&&r.push(c.build(t,o)),l!==null&&r.push(l.build(t,o))),t.format(`${t.getMethod(i,a)}( ${r.join(`, `)} )`,a,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};B.ALL=`all`,B.ANY=`any`,B.RADIANS=`radians`,B.DEGREES=`degrees`,B.EXP=`exp`,B.EXP2=`exp2`,B.LOG=`log`,B.LOG2=`log2`,B.SQRT=`sqrt`,B.INVERSE_SQRT=`inversesqrt`,B.FLOOR=`floor`,B.CEIL=`ceil`,B.NORMALIZE=`normalize`,B.FRACT=`fract`,B.SIN=`sin`,B.COS=`cos`,B.TAN=`tan`,B.ASIN=`asin`,B.ACOS=`acos`,B.ATAN=`atan`,B.ABS=`abs`,B.SIGN=`sign`,B.LENGTH=`length`,B.NEGATE=`negate`,B.ONE_MINUS=`oneMinus`,B.DFDX=`dFdx`,B.DFDY=`dFdy`,B.ROUND=`round`,B.RECIPROCAL=`reciprocal`,B.TRUNC=`trunc`,B.FWIDTH=`fwidth`,B.TRANSPOSE=`transpose`,B.BITCAST=`bitcast`,B.EQUALS=`equals`,B.MIN=`min`,B.MAX=`max`,B.STEP=`step`,B.REFLECT=`reflect`,B.DISTANCE=`distance`,B.DIFFERENCE=`difference`,B.DOT=`dot`,B.CROSS=`cross`,B.POW=`pow`,B.TRANSFORM_DIRECTION=`transformDirection`,B.MIX=`mix`,B.CLAMP=`clamp`,B.REFRACT=`refract`,B.SMOOTHSTEP=`smoothstep`,B.FACEFORWARD=`faceforward`;const mG=vW(Math.PI),foe=vW(Math.PI*2),hG=z(B,B.ALL).setParameterLength(1),gG=z(B,B.ANY).setParameterLength(1),_G=z(B,B.RADIANS).setParameterLength(1),vG=z(B,B.DEGREES).setParameterLength(1),yG=z(B,B.EXP).setParameterLength(1),bG=z(B,B.EXP2).setParameterLength(1),xG=z(B,B.LOG).setParameterLength(1),SG=z(B,B.LOG2).setParameterLength(1),CG=z(B,B.SQRT).setParameterLength(1),wG=z(B,B.INVERSE_SQRT).setParameterLength(1),TG=z(B,B.FLOOR).setParameterLength(1),EG=z(B,B.CEIL).setParameterLength(1),DG=z(B,B.NORMALIZE).setParameterLength(1),OG=z(B,B.FRACT).setParameterLength(1),kG=z(B,B.SIN).setParameterLength(1),AG=z(B,B.COS).setParameterLength(1),jG=z(B,B.TAN).setParameterLength(1),MG=z(B,B.ASIN).setParameterLength(1),NG=z(B,B.ACOS).setParameterLength(1),PG=z(B,B.ATAN).setParameterLength(1,2),FG=z(B,B.ABS).setParameterLength(1),IG=z(B,B.SIGN).setParameterLength(1),LG=z(B,B.LENGTH).setParameterLength(1),RG=z(B,B.NEGATE).setParameterLength(1),zG=z(B,B.ONE_MINUS).setParameterLength(1),BG=z(B,B.DFDX).setParameterLength(1),VG=z(B,B.DFDY).setParameterLength(1),HG=z(B,B.ROUND).setParameterLength(1),UG=z(B,B.RECIPROCAL).setParameterLength(1),WG=z(B,B.TRUNC).setParameterLength(1),GG=z(B,B.FWIDTH).setParameterLength(1),KG=z(B,B.TRANSPOSE).setParameterLength(1),qG=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),KW(e,t)),JG=z(B,B.MIN).setParameterLength(2,1/0),YG=z(B,B.MAX).setParameterLength(2,1/0),XG=z(B,B.STEP).setParameterLength(2),ZG=z(B,B.REFLECT).setParameterLength(2),QG=z(B,B.DISTANCE).setParameterLength(2),$G=z(B,B.DIFFERENCE).setParameterLength(2),eK=z(B,B.DOT).setParameterLength(2),tK=z(B,B.CROSS).setParameterLength(2),nK=z(B,B.POW).setParameterLength(2),rK=z(B,B.POW,2).setParameterLength(1),iK=z(B,B.POW,3).setParameterLength(1),aK=z(B,B.POW,4).setParameterLength(1),oK=z(B,B.TRANSFORM_DIRECTION).setParameterLength(2),sK=e=>UW(IG(e),nK(FG(e),1/3)),cK=e=>eK(e,e),lK=z(B,B.MIX).setParameterLength(3),uK=(e,t=0,n=1)=>dW(new B(B.CLAMP,dW(e),dW(t),dW(n))),dK=e=>uK(e),fK=z(B,B.REFRACT).setParameterLength(3),pK=z(B,B.SMOOTHSTEP).setParameterLength(3),mK=z(B,B.FACEFORWARD).setParameterLength(3),hK=hW(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=eK(e.xy,SW(t,n)),a=GW(i,mG);return OG(kG(a).mul(r))}),gK=(e,t,n)=>lK(t,n,e),_K=(e,t,n)=>pK(t,n,e),vK=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),PG(e,t));R(`all`,hG),R(`any`,gG),R(`equals`,qG),R(`radians`,_G),R(`degrees`,vG),R(`exp`,yG),R(`exp2`,bG),R(`log`,xG),R(`log2`,SG),R(`sqrt`,CG),R(`inverseSqrt`,wG),R(`floor`,TG),R(`ceil`,EG),R(`normalize`,DG),R(`fract`,OG),R(`sin`,kG),R(`cos`,AG),R(`tan`,jG),R(`asin`,MG),R(`acos`,NG),R(`atan`,PG),R(`abs`,FG),R(`sign`,IG),R(`length`,LG),R(`lengthSq`,cK),R(`negate`,RG),R(`oneMinus`,zG),R(`dFdx`,BG),R(`dFdy`,VG),R(`round`,HG),R(`reciprocal`,UG),R(`trunc`,WG),R(`fwidth`,GG),R(`atan2`,vK),R(`min`,JG),R(`max`,YG),R(`step`,XG),R(`reflect`,ZG),R(`distance`,QG),R(`dot`,eK),R(`cross`,tK),R(`pow`,nK),R(`pow2`,rK),R(`pow3`,iK),R(`pow4`,aK),R(`transformDirection`,oK),R(`mix`,gK),R(`clamp`,uK),R(`refract`,fK),R(`smoothstep`,_K),R(`faceForward`,mK),R(`difference`,$G),R(`saturate`,dK),R(`cbrt`,sK),R(`transpose`,KG),R(`rand`,hK);var yK=class extends gU{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}};const bK=(...e)=>{let t;if(e.length===1){let n=e[0];t=new yK(null,n.length,n)}else{let n=e[0],r=e[1];t=new yK(n,r)}return dW(t)};R(`toArray`,(e,t)=>bK(Array(t).fill(e)));var xK=class extends mU{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}};const SK=e=>new xK(e),CK=(e,t=0)=>new xK(e,!0,t),wK=CK(`render`),TK=SK(`object`);var EK=class extends jU{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=TK}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){let n=this.getSelf();return e=e.bind(n),super.onUpdate(t=>{let r=e(t,n);r!==void 0&&(this.value=r)},t)}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),s=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(s,n,t)}};const DK=(e,t)=>{let n=lW(t||e),r=e&&e.isNode===!0?e.node&&e.node.value||e.value:e;return dW(new EK(r,n))};var OK=class extends mU{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}};const kK=(e,t)=>dW(new OK(e,t));var AK=class extends gU{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e)),r=VV.join(``).slice(0,n)!==t.components;return r}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),o=n.build(e),s=r.build(e,a),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=o);else if(i){let r=e.getVarFromNode(this,null,a),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}),d=l.build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${d}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=o)}else u=`${o} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=o));return l.initialized=!0,e.format(u,a,t)}};const jK=z(AK).setParameterLength(2);R(`assign`,jK);var MK=class extends gU{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)console.error(`THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(console.error(`THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(vW(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(console.error(`THREE.TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(vW(0),e))):t.push(a(n,e))}let o=n.build(e,`property`);return`${o}( ${t.join(`, `)} )`}};const NK=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?pW(t):fW(t[0]),dW(new MK(dW(e),t)));R(`call`,NK);var PK=class extends mU{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?kK(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
396
+ var<${n}> ${e} : ${a};`}},cj=class{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture===null?e.depth&&e.stencil?t=L.Depth24PlusStencil8:e.depth&&(t=L.Depth24Plus):t=this.getTextureFormatGPU(e.depthTexture),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let e=this.backend.renderer,n=e.getRenderTarget();t=n?n.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t||=1;let n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0,r=n?1:t;return{samples:t,primarySamples:r,isMSAA:n}}getCurrentColorFormat(e){let t;return t=e.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(e.textures[0]),t}getCurrentColorSpace(e){return e.textures===null?this.backend.renderer.outputColorSpace:e.textures[0].colorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return fA.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return fA.LineList;if(e.isLine)return fA.LineStrip;if(e.isMesh)return fA.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=2**Math.floor(Math.log2(e)),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures===null?this.getSampleCount(this.backend.renderer.samples):this.getSampleCount(e.sampleCount)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===st)return L.BGRA8Unorm;if(e===mt)return L.RGBA16Float;throw Error(`Unsupported outputType`)}};const lj=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]),uj=new Map([[ja,[`float16`]]]),dj=new Map([[Int32Array,`sint32`],[Int16Array,`sint32`],[Uint32Array,`uint32`],[Uint16Array,`uint32`],[Float32Array,`float32`]]);var fj=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this._getBufferAttribute(e),r=this.backend,i=r.get(n),a=i.buffer;if(a===void 0){let o=r.device,s=n.array;if(e.normalized===!1){if(s.constructor===Int16Array||s.constructor===Int8Array)s=new Int32Array(s);else if((s.constructor===Uint16Array||s.constructor===Uint8Array)&&(s=new Uint32Array(s),t&GPUBufferUsage.INDEX))for(let e=0;e<s.length;e++)s[e]===65535&&(s[e]=4294967295)}if(n.array=s,(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3){s=new s.constructor(n.count*4);for(let e=0;e<n.count;e++)s.set(n.array.subarray(e*3,e*3+3),e*4);n.itemSize=4,n.array=s,i._force3to4BytesAlignment=!0}let c=s.byteLength,l=c+(4-c%4)%4;a=o.createBuffer({label:n.name,size:l,usage:t,mappedAtCreation:!0}),new s.constructor(a.getMappedRange()).set(s),a.unmap(),i.buffer=a}}updateAttribute(e){let t=this._getBufferAttribute(e),n=this.backend,r=n.device,i=n.get(t),a=n.get(t).buffer,o=t.array;if(i._force3to4BytesAlignment===!0){o=new o.constructor(t.count*4);for(let e=0;e<t.count;e++)o.set(t.array.subarray(e*3,e*3+3),e*4);t.array=o}let s=this._isTypedArray(o),c=t.updateRanges;if(c.length===0)r.queue.writeBuffer(a,0,o,0);else{let e=s?1:o.BYTES_PER_ELEMENT;for(let t=0,n=c.length;t<n;t++){let n=c[t],l,u;if(i._force3to4BytesAlignment===!0){let t=Math.floor(n.start/3),r=Math.ceil(n.count/3);l=t*4*e,u=r*4*e}else l=n.start*e,u=n.count*e;let d=l*(s?o.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(a,d,o,l,u)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){let t=e.getAttributes(),n=new Map;for(let e=0;e<t.length;e++){let r=t[e],i=r.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(r),o=n.get(a);if(o===void 0){let e,t;r.isInterleavedBufferAttribute===!0?(e=r.data.stride*i,t=r.data.isInstancedInterleavedBuffer?MA.Instance:MA.Vertex):(e=r.itemSize*i,t=r.isInstancedBufferAttribute?MA.Instance:MA.Vertex),r.normalized===!1&&(r.array.constructor===Int16Array||r.array.constructor===Uint16Array)&&(e=4),o={arrayStride:e,attributes:[],stepMode:t},n.set(a,o)}let s=this._getVertexFormat(r),c=r.isInterleavedBufferAttribute===!0?r.offset*i:0;o.attributes.push({shaderLocation:e,offset:c,format:s})}return Array.from(n.values())}destroyAttribute(e){let t=this.backend,n=t.get(this._getBufferAttribute(e));n.buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){let t=this.backend,n=t.device,r=t.get(this._getBufferAttribute(e)),i=r.buffer,a=i.size,o=n.createBuffer({label:`${e.name}_readback`,size:a,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),s=n.createCommandEncoder({label:`readback_encoder_${e.name}`});s.copyBufferToBuffer(i,0,o,0,a);let c=s.finish();n.queue.submit([c]),await o.mapAsync(GPUMapMode.READ);let l=o.getMappedRange(),u=new e.array.constructor(l.slice(0));return o.unmap(),u.buffer}_getVertexFormat(e){let{itemSize:t,normalized:n}=e,r=e.array.constructor,i=e.constructor,a;if(t===1)a=dj.get(r);else{let e=uj.get(i)||lj.get(r),o=e[n?1:0];if(o){let e=r.BYTES_PER_ELEMENT*t,n=Math.floor((e+3)/4)*4,i=n/r.BYTES_PER_ELEMENT;if(i%1)throw Error(`THREE.WebGPUAttributeUtils: Bad vertex format item size.`);a=`${o}x${i}`}}return a||console.error(`THREE.WebGPUAttributeUtils: Vertex format not supported yet.`),a}_isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},pj=class{constructor(e){this.backend=e,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(e){let t=this.backend,n=t.device,r=[],i=0;for(let n of e.bindings){let e={binding:i++,visibility:n.visibility};if(n.isUniformBuffer||n.isStorageBuffer){let t={};n.isStorageBuffer&&(n.visibility&4&&(n.access===vc.READ_WRITE||n.access===vc.WRITE_ONLY)?t.type=TA.Storage:t.type=TA.ReadOnlyStorage),e.buffer=t}else if(n.isSampler){let r={};n.texture.isDepthTexture&&(n.texture.compareFunction===null?t.compatibilityMode&&(r.type=DA.NonFiltering):r.type=DA.Comparison),e.sampler=r}else if(n.isSampledTexture&&n.texture.isVideoTexture)e.externalTexture={};else if(n.isSampledTexture&&n.store){let t={};t.format=this.backend.get(n.texture).texture.format;let r=n.access;r===vc.READ_WRITE?t.access=EA.ReadWrite:r===vc.WRITE_ONLY?t.access=EA.WriteOnly:t.access=EA.ReadOnly,e.storageTexture=t}else if(n.isSampledTexture){let r={},{primarySamples:i}=t.utils.getTextureSampleData(n.texture);if(i>1&&(r.multisampled=!0,n.texture.isDepthTexture||(r.sampleType=OA.UnfilterableFloat)),n.texture.isDepthTexture)t.compatibilityMode&&n.texture.compareFunction===null?r.sampleType=OA.UnfilterableFloat:r.sampleType=OA.Depth;else if(n.texture.isDataTexture||n.texture.isDataArrayTexture||n.texture.isData3DTexture){let e=n.texture.type;e===dt?r.sampleType=OA.SInt:e===ft?r.sampleType=OA.UInt:e===pt&&(this.backend.hasFeature(`float32-filterable`)?r.sampleType=OA.Float:r.sampleType=OA.UnfilterableFloat)}n.isSampledCubeTexture?r.viewDimension=AA.Cube:n.texture.isArrayTexture||n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?r.viewDimension=AA.TwoDArray:n.isSampledTexture3D&&(r.viewDimension=AA.ThreeD),e.texture=r}else console.error(`WebGPUBindingUtils: Unsupported binding "${n}".`);r.push(e)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){let{backend:i,bindGroupLayoutCache:a}=this,o=i.get(e),s=a.get(e.bindingsReference);s===void 0&&(s=this.createBindingsLayout(e),a.set(e.bindingsReference,s));let c;n>0&&(o.groups===void 0&&(o.groups=[],o.versions=[]),o.versions[n]===r&&(c=o.groups[n])),c===void 0&&(c=this.createBindGroup(e,s),n>0&&(o.groups[n]=c,o.versions[n]=r)),o.group=c,o.layout=s}updateBinding(e){let t=this.backend,n=t.device,r=e.buffer,i=t.get(e).buffer;n.queue.writeBuffer(i,0,r,0)}createBindGroupIndex(e,t){let n=this.backend,r=n.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=e[0],o=r.createBuffer({label:`bindingCameraIndex_`+a,size:16,usage:i});r.queue.writeBuffer(o,0,e,0);let s=[{binding:0,resource:{buffer:o}}];return r.createBindGroup({label:`bindGroupCameraIndex_`+a,layout:t,entries:s})}createBindGroup(e,t){let n=this.backend,r=n.device,i=0,a=[];for(let t of e.bindings){if(t.isUniformBuffer){let e=n.get(t);if(e.buffer===void 0){let n=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=r.createBuffer({label:`bindingBuffer_`+t.name,size:n,usage:i});e.buffer=a}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){let e=n.get(t);if(e.buffer===void 0){let r=t.attribute;e.buffer=n.get(r).buffer}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){let e=n.get(t.texture);a.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){let e=n.get(t.texture),o;if(e.externalTexture!==void 0)o=r.importExternalTexture({source:e.externalTexture});else{let n=t.store?1:e.texture.mipLevelCount,r=`view-${e.texture.width}-${e.texture.height}-${n}`;if(o=e[r],o===void 0){let i=jA.All,a;a=t.isSampledCubeTexture?AA.Cube:t.isSampledTexture3D?AA.ThreeD:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?AA.TwoDArray:AA.TwoD,o=e[r]=e.texture.createView({aspect:i,dimension:a,mipLevelCount:n})}}a.push({binding:i,resource:o})}i++}return r.createBindGroup({label:`bindGroup_`+e.name,layout:t,entries:a})}},mj=class{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){let n=this._activePipelines.get(e);n!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:n,material:r,geometry:i,pipeline:a}=e,{vertexProgram:o,fragmentProgram:s}=a,c=this.backend,l=c.device,u=c.utils,d=c.get(a),f=[];for(let t of e.getBindings()){let e=c.get(t);f.push(e.layout)}let p=c.attributeUtils.createShaderVertexBuffers(e),m;r.blending!==ae&&(r.blending!==oe||r.transparent!==!1)&&(m=this._getBlending(r));let h={};r.stencilWrite===!0&&(h={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});let g=this._getColorWriteMask(r),_=[];if(e.context.textures!==null){let t=e.context.textures;for(let e=0;e<t.length;e++){let n=u.getTextureFormatGPU(t[e]);_.push({format:n,blend:m,writeMask:g})}}else{let t=u.getCurrentColorFormat(e.context);_.push({format:t,blend:m,writeMask:g})}let v=c.get(o).module,y=c.get(s).module,b=this._getPrimitiveState(n,i,r),x=this._getDepthCompare(r),S=u.getCurrentDepthStencilFormat(e.context),ee=this._getSampleCount(e.context),te={label:`renderPipeline_${r.name||r.type}_${r.id}`,vertex:Object.assign({},v,{buffers:p}),fragment:Object.assign({},y,{targets:_}),primitive:b,multisample:{count:ee,alphaToCoverageEnabled:r.alphaToCoverage&&ee>1},layout:l.createPipelineLayout({bindGroupLayouts:f})},ne={},re=e.context.depth,ie=e.context.stencil;if((re===!0||ie===!0)&&(re===!0&&(ne.format=S,ne.depthWriteEnabled=r.depthWrite,ne.depthCompare=x),ie===!0&&(ne.stencilFront=h,ne.stencilBack={},ne.stencilReadMask=r.stencilFuncMask,ne.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&(ne.depthBias=r.polygonOffsetUnits,ne.depthBiasSlopeScale=r.polygonOffsetFactor,ne.depthBiasClamp=0),te.depthStencil=ne),t===null)d.pipeline=l.createRenderPipeline(te);else{let e=new Promise(e=>{l.createRenderPipelineAsync(te).then(t=>{d.pipeline=t,e()})});t.push(e)}}createBundleEncoder(e,t=`renderBundleEncoder`){let n=this.backend,{utils:r,device:i}=n,a=r.getCurrentDepthStencilFormat(e),o=r.getCurrentColorFormat(e),s=this._getSampleCount(e),c={label:t,colorFormats:[o],depthStencilFormat:a,sampleCount:s};return i.createRenderBundleEncoder(c)}createComputePipeline(e,t){let n=this.backend,r=n.device,i=n.get(e.computeProgram).module,a=n.get(e),o=[];for(let e of t){let t=n.get(e);o.push(t.layout)}a.pipeline=r.createComputePipeline({compute:i,layout:r.createPipelineLayout({bindGroupLayouts:o})})}_getBlending(e){let t,n,r=e.blending,i=e.blendSrc,a=e.blendDst,o=e.blendEquation;if(r===ue){let r=e.blendSrcAlpha===null?i:e.blendSrcAlpha,s=e.blendDstAlpha===null?a:e.blendDstAlpha,c=e.blendEquationAlpha===null?o:e.blendEquationAlpha;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(o)},n={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(c)}}else{let i=e.premultipliedAlpha,a=(e,r,i,a)=>{t={srcFactor:e,dstFactor:r,operation:SA.Add},n={srcFactor:i,dstFactor:a,operation:SA.Add}};if(i)switch(r){case oe:a(xA.One,xA.OneMinusSrcAlpha,xA.One,xA.OneMinusSrcAlpha);break;case se:a(xA.One,xA.One,xA.One,xA.One);break;case ce:a(xA.Zero,xA.OneMinusSrc,xA.Zero,xA.One);break;case le:a(xA.Zero,xA.Src,xA.Zero,xA.SrcAlpha);break}else switch(r){case oe:a(xA.SrcAlpha,xA.OneMinusSrcAlpha,xA.One,xA.OneMinusSrcAlpha);break;case se:a(xA.SrcAlpha,xA.One,xA.SrcAlpha,xA.One);break;case ce:a(xA.Zero,xA.OneMinusSrc,xA.Zero,xA.One);break;case le:a(xA.Zero,xA.Src,xA.Zero,xA.Src);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error(`THREE.WebGPURenderer: Invalid blending: `,r)}_getBlendFactor(e){let t;switch(e){case ge:t=xA.Zero;break;case _e:t=xA.One;break;case ve:t=xA.Src;break;case ye:t=xA.OneMinusSrc;break;case be:t=xA.SrcAlpha;break;case xe:t=xA.OneMinusSrcAlpha;break;case we:t=xA.Dst;break;case Te:t=xA.OneMinusDst;break;case Se:t=xA.DstAlpha;break;case Ce:t=xA.OneMinusDstAlpha;break;case Ee:t=xA.SrcAlphaSaturated;break;case qb:t=xA.Constant;break;case Jb:t=xA.OneMinusConstant;break;default:console.error(`THREE.WebGPURenderer: Blend factor not supported.`,e)}return t}_getStencilCompare(e){let t,n=e.stencilFunc;switch(n){case On:t=pA.Never;break;case Fn:t=pA.Always;break;case kn:t=pA.Less;break;case jn:t=pA.LessEqual;break;case An:t=pA.Equal;break;case Pn:t=pA.GreaterEqual;break;case Mn:t=pA.Greater;break;case Nn:t=pA.NotEqual;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil function.`,n)}return t}_getStencilOperation(e){let t;switch(e){case xn:t=wA.Keep;break;case bn:t=wA.Zero;break;case Sn:t=wA.Replace;break;case Dn:t=wA.Invert;break;case Cn:t=wA.IncrementClamp;break;case wn:t=wA.DecrementClamp;break;case Tn:t=wA.IncrementWrap;break;case En:t=wA.DecrementWrap;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil operation.`,t)}return t}_getBlendOperation(e){let t;switch(e){case de:t=SA.Add;break;case fe:t=SA.Subtract;break;case pe:t=SA.ReverseSubtract;break;case me:t=SA.Min;break;case he:t=SA.Max;break;default:console.error(`THREE.WebGPUPipelineUtils: Blend equation not supported.`,e)}return t}_getPrimitiveState(e,t,n){let r={},i=this.backend.utils;switch(r.topology=i.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?vA.Uint16:vA.Uint32),n.side){case ne:r.frontFace=gA.CCW,r.cullMode=_A.Back;break;case re:r.frontFace=gA.CCW,r.cullMode=_A.Front;break;case ie:r.frontFace=gA.CCW,r.cullMode=_A.None;break;default:console.error(`THREE.WebGPUPipelineUtils: Unknown material.side value.`,n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?CA.All:CA.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=pA.Always;else{let n=e.depthFunc;switch(n){case De:t=pA.Never;break;case Oe:t=pA.Always;break;case ke:t=pA.Less;break;case Ae:t=pA.LessEqual;break;case je:t=pA.Equal;break;case Me:t=pA.GreaterEqual;break;case Ne:t=pA.Greater;break;case Pe:t=pA.NotEqual;break;default:console.error(`THREE.WebGPUPipelineUtils: Invalid depth function.`,n)}}return t}},hj=class extends cA{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:`timestamp`,count:this.maxQueries,label:`queryset_global_timestamp_${t}`});let r=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return Mr(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{let e=await this.pendingResolve;return e}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!==`unmapped`)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder();r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);let i=r.finish();if(this.device.queue.submit([i]),this.resultBuffer.mapState!==`unmapped`)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue;let a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),o=0;for(let[,t]of e){let e=a[t],n=a[t+1],r=Number(n-e)/1e6;o+=r}return this.resultBuffer.unmap(),this.lastValue=o,o}catch(e){return console.error(`Error resolving queries:`,e),this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error(`Error waiting for pending resolve:`,e)}if(this.resultBuffer&&this.resultBuffer.mapState===`mapped`)try{this.resultBuffer.unmap()}catch(e){console.error(`Error unmapping buffer:`,e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}},gj=class extends Wk{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.compatibilityMode=e.compatibilityMode===void 0?!1:e.compatibilityMode,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new cj(this),this.attributeUtils=new fj(this),this.bindingUtils=new pj(this),this.pipelineUtils=new mj(this),this.textureUtils=new HA(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);let t=this.parameters,n;if(t.device===void 0){let e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?`compatibility`:void 0},r=typeof navigator<`u`?await navigator.gpu.requestAdapter(e):null;if(r===null)throw Error(`WebGPUBackend: Unable to create WebGPU adapter.`);let i=Object.values(NA),a=[];for(let e of i)r.features.has(e)&&a.push(e);let o={requiredFeatures:a,requiredLimits:t.requiredLimits};n=await r.requestDevice(o)}else n=t.device;n.lost.then(t=>{let n={api:`WebGPU`,message:t.message||`Unknown reason`,reason:t.reason||null,originalEvent:t};e.onDeviceLost(n)});let r=t.context===void 0?e.domElement.getContext(`webgpu`):t.context;this.device=n,this.context=r;let i=t.alpha?`premultiplied`:`opaque`;this.trackTimestamp=this.trackTimestamp&&this.hasFeature(NA.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return qn}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){let t=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});let n=e.colorAttachments[0];this.renderer.samples>0?n.view=this.colorBuffer.createView():n.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}let t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){let n=e.renderTarget,r=this.get(n),i=r.descriptors;if(i===void 0||r.width!==n.width||r.height!==n.height||r.dimensions!==n.dimensions||r.activeMipmapLevel!==e.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==n.samples){i={},r.descriptors=i;let e=()=>{n.removeEventListener(`dispose`,e),this.delete(n)};n.hasEventListener(`dispose`,e)===!1&&n.addEventListener(`dispose`,e)}let a=e.getCacheKey(),o=i[a];if(o===void 0){let t=e.textures,s=[],c,l=this._isRenderCameraDepthArray(e);for(let r=0;r<t.length;r++){let i=this.get(t[r]),a={label:`colorAttachment_${r}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:AA.TwoD};if(n.isRenderTarget3D)c=e.activeCubeFace,a.baseArrayLayer=0,a.dimension=AA.ThreeD,a.depthOrArrayLayers=t[r].image.depth;else if(n.isRenderTarget&&t[r].image.depth>1)if(l===!0){let t=e.camera.cameras;for(let e=0;e<t.length;e++){let t={...a,baseArrayLayer:e,arrayLayerCount:1,dimension:AA.TwoD},n=i.texture.createView(t);s.push({view:n,resolveTarget:void 0,depthSlice:void 0})}}else a.dimension=AA.TwoDArray,a.depthOrArrayLayers=t[r].image.depth;if(l!==!0){let e=i.texture.createView(a),t,n;i.msaaTexture===void 0?(t=e,n=void 0):(t=i.msaaTexture.createView(),n=e),s.push({view:t,resolveTarget:n,depthSlice:c})}}if(o={textureViews:s},e.depth){let t=this.get(e.depthTexture),n={};e.depthTexture.isArrayTexture&&(n.dimension=AA.TwoD,n.arrayLayerCount=1,n.baseArrayLayer=e.activeCubeFace),o.depthStencilView=t.texture.createView(n)}i[a]=o,r.width=n.width,r.height=n.height,r.samples=n.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace,r.dimensions=n.dimensions}let s={colorAttachments:[]};for(let e=0;e<o.textureViews.length;e++){let n=o.textureViews[e],r={r:0,g:0,b:0,a:1};e===0&&t.clearValue&&(r=t.clearValue),s.colorAttachments.push({view:n.view,depthSlice:n.depthSlice,resolveTarget:n.resolveTarget,loadOp:t.loadOp||hA.Load,storeOp:t.storeOp||mA.Store,clearValue:r})}return o.depthStencilView&&(s.depthStencilAttachment={view:o.depthStencilView}),s}beginRender(e){let t=this.get(e),n=this.device,r=e.occlusionQueryCount,i;r>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=n.createQuerySet({type:`occlusion`,count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=Array(r),t.lastOcclusionObject=null);let a;a=e.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:hA.Load}),this.initTimestampQuery(e,a),a.occlusionQuerySet=i;let o=a.depthStencilAttachment;if(e.textures!==null){let t=a.colorAttachments;for(let n=0;n<t.length;n++){let r=t[n];e.clearColor?(r.clearValue=n===0?e.clearColorValue:{r:0,g:0,b:0,a:1},r.loadOp=hA.Clear):r.loadOp=hA.Load,r.storeOp=mA.Store}}else{let t=a.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=hA.Clear):t.loadOp=hA.Load,t.storeOp=mA.Store}e.depth&&(e.clearDepth?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=hA.Clear):o.depthLoadOp=hA.Load,o.depthStoreOp=mA.Store),e.stencil&&(e.clearStencil?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=hA.Clear):o.stencilLoadOp=hA.Load,o.stencilStoreOp=mA.Store);let s=n.createCommandEncoder({label:`renderContext_`+e.id});if(this._isRenderCameraDepthArray(e)===!0){let n=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==n.length?this._createDepthLayerDescriptors(e,t,a,n):this._updateDepthLayerDescriptors(e,t,n),t.bundleEncoders=[],t.bundleSets=[];for(let r=0;r<n.length;r++){let n=this.pipelineUtils.createBundleEncoder(e,`renderBundleArrayCamera_`+r),i={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(n),t.bundleSets.push(i)}t.currentPass=null}else{let n=s.beginRenderPass(a);if(t.currentPass=n,e.viewport&&this.updateViewport(e),e.scissor){let{x:t,y:r,width:i,height:a}=e.scissorValue;n.setScissorRect(t,r,i,a)}}t.descriptor=a,t.encoder=s,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,n,r){let i=n.depthStencilAttachment;t.layerDescriptors=[];let a=this.get(e.depthTexture);a.viewCache||=[];for(let o=0;o<r.length;o++){let r={...n,colorAttachments:[{...n.colorAttachments[0],view:n.colorAttachments[o].view}]};if(n.depthStencilAttachment){let t=o;a.viewCache[t]||(a.viewCache[t]=a.texture.createView({dimension:AA.TwoD,baseArrayLayer:o,arrayLayerCount:1})),r.depthStencilAttachment={view:a.viewCache[t],depthLoadOp:i.depthLoadOp||hA.Clear,depthStoreOp:i.depthStoreOp||mA.Store,depthClearValue:i.depthClearValue||1},e.stencil&&(r.depthStencilAttachment.stencilLoadOp=i.stencilLoadOp,r.depthStencilAttachment.stencilStoreOp=i.stencilStoreOp,r.depthStencilAttachment.stencilClearValue=i.stencilClearValue)}else r.depthStencilAttachment={...i};t.layerDescriptors.push(r)}}_updateDepthLayerDescriptors(e,t,n){for(let r=0;r<n.length;r++){let n=t.layerDescriptors[r];if(n.depthStencilAttachment){let t=n.depthStencilAttachment;e.depth&&(e.clearDepth?(t.depthClearValue=e.clearDepthValue,t.depthLoadOp=hA.Clear):t.depthLoadOp=hA.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=hA.Clear):t.stencilLoadOp=hA.Load)}}}finishRender(e){let t=this.get(e),n=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let n=[];for(let e=0;e<t.bundleEncoders.length;e++){let r=t.bundleEncoders[e];n.push(r.finish())}for(let i=0;i<t.layerDescriptors.length;i++)if(i<n.length){let a=t.layerDescriptors[i],o=r.beginRenderPass(a);if(e.viewport){let{x:t,y:n,width:r,height:i,minDepth:a,maxDepth:s}=e.viewportValue;o.setViewport(t,n,r,i,a,s)}if(e.scissor){let{x:t,y:n,width:r,height:i}=e.scissorValue;o.setScissorRect(t,n,r,i)}o.executeBundles([n[i]]),o.end()}}else t.currentPass&&t.currentPass.end();if(n>0){let r=n*8,i=this.occludedResolveCache.get(r);i===void 0&&(i=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,i));let a=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,i,0),t.encoder.copyBufferToBuffer(i,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){let t=e.textures;for(let e=0;e<t.length;e++){let n=t[e];n.generateMipmaps===!0&&this.textureUtils.generateMipmaps(n)}}}isOccluded(e,t){let n=this.get(e);return n.occluded&&n.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:n,currentOcclusionQueryObjects:r}=t;if(n&&r){let e=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await n.mapAsync(GPUMapMode.READ);let i=n.getMappedRange(),a=new BigUint64Array(i);for(let t=0;t<r.length;t++)a[t]===BigInt(0)&&e.add(r[t]);n.destroy(),t.occluded=e}}updateViewport(e){let{currentPass:t}=this.get(e),{x:n,y:r,width:i,height:a,minDepth:o,maxDepth:s}=e.viewportValue;t.setViewport(n,r,i,a,o,s)}getClearColor(){let e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,n,r=null){let i=this.device,a=this.renderer,o=[],s,c,l,u;if(e){let e=this.getClearColor();c={r:e.r,g:e.g,b:e.b,a:e.a}}if(r===null){l=a.depth,u=a.stencil;let t=this._getDefaultRenderPassDescriptor();if(e){o=t.colorAttachments;let e=o[0];e.clearValue=c,e.loadOp=hA.Clear,e.storeOp=mA.Store}(l||u)&&(s=t.depthStencilAttachment)}else{l=r.depth,u=r.stencil;let i={loadOp:e?hA.Clear:hA.Load,clearValue:e?c:void 0};l&&(i.depthLoadOp=t?hA.Clear:hA.Load,i.depthClearValue=t?a.getClearDepth():void 0,i.depthStoreOp=mA.Store),u&&(i.stencilLoadOp=n?hA.Clear:hA.Load,i.stencilClearValue=n?a.getClearStencil():void 0,i.stencilStoreOp=mA.Store);let d=this._getRenderPassDescriptor(r,i);o=d.colorAttachments,s=d.depthStencilAttachment}l&&s&&s.depthLoadOp===void 0&&(t?(s.depthLoadOp=hA.Clear,s.depthClearValue=a.getClearDepth(),s.depthStoreOp=mA.Store):(s.depthLoadOp=hA.Load,s.depthStoreOp=mA.Store)),u&&s&&s.stencilLoadOp===void 0&&(n?(s.stencilLoadOp=hA.Clear,s.stencilClearValue=a.getClearStencil(),s.stencilStoreOp=mA.Store):(s.stencilLoadOp=hA.Load,s.stencilStoreOp=mA.Store));let d=i.createCommandEncoder({label:`clear`}),f=d.beginRenderPass({colorAttachments:o,depthStencilAttachment:s});f.end(),i.queue.submit([d.finish()])}beginCompute(e){let t=this.get(e),n={label:`computeGroup_`+e.id};this.initTimestampQuery(e,n),t.cmdEncoderGPU=this.device.createCommandEncoder({label:`computeGroup_`+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(n)}compute(e,t,n,r){let{passEncoderGPU:i}=this.get(e),a=this.get(r).pipeline;this.pipelineUtils.setPipeline(i,a);for(let e=0,t=n.length;e<t;e++){let t=n[e],r=this.get(t);i.setBindGroup(e,r.group)}let o=this.device.limits.maxComputeWorkgroupsPerDimension,s=this.get(t);s.dispatchSize===void 0&&(s.dispatchSize={x:0,y:1,z:1});let{dispatchSize:c}=s;t.dispatchCount>o?(c.x=Math.min(t.dispatchCount,o),c.y=Math.ceil(t.dispatchCount/o)):c.x=t.dispatchCount,i.dispatchWorkgroups(c.x,c.y,c.z)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){let{object:n,material:r,context:i,pipeline:a}=e,o=e.getBindings(),s=this.get(i),c=this.get(a).pipeline,l=e.getIndex(),u=l!==null,d=e.getDrawParameters();if(d===null)return;let f=(t,n)=>{this.pipelineUtils.setPipeline(t,c),n.pipeline=c;let a=n.bindingGroups;for(let e=0,n=o.length;e<n;e++){let n=o[e],r=this.get(n);a[n.index]!==n.id&&(t.setBindGroup(n.index,r.group),a[n.index]=n.id)}if(u===!0&&n.index!==l){let e=this.get(l).buffer,r=l.array instanceof Uint16Array?vA.Uint16:vA.Uint32;t.setIndexBuffer(e,r),n.index=l}let d=e.getVertexBuffers();for(let e=0,r=d.length;e<r;e++){let r=d[e];if(n.attributes[e]!==r){let i=this.get(r).buffer;t.setVertexBuffer(e,i),n.attributes[e]=r}}i.stencil===!0&&r.stencilWrite===!0&&s.currentStencilRef!==r.stencilRef&&(t.setStencilReference(r.stencilRef),s.currentStencilRef=r.stencilRef)},p=(r,i)=>{if(f(r,i),n.isBatchedMesh===!0){let e=n._multiDrawStarts,i=n._multiDrawCounts,a=n._multiDrawCount,o=n._multiDrawInstances;o!==null&&Mr(`THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`);for(let s=0;s<a;s++){let a=o?o[s]:1,c=a>1?0:s;u===!0?r.drawIndexed(i[s],a,e[s]/l.array.BYTES_PER_ELEMENT,0,c):r.draw(i[s],a,e[s],c),t.update(n,i[s],a)}}else if(u===!0){let{vertexCount:i,instanceCount:a,firstVertex:o}=d,s=e.getIndirect();if(s!==null){let e=this.get(s).buffer;r.drawIndexedIndirect(e,0)}else r.drawIndexed(i,a,o,0,0);t.update(n,i,a)}else{let{vertexCount:i,instanceCount:a,firstVertex:o}=d,s=e.getIndirect();if(s!==null){let e=this.get(s).buffer;r.drawIndirect(e,0)}else r.draw(i,a,o,0);t.update(n,i,a)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let t=this.get(e.camera),r=e.camera.cameras,a=e.getBindingGroup(`cameraIndex`);if(t.indexesGPU===void 0||t.indexesGPU.length!==r.length){let e=this.get(a),n=[],i=new Uint32Array([0,0,0,0]);for(let t=0,a=r.length;t<a;t++){i[0]=t;let r=this.bindingUtils.createBindGroupIndex(i,e.layout);n.push(r)}t.indexesGPU=n}let o=this.renderer.getPixelRatio();for(let e=0,c=r.length;e<c;e++){let c=r[e];if(n.layers.test(c.layers)){let n=c.viewport,r=s.currentPass,l=s.currentSets;if(s.bundleEncoders){let t=s.bundleEncoders[e],n=s.bundleSets[e];r=t,l=n}n&&r.setViewport(Math.floor(n.x*o),Math.floor(n.y*o),Math.floor(n.width*o),Math.floor(n.height*o),i.viewportValue.minDepth,i.viewportValue.maxDepth),a&&t.indexesGPU&&(r.setBindGroup(a.index,t.indexesGPU[e]),l.bindingGroups[a.index]=a.id),p(r,l)}}}else if(s.currentPass){if(s.occlusionQuerySet!==void 0){let e=s.lastOcclusionObject;e!==n&&(e!==null&&e.occlusionTest===!0&&(s.currentPass.endOcclusionQuery(),s.occlusionQueryIndex++),n.occlusionTest===!0&&(s.currentPass.beginOcclusionQuery(s.occlusionQueryIndex),s.occlusionQueryObjects[s.occlusionQueryIndex]=n),s.lastOcclusionObject=n)}p(s.currentPass,s.currentSets)}}needsRenderUpdate(e){let t=this.get(e),{object:n,material:r}=e,i=this.utils,a=i.getSampleCountRenderContext(e.context),o=i.getCurrentColorSpace(e.context),s=i.getCurrentColorFormat(e.context),c=i.getCurrentDepthStencilFormat(e.context),l=i.getPrimitiveTopology(n,r),u=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==o||t.colorFormat!==s||t.depthStencilFormat!==c||t.primitiveTopology!==l||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=o,t.colorFormat=s,t.depthStencilFormat=c,t.primitiveTopology=l,t.clippingContextCacheKey=e.clippingContextCacheKey,u=!0),u}getRenderCacheKey(e){let{object:t,material:n}=e,r=this.utils,i=e.context;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,r.getSampleCountRenderContext(i),r.getCurrentColorSpace(i),r.getCurrentColorFormat(i),r.getCurrentDepthStencilFormat(i),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}async copyTextureToBuffer(e,t,n,r,i,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,a)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;let n=e.isComputeNode?`compute`:`render`;this.timestampQueryPool[n]||(this.timestampQueryPool[n]=new hj(this.device,n,2048));let r=this.timestampQueryPool[n],i=r.allocateQueriesForContext(e);t.timestampWrites={querySet:r.querySet,beginningOfPassWriteIndex:i,endOfPassWriteIndex:i+1}}createNodeBuilder(e,t){return new sj(e,t)}createProgram(e){let t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name===``?``:`_${e.name}`)}),entryPoint:`main`}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){let t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){let n=this.get(e),r=n.currentPass,i=r.finish();this.get(t).bundleGPU=i,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){let n=this.get(e);n.renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){let o=0,s=0,c=0,l=0,u=0,d=0,f=e.image.width,p=e.image.height,m=1;n!==null&&(n.isBox3===!0?(l=n.min.x,u=n.min.y,d=n.min.z,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=n.max.z-n.min.z):(l=n.min.x,u=n.min.y,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=1)),r!==null&&(o=r.x,s=r.y,c=r.z||0);let h=this.device.createCommandEncoder({label:`copyTextureToTexture_`+e.id+`_`+t.id}),g=this.get(e).texture,_=this.get(t).texture;h.copyTextureToTexture({texture:g,mipLevel:i,origin:{x:l,y:u,z:d}},{texture:_,mipLevel:a,origin:{x:o,y:s,z:c}},[f,p,m]),this.device.queue.submit([h.finish()]),a===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,n){let r=this.get(t),i=null;i=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();let a=this.get(e).texture;if(i.format!==a.format){console.error(`WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.`,i.format,a.format);return}let o;if(r.currentPass?(r.currentPass.end(),o=r.encoder):o=this.device.createCommandEncoder({label:`copyFramebufferToTexture_`+e.id}),o.copyTextureToTexture({texture:i,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),r.currentPass){let{descriptor:e}=r;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=hA.Load;if(t.depth&&(e.depthStencilAttachment.depthLoadOp=hA.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=hA.Load),r.currentPass=o.beginRenderPass(e),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor){let{x:e,y:n,width:i,height:a}=t.scissorValue;r.currentPass.setScissorRect(e,n,i,a)}}else this.device.queue.submit([o.finish()]);e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}},_j=class extends Es{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},vj=class extends Es{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}},yj=class extends YO{constructor(){super(),this.addMaterial(xv,`MeshPhongMaterial`),this.addMaterial(_b,`MeshStandardMaterial`),this.addMaterial(yb,`MeshPhysicalMaterial`),this.addMaterial(Cb,`MeshToonMaterial`),this.addMaterial(dv,`MeshBasicMaterial`),this.addMaterial(yv,`MeshLambertMaterial`),this.addMaterial(X_,`MeshNormalMaterial`),this.addMaterial(Db,`MeshMatcapMaterial`),this.addMaterial(V_,`LineBasicMaterial`),this.addMaterial(U_,`LineDashedMaterial`),this.addMaterial(Nb,`PointsMaterial`),this.addMaterial(jb,`SpriteMaterial`),this.addMaterial(Ib,`ShadowMaterial`),this.addLight(YT,js),this.addLight(bO,Ps),this.addLight(wO,Is),this.addLight(TO,Es),this.addLight(kO,Fs),this.addLight(AO,bs),this.addLight(jO,Rs),this.addLight(EO,_j),this.addLight(OO,vj),this.addToneMapping(zC,ze),this.addToneMapping(BC,Be),this.addToneMapping(VC,Ve),this.addToneMapping(UC,He),this.addToneMapping(qC,Ue),this.addToneMapping(JC,We)}},bj=class extends vk{constructor(e={}){let t;e.forceWebGL?t=dA:(t=gj,e.getFallback=()=>(console.warn(`THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.`),new dA(e)));let n=new t(e);super(n,e),this.library=new yj,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}},xj={};_(xj,{BRDF_GGX:()=>Sj,BRDF_Lambert:()=>Cj,BasicShadowFilter:()=>wj,Break:()=>Tj,Const:()=>vte,Continue:()=>Ej,DFGApprox:()=>Dj,D_GGX:()=>Oj,Discard:()=>kj,EPSILON:()=>Aj,F_Schlick:()=>jj,Fn:()=>Mj,INFINITY:()=>Nj,If:()=>Pj,Loop:()=>Ij,NodeAccess:()=>Bj,NodeShaderStage:()=>Lj,NodeType:()=>Rj,NodeUpdateType:()=>zj,PCFShadowFilter:()=>Vj,PCFSoftShadowFilter:()=>Hj,PI:()=>Uj,PI2:()=>Wj,Return:()=>Gj,Schlick_to_F0:()=>Kj,ScriptableNodeResources:()=>qj,ShaderNode:()=>Jj,Switch:()=>Fj,TBNViewMatrix:()=>Yj,VSMShadowFilter:()=>Xj,V_GGX_SmithCorrelated:()=>Zj,Var:()=>aF,abs:()=>Qj,acesFilmicToneMapping:()=>$j,acos:()=>eM,add:()=>tM,addNodeElement:()=>nM,agxToneMapping:()=>rM,all:()=>iM,alphaT:()=>aM,and:()=>oM,anisotropy:()=>sM,anisotropyB:()=>cM,anisotropyT:()=>lM,any:()=>uM,append:()=>dM,array:()=>fM,arrayBuffer:()=>pM,asin:()=>mM,assign:()=>hM,atan:()=>gM,atan2:()=>_M,atomicAdd:()=>vM,atomicAnd:()=>yM,atomicFunc:()=>bM,atomicLoad:()=>pee,atomicMax:()=>xM,atomicMin:()=>SM,atomicOr:()=>CM,atomicStore:()=>wM,atomicSub:()=>TM,atomicXor:()=>EM,attenuationColor:()=>mee,attenuationDistance:()=>hee,attribute:()=>gee,attributeArray:()=>_ee,backgroundBlurriness:()=>vee,backgroundIntensity:()=>yee,backgroundRotation:()=>bee,batch:()=>xee,billboarding:()=>See,bitAnd:()=>Cee,bitNot:()=>wee,bitOr:()=>Tee,bitXor:()=>Eee,bitangentGeometry:()=>Dee,bitangentLocal:()=>Oee,bitangentView:()=>kee,bitangentWorld:()=>Aee,bitcast:()=>jee,blendBurn:()=>Mee,blendColor:()=>Nee,blendDodge:()=>Pee,blendOverlay:()=>Fee,blendScreen:()=>Iee,blur:()=>Lee,bool:()=>Ree,buffer:()=>zee,bufferAttribute:()=>Bee,bumpMap:()=>Vee,burn:()=>Hee,bvec2:()=>Uee,bvec3:()=>Wee,bvec4:()=>Gee,bypass:()=>Kee,cache:()=>qee,call:()=>Jee,cameraFar:()=>Yee,cameraIndex:()=>Xee,cameraNear:()=>Zee,cameraNormalMatrix:()=>Qee,cameraPosition:()=>$ee,cameraProjectionMatrix:()=>ete,cameraProjectionMatrixInverse:()=>tte,cameraViewMatrix:()=>nte,cameraWorldMatrix:()=>rte,cbrt:()=>ite,cdl:()=>ate,ceil:()=>ote,checker:()=>ste,cineonToneMapping:()=>cte,clamp:()=>DM,clearcoat:()=>lte,clearcoatRoughness:()=>ute,code:()=>dte,color:()=>fte,colorSpaceToWorking:()=>pte,colorToDirection:()=>mte,compute:()=>hte,computeSkinning:()=>gte,cond:()=>_te,context:()=>yte,convert:()=>bte,convertColorSpace:()=>xte,convertToTexture:()=>Ste,cos:()=>OM,cross:()=>Cte,cubeTexture:()=>wte,dFdx:()=>Tte,dFdy:()=>Ete,dashSize:()=>Dte,debug:()=>Ote,decrement:()=>kte,decrementBefore:()=>Ate,defaultBuildStages:()=>jte,defaultShaderStages:()=>Mte,defined:()=>Nte,degrees:()=>Pte,deltaTime:()=>Fte,densityFog:()=>Ite,densityFogFactor:()=>Lte,depth:()=>Rte,depthPass:()=>zte,difference:()=>Bte,diffuseColor:()=>Vte,directPointLight:()=>Hte,directionToColor:()=>Ute,dispersion:()=>Wte,distance:()=>Gte,div:()=>Kte,dodge:()=>qte,dot:()=>kM,drawIndex:()=>Jte,dynamicBufferAttribute:()=>Yte,element:()=>Xte,emissive:()=>Zte,equal:()=>Qte,equals:()=>$te,equirectUV:()=>ene,exp:()=>tne,exp2:()=>nne,expression:()=>rne,faceDirection:()=>ine,faceForward:()=>ane,faceforward:()=>one,float:()=>AM,floor:()=>sne,fog:()=>cne,fract:()=>jM,frameGroup:()=>lne,frameId:()=>une,frontFacing:()=>dne,fwidth:()=>fne,gain:()=>pne,gapSize:()=>mne,getConstNodeType:()=>hne,getCurrentStack:()=>gne,getDirection:()=>_ne,getDistanceAttenuation:()=>vne,getGeometryRoughness:()=>yne,getNormalFromDepth:()=>bne,getParallaxCorrectNormal:()=>xne,getRoughness:()=>Sne,getScreenPosition:()=>Cne,getShIrradianceAt:()=>wne,getShadowMaterial:()=>Dne,getShadowRenderObjectFunction:()=>One,getTextureIndex:()=>Tne,getViewPosition:()=>Ene,globalId:()=>bre,glsl:()=>kne,glslFn:()=>Ane,grayscale:()=>jne,greaterThan:()=>Mne,greaterThanEqual:()=>Nne,hash:()=>Pne,highpModelNormalViewMatrix:()=>Fne,highpModelViewMatrix:()=>Ine,hue:()=>Lne,increment:()=>Rne,incrementBefore:()=>zne,instance:()=>Bne,instanceIndex:()=>Vne,instancedArray:()=>Hne,instancedBufferAttribute:()=>Une,instancedDynamicBufferAttribute:()=>Wne,instancedMesh:()=>Gne,int:()=>Kne,inverseSqrt:()=>qne,inversesqrt:()=>Jne,invocationLocalIndex:()=>Yne,invocationSubgroupIndex:()=>Xne,ior:()=>Zne,iridescence:()=>Qne,iridescenceIOR:()=>$ne,iridescenceThickness:()=>ere,ivec2:()=>tre,ivec3:()=>nre,ivec4:()=>rre,js:()=>ire,label:()=>are,length:()=>ore,lengthSq:()=>sre,lessThan:()=>cre,lessThanEqual:()=>lre,lightPosition:()=>ure,lightProjectionUV:()=>WM,lightShadowMatrix:()=>dre,lightTargetDirection:()=>fre,lightTargetPosition:()=>pre,lightViewPosition:()=>mre,lightingContext:()=>hre,lights:()=>gre,linearDepth:()=>_re,linearToneMapping:()=>vre,localId:()=>yre,log:()=>xre,log2:()=>Sre,logarithmicDepthToViewZ:()=>Cre,loop:()=>wre,luminance:()=>Tre,mat2:()=>Dre,mat3:()=>Ore,mat4:()=>kre,matcapUV:()=>Are,materialAO:()=>jre,materialAlphaTest:()=>Mre,materialAnisotropy:()=>Nre,materialAnisotropyVector:()=>Pre,materialAttenuationColor:()=>Fre,materialAttenuationDistance:()=>Ire,materialClearcoat:()=>Lre,materialClearcoatNormal:()=>Rre,materialClearcoatRoughness:()=>zre,materialColor:()=>Bre,materialDispersion:()=>Vre,materialEmissive:()=>Hre,materialIOR:()=>Ure,materialIridescence:()=>Wre,materialIridescenceIOR:()=>Gre,materialIridescenceThickness:()=>Kre,materialLightMap:()=>qre,materialLineDashOffset:()=>Jre,materialLineDashSize:()=>Yre,materialLineGapSize:()=>Xre,materialLineScale:()=>Zre,materialLineWidth:()=>Qre,materialMetalness:()=>$re,materialNormal:()=>eie,materialOpacity:()=>tie,materialPointSize:()=>nie,materialReference:()=>rie,materialReflectivity:()=>iie,materialRefractionRatio:()=>aie,materialRotation:()=>oie,materialRoughness:()=>sie,materialSheen:()=>cie,materialSheenRoughness:()=>lie,materialShininess:()=>uie,materialSpecular:()=>die,materialSpecularColor:()=>fie,materialSpecularIntensity:()=>pie,materialSpecularStrength:()=>mie,materialThickness:()=>hie,materialTransmission:()=>gie,max:()=>MM,maxMipLevel:()=>_ie,mediumpModelViewMatrix:()=>Ere,metalness:()=>vie,min:()=>yie,mix:()=>NM,mixElement:()=>bie,mod:()=>xie,modInt:()=>Sie,modelDirection:()=>Cie,modelNormalMatrix:()=>wie,modelPosition:()=>Tie,modelRadius:()=>Eie,modelScale:()=>Die,modelViewMatrix:()=>Oie,modelViewPosition:()=>kie,modelViewProjection:()=>Aie,modelWorldMatrix:()=>jie,modelWorldMatrixInverse:()=>Mie,morphReference:()=>Nie,mrt:()=>Pie,mul:()=>PM,mx_aastep:()=>Fie,mx_cell_noise_float:()=>Iie,mx_contrast:()=>Lie,mx_fractal_noise_float:()=>Rie,mx_fractal_noise_vec2:()=>zie,mx_fractal_noise_vec3:()=>Bie,mx_fractal_noise_vec4:()=>Vie,mx_hsvtorgb:()=>Hie,mx_noise_float:()=>Uie,mx_noise_vec3:()=>Wie,mx_noise_vec4:()=>Gie,mx_ramplr:()=>Kie,mx_ramptb:()=>qie,mx_rgbtohsv:()=>Jie,mx_safepower:()=>Yie,mx_splitlr:()=>Xie,mx_splittb:()=>Zie,mx_srgb_texture_to_lin_rec709:()=>Qie,mx_transform_uv:()=>$ie,mx_worley_noise_float:()=>eae,mx_worley_noise_vec2:()=>tae,mx_worley_noise_vec3:()=>nae,namespace:()=>rae,negate:()=>iae,neutralToneMapping:()=>aae,nodeArray:()=>oae,nodeImmutable:()=>sae,nodeObject:()=>cae,nodeObjects:()=>lae,nodeProxy:()=>uae,normalFlat:()=>dae,normalGeometry:()=>fae,normalLocal:()=>pae,normalMap:()=>mae,normalView:()=>hae,normalWorld:()=>gae,normalize:()=>_ae,not:()=>vae,notEqual:()=>yae,numWorkgroups:()=>bae,objectDirection:()=>xae,objectGroup:()=>Sae,objectPosition:()=>Cae,objectRadius:()=>wae,objectScale:()=>Tae,objectViewPosition:()=>Eae,objectWorldMatrix:()=>Dae,oneMinus:()=>Oae,or:()=>kae,orthographicDepthToViewZ:()=>Aae,oscSawtooth:()=>jae,oscSine:()=>Mae,oscSquare:()=>Nae,oscTriangle:()=>Pae,output:()=>Fae,outputStruct:()=>Iae,overlay:()=>Lae,overloadingFn:()=>Rae,parabola:()=>zae,parallaxDirection:()=>Bae,parallaxUV:()=>Vae,parameter:()=>Hae,pass:()=>Uae,passTexture:()=>Wae,pcurve:()=>Gae,perspectiveDepthToViewZ:()=>Kae,pmremTexture:()=>qae,pointShadow:()=>ON,pointUV:()=>Jae,pointWidth:()=>Yae,positionGeometry:()=>Xae,positionLocal:()=>Zae,positionPrevious:()=>Qae,positionView:()=>$ae,positionViewDirection:()=>eoe,positionWorld:()=>toe,positionWorldDirection:()=>noe,posterize:()=>roe,pow:()=>FM,pow2:()=>ioe,pow3:()=>aoe,pow4:()=>ooe,premult:()=>IM,property:()=>LM,radians:()=>RM,rand:()=>zM,range:()=>BM,rangeFog:()=>VM,rangeFogFactor:()=>HM,reciprocal:()=>UM,reference:()=>GM,referenceBuffer:()=>KM,reflect:()=>qM,reflectVector:()=>JM,reflectView:()=>YM,reflector:()=>XM,refract:()=>ZM,refractVector:()=>QM,refractView:()=>$M,reinhardToneMapping:()=>eN,remainder:()=>tN,remap:()=>nN,remapClamp:()=>rN,renderGroup:()=>iN,renderOutput:()=>aN,rendererReference:()=>oN,rotate:()=>sN,rotateUV:()=>cN,roughness:()=>lN,round:()=>uN,rtt:()=>dN,sRGBTransferEOTF:()=>fN,sRGBTransferOETF:()=>pN,sampler:()=>mN,samplerComparison:()=>hN,saturate:()=>gN,saturation:()=>_N,screen:()=>vN,screenCoordinate:()=>yN,screenSize:()=>bN,screenUV:()=>xN,scriptable:()=>SN,scriptableValue:()=>CN,select:()=>wN,setCurrentStack:()=>TN,shaderStages:()=>EN,shadow:()=>DN,shadowPositionWorld:()=>kN,shapeCircle:()=>jN,sharedUniformGroup:()=>AN,sheen:()=>MN,sheenRoughness:()=>NN,shiftLeft:()=>PN,shiftRight:()=>FN,shininess:()=>IN,sign:()=>LN,sin:()=>RN,sinc:()=>zN,skinning:()=>BN,smoothstep:()=>VN,smoothstepElement:()=>HN,specularColor:()=>UN,specularF90:()=>WN,spherizeUV:()=>GN,split:()=>KN,spritesheetUV:()=>qN,sqrt:()=>JN,stack:()=>YN,step:()=>XN,storage:()=>ZN,storageBarrier:()=>QN,storageObject:()=>$N,storageTexture:()=>eP,string:()=>tP,struct:()=>nP,sub:()=>rP,subgroupIndex:()=>iP,subgroupSize:()=>aP,tan:()=>oP,tangentGeometry:()=>sP,tangentLocal:()=>cP,tangentView:()=>lP,tangentWorld:()=>uP,temp:()=>dP,texture:()=>fP,texture3D:()=>pP,textureBarrier:()=>mP,textureBicubic:()=>hP,textureCubeUV:()=>gP,textureLoad:()=>_P,textureSize:()=>vP,textureStore:()=>yP,thickness:()=>bP,time:()=>xP,timerDelta:()=>SP,timerGlobal:()=>CP,timerLocal:()=>wP,toneMapping:()=>TP,toneMappingExposure:()=>EP,toonOutlinePass:()=>DP,transformDirection:()=>OP,transformNormal:()=>kP,transformNormalToView:()=>AP,transformedBentNormalView:()=>jP,transformedBitangentView:()=>MP,transformedBitangentWorld:()=>NP,transformedClearcoatNormalView:()=>PP,transformedNormalView:()=>FP,transformedNormalWorld:()=>IP,transformedTangentView:()=>LP,transformedTangentWorld:()=>RP,transmission:()=>zP,transpose:()=>BP,triNoise3D:()=>VP,triplanarTexture:()=>HP,triplanarTextures:()=>UP,trunc:()=>WP,tslFn:()=>GP,uint:()=>KP,uniform:()=>qP,uniformArray:()=>YP,uniformCubeTexture:()=>JP,uniformGroup:()=>XP,uniformTexture:()=>ZP,uniforms:()=>QP,unpremult:()=>$P,userData:()=>eF,uv:()=>tF,uvec2:()=>nF,uvec3:()=>rF,uvec4:()=>iF,varying:()=>oF,varyingProperty:()=>sF,vec2:()=>cF,vec3:()=>lF,vec4:()=>uF,vectorComponents:()=>dF,velocity:()=>fF,vertexColor:()=>pF,vertexIndex:()=>mF,vibrance:()=>hF,viewZToLogarithmicDepth:()=>gF,viewZToOrthographicDepth:()=>_F,viewZToPerspectiveDepth:()=>vF,viewport:()=>yF,viewportBottomLeft:()=>bF,viewportCoordinate:()=>xF,viewportDepthTexture:()=>SF,viewportLinearDepth:()=>CF,viewportMipTexture:()=>wF,viewportResolution:()=>TF,viewportSafeUV:()=>EF,viewportSharedTexture:()=>DF,viewportSize:()=>OF,viewportTexture:()=>kF,viewportTopLeft:()=>AF,viewportUV:()=>jF,wgsl:()=>MF,wgslFn:()=>NF,workgroupArray:()=>PF,workgroupBarrier:()=>FF,workgroupId:()=>IF,workingToColorSpace:()=>LF,xor:()=>RF});const Sj=I.BRDF_GGX,Cj=I.BRDF_Lambert,wj=I.BasicShadowFilter,Tj=I.Break,Ej=I.Continue,Dj=I.DFGApprox,Oj=I.D_GGX,kj=I.Discard,Aj=I.EPSILON,jj=I.F_Schlick,Mj=I.Fn,Nj=I.INFINITY,Pj=I.If,Fj=I.Switch,Ij=I.Loop,Lj=I.NodeShaderStage,Rj=I.NodeType,zj=I.NodeUpdateType,Bj=I.NodeAccess,Vj=I.PCFShadowFilter,Hj=I.PCFSoftShadowFilter,Uj=I.PI,Wj=I.PI2,Gj=I.Return,Kj=I.Schlick_to_F0,qj=I.ScriptableNodeResources,Jj=I.ShaderNode,Yj=I.TBNViewMatrix,Xj=I.VSMShadowFilter,Zj=I.V_GGX_SmithCorrelated,Qj=I.abs,$j=I.acesFilmicToneMapping,eM=I.acos,tM=I.add,nM=I.addNodeElement,rM=I.agxToneMapping,iM=I.all,aM=I.alphaT,oM=I.and,sM=I.anisotropy,cM=I.anisotropyB,lM=I.anisotropyT,uM=I.any,dM=I.append,fM=I.array,pM=I.arrayBuffer,mM=I.asin,hM=I.assign,gM=I.atan,_M=I.atan2,vM=I.atomicAdd,yM=I.atomicAnd,bM=I.atomicFunc,xM=I.atomicMax,SM=I.atomicMin,CM=I.atomicOr,wM=I.atomicStore,TM=I.atomicSub,EM=I.atomicXor,pee=I.atomicLoad,mee=I.attenuationColor,hee=I.attenuationDistance,gee=I.attribute,_ee=I.attributeArray,vee=I.backgroundBlurriness,yee=I.backgroundIntensity,bee=I.backgroundRotation,xee=I.batch,See=I.billboarding,Cee=I.bitAnd,wee=I.bitNot,Tee=I.bitOr,Eee=I.bitXor,Dee=I.bitangentGeometry,Oee=I.bitangentLocal,kee=I.bitangentView,Aee=I.bitangentWorld,jee=I.bitcast,Mee=I.blendBurn,Nee=I.blendColor,Pee=I.blendDodge,Fee=I.blendOverlay,Iee=I.blendScreen,Lee=I.blur,Ree=I.bool,zee=I.buffer,Bee=I.bufferAttribute,Vee=I.bumpMap,Hee=I.burn,Uee=I.bvec2,Wee=I.bvec3,Gee=I.bvec4,Kee=I.bypass,qee=I.cache,Jee=I.call,Yee=I.cameraFar,Xee=I.cameraIndex,Zee=I.cameraNear,Qee=I.cameraNormalMatrix,$ee=I.cameraPosition,ete=I.cameraProjectionMatrix,tte=I.cameraProjectionMatrixInverse,nte=I.cameraViewMatrix,rte=I.cameraWorldMatrix,ite=I.cbrt,ate=I.cdl,ote=I.ceil,ste=I.checker,cte=I.cineonToneMapping,DM=I.clamp,lte=I.clearcoat,ute=I.clearcoatRoughness,dte=I.code,fte=I.color,pte=I.colorSpaceToWorking,mte=I.colorToDirection,hte=I.compute,gte=I.computeSkinning,_te=I.cond,vte=I.Const,yte=I.context,bte=I.convert,xte=I.convertColorSpace,Ste=I.convertToTexture,OM=I.cos,Cte=I.cross,wte=I.cubeTexture,Tte=I.dFdx,Ete=I.dFdy,Dte=I.dashSize,Ote=I.debug,kte=I.decrement,Ate=I.decrementBefore,jte=I.defaultBuildStages,Mte=I.defaultShaderStages,Nte=I.defined,Pte=I.degrees,Fte=I.deltaTime,Ite=I.densityFog,Lte=I.densityFogFactor,Rte=I.depth,zte=I.depthPass,Bte=I.difference,Vte=I.diffuseColor,Hte=I.directPointLight,Ute=I.directionToColor,Wte=I.dispersion,Gte=I.distance,Kte=I.div,qte=I.dodge,kM=I.dot,Jte=I.drawIndex,Yte=I.dynamicBufferAttribute,Xte=I.element,Zte=I.emissive,Qte=I.equal,$te=I.equals,ene=I.equirectUV,tne=I.exp,nne=I.exp2,rne=I.expression,ine=I.faceDirection,ane=I.faceForward,one=I.faceforward,AM=I.float,sne=I.floor,cne=I.fog,jM=I.fract,lne=I.frameGroup,une=I.frameId,dne=I.frontFacing,fne=I.fwidth,pne=I.gain,mne=I.gapSize,hne=I.getConstNodeType,gne=I.getCurrentStack,_ne=I.getDirection,vne=I.getDistanceAttenuation,yne=I.getGeometryRoughness,bne=I.getNormalFromDepth,xne=I.getParallaxCorrectNormal,Sne=I.getRoughness,Cne=I.getScreenPosition,wne=I.getShIrradianceAt,Tne=I.getTextureIndex,Ene=I.getViewPosition,Dne=I.getShadowMaterial,One=I.getShadowRenderObjectFunction,kne=I.glsl,Ane=I.glslFn,jne=I.grayscale,Mne=I.greaterThan,Nne=I.greaterThanEqual,Pne=I.hash,Fne=I.highpModelNormalViewMatrix,Ine=I.highpModelViewMatrix,Lne=I.hue,Rne=I.increment,zne=I.incrementBefore,Bne=I.instance,Vne=I.instanceIndex,Hne=I.instancedArray,Une=I.instancedBufferAttribute,Wne=I.instancedDynamicBufferAttribute,Gne=I.instancedMesh,Kne=I.int,qne=I.inverseSqrt,Jne=I.inversesqrt,Yne=I.invocationLocalIndex,Xne=I.invocationSubgroupIndex,Zne=I.ior,Qne=I.iridescence,$ne=I.iridescenceIOR,ere=I.iridescenceThickness,tre=I.ivec2,nre=I.ivec3,rre=I.ivec4,ire=I.js,are=I.label,ore=I.length,sre=I.lengthSq,cre=I.lessThan,lre=I.lessThanEqual,ure=I.lightPosition,dre=I.lightShadowMatrix,fre=I.lightTargetDirection,pre=I.lightTargetPosition,mre=I.lightViewPosition,hre=I.lightingContext,gre=I.lights,_re=I.linearDepth,vre=I.linearToneMapping,yre=I.localId,bre=I.globalId,xre=I.log,Sre=I.log2,Cre=I.logarithmicDepthToViewZ,wre=I.loop,Tre=I.luminance,Ere=I.mediumpModelViewMatrix,Dre=I.mat2,Ore=I.mat3,kre=I.mat4,Are=I.matcapUV,jre=I.materialAO,Mre=I.materialAlphaTest,Nre=I.materialAnisotropy,Pre=I.materialAnisotropyVector,Fre=I.materialAttenuationColor,Ire=I.materialAttenuationDistance,Lre=I.materialClearcoat,Rre=I.materialClearcoatNormal,zre=I.materialClearcoatRoughness,Bre=I.materialColor,Vre=I.materialDispersion,Hre=I.materialEmissive,Ure=I.materialIOR,Wre=I.materialIridescence,Gre=I.materialIridescenceIOR,Kre=I.materialIridescenceThickness,qre=I.materialLightMap,Jre=I.materialLineDashOffset,Yre=I.materialLineDashSize,Xre=I.materialLineGapSize,Zre=I.materialLineScale,Qre=I.materialLineWidth,$re=I.materialMetalness,eie=I.materialNormal,tie=I.materialOpacity,nie=I.materialPointSize,rie=I.materialReference,iie=I.materialReflectivity,aie=I.materialRefractionRatio,oie=I.materialRotation,sie=I.materialRoughness,cie=I.materialSheen,lie=I.materialSheenRoughness,uie=I.materialShininess,die=I.materialSpecular,fie=I.materialSpecularColor,pie=I.materialSpecularIntensity,mie=I.materialSpecularStrength,hie=I.materialThickness,gie=I.materialTransmission,MM=I.max,_ie=I.maxMipLevel,vie=I.metalness,yie=I.min,NM=I.mix,bie=I.mixElement,xie=I.mod,Sie=I.modInt,Cie=I.modelDirection,wie=I.modelNormalMatrix,Tie=I.modelPosition,Eie=I.modelRadius,Die=I.modelScale,Oie=I.modelViewMatrix,kie=I.modelViewPosition,Aie=I.modelViewProjection,jie=I.modelWorldMatrix,Mie=I.modelWorldMatrixInverse,Nie=I.morphReference,Pie=I.mrt,PM=I.mul,Fie=I.mx_aastep,Iie=I.mx_cell_noise_float,Lie=I.mx_contrast,Rie=I.mx_fractal_noise_float,zie=I.mx_fractal_noise_vec2,Bie=I.mx_fractal_noise_vec3,Vie=I.mx_fractal_noise_vec4,Hie=I.mx_hsvtorgb,Uie=I.mx_noise_float,Wie=I.mx_noise_vec3,Gie=I.mx_noise_vec4,Kie=I.mx_ramplr,qie=I.mx_ramptb,Jie=I.mx_rgbtohsv,Yie=I.mx_safepower,Xie=I.mx_splitlr,Zie=I.mx_splittb,Qie=I.mx_srgb_texture_to_lin_rec709,$ie=I.mx_transform_uv,eae=I.mx_worley_noise_float,tae=I.mx_worley_noise_vec2,nae=I.mx_worley_noise_vec3,rae=I.namespace,iae=I.negate,aae=I.neutralToneMapping,oae=I.nodeArray,sae=I.nodeImmutable,cae=I.nodeObject,lae=I.nodeObjects,uae=I.nodeProxy,dae=I.normalFlat,fae=I.normalGeometry,pae=I.normalLocal,mae=I.normalMap,hae=I.normalView,gae=I.normalWorld,_ae=I.normalize,vae=I.not,yae=I.notEqual,bae=I.numWorkgroups,xae=I.objectDirection,Sae=I.objectGroup,Cae=I.objectPosition,wae=I.objectRadius,Tae=I.objectScale,Eae=I.objectViewPosition,Dae=I.objectWorldMatrix,Oae=I.oneMinus,kae=I.or,Aae=I.orthographicDepthToViewZ,jae=I.oscSawtooth,Mae=I.oscSine,Nae=I.oscSquare,Pae=I.oscTriangle,Fae=I.output,Iae=I.outputStruct,Lae=I.overlay,Rae=I.overloadingFn,zae=I.parabola,Bae=I.parallaxDirection,Vae=I.parallaxUV,Hae=I.parameter,Uae=I.pass,Wae=I.passTexture,Gae=I.pcurve,Kae=I.perspectiveDepthToViewZ,qae=I.pmremTexture,Jae=I.pointUV,Yae=I.pointWidth,Xae=I.positionGeometry,Zae=I.positionLocal,Qae=I.positionPrevious,$ae=I.positionView,eoe=I.positionViewDirection,toe=I.positionWorld,noe=I.positionWorldDirection,roe=I.posterize,FM=I.pow,ioe=I.pow2,aoe=I.pow3,ooe=I.pow4,IM=I.premult,LM=I.property,RM=I.radians,zM=I.rand,BM=I.range,VM=I.rangeFog,HM=I.rangeFogFactor,UM=I.reciprocal,WM=I.lightProjectionUV,GM=I.reference,KM=I.referenceBuffer,qM=I.reflect,JM=I.reflectVector,YM=I.reflectView,XM=I.reflector,ZM=I.refract,QM=I.refractVector,$M=I.refractView,eN=I.reinhardToneMapping,tN=I.remainder,nN=I.remap,rN=I.remapClamp,iN=I.renderGroup,aN=I.renderOutput,oN=I.rendererReference,sN=I.rotate,cN=I.rotateUV,lN=I.roughness,uN=I.round,dN=I.rtt,fN=I.sRGBTransferEOTF,pN=I.sRGBTransferOETF,mN=I.sampler,hN=I.samplerComparison,gN=I.saturate,_N=I.saturation,vN=I.screen,yN=I.screenCoordinate,bN=I.screenSize,xN=I.screenUV,SN=I.scriptable,CN=I.scriptableValue,wN=I.select,TN=I.setCurrentStack,EN=I.shaderStages,DN=I.shadow,ON=I.pointShadow,kN=I.shadowPositionWorld,AN=I.sharedUniformGroup,jN=I.shapeCircle,MN=I.sheen,NN=I.sheenRoughness,PN=I.shiftLeft,FN=I.shiftRight,IN=I.shininess,LN=I.sign,RN=I.sin,zN=I.sinc,BN=I.skinning,VN=I.smoothstep,HN=I.smoothstepElement,UN=I.specularColor,WN=I.specularF90,GN=I.spherizeUV,KN=I.split,qN=I.spritesheetUV,JN=I.sqrt,YN=I.stack,XN=I.step,ZN=I.storage,QN=I.storageBarrier,$N=I.storageObject,eP=I.storageTexture,tP=I.string,nP=I.struct,rP=I.sub,iP=I.subgroupIndex,aP=I.subgroupSize,oP=I.tan,sP=I.tangentGeometry,cP=I.tangentLocal,lP=I.tangentView,uP=I.tangentWorld,dP=I.temp,fP=I.texture,pP=I.texture3D,mP=I.textureBarrier,hP=I.textureBicubic,gP=I.textureCubeUV,_P=I.textureLoad,vP=I.textureSize,yP=I.textureStore,bP=I.thickness,xP=I.time,SP=I.timerDelta,CP=I.timerGlobal,wP=I.timerLocal,TP=I.toneMapping,EP=I.toneMappingExposure,DP=I.toonOutlinePass,OP=I.transformDirection,kP=I.transformNormal,AP=I.transformNormalToView,jP=I.transformedBentNormalView,MP=I.transformedBitangentView,NP=I.transformedBitangentWorld,PP=I.transformedClearcoatNormalView,FP=I.transformedNormalView,IP=I.transformedNormalWorld,LP=I.transformedTangentView,RP=I.transformedTangentWorld,zP=I.transmission,BP=I.transpose,VP=I.triNoise3D,HP=I.triplanarTexture,UP=I.triplanarTextures,WP=I.trunc,GP=I.tslFn,KP=I.uint,qP=I.uniform,JP=I.uniformCubeTexture,YP=I.uniformArray,XP=I.uniformGroup,ZP=I.uniformTexture,QP=I.uniforms,$P=I.unpremult,eF=I.userData,tF=I.uv,nF=I.uvec2,rF=I.uvec3,iF=I.uvec4,aF=I.Var,oF=I.varying,sF=I.varyingProperty,cF=I.vec2,lF=I.vec3,uF=I.vec4,dF=I.vectorComponents,fF=I.velocity,pF=I.vertexColor,mF=I.vertexIndex,hF=I.vibrance,gF=I.viewZToLogarithmicDepth,_F=I.viewZToOrthographicDepth,vF=I.viewZToPerspectiveDepth,yF=I.viewport,bF=I.viewportBottomLeft,xF=I.viewportCoordinate,SF=I.viewportDepthTexture,CF=I.viewportLinearDepth,wF=I.viewportMipTexture,TF=I.viewportResolution,EF=I.viewportSafeUV,DF=I.viewportSharedTexture,OF=I.viewportSize,kF=I.viewportTexture,AF=I.viewportTopLeft,jF=I.viewportUV,MF=I.wgsl,NF=I.wgslFn,PF=I.workgroupArray,FF=I.workgroupBarrier,IF=I.workgroupId,LF=I.workingToColorSpace,RF=I.xor;function zF(e,t,n=1){let r=e.rgb,i=t.rgb,a=PM(r,i),o=PM(t.a,n),s=NM(r,a,o),c=MM(e.a,PM(t.a,n));return uF(s,c)}function BF(e,t,n=1){let r=PM(t.a,n),i=tM(r,PM(e.a,rP(1,r))),a=tM(PM(t.rgb,r),PM(e.rgb,PM(e.a,rP(1,r))));return uF(a,i)}const VF={normal:BF,multiply:zF};function HF(e,t,n=`normal`,r=1){let i=VF[n]||VF.normal;return i(e,t,r)}function UF(e,t){let n=PM(e.a,t.a);return uF(e.rgb,n)}function WF(e,t){let n=rP(1,t.a),r=PM(e.a,n);return uF(e.rgb,r)}function GF(e,t){let n=lF(.2126,.7152,.0722),r=kM(t.rgb,n),i=PM(e.a,r);return uF(e.rgb,i)}function KF(e,t){let n=lF(.2126,.7152,.0722),r=kM(t.rgb,n),i=rP(1,r),a=PM(e.a,i);return uF(e.rgb,a)}const qF={alpha:UF,alphaInverted:WF,luminance:GF,luminanceInverted:KF};function JF(e,t,n=`alpha`){let r=qF[n]||qF.alpha;return r(e,t)}const YF={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1};let XF=null,ZF=!1;const QF=()=>{try{if(YF!==void 0){let{MODE:e,DEV:t}=YF;return t||e===`development`}if(typeof window<`u`&&window.location){let e=window.location.hostname;return e===`localhost`||e===`127.0.0.1`||e.endsWith(`.local`)||e.includes(`dev.`)||e.startsWith(`dev-`)}return!1}catch{return!1}};function $F(){let e,t,n,r,i,a={nodes:new Map,rootId:null,idToNodeId:new Map},o=null,s=null,c=null,l=!1,u=!1,d=!1,f=null,p=!1,m=!0,h=0,g=0,_=0,v=0,y=8,b=.5,x=.5,S=!1,ee=!1,te=[],ne=!1,re=[],ie=!1,ae=()=>{var e,t,n;return(e=t=(n=window).matchMedia)?.call(n,`(prefers-reduced-motion: reduce)`).matches??!1},oe=(n,i)=>{if(n===h&&i===g)return;let o=performance.now();if(o-_<y)return;h=n,g=i,_=o,e.setSize(n,i,!1);let s=n/i,c=2,l=c*s;t.left=-l/2,t.right=l/2,t.top=c/2,t.bottom=-c/2,t.updateProjectionMatrix(),r.scale.set(l,c,1),a.rootId&&d&&le(),xe().catch(console.warn)},se=n=>{if(!e||!t||!r)return;let i=n[0];if(!i)return;let{width:a,height:o}=i.contentRect,s=Math.round(a),c=Math.round(o);oe(s,c)},ce=e=>{let t=e[0];t&&(p=t.isIntersecting,p?(i&&l&&a.rootId&&le(),m&&Se()):Ce())},le=()=>{if(!a.rootId||!i||ee)return;let e=a.nodes.get(a.rootId);if(e){ee=!0;try{let e=me(a.rootId);e&&i&&(i.fragmentNode=e,i.needsUpdate=!0)}catch(e){console.error(`Error composing shader tree:`,e)}finally{ee=!1}p&&xe()}},ue=e=>{let t=[];return a.nodes.forEach(n=>{n.parentId===e&&t.push(n)}),t},de=e=>{for(let[t,n]of a.nodes.entries())if(n.metadata.id===e)return t;return null},fe=(e,t,n,r)=>{var i,a;if(!(i=a=t.metadata.mask)?.source)return e;let o=t.metadata.mask.source,s=de(o);if(!s)return e;if(r.has(s))return console.error(`Uh oh, looks like you've got a circular dependency in your shader masks.`),e;let c=new Set(r);c.add(n);let l=me(s,c),u=t.metadata.mask.type||`alpha`;return JF(e,l,u)},pe=e=>{var t,n;let r=a.nodes.get(e);if(!r||!r.metadata.id)return!1;let i=r.metadata.id;for(let e of a.nodes.values())if((t=n=e.metadata.mask)?.source===i)return!0;return!1},me=(e,t=new Set)=>{let n=a.nodes.get(e);if(!n)return uF(0,0,0,0);let r=e=>{n.cleanupCallbacks.push(e)},i=e=>{n.beforeRenderCallbacks.push(e)},o=e=>{n.afterRenderCallbacks.push(e)},s=ue(e);if(s.length===0){let a=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:void 0,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:XF});return fe(a,n,e,t)}else{let a=[...s].sort((e,t)=>e.metadata.renderOrder-t.metadata.renderOrder),u=n.parentId===null;if(u){let s;for(let e of a){var c;if(e.metadata.opacity===0&&!pe(e.id))continue;let n=me(e.id,t),r=((c=e.uniforms)==null||(c=c.opacity)==null||(c=c.uniform)==null?void 0:c.value)>0,i=pe(e.id)&&!r?0:e.metadata.opacity;s=s===void 0?n:HF(s,n,e.metadata.blendMode,i)}let l=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:s,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:XF});return fe(l,n,e,t)}else{let s;for(let e of a){var l;let n=me(e.id,t);if(e.metadata.opacity===0&&!pe(e.id))continue;let r=((l=e.uniforms)==null||(l=l.opacity)==null||(l=l.uniform)==null?void 0:l.value)>0,i=pe(e.id)&&!r?0:e.metadata.opacity;s=s===void 0?n:HF(s,n,e.metadata.blendMode,i)}let c=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:s,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:XF});return fe(c,n,e,t)}}},he=(e,t,n,r,o={})=>{let s=0;if(n!==null){let e=Array.from(a.nodes.values()).filter(e=>e.parentId===n);e.length>0&&(s=Math.max(...e.map(e=>e.metadata.renderOrder))+1)}let c={id:e,fragmentNodeFunc:t,parentId:n,metadata:{blendMode:r?.blendMode||`normal`,opacity:r?.opacity===void 0?1:r?.opacity,id:r?.id,mask:r?.mask,renderOrder:r?.renderOrder===void 0?s:r?.renderOrder},uniforms:o,cleanupCallbacks:[],beforeRenderCallbacks:[],afterRenderCallbacks:[]};a.nodes.set(e,c),n===null&&(a.rootId=e),i&&l&&(te.includes(e)||te.push(e),ne||(ne=!0,queueMicrotask(()=>{ne=!1,te=[],le()})))},ge=(e,t,n)=>{let r=a.nodes.get(e);if(!r||!r.uniforms){console.warn(`Node or uniforms not found for ID: ${e}`);return}let i=r.uniforms[t];if(!i||!i.uniform){console.warn(`Uniform ${t} not found in node: ${e}`);return}i.uniform.value=n,p&&xe()},_e=(e,t)=>{var n,r,o,s,c,u,d,f;let m=a.nodes.get(e);if(!m)return;let h=!1;t.blendMode!==void 0&&m.metadata.blendMode!==t.blendMode&&(m.metadata.blendMode=t.blendMode,h=!0),t.opacity!==void 0&&m.metadata.opacity!==t.opacity&&(m.metadata.opacity=t.opacity,h=!0),t.renderOrder!==void 0&&m.metadata.renderOrder!==t.renderOrder&&(m.metadata.renderOrder=t.renderOrder,h=!0),t.id!==void 0&&m.metadata.id!==t.id&&(m.metadata.id=t.id,h=!0),t.mask!==void 0&&((n=c=m.metadata.mask)?.source!==(r=u=t.mask)?.source||(o=d=m.metadata.mask)?.type!==(s=f=t.mask)?.type)&&(m.metadata.mask=t.mask,h=!0),h&&i&&l?(re.includes(e)||re.push(e),ie||(ie=!0,queueMicrotask(()=>{ie=!1,re=[],le()}))):p&&xe()},ve=e=>{if(!a.nodes.has(e))return;let t=a.nodes.get(e);if(t&&t.cleanupCallbacks.length>0)for(let n of t.cleanupCallbacks)try{n()}catch(t){console.error(`Error executing cleanup callback for node ${e}:`,t)}let n=ue(e);for(let e of n)ve(e.id);a.rootId===e&&(a.rootId=null),a.nodes.delete(e),i&&l&&le()},ye=e=>{let t={deltaTime:e,pointer:{x:b,y:x},pointerActive:S,dimensions:{width:h,height:g}};for(let e of a.nodes.values())if(e.beforeRenderCallbacks.length>0)for(let n of e.beforeRenderCallbacks)try{n(t)}catch(t){console.error(`Error executing before render callback for node ${e.id}:`,t)}},be=e=>{let t={deltaTime:e,pointer:{x:b,y:x},pointerActive:S,dimensions:{width:h,height:g}};for(let e of a.nodes.values())if(e.afterRenderCallbacks.length>0)for(let n of e.afterRenderCallbacks)try{n(t)}catch(t){console.error(`Error executing after render callback for node ${e.id}:`,t)}},xe=async()=>{if(!l||!e||!n||!t||!i)return;let r=performance.now(),a=v>0?(r-v)/1e3:.016,o=Math.min(a,.1);v=r,ye(o);try{if(ee)return;e instanceof bj?await e.renderAsync(n,t).then(()=>{l&&be(o)}).catch(e=>{console.error(`WebGPU render error:`,e)}):(e.render(n,t),be(o))}catch(e){console.error(`Render frame error:`,e)}},Se=()=>{if(o||!m||!p)return;let e=()=>{o=requestAnimationFrame(e),xe()};e()},Ce=()=>{o&&(cancelAnimationFrame(o),o=null)},we=e=>{if(!XF)return;let t,n;if(`touches`in e){if(e.touches.length===0)return;t=e.touches[0].clientX,n=e.touches[0].clientY}else t=e.clientX,n=e.clientY;let r=XF.getBoundingClientRect(),i=(t-r.left)/r.width,a=(n-r.top)/r.height;b=i,x=a},Te=e=>{we(e)},Ee=e=>{we(e)},De=()=>{S=!1,xe()},Oe=()=>{S=!1,xe()},ke=async({canvas:a})=>{if(l||u)return;u=!0,f=new AbortController;let o=f;try{if(XF=a,n=new xo,n.background=null,t=new Ms(-1,1,1,-1,.1,10),t.position.z=1,t.lookAt(0,0,0),window.addEventListener(`mousemove`,Te),window.addEventListener(`touchmove`,Ee),a.addEventListener(`mousedown`,()=>{S=!0,xe()}),a.addEventListener(`touchstart`,()=>{S=!0,xe()}),window.addEventListener(`mouseup`,De),window.addEventListener(`touchend`,Oe),o.signal.aborted)return;try{if(e=new bj({canvas:a,antialias:!0,alpha:!0,depth:!1,powerPreference:`high-performance`}),await e.init(),o.signal.aborted){e.dispose();return}}catch(e){if(o.signal.aborted)return;console.error(`[Shaders] WebGPU initialization error:`,e);return}if(o.signal.aborted){e&&e.dispose();return}e.setPixelRatio(Math.min(window.devicePixelRatio,2)),e.outputColorSpace=gn,i=new dv({transparent:!0}),i.fragmentNode=uF(0,0,0,0);let u=new Uo(2,2);r=new Qa(u,i),n.add(r),s=new ResizeObserver(se),s.observe(a),c=new IntersectionObserver(ce,{threshold:0}),c.observe(a),m=!ae();let{width:f,height:h}=a.getBoundingClientRect();oe(Math.round(f),Math.round(h)),d=!0,await xe(),m&&p&&Se(),o.signal.aborted||(l=!0)}catch(e){console.error(`[Shaders] Initialization error:`,e)}finally{u=!1,f===o&&(f=null)}},Ae=()=>{!QF()||ZF||(console.warn(`Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production.`),ZF=!0)},je=()=>{if(f&&f.abort(),s&&(s.disconnect(),s=null),c&&(c.disconnect(),c=null),XF&&(XF.removeEventListener(`mousedown`,()=>{S=!0}),XF.removeEventListener(`touchstart`,()=>{S=!0})),window&&(window.removeEventListener(`mousemove`,Te),window.removeEventListener(`touchmove`,Ee),window.removeEventListener(`mouseup`,De),window.removeEventListener(`touchend`,Oe)),Ce(),a.nodes.clear(),a.rootId=null,a.idToNodeId.clear(),te=[],ne=!1,re=[],ie=!1,r&&(n&&n.remove(r),r.geometry&&r.geometry.dispose(),r.material instanceof ya&&r.material.dispose()),e)try{e.dispose()}catch(e){console.warn(`Error disposing renderer:`,e)}XF=null,e=null,t=null,n=null,r=null,i=null,l=!1,u=!1,d=!1,f=null,h=0,g=0,p=!1,m=!0,b=.5,x=.5,S=!1};return{initialize:ke,cleanup:je,registerNode:he,removeNode:ve,updateUniformValue:ge,updateNodeMetadata:_e,showLicenseWarning:Ae}}const{uniform:eI}=xj;function tI(e,t,n){let r={};return Object.entries(e.props).forEach(([e,i])=>{let a=t[e],o=a;i.transform&&(o=i.transform(a)),r[e]={uniform:eI(o).label(`${e}_${n}`),transform:i.transform||void 0}}),r}const{vec2:nI,fract:rI,sin:soe,dot:iI}=xj,aI=e=>rI(soe(iI(e,nI(12.12345,78.12345))).mul(40000.12345)),coe=(e=.03)=>t=>aI(t).mul(e).mul(.10012345),{vec2:oI}=xj,loe=(e=oI(0),t=.02,n=1,r=1)=>{let{vec2:i,sin:a,cos:o,time:s}=xj,c=r*1.618033988749895,l=r*2.718281828459045,u=(Math.sin(r)+2)*5,d=(Math.cos(r)+2)*5,f=i(a(e.x.mul(n).mul(u).add(s.mul(.1)).add(c)),o(e.y.mul(n).mul(u).add(s.mul(.1)).add(l))),p=i(a(e.y.mul(n).mul(d).add(s.mul(.05)).add(l)),o(e.x.mul(n).mul(d).add(s.mul(.05)).add(c))),m=f.add(p).mul(t);return e.add(m)},uoe=(e,t,n=.6,r=.3,i=1)=>{let{max:a,smoothstep:o,vec4:s}=xj,c=a(a(e.r,e.g),e.b),l=o(n,n+r,c).mul(i).mul(1),u=e.rgb.add(t.rgb.mul(l));return s(u,e.a)},doe=(e={})=>{let{inset:t=.4,softness:n=.5,offsetX:r=0,offsetY:i=0}=e,{float:a,smoothstep:o,uv:s}=xj,c=s(),l=c.x.sub(.5).sub(a(r)).mul(2),u=c.y.sub(.5).add(a(i)).mul(2),d=l.mul(l).add(u.mul(u)).sqrt();return a(1).sub(o(a(1).sub(a(t)),a(1).sub(a(t)).add(a(n)),d.mul(a(1).add(a(n)))))};var sI=function(exports){"use strict";function t(e){"@babel/helpers - typeof";return t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t(e)}function n(e,n){if(t(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(t(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function r(e){var r=n(e,`string`);return t(r)==`symbol`?r:r+``}function i(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return exports.defineProperty=i,exports}({}),cI,lI;function uI(e,t){let n=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let r=t[0].length,i=t[0].map((e,n)=>t.map(e=>e[n])),a=e.map(e=>i.map(t=>{let n=0;if(!Array.isArray(e)){for(let r of t)n+=e*r;return n}for(let r=0;r<e.length;r++)n+=e[r]*(t[r]||0);return n}));return n===1&&(a=a[0]),r===1?a.map(e=>e[0]):a}function dI(e){return fI(e)===`string`}function fI(e){let t=Object.prototype.toString.call(e);return(t.match(/^\[object\s+(.*?)\]$/)[1]||``).toLowerCase()}function pI(e,{precision:t,unit:n}){return mI(e)?`none`:gI(e,t)+(n??``)}function mI(e){return Number.isNaN(e)||e instanceof Number&&e?.none}function hI(e){return mI(e)?0:e}function gI(e,t){if(e===0)return 0;let n=~~e,r=0;n&&t&&(r=~~Math.log10(Math.abs(n))+1);let i=10**(t-r);return Math.floor(e*i+.5)/i}const _I={deg:1,grad:.9,rad:180/Math.PI,turn:360};function vI(e){if(!e)return;e=e.trim();let t=/^([a-z]+)\((.+?)\)$/i,n=/^-?[\d.]+$/,r=/%|deg|g?rad|turn$/,i=/\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g,a=e.match(t);if(a){let e=[];return a[2].replace(i,(t,i)=>{let a=i.match(r),o=i;if(a){let e=a[0],t=o.slice(0,-e.length);e===`%`?(o=new Number(t/100),o.type=`<percentage>`):(o=new Number(t*_I[e]),o.type=`<angle>`,o.unit=e)}else n.test(o)?(o=new Number(o),o.type=`<number>`):o===`none`&&(o=new Number(NaN),o.none=!0);t.startsWith(`/`)&&(o=o instanceof Number?o:new Number(o),o.alpha=!0),typeof o==`object`&&o instanceof Number&&(o.raw=i),e.push(o)}),{name:a[1].toLowerCase(),rawName:a[1],rawArgs:a[2],args:e}}}function yI(e){return e[e.length-1]}function bI(e,t,n){return isNaN(e)?t:isNaN(t)?e:e+(t-e)*n}function xI(e,t,n){return(n-e)/(t-e)}function SI(e,t,n){return bI(t[0],t[1],xI(e[0],e[1],n))}function CI(e){return e.map(e=>e.split(`|`).map(e=>{e=e.trim();let t=e.match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);if(t){let e=new String(t[1]);return e.range=[+t[2],+t[3]],e}return e}))}function wI(e,t,n){return Math.max(Math.min(n,t),e)}function TI(e,t){return Math.sign(e)===Math.sign(t)?e:-e}function EI(e,t){return TI(Math.abs(e)**t,e)}function DI(e,t){return t===0?0:e/t}function OI(e,t,n=0,r=e.length){for(;n<r;){let i=n+r>>1;e[i]<t?n=i+1:r=i}return n}var kI=Object.freeze({__proto__:null,bisectLeft:OI,clamp:wI,copySign:TI,interpolate:bI,interpolateInv:xI,isNone:mI,isString:dI,last:yI,mapRange:SI,multiplyMatrices:uI,parseCoordGrammar:CI,parseFunction:vI,serializeNumber:pI,skipNone:hI,spow:EI,toPrecision:gI,type:fI,zdiv:DI}),AI=class{add(e,t,n){if(typeof arguments[0]!=`string`){for(var e in arguments[0])this.add(e,arguments[0][e],arguments[1]);return}(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][n?`unshift`:`push`](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}};const jI=new AI;var MI={gamut_mapping:`css`,precision:5,deltaE:`76`,verbose:((cI=globalThis)==null||(cI=cI.process)==null||(cI=cI.env)==null||(cI=cI.NODE_ENV)==null?void 0:cI.toLowerCase())!==`test`,warn:function(e){var t,n;this.verbose&&((t=globalThis)==null||(t=t.console)==null||(n=t.warn)==null||n.call(t,e))}};const NI={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function PI(e){return Array.isArray(e)?e:NI[e]}function FI(e,t,n,r={}){if(e=PI(e),t=PI(t),!e||!t)throw TypeError(`Missing white point to convert ${e?``:`from`}${!e&&!t?`/`:``}${t?``:`to`}`);if(e===t)return n;let i={W1:e,W2:t,XYZ:n,options:r};if(jI.run(`chromatic-adaptation-start`,i),i.M||(i.W1===NI.D65&&i.W2===NI.D50?i.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:i.W1===NI.D50&&i.W2===NI.D65&&(i.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),jI.run(`chromatic-adaptation-end`,i),i.M)return uI(i.M,i.XYZ);throw TypeError(`Only Bradford CAT with white points D50 and D65 supported for now.`)}const II=new Set([`<number>`,`<percentage>`,`<angle>`]);function LI(e,t,n,r){let i=Object.entries(e.coords).map(([e,i],a)=>{let o=t.coordGrammar[a],s=r[a],c=s?.type,l;if(l=s.none?o.find(e=>II.has(e)):o.find(e=>e==c),!l){let t=i.name||e;throw TypeError(`${c??s.raw} not allowed for ${t} in ${n}()`)}let u=l.range;c===`<percentage>`&&(u||=[0,1]);let d=i.range||i.refRange;return u&&d&&(r[a]=SI(u,d,r[a])),l});return i}function RI(e,{meta:t}={}){var n,r;let i={str:(n=r=String(e))?.trim()};if(jI.run(`parse-start`,i),i.color)return i.color;if(i.parsed=vI(i.str),i.parsed){let e=i.parsed.name;if(e===`color`){let e=i.parsed.args.shift(),n=e.startsWith(`--`)?e.substring(2):`--${e}`,r=[e,n],c=i.parsed.rawArgs.indexOf(`/`)>0?i.parsed.args.pop():1;for(let n of VI.all){let s=n.getFormat(`color`);if(s){var a,o;if(r.includes(s.id)||(a=o=s.ids)?.filter(e=>r.includes(e)).length){let r=Object.keys(n.coords).map((e,t)=>i.parsed.args[t]||0),a;return s.coordGrammar&&(a=LI(n,s,`color`,r)),t&&Object.assign(t,{formatId:`color`,types:a}),s.id.startsWith(`--`)&&!e.startsWith(`--`)&&MI.warn(`${n.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${s.id}) instead of color(${e}).`),e.startsWith(`--`)&&!s.id.startsWith(`--`)&&MI.warn(`${n.name} is a standard space and supported in the CSS spec. Use color(${s.id}) instead of prefixed color(${e}).`),{spaceId:n.id,coords:r,alpha:c}}}}let l=``,u=e in VI.registry?e:n;if(u in VI.registry){var s;let e=(s=VI.registry[u].formats)==null||(s=s.color)==null?void 0:s.id;e&&(l=`Did you mean color(${e})?`)}throw TypeError(`Cannot parse color(${e}). `+(l||`Missing a plugin?`))}else for(let n of VI.all){let r=n.getFormat(e);if(r&&r.type===`function`){let a=1;(r.lastAlpha||yI(i.parsed.args).alpha)&&(a=i.parsed.args.pop());let o=i.parsed.args,s;return r.coordGrammar&&(s=LI(n,r,e,o)),t&&Object.assign(t,{formatId:r.name,types:s}),{spaceId:n.id,coords:o,alpha:a}}}}else for(let e of VI.all)for(let n in e.formats){let r=e.formats[n];if(r.type!==`custom`||r.test&&!r.test(i.str))continue;let a=r.parse(i.str);if(a)return a.alpha??=1,t&&(t.formatId=n),a}throw TypeError(`Could not parse ${e} as a color. Missing a plugin?`)}function zI(e){if(Array.isArray(e))return e.map(zI);if(!e)throw TypeError(`Empty color reference`);dI(e)&&(e=RI(e));let t=e.space||e.spaceId;return t instanceof VI||(e.space=VI.get(t)),e.alpha===void 0&&(e.alpha=1),e}const BI=75e-6;var VI=(lI=class e{constructor(t){var n,r;this.id=t.id,this.name=t.name,this.base=t.base?e.get(t.base):null,this.aliases=t.aliases,this.base&&(this.fromBase=t.fromBase,this.toBase=t.toBase);let i=t.coords??this.base.coords;for(let e in i)`name`in i[e]||(i[e].name=e);this.coords=i;let a=t.white??this.base.white??`D65`;for(let e in this.white=PI(a),this.formats=t.formats??{},this.formats){let t=this.formats[e];t.type||=`function`,t.name||=e}(n=r=this.formats.color)?.id||(this.formats.color={...this.formats.color??{},id:t.cssId||this.id}),t.gamutSpace?this.gamutSpace=t.gamutSpace===`self`?this:e.get(t.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(e,t)=>!0),this.referred=t.referred,Object.defineProperty(this,`path`,{value:HI(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),jI.run(`colorspace-init-end`,this)}inGamut(e,{epsilon:t=BI}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:t});let n=Object.values(this.coords);return e.every((e,r)=>{let i=n[r];if(i.type!==`angle`&&i.range){if(Number.isNaN(e))return!0;let[n,r]=i.range;return(n===void 0||e>=n-t)&&(r===void 0||e<=r+t)}return!0})}get isUnbounded(){return Object.values(this.coords).every(e=>!(`range`in e))}get cssId(){var e;return((e=this.formats)==null||(e=e.color)==null?void 0:e.id)||this.id}get isPolar(){for(let e in this.coords)if(this.coords[e].type===`angle`)return!0;return!1}getFormat(e){if(typeof e==`object`)return e=UI(e,this),e;let t;return t=e===`default`?Object.values(this.formats)[0]:this.formats[e],t?(t=UI(t,this),t):null}equals(e){return e?this===e||this.id===e||this.id===e.id:!1}to(t,n){if(arguments.length===1){let e=zI(t);[t,n]=[e.space,e.coords]}if(t=e.get(t),this.equals(t))return n;n=n.map(e=>Number.isNaN(e)?0:e);let r=this.path,i=t.path,a,o;for(let e=0;e<r.length&&r[e].equals(i[e]);e++)a=r[e],o=e;if(!a)throw Error(`Cannot convert between color spaces ${this} and ${t}: no connection space was found`);for(let e=r.length-1;e>o;e--)n=r[e].toBase(n);for(let e=o+1;e<i.length;e++)n=i[e].fromBase(n);return n}from(t,n){if(arguments.length===1){let e=zI(t);[t,n]=[e.space,e.coords]}return t=e.get(t),t.to(this,n)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let t in this.coords){let n=this.coords[t],r=n.range||n.refRange;e.push(r?.min??0)}return e}static get all(){return[...new Set(Object.values(e.registry))]}static register(e,t){if(arguments.length===1&&(t=arguments[0],e=t.id),t=this.get(t),this.registry[e]&&this.registry[e]!==t)throw Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=t,arguments.length===1&&t.aliases)for(let e of t.aliases)this.register(e,t);return t}static get(t,...n){if(!t||t instanceof e)return t;let r=fI(t);if(r===`string`){let n=e.registry[t.toLowerCase()];if(!n)throw TypeError(`No color space found with id = "${t}"`);return n}if(n.length)return e.get(...n);throw TypeError(`${t} is not a valid color space`)}static resolveCoord(t,n){let r=fI(t),i,a;if(r===`string`?t.includes(`.`)?[i,a]=t.split(`.`):[i,a]=[,t]:Array.isArray(t)?[i,a]=t:(i=t.space,a=t.coordId),i=e.get(i),i||=n,!i)throw TypeError(`Cannot resolve coordinate reference ${t}: No color space specified and relative references are not allowed here`);if(r=fI(a),r===`number`||r===`string`&&a>=0){let e=Object.entries(i.coords)[a];if(e)return{space:i,id:e[0],index:a,...e[1]}}i=e.get(i);let o=a.toLowerCase(),s=0;for(let e in i.coords){var c,l;let t=i.coords[e];if(e.toLowerCase()===o||(c=l=t.name)?.toLowerCase()===o)return{space:i,id:e,index:s,...t};s++}throw TypeError(`No "${a}" coordinate found in ${i.name}. Its coordinates are: ${Object.keys(i.coords).join(`, `)}`)}},sI.defineProperty(lI,`registry`,{}),sI.defineProperty(lI,`DEFAULT_FORMAT`,{type:`functions`,name:`color`}),lI);function HI(e){let t=[e];for(let n=e;n=n.base;)t.push(n);return t}function UI(e,{coords:t}={}){if(e.coords&&!e.coordGrammar){e.type||=`function`,e.name||=`color`,e.coordGrammar=CI(e.coords);let n=Object.entries(t).map(([t,n],r)=>{let i=e.coordGrammar[r][0],a=n.range||n.refRange,o=i.range,s=``;return i==`<percentage>`?(o=[0,100],s=`%`):i==`<angle>`&&(s=`deg`),{fromRange:a,toRange:o,suffix:s}});e.serializeCoords=(e,t)=>e.map((e,r)=>{let{fromRange:i,toRange:a,suffix:o}=n[r];return i&&a&&(e=SI(i,a,e)),e=pI(e,{precision:t,unit:o}),e})}return e}var WI=new VI({id:`xyz-d65`,name:`XYZ D65`,coords:{x:{name:`X`},y:{name:`Y`},z:{name:`Z`}},white:`D65`,formats:{color:{ids:[`xyz-d65`,`xyz`]}},aliases:[`xyz`]}),GI=class extends VI{constructor(e){e.coords||={r:{range:[0,1],name:`Red`},g:{range:[0,1],name:`Green`},b:{range:[0,1],name:`Blue`}},e.base||=WI,e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??=t=>{let n=uI(e.toXYZ_M,t);return this.white!==this.base.white&&(n=FI(this.white,this.base.white,n)),n},e.fromBase??=t=>(t=FI(this.base.white,this.white,t),uI(e.fromXYZ_M,t))),e.referred??=`display`,super(e)}};function KI(e,t){return e=zI(e),!t||e.space.equals(t)?e.coords.slice():(t=VI.get(t),t.from(e))}function qI(e,t){e=zI(e);let{space:n,index:r}=VI.resolveCoord(t,e.space),i=KI(e,n);return i[r]}function JI(e,t,n){return e=zI(e),t=VI.get(t),e.coords=t.to(e.space,n),e}JI.returns=`color`;function YI(e,t,n){if(e=zI(e),arguments.length===2&&fI(arguments[1])===`object`){let t=arguments[1];for(let n in t)YI(e,n,t[n])}else{typeof n==`function`&&(n=n(qI(e,t)));let{space:r,index:i}=VI.resolveCoord(t,e.space),a=KI(e,r);a[i]=n,JI(e,r,a)}return e}YI.returns=`color`;var XI=new VI({id:`xyz-d50`,name:`XYZ D50`,white:`D50`,base:WI,fromBase:e=>FI(WI.white,`D50`,e),toBase:e=>FI(`D50`,WI.white,e)});const ZI=216/24389,QI=24/116,$I=24389/27;let eL=NI.D50;var tL=new VI({id:`lab`,name:`Lab`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:eL,base:XI,fromBase(e){let t=e.map((e,t)=>e/eL[t]),n=t.map(e=>e>ZI?Math.cbrt(e):($I*e+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(e){let t=[];t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200;let n=[t[0]>QI?t[0]**3:(116*t[0]-16)/$I,e[0]>8?((e[0]+16)/116)**3:e[0]/$I,t[2]>QI?t[2]**3:(116*t[2]-16)/$I];return n.map((e,t)=>e*eL[t])},formats:{lab:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function nL(e){return(e%360+360)%360}function rL(e,t){if(e===`raw`)return t;let[n,r]=t.map(nL),i=r-n;return e===`increasing`?i<0&&(r+=360):e===`decreasing`?i>0&&(n+=360):e===`longer`?-180<i&&i<180&&(i>0?n+=360:r+=360):e===`shorter`&&(i>180?n+=360:i<-180&&(r+=360)),[n,r]}var iL=new VI({id:`lch`,name:`LCH`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,150],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:tL,fromBase(e){let[t,n,r]=e,i,a=.02;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),nL(i)]},toBase(e){let[t,n,r]=e;return n<0&&(n=0),isNaN(r)&&(r=0),[t,n*Math.cos(r*Math.PI/180),n*Math.sin(r*Math.PI/180)]},formats:{lch:{coords:[`<number> | <percentage>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const aL=25**7,oL=Math.PI,sL=180/oL,cL=oL/180;function lL(e){let t=e*e,n=t*t*t*e;return n}function uL(e,t,{kL:n=1,kC:r=1,kH:i=1}={}){[e,t]=zI([e,t]);let[a,o,s]=tL.from(e),c=iL.from(tL,[a,o,s])[1],[l,u,d]=tL.from(t),f=iL.from(tL,[l,u,d])[1];c<0&&(c=0),f<0&&(f=0);let p=(c+f)/2,m=lL(p),h=.5*(1-Math.sqrt(m/(m+aL))),g=(1+h)*o,_=(1+h)*u,v=Math.sqrt(g**2+s**2),y=Math.sqrt(_**2+d**2),b=g===0&&s===0?0:Math.atan2(s,g),x=_===0&&d===0?0:Math.atan2(d,_);b<0&&(b+=2*oL),x<0&&(x+=2*oL),b*=sL,x*=sL;let S=l-a,ee=y-v,te=x-b,ne=b+x,re=Math.abs(te),ie;v*y===0?ie=0:re<=180?ie=te:te>180?ie=te-360:te<-180?ie=te+360:MI.warn(`the unthinkable has happened`);let ae=2*Math.sqrt(y*v)*Math.sin(ie*cL/2),oe=(a+l)/2,se=(v+y)/2,ce=lL(se),le;le=v*y===0?ne:re<=180?ne/2:ne<360?(ne+360)/2:(ne-360)/2;let ue=(oe-50)**2,de=1+.015*ue/Math.sqrt(20+ue),fe=1+.045*se,pe=1;pe-=.17*Math.cos((le-30)*cL),pe+=.24*Math.cos(2*le*cL),pe+=.32*Math.cos((3*le+6)*cL),pe-=.2*Math.cos((4*le-63)*cL);let me=1+.015*se*pe,he=30*Math.exp(-1*((le-275)/25)**2),ge=2*Math.sqrt(ce/(ce+aL)),_e=-1*Math.sin(2*he*cL)*ge,ve=(S/(n*de))**2;return ve+=(ee/(r*fe))**2,ve+=(ae/(i*me))**2,ve+=_e*(ee/(r*fe))*(ae/(i*me)),Math.sqrt(ve)}const dL=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],fL=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],pL=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],mL=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var hL=new VI({id:`oklab`,name:`Oklab`,coords:{l:{refRange:[0,1],name:`Lightness`},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:`D65`,base:WI,fromBase(e){let t=uI(dL,e),n=t.map(e=>Math.cbrt(e));return uI(pL,n)},toBase(e){let t=uI(mL,e),n=t.map(e=>e**3);return uI(fL,n)},formats:{oklab:{coords:[`<percentage> | <number>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function gL(e,t){[e,t]=zI([e,t]);let[n,r,i]=hL.from(e),[a,o,s]=hL.from(t),c=n-a,l=r-o,u=i-s;return Math.sqrt(c**2+l**2+u**2)}const _L=75e-6;function vL(e,t,{epsilon:n=_L}={}){e=zI(e),t||=e.space,t=VI.get(t);let r=e.coords;return t!==e.space&&(r=t.from(e)),t.inGamut(r,{epsilon:n})}function yL(e){return{space:e.space,coords:e.coords.slice(),alpha:e.alpha}}function bL(e,t,n=`lab`){n=VI.get(n);let r=n.from(e),i=n.from(t);return Math.sqrt(r.reduce((e,t,n)=>{let r=i[n];return isNaN(t)||isNaN(r)?e:e+(r-t)**2},0))}function xL(e,t){return bL(e,t,`lab`)}const SL=Math.PI,CL=SL/180;function wL(e,t,{l:n=2,c:r=1}={}){[e,t]=zI([e,t]);let[i,a,o]=tL.from(e),[,s,c]=iL.from(tL,[i,a,o]),[l,u,d]=tL.from(t),f=iL.from(tL,[l,u,d])[1];s<0&&(s=0),f<0&&(f=0);let p=i-l,m=s-f,h=a-u,g=o-d,_=h**2+g**2-m**2,v=.511;i>=16&&(v=.040975*i/(1+.01765*i));let y=.0638*s/(1+.0131*s)+.638,b;Number.isNaN(c)&&(c=0),b=c>=164&&c<=345?.56+Math.abs(.2*Math.cos((c+168)*CL)):.36+Math.abs(.4*Math.cos((c+35)*CL));let x=s**4,S=Math.sqrt(x/(x+1900)),ee=y*(S*b+1-S),te=(p/(n*v))**2;return te+=(m/(r*y))**2,te+=_/ee**2,Math.sqrt(te)}const TL=203;var EL=new VI({id:`xyz-abs-d65`,cssId:`--xyz-abs-d65`,name:`Absolute XYZ D65`,coords:{x:{refRange:[0,9504.7],name:`Xa`},y:{refRange:[0,1e4],name:`Ya`},z:{refRange:[0,10888.3],name:`Za`}},base:WI,fromBase(e){return e.map(e=>Math.max(e*TL,0))},toBase(e){return e.map(e=>Math.max(e/TL,0))}});const DL=1.15,OL=.66,kL=2610/2**14,AL=2**14/2610,jL=3424/2**12,ML=2413/2**7,NL=2392/2**7,PL=1.7*2523/2**5,FL=2**5/(1.7*2523),IL=-.56,LL=16295499532821565e-27,RL=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],zL=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],BL=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],VL=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var HL=new VI({id:`jzazbz`,name:`Jzazbz`,coords:{jz:{refRange:[0,1],name:`Jz`},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:EL,fromBase(e){let[t,n,r]=e,i=DL*t-(DL-1)*r,a=OL*n-(OL-1)*t,o=uI(RL,[i,a,r]),s=o.map(function(e){let t=jL+ML*(e/1e4)**kL,n=1+NL*(e/1e4)**kL;return(t/n)**PL}),[c,l,u]=uI(BL,s),d=(1+IL)*c/(1+IL*c)-LL;return[d,l,u]},toBase(e){let[t,n,r]=e,i=(t+LL)/(1+IL-IL*(t+LL)),a=uI(VL,[i,n,r]),o=a.map(function(e){let t=jL-e**FL,n=NL*e**FL-ML,r=1e4*(t/n)**AL;return r}),[s,c,l]=uI(zL,o),u=(s+(DL-1)*l)/DL,d=(c+(OL-1)*u)/OL;return[u,d,l]},formats:{color:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),UL=new VI({id:`jzczhz`,name:`JzCzHz`,coords:{jz:{refRange:[0,1],name:`Jz`},cz:{refRange:[0,1],name:`Chroma`},hz:{refRange:[0,360],type:`angle`,name:`Hue`}},base:HL,fromBase(e){let[t,n,r]=e,i,a=2e-4;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),nL(i)]},toBase(e){return[e[0],e[1]*Math.cos(e[2]*Math.PI/180),e[1]*Math.sin(e[2]*Math.PI/180)]}});function WL(e,t){[e,t]=zI([e,t]);let[n,r,i]=UL.from(e),[a,o,s]=UL.from(t),c=n-a,l=r-o;Number.isNaN(i)&&Number.isNaN(s)?(i=0,s=0):Number.isNaN(i)?i=s:Number.isNaN(s)&&(s=i);let u=i-s,d=2*Math.sqrt(r*o)*Math.sin(u/2*(Math.PI/180));return Math.sqrt(c**2+l**2+d**2)}const GL=3424/4096,KL=2413/128,qL=2392/128,JL=2610/16384,YL=2523/32,XL=16384/2610,ZL=32/2523,QL=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],$L=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],eR=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],tR=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var nR=new VI({id:`ictcp`,name:`ICTCP`,coords:{i:{refRange:[0,1],name:`I`},ct:{refRange:[-.5,.5],name:`CT`},cp:{refRange:[-.5,.5],name:`CP`}},base:EL,fromBase(e){let t=uI(QL,e);return rR(t)},toBase(e){let t=iR(e);return uI(tR,t)}});function rR(e){let t=e.map(function(e){let t=GL+KL*(e/1e4)**JL,n=1+qL*(e/1e4)**JL;return(t/n)**YL});return uI($L,t)}function iR(e){let t=uI(eR,e),n=t.map(function(e){let t=Math.max(e**ZL-GL,0),n=KL-qL*e**ZL;return 1e4*(t/n)**XL});return n}function aR(e,t){[e,t]=zI([e,t]);let[n,r,i]=nR.from(e),[a,o,s]=nR.from(t);return 720*Math.sqrt((n-a)**2+.25*(r-o)**2+(i-s)**2)}const oR=NI.D65,sR=.42,cR=1/sR,lR=2*Math.PI,uR=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],dR=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],fR=[[460,451,288],[460,-891,-261],[460,-220,-6300]],pR={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},mR={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},hR=180/Math.PI,gR=Math.PI/180;function _R(e,t){let n=e.map(e=>{let n=EI(t*Math.abs(e)*.01,sR);return 400*TI(n,e)/(n+27.13)});return n}function vR(e,t){let n=100/t*27.13**cR;return e.map(e=>{let t=Math.abs(e);return TI(n*EI(t/(400-t),cR),e)})}function yR(e){let t=nL(e);t<=mR.h[0]&&(t+=360);let n=OI(mR.h,t)-1,[r,i]=mR.h.slice(n,n+2),[a,o]=mR.e.slice(n,n+2),s=mR.H[n],c=(t-r)/a;return s+100*c/(c+(i-t)/o)}function bR(e){let t=(e%400+400)%400,n=Math.floor(.01*t);t%=100;let[r,i]=mR.h.slice(n,n+2),[a,o]=mR.e.slice(n,n+2);return nL((t*(o*r-a*i)-100*r*o)/(t*(o-a)-100*o))}function xR(e,t,n,r,i){let a={};a.discounting=i,a.refWhite=e,a.surround=r;let o=e.map(e=>e*100);a.la=t,a.yb=n;let s=o[1],c=uI(uR,o);r=pR[a.surround];let l=r[0];a.c=r[1],a.nc=r[2];let u=1/(5*a.la+1),d=u**4;a.fl=d*a.la+.1*(1-d)*(1-d)*Math.cbrt(5*a.la),a.flRoot=a.fl**.25,a.n=a.yb/s,a.z=1.48+Math.sqrt(a.n),a.nbb=.725*a.n**-.2,a.ncb=a.nbb;let f=i?1:Math.max(Math.min(l*(1-1/3.6*Math.exp((-a.la-42)/92)),1),0);a.dRgb=c.map(e=>bI(1,s/e,f)),a.dRgbInv=a.dRgb.map(e=>1/e);let p=c.map((e,t)=>e*a.dRgb[t]),m=_R(p,a.fl);return a.aW=a.nbb*(2*m[0]+m[1]+.05*m[2]),a}const SR=xR(oR,64/Math.PI*.2,20,`average`,!1);function CR(e,t){if(!(e.J!==void 0^e.Q!==void 0))throw Error(`Conversion requires one and only one: 'J' or 'Q'`);if(!(e.C!==void 0^e.M!==void 0^e.s!==void 0))throw Error(`Conversion requires one and only one: 'C', 'M' or 's'`);if(!(e.h!==void 0^e.H!==void 0))throw Error(`Conversion requires one and only one: 'h' or 'H'`);if(e.J===0||e.Q===0)return[0,0,0];let n=0;n=e.h===void 0?bR(e.H)*gR:nL(e.h)*gR;let r=Math.cos(n),i=Math.sin(n),a=0;e.J===void 0?e.Q!==void 0&&(a=.25*t.c*e.Q/((t.aW+4)*t.flRoot)):a=EI(e.J,1/2)*.1;let o=0;e.C===void 0?e.M===void 0?e.s!==void 0&&(o=4e-4*e.s**2*(t.aW+4)/t.c):o=e.M/t.flRoot/a:o=e.C/a;let s=EI(o*(1.64-.29**t.n)**-.73,10/9),c=.25*(Math.cos(n+2)+3.8),l=t.aW*EI(a,2/t.c/t.z),u=5e4/13*t.nc*t.ncb*c,d=l/t.nbb,f=23*(d+.305)*DI(s,23*u+s*(11*r+108*i)),p=f*r,m=f*i,h=vR(uI(fR,[d,p,m]).map(e=>e*1/1403),t.fl);return uI(dR,h.map((e,n)=>e*t.dRgbInv[n])).map(e=>e/100)}function wR(e,t){let n=e.map(e=>e*100),r=_R(uI(uR,n).map((e,n)=>e*t.dRgb[n]),t.fl),i=r[0]+(-12*r[1]+r[2])/11,a=(r[0]+r[1]-2*r[2])/9,o=(Math.atan2(a,i)%lR+lR)%lR,s=.25*(Math.cos(o+2)+3.8),c=5e4/13*t.nc*t.ncb*DI(s*Math.sqrt(i**2+a**2),r[0]+r[1]+1.05*r[2]+.305),l=EI(c,.9)*(1.64-.29**t.n)**.73,u=t.nbb*(2*r[0]+r[1]+.05*r[2]),d=EI(u/t.aW,.5*t.c*t.z),f=100*EI(d,2),p=4/t.c*d*(t.aW+4)*t.flRoot,m=l*d,h=m*t.flRoot,g=nL(o*hR),_=yR(g),v=50*EI(t.c*l/(t.aW+4),1/2);return{J:f,C:m,h:g,s:v,Q:p,M:h,H:_}}var TR=new VI({id:`cam16-jmh`,cssId:`--cam16-jmh`,name:`CAM16-JMh`,coords:{j:{refRange:[0,100],name:`J`},m:{refRange:[0,105],name:`Colorfulness`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:WI,fromBase(e){let t=wR(e,SR);return[t.J,t.M,t.h]},toBase(e){return CR({J:e[0],M:e[1],h:e[2]},SR)}});const ER=NI.D65,DR=216/24389,OR=24389/27;function kR(e){let t=e>DR?Math.cbrt(e):(OR*e+16)/116;return 116*t-16}function AR(e){return e>8?((e+16)/116)**3:e/OR}function jR(e,t){let[n,r,i]=e,a=[],o=0;if(i===0)return[0,0,0];let s=AR(i);o=i>0?.00379058511492914*i**2+.608983189401032*i+.9155088574762233:9514440756550361e-21*i**2+.08693057439788597*i-21.928975842194614;let c=2e-12,l=15,u=0,d=1/0;for(;u<=l;){a=CR({J:o,C:r,h:n},t);let e=Math.abs(a[1]-s);if(e<d){if(e<=c)return a;d=e}o-=(a[1]-s)*o/(2*a[1]),u+=1}return CR({J:o,C:r,h:n},t)}function MR(e,t){let n=kR(e[1]);if(n===0)return[0,0,0];let r=wR(e,NR);return[nL(r.h),r.C,n]}const NR=xR(ER,200/Math.PI*AR(50),AR(50)*100,`average`,!1);var PR=new VI({id:`hct`,name:`HCT`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},c:{refRange:[0,145],name:`Colorfulness`},t:{refRange:[0,100],name:`Tone`}},base:WI,fromBase(e){return MR(e)},toBase(e){return jR(e,NR)},formats:{color:{id:`--hct`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const FR=Math.PI/180,IR=[1,.007,.0228];function LR(e){e[1]<0&&(e=PR.fromBase(PR.toBase(e)));let t=Math.log(Math.max(1+IR[2]*e[1]*NR.flRoot,1))/IR[2],n=e[0]*FR,r=t*Math.cos(n),i=t*Math.sin(n);return[e[2],r,i]}function RR(e,t){[e,t]=zI([e,t]);let[n,r,i]=LR(PR.from(e)),[a,o,s]=LR(PR.from(t));return Math.sqrt((n-a)**2+(r-o)**2+(i-s)**2)}var zR={deltaE76:xL,deltaECMC:wL,deltaE2000:uL,deltaEJz:WL,deltaEITP:aR,deltaEOK:gL,deltaEHCT:RR};function BR(e){let t=e?Math.floor(Math.log10(Math.abs(e))):0;return Math.max(parseFloat(`1e${t-2}`),1e-6)}const VR={hct:{method:`hct.c`,jnd:2,deltaEMethod:`hct`,blackWhiteClamp:{}},"hct-tonal":{method:`hct.c`,jnd:0,deltaEMethod:`hct`,blackWhiteClamp:{channel:`hct.t`,min:0,max:100}}};function HR(e,{method:t=MI.gamut_mapping,space:n=void 0,deltaEMethod:r=``,jnd:i=2,blackWhiteClamp:a={}}={}){if(e=zI(e),dI(arguments[1])?n=arguments[1]:n||=e.space,n=VI.get(n),vL(e,n,{epsilon:0}))return e;let o;if(t===`css`)o=WR(e,{space:n});else{if(t!==`clip`&&!vL(e,n)){Object.prototype.hasOwnProperty.call(VR,t)&&({method:t,jnd:i,deltaEMethod:r,blackWhiteClamp:a}=VR[t]);let s=uL;if(r!==``){for(let e in zR)if(`deltae`+r.toLowerCase()===e.toLowerCase()){s=zR[e];break}}let c=HR(GR(e,n),{method:`clip`,space:n});if(s(e,c)>i){if(Object.keys(a).length===3){let t=VI.resolveCoord(a.channel),n=qI(GR(e,t.space),t.id);if(mI(n)&&(n=0),n>=a.max)return GR({space:`xyz-d65`,coords:NI.D65},e.space);if(n<=a.min)return GR({space:`xyz-d65`,coords:[0,0,0]},e.space)}let r=VI.resolveCoord(t),c=r.space,l=r.id,u=GR(e,c);u.coords.forEach((e,t)=>{mI(e)&&(u.coords[t]=0)});let d=r.range||r.refRange,f=d[0],p=BR(i),m=f,h=qI(u,l);for(;h-m>p;){let e=yL(u);e=HR(e,{space:n,method:`clip`});let t=s(u,e);t-i<p?m=qI(u,l):h=qI(u,l),YI(u,l,(m+h)/2)}o=GR(u,n)}else o=c}else o=GR(e,n);if(t===`clip`||!vL(o,n,{epsilon:0})){let e=Object.values(n.coords).map(e=>e.range||[]);o.coords=o.coords.map((t,n)=>{let[r,i]=e[n];return r!==void 0&&(t=Math.max(r,t)),i!==void 0&&(t=Math.min(t,i)),t})}}return n!==e.space&&(o=GR(o,e.space)),e.coords=o.coords,e}HR.returns=`color`;const UR={WHITE:{space:hL,coords:[1,0,0]},BLACK:{space:hL,coords:[0,0,0]}};function WR(e,{space:t}={}){let n=.02,r=1e-4;e=zI(e),t||=e.space,t=VI.get(t);let i=VI.get(`oklch`);if(t.isUnbounded)return GR(e,t);let a=GR(e,i),o=a.coords[0];if(o>=1){let n=GR(UR.WHITE,t);return n.alpha=e.alpha,GR(n,t)}if(o<=0){let n=GR(UR.BLACK,t);return n.alpha=e.alpha,GR(n,t)}if(vL(a,t,{epsilon:0}))return GR(a,t);function s(e){let n=GR(e,t),r=Object.values(t.coords);return n.coords=n.coords.map((e,t)=>{if(`range`in r[t]){let[n,i]=r[t].range;return wI(n,e,i)}return e}),n}let c=0,l=a.coords[1],u=!0,d=yL(a),f=s(d),p=gL(f,d);if(p<n)return f;for(;l-c>r;){let e=(c+l)/2;if(d.coords[1]=e,u&&vL(d,t,{epsilon:0}))c=e;else if(f=s(d),p=gL(f,d),p<n){if(n-p<r)break;u=!1,c=e}else l=e}return f}function GR(e,t,{inGamut:n}={}){e=zI(e),t=VI.get(t);let r=t.from(e),i={space:t,coords:r,alpha:e.alpha};return n&&(i=HR(i,n===!0?void 0:n)),i}GR.returns=`color`;function KR(e,{precision:t=MI.precision,format:n=`default`,inGamut:r=!0,...i}={}){let a;e=zI(e);let o=n;n=e.space.getFormat(n)??e.space.getFormat(`default`)??VI.DEFAULT_FORMAT;let s=e.coords.slice();if(r||=n.toGamut,r&&!vL(e)&&(s=HR(yL(e),r===!0?void 0:r).coords),n.type===`custom`)if(i.precision=t,n.serialize)a=n.serialize(s,e.alpha,i);else throw TypeError(`format ${o} can only be used to parse colors, not for serialization`);else{let r=n.name||`color`;n.serializeCoords?s=n.serializeCoords(s,t):t!==null&&(s=s.map(e=>pI(e,{precision:t})));let i=[...s];if(r===`color`){var c,l;let t=n.id||(c=l=n.ids)?.[0]||e.space.id;i.unshift(t)}let o=e.alpha;t!==null&&(o=pI(o,{precision:t}));let u=e.alpha>=1||n.noAlpha?``:`${n.commas?`,`:` /`} ${o}`;a=`${r}(${i.join(n.commas?`, `:` `)}${u})`}return a}const qR=[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],JR=[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]];var YR=new GI({id:`rec2020-linear`,cssId:`--rec2020-linear`,name:`Linear REC.2020`,white:`D65`,toXYZ_M:qR,fromXYZ_M:JR});const XR=1.09929682680944,ZR=.018053968510807;var QR=new GI({id:`rec2020`,name:`REC.2020`,base:YR,toBase(e){return e.map(function(e){return e<ZR*4.5?e/4.5:((e+XR-1)/XR)**(1/.45)})},fromBase(e){return e.map(function(e){return e>=ZR?XR*e**.45-(XR-1):4.5*e})}});const $R=[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],ez=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]];var tz=new GI({id:`p3-linear`,cssId:`--display-p3-linear`,name:`Linear P3`,white:`D65`,toXYZ_M:$R,fromXYZ_M:ez});const nz=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],rz=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var iz=new GI({id:`srgb-linear`,name:`Linear sRGB`,white:`D65`,toXYZ_M:nz,fromXYZ_M:rz}),az={aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aqua:[0,1,1],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],black:[0,0,0],blanchedalmond:[1,235/255,205/255],blue:[0,0,1],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[153/255,50/255,204/255],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],fuchsia:[1,0,1],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],gray:[128/255,128/255,128/255],green:[0,128/255,0],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,153/255],lightslategrey:[119/255,136/255,153/255],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],lime:[0,1,0],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],maroon:[128/255,0,0],mediumaquamarine:[102/255,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,204/255],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],navy:[0,0,128/255],oldlace:[253/255,245/255,230/255],olive:[128/255,128/255,0],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],purple:[128/255,0,128/255],rebeccapurple:[102/255,51/255,153/255],red:[1,0,0],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],silver:[192/255,192/255,192/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],teal:[0,128/255,128/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],white:[1,1,1],whitesmoke:[245/255,245/255,245/255],yellow:[1,1,0],yellowgreen:[154/255,205/255,50/255]};let oz=[,,,].fill(`<percentage> | <number>[0, 255]`),sz=[,,,].fill(`<number>[0, 255]`);var cz=new GI({id:`srgb`,name:`sRGB`,base:iz,fromBase:e=>e.map(e=>{let t=e<0?-1:1,n=e*t;return n>.0031308?t*(1.055*n**(1/2.4)-.055):12.92*e}),toBase:e=>e.map(e=>{let t=e<0?-1:1,n=e*t;return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4}),formats:{rgb:{coords:oz},rgb_number:{name:`rgb`,commas:!0,coords:sz,noAlpha:!0},color:{},rgba:{coords:oz,commas:!0,lastAlpha:!0},rgba_number:{name:`rgba`,commas:!0,coords:sz},hex:{type:`custom`,toGamut:!0,test:e=>/^#([a-f0-9]{3,4}){1,2}$/i.test(e),parse(e){e.length<=5&&(e=e.replace(/[a-f0-9]/gi,`$&$&`));let t=[];return e.replace(/[a-f0-9]{2}/gi,e=>{t.push(parseInt(e,16)/255)}),{spaceId:`srgb`,coords:t.slice(0,3),alpha:t.slice(3)[0]}},serialize:(e,t,{collapse:n=!0}={})=>{t<1&&e.push(t),e=e.map(e=>Math.round(e*255));let r=n&&e.every(e=>e%17==0),i=e.map(e=>r?(e/17).toString(16):e.toString(16).padStart(2,`0`)).join(``);return`#`+i}},keyword:{type:`custom`,test:e=>/^[a-z]+$/i.test(e),parse(e){e=e.toLowerCase();let t={spaceId:`srgb`,coords:null,alpha:1};if(e===`transparent`?(t.coords=az.black,t.alpha=0):t.coords=az[e],t.coords)return t}}}}),lz=new GI({id:`p3`,cssId:`display-p3`,name:`P3`,base:tz,fromBase:cz.fromBase,toBase:cz.toBase});MI.display_space=cz;let uz;if(typeof CSS<`u`&&CSS.supports)for(let e of[tL,QR,lz]){let t=e.getMinCoords(),n={space:e,coords:t,alpha:1},r=KR(n);if(CSS.supports(`color`,r)){MI.display_space=e;break}}function dz(e,{space:t=MI.display_space,...n}={}){let r=KR(e,n);if(typeof CSS>`u`||CSS.supports(`color`,r)||!MI.display_space)r=new String(r),r.color=e;else{let i=e,a=e.coords.some(mI)||mI(e.alpha);if(a&&!(uz??=CSS.supports(`color`,`hsl(none 50% 50%)`))&&(i=yL(e),i.coords=i.coords.map(hI),i.alpha=hI(i.alpha),r=KR(i,n),CSS.supports(`color`,r)))return r=new String(r),r.color=i,r;i=GR(i,t),r=new String(KR(i,n)),r.color=i}return r}function fz(e,t){return e=zI(e),t=zI(t),e.space===t.space&&e.alpha===t.alpha&&e.coords.every((e,n)=>e===t.coords[n])}function pz(e){return qI(e,[WI,`y`])}function mz(e,t){YI(e,[WI,`y`],t)}function hz(e){Object.defineProperty(e.prototype,`luminance`,{get(){return pz(this)},set(e){mz(this,e)}})}var gz=Object.freeze({__proto__:null,getLuminance:pz,register:hz,setLuminance:mz});function _z(e,t){e=zI(e),t=zI(t);let n=Math.max(pz(e),0),r=Math.max(pz(t),0);return r>n&&([n,r]=[r,n]),(n+.05)/(r+.05)}const vz=.56,yz=.57,bz=.62,xz=.65,Sz=.022,Cz=1.414,wz=.1,Tz=5e-4,Ez=1.14,Dz=.027,Oz=1.14;function kz(e){return e>=Sz?e:e+(Sz-e)**Cz}function Az(e){let t=e<0?-1:1,n=Math.abs(e);return t*n**2.4}function jz(e,t){t=zI(t),e=zI(e);let n,r,i,a,o,s;t=GR(t,`srgb`),[a,o,s]=t.coords;let c=Az(a)*.2126729+Az(o)*.7151522+Az(s)*.072175;e=GR(e,`srgb`),[a,o,s]=e.coords;let l=Az(a)*.2126729+Az(o)*.7151522+Az(s)*.072175,u=kz(c),d=kz(l),f=d>u;return Math.abs(d-u)<Tz?r=0:f?(n=d**vz-u**yz,r=n*Ez):(n=d**xz-u**bz,r=n*Oz),i=Math.abs(r)<wz?0:r>0?r-Dz:r+Dz,i*100}function Mz(e,t){e=zI(e),t=zI(t);let n=Math.max(pz(e),0),r=Math.max(pz(t),0);r>n&&([n,r]=[r,n]);let i=n+r;return i===0?0:(n-r)/i}const Nz=5e4;function Pz(e,t){e=zI(e),t=zI(t);let n=Math.max(pz(e),0),r=Math.max(pz(t),0);return r>n&&([n,r]=[r,n]),r===0?Nz:(n-r)/r}function Fz(e,t){e=zI(e),t=zI(t);let n=qI(e,[tL,`l`]),r=qI(t,[tL,`l`]);return Math.abs(n-r)}const Iz=216/24389,Lz=24/116,Rz=24389/27;let zz=NI.D65;var Bz=new VI({id:`lab-d65`,name:`Lab D65`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:zz,base:WI,fromBase(e){let t=e.map((e,t)=>e/zz[t]),n=t.map(e=>e>Iz?Math.cbrt(e):(Rz*e+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(e){let t=[];t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200;let n=[t[0]>Lz?t[0]**3:(116*t[0]-16)/Rz,e[0]>8?((e[0]+16)/116)**3:e[0]/Rz,t[2]>Lz?t[2]**3:(116*t[2]-16)/Rz];return n.map((e,t)=>e*zz[t])},formats:{"lab-d65":{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});const Vz=5**.5*.5+.5;function Hz(e,t){e=zI(e),t=zI(t);let n=qI(e,[Bz,`l`]),r=qI(t,[Bz,`l`]),i=Math.abs(n**+Vz-r**+Vz),a=i**(1/Vz)*Math.SQRT2-40;return a<7.5?0:a}var Uz=Object.freeze({__proto__:null,contrastAPCA:jz,contrastDeltaPhi:Hz,contrastLstar:Fz,contrastMichelson:Mz,contrastWCAG21:_z,contrastWeber:Pz});function Wz(e,t,n={}){dI(n)&&(n={algorithm:n});let{algorithm:r,...i}=n;if(!r){let e=Object.keys(Uz).map(e=>e.replace(/^contrast/,``)).join(`, `);throw TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${e}`)}for(let n in e=zI(e),t=zI(t),Uz)if(`contrast`+r.toLowerCase()===n.toLowerCase())return Uz[n](e,t,i);throw TypeError(`Unknown contrast algorithm: ${r}`)}function Gz(e){let[t,n,r]=KI(e,WI),i=t+15*n+3*r;return[4*t/i,9*n/i]}function Kz(e){let[t,n,r]=KI(e,WI),i=t+n+r;return[t/i,n/i]}function qz(e){Object.defineProperty(e.prototype,`uv`,{get(){return Gz(this)}}),Object.defineProperty(e.prototype,`xy`,{get(){return Kz(this)}})}var Jz=Object.freeze({__proto__:null,register:qz,uv:Gz,xy:Kz});function Yz(e,t,n={}){dI(n)&&(n={method:n});let{method:r=MI.deltaE,...i}=n;for(let n in zR)if(`deltae`+r.toLowerCase()===n.toLowerCase())return zR[n](e,t,i);throw TypeError(`Unknown deltaE method: ${r}`)}function Xz(e,t=.25){let n=VI.get(`oklch`,`lch`),r=[n,`l`];return YI(e,r,e=>e*(1+t))}function Zz(e,t=.25){let n=VI.get(`oklch`,`lch`),r=[n,`l`];return YI(e,r,e=>e*(1-t))}var Qz=Object.freeze({__proto__:null,darken:Zz,lighten:Xz});function $z(e,t,n=.5,r={}){[e,t]=[zI(e),zI(t)],fI(n)===`object`&&([n,r]=[.5,n]);let i=tB(e,t,r);return i(n)}function eB(e,t,n={}){let r;nB(e)&&([r,n]=[e,t],[e,t]=r.rangeArgs.colors);let{maxDeltaE:i,deltaEMethod:a,steps:o=2,maxSteps:s=1e3,...c}=n;r||([e,t]=[zI(e),zI(t)],r=tB(e,t,c));let l=Yz(e,t),u=i>0?Math.max(o,Math.ceil(l/i)+1):o,d=[];if(s!==void 0&&(u=Math.min(u,s)),u===1)d=[{p:.5,color:r(.5)}];else{let e=1/(u-1);d=Array.from({length:u},(t,n)=>{let i=n*e;return{p:i,color:r(i)}})}if(i>0){let e=d.reduce((e,t,n)=>{if(n===0)return 0;let r=Yz(t.color,d[n-1].color,a);return Math.max(e,r)},0);for(;e>i;){e=0;for(let t=1;t<d.length&&d.length<s;t++){let n=d[t-1],i=d[t],a=(i.p+n.p)/2,o=r(a);e=Math.max(e,Yz(o,n.color),Yz(o,i.color)),d.splice(t,0,{p:a,color:r(a)}),t++}}}return d=d.map(e=>e.color),d}function tB(e,t,n={}){if(nB(e)){let[n,r]=[e,t];return tB(...n.rangeArgs.colors,{...n.rangeArgs.options,...r})}let{space:r,outputSpace:i,progression:a,premultiplied:o}=n;e=zI(e),t=zI(t),e=yL(e),t=yL(t);let s={colors:[e,t],options:n};if(r=r?VI.get(r):VI.registry[MI.interpolationSpace]||e.space,i=i?VI.get(i):r,e=GR(e,r),t=GR(t,r),e=HR(e),t=HR(t),r.coords.h&&r.coords.h.type===`angle`){let i=n.hue=n.hue||`shorter`,a=[r,`h`],[o,s]=[qI(e,a),qI(t,a)];isNaN(o)&&!isNaN(s)?o=s:isNaN(s)&&!isNaN(o)&&(s=o),[o,s]=rL(i,[o,s]),YI(e,a,o),YI(t,a,s)}return o&&(e.coords=e.coords.map(t=>t*e.alpha),t.coords=t.coords.map(e=>e*t.alpha)),Object.assign(n=>{n=a?a(n):n;let s=e.coords.map((e,r)=>{let i=t.coords[r];return bI(e,i,n)}),c=bI(e.alpha,t.alpha,n),l={space:r,coords:s,alpha:c};return o&&(l.coords=l.coords.map(e=>e/c)),i!==r&&(l=GR(l,i)),l},{rangeArgs:s})}function nB(e){return fI(e)===`function`&&!!e.rangeArgs}MI.interpolationSpace=`lab`;function rB(e){e.defineFunction(`mix`,$z,{returns:`color`}),e.defineFunction(`range`,tB,{returns:`function<color>`}),e.defineFunction(`steps`,eB,{returns:`array<color>`})}var iB=Object.freeze({__proto__:null,isRange:nB,mix:$z,range:tB,register:rB,steps:eB}),aB=new VI({id:`hsl`,name:`HSL`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:cz,fromBase:e=>{let t=Math.max(...e),n=Math.min(...e),[r,i,a]=e,[o,s,c]=[NaN,0,(n+t)/2],l=t-n;if(l!==0){switch(s=c===0||c===1?0:(t-c)/Math.min(c,1-c),t){case r:o=(i-a)/l+(i<a?6:0);break;case i:o=(a-r)/l+2;break;case a:o=(r-i)/l+4}o*=60}return s<0&&(o+=180,s=Math.abs(s)),o>=360&&(o-=360),[o,s*100,c*100]},toBase:e=>{let[t,n,r]=e;t%=360,t<0&&(t+=360),n/=100,r/=100;function i(e){let i=(e+t/30)%12,a=n*Math.min(r,1-r);return r-a*Math.max(-1,Math.min(i-3,9-i,1))}return[i(0),i(8),i(4)]},formats:{hsl:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`]},hsla:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`],commas:!0,lastAlpha:!0}}}),oB=new VI({id:`hsv`,name:`HSV`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},v:{range:[0,100],name:`Value`}},base:aB,fromBase(e){let[t,n,r]=e;n/=100,r/=100;let i=r+n*Math.min(r,1-r);return[t,i===0?0:200*(1-r/i),100*i]},toBase(e){let[t,n,r]=e;n/=100,r/=100;let i=r*(1-n/2);return[t,i===0||i===1?0:(r-i)/Math.min(i,1-i)*100,i*100]},formats:{color:{id:`--hsv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}}),sB=new VI({id:`hwb`,name:`HWB`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},w:{range:[0,100],name:`Whiteness`},b:{range:[0,100],name:`Blackness`}},base:oB,fromBase(e){let[t,n,r]=e;return[t,r*(100-n)/100,100-r]},toBase(e){let[t,n,r]=e;n/=100,r/=100;let i=n+r;if(i>=1){let e=n/i;return[t,0,e*100]}let a=1-r,o=a===0?0:1-n/a;return[t,o*100,a*100]},formats:{hwb:{coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const cB=[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],lB=[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]];var uB=new GI({id:`a98rgb-linear`,cssId:`--a98-rgb-linear`,name:`Linear Adobe® 98 RGB compatible`,white:`D65`,toXYZ_M:cB,fromXYZ_M:lB}),dB=new GI({id:`a98rgb`,cssId:`a98-rgb`,name:`Adobe® 98 RGB compatible`,base:uB,toBase:e=>e.map(e=>Math.abs(e)**(563/256)*Math.sign(e)),fromBase:e=>e.map(e=>Math.abs(e)**(256/563)*Math.sign(e))});const fB=[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],pB=[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]];var mB=new GI({id:`prophoto-linear`,cssId:`--prophoto-rgb-linear`,name:`Linear ProPhoto`,white:`D50`,base:XI,toXYZ_M:fB,fromXYZ_M:pB});const hB=1/512,gB=16/512;var _B=new GI({id:`prophoto`,cssId:`prophoto-rgb`,name:`ProPhoto`,base:mB,toBase(e){return e.map(e=>e<gB?e/16:e**1.8)},fromBase(e){return e.map(e=>e>=hB?e**(1/1.8):16*e)}}),vB=new VI({id:`oklch`,name:`Oklch`,coords:{l:{refRange:[0,1],name:`Lightness`},c:{refRange:[0,.4],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},white:`D65`,base:hL,fromBase(e){let[t,n,r]=e,i,a=2e-4;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),nL(i)]},toBase(e){let[t,n,r]=e,i,a;return isNaN(r)?(i=0,a=0):(i=n*Math.cos(r*Math.PI/180),a=n*Math.sin(r*Math.PI/180)),[t,i,a]},formats:{oklch:{coords:[`<percentage> | <number>`,`<number> | <percentage>[0,1]`,`<number> | <angle>`]}}});let yB=NI.D65;const bB=216/24389,xB=24389/27,[SB,CB]=Gz({space:WI,coords:yB});var wB=new VI({id:`luv`,name:`Luv`,coords:{l:{refRange:[0,100],name:`Lightness`},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:yB,base:WI,fromBase(e){let t=[hI(e[0]),hI(e[1]),hI(e[2])],n=t[1],[r,i]=Gz({space:WI,coords:t});if(!Number.isFinite(r)||!Number.isFinite(i))return[0,0,0];let a=n<=bB?xB*n:116*Math.cbrt(n)-16;return[a,13*a*(r-SB),13*a*(i-CB)]},toBase(e){let[t,n,r]=e;if(t===0||mI(t))return[0,0,0];n=hI(n),r=hI(r);let i=n/(13*t)+SB,a=r/(13*t)+CB,o=t<=8?t/xB:((t+16)/116)**3;return[o*(9*i/(4*a)),o,o*((12-3*i-20*a)/(4*a))]},formats:{color:{id:`--luv`,coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),TB=new VI({id:`lchuv`,name:`LChuv`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,220],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:wB,fromBase(e){let[t,n,r]=e,i,a=.02;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),nL(i)]},toBase(e){let[t,n,r]=e;return n<0&&(n=0),isNaN(r)&&(r=0),[t,n*Math.cos(r*Math.PI/180),n*Math.sin(r*Math.PI/180)]},formats:{color:{id:`--lchuv`,coords:[`<number> | <percentage>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const EB=216/24389,DB=24389/27,OB=rz[0][0],kB=rz[0][1],AB=rz[0][2],jB=rz[1][0],MB=rz[1][1],NB=rz[1][2],PB=rz[2][0],FB=rz[2][1],IB=rz[2][2];function LB(e,t,n){let r=t/(Math.sin(n)-e*Math.cos(n));return r<0?1/0:r}function RB(e){let t=(e+16)**3/1560896,n=t>EB?t:e/DB,r=n*(284517*OB-94839*AB),i=n*(838422*AB+769860*kB+731718*OB),a=n*(632260*AB-126452*kB),o=n*(284517*jB-94839*NB),s=n*(838422*NB+769860*MB+731718*jB),c=n*(632260*NB-126452*MB),l=n*(284517*PB-94839*IB),u=n*(838422*IB+769860*FB+731718*PB),d=n*(632260*IB-126452*FB);return{r0s:r/a,r0i:i*e/a,r1s:r/(a+126452),r1i:(i-769860)*e/(a+126452),g0s:o/c,g0i:s*e/c,g1s:o/(c+126452),g1i:(s-769860)*e/(c+126452),b0s:l/d,b0i:u*e/d,b1s:l/(d+126452),b1i:(u-769860)*e/(d+126452)}}function zB(e,t){let n=t/360*Math.PI*2,r=LB(e.r0s,e.r0i,n),i=LB(e.r1s,e.r1i,n),a=LB(e.g0s,e.g0i,n),o=LB(e.g1s,e.g1i,n),s=LB(e.b0s,e.b0i,n),c=LB(e.b1s,e.b1i,n);return Math.min(r,i,a,o,s,c)}var BB=new VI({id:`hsluv`,name:`HSLuv`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:TB,gamutSpace:cz,fromBase(e){let[t,n,r]=[hI(e[0]),hI(e[1]),hI(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=RB(t),a=zB(e,r);i=n/a*100}return[r,i,t]},toBase(e){let[t,n,r]=[hI(e[0]),hI(e[1]),hI(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=RB(r),a=zB(e,t);i=a/100*n}return[r,i,t]},formats:{color:{id:`--hsluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});rz[0][0],rz[0][1],rz[0][2],rz[1][0],rz[1][1],rz[1][2],rz[2][0],rz[2][1],rz[2][2];function VB(e,t){return Math.abs(t)/Math.sqrt(e**2+1)}function HB(e){let t=VB(e.r0s,e.r0i),n=VB(e.r1s,e.r1i),r=VB(e.g0s,e.g0i),i=VB(e.g1s,e.g1i),a=VB(e.b0s,e.b0i),o=VB(e.b1s,e.b1i);return Math.min(t,n,r,i,a,o)}var UB=new VI({id:`hpluv`,name:`HPLuv`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:TB,gamutSpace:`self`,fromBase(e){let[t,n,r]=[hI(e[0]),hI(e[1]),hI(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=RB(t),r=HB(e);i=n/r*100}return[r,i,t]},toBase(e){let[t,n,r]=[hI(e[0]),hI(e[1]),hI(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=RB(r),t=HB(e);i=t/100*n}return[r,i,t]},formats:{color:{id:`--hpluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const WB=203,GB=2610/2**14,KB=2**14/2610,qB=2523/2**5,JB=2**5/2523,YB=3424/2**12,XB=2413/2**7,ZB=2392/2**7;var QB=new GI({id:`rec2100pq`,cssId:`rec2100-pq`,name:`REC.2100-PQ`,base:YR,toBase(e){return e.map(function(e){let t=(Math.max(e**JB-YB,0)/(XB-ZB*e**JB))**KB;return t*1e4/WB})},fromBase(e){return e.map(function(e){let t=Math.max(e*WB/1e4,0),n=YB+XB*t**GB,r=1+ZB*t**GB;return(n/r)**qB})}});const $B=.17883277,eV=.28466892,tV=.55991073,nV=3.7743;var rV=new GI({id:`rec2100hlg`,cssId:`rec2100-hlg`,name:`REC.2100-HLG`,referred:`scene`,base:YR,toBase(e){return e.map(function(e){return e<=.5?e**2/3*nV:(Math.exp((e-tV)/$B)+eV)/12*nV})},fromBase(e){return e.map(function(e){return e/=nV,e<=1/12?Math.sqrt(3*e):$B*Math.log(12*e-eV)+tV})}});const iV={};jI.add(`chromatic-adaptation-start`,e=>{e.options.method&&(e.M=oV(e.W1,e.W2,e.options.method))}),jI.add(`chromatic-adaptation-end`,e=>{e.M||=oV(e.W1,e.W2,e.options.method)});function aV({id:e,toCone_M:t,fromCone_M:n}){iV[e]=arguments[0]}function oV(e,t,n=`Bradford`){let r=iV[n],[i,a,o]=uI(r.toCone_M,e),[s,c,l]=uI(r.toCone_M,t),u=[[s/i,0,0],[0,c/a,0],[0,0,l/o]],d=uI(u,r.toCone_M),f=uI(r.fromCone_M,d);return f}aV({id:`von Kries`,toCone_M:[[.40024,.7076,-.08081],[-.2263,1.16532,.0457],[0,0,.91822]],fromCone_M:[[1.8599363874558397,-1.1293816185800916,.21989740959619328],[.3611914362417676,.6388124632850422,-6370596838649899e-21],[0,0,1.0890636230968613]]}),aV({id:`Bradford`,toCone_M:[[.8951,.2664,-.1614],[-.7502,1.7135,.0367],[.0389,-.0685,1.0296]],fromCone_M:[[.9869929054667121,-.14705425642099013,.15996265166373122],[.4323052697233945,.5183602715367774,.049291228212855594],[-.00852866457517732,.04004282165408486,.96848669578755]]}),aV({id:`CAT02`,toCone_M:[[.7328,.4296,-.1624],[-.7036,1.6975,.0061],[.003,.0136,.9834]],fromCone_M:[[1.0961238208355142,-.27886900021828726,.18274517938277307],[.4543690419753592,.4735331543074117,.07209780371722911],[-.009627608738429355,-.00569803121611342,1.0153256399545427]]}),aV({id:`CAT16`,toCone_M:[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],fromCone_M:[[1.862067855087233,-1.0112546305316845,.14918677544445172],[.3875265432361372,.6214474419314753,-.008973985167612521],[-.01584149884933386,-.03412293802851557,1.0499644368778496]]}),Object.assign(NI,{A:[1.0985,1,.35585],C:[.98074,1,1.18232],D55:[.95682,1,.92149],D75:[.94972,1,1.22638],E:[1,1,1],F2:[.99186,1,.67393],F7:[.95041,1,1.08747],F11:[1.00962,1,.6435]}),NI.ACES=[.32168/.33767,1,.34065/.33767];const sV=[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],cV=[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]];var lV=new GI({id:`acescg`,cssId:`--acescg`,name:`ACEScg`,coords:{r:{range:[0,65504],name:`Red`},g:{range:[0,65504],name:`Green`},b:{range:[0,65504],name:`Blue`}},referred:`scene`,white:NI.ACES,toXYZ_M:sV,fromXYZ_M:cV});const uV=2**-16,dV=-.35828683,fV=(Math.log2(65504)+9.72)/17.52;var pV=new GI({id:`acescc`,cssId:`--acescc`,name:`ACEScc`,coords:{r:{range:[dV,fV],name:`Red`},g:{range:[dV,fV],name:`Green`},b:{range:[dV,fV],name:`Blue`}},referred:`scene`,base:lV,toBase(e){let t=-5.279999999999999/17.52;return e.map(function(e){return e<=t?(2**(e*17.52-9.72)-uV)*2:e<fV?2**(e*17.52-9.72):65504})},fromBase(e){return e.map(function(e){return e<=0?(Math.log2(uV)+9.72)/17.52:e<uV?(Math.log2(uV+e*.5)+9.72)/17.52:(Math.log2(e)+9.72)/17.52})}}),mV=Object.freeze({__proto__:null,A98RGB:dB,A98RGB_Linear:uB,ACEScc:pV,ACEScg:lV,CAM16_JMh:TR,HCT:PR,HPLuv:UB,HSL:aB,HSLuv:BB,HSV:oB,HWB:sB,ICTCP:nR,JzCzHz:UL,Jzazbz:HL,LCH:iL,LCHuv:TB,Lab:tL,Lab_D65:Bz,Luv:wB,OKLCH:vB,OKLab:hL,P3:lz,P3_Linear:tz,ProPhoto:_B,ProPhoto_Linear:mB,REC_2020:QR,REC_2020_Linear:YR,REC_2100_HLG:rV,REC_2100_PQ:QB,XYZ_ABS_D65:EL,XYZ_D50:XI,XYZ_D65:WI,sRGB:cz,sRGB_Linear:iz}),hV=class e{constructor(...e){let t;e.length===1&&(t=zI(e[0]));let n,r,i;t?(n=t.space||t.spaceId,r=t.coords,i=t.alpha):[n,r,i]=e,Object.defineProperty(this,`space`,{value:VI.get(n),writable:!1,enumerable:!0,configurable:!0}),this.coords=r?r.slice():[0,0,0],this.alpha=i>1||i===void 0?1:i<0?0:i;for(let e=0;e<this.coords.length;e++)this.coords[e]===`NaN`&&(this.coords[e]=NaN);for(let e in this.space.coords)Object.defineProperty(this,e,{get:()=>this.get(e),set:t=>this.set(e,t)})}get spaceId(){return this.space.id}clone(){return new e(this.space,this.coords,this.alpha)}toJSON(){return{spaceId:this.spaceId,coords:this.coords,alpha:this.alpha}}display(...t){let n=dz(this,...t);return n.color=new e(n.color),n}static get(t,...n){return t instanceof e?t:new e(t,...n)}static defineFunction(t,n,r=n){let{instance:i=!0,returns:a}=r,o=function(...t){let r=n(...t);if(a===`color`)r=e.get(r);else if(a===`function<color>`){let t=r;r=function(...n){let r=t(...n);return e.get(r)},Object.assign(r,t)}else a===`array<color>`&&(r=r.map(t=>e.get(t)));return r};t in e||(e[t]=o),i&&(e.prototype[t]=function(...e){return o(this,...e)})}static defineFunctions(t){for(let n in t)e.defineFunction(n,t[n],t[n])}static extend(exports){if(exports.register)exports.register(e);else for(let n in exports)e.defineFunction(n,exports[n])}};hV.defineFunctions({get:qI,getAll:KI,set:YI,setAll:JI,to:GR,equals:fz,inGamut:vL,toGamut:HR,distance:bL,toString:KR}),Object.assign(hV,{util:kI,hooks:jI,WHITES:NI,Space:VI,spaces:VI.registry,parse:RI,defaults:MI});for(let e of Object.keys(mV))VI.register(mV[e]);for(let e in VI.registry)gV(e,VI.registry[e]);jI.add(`colorspace-init-end`,e=>{var t,n;gV(e.id,e),(t=n=e.aliases)?.forEach(t=>{gV(t,e)})});function gV(e,t){let n=e.replace(/-/g,`_`);Object.defineProperty(hV.prototype,n,{get(){let n=this.getAll(e);return typeof Proxy>`u`?n:new Proxy(n,{has:(e,n)=>{try{return VI.resolveCoord([t,n]),!0}catch{}return Reflect.has(e,n)},get:(e,n,r)=>{if(n&&typeof n!=`symbol`&&!(n in e)){let{index:r}=VI.resolveCoord([t,n]);if(r>=0)return e[r]}return Reflect.get(e,n,r)},set:(n,r,i,a)=>{if(r&&typeof r!=`symbol`&&!(r in n)||r>=0){let{index:a}=VI.resolveCoord([t,r]);if(a>=0)return n[a]=i,this.setAll(e,n),!0}return Reflect.set(n,r,i,a)}})},set(t){this.setAll(e,t)},configurable:!0,enumerable:!0})}hV.extend(zR),hV.extend({deltaE:Yz}),Object.assign(hV,{deltaEMethods:zR}),hV.extend(Qz),hV.extend({contrast:Wz}),hV.extend(Jz),hV.extend(gz),hV.extend(iB),hV.extend(Uz);const{vec2:_V,vec4:vV}=xj,yV=e=>{let t=new hV(e);return vV(...t.to(`p3-linear`).coords,t.alpha).value},bV=e=>{let t=.5,n=.5;if(typeof e==`string`){let r=e.toLowerCase().trim().split(/\s+/);r.includes(`left`)?t=0:r.includes(`right`)?t=1:(r.includes(`center`)||r.length===1&&(r[0]===`top`||r[0]===`bottom`))&&(t=.5),r.includes(`top`)?n=0:r.includes(`bottom`)?n=1:(r.includes(`center`)||r.length===1&&(r[0]===`left`||r[0]===`right`))&&(n=.5),r.length===1&&r[0]===`center`&&(t=.5,n=.5)}else typeof e==`object`&&e?(t=e.x,n=e.y):console.warn(`Invalid position value provided: ${e}. Defaulting to center.`);return _V(t,1-n).value},{vec2:xV,viewportSize:SV}=xj,CV=(e=xV(0))=>{let t=SV,n=t.x.div(t.y),r=e.x.mul(n);return xV(r,e.y)},wV={name:`Circle`,props:{color:{type:String,default:`#ffffff`,transform:yV,description:`The color of the circle`},backgroundColor:{type:String,default:`transparent`,transform:yV,description:`The background color`},radius:{type:Number,default:1,description:`The radius of the circle`},softness:{type:Number,default:0,description:`Edge softness (0 = sharp, 1 = soft)`},center:{type:Object,default:{x:.5,y:.5},transform:bV}},fragmentNode:({uniforms:e})=>{let{vec2:t,vec4:n,length:r,mix:i,smoothstep:a,uv:o}=xj,s=t(e.center.uniform.x.mul(.5).add(.25),e.center.uniform.y.mul(.5).add(.25)),c=CV(o()),l=CV(s),u=r(c.sub(l)),d=e.softness.uniform,f=e.radius.uniform.mul(.25),p=a(f,f.sub(d),u);return n(i(e.backgroundColor.uniform,e.color.uniform,p),1)}};var TV=r({__name:`Circle`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},backgroundColor:{},radius:{},softness:{},center:{}},{blendMode:`normal`,opacity:1,...Object.entries(wV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${wV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(wV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(wV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI(wV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,wV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),EV=TV;const DV={name:`DotGrid`,props:{color:{type:String,default:`#ffffff`,description:`Dot color`,transform:yV},density:{type:Number,default:100,description:`Grid density (number of dots)`},dotSize:{type:Number,default:.2,description:`Size of each dot (0-1)`}},fragmentNode:({uniforms:e})=>{let{viewportUV:t,vec4:n,vec3:r,vec2:i,smoothstep:a,length:o,floor:s,float:c,viewportSize:l}=xj,u=t,d=e.density.uniform,f=e.dotSize.uniform,p=e.color.uniform,m=l,h=m.x.div(m.y),g=i(u.x.mul(h),u.y),_=g.mul(d),v=_.sub(s(_)),y=o(v.sub(.5)),b=c(1).sub(a(f.mul(.45),f.mul(.5),y)),x=r(p).mul(b);return n(x,b)}};var OV=r({__name:`DotGrid`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},density:{},dotSize:{}},{blendMode:`normal`,opacity:1,...Object.entries(DV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${DV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(DV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(DV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI(DV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,DV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),kV=OV;const AV={name:`FilmGrain`,props:{intensity:{type:Number,default:.25,description:`Grain intensity (0-1)`},power:{type:Number,default:.645,description:`Controls blending based on brightness`},speed:{type:Number,default:.5,description:`Animation speed of grain noise`}},fragmentNode:({uniforms:e,childNode:t})=>{let n=t||uF(0,0,0,0),r=tF(),i=e=>jM(RN(kM(e,cF(12.9898,78.233))).mul(43758.5453)),a=e=>kM(e,uF(.299,.587,.114,0)),o=i(r).add(xP.mul(e.speed.uniform)),s=jM(RN(o.mul(43758.5453))),c=NM(AM(.5),AM(.75),s).mul(e.intensity.uniform),l=FM(a(n),e.power.uniform),u=n.mul(c),d=DM(l,0,1),f=NM(u,n,d);return uF(f.x,f.y,f.z,n.w)}};var jV=r({__name:`FilmGrain`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{},power:{},speed:{}},{blendMode:`normal`,opacity:1,...Object.entries(AV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${AV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(AV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(AV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI(AV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,AV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),MV=jV;const NV=new WeakMap,PV={name:`glassTiles`,props:{intensity:{type:Number,default:1,description:`The intensity of the glass tiles effect`},tileCount:{type:Number,default:100,description:`Number of tiles across the shortest dimension`}},fragmentNode:({uniforms:e,childNode:t,onCleanup:n,canvas:r})=>{let{vec2:i,vec4:a,floor:o,mul:s,div:c,sub:l,add:u,convertToTexture:d,uv:f,uniform:p}=xj;if(!t)return console.error(`You must pass a child component into the Glass Tiles shader.`),a(0);let m=d(t),h=p(1),g=()=>{r&&(h.value=r.clientWidth/r.clientHeight)};g();let _=NV.get(r);_||(_=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect,i=window.devicePixelRatio||1;m.setSize(n*i,r*i),g()}),_.observe(r),NV.set(r,_)),n(()=>{let e=NV.get(r);e&&(e.disconnect(),NV.delete(r))});let v=f(),y=e.intensity.uniform,b=e.tileCount.uniform,x=i(h.greaterThanEqual(1).select(s(b,h),b),h.lessThan(1).select(c(b,h),b)),S=c(o(s(v,x)),x),ee=l(v,S),te=i(.5,.5),ne=s(y,.025),re=c(ee,c(i(1),x)),ie=l(re,te),ae=s(ie,ne),oe=u(ee,ae),se=u(oe,S);return a(m.sample(se))}};var FV=r({__name:`GlassTiles`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{},tileCount:{}},{blendMode:`normal`,opacity:1,...Object.entries(PV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${PV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(PV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(PV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI(PV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,PV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),IV=FV;const LV={VERTEX:`vertex`,FRAGMENT:`fragment`},RV={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},zV=[`fragment`,`vertex`],foe=[...zV,`compute`],BV=[`x`,`y`,`z`,`w`],VV=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`);let HV=1234567;const UV=Math.PI/180,WV=180/Math.PI;function GV(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=VV[e&255]+VV[e>>8&255]+VV[e>>16&255]+VV[e>>24&255]+`-`+VV[t&255]+VV[t>>8&255]+`-`+VV[t>>16&15|64]+VV[t>>24&255]+`-`+VV[n&63|128]+VV[n>>8&255]+`-`+VV[n>>16&255]+VV[n>>24&255]+VV[r&255]+VV[r>>8&255]+VV[r>>16&255]+VV[r>>24&255];return i.toLowerCase()}function KV(e,t,n){return Math.max(t,Math.min(n,e))}function qV(e,t){return(e%t+t)%t}function JV(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function YV(e,t,n){return e===t?0:(n-e)/(t-e)}function XV(e,t,n){return(1-n)*e+n*t}function ZV(e,t,n,r){return XV(e,t,1-Math.exp(-n*r))}function QV(e,t=1){return t-Math.abs(qV(e,t*2)-t)}function $V(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function eH(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function tH(e,t){return e+Math.floor(Math.random()*(t-e+1))}function nH(e,t){return e+Math.random()*(t-e)}function rH(e){return e*(.5-Math.random())}function iH(e){e!==void 0&&(HV=e);let t=HV+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function aH(e){return e*UV}function oH(e){return e*WV}function sH(e){return(e&e-1)==0&&e!==0}function cH(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function lH(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function uH(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function dH(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function fH(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const pH={DEG2RAD:UV,RAD2DEG:WV,generateUUID:GV,clamp:KV,euclideanModulo:qV,mapLinear:JV,inverseLerp:YV,lerp:XV,damp:ZV,pingpong:QV,smoothstep:$V,smootherstep:eH,randInt:tH,randFloat:nH,randFloatSpread:rH,seededRandom:iH,degToRad:aH,radToDeg:oH,isPowerOfTwo:sH,ceilPowerOfTwo:cH,floorPowerOfTwo:lH,setQuaternionFromProperEuler:uH,normalize:fH,denormalize:dH},mH=0,hH=1015,gH=``,_H=`srgb`,vH=`srgb-linear`,yH=`linear`,bH=`srgb`,xH=35044,SH=2e3,CH=2001;var wH=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(TH.makeScale(e,t)),this}rotate(e){return this.premultiply(TH.makeRotation(-e)),this}translate(e,t){return this.premultiply(TH.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const TH=new wH,EH={};function DH(e){e in EH||(EH[e]=!0,console.warn(e))}const OH=new wH().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),kH=new wH().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function AH(){let e={enabled:!0,workingColorSpace:vH,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===bH&&(e.r=MH(e.r),e.g=MH(e.g),e.b=MH(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===bH&&(e.r=NH(e.r),e.g=NH(e.g),e.b=NH(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===gH?yH:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return DH(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return DH(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[vH]:{primaries:t,whitePoint:r,transfer:yH,toXYZ:OH,fromXYZ:kH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:_H},outputColorSpaceConfig:{drawingBufferColorSpace:_H}},[_H]:{primaries:t,whitePoint:r,transfer:bH,toXYZ:OH,fromXYZ:kH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:_H}}}),e}const jH=AH();function MH(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function NH(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}const PH={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},FH={h:0,s:0,l:0},IH={h:0,s:0,l:0};function LH(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var RH=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=_H){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,jH.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=jH.workingColorSpace){return this.r=e,this.g=t,this.b=n,jH.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=jH.workingColorSpace){if(e=qV(e,1),t=KV(t,0,1),n=KV(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=LH(i,r,e+1/3),this.g=LH(i,r,e),this.b=LH(i,r,e-1/3)}return jH.colorSpaceToWorking(this,r),this}setStyle(e,t=_H){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=_H){let n=PH[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=MH(e.r),this.g=MH(e.g),this.b=MH(e.b),this}copyLinearToSRGB(e){return this.r=NH(e.r),this.g=NH(e.g),this.b=NH(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=_H){return jH.workingToColorSpace(zH.copy(this),e),Math.round(KV(zH.r*255,0,255))*65536+Math.round(KV(zH.g*255,0,255))*256+Math.round(KV(zH.b*255,0,255))}getHexString(e=_H){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=jH.workingColorSpace){jH.workingToColorSpace(zH.copy(this),t);let n=zH.r,r=zH.g,i=zH.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=jH.workingColorSpace){return jH.workingToColorSpace(zH.copy(this),t),e.r=zH.r,e.g=zH.g,e.b=zH.b,e}getStyle(e=_H){jH.workingToColorSpace(zH.copy(this),e);let t=zH.r,n=zH.g,r=zH.b;return e===_H?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(FH),this.setHSL(FH.h+e,FH.s+t,FH.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(FH),e.getHSL(IH);let n=XV(FH.h,IH.h,t),r=XV(FH.s,IH.s,t),i=XV(FH.l,IH.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const zH=new RH;RH.NAMES=PH;var BH=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}},VH=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(KV(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},HH=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(WH.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(WH.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=KV(this.x,e.x,t.x),this.y=KV(this.y,e.y,t.y),this.z=KV(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=KV(this.x,e,t),this.y=KV(this.y,e,t),this.z=KV(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(KV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return UH.copy(this).projectOnVector(e),this.sub(UH)}reflect(e){return this.sub(UH.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(KV(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const UH=new HH,WH=new VH;var GH=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/KH.setFromMatrixColumn(e,0).length(),i=1/KH.setFromMatrixColumn(e,1).length(),a=1/KH.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(JH,e,YH)}lookAt(e,t,n){let r=this.elements;return QH.subVectors(e,t),QH.lengthSq()===0&&(QH.z=1),QH.normalize(),XH.crossVectors(n,QH),XH.lengthSq()===0&&(Math.abs(n.z)===1?QH.x+=1e-4:QH.z+=1e-4,QH.normalize(),XH.crossVectors(n,QH)),XH.normalize(),ZH.crossVectors(QH,XH),r[0]=XH.x,r[4]=ZH.x,r[8]=QH.x,r[1]=XH.y,r[5]=ZH.y,r[9]=QH.y,r[2]=XH.z,r[6]=ZH.z,r[10]=QH.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=KH.set(r[0],r[1],r[2]).length(),a=KH.set(r[4],r[5],r[6]).length(),o=KH.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],qH.copy(this);let c=1/i,l=1/a,u=1/o;return qH.elements[0]*=c,qH.elements[1]*=c,qH.elements[2]*=c,qH.elements[4]*=l,qH.elements[5]*=l,qH.elements[6]*=l,qH.elements[8]*=u,qH.elements[9]*=u,qH.elements[10]*=u,t.setFromRotationMatrix(qH),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=SH){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===SH)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===CH)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=SH){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===SH)p=(a+i)*u,m=-2*u;else if(o===CH)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const KH=new HH,qH=new GH,JH=new HH(0,0,0),YH=new HH(1,1,1),XH=new HH,ZH=new HH,QH=new HH;var $H=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=KV(this.x,e.x,t.x),this.y=KV(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=KV(this.x,e,t),this.y=KV(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(KV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(KV(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},eU=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=KV(this.x,e.x,t.x),this.y=KV(this.y,e.y,t.y),this.z=KV(this.z,e.z,t.z),this.w=KV(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=KV(this.x,e,t),this.y=KV(this.y,e,t),this.z=KV(this.z,e,t),this.w=KV(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(KV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};function tU(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}const nU=(...e)=>tU(e);function rU(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of iU(e))n.push(tU(r.slice(0,-4)),i.getCacheKey(t));return tU(n)}function*iU(e,t=!1){for(let n in e){if(n.startsWith(`_`)===!0)continue;let r=e[n];if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)yield{property:n,childNode:r};else if(typeof r==`object`)for(let e in r){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}}}function aU(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function oU(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new RH(...t):n===`vec2`?new $H(...t):n===`vec3`?new HH(...t):n===`vec4`?new eU(...t):n===`mat2`?new BH(...t):n===`mat3`?new wH(...t):n===`mat4`?new GH(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?cU(t[0]):null}function sU(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function cU(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var lU=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const uU={analyze:`setup`,generate:`analyze`};let dU=0;var fU=class extends lU{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=RV.NONE,this.updateBeforeType=RV.NONE,this.updateAfterType=RV.NONE,this.uuid=pH.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:dU++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,RV.FRAME)}onRenderUpdate(e){return this.onUpdate(e,RV.RENDER)}onObjectUpdate(e){return this.onUpdate(e,RV.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of iU(this))yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e||=this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=nU(rU(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e),n=e.getElementType(t);return n}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t);return n||this}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn(`Abstract function.`)}updateAfter(){console.warn(`Abstract function.`)}update(){console.warn(`Abstract function.`)}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=uU[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){let n=this.generate.length===1;if(n){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(console.warn(`THREE.Node: Recursion detected.`,this),a=``):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return iU(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n]){let a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}},pU=fU,mU=class extends pU{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){let n=e.getBuildStage();if(n===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},hU=mU,gU=class extends pU{static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){let t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`);return`${n}[ ${r} ]`}},_U=gU,vU=class extends pU{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},yU=vU,bU=class extends hU{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;s+c>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i);let u=e.getComponentType(i);u!==a&&(l=e.format(l,u,a)),o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}},xU=bU;const SU=BV.join(``);var CU=class extends pU{static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(BV.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null,o=this.getVectorLength();o>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let s=n.build(e,a);i=this.components.length===r&&this.components===SU.slice(0,this.components.length)?e.format(s,a,t):e.format(`${s}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},wU=CU,TU=class extends hU{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=BV[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},EU=TU,DU=class extends hU{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=BV[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},OU=DU,kU=class extends pU{static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?aU(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=aU(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=sU(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?oU(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn(`Abstract function.`)}},AU=kU;const jU=/float|u?int/;var MU=class extends AU{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return jU.test(n)&&jU.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},NU=MU,PU=class extends pU{static get type(){return`MemberNode`}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){let t=this.node.build(e);return t+`.`+this.property}},FU=PU;let IU=null;const LU=new Map;function R(e,t){if(LU.has(e)){console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);LU.set(e,t)}const RU=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),zU=e=>RU(e).split(``).sort().join(``),BU={setup(e,t){let n=t.shift();return e(dW(n),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(IU.assign(n,...e),n);if(LU.has(t)){let r=LU.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}else if(t===`self`)return e;else if(t.endsWith(`Assign`)&&LU.has(t.slice(0,t.length-6))){let r=LU.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}else if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=RU(t),uW(new wU(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=zU(t.slice(3).toLowerCase()),n=>uW(new EU(e,t,uW(n)));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=zU(t.slice(4).toLowerCase()),()=>uW(new OU(uW(e),t));else if(t===`width`||t===`height`||t===`depth`)return t===`width`?t=`x`:t===`height`?t=`y`:t===`depth`&&(t=`z`),uW(new wU(e,t));else if(/^\d+$/.test(t)===!0)return uW(new _U(n,new NU(Number(t),`uint`)));else if(/^get$/.test(t)===!0)return e=>uW(new FU(n,e))}return Reflect.get(e,t,n)},set(e,t,n,r){return typeof t==`string`&&e[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t===`width`||t===`height`||t===`depth`||/^\d+$/.test(t)===!0)?(r[t].assign(n),!0):Reflect.set(e,t,n,r)}},VU=new WeakMap,HU=new WeakMap,UU=function(e,t=null){let n=aU(e);if(n===`node`){let t=VU.get(e);return t===void 0&&(t=new Proxy(e,BU),VU.set(e,t),VU.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return uW(aW(e,t));else if(n===`shader`)return mW(e);return e},WU=function(e,t=null){for(let n in e)e[n]=uW(e[n],t);return e},GU=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=uW(e[r],t);return e},KU=function(e,t=null,n=null,r=null){let i=e=>uW(r===null?e:Object.assign(e,r)),a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(console.error(`THREE.TSL: "${n}" parameter length is less than minimum required.`),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(console.error(`THREE.TSL: "${n}" parameter length exceeds limit.`),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...fW(l(t)))):n===null?a=(...n)=>i(new e(t,...fW(l(n)))):(n=uW(n),a=(...r)=>i(new e(t,...fW(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a};var qU=class extends pU{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace(`once`):`once`;if(r[i])return r[i];let a=null;if(t.layout){let r=HU.get(e.constructor);r===void 0&&(r=new WeakMap,HU.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=uW(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i),a=uW(i.call(n))}else{let r=t.jsFunc,i=n!==null||r.length>1?r(n||[],e):r(e);a=uW(i)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(r===`setup`){let t=e.getNamespace(`initialized`);i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return n}},JU=class extends pU{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return dW(e),uW(new qU(this,e))}setup(){return this.call()}};const YU=[!1,!0],XU=[0,1,2,3],ZU=[-1,-2],QU=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],$U=new Map;for(let e of YU)$U.set(e,new NU(e));const eW=new Map;for(let e of XU)eW.set(e,new NU(e,`uint`));const tW=new Map([...eW].map(e=>new NU(e.value,`int`)));for(let e of ZU)tW.set(e,new NU(e,`int`));const nW=new Map([...tW].map(e=>new NU(e.value)));for(let e of QU)nW.set(e,new NU(e));for(let e of QU)nW.set(-e,new NU(-e));const rW={bool:$U,uint:eW,ints:tW,float:nW},iW=new Map([...$U,...nW]),aW=(e,t)=>iW.has(e)?iW.get(e):e.isNode===!0?e:new NU(e,t),oW=e=>{try{return e.getNodeType()}catch{return}},sW=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[oU(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return uW(t.get(n[0]));if(n.length===1){let t=aW(n[0],e);return oW(t)===e?uW(t):uW(new yU(t,e))}let r=n.map(e=>aW(e));return uW(new xU(r,e))}},cW=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function lW(e,t){return new Proxy(new JU(e,t),BU)}const uW=(e,t=null)=>UU(e,t),dW=(e,t=null)=>new WU(e,t),fW=(e,t=null)=>new GU(e,t),z=(...e)=>new KU(...e);let pW=0;const mW=(e,t=null)=>{let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:console.error(`THREE.TSL: Invalid layout type.`),t=null));let r=new lW(e,n),i=(...e)=>{let t;dW(e);let i=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype);t=i?[...e]:e[0];let a=r.call(t);return n===`void`&&a.toStack(),a};if(i.shaderNode=r,i.id=r.id,i.getNodeType=(...e)=>r.getNodeType(...e),i.getCacheKey=(...e)=>r.getCacheKey(...e),i.setLayout=e=>(r.setLayout(e),i),i.once=(e=null)=>(r.once=!0,r.namespace=e,i),t!==null){if(typeof t.inputs!=`object`){let e={name:`fn`+ pW++,type:n,inputs:[]};for(let n in t){if(n===`return`)continue;e.inputs.push({name:n,type:t[n]})}t=e}i.setLayout(t)}return i};function hW(e){return IU&&IU.add(e),e}R(`toStack`,hW);const gW=new sW(`color`),_W=new sW(`float`,rW.float),vW=new sW(`int`,rW.ints),yW=new sW(`uint`,rW.uint),bW=new sW(`bool`,rW.bool),xW=new sW(`vec2`),SW=new sW(`ivec2`),CW=new sW(`uvec2`),wW=new sW(`bvec2`),TW=new sW(`vec3`),EW=new sW(`ivec3`),DW=new sW(`uvec3`),OW=new sW(`bvec3`),kW=new sW(`vec4`),AW=new sW(`ivec4`),jW=new sW(`uvec4`),MW=new sW(`bvec4`),NW=new sW(`mat2`),PW=new sW(`mat3`),FW=new sW(`mat4`);R(`toColor`,gW),R(`toFloat`,_W),R(`toInt`,vW),R(`toUint`,yW),R(`toBool`,bW),R(`toVec2`,xW),R(`toIVec2`,SW),R(`toUVec2`,CW),R(`toBVec2`,wW),R(`toVec3`,TW),R(`toIVec3`,EW),R(`toUVec3`,DW),R(`toBVec3`,OW),R(`toVec4`,kW),R(`toIVec4`,AW),R(`toUVec4`,jW),R(`toBVec4`,MW),R(`toMat2`,NW),R(`toMat3`,PW),R(`toMat4`,FW);const IW=z(_U).setParameterLength(2),LW=(e,t)=>uW(new yU(uW(e),t));R(`element`,IW),R(`convert`,LW),R(`append`,e=>(console.warn(`THREE.TSL: .append() has been renamed to .toStack().`),hW(e)));const RW={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var zW=class e extends hU{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(RW[this.op],t)}getNodeType(e){let t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i===`void`||a===`void`)return`void`;if(t===`%`)return i;if(t===`~`||t===`&`||t===`|`||t===`^`||t===`>>`||t===`<<`)return e.getIntegerType(i);if(t===`!`||t===`&&`||t===`||`||t===`^^`)return`bool`;if(t===`==`||t===`!=`||t===`<`||t===`>`||t===`<=`||t===`>=`){let t=Math.max(e.getTypeLength(i),e.getTypeLength(a));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(i)){if(a===`float`)return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i===`float`)return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===SH;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const BW=z(zW,`+`).setParameterLength(2,1/0).setName(`add`),VW=z(zW,`-`).setParameterLength(2,1/0).setName(`sub`),HW=z(zW,`*`).setParameterLength(2,1/0).setName(`mul`),UW=z(zW,`/`).setParameterLength(2,1/0).setName(`div`),WW=z(zW,`%`).setParameterLength(2).setName(`mod`),GW=z(zW,`==`).setParameterLength(2).setName(`equal`),KW=z(zW,`!=`).setParameterLength(2).setName(`notEqual`),qW=z(zW,`<`).setParameterLength(2).setName(`lessThan`),JW=z(zW,`>`).setParameterLength(2).setName(`greaterThan`),YW=z(zW,`<=`).setParameterLength(2).setName(`lessThanEqual`),XW=z(zW,`>=`).setParameterLength(2).setName(`greaterThanEqual`),ZW=z(zW,`&&`).setParameterLength(2,1/0).setName(`and`),QW=z(zW,`||`).setParameterLength(2,1/0).setName(`or`),$W=z(zW,`!`).setParameterLength(1).setName(`not`),eG=z(zW,`^^`).setParameterLength(2).setName(`xor`),tG=z(zW,`&`).setParameterLength(2).setName(`bitAnd`),nG=z(zW,`~`).setParameterLength(2).setName(`bitNot`),rG=z(zW,`|`).setParameterLength(2).setName(`bitOr`),iG=z(zW,`^`).setParameterLength(2).setName(`bitXor`),aG=z(zW,`<<`).setParameterLength(2).setName(`shiftLeft`),oG=z(zW,`>>`).setParameterLength(2).setName(`shiftRight`),sG=mW(([e])=>(e.addAssign(1),e)),cG=mW(([e])=>(e.subAssign(1),e)),lG=mW(([e])=>{let t=vW(e).toConst();return e.addAssign(1),t}),uG=mW(([e])=>{let t=vW(e).toConst();return e.subAssign(1),t});R(`add`,BW),R(`sub`,VW),R(`mul`,HW),R(`div`,UW),R(`mod`,WW),R(`equal`,GW),R(`notEqual`,KW),R(`lessThan`,qW),R(`greaterThan`,JW),R(`lessThanEqual`,YW),R(`greaterThanEqual`,XW),R(`and`,ZW),R(`or`,QW),R(`not`,$W),R(`xor`,eG),R(`bitAnd`,tG),R(`bitNot`,nG),R(`bitOr`,rG),R(`bitXor`,iG),R(`shiftLeft`,aG),R(`shiftRight`,oG),R(`incrementBefore`,sG),R(`decrementBefore`,cG),R(`increment`,lG),R(`decrement`,uG);const dG=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),WW(e,t)),fG=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),WW(vW(e),vW(t)));R(`remainder`,dG),R(`modInt`,fG);var B=class e extends hU{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=VW(1,n);else if(i===e.RECIPROCAL)a=UW(1,n);else if(i===e.DIFFERENCE)a=PG(VW(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=kW(TW(i),0):e=kW(TW(e),0);let o=HW(e,i).xyz;a=EG(o)}return a===null?super.setup(t):a}generate(t,n){let r=t.getNodeProperties(this);if(r.outputNode)return super.generate(t,n);let i=this.method,a=this.getNodeType(t),o=this.getInputType(t),s=this.aNode,c=this.bNode,l=this.cNode,u=t.renderer.coordinateSystem;if(i===e.NEGATE)return t.format(`( - `+s.build(t,o)+` )`,a,n);{let r=[];return i===e.CROSS?r.push(s.build(t,a),c.build(t,a)):u===SH&&i===e.STEP?r.push(s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:o),c.build(t,o)):u===SH&&(i===e.MIN||i===e.MAX)?r.push(s.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:o)):i===e.REFRACT?r.push(s.build(t,o),c.build(t,o),l.build(t,`float`)):i===e.MIX?r.push(s.build(t,o),c.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?`float`:o)):(u===CH&&i===e.ATAN&&c!==null&&(i=`atan2`),t.shaderStage!==`fragment`&&(i===e.DFDX||i===e.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i=`/*`+i+`*/`),r.push(s.build(t,o)),c!==null&&r.push(c.build(t,o)),l!==null&&r.push(l.build(t,o))),t.format(`${t.getMethod(i,a)}( ${r.join(`, `)} )`,a,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};B.ALL=`all`,B.ANY=`any`,B.RADIANS=`radians`,B.DEGREES=`degrees`,B.EXP=`exp`,B.EXP2=`exp2`,B.LOG=`log`,B.LOG2=`log2`,B.SQRT=`sqrt`,B.INVERSE_SQRT=`inversesqrt`,B.FLOOR=`floor`,B.CEIL=`ceil`,B.NORMALIZE=`normalize`,B.FRACT=`fract`,B.SIN=`sin`,B.COS=`cos`,B.TAN=`tan`,B.ASIN=`asin`,B.ACOS=`acos`,B.ATAN=`atan`,B.ABS=`abs`,B.SIGN=`sign`,B.LENGTH=`length`,B.NEGATE=`negate`,B.ONE_MINUS=`oneMinus`,B.DFDX=`dFdx`,B.DFDY=`dFdy`,B.ROUND=`round`,B.RECIPROCAL=`reciprocal`,B.TRUNC=`trunc`,B.FWIDTH=`fwidth`,B.TRANSPOSE=`transpose`,B.BITCAST=`bitcast`,B.EQUALS=`equals`,B.MIN=`min`,B.MAX=`max`,B.STEP=`step`,B.REFLECT=`reflect`,B.DISTANCE=`distance`,B.DIFFERENCE=`difference`,B.DOT=`dot`,B.CROSS=`cross`,B.POW=`pow`,B.TRANSFORM_DIRECTION=`transformDirection`,B.MIX=`mix`,B.CLAMP=`clamp`,B.REFRACT=`refract`,B.SMOOTHSTEP=`smoothstep`,B.FACEFORWARD=`faceforward`;const pG=_W(Math.PI),poe=_W(Math.PI*2),mG=z(B,B.ALL).setParameterLength(1),hG=z(B,B.ANY).setParameterLength(1),gG=z(B,B.RADIANS).setParameterLength(1),_G=z(B,B.DEGREES).setParameterLength(1),vG=z(B,B.EXP).setParameterLength(1),yG=z(B,B.EXP2).setParameterLength(1),bG=z(B,B.LOG).setParameterLength(1),xG=z(B,B.LOG2).setParameterLength(1),SG=z(B,B.SQRT).setParameterLength(1),CG=z(B,B.INVERSE_SQRT).setParameterLength(1),wG=z(B,B.FLOOR).setParameterLength(1),TG=z(B,B.CEIL).setParameterLength(1),EG=z(B,B.NORMALIZE).setParameterLength(1),DG=z(B,B.FRACT).setParameterLength(1),OG=z(B,B.SIN).setParameterLength(1),kG=z(B,B.COS).setParameterLength(1),AG=z(B,B.TAN).setParameterLength(1),jG=z(B,B.ASIN).setParameterLength(1),MG=z(B,B.ACOS).setParameterLength(1),NG=z(B,B.ATAN).setParameterLength(1,2),PG=z(B,B.ABS).setParameterLength(1),FG=z(B,B.SIGN).setParameterLength(1),IG=z(B,B.LENGTH).setParameterLength(1),LG=z(B,B.NEGATE).setParameterLength(1),RG=z(B,B.ONE_MINUS).setParameterLength(1),zG=z(B,B.DFDX).setParameterLength(1),BG=z(B,B.DFDY).setParameterLength(1),VG=z(B,B.ROUND).setParameterLength(1),HG=z(B,B.RECIPROCAL).setParameterLength(1),UG=z(B,B.TRUNC).setParameterLength(1),WG=z(B,B.FWIDTH).setParameterLength(1),GG=z(B,B.TRANSPOSE).setParameterLength(1),KG=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),GW(e,t)),qG=z(B,B.MIN).setParameterLength(2,1/0),JG=z(B,B.MAX).setParameterLength(2,1/0),YG=z(B,B.STEP).setParameterLength(2),XG=z(B,B.REFLECT).setParameterLength(2),ZG=z(B,B.DISTANCE).setParameterLength(2),QG=z(B,B.DIFFERENCE).setParameterLength(2),$G=z(B,B.DOT).setParameterLength(2),eK=z(B,B.CROSS).setParameterLength(2),tK=z(B,B.POW).setParameterLength(2),nK=z(B,B.POW,2).setParameterLength(1),rK=z(B,B.POW,3).setParameterLength(1),iK=z(B,B.POW,4).setParameterLength(1),aK=z(B,B.TRANSFORM_DIRECTION).setParameterLength(2),oK=e=>HW(FG(e),tK(PG(e),1/3)),sK=e=>$G(e,e),cK=z(B,B.MIX).setParameterLength(3),lK=(e,t=0,n=1)=>uW(new B(B.CLAMP,uW(e),uW(t),uW(n))),uK=e=>lK(e),dK=z(B,B.REFRACT).setParameterLength(3),fK=z(B,B.SMOOTHSTEP).setParameterLength(3),pK=z(B,B.FACEFORWARD).setParameterLength(3),mK=mW(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=$G(e.xy,xW(t,n)),a=WW(i,pG);return DG(OG(a).mul(r))}),hK=(e,t,n)=>cK(t,n,e),gK=(e,t,n)=>fK(t,n,e),_K=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),NG(e,t));R(`all`,mG),R(`any`,hG),R(`equals`,KG),R(`radians`,gG),R(`degrees`,_G),R(`exp`,vG),R(`exp2`,yG),R(`log`,bG),R(`log2`,xG),R(`sqrt`,SG),R(`inverseSqrt`,CG),R(`floor`,wG),R(`ceil`,TG),R(`normalize`,EG),R(`fract`,DG),R(`sin`,OG),R(`cos`,kG),R(`tan`,AG),R(`asin`,jG),R(`acos`,MG),R(`atan`,NG),R(`abs`,PG),R(`sign`,FG),R(`length`,IG),R(`lengthSq`,sK),R(`negate`,LG),R(`oneMinus`,RG),R(`dFdx`,zG),R(`dFdy`,BG),R(`round`,VG),R(`reciprocal`,HG),R(`trunc`,UG),R(`fwidth`,WG),R(`atan2`,_K),R(`min`,qG),R(`max`,JG),R(`step`,YG),R(`reflect`,XG),R(`distance`,ZG),R(`dot`,$G),R(`cross`,eK),R(`pow`,tK),R(`pow2`,nK),R(`pow3`,rK),R(`pow4`,iK),R(`transformDirection`,aK),R(`mix`,hK),R(`clamp`,lK),R(`refract`,dK),R(`smoothstep`,gK),R(`faceForward`,pK),R(`difference`,QG),R(`saturate`,uK),R(`cbrt`,oK),R(`transpose`,GG),R(`rand`,mK);var vK=class extends hU{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}};const yK=(...e)=>{let t;if(e.length===1){let n=e[0];t=new vK(null,n.length,n)}else{let n=e[0],r=e[1];t=new vK(n,r)}return uW(t)};R(`toArray`,(e,t)=>yK(Array(t).fill(e)));var bK=class extends pU{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}};const xK=e=>new bK(e),SK=(e,t=0)=>new bK(e,!0,t),CK=SK(`render`),wK=xK(`object`);var TK=class extends AU{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=wK}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){let n=this.getSelf();return e=e.bind(n),super.onUpdate(t=>{let r=e(t,n);r!==void 0&&(this.value=r)},t)}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),s=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(s,n,t)}};const EK=(e,t)=>{let n=cW(t||e),r=e&&e.isNode===!0?e.node&&e.node.value||e.value:e;return uW(new TK(r,n))};var DK=class extends pU{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}};const OK=(e,t)=>uW(new DK(e,t));var kK=class extends hU{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e)),r=BV.join(``).slice(0,n)!==t.components;return r}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),o=n.build(e),s=r.build(e,a),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=o);else if(i){let r=e.getVarFromNode(this,null,a),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}),d=l.build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${d}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=o)}else u=`${o} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=o));return l.initialized=!0,e.format(u,a,t)}};const AK=z(kK).setParameterLength(2);R(`assign`,AK);var jK=class extends hU{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)console.error(`THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(console.error(`THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(_W(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(console.error(`THREE.TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(_W(0),e))):t.push(a(n,e))}let o=n.build(e,`property`);return`${o}( ${t.join(`, `)} )`}};const MK=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?fW(t):dW(t[0]),uW(new jK(uW(e),t)));R(`call`,MK);var NK=class extends pU{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?OK(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
397
397
 
398
398
  `+e.tab+`}`),o!==null){e.addFlowCode(` else {
399
399
 
@@ -403,11 +403,11 @@ var<${n}> ${e} : ${a};`}},cj=class{constructor(e){this.backend=e}getCurrentDepth
403
403
 
404
404
  `)}else e.addFlowCode(`
405
405
 
406
- `);return e.format(l,n,t)}};const FK=z(PK).setParameterLength(2,3);R(`select`,FK);const IK=(...e)=>(console.warn(`THREE.TSL: cond() has been renamed to select().`),FK(...e));R(`cond`,IK);var LK=class extends mU{static get type(){return`ContextNode`}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){let n=e.getContext();e.setContext({...e.context,...this.value});let r=this.node.build(e,t);return e.setContext(n),r}};const RK=z(LK).setParameterLength(1,2),zK=(e,t)=>RK(e,{label:t});R(`context`,RK),R(`label`,zK);var BK=class extends mU{static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=e.getVectorType(this.getNodeType(e)),l=t.build(e,c),u=e.getVarFromNode(this,n,c,void 0,s),d=e.getPropertyName(u),f=d;if(s)if(a)f=o?`const ${d}`:`let ${d}`;else{let n=e.getArrayCount(t);f=`const ${e.getVar(u.type,d,n)}`}return e.addLineFlowCode(`${f} = ${l}`,this),d}};const VK=z(BK),HK=(e,t=null)=>VK(e,t).toStack(),UK=(e,t=null)=>VK(e,t,!0).toStack();R(`toVar`,HK),R(`toConst`,UK);const WK=e=>(console.warn(`TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.`),VK(e));R(`temp`,WK);var GK=class extends mU{static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){var t;let n=e.getNodeProperties(this),r=n.varying;if(r===void 0){let t=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;n.varying=r=e.getVaryingFromNode(this,t,i,a,o),n.node=this.node}return(t=r).needsInterpolation||(t.needsInterpolation=e.shaderStage===`fragment`),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(RV.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(RV.VERTEX,this.node)}generate(e){let t=e.getNodeProperties(this),n=this.setupVarying(e);if(t.propertyName===void 0){let r=this.getNodeType(e),i=e.getPropertyName(n,RV.VERTEX);e.flowNodeFromShaderStage(RV.VERTEX,this.node,r,i),t.propertyName=i}return e.getPropertyName(n)}};const KK=z(GK).setParameterLength(1,2),qK=e=>KK(e);R(`toVarying`,KK),R(`toVertexStage`,qK),R(`varying`,(...e)=>(console.warn(`THREE.TSL: .varying() has been renamed to .toVarying().`),KK(...e))),R(`vertexStage`,(...e)=>(console.warn(`THREE.TSL: .vertexStage() has been renamed to .toVertexStage().`),KK(...e)));const JK=hW(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),r=e.lessThanEqual(.04045),i=lK(t,n,r);return i}).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),YK=hW(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),r=e.lessThanEqual(.0031308),i=lK(t,n,r);return i}).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),XK=`WorkingColorSpace`,ZK=`OutputColorSpace`;var QK=class extends gU{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===XK?MH.workingColorSpace:t===ZK?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return MH.enabled===!1||n===r||!n||!r?i:(MH.getTransfer(n)===xH&&(i=AW(JK(i.rgb),i.a)),MH.getPrimaries(n)!==MH.getPrimaries(r)&&(i=AW(FW(MH._getMatrix(new TH,n,r)).mul(i.rgb),i.a)),MH.getTransfer(r)===xH&&(i=AW(YK(i.rgb),i.a)),i)}};const $K=(e,t)=>dW(new QK(dW(e),XK,t)),eq=(e,t)=>dW(new QK(dW(e),t,XK));R(`workingToColorSpace`,$K),R(`colorSpaceToWorking`,eq);var tq=class extends vU{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},nq=class extends mU{static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=zV.OBJECT}setGroup(e){return this.group=e,this}element(e){return dW(new tq(this,dW(e)))}setNodeType(e){let t=DK(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},rq=nq,iq=class extends rq{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(wK)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}};const aq=(e,t,n=null)=>dW(new iq(e,t,n));var oq=class extends gU{static get type(){return`ToneMappingNode`}constructor(e,t=cq,n=null){super(`vec3`),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return rU(this.toneMapping)}setup(e){let t=this.colorNode||e.context.color,n=this.toneMapping;if(n===hH)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(console.error(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=AW(i(t.rgb,this.exposureNode),t.a),r}};const sq=(e,t,n)=>dW(new oq(e,dW(t),dW(n))),cq=aq(`toneMappingExposure`,`float`);R(`toneMapping`,(e,t,n)=>sq(t,n,e));const lq=new UH,uq=new eU;let dq=0;var fq=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:dq++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=SH,this.updateRanges=[],this.gpuType=gH,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)uq.fromBufferAttribute(this,t),uq.applyMatrix3(e),this.setXY(t,uq.x,uq.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)lq.fromBufferAttribute(this,t),lq.applyMatrix3(e),this.setXYZ(t,lq.x,lq.y,lq.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)lq.fromBufferAttribute(this,t),lq.applyMatrix4(e),this.setXYZ(t,lq.x,lq.y,lq.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)lq.fromBufferAttribute(this,t),lq.applyNormalMatrix(e),this.setXYZ(t,lq.x,lq.y,lq.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)lq.fromBufferAttribute(this,t),lq.transformDirection(e),this.setXYZ(t,lq.x,lq.y,lq.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=fH(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=pH(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=fH(t,this.array)),t}setX(e,t){return this.normalized&&(t=pH(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=fH(t,this.array)),t}setY(e,t){return this.normalized&&(t=pH(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=fH(t,this.array)),t}setZ(e,t){return this.normalized&&(t=pH(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=fH(t,this.array)),t}setW(e,t){return this.normalized&&(t=pH(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=pH(t,this.array),n=pH(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=pH(t,this.array),n=pH(n,this.array),r=pH(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=pH(t,this.array),n=pH(n,this.array),r=pH(r,this.array),i=pH(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==SH&&(e.usage=this.usage),e}};const pq=new UH;var mq=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)pq.fromBufferAttribute(this,t),pq.applyMatrix4(e),this.setXYZ(t,pq.x,pq.y,pq.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)pq.fromBufferAttribute(this,t),pq.applyNormalMatrix(e),this.setXYZ(t,pq.x,pq.y,pq.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)pq.fromBufferAttribute(this,t),pq.transformDirection(e),this.setXYZ(t,pq.x,pq.y,pq.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=fH(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=pH(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=pH(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=pH(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=pH(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=pH(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=fH(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=fH(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=fH(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=fH(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=pH(t,this.array),n=pH(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=pH(t,this.array),n=pH(n,this.array),r=pH(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=pH(t,this.array),n=pH(n,this.array),r=pH(r,this.array),i=pH(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new fq(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log(`THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},hq=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=SH,this.updateRanges=[],this.version=0,this.uuid=KV()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=KV()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=KV()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},gq=class extends jU{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=SH,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),i=this.bufferStride||r,a=this.bufferOffset,o=n.isInterleavedBuffer===!0?n:new hq(n,i),s=new mq(o,r,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=r,i=r;else{let n=KK(this);i=n.build(e,t)}return i}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};const _q=(e,t=null,n=0,r=0)=>dW(new gq(e,t,n,r));R(`toAttribute`,e=>_q(e.value));var vq=class extends mU{static get type(){return`ComputeNode`}constructor(e,t,n=[64]){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name=``,this.updateBeforeType=zV.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:`dispose`})}label(e){return this.name=e,this}updateDispatchCount(){let{count:e,workgroupSize:t}=this,n=t[0];for(let e=1;e<t.length;e++)n*=t[e];this.dispatchCount=Math.ceil(e/n)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}else{let n=e.getNodeProperties(this),r=n.outputComputeNode;if(r)return r.build(e,t)}}};const yq=(e,t,n)=>dW(new vq(dW(e),t,n));R(`compute`,yq);var bq=class extends mU{static get type(){return`CacheNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}};const xq=(e,t)=>dW(new bq(dW(e),t));R(`cache`,xq);var Sq=class extends mU{static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}};const Cq=z(Sq).setParameterLength(2);R(`bypass`,Cq);var wq=class extends mU{static get type(){return`RemapNode`}constructor(e,t,n,r=vW(0),i=vW(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}};const Tq=z(wq,null,null,{doClamp:!1}).setParameterLength(3,5),Eq=z(wq).setParameterLength(3,5);R(`remap`,Tq),R(`remapClamp`,Eq);var Dq=class extends mU{static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}};const Oq=z(Dq).setParameterLength(1,2),kq=e=>(e?FK(e,Oq(`discard`)):Oq(`discard`)).toStack();R(`discard`,kq);var Aq=class extends gU{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color,n=(this.toneMapping===null?e.toneMapping:this.toneMapping)||hH,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||_H;return n!==hH&&(t=t.toneMapping(n)),r!==_H&&r!==MH.workingColorSpace&&(t=t.workingToColorSpace(r)),t}};const jq=(e,t=null,n=null)=>dW(new Aq(dW(e),t,n));R(`renderOutput`,jq);var Mq=class extends gU{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e),r=`--- TSL debug - `+e.shaderStage+` shader ---`,i=`-`.repeat(r.length),a=``;return a+=`// #`+r+`#
406
+ `);return e.format(l,n,t)}};const PK=z(NK).setParameterLength(2,3);R(`select`,PK);const FK=(...e)=>(console.warn(`THREE.TSL: cond() has been renamed to select().`),PK(...e));R(`cond`,FK);var IK=class extends pU{static get type(){return`ContextNode`}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){let n=e.getContext();e.setContext({...e.context,...this.value});let r=this.node.build(e,t);return e.setContext(n),r}};const LK=z(IK).setParameterLength(1,2),RK=(e,t)=>LK(e,{label:t});R(`context`,LK),R(`label`,RK);var zK=class extends pU{static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=e.getVectorType(this.getNodeType(e)),l=t.build(e,c),u=e.getVarFromNode(this,n,c,void 0,s),d=e.getPropertyName(u),f=d;if(s)if(a)f=o?`const ${d}`:`let ${d}`;else{let n=e.getArrayCount(t);f=`const ${e.getVar(u.type,d,n)}`}return e.addLineFlowCode(`${f} = ${l}`,this),d}};const BK=z(zK),VK=(e,t=null)=>BK(e,t).toStack(),HK=(e,t=null)=>BK(e,t,!0).toStack();R(`toVar`,VK),R(`toConst`,HK);const UK=e=>(console.warn(`TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.`),BK(e));R(`temp`,UK);var WK=class extends pU{static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){var t;let n=e.getNodeProperties(this),r=n.varying;if(r===void 0){let t=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;n.varying=r=e.getVaryingFromNode(this,t,i,a,o),n.node=this.node}return(t=r).needsInterpolation||(t.needsInterpolation=e.shaderStage===`fragment`),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(LV.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(LV.VERTEX,this.node)}generate(e){let t=e.getNodeProperties(this),n=this.setupVarying(e);if(t.propertyName===void 0){let r=this.getNodeType(e),i=e.getPropertyName(n,LV.VERTEX);e.flowNodeFromShaderStage(LV.VERTEX,this.node,r,i),t.propertyName=i}return e.getPropertyName(n)}};const GK=z(WK).setParameterLength(1,2),KK=e=>GK(e);R(`toVarying`,GK),R(`toVertexStage`,KK),R(`varying`,(...e)=>(console.warn(`THREE.TSL: .varying() has been renamed to .toVarying().`),GK(...e))),R(`vertexStage`,(...e)=>(console.warn(`THREE.TSL: .vertexStage() has been renamed to .toVertexStage().`),GK(...e)));const qK=mW(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),r=e.lessThanEqual(.04045),i=cK(t,n,r);return i}).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),JK=mW(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),r=e.lessThanEqual(.0031308),i=cK(t,n,r);return i}).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),YK=`WorkingColorSpace`,XK=`OutputColorSpace`;var ZK=class extends hU{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===YK?jH.workingColorSpace:t===XK?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return jH.enabled===!1||n===r||!n||!r?i:(jH.getTransfer(n)===bH&&(i=kW(qK(i.rgb),i.a)),jH.getPrimaries(n)!==jH.getPrimaries(r)&&(i=kW(PW(jH._getMatrix(new wH,n,r)).mul(i.rgb),i.a)),jH.getTransfer(r)===bH&&(i=kW(JK(i.rgb),i.a)),i)}};const QK=(e,t)=>uW(new ZK(uW(e),YK,t)),$K=(e,t)=>uW(new ZK(uW(e),t,YK));R(`workingToColorSpace`,QK),R(`colorSpaceToWorking`,$K);var eq=class extends _U{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},tq=class extends pU{static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=RV.OBJECT}setGroup(e){return this.group=e,this}element(e){return uW(new eq(this,uW(e)))}setNodeType(e){let t=EK(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},nq=tq,rq=class extends nq{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(CK)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}};const iq=(e,t,n=null)=>uW(new rq(e,t,n));var aq=class extends hU{static get type(){return`ToneMappingNode`}constructor(e,t=sq,n=null){super(`vec3`),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return nU(this.toneMapping)}setup(e){let t=this.colorNode||e.context.color,n=this.toneMapping;if(n===mH)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(console.error(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=kW(i(t.rgb,this.exposureNode),t.a),r}};const oq=(e,t,n)=>uW(new aq(e,uW(t),uW(n))),sq=iq(`toneMappingExposure`,`float`);R(`toneMapping`,(e,t,n)=>oq(t,n,e));const cq=new HH,lq=new $H;let uq=0;var dq=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:uq++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=xH,this.updateRanges=[],this.gpuType=hH,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)lq.fromBufferAttribute(this,t),lq.applyMatrix3(e),this.setXY(t,lq.x,lq.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)cq.fromBufferAttribute(this,t),cq.applyMatrix3(e),this.setXYZ(t,cq.x,cq.y,cq.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)cq.fromBufferAttribute(this,t),cq.applyMatrix4(e),this.setXYZ(t,cq.x,cq.y,cq.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)cq.fromBufferAttribute(this,t),cq.applyNormalMatrix(e),this.setXYZ(t,cq.x,cq.y,cq.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)cq.fromBufferAttribute(this,t),cq.transformDirection(e),this.setXYZ(t,cq.x,cq.y,cq.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=dH(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=fH(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=dH(t,this.array)),t}setX(e,t){return this.normalized&&(t=fH(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=dH(t,this.array)),t}setY(e,t){return this.normalized&&(t=fH(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=dH(t,this.array)),t}setZ(e,t){return this.normalized&&(t=fH(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=dH(t,this.array)),t}setW(e,t){return this.normalized&&(t=fH(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=fH(t,this.array),n=fH(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=fH(t,this.array),n=fH(n,this.array),r=fH(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=fH(t,this.array),n=fH(n,this.array),r=fH(r,this.array),i=fH(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==xH&&(e.usage=this.usage),e}};const fq=new HH;var pq=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)fq.fromBufferAttribute(this,t),fq.applyMatrix4(e),this.setXYZ(t,fq.x,fq.y,fq.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)fq.fromBufferAttribute(this,t),fq.applyNormalMatrix(e),this.setXYZ(t,fq.x,fq.y,fq.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)fq.fromBufferAttribute(this,t),fq.transformDirection(e),this.setXYZ(t,fq.x,fq.y,fq.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=dH(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=fH(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=fH(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=fH(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=fH(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=fH(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=dH(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=dH(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=dH(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=dH(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=fH(t,this.array),n=fH(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=fH(t,this.array),n=fH(n,this.array),r=fH(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=fH(t,this.array),n=fH(n,this.array),r=fH(r,this.array),i=fH(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new dq(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log(`THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},mq=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=xH,this.updateRanges=[],this.version=0,this.uuid=GV()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=GV()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=GV()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},hq=class extends AU{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=xH,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),i=this.bufferStride||r,a=this.bufferOffset,o=n.isInterleavedBuffer===!0?n:new mq(n,i),s=new pq(o,r,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=r,i=r;else{let n=GK(this);i=n.build(e,t)}return i}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};const gq=(e,t=null,n=0,r=0)=>uW(new hq(e,t,n,r));R(`toAttribute`,e=>gq(e.value));var _q=class extends pU{static get type(){return`ComputeNode`}constructor(e,t,n=[64]){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name=``,this.updateBeforeType=RV.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:`dispose`})}label(e){return this.name=e,this}updateDispatchCount(){let{count:e,workgroupSize:t}=this,n=t[0];for(let e=1;e<t.length;e++)n*=t[e];this.dispatchCount=Math.ceil(e/n)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}else{let n=e.getNodeProperties(this),r=n.outputComputeNode;if(r)return r.build(e,t)}}};const vq=(e,t,n)=>uW(new _q(uW(e),t,n));R(`compute`,vq);var yq=class extends pU{static get type(){return`CacheNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}};const bq=(e,t)=>uW(new yq(uW(e),t));R(`cache`,bq);var xq=class extends pU{static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}};const Sq=z(xq).setParameterLength(2);R(`bypass`,Sq);var Cq=class extends pU{static get type(){return`RemapNode`}constructor(e,t,n,r=_W(0),i=_W(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}};const wq=z(Cq,null,null,{doClamp:!1}).setParameterLength(3,5),Tq=z(Cq).setParameterLength(3,5);R(`remap`,wq),R(`remapClamp`,Tq);var Eq=class extends pU{static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}};const Dq=z(Eq).setParameterLength(1,2),Oq=e=>(e?PK(e,Dq(`discard`)):Dq(`discard`)).toStack();R(`discard`,Oq);var kq=class extends hU{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color,n=(this.toneMapping===null?e.toneMapping:this.toneMapping)||mH,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||gH;return n!==mH&&(t=t.toneMapping(n)),r!==gH&&r!==jH.workingColorSpace&&(t=t.workingToColorSpace(r)),t}};const Aq=(e,t=null,n=null)=>uW(new kq(uW(e),t,n));R(`renderOutput`,Aq);var jq=class extends hU{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e),r=`--- TSL debug - `+e.shaderStage+` shader ---`,i=`-`.repeat(r.length),a=``;return a+=`// #`+r+`#
407
407
  `,a+=e.flow.code.replace(/^\t/gm,``)+`
408
408
  `,a+=`/* ... */ `+n+` /* ... */
409
409
  `,a+=`// #`+i+`#
410
- `,t===null?console.log(a):t(e,a),n}};const Nq=(e,t=null)=>dW(new Mq(dW(e),t));R(`debug`,Nq);const Pq=hW(([e])=>Rq(e.rgb)),Fq=hW(([e,t=vW(1)])=>t.mix(Rq(e.rgb),e.rgb)),Iq=hW(([e,t=vW(1)])=>{let n=VW(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return lK(e.rgb,r,i)}),Lq=hW(([e,t=vW(1)])=>{let n=EW(.57735,.57735,.57735),r=t.cos();return EW(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(eK(n,e.rgb).mul(r.oneMinus())))))}),Rq=(e,t=EW(MH.getLuminanceCoefficients(new UH)))=>eK(e,t),zq={name:`Grayscale`,props:{},fragmentNode:({childNode:e})=>{let{vec4:t}=xj;if(!e)return console.error(`You must pass a child component into the Grayscale shader.`),t(0);let n=e||t(0,0,0,0);return t(Pq(n.rgb).rgb,n.a)}};var Bq=r({__name:`Grayscale`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{}},{blendMode:`normal`,opacity:1,...Object.entries(zq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${zq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(zq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(zq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(zq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,zq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Vq=Bq;const Hq={name:`HueShift`,props:{shift:{type:Number,default:0,description:`The amount to shift the hue by`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=xj;if(!t)return console.error(`You must pass a child component into the Hue Shift shader.`),n(0);let r=t||n(0,0,0,0);return n(Lq(r.rgb,e.shift.uniform).rgb,r.a)}};var Uq=r({__name:`HueShift`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},shift:{}},{blendMode:`normal`,opacity:1,...Object.entries(Hq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Hq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Hq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Hq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(Hq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Hq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Wq=Uq;const Gq={name:`Invert`,props:{},fragmentNode:({childNode:e})=>{let{vec4:t,vec3:n}=xj;if(!e)return console.error(`You must pass a child component into the Invert shader.`),t(0);let r=e||t(0,0,0,0);return t(n(1,1,1).sub(r.rgb),r.a)}};var Kq=r({__name:`Invert`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{}},{blendMode:`normal`,opacity:1,...Object.entries(Gq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Gq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Gq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Gq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(Gq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Gq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),qq=Kq;const Jq={name:`LinearGradient`,props:{startColor:{type:String,default:`#1aff00`,transform:bV,description:`The starting color of the gradient`},endColor:{type:String,default:`#0000ff`,transform:bV,description:`The ending color of the gradient`},angle:{type:Number,default:0,description:`rotation angle in degrees (0-360, where 0 = left-to-right)`},center:{type:Object,default:{x:.5,y:.5},transform:xV},autoRotate:{type:Boolean,default:!1,description:`Enable automatic rotation of the gradient`},autoRotateSpeed:{type:Number,default:1,description:`Speed of the automatic rotation in degrees per second`}},fragmentNode:({uniforms:e,onBeforeRender:t})=>{let{vec2:n,mix:r,float:i,cos:a,sin:o,dot:s,radians:c,viewportUV:l,abs:u,div:d,uniform:f}=xj,p=f(0);t(({deltaTime:t})=>{if(e.autoRotate.uniform.value){let n=e.autoRotateSpeed.uniform.value*t*100;p.value=(p.value+n)%360}});let m=e.angle.uniform.add(p),h=c(m),g=a(h),_=o(h),v=n(g,_),y=n(e.center.uniform[0],e.center.uniform[1]),b=l.sub(y),x=s(b,v),S=i(.5).mul(u(g).add(u(_))),ee=d(x,S.max(1e-6)),te=ee.mul(.5).add(.5).clamp(i(0),i(1));return r(e.startColor.uniform,e.endColor.uniform,te)}};var Yq=r({__name:`LinearGradient`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},startColor:{},endColor:{},angle:{},center:{},autoRotate:{type:Boolean},autoRotateSpeed:{}},{blendMode:`normal`,opacity:1,...Object.entries(Jq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Jq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Jq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Jq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(Jq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Jq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Xq=Yq;const Zq=new WeakMap,Qq={name:`MouseDistortion`,props:{viscosity:{type:Number,default:1,description:`Fluid resistance (0-1, higher = more viscous)`},velocityScale:{type:Number,default:1,description:`Speed multiplier for fluid motion`},vorticity:{type:Number,default:0,description:`Swirl strength (0-1)`},dissipation:{type:Number,default:5,description:`How quickly the effect fades (0-1)`},splatRadius:{type:Number,default:.05,description:`Radius of fluid splat effect (0-1)`}},fragmentNode:({uniforms:e,onBeforeRender:t,childNode:n,onCleanup:r,canvas:i})=>{let{vec2:a,vec4:o,float:s,uniform:c,length:l,viewportUV:u,convertToTexture:d,smoothstep:f}=xj;if(!n)return o(u.x,u.y,0,1);let p=d(n),m=Zq.get(i);m||(m=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect,i=window.devicePixelRatio||1;p.setSize(Math.round(n*i),Math.round(r*i))}),m.observe(i),Zq.set(i,m)),r(()=>{let e=Zq.get(i);e&&(e.disconnect(),Zq.delete(i))});let h=8,g=h*h,_=[],v=[];for(let e=0;e<g;e++)_.push(c(0)),v.push(c(0));let y=c(.5),b=c(.5),x=c(0),S=c(0),ee=.5,te=.5,ne=Date.now();t(({pointer:t})=>{let n=Date.now(),r=Math.min((n-ne)/1e3,.016);ne=n;let i=(t.x-ee)/r,a=(t.y-te)/r,o=.85;x.value=x.value*o+i*(1-o),S.value=S.value*o+a*(1-o),y.value=t.x,b.value=t.y;let s=e.dissipation.uniform.value,c=1-s*r;for(let e=0;e<g;e++){_[e].value*=c,v[e].value*=c;let t=1;_[e].value=Math.max(-t,Math.min(t,_[e].value)),v[e].value=Math.max(-t,Math.min(t,v[e].value))}if(Math.abs(i)>.01||Math.abs(a)>.01){let n=e.velocityScale.uniform.value,i=e.splatRadius.uniform.value;for(let a=0;a<h;a++)for(let o=0;o<h;o++){let s=a*h+o,c=(o+.5)/h,l=(a+.5)/h,u=c-t.x,d=l-t.y,f=Math.sqrt(u*u+d*d);if(f<i*2){let t=Math.exp(-f*f/(i*i));if(_[s].value+=x.value*t*n*r*.5,v[s].value+=S.value*t*n*r*.5,e.vorticity.uniform.value>0){let n=Math.atan2(d,u)+Math.PI*.5,i=e.vorticity.uniform.value;_[s].value+=Math.cos(n)*i*t*r*2,v[s].value+=Math.sin(n)*i*t*r*2}}}}ee=t.x,te=t.y});let re=a(u.x,u.y),ie=s(0),ae=s(0),oe=s(0);for(let e=0;e<h;e++)for(let t=0;t<h;t++){let n=e*h+t,r=(t+.5)/h,i=(e+.5)/h,o=re.x.sub(s(r)),c=re.y.sub(s(i)),u=l(a(o,c)),d=s(1.5/h),p=f(d,s(0),u);ie=ie.add(_[n].mul(p)),ae=ae.add(v[n].mul(p)),oe=oe.add(p)}let se=s(.1),ce=a(ie.clamp(se.negate(),se),ae.clamp(se.negate(),se)),le=l(ce).greaterThan(s(1e-5)),ue=re.sub(ce),de=le.cond(a(ue.x,s(1).sub(ue.y)),a(re.x,s(1).sub(re.y)));return p.sample(de)}};var $q=r({__name:`MouseDistortion`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},viscosity:{},velocityScale:{},vorticity:{},dissipation:{},splatRadius:{}},{blendMode:`normal`,opacity:1,...Object.entries(Qq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Qq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Qq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Qq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(Qq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Qq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),eJ=$q,tJ=class extends gU{static get type(){return`PosterizeNode`}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){let{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}};const nJ=z(tJ).setParameterLength(2),rJ={name:`Posterize`,props:{intensity:{type:Number,default:5,description:`The intensity of the posterization effect (lower is more posterized)`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n,int:r}=xj;if(!t)return console.error(`You must pass a child component into the Posterize shader.`),n(0);let i=t||n(0,0,0,0);return nJ(i,r(e.intensity.uniform))}};var iJ=r({__name:`Posterize`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(rJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${rJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(rJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(rJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(rJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,rJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),aJ=iJ;const oJ={name:`Saturation`,props:{intensity:{type:Number,default:1,description:`The intensity of the saturation effect (1 being no change)`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=xj;if(!t)return console.error(`You must pass a child component into the Saturation shader.`),n(0);let r=t||n(0,0,0,0);return n(Fq(r.rgb,e.intensity.uniform).rgb,r.a)}};var sJ=r({__name:`Saturation`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(oJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${oJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(oJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(oJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(oJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,oJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),cJ=sJ;const lJ={name:`SolidColor`,props:{color:{type:String,default:`#5b18ca`,transform:bV,description:`The solid color to display`}},fragmentNode:({uniforms:e})=>e.color.uniform};var uJ=r({__name:`SolidColor`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{}},{blendMode:`normal`,opacity:1,...Object.entries(lJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${lJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(lJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(lJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(lJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,lJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),dJ=uJ;const fJ={name:`Swirl`,props:{colorA:{type:String,default:`#1275d8`,description:`Primary gradient color`,transform:bV},colorB:{type:String,default:`#e19136`,description:`Secondary gradient color`,transform:bV},colorC:{type:String,default:`#320485`,description:`Accent gradient color`,transform:bV},speed:{type:Number,default:1,description:`Flow animation speed`},scale:{type:Number,default:5,description:`Gradient scale`},complexity:{type:Number,default:5,description:`Flow complexity`}},fragmentNode:({uniforms:e})=>{let t=nF(),n=SP.mul(e.speed.uniform),r=e.scale.uniform,i=e.complexity.uniform,a=zN(t.x.mul(r.mul(1.2)).add(n.mul(.8))).mul(.3),o=kM(t.y.mul(r.mul(.9)).sub(n.mul(.6))).mul(.3),s=lF(t.x.add(zN(t.y.mul(i.mul(2)).add(n)).mul(.08)),t.y.add(kM(t.x.mul(i.mul(1.5)).sub(n.mul(.7))).mul(.08))),c=zN(s.x.mul(r.mul(3)).add(s.y.mul(r.mul(2))).add(n.mul(.5))),l=kM(s.x.sub(s.y).mul(r.mul(2.5)).add(n.mul(.3))),u=zN(s.x.mul(i).add(a).add(s.y.mul(i.mul(.8)).add(o)).add(n.mul(.4))),d=PM(c,l,u.mul(.5).add(.5)),f=s.x.mul(.7).add(s.y.mul(.3)).add(d.mul(.2)),p=PM(e.colorA.uniform,e.colorB.uniform,HN(.1,.6,f)),m=PM(p,e.colorC.uniform,HN(.4,.9,f.add(u.mul(.3)))),h=zN(n.mul(3).add(f.mul(10))).mul(.02).add(1),g=m.mul(h);return dF(g,1)}};var pJ=r({__name:`Swirl`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},colorA:{},colorB:{},colorC:{},speed:{},scale:{},complexity:{}},{blendMode:`normal`,opacity:1,...Object.entries(fJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${fJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(fJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(fJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(fJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,fJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),mJ=pJ;const hJ={name:`Twirl`,props:{center:{type:Object,default:{x:.5,y:.5},transform:xV,description:`The center point of the twirl effect`},intensity:{type:Number,default:1,description:`The strength of the twirl effect`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec2:n,vec4:r,cos:i,sin:a,length:o,uv:s,convertToTexture:c}=xj;if(!t)return console.error(`You must pass a child component into the Twirl shader.`),r(0);let l=c(t),u=s(),d=n(e.center.uniform.x,e.center.uniform.y),f=u.sub(d),p=e.intensity.uniform.mul(o(f)),m=i(p),h=a(p),g=m.mul(f.x).sub(h.mul(f.y)),_=h.mul(f.x).add(m.mul(f.y)),v=n(g.add(d.x),_.add(d.y));return r(l.sample(v))}};var gJ=r({__name:`Twirl`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},center:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(hJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${hJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(hJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(hJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(hJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,hJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),_J=gJ;const vJ={name:`Vibrance`,props:{intensity:{type:Number,default:0,description:`The intensity of the vibrance effect`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=xj;if(!t)return console.error(`You must pass a child component into the Vibrance shader.`),n(0);let r=t||n(0,0,0,0);return n(Iq(r.rgb,e.intensity.uniform).rgb,r.a)}};var yJ=r({__name:`Vibrance`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(vJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${vJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(vJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(vJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=nI(vJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,vJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),bJ=yJ;const xJ=`177`,SJ=0,CJ=3,wJ=0,TJ=1,EJ=0,DJ=1,OJ=100,kJ=204,AJ=205,jJ=3,MJ=0,NJ=0,PJ=300,FJ=301,IJ=302,LJ=306,RJ=1e3,zJ=1001,BJ=1002,VJ=1003,HJ=1006,UJ=1008,WJ=1008,GJ=1009,KJ=1013,qJ=1014,JJ=1015,YJ=1016,XJ=1023,ZJ=1026,QJ=1027,$J=1030,eY=2300,tY=2301,nY=2302,rY=2400,iY=2401,aY=2402,oY=0,sY=1,cY=``,lY=`srgb`,uY=`srgb-linear`,dY=`linear`,fY=`srgb`,pY=7680,mY=519,hY=512,gY=513,_Y=514,vY=515,yY=516,bY=517,xY=518,SY=519,CY=35044,wY=35048,TY=2e3,EY=2001;var DY=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const OY=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`);let kY=1234567;const AY=Math.PI/180,jY=180/Math.PI;function MY(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=OY[e&255]+OY[e>>8&255]+OY[e>>16&255]+OY[e>>24&255]+`-`+OY[t&255]+OY[t>>8&255]+`-`+OY[t>>16&15|64]+OY[t>>24&255]+`-`+OY[n&63|128]+OY[n>>8&255]+`-`+OY[n>>16&255]+OY[n>>24&255]+OY[r&255]+OY[r>>8&255]+OY[r>>16&255]+OY[r>>24&255];return i.toLowerCase()}function NY(e,t,n){return Math.max(t,Math.min(n,e))}function PY(e,t){return(e%t+t)%t}function FY(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function IY(e,t,n){return e===t?0:(n-e)/(t-e)}function LY(e,t,n){return(1-n)*e+n*t}function RY(e,t,n,r){return LY(e,t,1-Math.exp(-n*r))}function zY(e,t=1){return t-Math.abs(PY(e,t*2)-t)}function BY(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function VY(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function HY(e,t){return e+Math.floor(Math.random()*(t-e+1))}function UY(e,t){return e+Math.random()*(t-e)}function WY(e){return e*(.5-Math.random())}function GY(e){e!==void 0&&(kY=e);let t=kY+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function KY(e){return e*AY}function qY(e){return e*jY}function JY(e){return(e&e-1)==0&&e!==0}function YY(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function XY(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function ZY(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function QY(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function $Y(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const eX={DEG2RAD:AY,RAD2DEG:jY,generateUUID:MY,clamp:NY,euclideanModulo:PY,mapLinear:FY,inverseLerp:IY,lerp:LY,damp:RY,pingpong:zY,smoothstep:BY,smootherstep:VY,randInt:HY,randFloat:UY,randFloatSpread:WY,seededRandom:GY,degToRad:KY,radToDeg:qY,isPowerOfTwo:JY,ceilPowerOfTwo:YY,floorPowerOfTwo:XY,setQuaternionFromProperEuler:ZY,normalize:$Y,denormalize:QY};var tX=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=NY(this.x,e.x,t.x),this.y=NY(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=NY(this.x,e,t),this.y=NY(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(NY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(NY(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},nX=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(NY(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},V=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(iX.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(iX.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=NY(this.x,e.x,t.x),this.y=NY(this.y,e.y,t.y),this.z=NY(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=NY(this.x,e,t),this.y=NY(this.y,e,t),this.z=NY(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(NY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return rX.copy(this).projectOnVector(e),this.sub(rX)}reflect(e){return this.sub(rX.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(NY(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const rX=new V,iX=new nX;var aX=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(oX.makeScale(e,t)),this}rotate(e){return this.premultiply(oX.makeRotation(-e)),this}translate(e,t){return this.premultiply(oX.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const oX=new aX;function sX(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function cX(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}const lX={};function uX(e){e in lX||(lX[e]=!0,console.warn(e))}const dX=new aX().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),fX=new aX().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function pX(){let e={enabled:!0,workingColorSpace:uY,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===fY&&(e.r=hX(e.r),e.g=hX(e.g),e.b=hX(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===fY&&(e.r=gX(e.r),e.g=gX(e.g),e.b=gX(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===cY?dY:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return uX(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return uX(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[uY]:{primaries:t,whitePoint:r,transfer:dY,toXYZ:dX,fromXYZ:fX,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:lY},outputColorSpaceConfig:{drawingBufferColorSpace:lY}},[lY]:{primaries:t,whitePoint:r,transfer:fY,toXYZ:dX,fromXYZ:fX,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:lY}}}),e}const mX=pX();function hX(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function gX(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}let _X;var vX=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{_X===void 0&&(_X=cX(`canvas`)),_X.width=e.width,_X.height=e.height;let t=_X.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=_X}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=cX(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=hX(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(hX(t[e]/255)*255):t[e]=hX(t[e]);return{data:t,width:e.width,height:e.height}}else return console.warn(`THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}};let yX=0;var bX=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:yX++}),this.uuid=MY(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(xX(r[t].image)):e.push(xX(r[t]))}else e=xX(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function xX(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?vX.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn(`THREE.Texture: Unable to serialize Texture.`),{})}let SX=0;const CX=new V;var wX=class e extends DY{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=zJ,i=zJ,a=HJ,o=UJ,s=XJ,c=GJ,l=e.DEFAULT_ANISOTROPY,u=cY){super(),this.isTexture=!0,Object.defineProperty(this,`id`,{value:SX++}),this.uuid=MY(),this.name=``,this.source=new bX(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new tX(0,0),this.repeat=new tX(1,1),this.center=new tX(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new aX,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(CX).x}get height(){return this.source.getSize(CX).y}get depth(){return this.source.getSize(CX).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==PJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case RJ:e.x-=Math.floor(e.x);break;case zJ:e.x=e.x<0?0:1;break;case BJ:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case RJ:e.y-=Math.floor(e.y);break;case zJ:e.y=e.y<0?0:1;break;case BJ:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};wX.DEFAULT_IMAGE=null,wX.DEFAULT_MAPPING=PJ,wX.DEFAULT_ANISOTROPY=1;var TX=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=NY(this.x,e.x,t.x),this.y=NY(this.y,e.y,t.y),this.z=NY(this.z,e.z,t.z),this.w=NY(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=NY(this.x,e,t),this.y=NY(this.y,e,t),this.z=NY(this.z,e,t),this.w=NY(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(NY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},EX=class extends DY{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:HJ,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new TX(0,0,e,t),this.scissorTest=!1,this.viewport=new TX(0,0,e,t);let r={width:e,height:t,depth:n.depth},i=new wX(r);this.textures=[];let a=n.count;for(let e=0;e<a;e++)this.textures[e]=i.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:HJ,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++){let n=this.textures[e];n.setValues(t)}}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new bX(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},DX=class extends wX{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=VJ,this.minFilter=VJ,this.wrapR=zJ,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},OX=class{constructor(e=new V(1/0,1/0,1/0),t=new V(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(AX.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(AX.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=AX.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,AX):AX.fromBufferAttribute(r,t),AX.applyMatrix4(e.matrixWorld),this.expandByPoint(AX);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),jX.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),jX.copy(e.boundingBox)),jX.applyMatrix4(e.matrixWorld),this.union(jX)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,AX),AX.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(RX),zX.subVectors(this.max,RX),MX.subVectors(e.a,RX),NX.subVectors(e.b,RX),PX.subVectors(e.c,RX),FX.subVectors(NX,MX),IX.subVectors(PX,NX),LX.subVectors(MX,PX);let t=[0,-FX.z,FX.y,0,-IX.z,IX.y,0,-LX.z,LX.y,FX.z,0,-FX.x,IX.z,0,-IX.x,LX.z,0,-LX.x,-FX.y,FX.x,0,-IX.y,IX.x,0,-LX.y,LX.x,0];return!HX(t,MX,NX,PX,zX)||(t=[1,0,0,0,1,0,0,0,1],!HX(t,MX,NX,PX,zX))?!1:(BX.crossVectors(FX,IX),t=[BX.x,BX.y,BX.z],HX(t,MX,NX,PX,zX))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,AX).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(AX).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(kX[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),kX[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),kX[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),kX[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),kX[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),kX[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),kX[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),kX[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(kX),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};const kX=[new V,new V,new V,new V,new V,new V,new V,new V],AX=new V,jX=new OX,MX=new V,NX=new V,PX=new V,FX=new V,IX=new V,LX=new V,RX=new V,zX=new V,BX=new V,VX=new V;function HX(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){VX.fromArray(e,a);let o=i.x*Math.abs(VX.x)+i.y*Math.abs(VX.y)+i.z*Math.abs(VX.z),s=t.dot(VX),c=n.dot(VX),l=r.dot(VX);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}const UX=new OX,WX=new V,GX=new V;var KX=class{constructor(e=new V,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?UX.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;WX.subVectors(e,this.center);let t=WX.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(WX,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(GX.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(WX.copy(e.center).add(GX)),this.expandByPoint(WX.copy(e.center).sub(GX))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const qX=new V,JX=new V,YX=new V,XX=new V,ZX=new V,QX=new V,$X=new V;var eZ=class{constructor(e=new V,t=new V(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,qX)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=qX.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(qX.copy(this.origin).addScaledVector(this.direction,t),qX.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){JX.copy(e).add(t).multiplyScalar(.5),YX.copy(t).sub(e).normalize(),XX.copy(this.origin).sub(JX);let i=e.distanceTo(t)*.5,a=-this.direction.dot(YX),o=XX.dot(this.direction),s=-XX.dot(YX),c=XX.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(JX).addScaledVector(YX,d),f}intersectSphere(e,t){qX.subVectors(e.center,this.origin);let n=qX.dot(this.direction),r=qX.dot(qX)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;let n=e.normal.dot(this.direction);return n*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,qX)!==null}intersectTriangle(e,t,n,r,i){ZX.subVectors(t,e),QX.subVectors(n,e),$X.crossVectors(ZX,QX);let a=this.direction.dot($X),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;XX.subVectors(this.origin,e);let s=o*this.direction.dot(QX.crossVectors(XX,QX));if(s<0)return null;let c=o*this.direction.dot(ZX.cross(XX));if(c<0||s+c>a)return null;let l=-o*XX.dot($X);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},tZ=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/nZ.setFromMatrixColumn(e,0).length(),i=1/nZ.setFromMatrixColumn(e,1).length(),a=1/nZ.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(iZ,e,aZ)}lookAt(e,t,n){let r=this.elements;return cZ.subVectors(e,t),cZ.lengthSq()===0&&(cZ.z=1),cZ.normalize(),oZ.crossVectors(n,cZ),oZ.lengthSq()===0&&(Math.abs(n.z)===1?cZ.x+=1e-4:cZ.z+=1e-4,cZ.normalize(),oZ.crossVectors(n,cZ)),oZ.normalize(),sZ.crossVectors(cZ,oZ),r[0]=oZ.x,r[4]=sZ.x,r[8]=cZ.x,r[1]=oZ.y,r[5]=sZ.y,r[9]=cZ.y,r[2]=oZ.z,r[6]=sZ.z,r[10]=cZ.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=nZ.set(r[0],r[1],r[2]).length(),a=nZ.set(r[4],r[5],r[6]).length(),o=nZ.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],rZ.copy(this);let c=1/i,l=1/a,u=1/o;return rZ.elements[0]*=c,rZ.elements[1]*=c,rZ.elements[2]*=c,rZ.elements[4]*=l,rZ.elements[5]*=l,rZ.elements[6]*=l,rZ.elements[8]*=u,rZ.elements[9]*=u,rZ.elements[10]*=u,t.setFromRotationMatrix(rZ),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=TY){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===TY)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===EY)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=TY){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===TY)p=(a+i)*u,m=-2*u;else if(o===EY)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const nZ=new V,rZ=new tZ,iZ=new V(0,0,0),aZ=new V(1,1,1),oZ=new V,sZ=new V,cZ=new V,lZ=new tZ,uZ=new nX;var dZ=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(NY(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-NY(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(NY(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-NY(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(NY(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-NY(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:console.warn(`THREE.Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return lZ.makeRotationFromQuaternion(e),this.setFromRotationMatrix(lZ,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return uZ.setFromEuler(this),this.setFromQuaternion(uZ,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};dZ.DEFAULT_ORDER=`XYZ`;var fZ=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}};let pZ=0;const mZ=new V,hZ=new nX,gZ=new tZ,_Z=new V,vZ=new V,yZ=new V,bZ=new nX,xZ=new V(1,0,0),SZ=new V(0,1,0),CZ=new V(0,0,1),wZ={type:`added`},TZ={type:`removed`},EZ={type:`childadded`,child:null},DZ={type:`childremoved`,child:null};var OZ=class e extends DY{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:pZ++}),this.uuid=MY(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new V,n=new dZ,r=new nX,i=new V(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new tZ},normalMatrix:{value:new aX}}),this.matrix=new tZ,this.matrixWorld=new tZ,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new fZ,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return hZ.setFromAxisAngle(e,t),this.quaternion.multiply(hZ),this}rotateOnWorldAxis(e,t){return hZ.setFromAxisAngle(e,t),this.quaternion.premultiply(hZ),this}rotateX(e){return this.rotateOnAxis(xZ,e)}rotateY(e){return this.rotateOnAxis(SZ,e)}rotateZ(e){return this.rotateOnAxis(CZ,e)}translateOnAxis(e,t){return mZ.copy(e).applyQuaternion(this.quaternion),this.position.add(mZ.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(xZ,e)}translateY(e){return this.translateOnAxis(SZ,e)}translateZ(e){return this.translateOnAxis(CZ,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(gZ.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?_Z.copy(e):_Z.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),vZ.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?gZ.lookAt(vZ,_Z,this.up):gZ.lookAt(_Z,vZ,this.up),this.quaternion.setFromRotationMatrix(gZ),r&&(gZ.extractRotation(r.matrixWorld),hZ.setFromRotationMatrix(gZ),this.quaternion.premultiply(hZ.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error(`THREE.Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(wZ),EZ.child=e,this.dispatchEvent(EZ),EZ.child=null):console.error(`THREE.Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(TZ),DZ.child=e,this.dispatchEvent(DZ),DZ.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),gZ.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),gZ.multiply(e.parent.matrixWorld)),e.applyMatrix4(gZ),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(wZ),EZ.child=e,this.dispatchEvent(EZ),EZ.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n],i=r.getObjectByProperty(e,t);if(i!==void 0)return i}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(vZ,e,yZ),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(vZ,bZ,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++){let r=t[n];r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++){let n=e[t];n.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};OZ.DEFAULT_UP=new V(0,1,0),OZ.DEFAULT_MATRIX_AUTO_UPDATE=!0,OZ.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const kZ=new V,AZ=new V,jZ=new V,MZ=new V,NZ=new V,PZ=new V,FZ=new V,IZ=new V,LZ=new V,RZ=new V,zZ=new TX,BZ=new TX,VZ=new TX;var HZ=class e{constructor(e=new V,t=new V,n=new V){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),kZ.subVectors(e,t),r.cross(kZ);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){kZ.subVectors(r,t),AZ.subVectors(n,t),jZ.subVectors(e,t);let a=kZ.dot(kZ),o=kZ.dot(AZ),s=kZ.dot(jZ),c=AZ.dot(AZ),l=AZ.dot(jZ),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,MZ)===null?!1:MZ.x>=0&&MZ.y>=0&&MZ.x+MZ.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,MZ)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,MZ.x),s.addScaledVector(a,MZ.y),s.addScaledVector(o,MZ.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return zZ.setScalar(0),BZ.setScalar(0),VZ.setScalar(0),zZ.fromBufferAttribute(e,t),BZ.fromBufferAttribute(e,n),VZ.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(zZ,i.x),a.addScaledVector(BZ,i.y),a.addScaledVector(VZ,i.z),a}static isFrontFacing(e,t,n,r){return kZ.subVectors(n,t),AZ.subVectors(e,t),kZ.cross(AZ).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return kZ.subVectors(this.c,this.b),AZ.subVectors(this.a,this.b),kZ.cross(AZ).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;NZ.subVectors(r,n),PZ.subVectors(i,n),IZ.subVectors(e,n);let s=NZ.dot(IZ),c=PZ.dot(IZ);if(s<=0&&c<=0)return t.copy(n);LZ.subVectors(e,r);let l=NZ.dot(LZ),u=PZ.dot(LZ);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(NZ,a);RZ.subVectors(e,i);let f=NZ.dot(RZ),p=PZ.dot(RZ);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(PZ,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return FZ.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(FZ,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(NZ,a).addScaledVector(PZ,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const UZ={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},WZ={h:0,s:0,l:0},GZ={h:0,s:0,l:0};function KZ(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var qZ=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=lY){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,mX.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=mX.workingColorSpace){return this.r=e,this.g=t,this.b=n,mX.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=mX.workingColorSpace){if(e=PY(e,1),t=NY(t,0,1),n=NY(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=KZ(i,r,e+1/3),this.g=KZ(i,r,e),this.b=KZ(i,r,e-1/3)}return mX.colorSpaceToWorking(this,r),this}setStyle(e,t=lY){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=lY){let n=UZ[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=hX(e.r),this.g=hX(e.g),this.b=hX(e.b),this}copyLinearToSRGB(e){return this.r=gX(e.r),this.g=gX(e.g),this.b=gX(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=lY){return mX.workingToColorSpace(JZ.copy(this),e),Math.round(NY(JZ.r*255,0,255))*65536+Math.round(NY(JZ.g*255,0,255))*256+Math.round(NY(JZ.b*255,0,255))}getHexString(e=lY){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=mX.workingColorSpace){mX.workingToColorSpace(JZ.copy(this),t);let n=JZ.r,r=JZ.g,i=JZ.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=mX.workingColorSpace){return mX.workingToColorSpace(JZ.copy(this),t),e.r=JZ.r,e.g=JZ.g,e.b=JZ.b,e}getStyle(e=lY){mX.workingToColorSpace(JZ.copy(this),e);let t=JZ.r,n=JZ.g,r=JZ.b;return e===lY?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(WZ),this.setHSL(WZ.h+e,WZ.s+t,WZ.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(WZ),e.getHSL(GZ);let n=LY(WZ.h,GZ.h,t),r=LY(WZ.s,GZ.s,t),i=LY(WZ.l,GZ.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const JZ=new qZ;qZ.NAMES=UZ;let YZ=0;var XZ=class extends DY{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:YZ++}),this.uuid=MY(),this.name=``,this.type=`Material`,this.blending=DJ,this.side=wJ,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=kJ,this.blendDst=AJ,this.blendEquation=OJ,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new qZ(0,0,0),this.blendAlpha=0,this.depthFunc=jJ,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=mY,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=pY,this.stencilZFail=pY,this.stencilZPass=pY,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==DJ&&(n.blending=this.blending),this.side!==wJ&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==kJ&&(n.blendSrc=this.blendSrc),this.blendDst!==AJ&&(n.blendDst=this.blendDst),this.blendEquation!==OJ&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==jJ&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==mY&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==pY&&(n.stencilFail=this.stencilFail),this.stencilZFail!==pY&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==pY&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},ZZ=class extends XZ{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new qZ(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dZ,this.combine=MJ,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const QZ=new V,$Z=new tX;let eQ=0;var tQ=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:eQ++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=CY,this.updateRanges=[],this.gpuType=JJ,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)$Z.fromBufferAttribute(this,t),$Z.applyMatrix3(e),this.setXY(t,$Z.x,$Z.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)QZ.fromBufferAttribute(this,t),QZ.applyMatrix3(e),this.setXYZ(t,QZ.x,QZ.y,QZ.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)QZ.fromBufferAttribute(this,t),QZ.applyMatrix4(e),this.setXYZ(t,QZ.x,QZ.y,QZ.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)QZ.fromBufferAttribute(this,t),QZ.applyNormalMatrix(e),this.setXYZ(t,QZ.x,QZ.y,QZ.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)QZ.fromBufferAttribute(this,t),QZ.transformDirection(e),this.setXYZ(t,QZ.x,QZ.y,QZ.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=QY(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=$Y(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=QY(t,this.array)),t}setX(e,t){return this.normalized&&(t=$Y(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=QY(t,this.array)),t}setY(e,t){return this.normalized&&(t=$Y(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=QY(t,this.array)),t}setZ(e,t){return this.normalized&&(t=$Y(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=QY(t,this.array)),t}setW(e,t){return this.normalized&&(t=$Y(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=$Y(t,this.array),n=$Y(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=$Y(t,this.array),n=$Y(n,this.array),r=$Y(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=$Y(t,this.array),n=$Y(n,this.array),r=$Y(r,this.array),i=$Y(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==CY&&(e.usage=this.usage),e}},nQ=class extends tQ{constructor(e,t,n){super(new Uint16Array(e),t,n)}},rQ=class extends tQ{constructor(e,t,n){super(new Uint32Array(e),t,n)}},iQ=class extends tQ{constructor(e,t,n){super(new Float32Array(e),t,n)}};let aQ=0;const oQ=new tZ,sQ=new OZ,cQ=new V,lQ=new OX,uQ=new OX,dQ=new V;var fQ=class e extends DY{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:aQ++}),this.uuid=MY(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(sX(e)?rQ:nQ)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new aX().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return oQ.makeRotationFromQuaternion(e),this.applyMatrix4(oQ),this}rotateX(e){return oQ.makeRotationX(e),this.applyMatrix4(oQ),this}rotateY(e){return oQ.makeRotationY(e),this.applyMatrix4(oQ),this}rotateZ(e){return oQ.makeRotationZ(e),this.applyMatrix4(oQ),this}translate(e,t,n){return oQ.makeTranslation(e,t,n),this.applyMatrix4(oQ),this}scale(e,t,n){return oQ.makeScale(e,t,n),this.applyMatrix4(oQ),this}lookAt(e){return sQ.lookAt(e),sQ.updateMatrix(),this.applyMatrix4(sQ.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(cQ).negate(),this.translate(cQ.x,cQ.y,cQ.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new iQ(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&console.warn(`THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new OX);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new V(-1/0,-1/0,-1/0),new V(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];lQ.setFromBufferAttribute(n),this.morphTargetsRelative?(dQ.addVectors(this.boundingBox.min,lQ.min),this.boundingBox.expandByPoint(dQ),dQ.addVectors(this.boundingBox.max,lQ.max),this.boundingBox.expandByPoint(dQ)):(this.boundingBox.expandByPoint(lQ.min),this.boundingBox.expandByPoint(lQ.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error(`THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new KX);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new V,1/0);return}if(e){let n=this.boundingSphere.center;if(lQ.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];uQ.setFromBufferAttribute(n),this.morphTargetsRelative?(dQ.addVectors(lQ.min,uQ.min),lQ.expandByPoint(dQ),dQ.addVectors(lQ.max,uQ.max),lQ.expandByPoint(dQ)):(lQ.expandByPoint(uQ.min),lQ.expandByPoint(uQ.max))}lQ.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)dQ.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(dQ));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)dQ.fromBufferAttribute(a,t),o&&(cQ.fromBufferAttribute(e,t),dQ.add(cQ)),r=Math.max(r,n.distanceToSquared(dQ))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error(`THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new tQ(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new V,s[e]=new V;let c=new V,l=new V,u=new V,d=new tX,f=new tX,p=new tX,m=new V,h=new V;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new V,y=new V,b=new V,x=new V;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e]),i=n<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,i)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new tQ(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new V,i=new V,a=new V,o=new V,s=new V,c=new V,l=new V,u=new V;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)dQ.fromBufferAttribute(e,t),dQ.normalize(),e.setXYZ(t,dQ.x,dQ.y,dQ.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new tQ(a,r,i)}if(this.index===null)return console.warn(`THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}};const pQ=new tZ,mQ=new eZ,hQ=new KX,gQ=new V,_Q=new V,vQ=new V,yQ=new V,bQ=new V,xQ=new V,SQ=new V,CQ=new V;var wQ=class extends OZ{constructor(e=new fQ,t=new ZZ){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry,t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){xQ.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(bQ.fromBufferAttribute(s,e),a?xQ.addScaledVector(bQ,r):xQ.addScaledVector(bQ.sub(t),r))}t.add(xQ)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),hQ.copy(n.boundingSphere),hQ.applyMatrix4(i),mQ.copy(e.ray).recast(e.near),!(hQ.containsPoint(mQ.origin)===!1&&(mQ.intersectSphere(hQ,gQ)===null||mQ.origin.distanceToSquared(gQ)>(e.far-e.near)**2))&&(pQ.copy(i).invert(),mQ.copy(e.ray).applyMatrix4(pQ),!(n.boundingBox!==null&&mQ.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,mQ)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=EQ(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=EQ(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=EQ(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=EQ(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function TQ(e,t,n,r,i,a,o,s){let c;if(c=t.side===TJ?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===wJ,s),c===null)return null;CQ.copy(s),CQ.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(CQ);return l<n.near||l>n.far?null:{distance:l,point:CQ.clone(),object:e}}function EQ(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,_Q),e.getVertexPosition(c,vQ),e.getVertexPosition(l,yQ);let u=TQ(e,t,n,r,_Q,vQ,yQ,SQ);if(u){let e=new V;HZ.getBarycoord(SQ,_Q,vQ,yQ,e),i&&(u.uv=HZ.getInterpolatedAttribute(i,s,c,l,e,new tX)),a&&(u.uv1=HZ.getInterpolatedAttribute(a,s,c,l,e,new tX)),o&&(u.normal=HZ.getInterpolatedAttribute(o,s,c,l,e,new V),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new V,materialIndex:0};HZ.getNormal(_Q,vQ,yQ,t.normal),u.face=t,u.barycoord=e}return u}var DQ=class e extends fQ{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new iQ(c,3)),this.setAttribute(`normal`,new iQ(l,3)),this.setAttribute(`uv`,new iQ(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,ee=h+1,te=g+1,ne=0,re=0,ie=new V;for(let a=0;a<te;a++){let o=a*y-x;for(let s=0;s<ee;s++){let d=s*v-b;ie[e]=d*r,ie[t]=o*i,ie[n]=S,c.push(ie.x,ie.y,ie.z),ie[e]=0,ie[t]=0,ie[n]=m>0?1:-1,l.push(ie.x,ie.y,ie.z),u.push(s/h),u.push(1-a/g),ne+=1}}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+ee*e,r=d+t+ee*(e+1),i=d+(t+1)+ee*(e+1),a=d+(t+1)+ee*e;s.push(n,r,a),s.push(r,i,a),re+=6}o.addGroup(f,re,_),f+=re,d+=ne}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},OQ=class extends OZ{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new tZ,this.projectionMatrix=new tZ,this.projectionMatrixInverse=new tZ,this.coordinateSystem=TY}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const kQ=new V,AQ=new tX,jQ=new tX;var MQ=class extends OQ{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=jY*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(AY*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return jY*2*Math.atan(Math.tan(AY*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){kQ.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(kQ.x,kQ.y).multiplyScalar(-e/kQ.z),kQ.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(kQ.x,kQ.y).multiplyScalar(-e/kQ.z)}getViewSize(e,t){return this.getViewBounds(e,AQ,jQ),t.subVectors(jQ,AQ)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(AY*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},NQ=class extends wX{constructor(e=[],t=FJ,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},PQ=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=CY,this.updateRanges=[],this.version=0,this.uuid=MY()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=MY()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=MY()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}};const FQ=new V;var IQ=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)FQ.fromBufferAttribute(this,t),FQ.applyMatrix4(e),this.setXYZ(t,FQ.x,FQ.y,FQ.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)FQ.fromBufferAttribute(this,t),FQ.applyNormalMatrix(e),this.setXYZ(t,FQ.x,FQ.y,FQ.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)FQ.fromBufferAttribute(this,t),FQ.transformDirection(e),this.setXYZ(t,FQ.x,FQ.y,FQ.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=QY(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=$Y(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=$Y(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=$Y(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=$Y(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=$Y(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=QY(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=QY(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=QY(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=QY(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=$Y(t,this.array),n=$Y(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=$Y(t,this.array),n=$Y(n,this.array),r=$Y(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=$Y(t,this.array),n=$Y(n,this.array),r=$Y(r,this.array),i=$Y(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new tQ(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log(`THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},LQ=class extends tQ{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};const RQ=new V,zQ=new V,BQ=new aX;var VQ=class{constructor(e=new V(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=RQ.subVectors(n,t).cross(zQ.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(RQ),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||BQ.getNormalMatrix(e),r=this.coplanarPoint(RQ).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},HQ=class extends wX{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=VJ,this.minFilter=VJ,this.generateMipmaps=!1,this.needsUpdate=!0}},UQ=class extends wX{constructor(e,t,n=qJ,r,i,a,o=VJ,s=VJ,c,l=ZJ,u=1){if(l!==ZJ&&l!==QJ)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);let d={width:e,height:t,depth:u};super(d,r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new bX(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}};function WQ(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function GQ(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var KQ=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`call to abstract method`)}intervalChanged_(){}},qQ=class extends KQ{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:rY,endingEnd:rY}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case iY:i=e,o=2*t-n;break;case aY:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case iY:a=e,s=2*n-t;break;case aY:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},JQ=class extends KQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},YQ=class extends KQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},XQ=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=WQ(t,this.TimeBufferType),this.values=WQ(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:WQ(e.times,Array),values:WQ(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new YQ(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new JQ(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new qQ(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case eY:t=this.InterpolantFactoryMethodDiscrete;break;case tY:t=this.InterpolantFactoryMethodLinear;break;case nY:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let t=`unsupported interpolation for `+this.ValueTypeName+` keyframe track named `+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(t);return console.warn(`THREE.KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return eY;case this.InterpolantFactoryMethodLinear:return tY;case this.InterpolantFactoryMethodSmooth:return nY}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error(`THREE.KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(console.error(`THREE.KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){console.error(`THREE.KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){console.error(`THREE.KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&GQ(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){console.error(`THREE.KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===nY,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o],c=e[o+1];if(s!==c&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};XQ.prototype.ValueTypeName=``,XQ.prototype.TimeBufferType=Float32Array,XQ.prototype.ValueBufferType=Float32Array,XQ.prototype.DefaultInterpolation=tY;var ZQ=class extends XQ{constructor(e,t,n){super(e,t,n)}};ZQ.prototype.ValueTypeName=`bool`,ZQ.prototype.ValueBufferType=Array,ZQ.prototype.DefaultInterpolation=eY,ZQ.prototype.InterpolantFactoryMethodLinear=void 0,ZQ.prototype.InterpolantFactoryMethodSmooth=void 0;var QQ=class extends XQ{constructor(e,t,n,r){super(e,t,n,r)}};QQ.prototype.ValueTypeName=`color`;var $Q=class extends XQ{constructor(e,t,n,r){super(e,t,n,r)}};$Q.prototype.ValueTypeName=`number`;var e$=class extends KQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)nX.slerpFlat(i,0,a,c-o,a,c,s);return i}},t$=class extends XQ{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new e$(this.times,this.values,this.getValueSize(),e)}};t$.prototype.ValueTypeName=`quaternion`,t$.prototype.InterpolantFactoryMethodSmooth=void 0;var n$=class extends XQ{constructor(e,t,n){super(e,t,n)}};n$.prototype.ValueTypeName=`string`,n$.prototype.ValueBufferType=Array,n$.prototype.DefaultInterpolation=eY,n$.prototype.InterpolantFactoryMethodLinear=void 0,n$.prototype.InterpolantFactoryMethodSmooth=void 0;var r$=class extends XQ{constructor(e,t,n,r){super(e,t,n,r)}};r$.prototype.ValueTypeName=`vector`;var i$=class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}};const a$=new i$;var o$=class{constructor(e){this.manager=e===void 0?a$:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};o$.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var s$=class extends OQ{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}};const c$=`\\[\\]\\.:\\/`,l$=RegExp(`[`+c$+`]`,`g`),u$=`[^`+c$+`]`,d$=`[^`+c$.replace(`\\.`,``)+`]`,f$=/((?:WC+[\/:])*)/.source.replace(`WC`,u$),p$=/(WCOD+)?/.source.replace(`WCOD`,d$),m$=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace(`WC`,u$),h$=/\.(WC+)(?:\[(.+)\])?/.source.replace(`WC`,u$),g$=RegExp(`^`+f$+p$+m$+h$+`$`),_$=[`material`,`materials`,`bones`,`map`];var v$=class{constructor(e,t,n){let r=n||y$.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},y$=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(l$,``)}static parseTrackName(e){let t=g$.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);_$.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn(`THREE.PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){console.error(`THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){console.error(`THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){console.error(`THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error(`THREE.PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){console.error(`THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;console.error(`THREE.PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};y$.Composite=v$,y$.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},y$.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},y$.prototype.GetterByBindingType=[y$.prototype._getValue_direct,y$.prototype._getValue_array,y$.prototype._getValue_arrayElement,y$.prototype._getValue_toArray],y$.prototype.SetterByBindingTypeAndVersioning=[[y$.prototype._setValue_direct,y$.prototype._setValue_direct_setNeedsUpdate,y$.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[y$.prototype._setValue_array,y$.prototype._setValue_array_setNeedsUpdate,y$.prototype._setValue_array_setMatrixWorldNeedsUpdate],[y$.prototype._setValue_arrayElement,y$.prototype._setValue_arrayElement_setNeedsUpdate,y$.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[y$.prototype._setValue_fromArray,y$.prototype._setValue_fromArray_setNeedsUpdate,y$.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const poe=new Float32Array(1);var b$=class extends PQ{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},x$=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}};typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:xJ}})),typeof window<`u`&&(window.__THREE__?console.warn(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=xJ);const S$=`alphaMap.alphaTest.anisotropy.anisotropyMap.anisotropyRotation.aoMap.aoMapIntensity.attenuationColor.attenuationDistance.bumpMap.clearcoat.clearcoatMap.clearcoatNormalMap.clearcoatNormalScale.clearcoatRoughness.color.dispersion.displacementMap.emissive.emissiveIntensity.emissiveMap.envMap.envMapIntensity.gradientMap.ior.iridescence.iridescenceIOR.iridescenceMap.iridescenceThicknessMap.lightMap.lightMapIntensity.map.matcap.metalness.metalnessMap.normalMap.normalScale.opacity.roughness.roughnessMap.sheen.sheenColor.sheenColorMap.sheenRoughnessMap.shininess.specular.specularColor.specularColorMap.specularIntensity.specularIntensityMap.specularMap.thickness.transmission.transmissionMap`.split(`.`);var C$=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=S$,this.renderId=0}firstInitialization(e){let t=this.renderObjects.has(e);return t===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){let t=e.getMRT();return t!==null&&t.has(`velocity`)}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){let{geometry:n,material:r,object:i}=e;if(t={material:this.getMaterialData(r),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){let{width:n,height:r}=e.context;t.bufferWidth=n,t.bufferHeight=r}this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let n in e){let r=e[n];t[n]={version:r.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return e.renderer.overrideNodes.modelViewMatrix!==null||e.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(e){let t={};for(let n of this.refreshUniforms){let r=e[n];if(r==null)continue;typeof r==`object`&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r}return t}equals(e){let{object:t,material:n,geometry:r}=e,i=this.getRenderObjectData(e);if(i.worldMatrix.equals(t.matrixWorld)!==!0)return i.worldMatrix.copy(t.matrixWorld),!1;let a=i.material;for(let e in a){let t=a[e],r=n[e];if(t.equals!==void 0){if(t.equals(r)===!1)return t.copy(r),!1}else if(r.isTexture===!0){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,!1}else if(t!==r)return a[e]=r,!1}if(a.transmission>0){let{width:t,height:n}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==n)return i.bufferWidth=t,i.bufferHeight=n,!1}let o=i.geometry,s=r.attributes,c=o.attributes,l=Object.keys(c),u=Object.keys(s);if(o.id!==r.id)return o.id=r.id,!1;if(l.length!==u.length)return i.geometry.attributes=this.getAttributesData(s),!1;for(let e of l){let t=c[e],n=s[e];if(n===void 0)return delete c[e],!1;if(t.version!==n.version)return t.version=n.version,!1}let d=r.index,f=o.indexVersion,p=d?d.version:null;if(f!==p)return o.indexVersion=p,!1;if(o.drawRange.start!==r.drawRange.start||o.drawRange.count!==r.drawRange.count)return o.drawRange.start=r.drawRange.start,o.drawRange.count=r.drawRange.count,!1;if(i.morphTargetInfluences){let e=!1;for(let n=0;n<i.morphTargetInfluences.length;n++)i.morphTargetInfluences[n]!==t.morphTargetInfluences[n]&&(e=!0);if(e)return!0}return i.center&&i.center.equals(t.center)===!1?(i.center.copy(t.center),!0):(e.bundle!==null&&(i.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;let{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;let r=e.object.static===!0,i=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||i)return!1;let a=this.equals(e)!==!0;return a}};function w$(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}const T$=e=>w$(e),E$=e=>w$(e),D$=(...e)=>w$(e);function O$(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of k$(e))n.push(w$(r.slice(0,-4)),i.getCacheKey(t));return w$(n)}function*k$(e,t=!1){for(let n in e){if(n.startsWith(`_`)===!0)continue;let r=e[n];if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)yield{property:n,childNode:r};else if(typeof r==`object`)for(let e in r){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}}}const A$=new Map([[1,`float`],[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]),j$=new WeakMap;function M$(e){return A$.get(e)}function N$(e){if(/[iu]?vec\d/.test(e))return e.startsWith(`ivec`)?Int32Array:e.startsWith(`uvec`)?Uint32Array:Float32Array;if(/mat\d/.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function P$(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 9;if(/mat4/.test(e))return 16;console.error(`THREE.TSL: Unsupported type:`,e)}function F$(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 12;if(/mat4/.test(e))return 16;console.error(`THREE.TSL: Unsupported type:`,e)}function I$(e){if(/float|int|uint/.test(e))return 4;if(/vec2/.test(e))return 8;if(/vec3/.test(e)||/vec4/.test(e))return 16;if(/mat2/.test(e))return 8;if(/mat3/.test(e))return 48;if(/mat4/.test(e))return 64;console.error(`THREE.TSL: Unsupported type:`,e)}function L$(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function R$(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new qZ(...t):n===`vec2`?new tX(...t):n===`vec3`?new V(...t):n===`vec4`?new TX(...t):n===`mat2`?new x$(...t):n===`mat3`?new aX(...t):n===`mat4`?new tZ(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?V$(t[0]):null}function z$(e){let t=j$.get(e);return t===void 0&&(t={},j$.set(e,t)),t}function B$(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function V$(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}const H$={VERTEX:`vertex`,FRAGMENT:`fragment`},U$={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},W$={BOOLEAN:`bool`,INTEGER:`int`,FLOAT:`float`,VECTOR2:`vec2`,VECTOR3:`vec3`,VECTOR4:`vec4`,MATRIX2:`mat2`,MATRIX3:`mat3`,MATRIX4:`mat4`},G$={READ_ONLY:`readOnly`,WRITE_ONLY:`writeOnly`,READ_WRITE:`readWrite`},K$=[`fragment`,`vertex`],q$=[`setup`,`analyze`,`generate`],J$=[...K$,`compute`],Y$=[`x`,`y`,`z`,`w`],X$={analyze:`setup`,generate:`analyze`};let Z$=0;var Q$=class extends DY{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=U$.NONE,this.updateBeforeType=U$.NONE,this.updateAfterType=U$.NONE,this.uuid=eX.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:Z$++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,U$.FRAME)}onRenderUpdate(e){return this.onUpdate(e,U$.RENDER)}onObjectUpdate(e){return this.onUpdate(e,U$.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of k$(this))yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e||=this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=D$(O$(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e),n=e.getElementType(t);return n}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t);return n||this}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn(`Abstract function.`)}updateAfter(){console.warn(`Abstract function.`)}update(){console.warn(`Abstract function.`)}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=X$[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){let n=this.generate.length===1;if(n){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(console.warn(`THREE.Node: Recursion detected.`,this),a=``):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return k$(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n]){let a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}},$$=class extends Q${static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){let t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`);return`${n}[ ${r} ]`}},e1=class extends Q${static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},t1=class extends Q${static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){let n=e.getBuildStage();if(n===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},n1=class extends t1{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;s+c>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i);let u=e.getComponentType(i);u!==a&&(l=e.format(l,u,a)),o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}};const r1=Y$.join(``);var i1=class extends Q${static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(Y$.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null,o=this.getVectorLength();o>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let s=n.build(e,a);i=this.components.length===r&&this.components===r1.slice(0,this.components.length)?e.format(s,a,t):e.format(`${s}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},a1=class extends t1{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=Y$[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},o1=class extends t1{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=Y$[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},s1=class extends Q${static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?L$(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=L$(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=B$(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?R$(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn(`Abstract function.`)}};const c1=/float|u?int/;var l1=class extends s1{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return c1.test(n)&&c1.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},u1=class extends Q${static get type(){return`MemberNode`}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){let t=this.node.build(e);return t+`.`+this.property}};let d1=null;const f1=new Map;function H(e,t){if(f1.has(e)){console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);f1.set(e,t)}const p1=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),m1=e=>p1(e).split(``).sort().join(``),h1={setup(e,t){let n=t.shift();return e(V1(n),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(d1.assign(n,...e),n);if(f1.has(t)){let r=f1.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}else if(t===`self`)return e;else if(t.endsWith(`Assign`)&&f1.has(t.slice(0,t.length-6))){let r=f1.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}else if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=p1(t),U(new i1(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=m1(t.slice(3).toLowerCase()),n=>U(new a1(e,t,U(n)));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=m1(t.slice(4).toLowerCase()),()=>U(new o1(U(e),t));else if(t===`width`||t===`height`||t===`depth`)return t===`width`?t=`x`:t===`height`?t=`y`:t===`depth`&&(t=`z`),U(new i1(e,t));else if(/^\d+$/.test(t)===!0)return U(new $$(n,new l1(Number(t),`uint`)));else if(/^get$/.test(t)===!0)return e=>U(new u1(n,e))}return Reflect.get(e,t,n)},set(e,t,n,r){return typeof t==`string`&&e[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t===`width`||t===`height`||t===`depth`||/^\d+$/.test(t)===!0)?(r[t].assign(n),!0):Reflect.set(e,t,n,r)}},g1=new WeakMap,_1=new WeakMap,v1=function(e,t=null){let n=L$(e);if(n===`node`){let t=g1.get(e);return t===void 0&&(t=new Proxy(e,h1),g1.set(e,t),g1.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return U(F1(e,t));else if(n===`shader`)return K(e);return e},y1=function(e,t=null){for(let n in e)e[n]=U(e[n],t);return e},b1=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=U(e[r],t);return e},x1=function(e,t=null,n=null,r=null){let i=e=>U(r===null?e:Object.assign(e,r)),a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(console.error(`THREE.TSL: "${n}" parameter length is less than minimum required.`),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(console.error(`THREE.TSL: "${n}" parameter length exceeds limit.`),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...H1(l(t)))):n===null?a=(...n)=>i(new e(t,...H1(l(n)))):(n=U(n),a=(...r)=>i(new e(t,...H1(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a},S1=function(e,...t){return U(new e(...H1(t)))};var C1=class extends Q${constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace(`once`):`once`;if(r[i])return r[i];let a=null;if(t.layout){let r=_1.get(e.constructor);r===void 0&&(r=new WeakMap,_1.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=U(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i),a=U(i.call(n))}else{let r=t.jsFunc,i=n!==null||r.length>1?r(n||[],e):r(e);a=U(i)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(r===`setup`){let t=e.getNamespace(`initialized`);i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return n}},w1=class extends Q${constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return V1(e),U(new C1(this,e))}setup(){return this.call()}};const T1=[!1,!0],E1=[0,1,2,3],D1=[-1,-2],O1=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],k1=new Map;for(let e of T1)k1.set(e,new l1(e));const A1=new Map;for(let e of E1)A1.set(e,new l1(e,`uint`));const j1=new Map([...A1].map(e=>new l1(e.value,`int`)));for(let e of D1)j1.set(e,new l1(e,`int`));const M1=new Map([...j1].map(e=>new l1(e.value)));for(let e of O1)M1.set(e,new l1(e));for(let e of O1)M1.set(-e,new l1(-e));const N1={bool:k1,uint:A1,ints:j1,float:M1},P1=new Map([...k1,...M1]),F1=(e,t)=>P1.has(e)?P1.get(e):e.isNode===!0?e:new l1(e,t),I1=e=>{try{return e.getNodeType()}catch{return}},L1=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[R$(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return U(t.get(n[0]));if(n.length===1){let t=F1(n[0],e);return I1(t)===e?U(t):U(new e1(t,e))}let r=n.map(e=>F1(e));return U(new n1(r,e))}},R1=e=>typeof e==`object`&&e?e.value:e,z1=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function B1(e,t){return new Proxy(new w1(e,t),h1)}const U=(e,t=null)=>v1(e,t),V1=(e,t=null)=>new y1(e,t),H1=(e,t=null)=>new b1(e,t),W=(...e)=>new x1(...e),G=(...e)=>new S1(...e);let U1=0;const K=(e,t=null)=>{let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:console.error(`THREE.TSL: Invalid layout type.`),t=null));let r=new B1(e,n),i=(...e)=>{let t;V1(e);let i=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype);t=i?[...e]:e[0];let a=r.call(t);return n===`void`&&a.toStack(),a};if(i.shaderNode=r,i.id=r.id,i.getNodeType=(...e)=>r.getNodeType(...e),i.getCacheKey=(...e)=>r.getCacheKey(...e),i.setLayout=e=>(r.setLayout(e),i),i.once=(e=null)=>(r.once=!0,r.namespace=e,i),t!==null){if(typeof t.inputs!=`object`){let e={name:`fn`+ U1++,type:n,inputs:[]};for(let n in t){if(n===`return`)continue;e.inputs.push({name:n,type:t[n]})}t=e}i.setLayout(t)}return i},W1=e=>{d1=e},G1=()=>d1,K1=(...e)=>d1.If(...e),q1=(...e)=>d1.Switch(...e);function J1(e){return d1&&d1.add(e),e}H(`toStack`,J1);const Y1=new L1(`color`),q=new L1(`float`,N1.float),J=new L1(`int`,N1.ints),X1=new L1(`uint`,N1.uint),Z1=new L1(`bool`,N1.bool),Y=new L1(`vec2`),Q1=new L1(`ivec2`),$1=new L1(`uvec2`),e0=new L1(`bvec2`),X=new L1(`vec3`),t0=new L1(`ivec3`),n0=new L1(`uvec3`),r0=new L1(`bvec3`),i0=new L1(`vec4`),a0=new L1(`ivec4`),o0=new L1(`uvec4`),s0=new L1(`bvec4`),c0=new L1(`mat2`),l0=new L1(`mat3`),u0=new L1(`mat4`),d0=(e=``)=>U(new l1(e,`string`)),f0=e=>U(new l1(e,`ArrayBuffer`));H(`toColor`,Y1),H(`toFloat`,q),H(`toInt`,J),H(`toUint`,X1),H(`toBool`,Z1),H(`toVec2`,Y),H(`toIVec2`,Q1),H(`toUVec2`,$1),H(`toBVec2`,e0),H(`toVec3`,X),H(`toIVec3`,t0),H(`toUVec3`,n0),H(`toBVec3`,r0),H(`toVec4`,i0),H(`toIVec4`,a0),H(`toUVec4`,o0),H(`toBVec4`,s0),H(`toMat2`,c0),H(`toMat3`,l0),H(`toMat4`,u0);const p0=W($$).setParameterLength(2),m0=(e,t)=>U(new e1(U(e),t)),h0=(e,t)=>U(new i1(U(e),t));H(`element`,p0),H(`convert`,m0);const g0=e=>(console.warn(`THREE.TSL: append() has been renamed to Stack().`),J1(e));H(`append`,e=>(console.warn(`THREE.TSL: .append() has been renamed to .toStack().`),J1(e)));const _0=(...e)=>(console.warn(`THREE.TSL: tslFn() has been renamed to Fn().`),K(...e));var v0=class extends Q${static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}};const y0=(e,t)=>U(new v0(e,t)),b0=(e,t)=>U(new v0(e,t,!0)),x0=G(v0,`vec4`,`DiffuseColor`),S0=G(v0,`vec3`,`EmissiveColor`),C0=G(v0,`float`,`Roughness`),w0=G(v0,`float`,`Metalness`),T0=G(v0,`float`,`Clearcoat`),E0=G(v0,`float`,`ClearcoatRoughness`),D0=G(v0,`vec3`,`Sheen`),O0=G(v0,`float`,`SheenRoughness`),k0=G(v0,`float`,`Iridescence`),A0=G(v0,`float`,`IridescenceIOR`),j0=G(v0,`float`,`IridescenceThickness`),M0=G(v0,`float`,`AlphaT`),N0=G(v0,`float`,`Anisotropy`),P0=G(v0,`vec3`,`AnisotropyT`),F0=G(v0,`vec3`,`AnisotropyB`),I0=G(v0,`color`,`SpecularColor`),L0=G(v0,`float`,`SpecularF90`),R0=G(v0,`float`,`Shininess`),z0=G(v0,`vec4`,`Output`),B0=G(v0,`float`,`dashSize`),V0=G(v0,`float`,`gapSize`),H0=G(v0,`float`,`pointWidth`),U0=G(v0,`float`,`IOR`),W0=G(v0,`float`,`Transmission`),G0=G(v0,`float`,`Thickness`),K0=G(v0,`float`,`AttenuationDistance`),q0=G(v0,`color`,`AttenuationColor`),J0=G(v0,`float`,`Dispersion`);var Y0=class extends Q${static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}};const X0=e=>new Y0(e),Z0=(e,t=0)=>new Y0(e,!0,t),Q0=Z0(`frame`),$0=Z0(`render`),e2=X0(`object`);var t2=class extends s1{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=e2}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){let n=this.getSelf();return e=e.bind(n),super.onUpdate(t=>{let r=e(t,n);r!==void 0&&(this.value=r)},t)}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),s=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(s,n,t)}};const n2=(e,t)=>{let n=z1(t||e),r=e&&e.isNode===!0?e.node&&e.node.value||e.value:e;return U(new t2(r,n))};var r2=class extends t1{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}};const i2=(...e)=>{let t;if(e.length===1){let n=e[0];t=new r2(null,n.length,n)}else{let n=e[0],r=e[1];t=new r2(n,r)}return U(t)};H(`toArray`,(e,t)=>i2(Array(t).fill(e)));var a2=class extends t1{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e)),r=Y$.join(``).slice(0,n)!==t.components;return r}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),o=n.build(e),s=r.build(e,a),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=o);else if(i){let r=e.getVarFromNode(this,null,a),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}),d=l.build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${d}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=o)}else u=`${o} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=o));return l.initialized=!0,e.format(u,a,t)}};const o2=W(a2).setParameterLength(2);H(`assign`,o2);var s2=class extends t1{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)console.error(`THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(console.error(`THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(q(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(console.error(`THREE.TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(q(0),e))):t.push(a(n,e))}let o=n.build(e,`property`);return`${o}( ${t.join(`, `)} )`}};const c2=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?H1(t):V1(t[0]),U(new s2(U(e),t)));H(`call`,c2);const l2={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var u2=class e extends t1{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(l2[this.op],t)}getNodeType(e){let t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i===`void`||a===`void`)return`void`;if(t===`%`)return i;if(t===`~`||t===`&`||t===`|`||t===`^`||t===`>>`||t===`<<`)return e.getIntegerType(i);if(t===`!`||t===`&&`||t===`||`||t===`^^`)return`bool`;if(t===`==`||t===`!=`||t===`<`||t===`>`||t===`<=`||t===`>=`){let t=Math.max(e.getTypeLength(i),e.getTypeLength(a));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(i)){if(a===`float`)return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i===`float`)return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===TY;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const d2=W(u2,`+`).setParameterLength(2,1/0).setName(`add`),f2=W(u2,`-`).setParameterLength(2,1/0).setName(`sub`),p2=W(u2,`*`).setParameterLength(2,1/0).setName(`mul`),m2=W(u2,`/`).setParameterLength(2,1/0).setName(`div`),h2=W(u2,`%`).setParameterLength(2).setName(`mod`),g2=W(u2,`==`).setParameterLength(2).setName(`equal`),_2=W(u2,`!=`).setParameterLength(2).setName(`notEqual`),v2=W(u2,`<`).setParameterLength(2).setName(`lessThan`),y2=W(u2,`>`).setParameterLength(2).setName(`greaterThan`),b2=W(u2,`<=`).setParameterLength(2).setName(`lessThanEqual`),x2=W(u2,`>=`).setParameterLength(2).setName(`greaterThanEqual`),S2=W(u2,`&&`).setParameterLength(2,1/0).setName(`and`),C2=W(u2,`||`).setParameterLength(2,1/0).setName(`or`),w2=W(u2,`!`).setParameterLength(1).setName(`not`),T2=W(u2,`^^`).setParameterLength(2).setName(`xor`),E2=W(u2,`&`).setParameterLength(2).setName(`bitAnd`),D2=W(u2,`~`).setParameterLength(2).setName(`bitNot`),O2=W(u2,`|`).setParameterLength(2).setName(`bitOr`),k2=W(u2,`^`).setParameterLength(2).setName(`bitXor`),A2=W(u2,`<<`).setParameterLength(2).setName(`shiftLeft`),j2=W(u2,`>>`).setParameterLength(2).setName(`shiftRight`),M2=K(([e])=>(e.addAssign(1),e)),N2=K(([e])=>(e.subAssign(1),e)),P2=K(([e])=>{let t=J(e).toConst();return e.addAssign(1),t}),F2=K(([e])=>{let t=J(e).toConst();return e.subAssign(1),t});H(`add`,d2),H(`sub`,f2),H(`mul`,p2),H(`div`,m2),H(`mod`,h2),H(`equal`,g2),H(`notEqual`,_2),H(`lessThan`,v2),H(`greaterThan`,y2),H(`lessThanEqual`,b2),H(`greaterThanEqual`,x2),H(`and`,S2),H(`or`,C2),H(`not`,w2),H(`xor`,T2),H(`bitAnd`,E2),H(`bitNot`,D2),H(`bitOr`,O2),H(`bitXor`,k2),H(`shiftLeft`,A2),H(`shiftRight`,j2),H(`incrementBefore`,M2),H(`decrementBefore`,N2),H(`increment`,P2),H(`decrement`,F2);const I2=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),h2(e,t)),L2=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),h2(J(e),J(t)));H(`remainder`,I2),H(`modInt`,L2);var Z=class e extends t1{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=f2(1,n);else if(i===e.RECIPROCAL)a=m2(1,n);else if(i===e.DIFFERENCE)a=c4(f2(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=i0(X(i),0):e=i0(X(e),0);let o=p2(e,i).xyz;a=e4(o)}return a===null?super.setup(t):a}generate(t,n){let r=t.getNodeProperties(this);if(r.outputNode)return super.generate(t,n);let i=this.method,a=this.getNodeType(t),o=this.getInputType(t),s=this.aNode,c=this.bNode,l=this.cNode,u=t.renderer.coordinateSystem;if(i===e.NEGATE)return t.format(`( - `+s.build(t,o)+` )`,a,n);{let r=[];return i===e.CROSS?r.push(s.build(t,a),c.build(t,a)):u===TY&&i===e.STEP?r.push(s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:o),c.build(t,o)):u===TY&&(i===e.MIN||i===e.MAX)?r.push(s.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:o)):i===e.REFRACT?r.push(s.build(t,o),c.build(t,o),l.build(t,`float`)):i===e.MIX?r.push(s.build(t,o),c.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?`float`:o)):(u===EY&&i===e.ATAN&&c!==null&&(i=`atan2`),t.shaderStage!==`fragment`&&(i===e.DFDX||i===e.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i=`/*`+i+`*/`),r.push(s.build(t,o)),c!==null&&r.push(c.build(t,o)),l!==null&&r.push(l.build(t,o))),t.format(`${t.getMethod(i,a)}( ${r.join(`, `)} )`,a,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};Z.ALL=`all`,Z.ANY=`any`,Z.RADIANS=`radians`,Z.DEGREES=`degrees`,Z.EXP=`exp`,Z.EXP2=`exp2`,Z.LOG=`log`,Z.LOG2=`log2`,Z.SQRT=`sqrt`,Z.INVERSE_SQRT=`inversesqrt`,Z.FLOOR=`floor`,Z.CEIL=`ceil`,Z.NORMALIZE=`normalize`,Z.FRACT=`fract`,Z.SIN=`sin`,Z.COS=`cos`,Z.TAN=`tan`,Z.ASIN=`asin`,Z.ACOS=`acos`,Z.ATAN=`atan`,Z.ABS=`abs`,Z.SIGN=`sign`,Z.LENGTH=`length`,Z.NEGATE=`negate`,Z.ONE_MINUS=`oneMinus`,Z.DFDX=`dFdx`,Z.DFDY=`dFdy`,Z.ROUND=`round`,Z.RECIPROCAL=`reciprocal`,Z.TRUNC=`trunc`,Z.FWIDTH=`fwidth`,Z.TRANSPOSE=`transpose`,Z.BITCAST=`bitcast`,Z.EQUALS=`equals`,Z.MIN=`min`,Z.MAX=`max`,Z.STEP=`step`,Z.REFLECT=`reflect`,Z.DISTANCE=`distance`,Z.DIFFERENCE=`difference`,Z.DOT=`dot`,Z.CROSS=`cross`,Z.POW=`pow`,Z.TRANSFORM_DIRECTION=`transformDirection`,Z.MIX=`mix`,Z.CLAMP=`clamp`,Z.REFRACT=`refract`,Z.SMOOTHSTEP=`smoothstep`,Z.FACEFORWARD=`faceforward`;const R2=q(1e-6),z2=q(1e6),B2=q(Math.PI),V2=q(Math.PI*2),H2=W(Z,Z.ALL).setParameterLength(1),U2=W(Z,Z.ANY).setParameterLength(1),W2=W(Z,Z.RADIANS).setParameterLength(1),G2=W(Z,Z.DEGREES).setParameterLength(1),K2=W(Z,Z.EXP).setParameterLength(1),q2=W(Z,Z.EXP2).setParameterLength(1),J2=W(Z,Z.LOG).setParameterLength(1),Y2=W(Z,Z.LOG2).setParameterLength(1),X2=W(Z,Z.SQRT).setParameterLength(1),Z2=W(Z,Z.INVERSE_SQRT).setParameterLength(1),Q2=W(Z,Z.FLOOR).setParameterLength(1),$2=W(Z,Z.CEIL).setParameterLength(1),e4=W(Z,Z.NORMALIZE).setParameterLength(1),t4=W(Z,Z.FRACT).setParameterLength(1),n4=W(Z,Z.SIN).setParameterLength(1),r4=W(Z,Z.COS).setParameterLength(1),i4=W(Z,Z.TAN).setParameterLength(1),a4=W(Z,Z.ASIN).setParameterLength(1),o4=W(Z,Z.ACOS).setParameterLength(1),s4=W(Z,Z.ATAN).setParameterLength(1,2),c4=W(Z,Z.ABS).setParameterLength(1),l4=W(Z,Z.SIGN).setParameterLength(1),u4=W(Z,Z.LENGTH).setParameterLength(1),d4=W(Z,Z.NEGATE).setParameterLength(1),f4=W(Z,Z.ONE_MINUS).setParameterLength(1),p4=W(Z,Z.DFDX).setParameterLength(1),m4=W(Z,Z.DFDY).setParameterLength(1),h4=W(Z,Z.ROUND).setParameterLength(1),g4=W(Z,Z.RECIPROCAL).setParameterLength(1),_4=W(Z,Z.TRUNC).setParameterLength(1),v4=W(Z,Z.FWIDTH).setParameterLength(1),y4=W(Z,Z.TRANSPOSE).setParameterLength(1),b4=W(Z,Z.BITCAST).setParameterLength(2),x4=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),g2(e,t)),S4=W(Z,Z.MIN).setParameterLength(2,1/0),C4=W(Z,Z.MAX).setParameterLength(2,1/0),w4=W(Z,Z.STEP).setParameterLength(2),T4=W(Z,Z.REFLECT).setParameterLength(2),E4=W(Z,Z.DISTANCE).setParameterLength(2),D4=W(Z,Z.DIFFERENCE).setParameterLength(2),O4=W(Z,Z.DOT).setParameterLength(2),k4=W(Z,Z.CROSS).setParameterLength(2),A4=W(Z,Z.POW).setParameterLength(2),j4=W(Z,Z.POW,2).setParameterLength(1),M4=W(Z,Z.POW,3).setParameterLength(1),N4=W(Z,Z.POW,4).setParameterLength(1),P4=W(Z,Z.TRANSFORM_DIRECTION).setParameterLength(2),F4=e=>p2(l4(e),A4(c4(e),1/3)),I4=e=>O4(e,e),L4=W(Z,Z.MIX).setParameterLength(3),R4=(e,t=0,n=1)=>U(new Z(Z.CLAMP,U(e),U(t),U(n))),z4=e=>R4(e),B4=W(Z,Z.REFRACT).setParameterLength(3),V4=W(Z,Z.SMOOTHSTEP).setParameterLength(3),H4=W(Z,Z.FACEFORWARD).setParameterLength(3),U4=K(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=O4(e.xy,Y(t,n)),a=h2(i,B2);return t4(n4(a).mul(r))}),W4=(e,t,n)=>L4(t,n,e),G4=(e,t,n)=>V4(t,n,e),K4=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),s4(e,t)),q4=H4,J4=Z2;H(`all`,H2),H(`any`,U2),H(`equals`,x4),H(`radians`,W2),H(`degrees`,G2),H(`exp`,K2),H(`exp2`,q2),H(`log`,J2),H(`log2`,Y2),H(`sqrt`,X2),H(`inverseSqrt`,Z2),H(`floor`,Q2),H(`ceil`,$2),H(`normalize`,e4),H(`fract`,t4),H(`sin`,n4),H(`cos`,r4),H(`tan`,i4),H(`asin`,a4),H(`acos`,o4),H(`atan`,s4),H(`abs`,c4),H(`sign`,l4),H(`length`,u4),H(`lengthSq`,I4),H(`negate`,d4),H(`oneMinus`,f4),H(`dFdx`,p4),H(`dFdy`,m4),H(`round`,h4),H(`reciprocal`,g4),H(`trunc`,_4),H(`fwidth`,v4),H(`atan2`,K4),H(`min`,S4),H(`max`,C4),H(`step`,w4),H(`reflect`,T4),H(`distance`,E4),H(`dot`,O4),H(`cross`,k4),H(`pow`,A4),H(`pow2`,j4),H(`pow3`,M4),H(`pow4`,N4),H(`transformDirection`,P4),H(`mix`,W4),H(`clamp`,R4),H(`refract`,B4),H(`smoothstep`,G4),H(`faceForward`,H4),H(`difference`,D4),H(`saturate`,z4),H(`cbrt`,F4),H(`transpose`,y4),H(`rand`,U4);var Y4=class extends Q${static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?y0(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
410
+ `,t===null?console.log(a):t(e,a),n}};const Mq=(e,t=null)=>uW(new jq(uW(e),t));R(`debug`,Mq);const Nq=mW(([e])=>Lq(e.rgb)),Pq=mW(([e,t=_W(1)])=>t.mix(Lq(e.rgb),e.rgb)),Fq=mW(([e,t=_W(1)])=>{let n=BW(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return cK(e.rgb,r,i)}),Iq=mW(([e,t=_W(1)])=>{let n=TW(.57735,.57735,.57735),r=t.cos();return TW(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul($G(n,e.rgb).mul(r.oneMinus())))))}),Lq=(e,t=TW(jH.getLuminanceCoefficients(new HH)))=>$G(e,t),Rq={name:`Grayscale`,props:{},fragmentNode:({childNode:e})=>{let{vec4:t}=xj;if(!e)return console.error(`You must pass a child component into the Grayscale shader.`),t(0);let n=e||t(0,0,0,0);return t(Nq(n.rgb).rgb,n.a)}};var zq=r({__name:`Grayscale`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{}},{blendMode:`normal`,opacity:1,...Object.entries(Rq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Rq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Rq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Rq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI(Rq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Rq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Bq=zq;const Vq={name:`HueShift`,props:{shift:{type:Number,default:0,description:`The amount to shift the hue by`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=xj;if(!t)return console.error(`You must pass a child component into the Hue Shift shader.`),n(0);let r=t||n(0,0,0,0);return n(Iq(r.rgb,e.shift.uniform).rgb,r.a)}};var Hq=r({__name:`HueShift`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},shift:{}},{blendMode:`normal`,opacity:1,...Object.entries(Vq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Vq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Vq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Vq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI(Vq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Vq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Uq=Hq;const Wq={name:`Invert`,props:{},fragmentNode:({childNode:e})=>{let{vec4:t,vec3:n}=xj;if(!e)return console.error(`You must pass a child component into the Invert shader.`),t(0);let r=e||t(0,0,0,0);return t(n(1,1,1).sub(r.rgb),r.a)}};var Gq=r({__name:`Invert`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{}},{blendMode:`normal`,opacity:1,...Object.entries(Wq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Wq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Wq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Wq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI(Wq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Wq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Kq=Gq;const qq={name:`LinearGradient`,props:{startColor:{type:String,default:`#1aff00`,transform:yV,description:`The starting color of the gradient`},endColor:{type:String,default:`#0000ff`,transform:yV,description:`The ending color of the gradient`},angle:{type:Number,default:0,description:`rotation angle in degrees (0-360, where 0 = left-to-right)`},center:{type:Object,default:{x:.5,y:.5},transform:bV},autoRotate:{type:Boolean,default:!1,description:`Enable automatic rotation of the gradient`},autoRotateSpeed:{type:Number,default:1,description:`Speed of the automatic rotation in degrees per second`}},fragmentNode:({uniforms:e,onBeforeRender:t})=>{let{vec2:n,mix:r,float:i,cos:a,sin:o,dot:s,radians:c,viewportUV:l,abs:u,div:d,uniform:f}=xj,p=f(0);t(({deltaTime:t})=>{if(e.autoRotate.uniform.value){let n=e.autoRotateSpeed.uniform.value*t*100;p.value=(p.value+n)%360}});let m=e.angle.uniform.add(p),h=c(m),g=a(h),_=o(h),v=n(g,_),y=n(e.center.uniform[0],e.center.uniform[1]),b=l.sub(y),x=s(b,v),S=i(.5).mul(u(g).add(u(_))),ee=d(x,S.max(1e-6)),te=ee.mul(.5).add(.5).clamp(i(0),i(1));return r(e.startColor.uniform,e.endColor.uniform,te)}};var Jq=r({__name:`LinearGradient`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},startColor:{},endColor:{},angle:{},center:{},autoRotate:{type:Boolean},autoRotateSpeed:{}},{blendMode:`normal`,opacity:1,...Object.entries(qq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${qq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(qq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(qq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI(qq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,qq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Yq=Jq;const Xq=`177`,Zq=0,Qq=3,$q=0,eJ=1,tJ=0,nJ=1,rJ=100,iJ=204,aJ=205,oJ=3,sJ=0,cJ=0,lJ=300,uJ=301,dJ=302,fJ=306,pJ=1e3,mJ=1001,hJ=1002,gJ=1003,_J=1006,vJ=1008,yJ=1008,bJ=1009,xJ=1013,SJ=1014,CJ=1015,wJ=1016,TJ=1023,EJ=1026,DJ=1027,OJ=1030,kJ=2300,AJ=2301,jJ=2302,MJ=2400,NJ=2401,PJ=2402,FJ=0,IJ=1,LJ=``,RJ=`srgb`,zJ=`srgb-linear`,BJ=`linear`,VJ=`srgb`,HJ=7680,UJ=519,WJ=512,GJ=513,KJ=514,qJ=515,JJ=516,YJ=517,XJ=518,ZJ=519,QJ=35044,$J=35048,eY=2e3,tY=2001;var nY=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const rY=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`);let iY=1234567;const aY=Math.PI/180,oY=180/Math.PI;function sY(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=rY[e&255]+rY[e>>8&255]+rY[e>>16&255]+rY[e>>24&255]+`-`+rY[t&255]+rY[t>>8&255]+`-`+rY[t>>16&15|64]+rY[t>>24&255]+`-`+rY[n&63|128]+rY[n>>8&255]+`-`+rY[n>>16&255]+rY[n>>24&255]+rY[r&255]+rY[r>>8&255]+rY[r>>16&255]+rY[r>>24&255];return i.toLowerCase()}function cY(e,t,n){return Math.max(t,Math.min(n,e))}function lY(e,t){return(e%t+t)%t}function uY(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function dY(e,t,n){return e===t?0:(n-e)/(t-e)}function fY(e,t,n){return(1-n)*e+n*t}function pY(e,t,n,r){return fY(e,t,1-Math.exp(-n*r))}function mY(e,t=1){return t-Math.abs(lY(e,t*2)-t)}function hY(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function gY(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function _Y(e,t){return e+Math.floor(Math.random()*(t-e+1))}function vY(e,t){return e+Math.random()*(t-e)}function yY(e){return e*(.5-Math.random())}function bY(e){e!==void 0&&(iY=e);let t=iY+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function xY(e){return e*aY}function SY(e){return e*oY}function CY(e){return(e&e-1)==0&&e!==0}function wY(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function TY(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function EY(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function DY(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function OY(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const kY={DEG2RAD:aY,RAD2DEG:oY,generateUUID:sY,clamp:cY,euclideanModulo:lY,mapLinear:uY,inverseLerp:dY,lerp:fY,damp:pY,pingpong:mY,smoothstep:hY,smootherstep:gY,randInt:_Y,randFloat:vY,randFloatSpread:yY,seededRandom:bY,degToRad:xY,radToDeg:SY,isPowerOfTwo:CY,ceilPowerOfTwo:wY,floorPowerOfTwo:TY,setQuaternionFromProperEuler:EY,normalize:OY,denormalize:DY};var AY=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=cY(this.x,e.x,t.x),this.y=cY(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=cY(this.x,e,t),this.y=cY(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(cY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(cY(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},jY=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(cY(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},V=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(NY.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(NY.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=cY(this.x,e.x,t.x),this.y=cY(this.y,e.y,t.y),this.z=cY(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=cY(this.x,e,t),this.y=cY(this.y,e,t),this.z=cY(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(cY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return MY.copy(this).projectOnVector(e),this.sub(MY)}reflect(e){return this.sub(MY.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(cY(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const MY=new V,NY=new jY;var PY=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(FY.makeScale(e,t)),this}rotate(e){return this.premultiply(FY.makeRotation(-e)),this}translate(e,t){return this.premultiply(FY.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const FY=new PY;function IY(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function LY(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}const RY={};function zY(e){e in RY||(RY[e]=!0,console.warn(e))}const BY=new PY().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),VY=new PY().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function HY(){let e={enabled:!0,workingColorSpace:zJ,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===VJ&&(e.r=WY(e.r),e.g=WY(e.g),e.b=WY(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===VJ&&(e.r=GY(e.r),e.g=GY(e.g),e.b=GY(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===LJ?BJ:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return zY(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return zY(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[zJ]:{primaries:t,whitePoint:r,transfer:BJ,toXYZ:BY,fromXYZ:VY,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:RJ},outputColorSpaceConfig:{drawingBufferColorSpace:RJ}},[RJ]:{primaries:t,whitePoint:r,transfer:VJ,toXYZ:BY,fromXYZ:VY,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:RJ}}}),e}const UY=HY();function WY(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function GY(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}let KY;var qY=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{KY===void 0&&(KY=LY(`canvas`)),KY.width=e.width,KY.height=e.height;let t=KY.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=KY}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=LY(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=WY(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(WY(t[e]/255)*255):t[e]=WY(t[e]);return{data:t,width:e.width,height:e.height}}else return console.warn(`THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}};let JY=0;var YY=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:JY++}),this.uuid=sY(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(XY(r[t].image)):e.push(XY(r[t]))}else e=XY(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function XY(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?qY.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn(`THREE.Texture: Unable to serialize Texture.`),{})}let ZY=0;const QY=new V;var $Y=class e extends nY{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=mJ,i=mJ,a=_J,o=vJ,s=TJ,c=bJ,l=e.DEFAULT_ANISOTROPY,u=LJ){super(),this.isTexture=!0,Object.defineProperty(this,`id`,{value:ZY++}),this.uuid=sY(),this.name=``,this.source=new YY(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new AY(0,0),this.repeat=new AY(1,1),this.center=new AY(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new PY,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(QY).x}get height(){return this.source.getSize(QY).y}get depth(){return this.source.getSize(QY).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==lJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case pJ:e.x-=Math.floor(e.x);break;case mJ:e.x=e.x<0?0:1;break;case hJ:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case pJ:e.y-=Math.floor(e.y);break;case mJ:e.y=e.y<0?0:1;break;case hJ:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};$Y.DEFAULT_IMAGE=null,$Y.DEFAULT_MAPPING=lJ,$Y.DEFAULT_ANISOTROPY=1;var eX=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=cY(this.x,e.x,t.x),this.y=cY(this.y,e.y,t.y),this.z=cY(this.z,e.z,t.z),this.w=cY(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=cY(this.x,e,t),this.y=cY(this.y,e,t),this.z=cY(this.z,e,t),this.w=cY(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(cY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},tX=class extends nY{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:_J,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new eX(0,0,e,t),this.scissorTest=!1,this.viewport=new eX(0,0,e,t);let r={width:e,height:t,depth:n.depth},i=new $Y(r);this.textures=[];let a=n.count;for(let e=0;e<a;e++)this.textures[e]=i.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:_J,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++){let n=this.textures[e];n.setValues(t)}}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new YY(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},nX=class extends $Y{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=gJ,this.minFilter=gJ,this.wrapR=mJ,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},rX=class{constructor(e=new V(1/0,1/0,1/0),t=new V(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(aX.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(aX.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=aX.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,aX):aX.fromBufferAttribute(r,t),aX.applyMatrix4(e.matrixWorld),this.expandByPoint(aX);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),oX.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),oX.copy(e.boundingBox)),oX.applyMatrix4(e.matrixWorld),this.union(oX)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,aX),aX.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(pX),mX.subVectors(this.max,pX),sX.subVectors(e.a,pX),cX.subVectors(e.b,pX),lX.subVectors(e.c,pX),uX.subVectors(cX,sX),dX.subVectors(lX,cX),fX.subVectors(sX,lX);let t=[0,-uX.z,uX.y,0,-dX.z,dX.y,0,-fX.z,fX.y,uX.z,0,-uX.x,dX.z,0,-dX.x,fX.z,0,-fX.x,-uX.y,uX.x,0,-dX.y,dX.x,0,-fX.y,fX.x,0];return!_X(t,sX,cX,lX,mX)||(t=[1,0,0,0,1,0,0,0,1],!_X(t,sX,cX,lX,mX))?!1:(hX.crossVectors(uX,dX),t=[hX.x,hX.y,hX.z],_X(t,sX,cX,lX,mX))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,aX).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(aX).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(iX[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),iX[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),iX[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),iX[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),iX[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),iX[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),iX[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),iX[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(iX),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};const iX=[new V,new V,new V,new V,new V,new V,new V,new V],aX=new V,oX=new rX,sX=new V,cX=new V,lX=new V,uX=new V,dX=new V,fX=new V,pX=new V,mX=new V,hX=new V,gX=new V;function _X(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){gX.fromArray(e,a);let o=i.x*Math.abs(gX.x)+i.y*Math.abs(gX.y)+i.z*Math.abs(gX.z),s=t.dot(gX),c=n.dot(gX),l=r.dot(gX);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}const vX=new rX,yX=new V,bX=new V;var xX=class{constructor(e=new V,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?vX.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;yX.subVectors(e,this.center);let t=yX.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(yX,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(bX.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(yX.copy(e.center).add(bX)),this.expandByPoint(yX.copy(e.center).sub(bX))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const SX=new V,CX=new V,wX=new V,TX=new V,EX=new V,DX=new V,OX=new V;var kX=class{constructor(e=new V,t=new V(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,SX)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=SX.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(SX.copy(this.origin).addScaledVector(this.direction,t),SX.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){CX.copy(e).add(t).multiplyScalar(.5),wX.copy(t).sub(e).normalize(),TX.copy(this.origin).sub(CX);let i=e.distanceTo(t)*.5,a=-this.direction.dot(wX),o=TX.dot(this.direction),s=-TX.dot(wX),c=TX.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(CX).addScaledVector(wX,d),f}intersectSphere(e,t){SX.subVectors(e.center,this.origin);let n=SX.dot(this.direction),r=SX.dot(SX)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;let n=e.normal.dot(this.direction);return n*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,SX)!==null}intersectTriangle(e,t,n,r,i){EX.subVectors(t,e),DX.subVectors(n,e),OX.crossVectors(EX,DX);let a=this.direction.dot(OX),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;TX.subVectors(this.origin,e);let s=o*this.direction.dot(DX.crossVectors(TX,DX));if(s<0)return null;let c=o*this.direction.dot(EX.cross(TX));if(c<0||s+c>a)return null;let l=-o*TX.dot(OX);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},AX=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/jX.setFromMatrixColumn(e,0).length(),i=1/jX.setFromMatrixColumn(e,1).length(),a=1/jX.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(NX,e,PX)}lookAt(e,t,n){let r=this.elements;return LX.subVectors(e,t),LX.lengthSq()===0&&(LX.z=1),LX.normalize(),FX.crossVectors(n,LX),FX.lengthSq()===0&&(Math.abs(n.z)===1?LX.x+=1e-4:LX.z+=1e-4,LX.normalize(),FX.crossVectors(n,LX)),FX.normalize(),IX.crossVectors(LX,FX),r[0]=FX.x,r[4]=IX.x,r[8]=LX.x,r[1]=FX.y,r[5]=IX.y,r[9]=LX.y,r[2]=FX.z,r[6]=IX.z,r[10]=LX.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=jX.set(r[0],r[1],r[2]).length(),a=jX.set(r[4],r[5],r[6]).length(),o=jX.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],MX.copy(this);let c=1/i,l=1/a,u=1/o;return MX.elements[0]*=c,MX.elements[1]*=c,MX.elements[2]*=c,MX.elements[4]*=l,MX.elements[5]*=l,MX.elements[6]*=l,MX.elements[8]*=u,MX.elements[9]*=u,MX.elements[10]*=u,t.setFromRotationMatrix(MX),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=eY){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===eY)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===tY)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=eY){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===eY)p=(a+i)*u,m=-2*u;else if(o===tY)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const jX=new V,MX=new AX,NX=new V(0,0,0),PX=new V(1,1,1),FX=new V,IX=new V,LX=new V,RX=new AX,zX=new jY;var BX=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(cY(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-cY(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(cY(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-cY(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(cY(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-cY(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:console.warn(`THREE.Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return RX.makeRotationFromQuaternion(e),this.setFromRotationMatrix(RX,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return zX.setFromEuler(this),this.setFromQuaternion(zX,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};BX.DEFAULT_ORDER=`XYZ`;var VX=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}};let HX=0;const UX=new V,WX=new jY,GX=new AX,KX=new V,qX=new V,JX=new V,YX=new jY,XX=new V(1,0,0),ZX=new V(0,1,0),QX=new V(0,0,1),$X={type:`added`},eZ={type:`removed`},tZ={type:`childadded`,child:null},nZ={type:`childremoved`,child:null};var rZ=class e extends nY{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:HX++}),this.uuid=sY(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new V,n=new BX,r=new jY,i=new V(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new AX},normalMatrix:{value:new PY}}),this.matrix=new AX,this.matrixWorld=new AX,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new VX,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return WX.setFromAxisAngle(e,t),this.quaternion.multiply(WX),this}rotateOnWorldAxis(e,t){return WX.setFromAxisAngle(e,t),this.quaternion.premultiply(WX),this}rotateX(e){return this.rotateOnAxis(XX,e)}rotateY(e){return this.rotateOnAxis(ZX,e)}rotateZ(e){return this.rotateOnAxis(QX,e)}translateOnAxis(e,t){return UX.copy(e).applyQuaternion(this.quaternion),this.position.add(UX.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(XX,e)}translateY(e){return this.translateOnAxis(ZX,e)}translateZ(e){return this.translateOnAxis(QX,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(GX.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?KX.copy(e):KX.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),qX.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?GX.lookAt(qX,KX,this.up):GX.lookAt(KX,qX,this.up),this.quaternion.setFromRotationMatrix(GX),r&&(GX.extractRotation(r.matrixWorld),WX.setFromRotationMatrix(GX),this.quaternion.premultiply(WX.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error(`THREE.Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent($X),tZ.child=e,this.dispatchEvent(tZ),tZ.child=null):console.error(`THREE.Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(eZ),nZ.child=e,this.dispatchEvent(nZ),nZ.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),GX.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),GX.multiply(e.parent.matrixWorld)),e.applyMatrix4(GX),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent($X),tZ.child=e,this.dispatchEvent(tZ),tZ.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n],i=r.getObjectByProperty(e,t);if(i!==void 0)return i}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(qX,e,JX),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(qX,YX,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++){let r=t[n];r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++){let n=e[t];n.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};rZ.DEFAULT_UP=new V(0,1,0),rZ.DEFAULT_MATRIX_AUTO_UPDATE=!0,rZ.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const iZ=new V,aZ=new V,oZ=new V,sZ=new V,cZ=new V,lZ=new V,uZ=new V,dZ=new V,fZ=new V,pZ=new V,mZ=new eX,hZ=new eX,gZ=new eX;var _Z=class e{constructor(e=new V,t=new V,n=new V){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),iZ.subVectors(e,t),r.cross(iZ);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){iZ.subVectors(r,t),aZ.subVectors(n,t),oZ.subVectors(e,t);let a=iZ.dot(iZ),o=iZ.dot(aZ),s=iZ.dot(oZ),c=aZ.dot(aZ),l=aZ.dot(oZ),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,sZ)===null?!1:sZ.x>=0&&sZ.y>=0&&sZ.x+sZ.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,sZ)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,sZ.x),s.addScaledVector(a,sZ.y),s.addScaledVector(o,sZ.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return mZ.setScalar(0),hZ.setScalar(0),gZ.setScalar(0),mZ.fromBufferAttribute(e,t),hZ.fromBufferAttribute(e,n),gZ.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(mZ,i.x),a.addScaledVector(hZ,i.y),a.addScaledVector(gZ,i.z),a}static isFrontFacing(e,t,n,r){return iZ.subVectors(n,t),aZ.subVectors(e,t),iZ.cross(aZ).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return iZ.subVectors(this.c,this.b),aZ.subVectors(this.a,this.b),iZ.cross(aZ).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;cZ.subVectors(r,n),lZ.subVectors(i,n),dZ.subVectors(e,n);let s=cZ.dot(dZ),c=lZ.dot(dZ);if(s<=0&&c<=0)return t.copy(n);fZ.subVectors(e,r);let l=cZ.dot(fZ),u=lZ.dot(fZ);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(cZ,a);pZ.subVectors(e,i);let f=cZ.dot(pZ),p=lZ.dot(pZ);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(lZ,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return uZ.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(uZ,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(cZ,a).addScaledVector(lZ,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const vZ={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},yZ={h:0,s:0,l:0},bZ={h:0,s:0,l:0};function xZ(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var SZ=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=RJ){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,UY.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=UY.workingColorSpace){return this.r=e,this.g=t,this.b=n,UY.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=UY.workingColorSpace){if(e=lY(e,1),t=cY(t,0,1),n=cY(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=xZ(i,r,e+1/3),this.g=xZ(i,r,e),this.b=xZ(i,r,e-1/3)}return UY.colorSpaceToWorking(this,r),this}setStyle(e,t=RJ){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=RJ){let n=vZ[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=WY(e.r),this.g=WY(e.g),this.b=WY(e.b),this}copyLinearToSRGB(e){return this.r=GY(e.r),this.g=GY(e.g),this.b=GY(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=RJ){return UY.workingToColorSpace(CZ.copy(this),e),Math.round(cY(CZ.r*255,0,255))*65536+Math.round(cY(CZ.g*255,0,255))*256+Math.round(cY(CZ.b*255,0,255))}getHexString(e=RJ){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=UY.workingColorSpace){UY.workingToColorSpace(CZ.copy(this),t);let n=CZ.r,r=CZ.g,i=CZ.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=UY.workingColorSpace){return UY.workingToColorSpace(CZ.copy(this),t),e.r=CZ.r,e.g=CZ.g,e.b=CZ.b,e}getStyle(e=RJ){UY.workingToColorSpace(CZ.copy(this),e);let t=CZ.r,n=CZ.g,r=CZ.b;return e===RJ?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(yZ),this.setHSL(yZ.h+e,yZ.s+t,yZ.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(yZ),e.getHSL(bZ);let n=fY(yZ.h,bZ.h,t),r=fY(yZ.s,bZ.s,t),i=fY(yZ.l,bZ.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const CZ=new SZ;SZ.NAMES=vZ;let wZ=0;var TZ=class extends nY{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:wZ++}),this.uuid=sY(),this.name=``,this.type=`Material`,this.blending=nJ,this.side=$q,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=iJ,this.blendDst=aJ,this.blendEquation=rJ,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new SZ(0,0,0),this.blendAlpha=0,this.depthFunc=oJ,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=UJ,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=HJ,this.stencilZFail=HJ,this.stencilZPass=HJ,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==nJ&&(n.blending=this.blending),this.side!==$q&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==iJ&&(n.blendSrc=this.blendSrc),this.blendDst!==aJ&&(n.blendDst=this.blendDst),this.blendEquation!==rJ&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==oJ&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==UJ&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==HJ&&(n.stencilFail=this.stencilFail),this.stencilZFail!==HJ&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==HJ&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},EZ=class extends TZ{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new SZ(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new BX,this.combine=sJ,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const DZ=new V,OZ=new AY;let kZ=0;var AZ=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:kZ++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=QJ,this.updateRanges=[],this.gpuType=CJ,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)OZ.fromBufferAttribute(this,t),OZ.applyMatrix3(e),this.setXY(t,OZ.x,OZ.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)DZ.fromBufferAttribute(this,t),DZ.applyMatrix3(e),this.setXYZ(t,DZ.x,DZ.y,DZ.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)DZ.fromBufferAttribute(this,t),DZ.applyMatrix4(e),this.setXYZ(t,DZ.x,DZ.y,DZ.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)DZ.fromBufferAttribute(this,t),DZ.applyNormalMatrix(e),this.setXYZ(t,DZ.x,DZ.y,DZ.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)DZ.fromBufferAttribute(this,t),DZ.transformDirection(e),this.setXYZ(t,DZ.x,DZ.y,DZ.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=DY(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=OY(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=DY(t,this.array)),t}setX(e,t){return this.normalized&&(t=OY(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=DY(t,this.array)),t}setY(e,t){return this.normalized&&(t=OY(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=DY(t,this.array)),t}setZ(e,t){return this.normalized&&(t=OY(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=DY(t,this.array)),t}setW(e,t){return this.normalized&&(t=OY(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=OY(t,this.array),n=OY(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=OY(t,this.array),n=OY(n,this.array),r=OY(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=OY(t,this.array),n=OY(n,this.array),r=OY(r,this.array),i=OY(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==QJ&&(e.usage=this.usage),e}},jZ=class extends AZ{constructor(e,t,n){super(new Uint16Array(e),t,n)}},MZ=class extends AZ{constructor(e,t,n){super(new Uint32Array(e),t,n)}},NZ=class extends AZ{constructor(e,t,n){super(new Float32Array(e),t,n)}};let PZ=0;const FZ=new AX,IZ=new rZ,LZ=new V,RZ=new rX,zZ=new rX,BZ=new V;var VZ=class e extends nY{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:PZ++}),this.uuid=sY(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(IY(e)?MZ:jZ)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new PY().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return FZ.makeRotationFromQuaternion(e),this.applyMatrix4(FZ),this}rotateX(e){return FZ.makeRotationX(e),this.applyMatrix4(FZ),this}rotateY(e){return FZ.makeRotationY(e),this.applyMatrix4(FZ),this}rotateZ(e){return FZ.makeRotationZ(e),this.applyMatrix4(FZ),this}translate(e,t,n){return FZ.makeTranslation(e,t,n),this.applyMatrix4(FZ),this}scale(e,t,n){return FZ.makeScale(e,t,n),this.applyMatrix4(FZ),this}lookAt(e){return IZ.lookAt(e),IZ.updateMatrix(),this.applyMatrix4(IZ.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(LZ).negate(),this.translate(LZ.x,LZ.y,LZ.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new NZ(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&console.warn(`THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new rX);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new V(-1/0,-1/0,-1/0),new V(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];RZ.setFromBufferAttribute(n),this.morphTargetsRelative?(BZ.addVectors(this.boundingBox.min,RZ.min),this.boundingBox.expandByPoint(BZ),BZ.addVectors(this.boundingBox.max,RZ.max),this.boundingBox.expandByPoint(BZ)):(this.boundingBox.expandByPoint(RZ.min),this.boundingBox.expandByPoint(RZ.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error(`THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new xX);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new V,1/0);return}if(e){let n=this.boundingSphere.center;if(RZ.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];zZ.setFromBufferAttribute(n),this.morphTargetsRelative?(BZ.addVectors(RZ.min,zZ.min),RZ.expandByPoint(BZ),BZ.addVectors(RZ.max,zZ.max),RZ.expandByPoint(BZ)):(RZ.expandByPoint(zZ.min),RZ.expandByPoint(zZ.max))}RZ.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)BZ.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(BZ));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)BZ.fromBufferAttribute(a,t),o&&(LZ.fromBufferAttribute(e,t),BZ.add(LZ)),r=Math.max(r,n.distanceToSquared(BZ))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error(`THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new AZ(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new V,s[e]=new V;let c=new V,l=new V,u=new V,d=new AY,f=new AY,p=new AY,m=new V,h=new V;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new V,y=new V,b=new V,x=new V;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e]),i=n<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,i)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new AZ(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new V,i=new V,a=new V,o=new V,s=new V,c=new V,l=new V,u=new V;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)BZ.fromBufferAttribute(e,t),BZ.normalize(),e.setXYZ(t,BZ.x,BZ.y,BZ.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new AZ(a,r,i)}if(this.index===null)return console.warn(`THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}};const HZ=new AX,UZ=new kX,WZ=new xX,GZ=new V,KZ=new V,qZ=new V,JZ=new V,YZ=new V,XZ=new V,ZZ=new V,QZ=new V;var $Z=class extends rZ{constructor(e=new VZ,t=new EZ){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry,t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){XZ.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(YZ.fromBufferAttribute(s,e),a?XZ.addScaledVector(YZ,r):XZ.addScaledVector(YZ.sub(t),r))}t.add(XZ)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),WZ.copy(n.boundingSphere),WZ.applyMatrix4(i),UZ.copy(e.ray).recast(e.near),!(WZ.containsPoint(UZ.origin)===!1&&(UZ.intersectSphere(WZ,GZ)===null||UZ.origin.distanceToSquared(GZ)>(e.far-e.near)**2))&&(HZ.copy(i).invert(),UZ.copy(e.ray).applyMatrix4(HZ),!(n.boundingBox!==null&&UZ.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,UZ)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=tQ(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=tQ(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=tQ(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=tQ(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function eQ(e,t,n,r,i,a,o,s){let c;if(c=t.side===eJ?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===$q,s),c===null)return null;QZ.copy(s),QZ.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(QZ);return l<n.near||l>n.far?null:{distance:l,point:QZ.clone(),object:e}}function tQ(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,KZ),e.getVertexPosition(c,qZ),e.getVertexPosition(l,JZ);let u=eQ(e,t,n,r,KZ,qZ,JZ,ZZ);if(u){let e=new V;_Z.getBarycoord(ZZ,KZ,qZ,JZ,e),i&&(u.uv=_Z.getInterpolatedAttribute(i,s,c,l,e,new AY)),a&&(u.uv1=_Z.getInterpolatedAttribute(a,s,c,l,e,new AY)),o&&(u.normal=_Z.getInterpolatedAttribute(o,s,c,l,e,new V),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new V,materialIndex:0};_Z.getNormal(KZ,qZ,JZ,t.normal),u.face=t,u.barycoord=e}return u}var nQ=class e extends VZ{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new NZ(c,3)),this.setAttribute(`normal`,new NZ(l,3)),this.setAttribute(`uv`,new NZ(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,ee=h+1,te=g+1,ne=0,re=0,ie=new V;for(let a=0;a<te;a++){let o=a*y-x;for(let s=0;s<ee;s++){let d=s*v-b;ie[e]=d*r,ie[t]=o*i,ie[n]=S,c.push(ie.x,ie.y,ie.z),ie[e]=0,ie[t]=0,ie[n]=m>0?1:-1,l.push(ie.x,ie.y,ie.z),u.push(s/h),u.push(1-a/g),ne+=1}}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+ee*e,r=d+t+ee*(e+1),i=d+(t+1)+ee*(e+1),a=d+(t+1)+ee*e;s.push(n,r,a),s.push(r,i,a),re+=6}o.addGroup(f,re,_),f+=re,d+=ne}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},rQ=class extends rZ{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new AX,this.projectionMatrix=new AX,this.projectionMatrixInverse=new AX,this.coordinateSystem=eY}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const iQ=new V,aQ=new AY,oQ=new AY;var sQ=class extends rQ{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=oY*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(aY*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return oY*2*Math.atan(Math.tan(aY*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){iQ.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(iQ.x,iQ.y).multiplyScalar(-e/iQ.z),iQ.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(iQ.x,iQ.y).multiplyScalar(-e/iQ.z)}getViewSize(e,t){return this.getViewBounds(e,aQ,oQ),t.subVectors(oQ,aQ)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(aY*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},cQ=class extends $Y{constructor(e=[],t=uJ,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},lQ=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=QJ,this.updateRanges=[],this.version=0,this.uuid=sY()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=sY()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=sY()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}};const uQ=new V;var dQ=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)uQ.fromBufferAttribute(this,t),uQ.applyMatrix4(e),this.setXYZ(t,uQ.x,uQ.y,uQ.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)uQ.fromBufferAttribute(this,t),uQ.applyNormalMatrix(e),this.setXYZ(t,uQ.x,uQ.y,uQ.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)uQ.fromBufferAttribute(this,t),uQ.transformDirection(e),this.setXYZ(t,uQ.x,uQ.y,uQ.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=DY(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=OY(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=OY(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=OY(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=OY(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=OY(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=DY(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=DY(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=DY(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=DY(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=OY(t,this.array),n=OY(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=OY(t,this.array),n=OY(n,this.array),r=OY(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=OY(t,this.array),n=OY(n,this.array),r=OY(r,this.array),i=OY(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new AZ(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log(`THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},fQ=class extends $Y{constructor(e=null,t=1,n=1,r,i,a,o,s,c=gJ,l=gJ,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},pQ=class extends AZ{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};const mQ=new V,hQ=new V,gQ=new PY;var _Q=class{constructor(e=new V(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=mQ.subVectors(n,t).cross(hQ.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(mQ),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||gQ.getNormalMatrix(e),r=this.coplanarPoint(mQ).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},vQ=class extends $Y{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=gJ,this.minFilter=gJ,this.generateMipmaps=!1,this.needsUpdate=!0}},yQ=class extends $Y{constructor(e,t,n=SJ,r,i,a,o=gJ,s=gJ,c,l=EJ,u=1){if(l!==EJ&&l!==DJ)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);let d={width:e,height:t,depth:u};super(d,r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new YY(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}};function bQ(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function xQ(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var SQ=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`call to abstract method`)}intervalChanged_(){}},CQ=class extends SQ{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:MJ,endingEnd:MJ}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case NJ:i=e,o=2*t-n;break;case PJ:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case NJ:a=e,s=2*n-t;break;case PJ:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},wQ=class extends SQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},TQ=class extends SQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},EQ=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=bQ(t,this.TimeBufferType),this.values=bQ(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:bQ(e.times,Array),values:bQ(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new TQ(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new wQ(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new CQ(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case kJ:t=this.InterpolantFactoryMethodDiscrete;break;case AJ:t=this.InterpolantFactoryMethodLinear;break;case jJ:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let t=`unsupported interpolation for `+this.ValueTypeName+` keyframe track named `+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(t);return console.warn(`THREE.KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return kJ;case this.InterpolantFactoryMethodLinear:return AJ;case this.InterpolantFactoryMethodSmooth:return jJ}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error(`THREE.KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(console.error(`THREE.KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){console.error(`THREE.KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){console.error(`THREE.KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&xQ(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){console.error(`THREE.KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===jJ,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o],c=e[o+1];if(s!==c&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};EQ.prototype.ValueTypeName=``,EQ.prototype.TimeBufferType=Float32Array,EQ.prototype.ValueBufferType=Float32Array,EQ.prototype.DefaultInterpolation=AJ;var DQ=class extends EQ{constructor(e,t,n){super(e,t,n)}};DQ.prototype.ValueTypeName=`bool`,DQ.prototype.ValueBufferType=Array,DQ.prototype.DefaultInterpolation=kJ,DQ.prototype.InterpolantFactoryMethodLinear=void 0,DQ.prototype.InterpolantFactoryMethodSmooth=void 0;var OQ=class extends EQ{constructor(e,t,n,r){super(e,t,n,r)}};OQ.prototype.ValueTypeName=`color`;var kQ=class extends EQ{constructor(e,t,n,r){super(e,t,n,r)}};kQ.prototype.ValueTypeName=`number`;var AQ=class extends SQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)jY.slerpFlat(i,0,a,c-o,a,c,s);return i}},jQ=class extends EQ{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new AQ(this.times,this.values,this.getValueSize(),e)}};jQ.prototype.ValueTypeName=`quaternion`,jQ.prototype.InterpolantFactoryMethodSmooth=void 0;var MQ=class extends EQ{constructor(e,t,n){super(e,t,n)}};MQ.prototype.ValueTypeName=`string`,MQ.prototype.ValueBufferType=Array,MQ.prototype.DefaultInterpolation=kJ,MQ.prototype.InterpolantFactoryMethodLinear=void 0,MQ.prototype.InterpolantFactoryMethodSmooth=void 0;var NQ=class extends EQ{constructor(e,t,n,r){super(e,t,n,r)}};NQ.prototype.ValueTypeName=`vector`;var PQ=class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}};const FQ=new PQ;var IQ=class{constructor(e){this.manager=e===void 0?FQ:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};IQ.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var LQ=class extends rQ{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}};const RQ=`\\[\\]\\.:\\/`,zQ=RegExp(`[`+RQ+`]`,`g`),BQ=`[^`+RQ+`]`,VQ=`[^`+RQ.replace(`\\.`,``)+`]`,HQ=/((?:WC+[\/:])*)/.source.replace(`WC`,BQ),UQ=/(WCOD+)?/.source.replace(`WCOD`,VQ),WQ=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace(`WC`,BQ),GQ=/\.(WC+)(?:\[(.+)\])?/.source.replace(`WC`,BQ),KQ=RegExp(`^`+HQ+UQ+WQ+GQ+`$`),qQ=[`material`,`materials`,`bones`,`map`];var JQ=class{constructor(e,t,n){let r=n||YQ.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},YQ=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(zQ,``)}static parseTrackName(e){let t=KQ.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);qQ.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn(`THREE.PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){console.error(`THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){console.error(`THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){console.error(`THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error(`THREE.PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){console.error(`THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;console.error(`THREE.PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};YQ.Composite=JQ,YQ.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},YQ.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},YQ.prototype.GetterByBindingType=[YQ.prototype._getValue_direct,YQ.prototype._getValue_array,YQ.prototype._getValue_arrayElement,YQ.prototype._getValue_toArray],YQ.prototype.SetterByBindingTypeAndVersioning=[[YQ.prototype._setValue_direct,YQ.prototype._setValue_direct_setNeedsUpdate,YQ.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[YQ.prototype._setValue_array,YQ.prototype._setValue_array_setNeedsUpdate,YQ.prototype._setValue_array_setMatrixWorldNeedsUpdate],[YQ.prototype._setValue_arrayElement,YQ.prototype._setValue_arrayElement_setNeedsUpdate,YQ.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[YQ.prototype._setValue_fromArray,YQ.prototype._setValue_fromArray_setNeedsUpdate,YQ.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const moe=new Float32Array(1);var XQ=class extends lQ{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},ZQ=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}};typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:Xq}})),typeof window<`u`&&(window.__THREE__?console.warn(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=Xq);const QQ=new WeakMap,$Q={name:`MouseDistortion`,props:{viscosity:{type:Number,default:0,description:`Fluid resistance (0-1, higher = more viscous)`},velocityScale:{type:Number,default:2,description:`Speed multiplier for fluid motion`},vorticity:{type:Number,default:.1,description:`Swirl strength (0-1)`},dissipation:{type:Number,default:3,description:`How quickly the effect fades (0-1)`},splatRadius:{type:Number,default:.1,description:`Radius of fluid splat effect (0-1)`}},fragmentNode:({uniforms:e,onBeforeRender:t,childNode:n,onCleanup:r,canvas:i})=>{let{vec2:a,vec4:o,float:s,uniform:c,viewportUV:l,convertToTexture:u,texture:d}=xj;if(!n)return o(l.x,l.y,0,1);let f=u(n),p=32,m=new Float32Array(p*p*2),h=new fQ(m,p,p,OJ,CJ);h.magFilter=_J,h.minFilter=_J,h.needsUpdate=!0;let g=d(h),_=c(.5),v=c(.5),y=c(0),b=c(0),x=.5,S=.5,ee=Date.now();t(({pointer:t})=>{let n=Date.now(),r=Math.min((n-ee)/1e3,.016);ee=n;let i=r>0?(t.x-x)/r:0,a=r>0?(t.y-S)/r:0;y.value=y.value*.85+i*.15,b.value=b.value*.85+a*.15,_.value=t.x,v.value=t.y;let o=e.dissipation.uniform.value,s=e.velocityScale.uniform.value,c=e.splatRadius.uniform.value,l=e.vorticity.uniform.value;for(let e=0;e<p;e++)for(let n=0;n<p;n++){let u=(e*p+n)*2;m[u]*=1-o*r,m[u+1]*=1-o*r;let d=(n+.5)/p,f=(e+.5)/p,h=d-t.x,g=f-t.y,_=Math.sqrt(h*h+g*g);if(_<c*2&&Math.abs(i)+Math.abs(a)>.01){let e=Math.exp(-_*_/(c*c));if(m[u]+=y.value*e*s*r*.5,m[u+1]+=b.value*e*s*r*.5,l>0){let t=Math.atan2(g,h)+Math.PI*.5;m[u]+=Math.cos(t)*l*e*r*2,m[u+1]+=Math.sin(t)*l*e*r*2}}m[u]=Math.max(-1,Math.min(1,m[u])),m[u+1]=Math.max(-1,Math.min(1,m[u+1]))}h.needsUpdate=!0,x=t.x,S=t.y});let te=QQ.get(i);te||(te=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect,i=window.devicePixelRatio||1;f.setSize(Math.round(n*i),Math.round(r*i))}),te.observe(i),QQ.set(i,te)),r(()=>{h.dispose();let e=QQ.get(i);e&&(e.disconnect(),QQ.delete(i))});let ne=g.sample(l).xy,re=s(.1),ie=s(-.1),ae=ne.clamp(a(ie,ie),a(re,re)),oe=l.sub(ae);return f.sample(oe)}};var e$=r({__name:`MouseDistortion`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},viscosity:{},velocityScale:{},vorticity:{},dissipation:{},splatRadius:{}},{blendMode:`normal`,opacity:1,...Object.entries($Q.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${$Q.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries($Q.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries($Q.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI($Q,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,$Q.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),t$=e$,n$=class extends hU{static get type(){return`PosterizeNode`}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){let{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}};const r$=z(n$).setParameterLength(2),i$={name:`Posterize`,props:{intensity:{type:Number,default:5,description:`The intensity of the posterization effect (lower is more posterized)`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n,int:r}=xj;if(!t)return console.error(`You must pass a child component into the Posterize shader.`),n(0);let i=t||n(0,0,0,0);return r$(i,r(e.intensity.uniform))}};var a$=r({__name:`Posterize`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(i$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${i$.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(i$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(i$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI(i$,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,i$.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),o$=a$;const s$={name:`Saturation`,props:{intensity:{type:Number,default:1,description:`The intensity of the saturation effect (1 being no change)`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=xj;if(!t)return console.error(`You must pass a child component into the Saturation shader.`),n(0);let r=t||n(0,0,0,0);return n(Pq(r.rgb,e.intensity.uniform).rgb,r.a)}};var c$=r({__name:`Saturation`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(s$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${s$.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(s$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(s$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI(s$,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,s$.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),l$=c$;const u$={name:`SolidColor`,props:{color:{type:String,default:`#5b18ca`,transform:yV,description:`The solid color to display`}},fragmentNode:({uniforms:e})=>e.color.uniform};var d$=r({__name:`SolidColor`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{}},{blendMode:`normal`,opacity:1,...Object.entries(u$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${u$.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(u$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(u$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI(u$,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,u$.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),f$=d$;const p$={name:`Swirl`,props:{colorA:{type:String,default:`#1275d8`,description:`Primary gradient color`,transform:yV},colorB:{type:String,default:`#e19136`,description:`Secondary gradient color`,transform:yV},colorC:{type:String,default:`#320485`,description:`Accent gradient color`,transform:yV},speed:{type:Number,default:1,description:`Flow animation speed`},scale:{type:Number,default:5,description:`Gradient scale`},complexity:{type:Number,default:5,description:`Flow complexity`}},fragmentNode:({uniforms:e})=>{let t=tF(),n=xP.mul(e.speed.uniform),r=e.scale.uniform,i=e.complexity.uniform,a=RN(t.x.mul(r.mul(1.2)).add(n.mul(.8))).mul(.3),o=OM(t.y.mul(r.mul(.9)).sub(n.mul(.6))).mul(.3),s=cF(t.x.add(RN(t.y.mul(i.mul(2)).add(n)).mul(.08)),t.y.add(OM(t.x.mul(i.mul(1.5)).sub(n.mul(.7))).mul(.08))),c=RN(s.x.mul(r.mul(3)).add(s.y.mul(r.mul(2))).add(n.mul(.5))),l=OM(s.x.sub(s.y).mul(r.mul(2.5)).add(n.mul(.3))),u=RN(s.x.mul(i).add(a).add(s.y.mul(i.mul(.8)).add(o)).add(n.mul(.4))),d=NM(c,l,u.mul(.5).add(.5)),f=s.x.mul(.7).add(s.y.mul(.3)).add(d.mul(.2)),p=NM(e.colorA.uniform,e.colorB.uniform,VN(.1,.6,f)),m=NM(p,e.colorC.uniform,VN(.4,.9,f.add(u.mul(.3)))),h=RN(n.mul(3).add(f.mul(10))).mul(.02).add(1),g=m.mul(h);return uF(g,1)}};var m$=r({__name:`Swirl`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},colorA:{},colorB:{},colorC:{},speed:{},scale:{},complexity:{}},{blendMode:`normal`,opacity:1,...Object.entries(p$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${p$.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(p$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(p$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI(p$,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,p$.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),h$=m$;const g$={name:`Twirl`,props:{center:{type:Object,default:{x:.5,y:.5},transform:bV,description:`The center point of the twirl effect`},intensity:{type:Number,default:1,description:`The strength of the twirl effect`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec2:n,vec4:r,cos:i,sin:a,length:o,uv:s,convertToTexture:c}=xj;if(!t)return console.error(`You must pass a child component into the Twirl shader.`),r(0);let l=c(t),u=s(),d=n(e.center.uniform.x,e.center.uniform.y),f=u.sub(d),p=e.intensity.uniform.mul(o(f)),m=i(p),h=a(p),g=m.mul(f.x).sub(h.mul(f.y)),_=h.mul(f.x).add(m.mul(f.y)),v=n(g.add(d.x),_.add(d.y));return r(l.sample(v))}};var _$=r({__name:`Twirl`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},center:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(g$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${g$.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(g$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(g$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI(g$,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,g$.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),v$=_$;const y$={name:`Vibrance`,props:{intensity:{type:Number,default:0,description:`The intensity of the vibrance effect`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=xj;if(!t)return console.error(`You must pass a child component into the Vibrance shader.`),n(0);let r=t||n(0,0,0,0);return n(Fq(r.rgb,e.intensity.uniform).rgb,r.a)}};var b$=r({__name:`Vibrance`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(y$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${y$.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(y$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(y$.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=tI(y$,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,y$.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),x$=b$;const S$=`alphaMap.alphaTest.anisotropy.anisotropyMap.anisotropyRotation.aoMap.aoMapIntensity.attenuationColor.attenuationDistance.bumpMap.clearcoat.clearcoatMap.clearcoatNormalMap.clearcoatNormalScale.clearcoatRoughness.color.dispersion.displacementMap.emissive.emissiveIntensity.emissiveMap.envMap.envMapIntensity.gradientMap.ior.iridescence.iridescenceIOR.iridescenceMap.iridescenceThicknessMap.lightMap.lightMapIntensity.map.matcap.metalness.metalnessMap.normalMap.normalScale.opacity.roughness.roughnessMap.sheen.sheenColor.sheenColorMap.sheenRoughnessMap.shininess.specular.specularColor.specularColorMap.specularIntensity.specularIntensityMap.specularMap.thickness.transmission.transmissionMap`.split(`.`);var C$=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=S$,this.renderId=0}firstInitialization(e){let t=this.renderObjects.has(e);return t===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){let t=e.getMRT();return t!==null&&t.has(`velocity`)}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){let{geometry:n,material:r,object:i}=e;if(t={material:this.getMaterialData(r),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){let{width:n,height:r}=e.context;t.bufferWidth=n,t.bufferHeight=r}this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let n in e){let r=e[n];t[n]={version:r.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return e.renderer.overrideNodes.modelViewMatrix!==null||e.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(e){let t={};for(let n of this.refreshUniforms){let r=e[n];if(r==null)continue;typeof r==`object`&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r}return t}equals(e){let{object:t,material:n,geometry:r}=e,i=this.getRenderObjectData(e);if(i.worldMatrix.equals(t.matrixWorld)!==!0)return i.worldMatrix.copy(t.matrixWorld),!1;let a=i.material;for(let e in a){let t=a[e],r=n[e];if(t.equals!==void 0){if(t.equals(r)===!1)return t.copy(r),!1}else if(r.isTexture===!0){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,!1}else if(t!==r)return a[e]=r,!1}if(a.transmission>0){let{width:t,height:n}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==n)return i.bufferWidth=t,i.bufferHeight=n,!1}let o=i.geometry,s=r.attributes,c=o.attributes,l=Object.keys(c),u=Object.keys(s);if(o.id!==r.id)return o.id=r.id,!1;if(l.length!==u.length)return i.geometry.attributes=this.getAttributesData(s),!1;for(let e of l){let t=c[e],n=s[e];if(n===void 0)return delete c[e],!1;if(t.version!==n.version)return t.version=n.version,!1}let d=r.index,f=o.indexVersion,p=d?d.version:null;if(f!==p)return o.indexVersion=p,!1;if(o.drawRange.start!==r.drawRange.start||o.drawRange.count!==r.drawRange.count)return o.drawRange.start=r.drawRange.start,o.drawRange.count=r.drawRange.count,!1;if(i.morphTargetInfluences){let e=!1;for(let n=0;n<i.morphTargetInfluences.length;n++)i.morphTargetInfluences[n]!==t.morphTargetInfluences[n]&&(e=!0);if(e)return!0}return i.center&&i.center.equals(t.center)===!1?(i.center.copy(t.center),!0):(e.bundle!==null&&(i.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;let{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;let r=e.object.static===!0,i=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||i)return!1;let a=this.equals(e)!==!0;return a}};function w$(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}const T$=e=>w$(e),E$=e=>w$(e),D$=(...e)=>w$(e);function O$(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of k$(e))n.push(w$(r.slice(0,-4)),i.getCacheKey(t));return w$(n)}function*k$(e,t=!1){for(let n in e){if(n.startsWith(`_`)===!0)continue;let r=e[n];if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)yield{property:n,childNode:r};else if(typeof r==`object`)for(let e in r){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}}}const A$=new Map([[1,`float`],[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]),j$=new WeakMap;function M$(e){return A$.get(e)}function N$(e){if(/[iu]?vec\d/.test(e))return e.startsWith(`ivec`)?Int32Array:e.startsWith(`uvec`)?Uint32Array:Float32Array;if(/mat\d/.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function P$(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 9;if(/mat4/.test(e))return 16;console.error(`THREE.TSL: Unsupported type:`,e)}function F$(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 12;if(/mat4/.test(e))return 16;console.error(`THREE.TSL: Unsupported type:`,e)}function I$(e){if(/float|int|uint/.test(e))return 4;if(/vec2/.test(e))return 8;if(/vec3/.test(e)||/vec4/.test(e))return 16;if(/mat2/.test(e))return 8;if(/mat3/.test(e))return 48;if(/mat4/.test(e))return 64;console.error(`THREE.TSL: Unsupported type:`,e)}function L$(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function R$(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new SZ(...t):n===`vec2`?new AY(...t):n===`vec3`?new V(...t):n===`vec4`?new eX(...t):n===`mat2`?new ZQ(...t):n===`mat3`?new PY(...t):n===`mat4`?new AX(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?V$(t[0]):null}function z$(e){let t=j$.get(e);return t===void 0&&(t={},j$.set(e,t)),t}function B$(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function V$(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}const H$={VERTEX:`vertex`,FRAGMENT:`fragment`},U$={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},W$={BOOLEAN:`bool`,INTEGER:`int`,FLOAT:`float`,VECTOR2:`vec2`,VECTOR3:`vec3`,VECTOR4:`vec4`,MATRIX2:`mat2`,MATRIX3:`mat3`,MATRIX4:`mat4`},G$={READ_ONLY:`readOnly`,WRITE_ONLY:`writeOnly`,READ_WRITE:`readWrite`},K$=[`fragment`,`vertex`],q$=[`setup`,`analyze`,`generate`],J$=[...K$,`compute`],Y$=[`x`,`y`,`z`,`w`],X$={analyze:`setup`,generate:`analyze`};let Z$=0;var Q$=class extends nY{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=U$.NONE,this.updateBeforeType=U$.NONE,this.updateAfterType=U$.NONE,this.uuid=kY.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:Z$++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,U$.FRAME)}onRenderUpdate(e){return this.onUpdate(e,U$.RENDER)}onObjectUpdate(e){return this.onUpdate(e,U$.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of k$(this))yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e||=this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=D$(O$(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e),n=e.getElementType(t);return n}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t);return n||this}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn(`Abstract function.`)}updateAfter(){console.warn(`Abstract function.`)}update(){console.warn(`Abstract function.`)}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=X$[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){let n=this.generate.length===1;if(n){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(console.warn(`THREE.Node: Recursion detected.`,this),a=``):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return k$(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n]){let a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}},$$=class extends Q${static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){let t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`);return`${n}[ ${r} ]`}},e1=class extends Q${static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},t1=class extends Q${static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){let n=e.getBuildStage();if(n===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},n1=class extends t1{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;s+c>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i);let u=e.getComponentType(i);u!==a&&(l=e.format(l,u,a)),o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}};const r1=Y$.join(``);var i1=class extends Q${static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(Y$.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null,o=this.getVectorLength();o>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let s=n.build(e,a);i=this.components.length===r&&this.components===r1.slice(0,this.components.length)?e.format(s,a,t):e.format(`${s}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},a1=class extends t1{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=Y$[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},o1=class extends t1{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=Y$[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},s1=class extends Q${static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?L$(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=L$(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=B$(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?R$(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn(`Abstract function.`)}};const c1=/float|u?int/;var l1=class extends s1{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return c1.test(n)&&c1.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},u1=class extends Q${static get type(){return`MemberNode`}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){let t=this.node.build(e);return t+`.`+this.property}};let d1=null;const f1=new Map;function H(e,t){if(f1.has(e)){console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);f1.set(e,t)}const p1=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),m1=e=>p1(e).split(``).sort().join(``),h1={setup(e,t){let n=t.shift();return e(V1(n),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(d1.assign(n,...e),n);if(f1.has(t)){let r=f1.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}else if(t===`self`)return e;else if(t.endsWith(`Assign`)&&f1.has(t.slice(0,t.length-6))){let r=f1.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}else if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=p1(t),U(new i1(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=m1(t.slice(3).toLowerCase()),n=>U(new a1(e,t,U(n)));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=m1(t.slice(4).toLowerCase()),()=>U(new o1(U(e),t));else if(t===`width`||t===`height`||t===`depth`)return t===`width`?t=`x`:t===`height`?t=`y`:t===`depth`&&(t=`z`),U(new i1(e,t));else if(/^\d+$/.test(t)===!0)return U(new $$(n,new l1(Number(t),`uint`)));else if(/^get$/.test(t)===!0)return e=>U(new u1(n,e))}return Reflect.get(e,t,n)},set(e,t,n,r){return typeof t==`string`&&e[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t===`width`||t===`height`||t===`depth`||/^\d+$/.test(t)===!0)?(r[t].assign(n),!0):Reflect.set(e,t,n,r)}},g1=new WeakMap,_1=new WeakMap,v1=function(e,t=null){let n=L$(e);if(n===`node`){let t=g1.get(e);return t===void 0&&(t=new Proxy(e,h1),g1.set(e,t),g1.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return U(F1(e,t));else if(n===`shader`)return K(e);return e},y1=function(e,t=null){for(let n in e)e[n]=U(e[n],t);return e},b1=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=U(e[r],t);return e},x1=function(e,t=null,n=null,r=null){let i=e=>U(r===null?e:Object.assign(e,r)),a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(console.error(`THREE.TSL: "${n}" parameter length is less than minimum required.`),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(console.error(`THREE.TSL: "${n}" parameter length exceeds limit.`),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...H1(l(t)))):n===null?a=(...n)=>i(new e(t,...H1(l(n)))):(n=U(n),a=(...r)=>i(new e(t,...H1(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a},S1=function(e,...t){return U(new e(...H1(t)))};var C1=class extends Q${constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace(`once`):`once`;if(r[i])return r[i];let a=null;if(t.layout){let r=_1.get(e.constructor);r===void 0&&(r=new WeakMap,_1.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=U(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i),a=U(i.call(n))}else{let r=t.jsFunc,i=n!==null||r.length>1?r(n||[],e):r(e);a=U(i)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(r===`setup`){let t=e.getNamespace(`initialized`);i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return n}},w1=class extends Q${constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return V1(e),U(new C1(this,e))}setup(){return this.call()}};const T1=[!1,!0],E1=[0,1,2,3],D1=[-1,-2],O1=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],k1=new Map;for(let e of T1)k1.set(e,new l1(e));const A1=new Map;for(let e of E1)A1.set(e,new l1(e,`uint`));const j1=new Map([...A1].map(e=>new l1(e.value,`int`)));for(let e of D1)j1.set(e,new l1(e,`int`));const M1=new Map([...j1].map(e=>new l1(e.value)));for(let e of O1)M1.set(e,new l1(e));for(let e of O1)M1.set(-e,new l1(-e));const N1={bool:k1,uint:A1,ints:j1,float:M1},P1=new Map([...k1,...M1]),F1=(e,t)=>P1.has(e)?P1.get(e):e.isNode===!0?e:new l1(e,t),I1=e=>{try{return e.getNodeType()}catch{return}},L1=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[R$(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return U(t.get(n[0]));if(n.length===1){let t=F1(n[0],e);return I1(t)===e?U(t):U(new e1(t,e))}let r=n.map(e=>F1(e));return U(new n1(r,e))}},R1=e=>typeof e==`object`&&e?e.value:e,z1=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function B1(e,t){return new Proxy(new w1(e,t),h1)}const U=(e,t=null)=>v1(e,t),V1=(e,t=null)=>new y1(e,t),H1=(e,t=null)=>new b1(e,t),W=(...e)=>new x1(...e),G=(...e)=>new S1(...e);let U1=0;const K=(e,t=null)=>{let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:console.error(`THREE.TSL: Invalid layout type.`),t=null));let r=new B1(e,n),i=(...e)=>{let t;V1(e);let i=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype);t=i?[...e]:e[0];let a=r.call(t);return n===`void`&&a.toStack(),a};if(i.shaderNode=r,i.id=r.id,i.getNodeType=(...e)=>r.getNodeType(...e),i.getCacheKey=(...e)=>r.getCacheKey(...e),i.setLayout=e=>(r.setLayout(e),i),i.once=(e=null)=>(r.once=!0,r.namespace=e,i),t!==null){if(typeof t.inputs!=`object`){let e={name:`fn`+ U1++,type:n,inputs:[]};for(let n in t){if(n===`return`)continue;e.inputs.push({name:n,type:t[n]})}t=e}i.setLayout(t)}return i},W1=e=>{d1=e},G1=()=>d1,K1=(...e)=>d1.If(...e),q1=(...e)=>d1.Switch(...e);function J1(e){return d1&&d1.add(e),e}H(`toStack`,J1);const Y1=new L1(`color`),q=new L1(`float`,N1.float),J=new L1(`int`,N1.ints),X1=new L1(`uint`,N1.uint),Z1=new L1(`bool`,N1.bool),Y=new L1(`vec2`),Q1=new L1(`ivec2`),$1=new L1(`uvec2`),e0=new L1(`bvec2`),X=new L1(`vec3`),t0=new L1(`ivec3`),n0=new L1(`uvec3`),r0=new L1(`bvec3`),i0=new L1(`vec4`),a0=new L1(`ivec4`),o0=new L1(`uvec4`),s0=new L1(`bvec4`),c0=new L1(`mat2`),l0=new L1(`mat3`),u0=new L1(`mat4`),d0=(e=``)=>U(new l1(e,`string`)),f0=e=>U(new l1(e,`ArrayBuffer`));H(`toColor`,Y1),H(`toFloat`,q),H(`toInt`,J),H(`toUint`,X1),H(`toBool`,Z1),H(`toVec2`,Y),H(`toIVec2`,Q1),H(`toUVec2`,$1),H(`toBVec2`,e0),H(`toVec3`,X),H(`toIVec3`,t0),H(`toUVec3`,n0),H(`toBVec3`,r0),H(`toVec4`,i0),H(`toIVec4`,a0),H(`toUVec4`,o0),H(`toBVec4`,s0),H(`toMat2`,c0),H(`toMat3`,l0),H(`toMat4`,u0);const p0=W($$).setParameterLength(2),m0=(e,t)=>U(new e1(U(e),t)),h0=(e,t)=>U(new i1(U(e),t));H(`element`,p0),H(`convert`,m0);const g0=e=>(console.warn(`THREE.TSL: append() has been renamed to Stack().`),J1(e));H(`append`,e=>(console.warn(`THREE.TSL: .append() has been renamed to .toStack().`),J1(e)));const _0=(...e)=>(console.warn(`THREE.TSL: tslFn() has been renamed to Fn().`),K(...e));var v0=class extends Q${static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}};const y0=(e,t)=>U(new v0(e,t)),b0=(e,t)=>U(new v0(e,t,!0)),x0=G(v0,`vec4`,`DiffuseColor`),S0=G(v0,`vec3`,`EmissiveColor`),C0=G(v0,`float`,`Roughness`),w0=G(v0,`float`,`Metalness`),T0=G(v0,`float`,`Clearcoat`),E0=G(v0,`float`,`ClearcoatRoughness`),D0=G(v0,`vec3`,`Sheen`),O0=G(v0,`float`,`SheenRoughness`),k0=G(v0,`float`,`Iridescence`),A0=G(v0,`float`,`IridescenceIOR`),j0=G(v0,`float`,`IridescenceThickness`),M0=G(v0,`float`,`AlphaT`),N0=G(v0,`float`,`Anisotropy`),P0=G(v0,`vec3`,`AnisotropyT`),F0=G(v0,`vec3`,`AnisotropyB`),I0=G(v0,`color`,`SpecularColor`),L0=G(v0,`float`,`SpecularF90`),R0=G(v0,`float`,`Shininess`),z0=G(v0,`vec4`,`Output`),B0=G(v0,`float`,`dashSize`),V0=G(v0,`float`,`gapSize`),H0=G(v0,`float`,`pointWidth`),U0=G(v0,`float`,`IOR`),W0=G(v0,`float`,`Transmission`),G0=G(v0,`float`,`Thickness`),K0=G(v0,`float`,`AttenuationDistance`),q0=G(v0,`color`,`AttenuationColor`),J0=G(v0,`float`,`Dispersion`);var Y0=class extends Q${static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}};const X0=e=>new Y0(e),Z0=(e,t=0)=>new Y0(e,!0,t),Q0=Z0(`frame`),$0=Z0(`render`),e2=X0(`object`);var t2=class extends s1{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=e2}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){let n=this.getSelf();return e=e.bind(n),super.onUpdate(t=>{let r=e(t,n);r!==void 0&&(this.value=r)},t)}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),s=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(s,n,t)}};const n2=(e,t)=>{let n=z1(t||e),r=e&&e.isNode===!0?e.node&&e.node.value||e.value:e;return U(new t2(r,n))};var r2=class extends t1{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}};const i2=(...e)=>{let t;if(e.length===1){let n=e[0];t=new r2(null,n.length,n)}else{let n=e[0],r=e[1];t=new r2(n,r)}return U(t)};H(`toArray`,(e,t)=>i2(Array(t).fill(e)));var a2=class extends t1{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e)),r=Y$.join(``).slice(0,n)!==t.components;return r}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),o=n.build(e),s=r.build(e,a),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=o);else if(i){let r=e.getVarFromNode(this,null,a),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}),d=l.build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${d}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=o)}else u=`${o} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=o));return l.initialized=!0,e.format(u,a,t)}};const o2=W(a2).setParameterLength(2);H(`assign`,o2);var s2=class extends t1{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)console.error(`THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(console.error(`THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(q(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(console.error(`THREE.TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(q(0),e))):t.push(a(n,e))}let o=n.build(e,`property`);return`${o}( ${t.join(`, `)} )`}};const c2=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?H1(t):V1(t[0]),U(new s2(U(e),t)));H(`call`,c2);const l2={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var u2=class e extends t1{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(l2[this.op],t)}getNodeType(e){let t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i===`void`||a===`void`)return`void`;if(t===`%`)return i;if(t===`~`||t===`&`||t===`|`||t===`^`||t===`>>`||t===`<<`)return e.getIntegerType(i);if(t===`!`||t===`&&`||t===`||`||t===`^^`)return`bool`;if(t===`==`||t===`!=`||t===`<`||t===`>`||t===`<=`||t===`>=`){let t=Math.max(e.getTypeLength(i),e.getTypeLength(a));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(i)){if(a===`float`)return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i===`float`)return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===eY;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const d2=W(u2,`+`).setParameterLength(2,1/0).setName(`add`),f2=W(u2,`-`).setParameterLength(2,1/0).setName(`sub`),p2=W(u2,`*`).setParameterLength(2,1/0).setName(`mul`),m2=W(u2,`/`).setParameterLength(2,1/0).setName(`div`),h2=W(u2,`%`).setParameterLength(2).setName(`mod`),g2=W(u2,`==`).setParameterLength(2).setName(`equal`),_2=W(u2,`!=`).setParameterLength(2).setName(`notEqual`),v2=W(u2,`<`).setParameterLength(2).setName(`lessThan`),y2=W(u2,`>`).setParameterLength(2).setName(`greaterThan`),b2=W(u2,`<=`).setParameterLength(2).setName(`lessThanEqual`),x2=W(u2,`>=`).setParameterLength(2).setName(`greaterThanEqual`),S2=W(u2,`&&`).setParameterLength(2,1/0).setName(`and`),C2=W(u2,`||`).setParameterLength(2,1/0).setName(`or`),w2=W(u2,`!`).setParameterLength(1).setName(`not`),T2=W(u2,`^^`).setParameterLength(2).setName(`xor`),E2=W(u2,`&`).setParameterLength(2).setName(`bitAnd`),D2=W(u2,`~`).setParameterLength(2).setName(`bitNot`),O2=W(u2,`|`).setParameterLength(2).setName(`bitOr`),k2=W(u2,`^`).setParameterLength(2).setName(`bitXor`),A2=W(u2,`<<`).setParameterLength(2).setName(`shiftLeft`),j2=W(u2,`>>`).setParameterLength(2).setName(`shiftRight`),M2=K(([e])=>(e.addAssign(1),e)),N2=K(([e])=>(e.subAssign(1),e)),P2=K(([e])=>{let t=J(e).toConst();return e.addAssign(1),t}),F2=K(([e])=>{let t=J(e).toConst();return e.subAssign(1),t});H(`add`,d2),H(`sub`,f2),H(`mul`,p2),H(`div`,m2),H(`mod`,h2),H(`equal`,g2),H(`notEqual`,_2),H(`lessThan`,v2),H(`greaterThan`,y2),H(`lessThanEqual`,b2),H(`greaterThanEqual`,x2),H(`and`,S2),H(`or`,C2),H(`not`,w2),H(`xor`,T2),H(`bitAnd`,E2),H(`bitNot`,D2),H(`bitOr`,O2),H(`bitXor`,k2),H(`shiftLeft`,A2),H(`shiftRight`,j2),H(`incrementBefore`,M2),H(`decrementBefore`,N2),H(`increment`,P2),H(`decrement`,F2);const I2=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),h2(e,t)),L2=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),h2(J(e),J(t)));H(`remainder`,I2),H(`modInt`,L2);var Z=class e extends t1{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=f2(1,n);else if(i===e.RECIPROCAL)a=m2(1,n);else if(i===e.DIFFERENCE)a=c4(f2(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=i0(X(i),0):e=i0(X(e),0);let o=p2(e,i).xyz;a=e4(o)}return a===null?super.setup(t):a}generate(t,n){let r=t.getNodeProperties(this);if(r.outputNode)return super.generate(t,n);let i=this.method,a=this.getNodeType(t),o=this.getInputType(t),s=this.aNode,c=this.bNode,l=this.cNode,u=t.renderer.coordinateSystem;if(i===e.NEGATE)return t.format(`( - `+s.build(t,o)+` )`,a,n);{let r=[];return i===e.CROSS?r.push(s.build(t,a),c.build(t,a)):u===eY&&i===e.STEP?r.push(s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:o),c.build(t,o)):u===eY&&(i===e.MIN||i===e.MAX)?r.push(s.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:o)):i===e.REFRACT?r.push(s.build(t,o),c.build(t,o),l.build(t,`float`)):i===e.MIX?r.push(s.build(t,o),c.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?`float`:o)):(u===tY&&i===e.ATAN&&c!==null&&(i=`atan2`),t.shaderStage!==`fragment`&&(i===e.DFDX||i===e.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i=`/*`+i+`*/`),r.push(s.build(t,o)),c!==null&&r.push(c.build(t,o)),l!==null&&r.push(l.build(t,o))),t.format(`${t.getMethod(i,a)}( ${r.join(`, `)} )`,a,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};Z.ALL=`all`,Z.ANY=`any`,Z.RADIANS=`radians`,Z.DEGREES=`degrees`,Z.EXP=`exp`,Z.EXP2=`exp2`,Z.LOG=`log`,Z.LOG2=`log2`,Z.SQRT=`sqrt`,Z.INVERSE_SQRT=`inversesqrt`,Z.FLOOR=`floor`,Z.CEIL=`ceil`,Z.NORMALIZE=`normalize`,Z.FRACT=`fract`,Z.SIN=`sin`,Z.COS=`cos`,Z.TAN=`tan`,Z.ASIN=`asin`,Z.ACOS=`acos`,Z.ATAN=`atan`,Z.ABS=`abs`,Z.SIGN=`sign`,Z.LENGTH=`length`,Z.NEGATE=`negate`,Z.ONE_MINUS=`oneMinus`,Z.DFDX=`dFdx`,Z.DFDY=`dFdy`,Z.ROUND=`round`,Z.RECIPROCAL=`reciprocal`,Z.TRUNC=`trunc`,Z.FWIDTH=`fwidth`,Z.TRANSPOSE=`transpose`,Z.BITCAST=`bitcast`,Z.EQUALS=`equals`,Z.MIN=`min`,Z.MAX=`max`,Z.STEP=`step`,Z.REFLECT=`reflect`,Z.DISTANCE=`distance`,Z.DIFFERENCE=`difference`,Z.DOT=`dot`,Z.CROSS=`cross`,Z.POW=`pow`,Z.TRANSFORM_DIRECTION=`transformDirection`,Z.MIX=`mix`,Z.CLAMP=`clamp`,Z.REFRACT=`refract`,Z.SMOOTHSTEP=`smoothstep`,Z.FACEFORWARD=`faceforward`;const R2=q(1e-6),z2=q(1e6),B2=q(Math.PI),V2=q(Math.PI*2),H2=W(Z,Z.ALL).setParameterLength(1),U2=W(Z,Z.ANY).setParameterLength(1),W2=W(Z,Z.RADIANS).setParameterLength(1),G2=W(Z,Z.DEGREES).setParameterLength(1),K2=W(Z,Z.EXP).setParameterLength(1),q2=W(Z,Z.EXP2).setParameterLength(1),J2=W(Z,Z.LOG).setParameterLength(1),Y2=W(Z,Z.LOG2).setParameterLength(1),X2=W(Z,Z.SQRT).setParameterLength(1),Z2=W(Z,Z.INVERSE_SQRT).setParameterLength(1),Q2=W(Z,Z.FLOOR).setParameterLength(1),$2=W(Z,Z.CEIL).setParameterLength(1),e4=W(Z,Z.NORMALIZE).setParameterLength(1),t4=W(Z,Z.FRACT).setParameterLength(1),n4=W(Z,Z.SIN).setParameterLength(1),r4=W(Z,Z.COS).setParameterLength(1),i4=W(Z,Z.TAN).setParameterLength(1),a4=W(Z,Z.ASIN).setParameterLength(1),o4=W(Z,Z.ACOS).setParameterLength(1),s4=W(Z,Z.ATAN).setParameterLength(1,2),c4=W(Z,Z.ABS).setParameterLength(1),l4=W(Z,Z.SIGN).setParameterLength(1),u4=W(Z,Z.LENGTH).setParameterLength(1),d4=W(Z,Z.NEGATE).setParameterLength(1),f4=W(Z,Z.ONE_MINUS).setParameterLength(1),p4=W(Z,Z.DFDX).setParameterLength(1),m4=W(Z,Z.DFDY).setParameterLength(1),h4=W(Z,Z.ROUND).setParameterLength(1),g4=W(Z,Z.RECIPROCAL).setParameterLength(1),_4=W(Z,Z.TRUNC).setParameterLength(1),v4=W(Z,Z.FWIDTH).setParameterLength(1),y4=W(Z,Z.TRANSPOSE).setParameterLength(1),b4=W(Z,Z.BITCAST).setParameterLength(2),x4=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),g2(e,t)),S4=W(Z,Z.MIN).setParameterLength(2,1/0),C4=W(Z,Z.MAX).setParameterLength(2,1/0),w4=W(Z,Z.STEP).setParameterLength(2),T4=W(Z,Z.REFLECT).setParameterLength(2),E4=W(Z,Z.DISTANCE).setParameterLength(2),D4=W(Z,Z.DIFFERENCE).setParameterLength(2),O4=W(Z,Z.DOT).setParameterLength(2),k4=W(Z,Z.CROSS).setParameterLength(2),A4=W(Z,Z.POW).setParameterLength(2),j4=W(Z,Z.POW,2).setParameterLength(1),M4=W(Z,Z.POW,3).setParameterLength(1),N4=W(Z,Z.POW,4).setParameterLength(1),P4=W(Z,Z.TRANSFORM_DIRECTION).setParameterLength(2),F4=e=>p2(l4(e),A4(c4(e),1/3)),I4=e=>O4(e,e),L4=W(Z,Z.MIX).setParameterLength(3),R4=(e,t=0,n=1)=>U(new Z(Z.CLAMP,U(e),U(t),U(n))),z4=e=>R4(e),B4=W(Z,Z.REFRACT).setParameterLength(3),V4=W(Z,Z.SMOOTHSTEP).setParameterLength(3),H4=W(Z,Z.FACEFORWARD).setParameterLength(3),U4=K(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=O4(e.xy,Y(t,n)),a=h2(i,B2);return t4(n4(a).mul(r))}),W4=(e,t,n)=>L4(t,n,e),G4=(e,t,n)=>V4(t,n,e),K4=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),s4(e,t)),q4=H4,J4=Z2;H(`all`,H2),H(`any`,U2),H(`equals`,x4),H(`radians`,W2),H(`degrees`,G2),H(`exp`,K2),H(`exp2`,q2),H(`log`,J2),H(`log2`,Y2),H(`sqrt`,X2),H(`inverseSqrt`,Z2),H(`floor`,Q2),H(`ceil`,$2),H(`normalize`,e4),H(`fract`,t4),H(`sin`,n4),H(`cos`,r4),H(`tan`,i4),H(`asin`,a4),H(`acos`,o4),H(`atan`,s4),H(`abs`,c4),H(`sign`,l4),H(`length`,u4),H(`lengthSq`,I4),H(`negate`,d4),H(`oneMinus`,f4),H(`dFdx`,p4),H(`dFdy`,m4),H(`round`,h4),H(`reciprocal`,g4),H(`trunc`,_4),H(`fwidth`,v4),H(`atan2`,K4),H(`min`,S4),H(`max`,C4),H(`step`,w4),H(`reflect`,T4),H(`distance`,E4),H(`dot`,O4),H(`cross`,k4),H(`pow`,A4),H(`pow2`,j4),H(`pow3`,M4),H(`pow4`,N4),H(`transformDirection`,P4),H(`mix`,W4),H(`clamp`,R4),H(`refract`,B4),H(`smoothstep`,G4),H(`faceForward`,H4),H(`difference`,D4),H(`saturate`,z4),H(`cbrt`,F4),H(`transpose`,y4),H(`rand`,U4);var Y4=class extends Q${static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?y0(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
411
411
 
412
412
  `+e.tab+`}`),o!==null){e.addFlowCode(` else {
413
413
 
@@ -417,20 +417,20 @@ var<${n}> ${e} : ${a};`}},cj=class{constructor(e){this.backend=e}getCurrentDepth
417
417
 
418
418
  `)}else e.addFlowCode(`
419
419
 
420
- `);return e.format(l,n,t)}};const X4=W(Y4).setParameterLength(2,3);H(`select`,X4);const Z4=(...e)=>(console.warn(`THREE.TSL: cond() has been renamed to select().`),X4(...e));H(`cond`,Z4);var Q4=class extends Q${static get type(){return`ContextNode`}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){let n=e.getContext();e.setContext({...e.context,...this.value});let r=this.node.build(e,t);return e.setContext(n),r}};const $4=W(Q4).setParameterLength(1,2),e3=(e,t)=>$4(e,{label:t});H(`context`,$4),H(`label`,e3);var moe=class extends Q${static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=e.getVectorType(this.getNodeType(e)),l=t.build(e,c),u=e.getVarFromNode(this,n,c,void 0,s),d=e.getPropertyName(u),f=d;if(s)if(a)f=o?`const ${d}`:`let ${d}`;else{let n=e.getArrayCount(t);f=`const ${e.getVar(u.type,d,n)}`}return e.addLineFlowCode(`${f} = ${l}`,this),d}};const t3=W(moe),n3=(e,t=null)=>t3(e,t).toStack(),r3=(e,t=null)=>t3(e,t,!0).toStack();H(`toVar`,n3),H(`toConst`,r3);const i3=e=>(console.warn(`TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.`),t3(e));H(`temp`,i3);var hoe=class extends Q${static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),n=t.varying;if(n===void 0){let r=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,i,a,o),t.node=this.node}return n.needsInterpolation||=e.shaderStage===`fragment`,n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(H$.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(H$.VERTEX,this.node)}generate(e){let t=e.getNodeProperties(this),n=this.setupVarying(e);if(t.propertyName===void 0){let r=this.getNodeType(e),i=e.getPropertyName(n,H$.VERTEX);e.flowNodeFromShaderStage(H$.VERTEX,this.node,r,i),t.propertyName=i}return e.getPropertyName(n)}};const a3=W(hoe).setParameterLength(1,2),o3=e=>a3(e);H(`toVarying`,a3),H(`toVertexStage`,o3),H(`varying`,(...e)=>(console.warn(`THREE.TSL: .varying() has been renamed to .toVarying().`),a3(...e))),H(`vertexStage`,(...e)=>(console.warn(`THREE.TSL: .vertexStage() has been renamed to .toVertexStage().`),a3(...e)));const s3=K(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),r=e.lessThanEqual(.04045),i=L4(t,n,r);return i}).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),c3=K(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),r=e.lessThanEqual(.0031308),i=L4(t,n,r);return i}).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),l3=`WorkingColorSpace`,goe=`OutputColorSpace`;var u3=class extends t1{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===l3?mX.workingColorSpace:t===goe?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return mX.enabled===!1||n===r||!n||!r?i:(mX.getTransfer(n)===fY&&(i=i0(s3(i.rgb),i.a)),mX.getPrimaries(n)!==mX.getPrimaries(r)&&(i=i0(l0(mX._getMatrix(new aX,n,r)).mul(i.rgb),i.a)),mX.getTransfer(r)===fY&&(i=i0(c3(i.rgb),i.a)),i)}};const d3=(e,t)=>U(new u3(U(e),l3,t)),f3=(e,t)=>U(new u3(U(e),t,l3)),_oe=(e,t,n)=>U(new u3(U(e),t,n));H(`workingToColorSpace`,d3),H(`colorSpaceToWorking`,f3);let voe=class extends $${static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};var yoe=class extends Q${static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=U$.OBJECT}setGroup(e){return this.group=e,this}element(e){return U(new voe(this,U(e)))}setNodeType(e){let t=n2(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},boe=class extends yoe{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup($0)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}};const p3=(e,t,n=null)=>U(new boe(e,t,n));var xoe=class extends t1{static get type(){return`ToneMappingNode`}constructor(e,t=h3,n=null){super(`vec3`),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return D$(this.toneMapping)}setup(e){let t=this.colorNode||e.context.color,n=this.toneMapping;if(n===NJ)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(console.error(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=i0(i(t.rgb,this.exposureNode),t.a),r}};const m3=(e,t,n)=>U(new xoe(e,U(t),U(n))),h3=p3(`toneMappingExposure`,`float`);H(`toneMapping`,(e,t,n)=>m3(t,n,e));var Soe=class extends s1{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=CY,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),i=this.bufferStride||r,a=this.bufferOffset,o=n.isInterleavedBuffer===!0?n:new PQ(n,i),s=new IQ(o,r,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=r,i=r;else{let n=a3(this);i=n.build(e,t)}return i}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};const g3=(e,t=null,n=0,r=0)=>U(new Soe(e,t,n,r)),_3=(e,t=null,n=0,r=0)=>g3(e,t,n,r).setUsage(wY),v3=(e,t=null,n=0,r=0)=>g3(e,t,n,r).setInstanced(!0),y3=(e,t=null,n=0,r=0)=>_3(e,t,n,r).setInstanced(!0);H(`toAttribute`,e=>g3(e.value));var Coe=class extends Q${static get type(){return`ComputeNode`}constructor(e,t,n=[64]){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name=``,this.updateBeforeType=U$.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:`dispose`})}label(e){return this.name=e,this}updateDispatchCount(){let{count:e,workgroupSize:t}=this,n=t[0];for(let e=1;e<t.length;e++)n*=t[e];this.dispatchCount=Math.ceil(e/n)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}else{let n=e.getNodeProperties(this),r=n.outputComputeNode;if(r)return r.build(e,t)}}};const b3=(e,t,n)=>U(new Coe(U(e),t,n));H(`compute`,b3);var woe=class extends Q${static get type(){return`CacheNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}};const x3=(e,t)=>U(new woe(U(e),t)),S3=(e,t)=>e.context({namespace:t});H(`cache`,x3);var Toe=class extends Q${static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}};const C3=W(Toe).setParameterLength(2);H(`bypass`,C3);var w3=class extends Q${static get type(){return`RemapNode`}constructor(e,t,n,r=q(0),i=q(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}};const T3=W(w3,null,null,{doClamp:!1}).setParameterLength(3,5),E3=W(w3).setParameterLength(3,5);H(`remap`,T3),H(`remapClamp`,E3);var Eoe=class extends Q${static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}};const D3=W(Eoe).setParameterLength(1,2),O3=e=>(e?X4(e,D3(`discard`)):D3(`discard`)).toStack(),Doe=()=>D3(`return`).toStack();H(`discard`,O3);var Ooe=class extends t1{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color,n=(this.toneMapping===null?e.toneMapping:this.toneMapping)||NJ,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||cY;return n!==NJ&&(t=t.toneMapping(n)),r!==cY&&r!==mX.workingColorSpace&&(t=t.workingToColorSpace(r)),t}};const k3=(e,t=null,n=null)=>U(new Ooe(U(e),t,n));H(`renderOutput`,k3);var koe=class extends t1{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e),r=`--- TSL debug - `+e.shaderStage+` shader ---`,i=`-`.repeat(r.length),a=``;return a+=`// #`+r+`#
420
+ `);return e.format(l,n,t)}};const X4=W(Y4).setParameterLength(2,3);H(`select`,X4);const Z4=(...e)=>(console.warn(`THREE.TSL: cond() has been renamed to select().`),X4(...e));H(`cond`,Z4);var Q4=class extends Q${static get type(){return`ContextNode`}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){let n=e.getContext();e.setContext({...e.context,...this.value});let r=this.node.build(e,t);return e.setContext(n),r}};const $4=W(Q4).setParameterLength(1,2),e3=(e,t)=>$4(e,{label:t});H(`context`,$4),H(`label`,e3);var hoe=class extends Q${static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=e.getVectorType(this.getNodeType(e)),l=t.build(e,c),u=e.getVarFromNode(this,n,c,void 0,s),d=e.getPropertyName(u),f=d;if(s)if(a)f=o?`const ${d}`:`let ${d}`;else{let n=e.getArrayCount(t);f=`const ${e.getVar(u.type,d,n)}`}return e.addLineFlowCode(`${f} = ${l}`,this),d}};const t3=W(hoe),n3=(e,t=null)=>t3(e,t).toStack(),r3=(e,t=null)=>t3(e,t,!0).toStack();H(`toVar`,n3),H(`toConst`,r3);const i3=e=>(console.warn(`TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.`),t3(e));H(`temp`,i3);var goe=class extends Q${static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),n=t.varying;if(n===void 0){let r=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,i,a,o),t.node=this.node}return n.needsInterpolation||=e.shaderStage===`fragment`,n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(H$.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(H$.VERTEX,this.node)}generate(e){let t=e.getNodeProperties(this),n=this.setupVarying(e);if(t.propertyName===void 0){let r=this.getNodeType(e),i=e.getPropertyName(n,H$.VERTEX);e.flowNodeFromShaderStage(H$.VERTEX,this.node,r,i),t.propertyName=i}return e.getPropertyName(n)}};const a3=W(goe).setParameterLength(1,2),o3=e=>a3(e);H(`toVarying`,a3),H(`toVertexStage`,o3),H(`varying`,(...e)=>(console.warn(`THREE.TSL: .varying() has been renamed to .toVarying().`),a3(...e))),H(`vertexStage`,(...e)=>(console.warn(`THREE.TSL: .vertexStage() has been renamed to .toVertexStage().`),a3(...e)));const s3=K(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),r=e.lessThanEqual(.04045),i=L4(t,n,r);return i}).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),c3=K(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),r=e.lessThanEqual(.0031308),i=L4(t,n,r);return i}).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),l3=`WorkingColorSpace`,_oe=`OutputColorSpace`;var u3=class extends t1{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===l3?UY.workingColorSpace:t===_oe?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return UY.enabled===!1||n===r||!n||!r?i:(UY.getTransfer(n)===VJ&&(i=i0(s3(i.rgb),i.a)),UY.getPrimaries(n)!==UY.getPrimaries(r)&&(i=i0(l0(UY._getMatrix(new PY,n,r)).mul(i.rgb),i.a)),UY.getTransfer(r)===VJ&&(i=i0(c3(i.rgb),i.a)),i)}};const d3=(e,t)=>U(new u3(U(e),l3,t)),f3=(e,t)=>U(new u3(U(e),t,l3)),voe=(e,t,n)=>U(new u3(U(e),t,n));H(`workingToColorSpace`,d3),H(`colorSpaceToWorking`,f3);let yoe=class extends $${static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};var boe=class extends Q${static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=U$.OBJECT}setGroup(e){return this.group=e,this}element(e){return U(new yoe(this,U(e)))}setNodeType(e){let t=n2(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},xoe=class extends boe{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup($0)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}};const p3=(e,t,n=null)=>U(new xoe(e,t,n));var Soe=class extends t1{static get type(){return`ToneMappingNode`}constructor(e,t=h3,n=null){super(`vec3`),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return D$(this.toneMapping)}setup(e){let t=this.colorNode||e.context.color,n=this.toneMapping;if(n===cJ)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(console.error(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=i0(i(t.rgb,this.exposureNode),t.a),r}};const m3=(e,t,n)=>U(new Soe(e,U(t),U(n))),h3=p3(`toneMappingExposure`,`float`);H(`toneMapping`,(e,t,n)=>m3(t,n,e));var Coe=class extends s1{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=QJ,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),i=this.bufferStride||r,a=this.bufferOffset,o=n.isInterleavedBuffer===!0?n:new lQ(n,i),s=new dQ(o,r,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=r,i=r;else{let n=a3(this);i=n.build(e,t)}return i}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};const g3=(e,t=null,n=0,r=0)=>U(new Coe(e,t,n,r)),_3=(e,t=null,n=0,r=0)=>g3(e,t,n,r).setUsage($J),v3=(e,t=null,n=0,r=0)=>g3(e,t,n,r).setInstanced(!0),y3=(e,t=null,n=0,r=0)=>_3(e,t,n,r).setInstanced(!0);H(`toAttribute`,e=>g3(e.value));var woe=class extends Q${static get type(){return`ComputeNode`}constructor(e,t,n=[64]){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name=``,this.updateBeforeType=U$.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:`dispose`})}label(e){return this.name=e,this}updateDispatchCount(){let{count:e,workgroupSize:t}=this,n=t[0];for(let e=1;e<t.length;e++)n*=t[e];this.dispatchCount=Math.ceil(e/n)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}else{let n=e.getNodeProperties(this),r=n.outputComputeNode;if(r)return r.build(e,t)}}};const b3=(e,t,n)=>U(new woe(U(e),t,n));H(`compute`,b3);var Toe=class extends Q${static get type(){return`CacheNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}};const x3=(e,t)=>U(new Toe(U(e),t)),S3=(e,t)=>e.context({namespace:t});H(`cache`,x3);var Eoe=class extends Q${static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}};const C3=W(Eoe).setParameterLength(2);H(`bypass`,C3);var w3=class extends Q${static get type(){return`RemapNode`}constructor(e,t,n,r=q(0),i=q(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}};const T3=W(w3,null,null,{doClamp:!1}).setParameterLength(3,5),E3=W(w3).setParameterLength(3,5);H(`remap`,T3),H(`remapClamp`,E3);var Doe=class extends Q${static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}};const D3=W(Doe).setParameterLength(1,2),O3=e=>(e?X4(e,D3(`discard`)):D3(`discard`)).toStack(),Ooe=()=>D3(`return`).toStack();H(`discard`,O3);var koe=class extends t1{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color,n=(this.toneMapping===null?e.toneMapping:this.toneMapping)||cJ,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||LJ;return n!==cJ&&(t=t.toneMapping(n)),r!==LJ&&r!==UY.workingColorSpace&&(t=t.workingToColorSpace(r)),t}};const k3=(e,t=null,n=null)=>U(new koe(U(e),t,n));H(`renderOutput`,k3);var Aoe=class extends t1{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e),r=`--- TSL debug - `+e.shaderStage+` shader ---`,i=`-`.repeat(r.length),a=``;return a+=`// #`+r+`#
421
421
  `,a+=e.flow.code.replace(/^\t/gm,``)+`
422
422
  `,a+=`/* ... */ `+n+` /* ... */
423
423
  `,a+=`// #`+i+`#
424
- `,t===null?console.log(a):t(e,a),n}};const A3=(e,t=null)=>U(new koe(U(e),t));H(`debug`,A3);function Aoe(e){console.warn(`THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add`,e)}var j3=class extends Q${static get type(){return`AttributeNode`}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){let n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){let r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t=`float`}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),n=this.getNodeType(e),r=e.hasGeometryAttribute(t);if(r===!0){let r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);if(e.shaderStage===`vertex`)return e.format(a.name,i,n);{let t=a3(this);return t.build(e,n)}}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}};const M3=(e,t=null)=>U(new j3(e,t)),N3=(e=0)=>M3(`uv`+(e>0?e:``),`vec2`);var joe=class extends Q${static get type(){return`TextureSizeNode`}constructor(e,t=null){super(`uvec2`),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let n=this.textureNode.build(e,`property`),r=this.levelNode===null?`0`:this.levelNode.build(e,`int`);return e.format(`${e.getMethod(`textureDimensions`)}( ${n}, ${r} )`,this.getNodeType(e),t)}};const P3=W(joe).setParameterLength(1,2);var Moe=class extends t2{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=U$.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){let{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}};const F3=W(Moe).setParameterLength(1),I3=new wX;var L3=class extends t2{static get type(){return`TextureNode`}constructor(e=I3,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=U$.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?`float`:this.value.type===qJ?`uvec4`:this.value.type===KJ?`ivec4`:`vec4`}getInputType(){return`texture`}getDefaultUV(){return N3(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=n2(this.value.matrix)),this._matrixUniform.mul(X(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?U$.OBJECT:U$.NONE,this}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(t=this.sampler?t.flipY():t.setY(J(P3(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.value;if(!n||n.isTexture!==!0)throw Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let r=this.uvNode;(r===null||e.context.forceUVContext===!0)&&e.context.getUV&&(r=e.context.getUV(this,e)),r||=this.getDefaultUV(),this.updateMatrix===!0&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);let i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?`vec2`:`ivec2`)}generateSnippet(e,t,n,r,i,a,o,s){let c=this.value,l;return l=r?e.generateTextureLevel(c,t,n,r,a):i?e.generateTextureBias(c,t,n,i,a):s?e.generateTextureGrad(c,t,n,s,a):o?e.generateTextureCompare(c,t,n,o,a):this.sampler===!1?e.generateTextureLoad(c,t,n,a):e.generateTexture(c,t,n,a),l}generate(e,t){let n=this.value,r=e.getNodeProperties(this),i=super.generate(e,`property`);if(/^sampler/.test(t))return i+`_sampler`;if(e.isReference(t))return i;{let a=e.getDataFromNode(this),o=a.propertyName;if(o===void 0){let{uvNode:t,levelNode:n,biasNode:s,compareNode:c,depthNode:l,gradNode:u}=r,d=this.generateUV(e,t),f=n?n.build(e,`float`):null,p=s?s.build(e,`float`):null,m=l?l.build(e,`int`):null,h=c?c.build(e,`float`):null,g=u?[u[0].build(e,`vec2`),u[1].build(e,`vec2`)]:null,_=e.getVarFromNode(this);o=e.getPropertyName(_);let v=this.generateSnippet(e,i,d,f,p,m,h,g);e.addLineFlowCode(`${o} = ${v}`,this),a.snippet=v,a.propertyName=o}let s=o,c=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(s=f3(D3(s,c),n.colorSpace).setup(e).build(e,c)),e.format(s,c,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn(`THREE.TextureNode: .uv() has been renamed. Use .sample() instead.`),this.sample(e)}sample(e){let t=this.clone();return t.uvNode=U(e),t.referenceNode=this.getSelf(),U(t)}blur(e){let t=this.clone();t.biasNode=U(e).mul(F3(t)),t.referenceNode=this.getSelf();let n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===VJ||n.magFilter===VJ)&&(console.warn(`THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.`),t.biasNode=null),U(t)}level(e){let t=this.clone();return t.levelNode=U(e),t.referenceNode=this.getSelf(),U(t)}size(e){return P3(this,e)}bias(e){let t=this.clone();return t.biasNode=U(e),t.referenceNode=this.getSelf(),U(t)}compare(e){let t=this.clone();return t.compareNode=U(e),t.referenceNode=this.getSelf(),U(t)}grad(e,t){let n=this.clone();return n.gradNode=[U(e),U(t)],n.referenceNode=this.getSelf(),U(n)}depth(e){let t=this.clone();return t.depthNode=U(e),t.referenceNode=this.getSelf(),U(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}};const Noe=W(L3).setParameterLength(1,4).setName(`texture`),R3=(e=I3,t=null,n=null,r=null)=>{let i;return e&&e.isTextureNode===!0?(i=U(e.clone()),i.referenceNode=e.getSelf(),t!==null&&(i.uvNode=U(t)),n!==null&&(i.levelNode=U(n)),r!==null&&(i.biasNode=U(r))):i=Noe(e,t,n,r),i},Poe=(e=I3)=>R3(e),z3=(...e)=>R3(...e).setSampler(!1),Foe=e=>(e.isNode===!0?e:R3(e)).convert(`sampler`),Ioe=e=>(e.isNode===!0?e:R3(e)).convert(`samplerComparison`);var B3=class extends t2{static get type(){return`BufferNode`}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return`buffer`}};const V3=(e,t,n)=>U(new B3(e,t,n));var Loe=class extends $${static get type(){return`UniformArrayElementNode`}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}},H3=class extends B3{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?L$(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=U$.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t=`vec4`;return e===`mat2`?t=`mat2`:/mat/.test(e)===!0?t=`mat4`:e.charAt(0)===`i`?t=`ivec4`:e.charAt(0)===`u`&&(t=`uvec4`),t}update(){let{array:e,value:t}=this,n=this.elementType;if(n===`float`||n===`int`||n===`uint`)for(let n=0;n<e.length;n++){let r=n*4;t[r]=e[n]}else if(n===`color`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.r,t[r+1]=i.g,t[r+2]=i.b||0}else if(n===`mat2`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+3]=i.elements[3]}else if(n===`mat3`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+4]=i.elements[3],t[r+5]=i.elements[4],t[r+6]=i.elements[5],t[r+8]=i.elements[6],t[r+9]=i.elements[7],t[r+10]=i.elements[8],t[r+15]=1}else if(n===`mat4`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];for(let e=0;e<i.elements.length;e++)t[r+e]=i.elements[e]}else for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z||0,t[r+3]=i.w||0}}setup(e){let t=this.array.length,n=this.elementType,r=Float32Array,i=this.paddedType,a=e.getTypeLength(i);return n.charAt(0)===`i`&&(r=Int32Array),n.charAt(0)===`u`&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=i,super.setup(e)}element(e){return U(new Loe(this,U(e)))}};const U3=(e,t)=>U(new H3(e,t)),Roe=(e,t)=>(console.warn(`THREE.TSL: uniforms() has been renamed to uniformArray().`),U(new H3(e,t)));var zoe=class extends Q${constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}};const W3=W(zoe).setParameterLength(1),G3=n2(0,`uint`).label(`u_cameraIndex`).setGroup(Z0(`cameraIndex`)).toVarying(`v_cameraIndex`),K3=n2(`float`).label(`cameraNear`).setGroup($0).onRenderUpdate(({camera:e})=>e.near),q3=n2(`float`).label(`cameraFar`).setGroup($0).onRenderUpdate(({camera:e})=>e.far),J3=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrix);let r=U3(n).setGroup($0).label(`cameraProjectionMatrices`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraProjectionMatrix`)}else t=n2(`mat4`).label(`cameraProjectionMatrix`).setGroup($0).onRenderUpdate(({camera:e})=>e.projectionMatrix);return t}).once()(),Boe=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrixInverse);let r=U3(n).setGroup($0).label(`cameraProjectionMatricesInverse`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraProjectionMatrixInverse`)}else t=n2(`mat4`).label(`cameraProjectionMatrixInverse`).setGroup($0).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse);return t}).once()(),Y3=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorldInverse);let r=U3(n).setGroup($0).label(`cameraViewMatrices`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraViewMatrix`)}else t=n2(`mat4`).label(`cameraViewMatrix`).setGroup($0).onRenderUpdate(({camera:e})=>e.matrixWorldInverse);return t}).once()(),Voe=n2(`mat4`).label(`cameraWorldMatrix`).setGroup($0).onRenderUpdate(({camera:e})=>e.matrixWorld),Hoe=n2(`mat3`).label(`cameraNormalMatrix`).setGroup($0).onRenderUpdate(({camera:e})=>e.normalMatrix),Uoe=n2(new V).label(`cameraPosition`).setGroup($0).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld)),X3=new KX;var Z3=class e extends Q${static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=U$.OBJECT,this.uniformNode=new t2(null)}getNodeType(){let t=this.scope;if(t===e.WORLD_MATRIX)return`mat4`;if(t===e.POSITION||t===e.VIEW_POSITION||t===e.DIRECTION||t===e.SCALE)return`vec3`;if(t===e.RADIUS)return`float`}update(t){let n=this.object3d,r=this.uniformNode,i=this.scope;if(i===e.WORLD_MATRIX)r.value=n.matrixWorld;else if(i===e.POSITION)r.value=r.value||new V,r.value.setFromMatrixPosition(n.matrixWorld);else if(i===e.SCALE)r.value=r.value||new V,r.value.setFromMatrixScale(n.matrixWorld);else if(i===e.DIRECTION)r.value=r.value||new V,n.getWorldDirection(r.value);else if(i===e.VIEW_POSITION){let e=t.camera;r.value=r.value||new V,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(e.matrixWorldInverse)}else if(i===e.RADIUS){let e=t.object.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),X3.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=X3.radius}}generate(t){let n=this.scope;return n===e.WORLD_MATRIX?this.uniformNode.nodeType=`mat4`:n===e.POSITION||n===e.VIEW_POSITION||n===e.DIRECTION||n===e.SCALE?this.uniformNode.nodeType=`vec3`:n===e.RADIUS&&(this.uniformNode.nodeType=`float`),this.uniformNode.build(t)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};Z3.WORLD_MATRIX=`worldMatrix`,Z3.POSITION=`position`,Z3.SCALE=`scale`,Z3.VIEW_POSITION=`viewPosition`,Z3.DIRECTION=`direction`,Z3.RADIUS=`radius`;const Woe=W(Z3,Z3.DIRECTION).setParameterLength(1),Goe=W(Z3,Z3.WORLD_MATRIX).setParameterLength(1),Q3=W(Z3,Z3.POSITION).setParameterLength(1),Koe=W(Z3,Z3.SCALE).setParameterLength(1),qoe=W(Z3,Z3.VIEW_POSITION).setParameterLength(1),Joe=W(Z3,Z3.RADIUS).setParameterLength(1);var $3=class extends Z3{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}};const Yoe=G($3,$3.DIRECTION),e6=G($3,$3.WORLD_MATRIX),Xoe=G($3,$3.POSITION),Zoe=G($3,$3.SCALE),Qoe=G($3,$3.VIEW_POSITION),$oe=G($3,$3.RADIUS),t6=n2(new aX).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),ese=n2(new tZ).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),n6=K(e=>e.renderer.overrideNodes.modelViewMatrix||r6).once()().toVar(`modelViewMatrix`),r6=Y3.mul(e6),tse=K(e=>(e.context.isHighPrecisionModelViewMatrix=!0,n2(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highpModelViewMatrix`),nse=K(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return n2(`mat3`).onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar(`highpModelNormalViewMatrix`),i6=M3(`position`,`vec3`),a6=i6.toVarying(`positionLocal`),o6=i6.toVarying(`positionPrevious`),s6=K(e=>e6.mul(a6).xyz.toVarying(e.getNamespace(`v_positionWorld`)),`vec3`).once(`POSITION`)(),c6=K(e=>{let t=a6.transformDirection(e6).toVarying(e.getNamespace(`v_positionWorldDirection`));return t.normalize().toVar(`positionWorldDirection`)},`vec3`).once(`POSITION`)(),l6=K(e=>e.context.setupPositionView().toVarying(e.getNamespace(`v_positionView`)),`vec3`).once(`POSITION`)(),u6=l6.negate().toVarying(`v_positionViewDirection`).normalize().toVar(`positionViewDirection`);var rse=class extends Q${static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){let{renderer:t,material:n}=e;return t.coordinateSystem===TY&&n.side===TJ?`false`:e.getFrontFacing()}};const d6=G(rse),f6=q(d6).mul(2).sub(1),p6=M3(`normal`,`vec3`),m6=K(e=>e.geometry.hasAttribute(`normal`)===!1?(console.warn(`THREE.TSL: Vertex attribute "normal" not found on geometry.`),X(0,1,0)):p6,`vec3`).once()().toVar(`normalLocal`),h6=l6.dFdx().cross(l6.dFdy()).normalize().toVar(`normalFlat`),g6=K(e=>{let t;return t=e.material.flatShading===!0?h6:a3(x6(m6),`v_normalView`).normalize(),t},`vec3`).once()().toVar(`normalView`),_6=K(e=>{let t=g6.transformDirection(Y3);return e.material.flatShading!==!0&&(t=a3(t,`v_normalWorld`)),t},`vec3`).once()().normalize().toVar(`normalWorld`),v6=K(e=>{let t=e.context.setupNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(f6)),t},`vec3`).once()().toVar(`transformedNormalView`),y6=v6.transformDirection(Y3).toVar(`transformedNormalWorld`),ise=K(e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(f6)),t},`vec3`).once()().toVar(`transformedClearcoatNormalView`),b6=K(([e,t=e6])=>{let n=l0(t),r=e.div(X(n[0].dot(n[0]),n[1].dot(n[1]),n[2].dot(n[2])));return n.mul(r).xyz}),x6=K(([e],t)=>{let n=t.renderer.overrideNodes.modelNormalViewMatrix;if(n!==null)return n.transformDirection(e);let r=t6.mul(e);return Y3.transformDirection(r)}),S6=new dZ,C6=new tZ,w6=n2(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),ase=n2(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),T6=n2(new tZ).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let n=t.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation;return n?(S6.copy(n),C6.makeRotationFromEuler(S6)):C6.identity(),C6}),E6=u6.negate().reflect(v6),D6=u6.negate().refract(v6,w6),O6=E6.transformDirection(Y3).toVar(`reflectVector`),k6=D6.transformDirection(Y3).toVar(`reflectVector`),A6=new NQ;var ose=class extends L3{static get type(){return`CubeTextureNode`}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return`cubeTexture`}getDefaultUV(){let e=this.value;return e.mapping===FJ?O6:e.mapping===IJ?k6:(console.error(`THREE.CubeTextureNode: Mapping "%s" not supported.`,e.mapping),X(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return(e.renderer.coordinateSystem===EY||!n.isRenderTargetTexture)&&(t=X(t.x.negate(),t.yz)),T6.mul(t)}generateUV(e,t){return t.build(e,`vec3`)}};const j6=W(ose).setParameterLength(1,4).setName(`cubeTexture`),M6=(e=A6,t=null,n=null,r=null)=>{let i;return e&&e.isCubeTextureNode===!0?(i=U(e.clone()),i.referenceNode=e.getSelf(),t!==null&&(i.uvNode=U(t)),n!==null&&(i.levelNode=U(n)),r!==null&&(i.biasNode=U(r))):i=j6(e,t,n,r),i},sse=(e=A6)=>j6(e);var cse=class extends $${static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},N6=class extends Q${static get type(){return`ReferenceNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=U$.OBJECT}element(e){return U(new cse(this,U(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=this.count===null?Array.isArray(this.getValueFromReference())?U3(null,e):e===`texture`?R3(null):e===`cubeTexture`?M6(null):n2(null,e):V3(null,e,this.count),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}};const P6=(e,t,n)=>U(new N6(e,t,n)),F6=(e,t,n,r)=>U(new N6(e,t,r,n));var lse=class extends N6{static get type(){return`MaterialReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}};const I6=(e,t,n=null)=>U(new lse(e,t,n)),L6=K(e=>(e.geometry.hasAttribute(`tangent`)===!1&&e.geometry.computeTangents(),M3(`tangent`,`vec4`)))(),R6=L6.xyz.toVar(`tangentLocal`),z6=n6.mul(i0(R6,0)).xyz.toVarying(`v_tangentView`).normalize().toVar(`tangentView`),B6=z6.transformDirection(Y3).toVarying(`v_tangentWorld`).normalize().toVar(`tangentWorld`),V6=z6.toVar(`transformedTangentView`),use=V6.transformDirection(Y3).normalize().toVar(`transformedTangentWorld`),H6=K(([e,t],n)=>{let r=e.mul(L6.w).xyz;return n.material.flatShading!==!0&&(r=a3(r,t)),r}).once(),dse=H6(p6.cross(L6),`v_bitangentGeometry`).normalize().toVar(`bitangentGeometry`),fse=H6(m6.cross(R6),`v_bitangentLocal`).normalize().toVar(`bitangentLocal`),U6=H6(g6.cross(z6),`v_bitangentView`).normalize().toVar(`bitangentView`),pse=H6(_6.cross(B6),`v_bitangentWorld`).normalize().toVar(`bitangentWorld`),W6=H6(v6.cross(V6),`v_transformedBitangentView`).normalize().toVar(`transformedBitangentView`),mse=W6.transformDirection(Y3).normalize().toVar(`transformedBitangentWorld`),G6=l0(z6,U6,g6),K6=u6.mul(G6),hse=(e,t)=>e.sub(K6.mul(t)),gse=(()=>{let e=F0.cross(u6);return e=e.cross(F0).normalize(),e=L4(e,v6,N0.mul(C0.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),_se=K(e=>{let{eye_pos:t,surf_norm:n,mapN:r,uv:i}=e,a=t.dFdx(),o=t.dFdy(),s=i.dFdx(),c=i.dFdy(),l=n,u=o.cross(l),d=l.cross(a),f=u.mul(s.x).add(d.mul(c.x)),p=u.mul(s.y).add(d.mul(c.y)),m=f.dot(f).max(p.dot(p)),h=f6.mul(m.inverseSqrt());return d2(f.mul(r.x,h),p.mul(r.y,h),l.mul(r.z)).normalize()});var vse=class extends t1{static get type(){return`NormalMapNode`}constructor(e,t=null){super(`vec3`),this.node=e,this.scaleNode=t,this.normalMapType=oY}setup(e){let{normalMapType:t,scaleNode:n}=this,r=this.node.mul(2).sub(1);n!==null&&(r=X(r.xy.mul(n),r.z));let i=null;if(t===sY)i=x6(r);else if(t===oY){let t=e.hasGeometryAttribute(`tangent`);i=t===!0?G6.mul(r).normalize():_se({eye_pos:l6,surf_norm:g6,mapN:r,uv:N3()})}return i}};const q6=W(vse).setParameterLength(1,2),yse=K(({textureNode:e,bumpScale:t})=>{let n=t=>e.cache().context({getUV:e=>t(e.uvNode||N3()),forceUVContext:!0}),r=q(n(e=>e));return Y(q(n(e=>e.add(e.dFdx()))).sub(r),q(n(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),bse=K(e=>{let{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),a=t.dFdy().normalize(),o=n,s=a.cross(o),c=o.cross(i),l=i.dot(s).mul(f6),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()});var xse=class extends t1{static get type(){return`BumpMapNode`}constructor(e,t=null){super(`vec3`),this.textureNode=e,this.scaleNode=t}setup(){let e=this.scaleNode===null?1:this.scaleNode,t=yse({textureNode:this.textureNode,bumpScale:e});return bse({surf_pos:l6,surf_norm:g6,dHdxy:t})}};const J6=W(xse).setParameterLength(1,2),Y6=new Map;var Q=class e extends Q${static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=Y6.get(e);return n===void 0&&(n=I6(e,t),Y6.set(e,n)),n}getFloat(e){return this.getCache(e,`float`)}getColor(e){return this.getCache(e,`color`)}getTexture(e){return this.getCache(e===`map`?`map`:e+`Map`,`texture`)}setup(t){let n=t.context.material,r=this.scope,i=null;if(r===e.COLOR){let e=n.color===void 0?X():this.getColor(r);i=n.map&&n.map.isTexture===!0?e.mul(this.getTexture(`map`)):e}else if(r===e.OPACITY){let e=this.getFloat(r);i=n.alphaMap&&n.alphaMap.isTexture===!0?e.mul(this.getTexture(`alpha`)):e}else if(r===e.SPECULAR_STRENGTH)i=n.specularMap&&n.specularMap.isTexture===!0?this.getTexture(`specular`).r:q(1);else if(r===e.SPECULAR_INTENSITY){let e=this.getFloat(r);i=n.specularIntensityMap&&n.specularIntensityMap.isTexture===!0?e.mul(this.getTexture(r).a):e}else if(r===e.SPECULAR_COLOR){let e=this.getColor(r);i=n.specularColorMap&&n.specularColorMap.isTexture===!0?e.mul(this.getTexture(r).rgb):e}else if(r===e.ROUGHNESS){let e=this.getFloat(r);i=n.roughnessMap&&n.roughnessMap.isTexture===!0?e.mul(this.getTexture(r).g):e}else if(r===e.METALNESS){let e=this.getFloat(r);i=n.metalnessMap&&n.metalnessMap.isTexture===!0?e.mul(this.getTexture(r).b):e}else if(r===e.EMISSIVE){let e=this.getFloat(`emissiveIntensity`),t=this.getColor(r).mul(e);i=n.emissiveMap&&n.emissiveMap.isTexture===!0?t.mul(this.getTexture(r)):t}else if(r===e.NORMAL)n.normalMap?(i=q6(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType):i=n.bumpMap?J6(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):g6;else if(r===e.CLEARCOAT){let e=this.getFloat(r);i=n.clearcoatMap&&n.clearcoatMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=n.clearcoatRoughnessMap&&n.clearcoatRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_NORMAL)i=n.clearcoatNormalMap?q6(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):g6;else if(r===e.SHEEN){let e=this.getColor(`sheenColor`).mul(this.getFloat(`sheen`));i=n.sheenColorMap&&n.sheenColorMap.isTexture===!0?e.mul(this.getTexture(`sheenColor`).rgb):e}else if(r===e.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=n.sheenRoughnessMap&&n.sheenRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).a):e,i=i.clamp(.07,1)}else if(r===e.ANISOTROPY)if(n.anisotropyMap&&n.anisotropyMap.isTexture===!0){let e=this.getTexture(r),t=c0(r8.x,r8.y,r8.y.negate(),r8.x);i=t.mul(e.rg.mul(2).sub(Y(1)).normalize().mul(e.b))}else i=r8;else if(r===e.IRIDESCENCE_THICKNESS){let e=P6(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=P6(`0`,`float`,n.iridescenceThicknessRange);i=e.sub(t).mul(this.getTexture(r).g).add(t)}else i=e}else if(r===e.TRANSMISSION){let e=this.getFloat(r);i=n.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===e.THICKNESS){let e=this.getFloat(r);i=n.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===e.IOR)i=this.getFloat(r);else if(r===e.LIGHT_MAP)i=this.getTexture(r).rgb.mul(this.getFloat(`lightMapIntensity`));else if(r===e.AO)i=this.getTexture(r).r.sub(1).mul(this.getFloat(`aoMapIntensity`)).add(1);else if(r===e.LINE_DASH_OFFSET)i=n.dashOffset?this.getFloat(r):q(0);else{let e=this.getNodeType(t);i=this.getCache(r,e)}return i}};Q.ALPHA_TEST=`alphaTest`,Q.COLOR=`color`,Q.OPACITY=`opacity`,Q.SHININESS=`shininess`,Q.SPECULAR=`specular`,Q.SPECULAR_STRENGTH=`specularStrength`,Q.SPECULAR_INTENSITY=`specularIntensity`,Q.SPECULAR_COLOR=`specularColor`,Q.REFLECTIVITY=`reflectivity`,Q.ROUGHNESS=`roughness`,Q.METALNESS=`metalness`,Q.NORMAL=`normal`,Q.CLEARCOAT=`clearcoat`,Q.CLEARCOAT_ROUGHNESS=`clearcoatRoughness`,Q.CLEARCOAT_NORMAL=`clearcoatNormal`,Q.EMISSIVE=`emissive`,Q.ROTATION=`rotation`,Q.SHEEN=`sheen`,Q.SHEEN_ROUGHNESS=`sheenRoughness`,Q.ANISOTROPY=`anisotropy`,Q.IRIDESCENCE=`iridescence`,Q.IRIDESCENCE_IOR=`iridescenceIOR`,Q.IRIDESCENCE_THICKNESS=`iridescenceThickness`,Q.IOR=`ior`,Q.TRANSMISSION=`transmission`,Q.THICKNESS=`thickness`,Q.ATTENUATION_DISTANCE=`attenuationDistance`,Q.ATTENUATION_COLOR=`attenuationColor`,Q.LINE_SCALE=`scale`,Q.LINE_DASH_SIZE=`dashSize`,Q.LINE_GAP_SIZE=`gapSize`,Q.LINE_WIDTH=`linewidth`,Q.LINE_DASH_OFFSET=`dashOffset`,Q.POINT_SIZE=`size`,Q.DISPERSION=`dispersion`,Q.LIGHT_MAP=`light`,Q.AO=`ao`;const X6=G(Q,Q.ALPHA_TEST),Z6=G(Q,Q.COLOR),Sse=G(Q,Q.SHININESS),Q6=G(Q,Q.EMISSIVE),$6=G(Q,Q.OPACITY),Cse=G(Q,Q.SPECULAR),wse=G(Q,Q.SPECULAR_INTENSITY),Tse=G(Q,Q.SPECULAR_COLOR),Ese=G(Q,Q.SPECULAR_STRENGTH),Dse=G(Q,Q.REFLECTIVITY),Ose=G(Q,Q.ROUGHNESS),kse=G(Q,Q.METALNESS),e8=G(Q,Q.NORMAL),Ase=G(Q,Q.CLEARCOAT),jse=G(Q,Q.CLEARCOAT_ROUGHNESS),Mse=G(Q,Q.CLEARCOAT_NORMAL),Nse=G(Q,Q.ROTATION),Pse=G(Q,Q.SHEEN),Fse=G(Q,Q.SHEEN_ROUGHNESS),Ise=G(Q,Q.ANISOTROPY),Lse=G(Q,Q.IRIDESCENCE),Rse=G(Q,Q.IRIDESCENCE_IOR),zse=G(Q,Q.IRIDESCENCE_THICKNESS),Bse=G(Q,Q.TRANSMISSION),Vse=G(Q,Q.THICKNESS),Hse=G(Q,Q.IOR),Use=G(Q,Q.ATTENUATION_DISTANCE),Wse=G(Q,Q.ATTENUATION_COLOR),Gse=G(Q,Q.LINE_SCALE),Kse=G(Q,Q.LINE_DASH_SIZE),qse=G(Q,Q.LINE_GAP_SIZE),Jse=G(Q,Q.LINE_WIDTH),Yse=G(Q,Q.LINE_DASH_OFFSET),Xse=G(Q,Q.POINT_SIZE),Zse=G(Q,Q.DISPERSION),t8=G(Q,Q.LIGHT_MAP),n8=G(Q,Q.AO),r8=n2(new tX).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),i8=K(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`);var a8=class e extends Q${static get type(){return`IndexNode`}constructor(e){super(`uint`),this.scope=e,this.isIndexNode=!0}generate(t){let n=this.getNodeType(t),r=this.scope,i;if(r===e.VERTEX)i=t.getVertexIndex();else if(r===e.INSTANCE)i=t.getInstanceIndex();else if(r===e.DRAW)i=t.getDrawIndex();else if(r===e.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(r===e.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(r===e.SUBGROUP)i=t.getSubgroupIndex();else throw Error(`THREE.IndexNode: Unknown scope: `+r);let a;if(t.shaderStage===`vertex`||t.shaderStage===`compute`)a=i;else{let e=a3(this);a=e.build(t,n)}return a}};a8.VERTEX=`vertex`,a8.INSTANCE=`instance`,a8.SUBGROUP=`subgroup`,a8.INVOCATION_LOCAL=`invocationLocal`,a8.INVOCATION_SUBGROUP=`invocationSubgroup`,a8.DRAW=`draw`;const o8=G(a8,a8.VERTEX),s8=G(a8,a8.INSTANCE),Qse=G(a8,a8.SUBGROUP),$se=G(a8,a8.INVOCATION_SUBGROUP),ece=G(a8,a8.INVOCATION_LOCAL),c8=G(a8,a8.DRAW);var l8=class extends Q${static get type(){return`InstanceNode`}constructor(e,t,n=null){super(`void`),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=U$.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let{count:t,instanceMatrix:n,instanceColor:r}=this,{instanceMatrixNode:i,instanceColorNode:a}=this;if(i===null){if(t<=1e3)i=V3(n.array,`mat4`,Math.max(t,1)).element(s8);else{let e=new b$(n.array,16,1);this.buffer=e;let t=n.usage===wY?y3:v3,r=[t(e,`vec4`,16,0),t(e,`vec4`,16,4),t(e,`vec4`,16,8),t(e,`vec4`,16,12)];i=u0(...r)}this.instanceMatrixNode=i}if(r&&a===null){let e=new LQ(r.array,3),t=r.usage===wY?y3:v3;this.bufferColor=e,a=X(t(e,`vec3`,3,0)),this.instanceColorNode=a}let o=i.mul(a6).xyz;if(a6.assign(o),e.hasGeometryAttribute(`normal`)){let e=b6(m6,i);m6.assign(e)}this.instanceColorNode!==null&&b0(`vec3`,`vInstanceColor`).assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==wY&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==wY&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}};const tce=W(l8).setParameterLength(2,3);var nce=class extends l8{static get type(){return`InstancedMeshNode`}constructor(e){let{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}};const u8=W(nce).setParameterLength(1);var rce=class extends Q${static get type(){return`BatchNode`}constructor(e){super(`void`),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=s8:this.batchingIdNode=c8);let t=K(([e])=>{let t=J(P3(z3(this.batchMesh._indirectTexture),0).x),n=J(e).mod(t),r=J(e).div(t);return z3(this.batchMesh._indirectTexture,Q1(n,r)).x}).setLayout({name:`getIndirectIndex`,type:`uint`,inputs:[{name:`id`,type:`int`}]}),n=t(J(this.batchingIdNode)),r=this.batchMesh._matricesTexture,i=J(P3(z3(r),0).x),a=q(n).mul(4).toInt().toVar(),o=a.mod(i),s=a.div(i),c=u0(z3(r,Q1(o,s)),z3(r,Q1(o.add(1),s)),z3(r,Q1(o.add(2),s)),z3(r,Q1(o.add(3),s))),l=this.batchMesh._colorsTexture;if(l!==null){let e=K(([e])=>{let t=J(P3(z3(l),0).x),n=e,r=n.mod(t),i=n.div(t);return z3(l,Q1(r,i)).rgb}).setLayout({name:`getBatchingColor`,type:`vec3`,inputs:[{name:`id`,type:`int`}]}),t=e(n);b0(`vec3`,`vBatchColor`).assign(t)}let u=l0(c);a6.assign(c.mul(a6));let d=m6.div(X(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),f=u.mul(d).xyz;m6.assign(f),e.hasGeometryAttribute(`tangent`)&&R6.mulAssign(u)}};const d8=W(rce).setParameterLength(1);var ice=class extends $${static get type(){return`StorageArrayElementNode`}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):`void`}setup(e){return e.isAvailable(`storageBuffer`)===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,r=e.context.assign;if(n=e.isAvailable(`storageBuffer`)===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!==`compute`)?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}};const ace=W(ice).setParameterLength(2);var oce=class extends B3{static get type(){return`StorageBufferNode`}constructor(e,t=null,n=0){let r,i=null;t&&t.isStruct?(r=`struct`,i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=M$(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=G$.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?`indirectStorageBuffer`:`storageBuffer`}element(e){return ace(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(G$.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=g3(this.value),this._varying=a3(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.getNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode===null?`void`:this.structTypeNode.getMemberType(e,t)}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generate(e);let{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}};const f8=(e,t=null,n=0)=>U(new oce(e,t,n)),sce=(e,t,n)=>(console.warn(`THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.`),f8(e,t,n).setPBO(!0)),p8=new WeakMap;var m8=class extends Q${static get type(){return`SkinningNode`}constructor(e){super(`void`),this.skinnedMesh=e,this.updateType=U$.OBJECT,this.skinIndexNode=M3(`skinIndex`,`uvec4`),this.skinWeightNode=M3(`skinWeight`,`vec4`),this.bindMatrixNode=P6(`bindMatrix`,`mat4`),this.bindMatrixInverseNode=P6(`bindMatrixInverse`,`mat4`),this.boneMatricesNode=F6(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length),this.positionNode=a6,this.toPositionNode=a6,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=i.mul(t),d=d2(o.mul(r.x).mul(u),s.mul(r.y).mul(u),c.mul(r.z).mul(u),l.mul(r.w).mul(u));return a.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=m6){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=d2(r.x.mul(o),r.y.mul(s),r.z.mul(c),r.w.mul(l));return u=a.mul(u).mul(i),u.transformDirection(t).xyz}getPreviousSkinnedPosition(e){let t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=F6(`skeleton.previousBoneMatrices`,`mat4`,t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,o6)}needsPreviousBoneMatrices(e){let t=e.renderer.getMRT();return t&&t.has(`velocity`)||z$(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&o6.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute(`normal`)){let t=this.getSkinnedNormal();m6.assign(t),e.hasGeometryAttribute(`tangent`)&&R6.assign(t)}return t}generate(e,t){if(t!==`void`)return super.generate(e,t)}update(e){let t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;p8.get(t)!==e.frameId&&(p8.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}};const h8=e=>U(new m8(e)),cce=(e,t=null)=>{let n=new m8(e);return n.positionNode=f8(new LQ(e.geometry.getAttribute(`position`).array,3),`vec3`).setPBO(!0).toReadOnly().element(s8).toVar(),n.skinIndexNode=f8(new LQ(new Uint32Array(e.geometry.getAttribute(`skinIndex`).array),4),`uvec4`).setPBO(!0).toReadOnly().element(s8).toVar(),n.skinWeightNode=f8(new LQ(e.geometry.getAttribute(`skinWeight`).array,4),`vec4`).setPBO(!0).toReadOnly().element(s8).toVar(),n.bindMatrixNode=n2(e.bindMatrix,`mat4`),n.bindMatrixInverseNode=n2(e.bindMatrixInverse,`mat4`),n.boneMatricesNode=V3(e.skeleton.boneMatrices,`mat4`,e.skeleton.bones.length),n.toPositionNode=t,U(n)};var lce=class extends Q${static get type(){return`LoopNode`}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let n={};for(let e=0,t=this.params.length-1;e<t;e++){let t=this.params[e],r=t.isNode!==!0&&t.name||this.getVarName(e),i=t.isNode!==!0&&t.type||`int`;n[r]=D3(r,i)}let r=e.addStack();t.returnsNode=this.params[this.params.length-1](n,e),t.stackNode=r;let i=this.params[0];return i.isNode!==!0&&typeof i.update==`function`&&(t.updateNode=K(this.params[0].update)(n)),e.removeStack(),t}getNodeType(e){let{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):`void`}setup(e){this.getProperties(e)}generate(e){let t=this.getProperties(e),n=this.params,r=t.stackNode;for(let r=0,i=n.length-1;r<i;r++){let i=n[r],a=!1,o=null,s=null,c=null,l=null,u=null,d=null;i.isNode?i.getNodeType(e)===`bool`?(a=!0,l=`bool`,s=i.build(e,l)):(l=`int`,c=this.getVarName(r),o=`0`,s=i.build(e,l),u=`<`):(l=i.type||`int`,c=i.name||this.getVarName(r),o=i.start,s=i.end,u=i.condition,d=i.update,typeof o==`number`?o=e.generateConst(l,o):o&&o.isNode&&(o=o.build(e,l)),typeof s==`number`?s=e.generateConst(l,s):s&&s.isNode&&(s=s.build(e,l)),o!==void 0&&s===void 0?(o+=` - 1`,s=`0`,u=`>=`):s!==void 0&&o===void 0&&(o=`0`,u=`<`),u===void 0&&(u=Number(o)>Number(s)?`>=`:`<`));let f;if(a)f=`while ( ${s} )`;else{let n={start:o,end:s},r=n.start,i=n.end,a,p=()=>u.includes(`<`)?`+=`:`-=`;if(d!=null)switch(typeof d){case`function`:let n=e.flowStagesNode(t.updateNode,`void`),r=n.code.replace(/\t|;/g,``);a=r;break;case`number`:a=c+` `+p()+` `+e.generateConst(l,d);break;case`string`:a=c+` `+d;break;default:d.isNode?a=c+` `+p()+` `+d.build(e):(console.error(`THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number.`),a=`break /* invalid update */`)}else d=l===`int`||l===`uint`?u.includes(`<`)?`++`:`--`:p()+` 1.`,a=c+` `+d;let m=e.getVar(l,c)+` = `+r,h=c+` `+u+` `+i;f=`for ( ${m}; ${h}; ${a} )`}e.addFlowCode((r===0?`
424
+ `,t===null?console.log(a):t(e,a),n}};const A3=(e,t=null)=>U(new Aoe(U(e),t));H(`debug`,A3);function joe(e){console.warn(`THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add`,e)}var j3=class extends Q${static get type(){return`AttributeNode`}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){let n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){let r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t=`float`}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),n=this.getNodeType(e),r=e.hasGeometryAttribute(t);if(r===!0){let r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);if(e.shaderStage===`vertex`)return e.format(a.name,i,n);{let t=a3(this);return t.build(e,n)}}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}};const M3=(e,t=null)=>U(new j3(e,t)),N3=(e=0)=>M3(`uv`+(e>0?e:``),`vec2`);var Moe=class extends Q${static get type(){return`TextureSizeNode`}constructor(e,t=null){super(`uvec2`),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let n=this.textureNode.build(e,`property`),r=this.levelNode===null?`0`:this.levelNode.build(e,`int`);return e.format(`${e.getMethod(`textureDimensions`)}( ${n}, ${r} )`,this.getNodeType(e),t)}};const P3=W(Moe).setParameterLength(1,2);var Noe=class extends t2{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=U$.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){let{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}};const F3=W(Noe).setParameterLength(1),I3=new $Y;var L3=class extends t2{static get type(){return`TextureNode`}constructor(e=I3,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=U$.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?`float`:this.value.type===SJ?`uvec4`:this.value.type===xJ?`ivec4`:`vec4`}getInputType(){return`texture`}getDefaultUV(){return N3(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=n2(this.value.matrix)),this._matrixUniform.mul(X(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?U$.OBJECT:U$.NONE,this}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(t=this.sampler?t.flipY():t.setY(J(P3(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.value;if(!n||n.isTexture!==!0)throw Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let r=this.uvNode;(r===null||e.context.forceUVContext===!0)&&e.context.getUV&&(r=e.context.getUV(this,e)),r||=this.getDefaultUV(),this.updateMatrix===!0&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);let i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?`vec2`:`ivec2`)}generateSnippet(e,t,n,r,i,a,o,s){let c=this.value,l;return l=r?e.generateTextureLevel(c,t,n,r,a):i?e.generateTextureBias(c,t,n,i,a):s?e.generateTextureGrad(c,t,n,s,a):o?e.generateTextureCompare(c,t,n,o,a):this.sampler===!1?e.generateTextureLoad(c,t,n,a):e.generateTexture(c,t,n,a),l}generate(e,t){let n=this.value,r=e.getNodeProperties(this),i=super.generate(e,`property`);if(/^sampler/.test(t))return i+`_sampler`;if(e.isReference(t))return i;{let a=e.getDataFromNode(this),o=a.propertyName;if(o===void 0){let{uvNode:t,levelNode:n,biasNode:s,compareNode:c,depthNode:l,gradNode:u}=r,d=this.generateUV(e,t),f=n?n.build(e,`float`):null,p=s?s.build(e,`float`):null,m=l?l.build(e,`int`):null,h=c?c.build(e,`float`):null,g=u?[u[0].build(e,`vec2`),u[1].build(e,`vec2`)]:null,_=e.getVarFromNode(this);o=e.getPropertyName(_);let v=this.generateSnippet(e,i,d,f,p,m,h,g);e.addLineFlowCode(`${o} = ${v}`,this),a.snippet=v,a.propertyName=o}let s=o,c=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(s=f3(D3(s,c),n.colorSpace).setup(e).build(e,c)),e.format(s,c,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn(`THREE.TextureNode: .uv() has been renamed. Use .sample() instead.`),this.sample(e)}sample(e){let t=this.clone();return t.uvNode=U(e),t.referenceNode=this.getSelf(),U(t)}blur(e){let t=this.clone();t.biasNode=U(e).mul(F3(t)),t.referenceNode=this.getSelf();let n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===gJ||n.magFilter===gJ)&&(console.warn(`THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.`),t.biasNode=null),U(t)}level(e){let t=this.clone();return t.levelNode=U(e),t.referenceNode=this.getSelf(),U(t)}size(e){return P3(this,e)}bias(e){let t=this.clone();return t.biasNode=U(e),t.referenceNode=this.getSelf(),U(t)}compare(e){let t=this.clone();return t.compareNode=U(e),t.referenceNode=this.getSelf(),U(t)}grad(e,t){let n=this.clone();return n.gradNode=[U(e),U(t)],n.referenceNode=this.getSelf(),U(n)}depth(e){let t=this.clone();return t.depthNode=U(e),t.referenceNode=this.getSelf(),U(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}};const Poe=W(L3).setParameterLength(1,4).setName(`texture`),R3=(e=I3,t=null,n=null,r=null)=>{let i;return e&&e.isTextureNode===!0?(i=U(e.clone()),i.referenceNode=e.getSelf(),t!==null&&(i.uvNode=U(t)),n!==null&&(i.levelNode=U(n)),r!==null&&(i.biasNode=U(r))):i=Poe(e,t,n,r),i},Foe=(e=I3)=>R3(e),z3=(...e)=>R3(...e).setSampler(!1),Ioe=e=>(e.isNode===!0?e:R3(e)).convert(`sampler`),Loe=e=>(e.isNode===!0?e:R3(e)).convert(`samplerComparison`);var B3=class extends t2{static get type(){return`BufferNode`}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return`buffer`}};const V3=(e,t,n)=>U(new B3(e,t,n));var Roe=class extends $${static get type(){return`UniformArrayElementNode`}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}},H3=class extends B3{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?L$(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=U$.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t=`vec4`;return e===`mat2`?t=`mat2`:/mat/.test(e)===!0?t=`mat4`:e.charAt(0)===`i`?t=`ivec4`:e.charAt(0)===`u`&&(t=`uvec4`),t}update(){let{array:e,value:t}=this,n=this.elementType;if(n===`float`||n===`int`||n===`uint`)for(let n=0;n<e.length;n++){let r=n*4;t[r]=e[n]}else if(n===`color`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.r,t[r+1]=i.g,t[r+2]=i.b||0}else if(n===`mat2`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+3]=i.elements[3]}else if(n===`mat3`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+4]=i.elements[3],t[r+5]=i.elements[4],t[r+6]=i.elements[5],t[r+8]=i.elements[6],t[r+9]=i.elements[7],t[r+10]=i.elements[8],t[r+15]=1}else if(n===`mat4`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];for(let e=0;e<i.elements.length;e++)t[r+e]=i.elements[e]}else for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z||0,t[r+3]=i.w||0}}setup(e){let t=this.array.length,n=this.elementType,r=Float32Array,i=this.paddedType,a=e.getTypeLength(i);return n.charAt(0)===`i`&&(r=Int32Array),n.charAt(0)===`u`&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=i,super.setup(e)}element(e){return U(new Roe(this,U(e)))}};const U3=(e,t)=>U(new H3(e,t)),zoe=(e,t)=>(console.warn(`THREE.TSL: uniforms() has been renamed to uniformArray().`),U(new H3(e,t)));var Boe=class extends Q${constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}};const W3=W(Boe).setParameterLength(1),G3=n2(0,`uint`).label(`u_cameraIndex`).setGroup(Z0(`cameraIndex`)).toVarying(`v_cameraIndex`),K3=n2(`float`).label(`cameraNear`).setGroup($0).onRenderUpdate(({camera:e})=>e.near),q3=n2(`float`).label(`cameraFar`).setGroup($0).onRenderUpdate(({camera:e})=>e.far),J3=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrix);let r=U3(n).setGroup($0).label(`cameraProjectionMatrices`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraProjectionMatrix`)}else t=n2(`mat4`).label(`cameraProjectionMatrix`).setGroup($0).onRenderUpdate(({camera:e})=>e.projectionMatrix);return t}).once()(),Voe=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrixInverse);let r=U3(n).setGroup($0).label(`cameraProjectionMatricesInverse`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraProjectionMatrixInverse`)}else t=n2(`mat4`).label(`cameraProjectionMatrixInverse`).setGroup($0).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse);return t}).once()(),Y3=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorldInverse);let r=U3(n).setGroup($0).label(`cameraViewMatrices`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraViewMatrix`)}else t=n2(`mat4`).label(`cameraViewMatrix`).setGroup($0).onRenderUpdate(({camera:e})=>e.matrixWorldInverse);return t}).once()(),Hoe=n2(`mat4`).label(`cameraWorldMatrix`).setGroup($0).onRenderUpdate(({camera:e})=>e.matrixWorld),Uoe=n2(`mat3`).label(`cameraNormalMatrix`).setGroup($0).onRenderUpdate(({camera:e})=>e.normalMatrix),Woe=n2(new V).label(`cameraPosition`).setGroup($0).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld)),X3=new xX;var Z3=class e extends Q${static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=U$.OBJECT,this.uniformNode=new t2(null)}getNodeType(){let t=this.scope;if(t===e.WORLD_MATRIX)return`mat4`;if(t===e.POSITION||t===e.VIEW_POSITION||t===e.DIRECTION||t===e.SCALE)return`vec3`;if(t===e.RADIUS)return`float`}update(t){let n=this.object3d,r=this.uniformNode,i=this.scope;if(i===e.WORLD_MATRIX)r.value=n.matrixWorld;else if(i===e.POSITION)r.value=r.value||new V,r.value.setFromMatrixPosition(n.matrixWorld);else if(i===e.SCALE)r.value=r.value||new V,r.value.setFromMatrixScale(n.matrixWorld);else if(i===e.DIRECTION)r.value=r.value||new V,n.getWorldDirection(r.value);else if(i===e.VIEW_POSITION){let e=t.camera;r.value=r.value||new V,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(e.matrixWorldInverse)}else if(i===e.RADIUS){let e=t.object.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),X3.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=X3.radius}}generate(t){let n=this.scope;return n===e.WORLD_MATRIX?this.uniformNode.nodeType=`mat4`:n===e.POSITION||n===e.VIEW_POSITION||n===e.DIRECTION||n===e.SCALE?this.uniformNode.nodeType=`vec3`:n===e.RADIUS&&(this.uniformNode.nodeType=`float`),this.uniformNode.build(t)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};Z3.WORLD_MATRIX=`worldMatrix`,Z3.POSITION=`position`,Z3.SCALE=`scale`,Z3.VIEW_POSITION=`viewPosition`,Z3.DIRECTION=`direction`,Z3.RADIUS=`radius`;const Goe=W(Z3,Z3.DIRECTION).setParameterLength(1),Koe=W(Z3,Z3.WORLD_MATRIX).setParameterLength(1),Q3=W(Z3,Z3.POSITION).setParameterLength(1),qoe=W(Z3,Z3.SCALE).setParameterLength(1),Joe=W(Z3,Z3.VIEW_POSITION).setParameterLength(1),Yoe=W(Z3,Z3.RADIUS).setParameterLength(1);var $3=class extends Z3{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}};const Xoe=G($3,$3.DIRECTION),e6=G($3,$3.WORLD_MATRIX),Zoe=G($3,$3.POSITION),Qoe=G($3,$3.SCALE),$oe=G($3,$3.VIEW_POSITION),ese=G($3,$3.RADIUS),t6=n2(new PY).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),tse=n2(new AX).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),n6=K(e=>e.renderer.overrideNodes.modelViewMatrix||r6).once()().toVar(`modelViewMatrix`),r6=Y3.mul(e6),nse=K(e=>(e.context.isHighPrecisionModelViewMatrix=!0,n2(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highpModelViewMatrix`),rse=K(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return n2(`mat3`).onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar(`highpModelNormalViewMatrix`),i6=M3(`position`,`vec3`),a6=i6.toVarying(`positionLocal`),o6=i6.toVarying(`positionPrevious`),s6=K(e=>e6.mul(a6).xyz.toVarying(e.getNamespace(`v_positionWorld`)),`vec3`).once(`POSITION`)(),c6=K(e=>{let t=a6.transformDirection(e6).toVarying(e.getNamespace(`v_positionWorldDirection`));return t.normalize().toVar(`positionWorldDirection`)},`vec3`).once(`POSITION`)(),l6=K(e=>e.context.setupPositionView().toVarying(e.getNamespace(`v_positionView`)),`vec3`).once(`POSITION`)(),u6=l6.negate().toVarying(`v_positionViewDirection`).normalize().toVar(`positionViewDirection`);var ise=class extends Q${static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){let{renderer:t,material:n}=e;return t.coordinateSystem===eY&&n.side===eJ?`false`:e.getFrontFacing()}};const d6=G(ise),f6=q(d6).mul(2).sub(1),p6=M3(`normal`,`vec3`),m6=K(e=>e.geometry.hasAttribute(`normal`)===!1?(console.warn(`THREE.TSL: Vertex attribute "normal" not found on geometry.`),X(0,1,0)):p6,`vec3`).once()().toVar(`normalLocal`),h6=l6.dFdx().cross(l6.dFdy()).normalize().toVar(`normalFlat`),g6=K(e=>{let t;return t=e.material.flatShading===!0?h6:a3(x6(m6),`v_normalView`).normalize(),t},`vec3`).once()().toVar(`normalView`),_6=K(e=>{let t=g6.transformDirection(Y3);return e.material.flatShading!==!0&&(t=a3(t,`v_normalWorld`)),t},`vec3`).once()().normalize().toVar(`normalWorld`),v6=K(e=>{let t=e.context.setupNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(f6)),t},`vec3`).once()().toVar(`transformedNormalView`),y6=v6.transformDirection(Y3).toVar(`transformedNormalWorld`),ase=K(e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(f6)),t},`vec3`).once()().toVar(`transformedClearcoatNormalView`),b6=K(([e,t=e6])=>{let n=l0(t),r=e.div(X(n[0].dot(n[0]),n[1].dot(n[1]),n[2].dot(n[2])));return n.mul(r).xyz}),x6=K(([e],t)=>{let n=t.renderer.overrideNodes.modelNormalViewMatrix;if(n!==null)return n.transformDirection(e);let r=t6.mul(e);return Y3.transformDirection(r)}),S6=new BX,C6=new AX,w6=n2(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),ose=n2(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),T6=n2(new AX).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let n=t.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation;return n?(S6.copy(n),C6.makeRotationFromEuler(S6)):C6.identity(),C6}),E6=u6.negate().reflect(v6),D6=u6.negate().refract(v6,w6),O6=E6.transformDirection(Y3).toVar(`reflectVector`),k6=D6.transformDirection(Y3).toVar(`reflectVector`),A6=new cQ;var sse=class extends L3{static get type(){return`CubeTextureNode`}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return`cubeTexture`}getDefaultUV(){let e=this.value;return e.mapping===uJ?O6:e.mapping===dJ?k6:(console.error(`THREE.CubeTextureNode: Mapping "%s" not supported.`,e.mapping),X(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return(e.renderer.coordinateSystem===tY||!n.isRenderTargetTexture)&&(t=X(t.x.negate(),t.yz)),T6.mul(t)}generateUV(e,t){return t.build(e,`vec3`)}};const j6=W(sse).setParameterLength(1,4).setName(`cubeTexture`),M6=(e=A6,t=null,n=null,r=null)=>{let i;return e&&e.isCubeTextureNode===!0?(i=U(e.clone()),i.referenceNode=e.getSelf(),t!==null&&(i.uvNode=U(t)),n!==null&&(i.levelNode=U(n)),r!==null&&(i.biasNode=U(r))):i=j6(e,t,n,r),i},cse=(e=A6)=>j6(e);var lse=class extends $${static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},N6=class extends Q${static get type(){return`ReferenceNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=U$.OBJECT}element(e){return U(new lse(this,U(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=this.count===null?Array.isArray(this.getValueFromReference())?U3(null,e):e===`texture`?R3(null):e===`cubeTexture`?M6(null):n2(null,e):V3(null,e,this.count),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}};const P6=(e,t,n)=>U(new N6(e,t,n)),F6=(e,t,n,r)=>U(new N6(e,t,r,n));var use=class extends N6{static get type(){return`MaterialReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}};const I6=(e,t,n=null)=>U(new use(e,t,n)),L6=K(e=>(e.geometry.hasAttribute(`tangent`)===!1&&e.geometry.computeTangents(),M3(`tangent`,`vec4`)))(),R6=L6.xyz.toVar(`tangentLocal`),z6=n6.mul(i0(R6,0)).xyz.toVarying(`v_tangentView`).normalize().toVar(`tangentView`),B6=z6.transformDirection(Y3).toVarying(`v_tangentWorld`).normalize().toVar(`tangentWorld`),V6=z6.toVar(`transformedTangentView`),dse=V6.transformDirection(Y3).normalize().toVar(`transformedTangentWorld`),H6=K(([e,t],n)=>{let r=e.mul(L6.w).xyz;return n.material.flatShading!==!0&&(r=a3(r,t)),r}).once(),fse=H6(p6.cross(L6),`v_bitangentGeometry`).normalize().toVar(`bitangentGeometry`),pse=H6(m6.cross(R6),`v_bitangentLocal`).normalize().toVar(`bitangentLocal`),U6=H6(g6.cross(z6),`v_bitangentView`).normalize().toVar(`bitangentView`),mse=H6(_6.cross(B6),`v_bitangentWorld`).normalize().toVar(`bitangentWorld`),W6=H6(v6.cross(V6),`v_transformedBitangentView`).normalize().toVar(`transformedBitangentView`),hse=W6.transformDirection(Y3).normalize().toVar(`transformedBitangentWorld`),G6=l0(z6,U6,g6),K6=u6.mul(G6),gse=(e,t)=>e.sub(K6.mul(t)),_se=(()=>{let e=F0.cross(u6);return e=e.cross(F0).normalize(),e=L4(e,v6,N0.mul(C0.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),vse=K(e=>{let{eye_pos:t,surf_norm:n,mapN:r,uv:i}=e,a=t.dFdx(),o=t.dFdy(),s=i.dFdx(),c=i.dFdy(),l=n,u=o.cross(l),d=l.cross(a),f=u.mul(s.x).add(d.mul(c.x)),p=u.mul(s.y).add(d.mul(c.y)),m=f.dot(f).max(p.dot(p)),h=f6.mul(m.inverseSqrt());return d2(f.mul(r.x,h),p.mul(r.y,h),l.mul(r.z)).normalize()});var yse=class extends t1{static get type(){return`NormalMapNode`}constructor(e,t=null){super(`vec3`),this.node=e,this.scaleNode=t,this.normalMapType=FJ}setup(e){let{normalMapType:t,scaleNode:n}=this,r=this.node.mul(2).sub(1);n!==null&&(r=X(r.xy.mul(n),r.z));let i=null;if(t===IJ)i=x6(r);else if(t===FJ){let t=e.hasGeometryAttribute(`tangent`);i=t===!0?G6.mul(r).normalize():vse({eye_pos:l6,surf_norm:g6,mapN:r,uv:N3()})}return i}};const q6=W(yse).setParameterLength(1,2),bse=K(({textureNode:e,bumpScale:t})=>{let n=t=>e.cache().context({getUV:e=>t(e.uvNode||N3()),forceUVContext:!0}),r=q(n(e=>e));return Y(q(n(e=>e.add(e.dFdx()))).sub(r),q(n(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),xse=K(e=>{let{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),a=t.dFdy().normalize(),o=n,s=a.cross(o),c=o.cross(i),l=i.dot(s).mul(f6),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()});var Sse=class extends t1{static get type(){return`BumpMapNode`}constructor(e,t=null){super(`vec3`),this.textureNode=e,this.scaleNode=t}setup(){let e=this.scaleNode===null?1:this.scaleNode,t=bse({textureNode:this.textureNode,bumpScale:e});return xse({surf_pos:l6,surf_norm:g6,dHdxy:t})}};const J6=W(Sse).setParameterLength(1,2),Y6=new Map;var Q=class e extends Q${static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=Y6.get(e);return n===void 0&&(n=I6(e,t),Y6.set(e,n)),n}getFloat(e){return this.getCache(e,`float`)}getColor(e){return this.getCache(e,`color`)}getTexture(e){return this.getCache(e===`map`?`map`:e+`Map`,`texture`)}setup(t){let n=t.context.material,r=this.scope,i=null;if(r===e.COLOR){let e=n.color===void 0?X():this.getColor(r);i=n.map&&n.map.isTexture===!0?e.mul(this.getTexture(`map`)):e}else if(r===e.OPACITY){let e=this.getFloat(r);i=n.alphaMap&&n.alphaMap.isTexture===!0?e.mul(this.getTexture(`alpha`)):e}else if(r===e.SPECULAR_STRENGTH)i=n.specularMap&&n.specularMap.isTexture===!0?this.getTexture(`specular`).r:q(1);else if(r===e.SPECULAR_INTENSITY){let e=this.getFloat(r);i=n.specularIntensityMap&&n.specularIntensityMap.isTexture===!0?e.mul(this.getTexture(r).a):e}else if(r===e.SPECULAR_COLOR){let e=this.getColor(r);i=n.specularColorMap&&n.specularColorMap.isTexture===!0?e.mul(this.getTexture(r).rgb):e}else if(r===e.ROUGHNESS){let e=this.getFloat(r);i=n.roughnessMap&&n.roughnessMap.isTexture===!0?e.mul(this.getTexture(r).g):e}else if(r===e.METALNESS){let e=this.getFloat(r);i=n.metalnessMap&&n.metalnessMap.isTexture===!0?e.mul(this.getTexture(r).b):e}else if(r===e.EMISSIVE){let e=this.getFloat(`emissiveIntensity`),t=this.getColor(r).mul(e);i=n.emissiveMap&&n.emissiveMap.isTexture===!0?t.mul(this.getTexture(r)):t}else if(r===e.NORMAL)n.normalMap?(i=q6(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType):i=n.bumpMap?J6(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):g6;else if(r===e.CLEARCOAT){let e=this.getFloat(r);i=n.clearcoatMap&&n.clearcoatMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=n.clearcoatRoughnessMap&&n.clearcoatRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_NORMAL)i=n.clearcoatNormalMap?q6(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):g6;else if(r===e.SHEEN){let e=this.getColor(`sheenColor`).mul(this.getFloat(`sheen`));i=n.sheenColorMap&&n.sheenColorMap.isTexture===!0?e.mul(this.getTexture(`sheenColor`).rgb):e}else if(r===e.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=n.sheenRoughnessMap&&n.sheenRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).a):e,i=i.clamp(.07,1)}else if(r===e.ANISOTROPY)if(n.anisotropyMap&&n.anisotropyMap.isTexture===!0){let e=this.getTexture(r),t=c0(r8.x,r8.y,r8.y.negate(),r8.x);i=t.mul(e.rg.mul(2).sub(Y(1)).normalize().mul(e.b))}else i=r8;else if(r===e.IRIDESCENCE_THICKNESS){let e=P6(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=P6(`0`,`float`,n.iridescenceThicknessRange);i=e.sub(t).mul(this.getTexture(r).g).add(t)}else i=e}else if(r===e.TRANSMISSION){let e=this.getFloat(r);i=n.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===e.THICKNESS){let e=this.getFloat(r);i=n.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===e.IOR)i=this.getFloat(r);else if(r===e.LIGHT_MAP)i=this.getTexture(r).rgb.mul(this.getFloat(`lightMapIntensity`));else if(r===e.AO)i=this.getTexture(r).r.sub(1).mul(this.getFloat(`aoMapIntensity`)).add(1);else if(r===e.LINE_DASH_OFFSET)i=n.dashOffset?this.getFloat(r):q(0);else{let e=this.getNodeType(t);i=this.getCache(r,e)}return i}};Q.ALPHA_TEST=`alphaTest`,Q.COLOR=`color`,Q.OPACITY=`opacity`,Q.SHININESS=`shininess`,Q.SPECULAR=`specular`,Q.SPECULAR_STRENGTH=`specularStrength`,Q.SPECULAR_INTENSITY=`specularIntensity`,Q.SPECULAR_COLOR=`specularColor`,Q.REFLECTIVITY=`reflectivity`,Q.ROUGHNESS=`roughness`,Q.METALNESS=`metalness`,Q.NORMAL=`normal`,Q.CLEARCOAT=`clearcoat`,Q.CLEARCOAT_ROUGHNESS=`clearcoatRoughness`,Q.CLEARCOAT_NORMAL=`clearcoatNormal`,Q.EMISSIVE=`emissive`,Q.ROTATION=`rotation`,Q.SHEEN=`sheen`,Q.SHEEN_ROUGHNESS=`sheenRoughness`,Q.ANISOTROPY=`anisotropy`,Q.IRIDESCENCE=`iridescence`,Q.IRIDESCENCE_IOR=`iridescenceIOR`,Q.IRIDESCENCE_THICKNESS=`iridescenceThickness`,Q.IOR=`ior`,Q.TRANSMISSION=`transmission`,Q.THICKNESS=`thickness`,Q.ATTENUATION_DISTANCE=`attenuationDistance`,Q.ATTENUATION_COLOR=`attenuationColor`,Q.LINE_SCALE=`scale`,Q.LINE_DASH_SIZE=`dashSize`,Q.LINE_GAP_SIZE=`gapSize`,Q.LINE_WIDTH=`linewidth`,Q.LINE_DASH_OFFSET=`dashOffset`,Q.POINT_SIZE=`size`,Q.DISPERSION=`dispersion`,Q.LIGHT_MAP=`light`,Q.AO=`ao`;const X6=G(Q,Q.ALPHA_TEST),Z6=G(Q,Q.COLOR),Cse=G(Q,Q.SHININESS),Q6=G(Q,Q.EMISSIVE),$6=G(Q,Q.OPACITY),wse=G(Q,Q.SPECULAR),Tse=G(Q,Q.SPECULAR_INTENSITY),Ese=G(Q,Q.SPECULAR_COLOR),Dse=G(Q,Q.SPECULAR_STRENGTH),Ose=G(Q,Q.REFLECTIVITY),kse=G(Q,Q.ROUGHNESS),Ase=G(Q,Q.METALNESS),e8=G(Q,Q.NORMAL),jse=G(Q,Q.CLEARCOAT),Mse=G(Q,Q.CLEARCOAT_ROUGHNESS),Nse=G(Q,Q.CLEARCOAT_NORMAL),Pse=G(Q,Q.ROTATION),Fse=G(Q,Q.SHEEN),Ise=G(Q,Q.SHEEN_ROUGHNESS),Lse=G(Q,Q.ANISOTROPY),Rse=G(Q,Q.IRIDESCENCE),zse=G(Q,Q.IRIDESCENCE_IOR),Bse=G(Q,Q.IRIDESCENCE_THICKNESS),Vse=G(Q,Q.TRANSMISSION),Hse=G(Q,Q.THICKNESS),Use=G(Q,Q.IOR),Wse=G(Q,Q.ATTENUATION_DISTANCE),Gse=G(Q,Q.ATTENUATION_COLOR),Kse=G(Q,Q.LINE_SCALE),qse=G(Q,Q.LINE_DASH_SIZE),Jse=G(Q,Q.LINE_GAP_SIZE),Yse=G(Q,Q.LINE_WIDTH),Xse=G(Q,Q.LINE_DASH_OFFSET),Zse=G(Q,Q.POINT_SIZE),Qse=G(Q,Q.DISPERSION),t8=G(Q,Q.LIGHT_MAP),n8=G(Q,Q.AO),r8=n2(new AY).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),i8=K(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`);var a8=class e extends Q${static get type(){return`IndexNode`}constructor(e){super(`uint`),this.scope=e,this.isIndexNode=!0}generate(t){let n=this.getNodeType(t),r=this.scope,i;if(r===e.VERTEX)i=t.getVertexIndex();else if(r===e.INSTANCE)i=t.getInstanceIndex();else if(r===e.DRAW)i=t.getDrawIndex();else if(r===e.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(r===e.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(r===e.SUBGROUP)i=t.getSubgroupIndex();else throw Error(`THREE.IndexNode: Unknown scope: `+r);let a;if(t.shaderStage===`vertex`||t.shaderStage===`compute`)a=i;else{let e=a3(this);a=e.build(t,n)}return a}};a8.VERTEX=`vertex`,a8.INSTANCE=`instance`,a8.SUBGROUP=`subgroup`,a8.INVOCATION_LOCAL=`invocationLocal`,a8.INVOCATION_SUBGROUP=`invocationSubgroup`,a8.DRAW=`draw`;const o8=G(a8,a8.VERTEX),s8=G(a8,a8.INSTANCE),$se=G(a8,a8.SUBGROUP),ece=G(a8,a8.INVOCATION_SUBGROUP),tce=G(a8,a8.INVOCATION_LOCAL),c8=G(a8,a8.DRAW);var l8=class extends Q${static get type(){return`InstanceNode`}constructor(e,t,n=null){super(`void`),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=U$.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let{count:t,instanceMatrix:n,instanceColor:r}=this,{instanceMatrixNode:i,instanceColorNode:a}=this;if(i===null){if(t<=1e3)i=V3(n.array,`mat4`,Math.max(t,1)).element(s8);else{let e=new XQ(n.array,16,1);this.buffer=e;let t=n.usage===$J?y3:v3,r=[t(e,`vec4`,16,0),t(e,`vec4`,16,4),t(e,`vec4`,16,8),t(e,`vec4`,16,12)];i=u0(...r)}this.instanceMatrixNode=i}if(r&&a===null){let e=new pQ(r.array,3),t=r.usage===$J?y3:v3;this.bufferColor=e,a=X(t(e,`vec3`,3,0)),this.instanceColorNode=a}let o=i.mul(a6).xyz;if(a6.assign(o),e.hasGeometryAttribute(`normal`)){let e=b6(m6,i);m6.assign(e)}this.instanceColorNode!==null&&b0(`vec3`,`vInstanceColor`).assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==$J&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==$J&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}};const nce=W(l8).setParameterLength(2,3);var rce=class extends l8{static get type(){return`InstancedMeshNode`}constructor(e){let{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}};const u8=W(rce).setParameterLength(1);var ice=class extends Q${static get type(){return`BatchNode`}constructor(e){super(`void`),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=s8:this.batchingIdNode=c8);let t=K(([e])=>{let t=J(P3(z3(this.batchMesh._indirectTexture),0).x),n=J(e).mod(t),r=J(e).div(t);return z3(this.batchMesh._indirectTexture,Q1(n,r)).x}).setLayout({name:`getIndirectIndex`,type:`uint`,inputs:[{name:`id`,type:`int`}]}),n=t(J(this.batchingIdNode)),r=this.batchMesh._matricesTexture,i=J(P3(z3(r),0).x),a=q(n).mul(4).toInt().toVar(),o=a.mod(i),s=a.div(i),c=u0(z3(r,Q1(o,s)),z3(r,Q1(o.add(1),s)),z3(r,Q1(o.add(2),s)),z3(r,Q1(o.add(3),s))),l=this.batchMesh._colorsTexture;if(l!==null){let e=K(([e])=>{let t=J(P3(z3(l),0).x),n=e,r=n.mod(t),i=n.div(t);return z3(l,Q1(r,i)).rgb}).setLayout({name:`getBatchingColor`,type:`vec3`,inputs:[{name:`id`,type:`int`}]}),t=e(n);b0(`vec3`,`vBatchColor`).assign(t)}let u=l0(c);a6.assign(c.mul(a6));let d=m6.div(X(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),f=u.mul(d).xyz;m6.assign(f),e.hasGeometryAttribute(`tangent`)&&R6.mulAssign(u)}};const d8=W(ice).setParameterLength(1);var ace=class extends $${static get type(){return`StorageArrayElementNode`}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):`void`}setup(e){return e.isAvailable(`storageBuffer`)===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,r=e.context.assign;if(n=e.isAvailable(`storageBuffer`)===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!==`compute`)?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}};const oce=W(ace).setParameterLength(2);var sce=class extends B3{static get type(){return`StorageBufferNode`}constructor(e,t=null,n=0){let r,i=null;t&&t.isStruct?(r=`struct`,i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=M$(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=G$.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?`indirectStorageBuffer`:`storageBuffer`}element(e){return oce(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(G$.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=g3(this.value),this._varying=a3(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.getNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode===null?`void`:this.structTypeNode.getMemberType(e,t)}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generate(e);let{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}};const f8=(e,t=null,n=0)=>U(new sce(e,t,n)),cce=(e,t,n)=>(console.warn(`THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.`),f8(e,t,n).setPBO(!0)),p8=new WeakMap;var m8=class extends Q${static get type(){return`SkinningNode`}constructor(e){super(`void`),this.skinnedMesh=e,this.updateType=U$.OBJECT,this.skinIndexNode=M3(`skinIndex`,`uvec4`),this.skinWeightNode=M3(`skinWeight`,`vec4`),this.bindMatrixNode=P6(`bindMatrix`,`mat4`),this.bindMatrixInverseNode=P6(`bindMatrixInverse`,`mat4`),this.boneMatricesNode=F6(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length),this.positionNode=a6,this.toPositionNode=a6,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=i.mul(t),d=d2(o.mul(r.x).mul(u),s.mul(r.y).mul(u),c.mul(r.z).mul(u),l.mul(r.w).mul(u));return a.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=m6){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=d2(r.x.mul(o),r.y.mul(s),r.z.mul(c),r.w.mul(l));return u=a.mul(u).mul(i),u.transformDirection(t).xyz}getPreviousSkinnedPosition(e){let t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=F6(`skeleton.previousBoneMatrices`,`mat4`,t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,o6)}needsPreviousBoneMatrices(e){let t=e.renderer.getMRT();return t&&t.has(`velocity`)||z$(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&o6.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute(`normal`)){let t=this.getSkinnedNormal();m6.assign(t),e.hasGeometryAttribute(`tangent`)&&R6.assign(t)}return t}generate(e,t){if(t!==`void`)return super.generate(e,t)}update(e){let t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;p8.get(t)!==e.frameId&&(p8.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}};const h8=e=>U(new m8(e)),lce=(e,t=null)=>{let n=new m8(e);return n.positionNode=f8(new pQ(e.geometry.getAttribute(`position`).array,3),`vec3`).setPBO(!0).toReadOnly().element(s8).toVar(),n.skinIndexNode=f8(new pQ(new Uint32Array(e.geometry.getAttribute(`skinIndex`).array),4),`uvec4`).setPBO(!0).toReadOnly().element(s8).toVar(),n.skinWeightNode=f8(new pQ(e.geometry.getAttribute(`skinWeight`).array,4),`vec4`).setPBO(!0).toReadOnly().element(s8).toVar(),n.bindMatrixNode=n2(e.bindMatrix,`mat4`),n.bindMatrixInverseNode=n2(e.bindMatrixInverse,`mat4`),n.boneMatricesNode=V3(e.skeleton.boneMatrices,`mat4`,e.skeleton.bones.length),n.toPositionNode=t,U(n)};var uce=class extends Q${static get type(){return`LoopNode`}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let n={};for(let e=0,t=this.params.length-1;e<t;e++){let t=this.params[e],r=t.isNode!==!0&&t.name||this.getVarName(e),i=t.isNode!==!0&&t.type||`int`;n[r]=D3(r,i)}let r=e.addStack();t.returnsNode=this.params[this.params.length-1](n,e),t.stackNode=r;let i=this.params[0];return i.isNode!==!0&&typeof i.update==`function`&&(t.updateNode=K(this.params[0].update)(n)),e.removeStack(),t}getNodeType(e){let{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):`void`}setup(e){this.getProperties(e)}generate(e){let t=this.getProperties(e),n=this.params,r=t.stackNode;for(let r=0,i=n.length-1;r<i;r++){let i=n[r],a=!1,o=null,s=null,c=null,l=null,u=null,d=null;i.isNode?i.getNodeType(e)===`bool`?(a=!0,l=`bool`,s=i.build(e,l)):(l=`int`,c=this.getVarName(r),o=`0`,s=i.build(e,l),u=`<`):(l=i.type||`int`,c=i.name||this.getVarName(r),o=i.start,s=i.end,u=i.condition,d=i.update,typeof o==`number`?o=e.generateConst(l,o):o&&o.isNode&&(o=o.build(e,l)),typeof s==`number`?s=e.generateConst(l,s):s&&s.isNode&&(s=s.build(e,l)),o!==void 0&&s===void 0?(o+=` - 1`,s=`0`,u=`>=`):s!==void 0&&o===void 0&&(o=`0`,u=`<`),u===void 0&&(u=Number(o)>Number(s)?`>=`:`<`));let f;if(a)f=`while ( ${s} )`;else{let n={start:o,end:s},r=n.start,i=n.end,a,p=()=>u.includes(`<`)?`+=`:`-=`;if(d!=null)switch(typeof d){case`function`:let n=e.flowStagesNode(t.updateNode,`void`),r=n.code.replace(/\t|;/g,``);a=r;break;case`number`:a=c+` `+p()+` `+e.generateConst(l,d);break;case`string`:a=c+` `+d;break;default:d.isNode?a=c+` `+p()+` `+d.build(e):(console.error(`THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number.`),a=`break /* invalid update */`)}else d=l===`int`||l===`uint`?u.includes(`<`)?`++`:`--`:p()+` 1.`,a=c+` `+d;let m=e.getVar(l,c)+` = `+r,h=c+` `+u+` `+i;f=`for ( ${m}; ${h}; ${a} )`}e.addFlowCode((r===0?`
425
425
  `:``)+e.tab+f+` {
426
426
 
427
427
  `).addFlowTab()}let i=r.build(e,`void`),a=t.returnsNode?t.returnsNode.build(e):``;e.removeFlowTab().addFlowCode(`
428
428
  `+e.tab+i);for(let t=0,n=this.params.length-1;t<n;t++)e.addFlowCode((t===0?``:e.tab)+`}
429
429
 
430
- `).removeFlowTab();return e.addFlowTab(),a}};const g8=(...e)=>U(new lce(H1(e,`int`))).toStack(),uce=()=>D3(`continue`).toStack(),_8=()=>D3(`break`).toStack(),dce=(...e)=>(console.warn(`THREE.TSL: loop() has been renamed to Loop().`),g8(...e)),v8=new WeakMap,y8=new TX,b8=K(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=J(o8).mul(n).add(a),s=o.div(r),c=o.sub(s.mul(r)),l=z3(e,Q1(c,s)).depth(i).xyz;return l.mul(t)});function fce(e){let t=e.morphAttributes.position!==void 0,n=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=i===void 0?0:i.length,o=v8.get(e);if(o===void 0||o.count!==a){o!==void 0&&o.texture.dispose();let i=e.morphAttributes.position||[],s=e.morphAttributes.normal||[],c=e.morphAttributes.color||[],l=0;t===!0&&(l=1),n===!0&&(l=2),r===!0&&(l=3);let u=e.attributes.position.count*l,d=1,f=4096;u>f&&(d=Math.ceil(u/f),u=f);let p=new Float32Array(u*d*4*a),m=new DX(p,u,d,a);m.type=JJ,m.needsUpdate=!0;let h=l*4;for(let e=0;e<a;e++){let a=i[e],o=s[e],l=c[e],f=u*d*4*e;for(let e=0;e<a.count;e++){let i=e*h;t===!0&&(y8.fromBufferAttribute(a,e),p[f+i+0]=y8.x,p[f+i+1]=y8.y,p[f+i+2]=y8.z,p[f+i+3]=0),n===!0&&(y8.fromBufferAttribute(o,e),p[f+i+4]=y8.x,p[f+i+5]=y8.y,p[f+i+6]=y8.z,p[f+i+7]=0),r===!0&&(y8.fromBufferAttribute(l,e),p[f+i+8]=y8.x,p[f+i+9]=y8.y,p[f+i+10]=y8.z,p[f+i+11]=l.itemSize===4?y8.w:1)}}o={count:a,texture:m,stride:l,size:new tX(u,d)},v8.set(e,o);function g(){m.dispose(),v8.delete(e),e.removeEventListener(`dispose`,g)}e.addEventListener(`dispose`,g)}return o}var pce=class extends Q${static get type(){return`MorphNode`}constructor(e){super(`void`),this.mesh=e,this.morphBaseInfluence=n2(1),this.updateType=U$.OBJECT}setup(e){let{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute(`normal`)&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=i===void 0?0:i.length,{texture:o,stride:s,size:c}=fce(t);n===!0&&a6.mulAssign(this.morphBaseInfluence),r===!0&&m6.mulAssign(this.morphBaseInfluence);let l=J(c.width);g8(a,({i:e})=>{let t=q(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?t.assign(z3(this.mesh.morphTexture,Q1(J(e).add(1),J(s8))).r):t.assign(P6(`morphTargetInfluences`,`float`).element(e).toVar()),K1(t.notEqual(0),()=>{n===!0&&a6.addAssign(b8({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:J(0)})),r===!0&&m6.addAssign(b8({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:J(1)}))})})}update(){let e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}};const x8=W(pce).setParameterLength(1);var S8=class extends Q${static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},mce=class extends S8{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},hce=class extends Q4{static get type(){return`LightingContextNode`}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){let{backdropNode:e,backdropAlphaNode:t}=this,n=X().toVar(`directDiffuse`),r=X().toVar(`directSpecular`),i=X().toVar(`indirectDiffuse`),a=X().toVar(`indirectSpecular`),o={directDiffuse:n,directSpecular:r,indirectDiffuse:i,indirectSpecular:a},s={radiance:X().toVar(`radiance`),irradiance:X().toVar(`irradiance`),iblIrradiance:X().toVar(`iblIrradiance`),ambientOcclusion:q(1).toVar(`ambientOcclusion`),reflectedLight:o,backdrop:e,backdropAlpha:t};return s}setup(e){return this.value=this._value||=this.getContext(),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}};const C8=W(hce);var gce=class extends S8{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}};let w8,T8;var E8=class e extends Q${static get type(){return`ScreenNode`}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===e.VIEWPORT?`vec4`:`vec2`}getUpdateType(){let t=U$.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT)&&(t=U$.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(T8),T8.multiplyScalar(t.getPixelRatio())):T8.copy(n.viewport):n===null?t.getDrawingBufferSize(w8):(w8.width=n.width,w8.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?n2(w8||=new tX):t===e.VIEWPORT?n2(T8||=new TX):Y(k8.div(O8)),n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(O8).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};E8.COORDINATE=`coordinate`,E8.VIEWPORT=`viewport`,E8.SIZE=`size`,E8.UV=`uv`;const D8=G(E8,E8.UV),O8=G(E8,E8.SIZE),k8=G(E8,E8.COORDINATE),A8=G(E8,E8.VIEWPORT),j8=A8.zw,M8=k8.sub(A8.xy),_ce=M8.div(j8),vce=K(()=>(console.warn(`THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.`),O8),`vec2`).once()(),yce=K(()=>(console.warn(`THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.`),D8),`vec2`).once()(),bce=K(()=>(console.warn(`THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.`),D8.flipY()),`vec2`).once()(),N8=new tX;var P8=class extends L3{static get type(){return`ViewportTextureNode`}constructor(e=D8,t=null,n=null){n===null&&(n=new HQ,n.minFilter=UJ),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=U$.FRAME}updateBefore(e){let t=e.renderer;t.getDrawingBufferSize(N8);let n=this.value;(n.image.width!==N8.width||n.image.height!==N8.height)&&(n.image.width=N8.width,n.image.height=N8.height,n.needsUpdate=!0);let r=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=r}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}};const xce=W(P8).setParameterLength(0,3),Sce=W(P8,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let F8=null;var Cce=class extends P8{static get type(){return`ViewportDepthTextureNode`}constructor(e=D8,t=null){F8===null&&(F8=new UQ),super(e,t,F8)}};const I8=W(Cce).setParameterLength(0,2);var L8=class e extends Q${static get type(){return`ViewportDepthNode`}constructor(e,t=null){super(`float`),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(t){let{scope:n}=this;return n===e.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:n}=this,r=this.valueNode,i=null;if(n===e.DEPTH_BASE)r!==null&&(i=H8().assign(r));else if(n===e.DEPTH)i=t.isPerspectiveCamera?z8(l6.z,K3,q3):R8(l6.z,K3,q3);else if(n===e.LINEAR_DEPTH)if(r!==null)if(t.isPerspectiveCamera){let e=B8(r,K3,q3);i=R8(e,K3,q3)}else i=r;else i=R8(l6.z,K3,q3);return i}};L8.DEPTH_BASE=`depthBase`,L8.DEPTH=`depth`,L8.LINEAR_DEPTH=`linearDepth`;const R8=(e,t,n)=>e.add(t).div(t.sub(n)),wce=(e,t,n)=>t.sub(n).mul(e).sub(t),z8=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),B8=(e,t,n)=>t.mul(n).div(n.sub(t).mul(e).sub(n)),V8=(e,t,n)=>{t=t.max(1e-6).toVar();let r=Y2(e.negate().div(t)),i=Y2(n.div(t));return r.div(i)},Tce=(e,t,n)=>{let r=e.mul(J2(n.div(t)));return q(Math.E).pow(r).mul(t).negate()},H8=W(L8,L8.DEPTH_BASE),U8=G(L8,L8.DEPTH),W8=W(L8,L8.LINEAR_DEPTH).setParameterLength(0,1),Ece=W8(I8());U8.assign=e=>H8(e);var G8=class e extends Q${static get type(){return`ClippingNode`}constructor(t=e.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let n=t.clippingContext,{intersectionPlanes:r,unionPlanes:i}=n;return this.hardwareClipping=t.material.hardwareClipping,this.scope===e.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,i):this.scope===e.HARDWARE?this.setupHardwareClipping(i,t):this.setupDefault(r,i)}setupAlphaToCoverage(e,t){return K(()=>{let n=q().toVar(`distanceToPlane`),r=q().toVar(`distanceToGradient`),i=q(1).toVar(`clipOpacity`),a=t.length;if(this.hardwareClipping===!1&&a>0){let e=U3(t);g8(a,({i:t})=>{let a=e.element(t);n.assign(l6.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(V4(r.negate(),r,n))})}let o=e.length;if(o>0){let t=U3(e),a=q(1).toVar(`intersectionClipOpacity`);g8(o,({i:e})=>{let i=t.element(e);n.assign(l6.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(V4(r.negate(),r,n).oneMinus())}),i.mulAssign(a.oneMinus())}x0.a.mulAssign(i),x0.a.equal(0).discard()})()}setupDefault(e,t){return K(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let e=U3(t);g8(n,({i:t})=>{let n=e.element(t);l6.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=U3(e),n=Z1(!0).toVar(`clipped`);g8(r,({i:e})=>{let r=t.element(e);n.assign(l6.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),K(()=>{let r=U3(e),i=W3(t.getClipDistance());g8(n,({i:e})=>{let t=r.element(e),n=l6.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};G8.ALPHA_TO_COVERAGE=`alphaToCoverage`,G8.DEFAULT=`default`,G8.HARDWARE=`hardware`;const Dce=()=>U(new G8),Oce=()=>U(new G8(G8.ALPHA_TO_COVERAGE)),kce=()=>U(new G8(G8.HARDWARE)),Ace=.05,K8=K(([e])=>t4(p2(1e4,n4(p2(17,e.x).add(p2(.1,e.y)))).mul(d2(.1,c4(n4(p2(13,e.y).add(e.x))))))),q8=K(([e])=>K8(Y(K8(e.xy),e.z))),jce=K(([e])=>{let t=C4(u4(p4(e.xyz)),u4(m4(e.xyz))),n=q(1).div(q(Ace).mul(t)).toVar(`pixScale`),r=Y(q2(Q2(Y2(n))),q2($2(Y2(n)))),i=Y(q8(Q2(r.x.mul(e.xyz))),q8(Q2(r.y.mul(e.xyz)))),a=t4(Y2(n)),o=d2(p2(a.oneMinus(),i.x),p2(a,i.y)),s=S4(a,a.oneMinus()),c=X(o.mul(o).div(p2(2,s).mul(f2(1,s))),o.sub(p2(.5,s)).div(f2(1,s)),f2(1,f2(1,o).mul(f2(1,o)).div(p2(2,s).mul(f2(1,s))))),l=o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z);return R4(l,1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]});var Mce=class extends j3{static get type(){return`VertexColorNode`}constructor(e){super(null,`vec4`),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return`color`+(e>0?e:``)}generate(e){let t=this.getAttributeName(e),n=e.hasGeometryAttribute(t),r;return r=n===!0?super.generate(e):e.generateConst(this.nodeType,new TX(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}};const J8=(e=0)=>U(new Mce(e));var Y8=class extends XZ{static get type(){return`NodeMaterial`}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,`shadowPositionNode`,{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn(`THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".`),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+O$(this)}build(e){this.setup(e)}setupObserver(e){return new C$(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,n=t.getRenderTarget();e.addStack();let r=this.setupVertex(e),i=this.vertexNode||r;e.stack.outputNode=i,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow(`vertex`,e.removeStack()),e.addStack();let a,o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n===null?t.depth===!0&&this.setupDepth(e):n.depthBuffer===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);let r=this.setupLighting(e);o!==null&&e.stack.add(o);let i=i0(r,x0.a).max(0);a=this.setupOutput(e,i),z0.assign(a);let s=this.outputNode!==null;if(s&&(a=this.outputNode),n!==null){let e=t.getMRT(),n=this.mrtNode;e===null?n!==null&&(a=n):(s&&z0.assign(a),a=e,n!==null&&(a=e.merge(n)))}}else{let t=this.fragmentNode;t.isOutputStructNode!==!0&&(t=i0(t)),a=this.setupOutput(e,t)}e.stack.outputNode=a,e.addFlow(`fragment`,e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:n}=e.clippingContext,r=null;if(t.length>0||n.length>0){let t=e.renderer.samples;this.alphaToCoverage&&t>1?r=Oce():e.stack.add(Dce())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable(`clipDistance`)&&(e.stack.add(kce()),this.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:n}=e,r=this.depthNode;if(r===null){let e=t.getMRT();e&&e.has(`depth`)?r=e.get(`depth`):t.logarithmicDepthBuffer===!0&&(r=n.isPerspectiveCamera?V8(l6.z,K3,q3):R8(l6.z,K3,q3))}r!==null&&U8.assign(r).toStack()}setupPositionView(){return n6.mul(a6).xyz}setupModelViewProjection(){return J3.mul(l6)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),i8}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&x8(t).toStack(),t.isSkinnedMesh===!0&&h8(t).toStack(),this.displacementMap){let e=I6(`displacementMap`,`texture`),t=I6(`displacementScale`,`float`),n=I6(`displacementBias`,`float`);a6.addAssign(m6.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&d8(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&u8(t).toStack(),this.positionNode!==null&&a6.assign(S3(this.positionNode,`POSITION`)),a6}setupDiffuseColor({object:e,geometry:t}){this.maskNode!==null&&Z1(this.maskNode).not().discard();let n=this.colorNode?i0(this.colorNode):Z6;if(this.vertexColors===!0&&t.hasAttribute(`color`)&&(n=n.mul(J8())),e.instanceColor){let e=b0(`vec3`,`vInstanceColor`);n=e.mul(n)}if(e.isBatchedMesh&&e._colorsTexture){let e=b0(`vec3`,`vBatchColor`);n=e.mul(n)}x0.assign(n);let r=this.opacityNode?q(this.opacityNode):$6;x0.a.assign(x0.a.mul(r));let i=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(i=this.alphaTestNode===null?X6:q(this.alphaTestNode),x0.a.lessThanEqual(i).discard()),this.alphaHash===!0&&x0.a.lessThan(jce(a6)).discard();let a=this.transparent===!1&&this.blending===DJ&&this.alphaToCoverage===!1;a?x0.a.assign(1):i===null&&x0.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?X(0):x0.rgb}setupNormal(){return this.normalNode?X(this.normalNode):e8}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?I6(`envMap`,`cubeTexture`):I6(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new gce(t8)),t}setupLights(e){let t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){let e=this.aoNode===null?n8:this.aoNode;t.push(new mce(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=this,a=this.lights===!0||this.lightsNode!==null,o=a?this.setupLights(e):null,s=this.setupOutgoingLight(e);if(o&&o.getScope().hasLights){let t=this.setupLightingModel(e)||null;s=C8(o,t,n,r)}else n!==null&&(s=X(r===null?n:L4(s,n,r)));return(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(S0.assign(X(i||Q6)),s=s.add(S0)),s}setupFog(e,t){let n=e.fogNode;return n&&(z0.assign(t),t=i0(n)),t}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),t}setDefaultValues(e){for(let t in e){let n=e[t];this[t]===void 0&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===void 0&&t[e].get!==void 0&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{},nodes:{}});let n=XZ.prototype.toJSON.call(this,e),r=k$(this);n.inputNodes={};for(let{property:t,childNode:i}of r)n.inputNodes[t]=i.toJSON(e).uuid;function i(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=i(e.textures),r=i(e.images),a=i(e.nodes);t.length>0&&(n.textures=t),r.length>0&&(n.images=r),a.length>0&&(n.nodes=a)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}};let X8=null;var Nce=class extends P8{static get type(){return`ViewportSharedTextureNode`}constructor(e=D8,t=null){X8===null&&(X8=new HQ),super(e,t,X8)}updateReference(){return this}};const Pce=W(Nce).setParameterLength(0,2),Fce=e=>U(e).mul(.5).add(.5),Ice=e=>U(e).mul(2).sub(1);var Lce=class extends t1{static get type(){return`EquirectUVNode`}constructor(e=c6){super(`vec2`),this.dirNode=e}setup(){let e=this.dirNode,t=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Y(t,n)}};const Z8=W(Lce).setParameterLength(0,1),Q8=K(({f0:e,f90:t,dotVH:n})=>{let r=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),Rce=K(e=>e.diffuseColor.mul(1/Math.PI)),$8=K(e=>{if(e.geometry.hasAttribute(`normal`)===!1)return q(0);let t=g6.dFdx().abs().max(g6.dFdy().abs()),n=t.x.max(t.y).max(t.z);return n}),zce=K(e=>{let{roughness:t}=e,n=$8(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),e5=K(({alpha:e,dotNL:t,dotNV:n})=>{let r=e.pow2(),i=t.mul(r.add(r.oneMinus().mul(n.pow2())).sqrt()),a=n.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return m2(.5,i.add(a).max(R2))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),Bce=K(({alphaT:e,alphaB:t,dotTV:n,dotBV:r,dotTL:i,dotBL:a,dotNV:o,dotNL:s})=>{let c=s.mul(X(e.mul(n),t.mul(r),o).length()),l=o.mul(X(e.mul(i),t.mul(a),s).length()),u=m2(.5,c.add(l));return u.saturate()}).setLayout({name:`V_GGX_SmithCorrelated_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotTV`,type:`float`,qualifier:`in`},{name:`dotBV`,type:`float`,qualifier:`in`},{name:`dotTL`,type:`float`,qualifier:`in`},{name:`dotBL`,type:`float`,qualifier:`in`},{name:`dotNV`,type:`float`,qualifier:`in`},{name:`dotNL`,type:`float`,qualifier:`in`}]}),t5=K(({alpha:e,dotNH:t})=>{let n=e.pow2(),r=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:`D_GGX`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNH`,type:`float`}]}),Vce=q(1/Math.PI),Hce=K(({alphaT:e,alphaB:t,dotNH:n,dotTH:r,dotBH:i})=>{let a=e.mul(t),o=X(t.mul(r),e.mul(i),a.mul(n)),s=o.dot(o),c=a.div(s);return Vce.mul(a.mul(c.pow2()))}).setLayout({name:`D_GGX_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotNH`,type:`float`,qualifier:`in`},{name:`dotTH`,type:`float`,qualifier:`in`},{name:`dotBH`,type:`float`,qualifier:`in`}]}),Uce=K(e=>{let{lightDirection:t,f0:n,f90:r,roughness:i,f:a,USE_IRIDESCENCE:o,USE_ANISOTROPY:s}=e,c=e.normalView||v6,l=i.pow2(),u=t.add(u6).normalize(),d=c.dot(t).clamp(),f=c.dot(u6).clamp(),p=c.dot(u).clamp(),m=u6.dot(u).clamp(),h=Q8({f0:n,f90:r,dotVH:m}),g,_;if(R1(o)&&(h=k0.mix(h,a)),R1(s)){let e=P0.dot(t),n=P0.dot(u6),r=P0.dot(u),i=F0.dot(t),a=F0.dot(u6),o=F0.dot(u);g=Bce({alphaT:M0,alphaB:l,dotTV:n,dotBV:a,dotTL:e,dotBL:i,dotNV:f,dotNL:d}),_=Hce({alphaT:M0,alphaB:l,dotNH:p,dotTH:r,dotBH:o})}else g=e5({alpha:l,dotNL:d,dotNV:f}),_=t5({alpha:l,dotNH:p});return h.mul(g).mul(_)}),Wce=K(({roughness:e,dotNV:t})=>{let n=i0(-1,-.0275,-.572,.022),r=i0(1,.0425,1.04,-.04),i=e.mul(n).add(r),a=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y),o=Y(-1.04,1.04).mul(a).add(i.zw);return o}).setLayout({name:`DFGApprox`,type:`vec2`,inputs:[{name:`roughness`,type:`float`},{name:`dotNV`,type:`vec3`}]}),Gce=K(({f:e,f90:t,dotVH:n})=>{let r=n.oneMinus().saturate(),i=r.mul(r),a=r.mul(i,i).clamp(0,.9999);return e.sub(X(t).mul(a)).div(a.oneMinus())}).setLayout({name:`Schlick_to_F0`,type:`vec3`,inputs:[{name:`f`,type:`vec3`},{name:`f90`,type:`float`},{name:`dotVH`,type:`float`}]}),n5=1/6,r5=e=>p2(n5,p2(e,p2(e,e.negate().add(3)).sub(3)).add(1)),i5=e=>p2(n5,p2(e,p2(e,p2(3,e).sub(6))).add(4)),a5=e=>p2(n5,p2(e,p2(e,p2(-3,e).add(3)).add(3)).add(1)),o5=e=>p2(n5,A4(e,3)),s5=e=>r5(e).add(i5(e)),c5=e=>a5(e).add(o5(e)),l5=e=>d2(-1,i5(e).div(r5(e).add(i5(e)))),u5=e=>d2(1,o5(e).div(a5(e).add(o5(e)))),d5=(e,t,n)=>{let r=e.uvNode,i=p2(r,t.zw).add(.5),a=Q2(i),o=t4(i),s=s5(o.x),c=c5(o.x),l=l5(o.x),u=u5(o.x),d=l5(o.y),f=u5(o.y),p=Y(a.x.add(l),a.y.add(d)).sub(.5).mul(t.xy),m=Y(a.x.add(u),a.y.add(d)).sub(.5).mul(t.xy),h=Y(a.x.add(l),a.y.add(f)).sub(.5).mul(t.xy),g=Y(a.x.add(u),a.y.add(f)).sub(.5).mul(t.xy),_=s5(o.y).mul(d2(s.mul(e.sample(p).level(n)),c.mul(e.sample(m).level(n)))),v=c5(o.y).mul(d2(s.mul(e.sample(h).level(n)),c.mul(e.sample(g).level(n))));return _.add(v)},Kce=K(([e,t=q(3)])=>{let n=Y(e.size(J(t))),r=Y(e.size(J(t.add(1)))),i=m2(1,n),a=m2(1,r),o=d5(e,i0(i,n),Q2(t)),s=d5(e,i0(a,r),$2(t));return t4(t).mix(o,s)}),qce=X(.04),Jce=q(1),f5=q(1),p5=q(-2),m5=q(.8),h5=q(-1),g5=q(.4),_5=q(2),v5=q(.305),y5=q(3),b5=q(.21),Yce=q(4),x5=q(4),Xce=q(16),Zce=K(([e])=>{let t=X(c4(e)).toVar(),n=q(-1).toVar();return K1(t.x.greaterThan(t.z),()=>{K1(t.x.greaterThan(t.y),()=>{n.assign(X4(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(X4(e.y.greaterThan(0),1,4))})}).Else(()=>{K1(t.z.greaterThan(t.y),()=>{n.assign(X4(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(X4(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),Qce=K(([e,t])=>{let n=Y().toVar();return K1(t.equal(0),()=>{n.assign(Y(e.z,e.y).div(c4(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(Y(e.x.negate(),e.z.negate()).div(c4(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(Y(e.x.negate(),e.y).div(c4(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(Y(e.z.negate(),e.y).div(c4(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(Y(e.x.negate(),e.z).div(c4(e.y)))}).Else(()=>{n.assign(Y(e.x,e.y).div(c4(e.z)))}),p2(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),$ce=K(([e])=>{let t=q(0).toVar();return K1(e.greaterThanEqual(m5),()=>{t.assign(f5.sub(e).mul(h5.sub(p5)).div(f5.sub(m5)).add(p5))}).ElseIf(e.greaterThanEqual(g5),()=>{t.assign(m5.sub(e).mul(_5.sub(h5)).div(m5.sub(g5)).add(h5))}).ElseIf(e.greaterThanEqual(v5),()=>{t.assign(g5.sub(e).mul(y5.sub(_5)).div(g5.sub(v5)).add(_5))}).ElseIf(e.greaterThanEqual(b5),()=>{t.assign(v5.sub(e).mul(Yce.sub(y5)).div(v5.sub(b5)).add(y5))}).Else(()=>{t.assign(q(-2).mul(Y2(p2(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),S5=K(([e,t])=>{let n=e.toVar();n.assign(p2(2,n).sub(1));let r=X(n,1).toVar();return K1(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:`getDirection`,type:`vec3`,inputs:[{name:`uv`,type:`vec2`},{name:`face`,type:`float`}]}),C5=K(([e,t,n,r,i,a])=>{let o=q(n),s=X(t),c=R4($ce(o),p5,a),l=t4(c),u=Q2(c),d=X(w5(e,s,u,r,i,a)).toVar();return K1(l.notEqual(0),()=>{let t=X(w5(e,s,u.add(1),r,i,a)).toVar();d.assign(L4(d,t,l))}),d}),w5=K(([e,t,n,r,i,a])=>{let o=q(n).toVar(),s=X(t),c=q(Zce(s)).toVar(),l=q(C4(x5.sub(o),0)).toVar();o.assign(C4(o,x5));let u=q(q2(o)).toVar(),d=Y(Qce(s,c).mul(u.sub(2)).add(1)).toVar();return K1(c.greaterThan(2),()=>{d.y.addAssign(u),c.subAssign(3)}),d.x.addAssign(c.mul(u)),d.x.addAssign(l.mul(p2(3,Xce))),d.y.addAssign(p2(4,q2(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.sample(d).grad(Y(),Y())}),T5=K(({envMap:e,mipInt:t,outputDirection:n,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=r4(r),l=n.mul(c).add(i.cross(n).mul(n4(r))).add(i.mul(i.dot(n).mul(c.oneMinus())));return w5(e,l,t,a,o,s)}),E5=K(({n:e,latitudinal:t,poleAxis:n,outputDirection:r,weights:i,samples:a,dTheta:o,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let f=X(X4(t,n,k4(n,r))).toVar();K1(f.equal(X(0)),()=>{f.assign(X(r.z,0,r.x.negate()))}),f.assign(e4(f));let p=X().toVar();return p.addAssign(i.element(0).mul(T5({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),g8({start:J(1),end:e},({i:e})=>{K1(e.greaterThanEqual(a),()=>{_8()});let t=q(o.mul(q(e))).toVar();p.addAssign(i.element(e).mul(T5({theta:t.mul(-1),axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(i.element(e).mul(T5({theta:t,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),i0(p,1)}),D5=4,O5=[.125,.215,.35,.446,.526,.582],k5=20,A5=new s$(-1,1,1,-1,0,1),ele=new MQ(90,1),j5=new qZ;let M5=null,N5=0,P5=0;const F5=(1+Math.sqrt(5))/2,I5=1/F5,L5=[new V(-F5,I5,0),new V(F5,I5,0),new V(-I5,0,F5),new V(I5,0,F5),new V(0,F5,-I5),new V(0,F5,I5),new V(-1,1,-1),new V(1,1,-1),new V(-1,1,1),new V(1,1,1)],tle=new V,R5=new WeakMap,nle=[3,1,5,0,4,2],z5=S5(N3(),M3(`faceIndex`)).normalize(),B5=X(z5.x,z5.y,z5.z);var rle=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=tle,renderTarget:s=null}=i;if(this._setSize(a),this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.`);let a=s||this._allocateTarget();return i.renderTarget=a,this.fromSceneAsync(e,t,n,r,i),a}M5=this._renderer.getRenderTarget(),N5=this._renderer.getActiveCubeFace(),P5=this._renderer.getActiveMipmapLevel();let c=s||this._allocateTarget();return c.depthBuffer=!0,this._init(c),this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}async fromSceneAsync(e,t=0,n=.1,r=100,i={}){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,n,r,i)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=W5(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=G5(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===FJ||e.mapping===IJ?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(M5,N5,P5),e.scissorTest=!1,H5(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),M5=this._renderer.getRenderTarget(),N5=this._renderer.getActiveCubeFace(),P5=this._renderer.getActiveMipmapLevel();let n=t||this._allocateTarget();return this._init(n),this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTarget(){let e=3*Math.max(this._cubeSize,16*7),t=4*this._cubeSize,n=V5(e,t);return n}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=V5(e.width,e.height);let{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=ile(t)),this._blurMaterial=ale(t,e.width,e.height)}}async _compileMaterial(e){let t=new wQ(this._lodPlanes[0],e);await this._renderer.compile(t,A5)}_sceneToCubeUV(e,t,n,r,i){let a=ele;a.near=t,a.far=n;let o=[1,1,1,1,-1,1],s=[1,-1,1,-1,1,-1],c=this._renderer,l=c.autoClear;c.getClearColor(j5),c.autoClear=!1;let u=this._backgroundBox;if(u===null){let e=new ZZ({name:`PMREM.Background`,side:TJ,depthWrite:!1,depthTest:!1});u=new wQ(new DQ,e)}let d=!1,f=e.background;f?f.isColor&&(u.material.color.copy(f),e.background=null,d=!0):(u.material.color.copy(j5),d=!0),c.setRenderTarget(r),c.clear(),d&&c.render(u,a);for(let t=0;t<6;t++){let n=t%3;n===0?(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x+s[t],i.y,i.z)):n===1?(a.up.set(0,0,o[t]),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y+s[t],i.z)):(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y,i.z+s[t]));let l=this._cubeSize;H5(r,n*l,t>2?l:0,l,l),c.render(e,a)}c.autoClear=l,e.background=f}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===FJ||e.mapping===IJ;r?this._cubemapMaterial===null&&(this._cubemapMaterial=W5(e)):this._equirectMaterial===null&&(this._equirectMaterial=G5(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;H5(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,A5)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let t=1;t<r;t++){let n=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),i=L5[(r-t-1)%L5.length];this._blur(e,t-1,t,n,i)}t.autoClear=n}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&console.error(`blur direction must be either latitudinal or longitudinal!`);let l=3,u=this._lodMeshes[r];u.material=c;let d=R5.get(c),f=this._sizeLods[n]-1,p=isFinite(i)?Math.PI/(2*f):2*Math.PI/(2*k5-1),m=i/p,h=isFinite(i)?1+Math.floor(l*m):k5;h>k5&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${h} samples when the maximum is set to ${k5}`);let g=[],_=0;for(let e=0;e<k5;++e){let t=e/m,n=Math.exp(-t*t/2);g.push(n),e===0?_+=n:e<h&&(_+=2*n)}for(let e=0;e<g.length;e++)g[e]=g[e]/_;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=h,d.weights.array=g,d.latitudinal.value=a===`latitudinal`?1:0,o&&(d.poleAxis.value=o);let{_lodMax:v}=this;d.dTheta.value=p,d.mipInt.value=v-n;let y=this._sizeLods[r],b=3*y*(r>v-D5?r-v+D5:0),x=4*(this._cubeSize-y);H5(t,b,x,3*y,2*y),s.setRenderTarget(t),s.render(u,A5)}};function ile(e){let t=[],n=[],r=[],i=[],a=e,o=e-D5+1+O5.length;for(let s=0;s<o;s++){let o=2**a;n.push(o);let c=1/o;s>e-D5?c=O5[s-e+D5-1]:s===0&&(c=0),r.push(c);let l=1/(o-2),u=-l,d=1+l,f=[u,u,d,u,d,d,u,u,d,d,u,d],p=6,m=6,h=3,g=2,_=1,v=new Float32Array(h*m*p),y=new Float32Array(g*m*p),b=new Float32Array(_*m*p);for(let e=0;e<p;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],i=nle[e];v.set(r,h*m*i),y.set(f,g*m*i);let a=[i,i,i,i,i,i];b.set(a,_*m*i)}let x=new fQ;x.setAttribute(`position`,new tQ(v,h)),x.setAttribute(`uv`,new tQ(y,g)),x.setAttribute(`faceIndex`,new tQ(b,_)),t.push(x),i.push(new wQ(x,null)),a>D5&&a--}return{lodPlanes:t,sizeLods:n,sigmas:r,lodMeshes:i}}function V5(e,t){let n={magFilter:HJ,minFilter:HJ,generateMipmaps:!1,type:YJ,format:XJ,colorSpace:uY},r=new EX(e,t,n);return r.texture.mapping=LJ,r.texture.name=`PMREM.cubeUv`,r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function H5(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function U5(e){let t=new Y8;return t.depthTest=!1,t.depthWrite=!1,t.blending=EJ,t.name=`PMREM_${e}`,t}function ale(e,t,n){let r=U3(Array(k5).fill(0)),i=n2(new V(0,1,0)),a=n2(0),o=q(k5),s=n2(0),c=n2(1),l=R3(null),u=n2(0),d=q(1/t),f=q(1/n),p=q(e),m={n:o,latitudinal:s,weights:r,poleAxis:i,outputDirection:B5,dTheta:a,samples:c,envMap:l,mipInt:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:f,CUBEUV_MAX_MIP:p},h=U5(`blur`);return h.fragmentNode=E5({...m,latitudinal:s.equal(1)}),R5.set(h,m),h}function W5(e){let t=U5(`cubemap`);return t.fragmentNode=M6(e,B5),t}function G5(e){let t=U5(`equirect`);return t.fragmentNode=R3(e,Z8(B5),0),t}const K5=new WeakMap;function ole(e){let t=Math.log2(e)-2,n=1/e,r=1/(3*Math.max(2**t,7*16));return{texelWidth:r,texelHeight:n,maxMip:t}}function sle(e,t,n){let r=cle(t),i=r.get(e),a=i===void 0?-1:i.pmremVersion;if(a!==e.pmremVersion){let t=e.image;if(e.isCubeTexture)if(ule(t))i=n.fromCubemap(e,i);else return null;else if(dle(t))i=n.fromEquirectangular(e,i);else return null;i.pmremVersion=e.pmremVersion,r.set(e,i)}return i.texture}function cle(e){let t=K5.get(e);return t===void 0&&(t=new WeakMap,K5.set(e,t)),t}var lle=class extends t1{static get type(){return`PMREMNode`}constructor(e,t=null,n=null){super(`vec3`),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;let r=new wX;r.isRenderTargetTexture=!0,this._texture=R3(r),this._width=n2(0),this._height=n2(0),this._maxMip=n2(0),this.updateBeforeType=U$.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=ole(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(t=r.isPMREMTexture===!0?r:sle(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new rle(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=T6.mul(X(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),C5(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function ule(e){if(e==null)return!1;let t=0,n=6;for(let r=0;r<n;r++)e[r]!==void 0&&t++;return t===n}function dle(e){return e==null?!1:e.height>0}const fle=W(lle).setParameterLength(1,3);var ple=class extends t1{static get type(){return`MatcapUVNode`}constructor(){super(`vec2`)}setup(){let e=X(u6.z,0,u6.x.negate()).normalize(),t=u6.cross(e);return Y(e.dot(v6),t.dot(v6)).mul(.495).add(.5)}};const mle=G(ple);var hle=class extends t1{static get type(){return`RotateNode`}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:n}=this,r=this.getNodeType(e);if(r===`vec2`){let e=t.cos(),r=t.sin(),i=c0(e,r,r.negate(),e);return i.mul(n)}else{let e=t,r=u0(i0(1,0,0,0),i0(0,r4(e.x),n4(e.x).negate(),0),i0(0,n4(e.x),r4(e.x),0),i0(0,0,0,1)),i=u0(i0(r4(e.y),0,n4(e.y),0),i0(0,1,0,0),i0(n4(e.y).negate(),0,r4(e.y),0),i0(0,0,0,1)),a=u0(i0(r4(e.z),n4(e.z).negate(),0,0),i0(n4(e.z),r4(e.z),0,0),i0(0,0,1,0),i0(0,0,0,1));return r.mul(i).mul(a).mul(i0(n,1)).xyz}}};const q5=W(hle).setParameterLength(2),gle=y0(`vec3`),_le=y0(`vec3`),vle=y0(`vec3`);var yle=class{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this.weakMap;for(let t=0;t<e.length-1;t++){let r=e[t];n.has(r)===!1&&n.set(r,new WeakMap),n=n.get(r)}return n.set(e[e.length-1],t),this}delete(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}},ble=class extends v0{static get type(){return`ParameterNode`}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}};const xle=(e,t)=>U(new ble(e,t));var Sle=class extends Q${static get type(){return`StackNode`}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):`void`}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):`void`}add(e){return this.nodes.push(e),this}If(e,t){let n=new B1(t);return this._currentCond=X4(e,n),this.add(this._currentCond)}ElseIf(e,t){let n=new B1(t),r=X4(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new B1(e),this}Switch(e){return this._expressionNode=U(e),this}Case(...e){let t=[];if(e.length>=2)for(let n=0;n<e.length-1;n++)t.push(this._expressionNode.equal(U(e[n])));else throw Error(`TSL: Invalid parameter length. Case() requires at least two parameters.`);let n=e[e.length-1],r=new B1(n),i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);let a=X4(i,r);return this._currentCond===null?(this._currentCond=a,this.add(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(e){return this.Else(e),this}build(e,...t){let n=G1();W1(this);let r=e.buildStage;for(let t of this.nodes)if(r===`setup`)t.build(e);else if(r===`analyze`)t.build(e,this);else if(r===`generate`){let n=e.getDataFromNode(t,`any`).stages,r=n&&n[e.shaderStage];if(t.isVarNode&&r&&r.length===1&&r[0]&&r[0].isStackNode)continue;t.build(e,`void`)}return W1(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn(`THREE.TSL: .else() has been renamed to .Else().`),this.Else(...e)}elseif(...e){return console.warn(`THREE.TSL: .elseif() has been renamed to .ElseIf().`),this.ElseIf(...e)}};const Cle=W(Sle).setParameterLength(0,1);function wle(e){return Object.entries(e).map(([e,t])=>typeof t==`string`?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}var Tle=class extends Q${static get type(){return`StructTypeNode`}constructor(e,t=null){super(`struct`),this.membersLayout=wle(e),this.name=t,this.isStructLayoutNode=!0}getLength(){let e=8,t=Float32Array.BYTES_PER_ELEMENT,n=0;for(let r of this.membersLayout){let i=r.type,a=F$(i)*t,o=I$(i),s=n%e,c=s%o,l=s+c;n+=c,l!==0&&e-l<a&&(n+=e-l),n+=a}return Math.ceil(n/e)*e/t}getMemberType(e,t){let n=this.membersLayout.find(e=>e.name===t);return n?n.type:`void`}getNodeType(e){let t=e.getStructTypeFromNode(this,this.membersLayout,this.name);return t.name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}},Ele=class extends Q${static get type(){return`StructNode`}constructor(e,t){super(`vec3`),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){let t=e.getVarFromNode(this),n=t.type,r=e.getPropertyName(t);return e.addLineFlowCode(`${r} = ${e.generateStruct(n,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}};const Dle=(e,t=null)=>{let n=new Tle(e,t),r=(...t)=>{let r=null;if(t.length>0)if(t[0].isNode){r={};let n=Object.keys(e);for(let e=0;e<t.length;e++)r[n[e]]=t[e]}else r=t[0];return U(new Ele(n,r))};return r.layout=n,r.isStruct=!0,r};var J5=class extends Q${static get type(){return`OutputStructNode`}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){let t=e.getNodeProperties(this);if(t.membersLayout===void 0){let n=this.members,r=[];for(let t=0;t<n.length;t++){let i=`m`+t,a=n[t].getNodeType(e);r.push({name:i,type:a,index:t})}t.membersLayout=r,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}return t.structType.name}generate(e){let t=e.getOutputStructName(),n=this.members,r=t===``?``:t+`.`;for(let t=0;t<n.length;t++){let i=n[t].build(e);e.addLineFlowCode(`${r}m${t} = ${i}`,this)}return t}};const Ole=W(J5);function Y5(e,t){for(let n=0;n<e.length;n++)if(e[n].name===t)return n;return-1}var kle=class extends J5{static get type(){return`MRTNode`}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){let t={...this.outputNodes,...e.outputNodes};return X5(t)}setup(e){let t=this.outputNodes,n=e.renderer.getRenderTarget(),r=[],i=n.textures;for(let e in t){let n=Y5(i,e);r[n]=i0(t[e])}return this.members=r,super.setup(e)}};const X5=W(kle),Ale=K(([e])=>{let t=e.toUint().mul(747796405).add(2891336453),n=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737),r=n.shiftRight(22).bitXor(n);return r.toFloat().mul(1/2**32)}),Z5=(e,t)=>A4(p2(4,e.mul(f2(1,e))),t),jle=(e,t)=>e.lessThan(.5)?Z5(e.mul(2),t).div(2):f2(1,Z5(p2(f2(1,e),2),t).div(2)),Mle=(e,t,n)=>A4(m2(A4(e,t),d2(A4(e,t),A4(f2(1,e),n))),1/t),Nle=(e,t)=>n4(B2.mul(t.mul(e).sub(1))).div(B2.mul(t.mul(e).sub(1))),Q5=K(([e])=>e.fract().sub(.5).abs()).setLayout({name:`tri`,type:`float`,inputs:[{name:`x`,type:`float`}]}),Ple=K(([e])=>X(Q5(e.z.add(Q5(e.y.mul(1)))),Q5(e.z.add(Q5(e.x.mul(1)))),Q5(e.y.add(Q5(e.x.mul(1)))))).setLayout({name:`tri3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Fle=K(([e,t,n])=>{let r=X(e).toVar(),i=q(1.4).toVar(),a=q(0).toVar(),o=X(r).toVar();return g8({start:q(0),end:q(3),type:`float`,condition:`<=`},()=>{let e=X(Ple(o.mul(2))).toVar();r.addAssign(e.add(n.mul(q(.1).mul(t)))),o.mulAssign(1.8),i.mulAssign(1.5),r.mulAssign(1.2);let s=q(Q5(r.z.add(Q5(r.x.add(Q5(r.y)))))).toVar();a.addAssign(s.div(i)),o.addAssign(.14)}),a}).setLayout({name:`triNoise3D`,type:`float`,inputs:[{name:`position`,type:`vec3`},{name:`speed`,type:`float`},{name:`time`,type:`float`}]});var Ile=class extends Q${static get type(){return`FunctionOverloadingNode`}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){let t=this.parametersNodes,n=this._candidateFnCall;if(n===null){let r=null,i=-1;for(let n of this.functionNodes){let a=n.shaderNode,o=a.layout;if(o===null)throw Error(`FunctionOverloadingNode: FunctionNode must be a layout.`);let s=o.inputs;if(t.length===s.length){let a=0;for(let n=0;n<t.length;n++){let r=t[n],i=s[n];r.getNodeType(e)===i.type?a++:a=0}a>i&&(r=n,i=a)}}this._candidateFnCall=n=r(...t)}return n}};const Lle=W(Ile),$5=e=>(...t)=>Lle(e,...t),e7=n2(0).setGroup($0).onRenderUpdate(e=>e.time),t7=n2(0).setGroup($0).onRenderUpdate(e=>e.deltaTime),Rle=n2(0,`uint`).setGroup($0).onRenderUpdate(e=>e.frameId),zle=(e=1)=>(console.warn(`TSL: timerLocal() is deprecated. Use "time" instead.`),e7.mul(e)),Ble=(e=1)=>(console.warn(`TSL: timerGlobal() is deprecated. Use "time" instead.`),e7.mul(e)),Vle=(e=1)=>(console.warn(`TSL: timerDelta() is deprecated. Use "deltaTime" instead.`),t7.mul(e)),Hle=(e=e7)=>e.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),Ule=(e=e7)=>e.fract().round(),Wle=(e=e7)=>e.add(.5).fract().mul(2).sub(1).abs(),Gle=(e=e7)=>e.fract(),Kle=K(([e,t,n=Y(.5)])=>q5(e.sub(n),t).add(n)),qle=K(([e,t,n=Y(.5)])=>{let r=e.sub(n),i=r.dot(r),a=i.mul(i),o=a.mul(t);return e.add(r.mul(o))}),Jle=K(({position:e=null,horizontal:t=!0,vertical:n=!1})=>{let r;e===null?r=e6:(r=e6.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z);let i=Y3.mul(r);return R1(t)&&(i[0][0]=e6[0].length(),i[0][1]=0,i[0][2]=0),R1(n)&&(i[1][0]=0,i[1][1]=e6[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,J3.mul(i).mul(a6)}),Yle=K(([e=null])=>{let t=W8(),n=W8(I8(e)).sub(t),r=n.lessThan(0).select(D8,e);return r});var Xle=class extends Q${static get type(){return`SpriteSheetUVNode`}constructor(e,t=N3(),n=q(0)){super(`vec2`),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){let{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:i}=n,a=e.mod(r.mul(i)).floor(),o=a.mod(r),s=i.sub(a.add(1).div(r).ceil()),c=n.reciprocal(),l=Y(o,s);return t.add(l).mul(c)}};const Zle=W(Xle).setParameterLength(3);var Qle=class extends Q${static get type(){return`TriplanarTexturesNode`}constructor(e,t=null,n=null,r=q(1),i=a6,a=m6){super(`vec4`),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=r,this.positionNode=i,this.normalNode=a}setup(){let{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:r,positionNode:i,normalNode:a}=this,o=a.abs().normalize();o=o.div(o.dot(X(1)));let s=i.yz.mul(r),c=i.zx.mul(r),l=i.xy.mul(r),u=e.value,d=t===null?u:t.value,f=n===null?u:n.value,p=R3(u,s).mul(o.x),m=R3(d,c).mul(o.y),h=R3(f,l).mul(o.z);return d2(p,m,h)}};const n7=W(Qle).setParameterLength(1,6),$le=(...e)=>n7(...e),r7=new VQ,i7=new V,a7=new V,o7=new V,s7=new tZ,c7=new V(0,0,-1),l7=new TX,u7=new V,d7=new V,f7=new TX,p7=new tX,m7=new EX,eue=D8.flipX();m7.depthTexture=new UQ(1,1);let h7=!1;var tue=class e extends L3{static get type(){return`ReflectorNode`}constructor(e={}){super(e.defaultTexture||m7.texture,eue),this._reflectorBaseNode=e.reflector||new nue(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw Error(`THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. `);this._depthNode=U(new e({defaultTexture:m7.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){let e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},nue=class extends Q${static get type(){return`ReflectorBaseNode`}constructor(e,t={}){super();let{target:n=new OZ,resolution:r=1,generateMipmaps:i=!1,bounces:a=!0,depth:o=!1}=t;this.textureNode=e,this.target=n,this.resolution=r,this.generateMipmaps=i,this.bounces=a,this.depth=o,this.updateBeforeType=a?U$.RENDER:U$.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let n=this.resolution;t.getDrawingBufferSize(p7),e.setSize(Math.round(p7.width*n),Math.round(p7.height*n))}setup(e){return this._updateResolution(m7,e.renderer),super.setup(e)}dispose(){super.dispose();for(let e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new EX(0,0,{type:YJ}),this.generateMipmaps===!0&&(t.texture.minFilter=WJ,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new UQ),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&h7)return!1;h7=!0;let{scene:t,camera:n,renderer:r,material:i}=e,{target:a}=this,o=this.getVirtualCamera(n),s=this.getRenderTarget(o);r.getDrawingBufferSize(p7),this._updateResolution(s,r),a7.setFromMatrixPosition(a.matrixWorld),o7.setFromMatrixPosition(n.matrixWorld),s7.extractRotation(a.matrixWorld),i7.set(0,0,1),i7.applyMatrix4(s7),u7.subVectors(a7,o7);let c=u7.dot(i7)>0,l=!1;if(c===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){h7=!1;return}l=!0}u7.reflect(i7).negate(),u7.add(a7),s7.extractRotation(n.matrixWorld),c7.set(0,0,-1),c7.applyMatrix4(s7),c7.add(o7),d7.subVectors(a7,c7),d7.reflect(i7).negate(),d7.add(a7),o.coordinateSystem=n.coordinateSystem,o.position.copy(u7),o.up.set(0,1,0),o.up.applyMatrix4(s7),o.up.reflect(i7),o.lookAt(d7),o.near=n.near,o.far=n.far,o.updateMatrixWorld(),o.projectionMatrix.copy(n.projectionMatrix),r7.setFromNormalAndCoplanarPoint(i7,a7),r7.applyMatrix4(o.matrixWorldInverse),l7.set(r7.normal.x,r7.normal.y,r7.normal.z,r7.constant);let u=o.projectionMatrix;f7.x=(Math.sign(l7.x)+u.elements[8])/u.elements[0],f7.y=(Math.sign(l7.y)+u.elements[9])/u.elements[5],f7.z=-1,f7.w=(1+u.elements[10])/u.elements[14],l7.multiplyScalar(1/l7.dot(f7));let d=0;u.elements[2]=l7.x,u.elements[6]=l7.y,u.elements[10]=r.coordinateSystem===EY?l7.z-d:l7.z+1-d,u.elements[14]=l7.w,this.textureNode.value=s.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=s.depthTexture),i.visible=!1;let f=r.getRenderTarget(),p=r.getMRT(),m=r.autoClear;r.setMRT(null),r.setRenderTarget(s),r.autoClear=!0,l?(r.clear(),this.hasOutput=!1):(r.render(t,o),this.hasOutput=!0),r.setMRT(p),r.setRenderTarget(f),r.autoClear=m,i.visible=!0,h7=!1,this.forceUpdate=!1}};const rue=e=>U(new tue(e)),g7=new s$(-1,1,1,-1,0,1);var iue=class extends fQ{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute(`position`,new iQ([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new iQ(t,2))}};const aue=new iue;var _7=class extends wQ{constructor(e=null){super(aue,e),this.camera=g7,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,g7)}render(e){e.render(this,g7)}};const oue=new tX;var sue=class extends L3{static get type(){return`RTTNode`}constructor(e,t=null,n=null,r={type:YJ}){let i=new EX(t,n,r);super(i.texture,N3()),this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new _7(new Y8),this.updateBeforeType=U$.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name=`RTT`,this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;let n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();let t=e.getSize(oue);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;let t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){let e=new L3(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}};const v7=(e,...t)=>U(new sue(U(e),...t)),cue=(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():v7(e,...t),y7=K(([e,t,n],r)=>{let i;r.renderer.coordinateSystem===EY?(e=Y(e.x,e.y.oneMinus()).mul(2).sub(1),i=i0(X(e,t),1)):i=i0(X(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let a=i0(n.mul(i));return a.xyz.div(a.w)}),lue=K(([e,t])=>{let n=t.mul(i0(e,1)),r=n.xy.div(n.w).mul(.5).add(.5).toVar();return Y(r.x,r.y.oneMinus())}),uue=K(([e,t,n])=>{let r=P3(z3(t)),i=Q1(e.mul(r)).toVar(),a=z3(t,i).toVar(),o=z3(t,i.sub(Q1(2,0))).toVar(),s=z3(t,i.sub(Q1(1,0))).toVar(),c=z3(t,i.add(Q1(1,0))).toVar(),l=z3(t,i.add(Q1(2,0))).toVar(),u=z3(t,i.add(Q1(0,2))).toVar(),d=z3(t,i.add(Q1(0,1))).toVar(),f=z3(t,i.sub(Q1(0,1))).toVar(),p=z3(t,i.sub(Q1(0,2))).toVar(),m=c4(f2(q(2).mul(s).sub(o),a)).toVar(),h=c4(f2(q(2).mul(c).sub(l),a)).toVar(),g=c4(f2(q(2).mul(d).sub(u),a)).toVar(),_=c4(f2(q(2).mul(f).sub(p),a)).toVar(),v=y7(e,a,n).toVar(),y=m.lessThan(h).select(v.sub(y7(e.sub(Y(q(1).div(r.x),0)),s,n)),v.negate().add(y7(e.add(Y(q(1).div(r.x),0)),c,n))),b=g.lessThan(_).select(v.sub(y7(e.add(Y(0,q(1).div(r.y))),d,n)),v.negate().add(y7(e.sub(Y(0,q(1).div(r.y))),f,n)));return e4(k4(y,b))});var due=class extends LQ{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}},fue=class extends tQ{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}};const pue=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=N$(`float`)):(n=P$(t),r=N$(t));let i=new fue(e,n,r),a=f8(i,t,e);return a},mue=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=N$(`float`)):(n=P$(t),r=N$(t));let i=new due(e,n,r),a=f8(i,t,e);return a};var hue=class extends Q${static get type(){return`PointUVNode`}constructor(){super(`vec2`),this.isPointUVNode=!0}generate(){return`vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )`}};const gue=G(hue),b7=new dZ,x7=new tZ;var S7=class e extends Q${static get type(){return`SceneNode`}constructor(t=e.BACKGROUND_BLURRINESS,n=null){super(),this.scope=t,this.scene=n}setup(t){let n=this.scope,r=this.scene===null?t.scene:this.scene,i;return n===e.BACKGROUND_BLURRINESS?i=P6(`backgroundBlurriness`,`float`,r):n===e.BACKGROUND_INTENSITY?i=P6(`backgroundIntensity`,`float`,r):n===e.BACKGROUND_ROTATION?i=n2(`mat4`).label(`backgroundRotation`).setGroup($0).onRenderUpdate(()=>{let e=r.background;return e!==null&&e.isTexture&&e.mapping!==PJ?(b7.copy(r.backgroundRotation),b7.x*=-1,b7.y*=-1,b7.z*=-1,x7.makeRotationFromEuler(b7)):x7.identity(),x7}):console.error(`THREE.SceneNode: Unknown scope:`,n),i}};S7.BACKGROUND_BLURRINESS=`backgroundBlurriness`,S7.BACKGROUND_INTENSITY=`backgroundIntensity`,S7.BACKGROUND_ROTATION=`backgroundRotation`;const _ue=G(S7,S7.BACKGROUND_BLURRINESS),vue=G(S7,S7.BACKGROUND_INTENSITY),yue=G(S7,S7.BACKGROUND_ROTATION);var bue=class extends L3{static get type(){return`StorageTextureNode`}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=G$.WRITE_ONLY}getInputType(){return`storageTexture`}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let n;return n=this.storeNode===null?super.generate(e,t):this.generateStore(e),n}toReadWrite(){return this.setAccess(G$.READ_WRITE)}toReadOnly(){return this.setAccess(G$.READ_ONLY)}toWriteOnly(){return this.setAccess(G$.WRITE_ONLY)}generateStore(e){let t=e.getNodeProperties(this),{uvNode:n,storeNode:r,depthNode:i}=t,a=super.generate(e,`property`),o=n.build(e,`uvec2`),s=r.build(e,`vec4`),c=i?i.build(e,`int`):null,l=e.generateTextureStore(e,a,o,c,s);e.addLineFlowCode(l,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e}};const C7=W(bue).setParameterLength(1,3),xue=(e,t,n)=>{let r=C7(e,t,n);return n!==null&&r.toStack(),r},Sue=K(({texture:e,uv:t})=>{let n=1e-4,r=X().toVar();return K1(t.x.lessThan(n),()=>{r.assign(X(1,0,0))}).ElseIf(t.y.lessThan(n),()=>{r.assign(X(0,1,0))}).ElseIf(t.z.lessThan(n),()=>{r.assign(X(0,0,1))}).ElseIf(t.x.greaterThan(1-n),()=>{r.assign(X(-1,0,0))}).ElseIf(t.y.greaterThan(1-n),()=>{r.assign(X(0,-1,0))}).ElseIf(t.z.greaterThan(1-n),()=>{r.assign(X(0,0,-1))}).Else(()=>{let n=.01,i=e.sample(t.add(X(-.01,0,0))).r.sub(e.sample(t.add(X(n,0,0))).r),a=e.sample(t.add(X(0,-.01,0))).r.sub(e.sample(t.add(X(0,n,0))).r),o=e.sample(t.add(X(0,0,-.01))).r.sub(e.sample(t.add(X(0,0,n))).r);r.assign(X(i,a,o))}),r.normalize()});var Cue=class extends L3{static get type(){return`Texture3DNode`}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return`texture3D`}getDefaultUV(){return X(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(t=this.sampler?t.flipY():t.setY(J(P3(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,`vec3`)}normal(e){return Sue({texture:this,uv:e})}};const wue=W(Cue).setParameterLength(1,3);var Tue=class extends N6{static get type(){return`UserDataNode`}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData===null?e.object.userData:this.userData,this.reference}};const Eue=(e,t,n)=>U(new Tue(e,t,n)),w7=new WeakMap;var Due=class extends t1{static get type(){return`VelocityNode`}constructor(){super(`vec2`),this.projectionMatrix=null,this.updateType=U$.OBJECT,this.updateAfterType=U$.OBJECT,this.previousModelWorldMatrix=n2(new tZ),this.previousProjectionMatrix=n2(new tZ).setGroup($0),this.previousCameraViewMatrix=n2(new tZ)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){let r=E7(n);this.previousModelWorldMatrix.value.copy(r);let i=T7(t);i.frameId!==e&&(i.frameId=e,i.previousProjectionMatrix===void 0?(i.previousProjectionMatrix=new tZ,i.previousCameraViewMatrix=new tZ,i.currentProjectionMatrix=new tZ,i.currentCameraViewMatrix=new tZ,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){E7(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?J3:n2(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(n6).mul(a6),r=this.previousProjectionMatrix.mul(t).mul(o6),i=n.xy.div(n.w),a=r.xy.div(r.w),o=f2(i,a);return o}};function T7(e){let t=w7.get(e);return t===void 0&&(t={},w7.set(e,t)),t}function E7(e,t=0){let n=T7(e),r=n[t];return r===void 0&&(n[t]=r=new tZ,n[t].copy(e.matrixWorld)),r}const Oue=G(Due),D7=K(([e,t])=>S4(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:`blendBurn`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),O7=K(([e,t])=>S4(e.div(t.oneMinus()),1)).setLayout({name:`blendDodge`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),k7=K(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:`blendScreen`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),A7=K(([e,t])=>L4(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),w4(.5,e))).setLayout({name:`blendOverlay`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),kue=K(([e,t])=>{let n=t.a.add(e.a.mul(t.a.oneMinus()));return i0(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(n),n)}).setLayout({name:`blendColor`,type:`vec4`,inputs:[{name:`base`,type:`vec4`},{name:`blend`,type:`vec4`}]}),Aue=K(([e])=>i0(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),jue=K(([e])=>(K1(e.a.equal(0),()=>i0(0)),i0(e.rgb.div(e.a),e.a)),{color:`vec4`,return:`vec4`}),Mue=(...e)=>(console.warn(`THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.`),D7(e)),Nue=(...e)=>(console.warn(`THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.`),O7(e)),Pue=(...e)=>(console.warn(`THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.`),k7(e)),Fue=(...e)=>(console.warn(`THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.`),A7(e)),Iue=K(([e])=>j7(e.rgb)),Lue=K(([e,t=q(1)])=>t.mix(j7(e.rgb),e.rgb)),Rue=K(([e,t=q(1)])=>{let n=d2(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return L4(e.rgb,r,i)}),zue=K(([e,t=q(1)])=>{let n=X(.57735,.57735,.57735),r=t.cos();return X(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(O4(n,e.rgb).mul(r.oneMinus())))))}),j7=(e,t=X(mX.getLuminanceCoefficients(new V)))=>O4(e,t),Bue=K(([e,t=X(1),n=X(0),r=X(1),i=q(1),a=X(mX.getLuminanceCoefficients(new V,uY))])=>{let o=e.rgb.dot(X(a)),s=C4(e.rgb.mul(t).add(n),0).toVar(),c=s.pow(r).toVar();return K1(s.r.greaterThan(0),()=>{s.r.assign(c.r)}),K1(s.g.greaterThan(0),()=>{s.g.assign(c.g)}),K1(s.b.greaterThan(0),()=>{s.b.assign(c.b)}),s.assign(o.add(s.sub(o).mul(i))),i0(s.rgb,e.a)});var Vue=class extends t1{static get type(){return`PosterizeNode`}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){let{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}};const Hue=W(Vue).setParameterLength(2),M7=new tX;var N7=class extends L3{static get type(){return`PassTextureNode`}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},P7=class extends N7{static get type(){return`PassMultipleTextureNode`}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}},F7=class e extends t1{static get type(){return`PassNode`}constructor(e,t,n,r={}){super(`vec4`),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;let i=new UQ;i.isRenderTargetTexture=!0,i.name=`depth`;let a=new EX(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:YJ,...r});a.texture.name=`output`,a.depthTexture=i,this.renderTarget=a,this._textures={output:a.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=n2(0),this._cameraFar=n2(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=U$.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(t===void 0){let n=this.renderTarget.texture;t=n.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e=`output`){let t=this._textureNodes[e];return t===void 0&&(t=U(new P7(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e=`output`){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=U(new P7(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e=`depth`){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=B8(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e=`depth`){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=R8(i,n,r)}return t}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,t.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.texture.type=t.getColorBufferType(),this.scope===e.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n}=this,r,i,a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(i=1,r=t.xr.getCamera(),t.xr.updateCamera(r),M7.set(a.width,a.height)):(r=this.camera,i=t.getPixelRatio(),t.getSize(M7)),this._pixelRatio=i,this.setSize(M7.width,M7.height);let o=t.getRenderTarget(),s=t.getMRT(),c=r.layers.mask;for(let e in this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask),this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(o),t.setMRT(s),r.layers.mask=c}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio*this._resolution,r=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}};F7.COLOR=`color`,F7.DEPTH=`depth`;const Uue=(e,t,n)=>U(new F7(F7.COLOR,e,t,n)),Wue=(e,t)=>U(new N7(e,t)),Gue=(e,t,n)=>U(new F7(F7.DEPTH,e,t,n));var Kue=class extends F7{static get type(){return`ToonOutlinePassNode`}constructor(e,t,n,r,i){super(F7.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){let{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((e,n,r,i,a,o,s,c)=>{if((a.isMeshToonMaterial||a.isMeshToonNodeMaterial)&&a.wireframe===!1){let l=this._getOutlineMaterial(a);t.renderObject(e,n,r,i,l,o,s,c)}t.renderObject(e,n,r,i,a,o,s,c)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){let e=new Y8;e.isMeshToonOutlineMaterial=!0,e.name=`Toon_Outline`,e.side=TJ;let t=m6.negate(),n=J3.mul(n6),r=q(1),i=n.mul(i0(a6,1)),a=n.mul(i0(a6.add(t),1)),o=e4(i.sub(a));return e.vertexNode=i.add(o.mul(this.thicknessNode).mul(i.w).mul(r)),e.colorNode=i0(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}};const que=(e,t,n=new qZ(0,0,0),r=.003,i=1)=>U(new Kue(e,t,U(n),U(r),U(i))),Jue=K(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Yue=K(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:`reinhardToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Xue=K(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);let n=e.mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(r).pow(2.2)}).setLayout({name:`cineonToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Zue=K(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)}),Que=K(([e,t])=>{let n=l0(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=l0(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=Zue(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),$ue=l0(X(1.6605,-.1246,-.0182),X(-.5876,1.1329,-.1006),X(-.0728,-.0083,1.1187)),ede=l0(X(.6274,.0691,.0164),X(.3293,.9195,.088),X(.0433,.0113,.8956)),tde=K(([e])=>{let t=X(e).toVar(),n=X(t.mul(t)).toVar(),r=X(n.mul(n)).toVar();return q(15.5).mul(r.mul(n)).sub(p2(40.14,r.mul(t))).add(p2(31.96,r).sub(p2(6.868,n.mul(t))).add(p2(.4298,n).add(p2(.1191,t).sub(.00232))))}),nde=K(([e,t])=>{let n=X(e).toVar(),r=l0(X(.856627153315983,.137318972929847,.11189821299995),X(.0951212405381588,.761241990602591,.0767994186031903),X(.0482516061458583,.101439036467562,.811302368396859)),i=l0(X(1.1271005818144368,-.1413297634984383,-.14132976349843826),X(-.11060664309660323,1.157823702216272,-.11060664309660294),X(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=q(-12.47393),o=q(4.026069);return n.mulAssign(t),n.assign(ede.mul(n)),n.assign(r.mul(n)),n.assign(C4(n,1e-10)),n.assign(Y2(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign(R4(n,0,1)),n.assign(tde(n)),n.assign(i.mul(n)),n.assign(A4(C4(X(0),n),X(2.2))),n.assign($ue.mul(n)),n.assign(R4(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),rde=K(([e,t])=>{let n=q(.76),r=q(.15);e=e.mul(t);let i=S4(e.r,S4(e.g,e.b)),a=X4(i.lessThan(.08),i.sub(p2(6.25,i.mul(i))),.04);e.subAssign(a);let o=C4(e.r,C4(e.g,e.b));K1(o.lessThan(n),()=>e);let s=f2(1,n),c=f2(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=f2(1,m2(1,r.mul(o.sub(c)).add(1)));return L4(e,X(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]});var I7=class extends Q${static get type(){return`CodeNode`}constructor(e=``,t=[],n=``){super(`code`),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e);let n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}};const L7=W(I7).setParameterLength(1,3),ide=(e,t)=>L7(e,t,`js`),ade=(e,t)=>L7(e,t,`wgsl`),ode=(e,t)=>L7(e,t,`glsl`);var sde=class extends I7{static get type(){return`FunctionNode`}constructor(e=``,t=[],n=``){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);let n=this.getNodeFunction(e),r=n.name,i=n.type,a=e.getCodeFromNode(this,i);r!==``&&(a.name=r);let o=e.getPropertyName(a),s=this.getNodeFunction(e).getCode(o);return a.code=s+`
431
- `,t===`property`?o:e.format(`${o}()`,i,t)}};const R7=(e,t=[],n=``)=>{for(let e=0;e<t.length;e++){let n=t[e];typeof n==`function`&&(t[e]=n.functionNode)}let r=U(new sde(e,t,n)),i=(...e)=>r.call(...e);return i.functionNode=r,i},cde=(e,t)=>R7(e,t,`glsl`),lde=(e,t)=>R7(e,t,`wgsl`);var ude=class extends Q${static get type(){return`ScriptableValueNode`}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new DY,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType===`URL`&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:`change`}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:`refresh`})}getValue(){let e=this.value;if(e&&this._cache===null&&this.inputType===`URL`&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType===`URL`||this.inputType===`String`)&&typeof e.value==`string`||this.inputType===`Number`&&typeof e.value==`number`||this.inputType===`Vector2`&&e.value.isVector2||this.inputType===`Vector3`&&e.value.isVector3||this.inputType===`Vector4`&&e.value.isVector4||this.inputType===`Color`&&e.value.isColor||this.inputType===`Matrix3`&&e.value.isMatrix3||this.inputType===`Matrix4`&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):`float`}setup(){return this.value&&this.value.isNode?this.value:q()}serialize(e){super.serialize(e),this.value===null?e.value=null:this.inputType===`ArrayBuffer`?e.value=B$(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(t=e.inputType===`ArrayBuffer`?V$(e.value):e.inputType===`Texture`?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}};const z7=W(ude).setParameterLength(1);var B7=class extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){let r=t(...n);return this.set(e,r),r}}},dde=class{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){let t=this.parameters[e],n=t?t.getValue():null;return n}};const V7=new B7;var fde=class extends Q${static get type(){return`ScriptableNode`}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new B7,this._output=z7(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:``}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(let t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(let t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){let n=this._outputs;return n[e]===void 0?n[e]=z7(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){let n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener(`refresh`,this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener(`refresh`,this.onRefresh)):n[e]===void 0?(n[e]=z7(t),n[e].events.addEventListener(`refresh`,this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener(`refresh`,this.onRefresh)),this}clearParameters(){for(let e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){let n=this.getObject(),r=n[e];if(typeof r==`function`)return r(...t)}async callAsync(e,...t){let n=this.getObject(),r=n[e];if(typeof r==`function`)return r.constructor.name===`AsyncFunction`?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e===null?this._refresh():this.getOutput(e).refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;let e=()=>this.refresh(),t=(e,t)=>this.setOutput(e,t),n=new dde(this),r=V7.get(`THREE`),i=V7.get(`TSL`),a=this.getMethod(),o=[n,this._local,V7,e,t,r,i];this._object=a(...o);let s=this._object.layout;if(s&&(s.cache===!1&&this._local.clear(),this._output.outputType=s.outputType||null,Array.isArray(s.elements)))for(let e of s.elements){let t=e.id||e.name;e.inputType&&(this.getParameter(t)===void 0&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(this.getOutput(t)===void 0&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){for(let t in super.deserialize(e),this.parameters){let e=this.parameters[t];e.isScriptableNode&&(e=e.getDefaultOutput()),e.events.addEventListener(`refresh`,this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){let e=this.getDefaultOutput().value;return e&&e.isNode?e:q()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;let e=[`parameters`,`local`,`global`,`refresh`,`setOutput`,`THREE`,`TSL`],t=[`layout`,`init`,`main`,`dispose`],n=t.join(`, `),r=`var `+n+`; var output = {};
430
+ `).removeFlowTab();return e.addFlowTab(),a}};const g8=(...e)=>U(new uce(H1(e,`int`))).toStack(),dce=()=>D3(`continue`).toStack(),_8=()=>D3(`break`).toStack(),fce=(...e)=>(console.warn(`THREE.TSL: loop() has been renamed to Loop().`),g8(...e)),v8=new WeakMap,y8=new eX,b8=K(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=J(o8).mul(n).add(a),s=o.div(r),c=o.sub(s.mul(r)),l=z3(e,Q1(c,s)).depth(i).xyz;return l.mul(t)});function pce(e){let t=e.morphAttributes.position!==void 0,n=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=i===void 0?0:i.length,o=v8.get(e);if(o===void 0||o.count!==a){o!==void 0&&o.texture.dispose();let i=e.morphAttributes.position||[],s=e.morphAttributes.normal||[],c=e.morphAttributes.color||[],l=0;t===!0&&(l=1),n===!0&&(l=2),r===!0&&(l=3);let u=e.attributes.position.count*l,d=1,f=4096;u>f&&(d=Math.ceil(u/f),u=f);let p=new Float32Array(u*d*4*a),m=new nX(p,u,d,a);m.type=CJ,m.needsUpdate=!0;let h=l*4;for(let e=0;e<a;e++){let a=i[e],o=s[e],l=c[e],f=u*d*4*e;for(let e=0;e<a.count;e++){let i=e*h;t===!0&&(y8.fromBufferAttribute(a,e),p[f+i+0]=y8.x,p[f+i+1]=y8.y,p[f+i+2]=y8.z,p[f+i+3]=0),n===!0&&(y8.fromBufferAttribute(o,e),p[f+i+4]=y8.x,p[f+i+5]=y8.y,p[f+i+6]=y8.z,p[f+i+7]=0),r===!0&&(y8.fromBufferAttribute(l,e),p[f+i+8]=y8.x,p[f+i+9]=y8.y,p[f+i+10]=y8.z,p[f+i+11]=l.itemSize===4?y8.w:1)}}o={count:a,texture:m,stride:l,size:new AY(u,d)},v8.set(e,o);function g(){m.dispose(),v8.delete(e),e.removeEventListener(`dispose`,g)}e.addEventListener(`dispose`,g)}return o}var mce=class extends Q${static get type(){return`MorphNode`}constructor(e){super(`void`),this.mesh=e,this.morphBaseInfluence=n2(1),this.updateType=U$.OBJECT}setup(e){let{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute(`normal`)&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=i===void 0?0:i.length,{texture:o,stride:s,size:c}=pce(t);n===!0&&a6.mulAssign(this.morphBaseInfluence),r===!0&&m6.mulAssign(this.morphBaseInfluence);let l=J(c.width);g8(a,({i:e})=>{let t=q(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?t.assign(z3(this.mesh.morphTexture,Q1(J(e).add(1),J(s8))).r):t.assign(P6(`morphTargetInfluences`,`float`).element(e).toVar()),K1(t.notEqual(0),()=>{n===!0&&a6.addAssign(b8({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:J(0)})),r===!0&&m6.addAssign(b8({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:J(1)}))})})}update(){let e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}};const x8=W(mce).setParameterLength(1);var S8=class extends Q${static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},hce=class extends S8{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},gce=class extends Q4{static get type(){return`LightingContextNode`}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){let{backdropNode:e,backdropAlphaNode:t}=this,n=X().toVar(`directDiffuse`),r=X().toVar(`directSpecular`),i=X().toVar(`indirectDiffuse`),a=X().toVar(`indirectSpecular`),o={directDiffuse:n,directSpecular:r,indirectDiffuse:i,indirectSpecular:a},s={radiance:X().toVar(`radiance`),irradiance:X().toVar(`irradiance`),iblIrradiance:X().toVar(`iblIrradiance`),ambientOcclusion:q(1).toVar(`ambientOcclusion`),reflectedLight:o,backdrop:e,backdropAlpha:t};return s}setup(e){return this.value=this._value||=this.getContext(),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}};const C8=W(gce);var _ce=class extends S8{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}};let w8,T8;var E8=class e extends Q${static get type(){return`ScreenNode`}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===e.VIEWPORT?`vec4`:`vec2`}getUpdateType(){let t=U$.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT)&&(t=U$.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(T8),T8.multiplyScalar(t.getPixelRatio())):T8.copy(n.viewport):n===null?t.getDrawingBufferSize(w8):(w8.width=n.width,w8.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?n2(w8||=new AY):t===e.VIEWPORT?n2(T8||=new eX):Y(k8.div(O8)),n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(O8).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};E8.COORDINATE=`coordinate`,E8.VIEWPORT=`viewport`,E8.SIZE=`size`,E8.UV=`uv`;const D8=G(E8,E8.UV),O8=G(E8,E8.SIZE),k8=G(E8,E8.COORDINATE),A8=G(E8,E8.VIEWPORT),j8=A8.zw,M8=k8.sub(A8.xy),vce=M8.div(j8),yce=K(()=>(console.warn(`THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.`),O8),`vec2`).once()(),bce=K(()=>(console.warn(`THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.`),D8),`vec2`).once()(),xce=K(()=>(console.warn(`THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.`),D8.flipY()),`vec2`).once()(),N8=new AY;var P8=class extends L3{static get type(){return`ViewportTextureNode`}constructor(e=D8,t=null,n=null){n===null&&(n=new vQ,n.minFilter=vJ),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=U$.FRAME}updateBefore(e){let t=e.renderer;t.getDrawingBufferSize(N8);let n=this.value;(n.image.width!==N8.width||n.image.height!==N8.height)&&(n.image.width=N8.width,n.image.height=N8.height,n.needsUpdate=!0);let r=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=r}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}};const Sce=W(P8).setParameterLength(0,3),Cce=W(P8,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let F8=null;var wce=class extends P8{static get type(){return`ViewportDepthTextureNode`}constructor(e=D8,t=null){F8===null&&(F8=new yQ),super(e,t,F8)}};const I8=W(wce).setParameterLength(0,2);var L8=class e extends Q${static get type(){return`ViewportDepthNode`}constructor(e,t=null){super(`float`),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(t){let{scope:n}=this;return n===e.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:n}=this,r=this.valueNode,i=null;if(n===e.DEPTH_BASE)r!==null&&(i=H8().assign(r));else if(n===e.DEPTH)i=t.isPerspectiveCamera?z8(l6.z,K3,q3):R8(l6.z,K3,q3);else if(n===e.LINEAR_DEPTH)if(r!==null)if(t.isPerspectiveCamera){let e=B8(r,K3,q3);i=R8(e,K3,q3)}else i=r;else i=R8(l6.z,K3,q3);return i}};L8.DEPTH_BASE=`depthBase`,L8.DEPTH=`depth`,L8.LINEAR_DEPTH=`linearDepth`;const R8=(e,t,n)=>e.add(t).div(t.sub(n)),Tce=(e,t,n)=>t.sub(n).mul(e).sub(t),z8=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),B8=(e,t,n)=>t.mul(n).div(n.sub(t).mul(e).sub(n)),V8=(e,t,n)=>{t=t.max(1e-6).toVar();let r=Y2(e.negate().div(t)),i=Y2(n.div(t));return r.div(i)},Ece=(e,t,n)=>{let r=e.mul(J2(n.div(t)));return q(Math.E).pow(r).mul(t).negate()},H8=W(L8,L8.DEPTH_BASE),U8=G(L8,L8.DEPTH),W8=W(L8,L8.LINEAR_DEPTH).setParameterLength(0,1),Dce=W8(I8());U8.assign=e=>H8(e);var G8=class e extends Q${static get type(){return`ClippingNode`}constructor(t=e.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let n=t.clippingContext,{intersectionPlanes:r,unionPlanes:i}=n;return this.hardwareClipping=t.material.hardwareClipping,this.scope===e.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,i):this.scope===e.HARDWARE?this.setupHardwareClipping(i,t):this.setupDefault(r,i)}setupAlphaToCoverage(e,t){return K(()=>{let n=q().toVar(`distanceToPlane`),r=q().toVar(`distanceToGradient`),i=q(1).toVar(`clipOpacity`),a=t.length;if(this.hardwareClipping===!1&&a>0){let e=U3(t);g8(a,({i:t})=>{let a=e.element(t);n.assign(l6.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(V4(r.negate(),r,n))})}let o=e.length;if(o>0){let t=U3(e),a=q(1).toVar(`intersectionClipOpacity`);g8(o,({i:e})=>{let i=t.element(e);n.assign(l6.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(V4(r.negate(),r,n).oneMinus())}),i.mulAssign(a.oneMinus())}x0.a.mulAssign(i),x0.a.equal(0).discard()})()}setupDefault(e,t){return K(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let e=U3(t);g8(n,({i:t})=>{let n=e.element(t);l6.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=U3(e),n=Z1(!0).toVar(`clipped`);g8(r,({i:e})=>{let r=t.element(e);n.assign(l6.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),K(()=>{let r=U3(e),i=W3(t.getClipDistance());g8(n,({i:e})=>{let t=r.element(e),n=l6.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};G8.ALPHA_TO_COVERAGE=`alphaToCoverage`,G8.DEFAULT=`default`,G8.HARDWARE=`hardware`;const Oce=()=>U(new G8),kce=()=>U(new G8(G8.ALPHA_TO_COVERAGE)),Ace=()=>U(new G8(G8.HARDWARE)),jce=.05,K8=K(([e])=>t4(p2(1e4,n4(p2(17,e.x).add(p2(.1,e.y)))).mul(d2(.1,c4(n4(p2(13,e.y).add(e.x))))))),q8=K(([e])=>K8(Y(K8(e.xy),e.z))),Mce=K(([e])=>{let t=C4(u4(p4(e.xyz)),u4(m4(e.xyz))),n=q(1).div(q(jce).mul(t)).toVar(`pixScale`),r=Y(q2(Q2(Y2(n))),q2($2(Y2(n)))),i=Y(q8(Q2(r.x.mul(e.xyz))),q8(Q2(r.y.mul(e.xyz)))),a=t4(Y2(n)),o=d2(p2(a.oneMinus(),i.x),p2(a,i.y)),s=S4(a,a.oneMinus()),c=X(o.mul(o).div(p2(2,s).mul(f2(1,s))),o.sub(p2(.5,s)).div(f2(1,s)),f2(1,f2(1,o).mul(f2(1,o)).div(p2(2,s).mul(f2(1,s))))),l=o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z);return R4(l,1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]});var Nce=class extends j3{static get type(){return`VertexColorNode`}constructor(e){super(null,`vec4`),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return`color`+(e>0?e:``)}generate(e){let t=this.getAttributeName(e),n=e.hasGeometryAttribute(t),r;return r=n===!0?super.generate(e):e.generateConst(this.nodeType,new eX(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}};const J8=(e=0)=>U(new Nce(e));var Y8=class extends TZ{static get type(){return`NodeMaterial`}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,`shadowPositionNode`,{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn(`THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".`),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+O$(this)}build(e){this.setup(e)}setupObserver(e){return new C$(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,n=t.getRenderTarget();e.addStack();let r=this.setupVertex(e),i=this.vertexNode||r;e.stack.outputNode=i,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow(`vertex`,e.removeStack()),e.addStack();let a,o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n===null?t.depth===!0&&this.setupDepth(e):n.depthBuffer===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);let r=this.setupLighting(e);o!==null&&e.stack.add(o);let i=i0(r,x0.a).max(0);a=this.setupOutput(e,i),z0.assign(a);let s=this.outputNode!==null;if(s&&(a=this.outputNode),n!==null){let e=t.getMRT(),n=this.mrtNode;e===null?n!==null&&(a=n):(s&&z0.assign(a),a=e,n!==null&&(a=e.merge(n)))}}else{let t=this.fragmentNode;t.isOutputStructNode!==!0&&(t=i0(t)),a=this.setupOutput(e,t)}e.stack.outputNode=a,e.addFlow(`fragment`,e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:n}=e.clippingContext,r=null;if(t.length>0||n.length>0){let t=e.renderer.samples;this.alphaToCoverage&&t>1?r=kce():e.stack.add(Oce())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable(`clipDistance`)&&(e.stack.add(Ace()),this.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:n}=e,r=this.depthNode;if(r===null){let e=t.getMRT();e&&e.has(`depth`)?r=e.get(`depth`):t.logarithmicDepthBuffer===!0&&(r=n.isPerspectiveCamera?V8(l6.z,K3,q3):R8(l6.z,K3,q3))}r!==null&&U8.assign(r).toStack()}setupPositionView(){return n6.mul(a6).xyz}setupModelViewProjection(){return J3.mul(l6)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),i8}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&x8(t).toStack(),t.isSkinnedMesh===!0&&h8(t).toStack(),this.displacementMap){let e=I6(`displacementMap`,`texture`),t=I6(`displacementScale`,`float`),n=I6(`displacementBias`,`float`);a6.addAssign(m6.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&d8(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&u8(t).toStack(),this.positionNode!==null&&a6.assign(S3(this.positionNode,`POSITION`)),a6}setupDiffuseColor({object:e,geometry:t}){this.maskNode!==null&&Z1(this.maskNode).not().discard();let n=this.colorNode?i0(this.colorNode):Z6;if(this.vertexColors===!0&&t.hasAttribute(`color`)&&(n=n.mul(J8())),e.instanceColor){let e=b0(`vec3`,`vInstanceColor`);n=e.mul(n)}if(e.isBatchedMesh&&e._colorsTexture){let e=b0(`vec3`,`vBatchColor`);n=e.mul(n)}x0.assign(n);let r=this.opacityNode?q(this.opacityNode):$6;x0.a.assign(x0.a.mul(r));let i=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(i=this.alphaTestNode===null?X6:q(this.alphaTestNode),x0.a.lessThanEqual(i).discard()),this.alphaHash===!0&&x0.a.lessThan(Mce(a6)).discard();let a=this.transparent===!1&&this.blending===nJ&&this.alphaToCoverage===!1;a?x0.a.assign(1):i===null&&x0.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?X(0):x0.rgb}setupNormal(){return this.normalNode?X(this.normalNode):e8}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?I6(`envMap`,`cubeTexture`):I6(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new _ce(t8)),t}setupLights(e){let t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){let e=this.aoNode===null?n8:this.aoNode;t.push(new hce(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=this,a=this.lights===!0||this.lightsNode!==null,o=a?this.setupLights(e):null,s=this.setupOutgoingLight(e);if(o&&o.getScope().hasLights){let t=this.setupLightingModel(e)||null;s=C8(o,t,n,r)}else n!==null&&(s=X(r===null?n:L4(s,n,r)));return(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(S0.assign(X(i||Q6)),s=s.add(S0)),s}setupFog(e,t){let n=e.fogNode;return n&&(z0.assign(t),t=i0(n)),t}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),t}setDefaultValues(e){for(let t in e){let n=e[t];this[t]===void 0&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===void 0&&t[e].get!==void 0&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{},nodes:{}});let n=TZ.prototype.toJSON.call(this,e),r=k$(this);n.inputNodes={};for(let{property:t,childNode:i}of r)n.inputNodes[t]=i.toJSON(e).uuid;function i(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=i(e.textures),r=i(e.images),a=i(e.nodes);t.length>0&&(n.textures=t),r.length>0&&(n.images=r),a.length>0&&(n.nodes=a)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}};let X8=null;var Pce=class extends P8{static get type(){return`ViewportSharedTextureNode`}constructor(e=D8,t=null){X8===null&&(X8=new vQ),super(e,t,X8)}updateReference(){return this}};const Fce=W(Pce).setParameterLength(0,2),Ice=e=>U(e).mul(.5).add(.5),Lce=e=>U(e).mul(2).sub(1);var Rce=class extends t1{static get type(){return`EquirectUVNode`}constructor(e=c6){super(`vec2`),this.dirNode=e}setup(){let e=this.dirNode,t=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Y(t,n)}};const Z8=W(Rce).setParameterLength(0,1),Q8=K(({f0:e,f90:t,dotVH:n})=>{let r=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),zce=K(e=>e.diffuseColor.mul(1/Math.PI)),$8=K(e=>{if(e.geometry.hasAttribute(`normal`)===!1)return q(0);let t=g6.dFdx().abs().max(g6.dFdy().abs()),n=t.x.max(t.y).max(t.z);return n}),Bce=K(e=>{let{roughness:t}=e,n=$8(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),e5=K(({alpha:e,dotNL:t,dotNV:n})=>{let r=e.pow2(),i=t.mul(r.add(r.oneMinus().mul(n.pow2())).sqrt()),a=n.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return m2(.5,i.add(a).max(R2))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),Vce=K(({alphaT:e,alphaB:t,dotTV:n,dotBV:r,dotTL:i,dotBL:a,dotNV:o,dotNL:s})=>{let c=s.mul(X(e.mul(n),t.mul(r),o).length()),l=o.mul(X(e.mul(i),t.mul(a),s).length()),u=m2(.5,c.add(l));return u.saturate()}).setLayout({name:`V_GGX_SmithCorrelated_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotTV`,type:`float`,qualifier:`in`},{name:`dotBV`,type:`float`,qualifier:`in`},{name:`dotTL`,type:`float`,qualifier:`in`},{name:`dotBL`,type:`float`,qualifier:`in`},{name:`dotNV`,type:`float`,qualifier:`in`},{name:`dotNL`,type:`float`,qualifier:`in`}]}),t5=K(({alpha:e,dotNH:t})=>{let n=e.pow2(),r=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:`D_GGX`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNH`,type:`float`}]}),Hce=q(1/Math.PI),Uce=K(({alphaT:e,alphaB:t,dotNH:n,dotTH:r,dotBH:i})=>{let a=e.mul(t),o=X(t.mul(r),e.mul(i),a.mul(n)),s=o.dot(o),c=a.div(s);return Hce.mul(a.mul(c.pow2()))}).setLayout({name:`D_GGX_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotNH`,type:`float`,qualifier:`in`},{name:`dotTH`,type:`float`,qualifier:`in`},{name:`dotBH`,type:`float`,qualifier:`in`}]}),Wce=K(e=>{let{lightDirection:t,f0:n,f90:r,roughness:i,f:a,USE_IRIDESCENCE:o,USE_ANISOTROPY:s}=e,c=e.normalView||v6,l=i.pow2(),u=t.add(u6).normalize(),d=c.dot(t).clamp(),f=c.dot(u6).clamp(),p=c.dot(u).clamp(),m=u6.dot(u).clamp(),h=Q8({f0:n,f90:r,dotVH:m}),g,_;if(R1(o)&&(h=k0.mix(h,a)),R1(s)){let e=P0.dot(t),n=P0.dot(u6),r=P0.dot(u),i=F0.dot(t),a=F0.dot(u6),o=F0.dot(u);g=Vce({alphaT:M0,alphaB:l,dotTV:n,dotBV:a,dotTL:e,dotBL:i,dotNV:f,dotNL:d}),_=Uce({alphaT:M0,alphaB:l,dotNH:p,dotTH:r,dotBH:o})}else g=e5({alpha:l,dotNL:d,dotNV:f}),_=t5({alpha:l,dotNH:p});return h.mul(g).mul(_)}),Gce=K(({roughness:e,dotNV:t})=>{let n=i0(-1,-.0275,-.572,.022),r=i0(1,.0425,1.04,-.04),i=e.mul(n).add(r),a=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y),o=Y(-1.04,1.04).mul(a).add(i.zw);return o}).setLayout({name:`DFGApprox`,type:`vec2`,inputs:[{name:`roughness`,type:`float`},{name:`dotNV`,type:`vec3`}]}),Kce=K(({f:e,f90:t,dotVH:n})=>{let r=n.oneMinus().saturate(),i=r.mul(r),a=r.mul(i,i).clamp(0,.9999);return e.sub(X(t).mul(a)).div(a.oneMinus())}).setLayout({name:`Schlick_to_F0`,type:`vec3`,inputs:[{name:`f`,type:`vec3`},{name:`f90`,type:`float`},{name:`dotVH`,type:`float`}]}),n5=1/6,r5=e=>p2(n5,p2(e,p2(e,e.negate().add(3)).sub(3)).add(1)),i5=e=>p2(n5,p2(e,p2(e,p2(3,e).sub(6))).add(4)),a5=e=>p2(n5,p2(e,p2(e,p2(-3,e).add(3)).add(3)).add(1)),o5=e=>p2(n5,A4(e,3)),s5=e=>r5(e).add(i5(e)),c5=e=>a5(e).add(o5(e)),l5=e=>d2(-1,i5(e).div(r5(e).add(i5(e)))),u5=e=>d2(1,o5(e).div(a5(e).add(o5(e)))),d5=(e,t,n)=>{let r=e.uvNode,i=p2(r,t.zw).add(.5),a=Q2(i),o=t4(i),s=s5(o.x),c=c5(o.x),l=l5(o.x),u=u5(o.x),d=l5(o.y),f=u5(o.y),p=Y(a.x.add(l),a.y.add(d)).sub(.5).mul(t.xy),m=Y(a.x.add(u),a.y.add(d)).sub(.5).mul(t.xy),h=Y(a.x.add(l),a.y.add(f)).sub(.5).mul(t.xy),g=Y(a.x.add(u),a.y.add(f)).sub(.5).mul(t.xy),_=s5(o.y).mul(d2(s.mul(e.sample(p).level(n)),c.mul(e.sample(m).level(n)))),v=c5(o.y).mul(d2(s.mul(e.sample(h).level(n)),c.mul(e.sample(g).level(n))));return _.add(v)},qce=K(([e,t=q(3)])=>{let n=Y(e.size(J(t))),r=Y(e.size(J(t.add(1)))),i=m2(1,n),a=m2(1,r),o=d5(e,i0(i,n),Q2(t)),s=d5(e,i0(a,r),$2(t));return t4(t).mix(o,s)}),Jce=X(.04),Yce=q(1),f5=q(1),p5=q(-2),m5=q(.8),h5=q(-1),g5=q(.4),_5=q(2),v5=q(.305),y5=q(3),b5=q(.21),Xce=q(4),x5=q(4),Zce=q(16),Qce=K(([e])=>{let t=X(c4(e)).toVar(),n=q(-1).toVar();return K1(t.x.greaterThan(t.z),()=>{K1(t.x.greaterThan(t.y),()=>{n.assign(X4(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(X4(e.y.greaterThan(0),1,4))})}).Else(()=>{K1(t.z.greaterThan(t.y),()=>{n.assign(X4(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(X4(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),$ce=K(([e,t])=>{let n=Y().toVar();return K1(t.equal(0),()=>{n.assign(Y(e.z,e.y).div(c4(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(Y(e.x.negate(),e.z.negate()).div(c4(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(Y(e.x.negate(),e.y).div(c4(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(Y(e.z.negate(),e.y).div(c4(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(Y(e.x.negate(),e.z).div(c4(e.y)))}).Else(()=>{n.assign(Y(e.x,e.y).div(c4(e.z)))}),p2(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),ele=K(([e])=>{let t=q(0).toVar();return K1(e.greaterThanEqual(m5),()=>{t.assign(f5.sub(e).mul(h5.sub(p5)).div(f5.sub(m5)).add(p5))}).ElseIf(e.greaterThanEqual(g5),()=>{t.assign(m5.sub(e).mul(_5.sub(h5)).div(m5.sub(g5)).add(h5))}).ElseIf(e.greaterThanEqual(v5),()=>{t.assign(g5.sub(e).mul(y5.sub(_5)).div(g5.sub(v5)).add(_5))}).ElseIf(e.greaterThanEqual(b5),()=>{t.assign(v5.sub(e).mul(Xce.sub(y5)).div(v5.sub(b5)).add(y5))}).Else(()=>{t.assign(q(-2).mul(Y2(p2(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),S5=K(([e,t])=>{let n=e.toVar();n.assign(p2(2,n).sub(1));let r=X(n,1).toVar();return K1(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:`getDirection`,type:`vec3`,inputs:[{name:`uv`,type:`vec2`},{name:`face`,type:`float`}]}),C5=K(([e,t,n,r,i,a])=>{let o=q(n),s=X(t),c=R4(ele(o),p5,a),l=t4(c),u=Q2(c),d=X(w5(e,s,u,r,i,a)).toVar();return K1(l.notEqual(0),()=>{let t=X(w5(e,s,u.add(1),r,i,a)).toVar();d.assign(L4(d,t,l))}),d}),w5=K(([e,t,n,r,i,a])=>{let o=q(n).toVar(),s=X(t),c=q(Qce(s)).toVar(),l=q(C4(x5.sub(o),0)).toVar();o.assign(C4(o,x5));let u=q(q2(o)).toVar(),d=Y($ce(s,c).mul(u.sub(2)).add(1)).toVar();return K1(c.greaterThan(2),()=>{d.y.addAssign(u),c.subAssign(3)}),d.x.addAssign(c.mul(u)),d.x.addAssign(l.mul(p2(3,Zce))),d.y.addAssign(p2(4,q2(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.sample(d).grad(Y(),Y())}),T5=K(({envMap:e,mipInt:t,outputDirection:n,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=r4(r),l=n.mul(c).add(i.cross(n).mul(n4(r))).add(i.mul(i.dot(n).mul(c.oneMinus())));return w5(e,l,t,a,o,s)}),E5=K(({n:e,latitudinal:t,poleAxis:n,outputDirection:r,weights:i,samples:a,dTheta:o,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let f=X(X4(t,n,k4(n,r))).toVar();K1(f.equal(X(0)),()=>{f.assign(X(r.z,0,r.x.negate()))}),f.assign(e4(f));let p=X().toVar();return p.addAssign(i.element(0).mul(T5({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),g8({start:J(1),end:e},({i:e})=>{K1(e.greaterThanEqual(a),()=>{_8()});let t=q(o.mul(q(e))).toVar();p.addAssign(i.element(e).mul(T5({theta:t.mul(-1),axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(i.element(e).mul(T5({theta:t,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),i0(p,1)}),D5=4,O5=[.125,.215,.35,.446,.526,.582],k5=20,A5=new LQ(-1,1,1,-1,0,1),tle=new sQ(90,1),j5=new SZ;let M5=null,N5=0,P5=0;const F5=(1+Math.sqrt(5))/2,I5=1/F5,L5=[new V(-F5,I5,0),new V(F5,I5,0),new V(-I5,0,F5),new V(I5,0,F5),new V(0,F5,-I5),new V(0,F5,I5),new V(-1,1,-1),new V(1,1,-1),new V(-1,1,1),new V(1,1,1)],nle=new V,R5=new WeakMap,rle=[3,1,5,0,4,2],z5=S5(N3(),M3(`faceIndex`)).normalize(),B5=X(z5.x,z5.y,z5.z);var ile=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=nle,renderTarget:s=null}=i;if(this._setSize(a),this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.`);let a=s||this._allocateTarget();return i.renderTarget=a,this.fromSceneAsync(e,t,n,r,i),a}M5=this._renderer.getRenderTarget(),N5=this._renderer.getActiveCubeFace(),P5=this._renderer.getActiveMipmapLevel();let c=s||this._allocateTarget();return c.depthBuffer=!0,this._init(c),this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}async fromSceneAsync(e,t=0,n=.1,r=100,i={}){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,n,r,i)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=W5(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=G5(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===uJ||e.mapping===dJ?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(M5,N5,P5),e.scissorTest=!1,H5(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),M5=this._renderer.getRenderTarget(),N5=this._renderer.getActiveCubeFace(),P5=this._renderer.getActiveMipmapLevel();let n=t||this._allocateTarget();return this._init(n),this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTarget(){let e=3*Math.max(this._cubeSize,16*7),t=4*this._cubeSize,n=V5(e,t);return n}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=V5(e.width,e.height);let{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=ale(t)),this._blurMaterial=ole(t,e.width,e.height)}}async _compileMaterial(e){let t=new $Z(this._lodPlanes[0],e);await this._renderer.compile(t,A5)}_sceneToCubeUV(e,t,n,r,i){let a=tle;a.near=t,a.far=n;let o=[1,1,1,1,-1,1],s=[1,-1,1,-1,1,-1],c=this._renderer,l=c.autoClear;c.getClearColor(j5),c.autoClear=!1;let u=this._backgroundBox;if(u===null){let e=new EZ({name:`PMREM.Background`,side:eJ,depthWrite:!1,depthTest:!1});u=new $Z(new nQ,e)}let d=!1,f=e.background;f?f.isColor&&(u.material.color.copy(f),e.background=null,d=!0):(u.material.color.copy(j5),d=!0),c.setRenderTarget(r),c.clear(),d&&c.render(u,a);for(let t=0;t<6;t++){let n=t%3;n===0?(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x+s[t],i.y,i.z)):n===1?(a.up.set(0,0,o[t]),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y+s[t],i.z)):(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y,i.z+s[t]));let l=this._cubeSize;H5(r,n*l,t>2?l:0,l,l),c.render(e,a)}c.autoClear=l,e.background=f}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===uJ||e.mapping===dJ;r?this._cubemapMaterial===null&&(this._cubemapMaterial=W5(e)):this._equirectMaterial===null&&(this._equirectMaterial=G5(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;H5(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,A5)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let t=1;t<r;t++){let n=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),i=L5[(r-t-1)%L5.length];this._blur(e,t-1,t,n,i)}t.autoClear=n}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&console.error(`blur direction must be either latitudinal or longitudinal!`);let l=3,u=this._lodMeshes[r];u.material=c;let d=R5.get(c),f=this._sizeLods[n]-1,p=isFinite(i)?Math.PI/(2*f):2*Math.PI/(2*k5-1),m=i/p,h=isFinite(i)?1+Math.floor(l*m):k5;h>k5&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${h} samples when the maximum is set to ${k5}`);let g=[],_=0;for(let e=0;e<k5;++e){let t=e/m,n=Math.exp(-t*t/2);g.push(n),e===0?_+=n:e<h&&(_+=2*n)}for(let e=0;e<g.length;e++)g[e]=g[e]/_;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=h,d.weights.array=g,d.latitudinal.value=a===`latitudinal`?1:0,o&&(d.poleAxis.value=o);let{_lodMax:v}=this;d.dTheta.value=p,d.mipInt.value=v-n;let y=this._sizeLods[r],b=3*y*(r>v-D5?r-v+D5:0),x=4*(this._cubeSize-y);H5(t,b,x,3*y,2*y),s.setRenderTarget(t),s.render(u,A5)}};function ale(e){let t=[],n=[],r=[],i=[],a=e,o=e-D5+1+O5.length;for(let s=0;s<o;s++){let o=2**a;n.push(o);let c=1/o;s>e-D5?c=O5[s-e+D5-1]:s===0&&(c=0),r.push(c);let l=1/(o-2),u=-l,d=1+l,f=[u,u,d,u,d,d,u,u,d,d,u,d],p=6,m=6,h=3,g=2,_=1,v=new Float32Array(h*m*p),y=new Float32Array(g*m*p),b=new Float32Array(_*m*p);for(let e=0;e<p;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],i=rle[e];v.set(r,h*m*i),y.set(f,g*m*i);let a=[i,i,i,i,i,i];b.set(a,_*m*i)}let x=new VZ;x.setAttribute(`position`,new AZ(v,h)),x.setAttribute(`uv`,new AZ(y,g)),x.setAttribute(`faceIndex`,new AZ(b,_)),t.push(x),i.push(new $Z(x,null)),a>D5&&a--}return{lodPlanes:t,sizeLods:n,sigmas:r,lodMeshes:i}}function V5(e,t){let n={magFilter:_J,minFilter:_J,generateMipmaps:!1,type:wJ,format:TJ,colorSpace:zJ},r=new tX(e,t,n);return r.texture.mapping=fJ,r.texture.name=`PMREM.cubeUv`,r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function H5(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function U5(e){let t=new Y8;return t.depthTest=!1,t.depthWrite=!1,t.blending=tJ,t.name=`PMREM_${e}`,t}function ole(e,t,n){let r=U3(Array(k5).fill(0)),i=n2(new V(0,1,0)),a=n2(0),o=q(k5),s=n2(0),c=n2(1),l=R3(null),u=n2(0),d=q(1/t),f=q(1/n),p=q(e),m={n:o,latitudinal:s,weights:r,poleAxis:i,outputDirection:B5,dTheta:a,samples:c,envMap:l,mipInt:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:f,CUBEUV_MAX_MIP:p},h=U5(`blur`);return h.fragmentNode=E5({...m,latitudinal:s.equal(1)}),R5.set(h,m),h}function W5(e){let t=U5(`cubemap`);return t.fragmentNode=M6(e,B5),t}function G5(e){let t=U5(`equirect`);return t.fragmentNode=R3(e,Z8(B5),0),t}const K5=new WeakMap;function sle(e){let t=Math.log2(e)-2,n=1/e,r=1/(3*Math.max(2**t,7*16));return{texelWidth:r,texelHeight:n,maxMip:t}}function cle(e,t,n){let r=lle(t),i=r.get(e),a=i===void 0?-1:i.pmremVersion;if(a!==e.pmremVersion){let t=e.image;if(e.isCubeTexture)if(dle(t))i=n.fromCubemap(e,i);else return null;else if(fle(t))i=n.fromEquirectangular(e,i);else return null;i.pmremVersion=e.pmremVersion,r.set(e,i)}return i.texture}function lle(e){let t=K5.get(e);return t===void 0&&(t=new WeakMap,K5.set(e,t)),t}var ule=class extends t1{static get type(){return`PMREMNode`}constructor(e,t=null,n=null){super(`vec3`),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;let r=new $Y;r.isRenderTargetTexture=!0,this._texture=R3(r),this._width=n2(0),this._height=n2(0),this._maxMip=n2(0),this.updateBeforeType=U$.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=sle(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(t=r.isPMREMTexture===!0?r:cle(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new ile(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=T6.mul(X(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),C5(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function dle(e){if(e==null)return!1;let t=0,n=6;for(let r=0;r<n;r++)e[r]!==void 0&&t++;return t===n}function fle(e){return e==null?!1:e.height>0}const ple=W(ule).setParameterLength(1,3);var mle=class extends t1{static get type(){return`MatcapUVNode`}constructor(){super(`vec2`)}setup(){let e=X(u6.z,0,u6.x.negate()).normalize(),t=u6.cross(e);return Y(e.dot(v6),t.dot(v6)).mul(.495).add(.5)}};const hle=G(mle);var gle=class extends t1{static get type(){return`RotateNode`}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:n}=this,r=this.getNodeType(e);if(r===`vec2`){let e=t.cos(),r=t.sin(),i=c0(e,r,r.negate(),e);return i.mul(n)}else{let e=t,r=u0(i0(1,0,0,0),i0(0,r4(e.x),n4(e.x).negate(),0),i0(0,n4(e.x),r4(e.x),0),i0(0,0,0,1)),i=u0(i0(r4(e.y),0,n4(e.y),0),i0(0,1,0,0),i0(n4(e.y).negate(),0,r4(e.y),0),i0(0,0,0,1)),a=u0(i0(r4(e.z),n4(e.z).negate(),0,0),i0(n4(e.z),r4(e.z),0,0),i0(0,0,1,0),i0(0,0,0,1));return r.mul(i).mul(a).mul(i0(n,1)).xyz}}};const q5=W(gle).setParameterLength(2),_le=y0(`vec3`),vle=y0(`vec3`),yle=y0(`vec3`);var ble=class{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this.weakMap;for(let t=0;t<e.length-1;t++){let r=e[t];n.has(r)===!1&&n.set(r,new WeakMap),n=n.get(r)}return n.set(e[e.length-1],t),this}delete(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}},xle=class extends v0{static get type(){return`ParameterNode`}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}};const Sle=(e,t)=>U(new xle(e,t));var Cle=class extends Q${static get type(){return`StackNode`}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):`void`}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):`void`}add(e){return this.nodes.push(e),this}If(e,t){let n=new B1(t);return this._currentCond=X4(e,n),this.add(this._currentCond)}ElseIf(e,t){let n=new B1(t),r=X4(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new B1(e),this}Switch(e){return this._expressionNode=U(e),this}Case(...e){let t=[];if(e.length>=2)for(let n=0;n<e.length-1;n++)t.push(this._expressionNode.equal(U(e[n])));else throw Error(`TSL: Invalid parameter length. Case() requires at least two parameters.`);let n=e[e.length-1],r=new B1(n),i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);let a=X4(i,r);return this._currentCond===null?(this._currentCond=a,this.add(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(e){return this.Else(e),this}build(e,...t){let n=G1();W1(this);let r=e.buildStage;for(let t of this.nodes)if(r===`setup`)t.build(e);else if(r===`analyze`)t.build(e,this);else if(r===`generate`){let n=e.getDataFromNode(t,`any`).stages,r=n&&n[e.shaderStage];if(t.isVarNode&&r&&r.length===1&&r[0]&&r[0].isStackNode)continue;t.build(e,`void`)}return W1(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn(`THREE.TSL: .else() has been renamed to .Else().`),this.Else(...e)}elseif(...e){return console.warn(`THREE.TSL: .elseif() has been renamed to .ElseIf().`),this.ElseIf(...e)}};const wle=W(Cle).setParameterLength(0,1);function Tle(e){return Object.entries(e).map(([e,t])=>typeof t==`string`?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}var Ele=class extends Q${static get type(){return`StructTypeNode`}constructor(e,t=null){super(`struct`),this.membersLayout=Tle(e),this.name=t,this.isStructLayoutNode=!0}getLength(){let e=8,t=Float32Array.BYTES_PER_ELEMENT,n=0;for(let r of this.membersLayout){let i=r.type,a=F$(i)*t,o=I$(i),s=n%e,c=s%o,l=s+c;n+=c,l!==0&&e-l<a&&(n+=e-l),n+=a}return Math.ceil(n/e)*e/t}getMemberType(e,t){let n=this.membersLayout.find(e=>e.name===t);return n?n.type:`void`}getNodeType(e){let t=e.getStructTypeFromNode(this,this.membersLayout,this.name);return t.name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}},Dle=class extends Q${static get type(){return`StructNode`}constructor(e,t){super(`vec3`),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){let t=e.getVarFromNode(this),n=t.type,r=e.getPropertyName(t);return e.addLineFlowCode(`${r} = ${e.generateStruct(n,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}};const Ole=(e,t=null)=>{let n=new Ele(e,t),r=(...t)=>{let r=null;if(t.length>0)if(t[0].isNode){r={};let n=Object.keys(e);for(let e=0;e<t.length;e++)r[n[e]]=t[e]}else r=t[0];return U(new Dle(n,r))};return r.layout=n,r.isStruct=!0,r};var J5=class extends Q${static get type(){return`OutputStructNode`}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){let t=e.getNodeProperties(this);if(t.membersLayout===void 0){let n=this.members,r=[];for(let t=0;t<n.length;t++){let i=`m`+t,a=n[t].getNodeType(e);r.push({name:i,type:a,index:t})}t.membersLayout=r,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}return t.structType.name}generate(e){let t=e.getOutputStructName(),n=this.members,r=t===``?``:t+`.`;for(let t=0;t<n.length;t++){let i=n[t].build(e);e.addLineFlowCode(`${r}m${t} = ${i}`,this)}return t}};const kle=W(J5);function Y5(e,t){for(let n=0;n<e.length;n++)if(e[n].name===t)return n;return-1}var Ale=class extends J5{static get type(){return`MRTNode`}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){let t={...this.outputNodes,...e.outputNodes};return X5(t)}setup(e){let t=this.outputNodes,n=e.renderer.getRenderTarget(),r=[],i=n.textures;for(let e in t){let n=Y5(i,e);r[n]=i0(t[e])}return this.members=r,super.setup(e)}};const X5=W(Ale),jle=K(([e])=>{let t=e.toUint().mul(747796405).add(2891336453),n=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737),r=n.shiftRight(22).bitXor(n);return r.toFloat().mul(1/2**32)}),Z5=(e,t)=>A4(p2(4,e.mul(f2(1,e))),t),Mle=(e,t)=>e.lessThan(.5)?Z5(e.mul(2),t).div(2):f2(1,Z5(p2(f2(1,e),2),t).div(2)),Nle=(e,t,n)=>A4(m2(A4(e,t),d2(A4(e,t),A4(f2(1,e),n))),1/t),Ple=(e,t)=>n4(B2.mul(t.mul(e).sub(1))).div(B2.mul(t.mul(e).sub(1))),Q5=K(([e])=>e.fract().sub(.5).abs()).setLayout({name:`tri`,type:`float`,inputs:[{name:`x`,type:`float`}]}),Fle=K(([e])=>X(Q5(e.z.add(Q5(e.y.mul(1)))),Q5(e.z.add(Q5(e.x.mul(1)))),Q5(e.y.add(Q5(e.x.mul(1)))))).setLayout({name:`tri3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Ile=K(([e,t,n])=>{let r=X(e).toVar(),i=q(1.4).toVar(),a=q(0).toVar(),o=X(r).toVar();return g8({start:q(0),end:q(3),type:`float`,condition:`<=`},()=>{let e=X(Fle(o.mul(2))).toVar();r.addAssign(e.add(n.mul(q(.1).mul(t)))),o.mulAssign(1.8),i.mulAssign(1.5),r.mulAssign(1.2);let s=q(Q5(r.z.add(Q5(r.x.add(Q5(r.y)))))).toVar();a.addAssign(s.div(i)),o.addAssign(.14)}),a}).setLayout({name:`triNoise3D`,type:`float`,inputs:[{name:`position`,type:`vec3`},{name:`speed`,type:`float`},{name:`time`,type:`float`}]});var Lle=class extends Q${static get type(){return`FunctionOverloadingNode`}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){let t=this.parametersNodes,n=this._candidateFnCall;if(n===null){let r=null,i=-1;for(let n of this.functionNodes){let a=n.shaderNode,o=a.layout;if(o===null)throw Error(`FunctionOverloadingNode: FunctionNode must be a layout.`);let s=o.inputs;if(t.length===s.length){let a=0;for(let n=0;n<t.length;n++){let r=t[n],i=s[n];r.getNodeType(e)===i.type?a++:a=0}a>i&&(r=n,i=a)}}this._candidateFnCall=n=r(...t)}return n}};const Rle=W(Lle),$5=e=>(...t)=>Rle(e,...t),e7=n2(0).setGroup($0).onRenderUpdate(e=>e.time),t7=n2(0).setGroup($0).onRenderUpdate(e=>e.deltaTime),zle=n2(0,`uint`).setGroup($0).onRenderUpdate(e=>e.frameId),Ble=(e=1)=>(console.warn(`TSL: timerLocal() is deprecated. Use "time" instead.`),e7.mul(e)),Vle=(e=1)=>(console.warn(`TSL: timerGlobal() is deprecated. Use "time" instead.`),e7.mul(e)),Hle=(e=1)=>(console.warn(`TSL: timerDelta() is deprecated. Use "deltaTime" instead.`),t7.mul(e)),Ule=(e=e7)=>e.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),Wle=(e=e7)=>e.fract().round(),Gle=(e=e7)=>e.add(.5).fract().mul(2).sub(1).abs(),Kle=(e=e7)=>e.fract(),qle=K(([e,t,n=Y(.5)])=>q5(e.sub(n),t).add(n)),Jle=K(([e,t,n=Y(.5)])=>{let r=e.sub(n),i=r.dot(r),a=i.mul(i),o=a.mul(t);return e.add(r.mul(o))}),Yle=K(({position:e=null,horizontal:t=!0,vertical:n=!1})=>{let r;e===null?r=e6:(r=e6.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z);let i=Y3.mul(r);return R1(t)&&(i[0][0]=e6[0].length(),i[0][1]=0,i[0][2]=0),R1(n)&&(i[1][0]=0,i[1][1]=e6[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,J3.mul(i).mul(a6)}),Xle=K(([e=null])=>{let t=W8(),n=W8(I8(e)).sub(t),r=n.lessThan(0).select(D8,e);return r});var Zle=class extends Q${static get type(){return`SpriteSheetUVNode`}constructor(e,t=N3(),n=q(0)){super(`vec2`),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){let{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:i}=n,a=e.mod(r.mul(i)).floor(),o=a.mod(r),s=i.sub(a.add(1).div(r).ceil()),c=n.reciprocal(),l=Y(o,s);return t.add(l).mul(c)}};const Qle=W(Zle).setParameterLength(3);var $le=class extends Q${static get type(){return`TriplanarTexturesNode`}constructor(e,t=null,n=null,r=q(1),i=a6,a=m6){super(`vec4`),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=r,this.positionNode=i,this.normalNode=a}setup(){let{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:r,positionNode:i,normalNode:a}=this,o=a.abs().normalize();o=o.div(o.dot(X(1)));let s=i.yz.mul(r),c=i.zx.mul(r),l=i.xy.mul(r),u=e.value,d=t===null?u:t.value,f=n===null?u:n.value,p=R3(u,s).mul(o.x),m=R3(d,c).mul(o.y),h=R3(f,l).mul(o.z);return d2(p,m,h)}};const n7=W($le).setParameterLength(1,6),eue=(...e)=>n7(...e),r7=new _Q,i7=new V,a7=new V,o7=new V,s7=new AX,c7=new V(0,0,-1),l7=new eX,u7=new V,d7=new V,f7=new eX,p7=new AY,m7=new tX,tue=D8.flipX();m7.depthTexture=new yQ(1,1);let h7=!1;var nue=class e extends L3{static get type(){return`ReflectorNode`}constructor(e={}){super(e.defaultTexture||m7.texture,tue),this._reflectorBaseNode=e.reflector||new rue(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw Error(`THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. `);this._depthNode=U(new e({defaultTexture:m7.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){let e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},rue=class extends Q${static get type(){return`ReflectorBaseNode`}constructor(e,t={}){super();let{target:n=new rZ,resolution:r=1,generateMipmaps:i=!1,bounces:a=!0,depth:o=!1}=t;this.textureNode=e,this.target=n,this.resolution=r,this.generateMipmaps=i,this.bounces=a,this.depth=o,this.updateBeforeType=a?U$.RENDER:U$.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let n=this.resolution;t.getDrawingBufferSize(p7),e.setSize(Math.round(p7.width*n),Math.round(p7.height*n))}setup(e){return this._updateResolution(m7,e.renderer),super.setup(e)}dispose(){super.dispose();for(let e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new tX(0,0,{type:wJ}),this.generateMipmaps===!0&&(t.texture.minFilter=yJ,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new yQ),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&h7)return!1;h7=!0;let{scene:t,camera:n,renderer:r,material:i}=e,{target:a}=this,o=this.getVirtualCamera(n),s=this.getRenderTarget(o);r.getDrawingBufferSize(p7),this._updateResolution(s,r),a7.setFromMatrixPosition(a.matrixWorld),o7.setFromMatrixPosition(n.matrixWorld),s7.extractRotation(a.matrixWorld),i7.set(0,0,1),i7.applyMatrix4(s7),u7.subVectors(a7,o7);let c=u7.dot(i7)>0,l=!1;if(c===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){h7=!1;return}l=!0}u7.reflect(i7).negate(),u7.add(a7),s7.extractRotation(n.matrixWorld),c7.set(0,0,-1),c7.applyMatrix4(s7),c7.add(o7),d7.subVectors(a7,c7),d7.reflect(i7).negate(),d7.add(a7),o.coordinateSystem=n.coordinateSystem,o.position.copy(u7),o.up.set(0,1,0),o.up.applyMatrix4(s7),o.up.reflect(i7),o.lookAt(d7),o.near=n.near,o.far=n.far,o.updateMatrixWorld(),o.projectionMatrix.copy(n.projectionMatrix),r7.setFromNormalAndCoplanarPoint(i7,a7),r7.applyMatrix4(o.matrixWorldInverse),l7.set(r7.normal.x,r7.normal.y,r7.normal.z,r7.constant);let u=o.projectionMatrix;f7.x=(Math.sign(l7.x)+u.elements[8])/u.elements[0],f7.y=(Math.sign(l7.y)+u.elements[9])/u.elements[5],f7.z=-1,f7.w=(1+u.elements[10])/u.elements[14],l7.multiplyScalar(1/l7.dot(f7));let d=0;u.elements[2]=l7.x,u.elements[6]=l7.y,u.elements[10]=r.coordinateSystem===tY?l7.z-d:l7.z+1-d,u.elements[14]=l7.w,this.textureNode.value=s.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=s.depthTexture),i.visible=!1;let f=r.getRenderTarget(),p=r.getMRT(),m=r.autoClear;r.setMRT(null),r.setRenderTarget(s),r.autoClear=!0,l?(r.clear(),this.hasOutput=!1):(r.render(t,o),this.hasOutput=!0),r.setMRT(p),r.setRenderTarget(f),r.autoClear=m,i.visible=!0,h7=!1,this.forceUpdate=!1}};const iue=e=>U(new nue(e)),g7=new LQ(-1,1,1,-1,0,1);var aue=class extends VZ{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute(`position`,new NZ([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new NZ(t,2))}};const oue=new aue;var _7=class extends $Z{constructor(e=null){super(oue,e),this.camera=g7,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,g7)}render(e){e.render(this,g7)}};const sue=new AY;var cue=class extends L3{static get type(){return`RTTNode`}constructor(e,t=null,n=null,r={type:wJ}){let i=new tX(t,n,r);super(i.texture,N3()),this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new _7(new Y8),this.updateBeforeType=U$.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name=`RTT`,this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;let n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();let t=e.getSize(sue);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;let t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){let e=new L3(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}};const v7=(e,...t)=>U(new cue(U(e),...t)),lue=(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():v7(e,...t),y7=K(([e,t,n],r)=>{let i;r.renderer.coordinateSystem===tY?(e=Y(e.x,e.y.oneMinus()).mul(2).sub(1),i=i0(X(e,t),1)):i=i0(X(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let a=i0(n.mul(i));return a.xyz.div(a.w)}),uue=K(([e,t])=>{let n=t.mul(i0(e,1)),r=n.xy.div(n.w).mul(.5).add(.5).toVar();return Y(r.x,r.y.oneMinus())}),due=K(([e,t,n])=>{let r=P3(z3(t)),i=Q1(e.mul(r)).toVar(),a=z3(t,i).toVar(),o=z3(t,i.sub(Q1(2,0))).toVar(),s=z3(t,i.sub(Q1(1,0))).toVar(),c=z3(t,i.add(Q1(1,0))).toVar(),l=z3(t,i.add(Q1(2,0))).toVar(),u=z3(t,i.add(Q1(0,2))).toVar(),d=z3(t,i.add(Q1(0,1))).toVar(),f=z3(t,i.sub(Q1(0,1))).toVar(),p=z3(t,i.sub(Q1(0,2))).toVar(),m=c4(f2(q(2).mul(s).sub(o),a)).toVar(),h=c4(f2(q(2).mul(c).sub(l),a)).toVar(),g=c4(f2(q(2).mul(d).sub(u),a)).toVar(),_=c4(f2(q(2).mul(f).sub(p),a)).toVar(),v=y7(e,a,n).toVar(),y=m.lessThan(h).select(v.sub(y7(e.sub(Y(q(1).div(r.x),0)),s,n)),v.negate().add(y7(e.add(Y(q(1).div(r.x),0)),c,n))),b=g.lessThan(_).select(v.sub(y7(e.add(Y(0,q(1).div(r.y))),d,n)),v.negate().add(y7(e.sub(Y(0,q(1).div(r.y))),f,n)));return e4(k4(y,b))});var fue=class extends pQ{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}},pue=class extends AZ{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}};const mue=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=N$(`float`)):(n=P$(t),r=N$(t));let i=new pue(e,n,r),a=f8(i,t,e);return a},hue=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=N$(`float`)):(n=P$(t),r=N$(t));let i=new fue(e,n,r),a=f8(i,t,e);return a};var gue=class extends Q${static get type(){return`PointUVNode`}constructor(){super(`vec2`),this.isPointUVNode=!0}generate(){return`vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )`}};const _ue=G(gue),b7=new BX,x7=new AX;var S7=class e extends Q${static get type(){return`SceneNode`}constructor(t=e.BACKGROUND_BLURRINESS,n=null){super(),this.scope=t,this.scene=n}setup(t){let n=this.scope,r=this.scene===null?t.scene:this.scene,i;return n===e.BACKGROUND_BLURRINESS?i=P6(`backgroundBlurriness`,`float`,r):n===e.BACKGROUND_INTENSITY?i=P6(`backgroundIntensity`,`float`,r):n===e.BACKGROUND_ROTATION?i=n2(`mat4`).label(`backgroundRotation`).setGroup($0).onRenderUpdate(()=>{let e=r.background;return e!==null&&e.isTexture&&e.mapping!==lJ?(b7.copy(r.backgroundRotation),b7.x*=-1,b7.y*=-1,b7.z*=-1,x7.makeRotationFromEuler(b7)):x7.identity(),x7}):console.error(`THREE.SceneNode: Unknown scope:`,n),i}};S7.BACKGROUND_BLURRINESS=`backgroundBlurriness`,S7.BACKGROUND_INTENSITY=`backgroundIntensity`,S7.BACKGROUND_ROTATION=`backgroundRotation`;const vue=G(S7,S7.BACKGROUND_BLURRINESS),yue=G(S7,S7.BACKGROUND_INTENSITY),bue=G(S7,S7.BACKGROUND_ROTATION);var xue=class extends L3{static get type(){return`StorageTextureNode`}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=G$.WRITE_ONLY}getInputType(){return`storageTexture`}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let n;return n=this.storeNode===null?super.generate(e,t):this.generateStore(e),n}toReadWrite(){return this.setAccess(G$.READ_WRITE)}toReadOnly(){return this.setAccess(G$.READ_ONLY)}toWriteOnly(){return this.setAccess(G$.WRITE_ONLY)}generateStore(e){let t=e.getNodeProperties(this),{uvNode:n,storeNode:r,depthNode:i}=t,a=super.generate(e,`property`),o=n.build(e,`uvec2`),s=r.build(e,`vec4`),c=i?i.build(e,`int`):null,l=e.generateTextureStore(e,a,o,c,s);e.addLineFlowCode(l,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e}};const C7=W(xue).setParameterLength(1,3),Sue=(e,t,n)=>{let r=C7(e,t,n);return n!==null&&r.toStack(),r},Cue=K(({texture:e,uv:t})=>{let n=1e-4,r=X().toVar();return K1(t.x.lessThan(n),()=>{r.assign(X(1,0,0))}).ElseIf(t.y.lessThan(n),()=>{r.assign(X(0,1,0))}).ElseIf(t.z.lessThan(n),()=>{r.assign(X(0,0,1))}).ElseIf(t.x.greaterThan(1-n),()=>{r.assign(X(-1,0,0))}).ElseIf(t.y.greaterThan(1-n),()=>{r.assign(X(0,-1,0))}).ElseIf(t.z.greaterThan(1-n),()=>{r.assign(X(0,0,-1))}).Else(()=>{let n=.01,i=e.sample(t.add(X(-.01,0,0))).r.sub(e.sample(t.add(X(n,0,0))).r),a=e.sample(t.add(X(0,-.01,0))).r.sub(e.sample(t.add(X(0,n,0))).r),o=e.sample(t.add(X(0,0,-.01))).r.sub(e.sample(t.add(X(0,0,n))).r);r.assign(X(i,a,o))}),r.normalize()});var wue=class extends L3{static get type(){return`Texture3DNode`}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return`texture3D`}getDefaultUV(){return X(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(t=this.sampler?t.flipY():t.setY(J(P3(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,`vec3`)}normal(e){return Cue({texture:this,uv:e})}};const Tue=W(wue).setParameterLength(1,3);var Eue=class extends N6{static get type(){return`UserDataNode`}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData===null?e.object.userData:this.userData,this.reference}};const Due=(e,t,n)=>U(new Eue(e,t,n)),w7=new WeakMap;var Oue=class extends t1{static get type(){return`VelocityNode`}constructor(){super(`vec2`),this.projectionMatrix=null,this.updateType=U$.OBJECT,this.updateAfterType=U$.OBJECT,this.previousModelWorldMatrix=n2(new AX),this.previousProjectionMatrix=n2(new AX).setGroup($0),this.previousCameraViewMatrix=n2(new AX)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){let r=E7(n);this.previousModelWorldMatrix.value.copy(r);let i=T7(t);i.frameId!==e&&(i.frameId=e,i.previousProjectionMatrix===void 0?(i.previousProjectionMatrix=new AX,i.previousCameraViewMatrix=new AX,i.currentProjectionMatrix=new AX,i.currentCameraViewMatrix=new AX,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){E7(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?J3:n2(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(n6).mul(a6),r=this.previousProjectionMatrix.mul(t).mul(o6),i=n.xy.div(n.w),a=r.xy.div(r.w),o=f2(i,a);return o}};function T7(e){let t=w7.get(e);return t===void 0&&(t={},w7.set(e,t)),t}function E7(e,t=0){let n=T7(e),r=n[t];return r===void 0&&(n[t]=r=new AX,n[t].copy(e.matrixWorld)),r}const kue=G(Oue),D7=K(([e,t])=>S4(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:`blendBurn`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),O7=K(([e,t])=>S4(e.div(t.oneMinus()),1)).setLayout({name:`blendDodge`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),k7=K(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:`blendScreen`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),A7=K(([e,t])=>L4(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),w4(.5,e))).setLayout({name:`blendOverlay`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Aue=K(([e,t])=>{let n=t.a.add(e.a.mul(t.a.oneMinus()));return i0(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(n),n)}).setLayout({name:`blendColor`,type:`vec4`,inputs:[{name:`base`,type:`vec4`},{name:`blend`,type:`vec4`}]}),jue=K(([e])=>i0(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),Mue=K(([e])=>(K1(e.a.equal(0),()=>i0(0)),i0(e.rgb.div(e.a),e.a)),{color:`vec4`,return:`vec4`}),Nue=(...e)=>(console.warn(`THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.`),D7(e)),Pue=(...e)=>(console.warn(`THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.`),O7(e)),Fue=(...e)=>(console.warn(`THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.`),k7(e)),Iue=(...e)=>(console.warn(`THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.`),A7(e)),Lue=K(([e])=>j7(e.rgb)),Rue=K(([e,t=q(1)])=>t.mix(j7(e.rgb),e.rgb)),zue=K(([e,t=q(1)])=>{let n=d2(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return L4(e.rgb,r,i)}),Bue=K(([e,t=q(1)])=>{let n=X(.57735,.57735,.57735),r=t.cos();return X(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(O4(n,e.rgb).mul(r.oneMinus())))))}),j7=(e,t=X(UY.getLuminanceCoefficients(new V)))=>O4(e,t),Vue=K(([e,t=X(1),n=X(0),r=X(1),i=q(1),a=X(UY.getLuminanceCoefficients(new V,zJ))])=>{let o=e.rgb.dot(X(a)),s=C4(e.rgb.mul(t).add(n),0).toVar(),c=s.pow(r).toVar();return K1(s.r.greaterThan(0),()=>{s.r.assign(c.r)}),K1(s.g.greaterThan(0),()=>{s.g.assign(c.g)}),K1(s.b.greaterThan(0),()=>{s.b.assign(c.b)}),s.assign(o.add(s.sub(o).mul(i))),i0(s.rgb,e.a)});var Hue=class extends t1{static get type(){return`PosterizeNode`}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){let{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}};const Uue=W(Hue).setParameterLength(2),M7=new AY;var N7=class extends L3{static get type(){return`PassTextureNode`}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},P7=class extends N7{static get type(){return`PassMultipleTextureNode`}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}},F7=class e extends t1{static get type(){return`PassNode`}constructor(e,t,n,r={}){super(`vec4`),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;let i=new yQ;i.isRenderTargetTexture=!0,i.name=`depth`;let a=new tX(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:wJ,...r});a.texture.name=`output`,a.depthTexture=i,this.renderTarget=a,this._textures={output:a.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=n2(0),this._cameraFar=n2(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=U$.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(t===void 0){let n=this.renderTarget.texture;t=n.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e=`output`){let t=this._textureNodes[e];return t===void 0&&(t=U(new P7(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e=`output`){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=U(new P7(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e=`depth`){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=B8(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e=`depth`){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=R8(i,n,r)}return t}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,t.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.texture.type=t.getColorBufferType(),this.scope===e.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n}=this,r,i,a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(i=1,r=t.xr.getCamera(),t.xr.updateCamera(r),M7.set(a.width,a.height)):(r=this.camera,i=t.getPixelRatio(),t.getSize(M7)),this._pixelRatio=i,this.setSize(M7.width,M7.height);let o=t.getRenderTarget(),s=t.getMRT(),c=r.layers.mask;for(let e in this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask),this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(o),t.setMRT(s),r.layers.mask=c}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio*this._resolution,r=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}};F7.COLOR=`color`,F7.DEPTH=`depth`;const Wue=(e,t,n)=>U(new F7(F7.COLOR,e,t,n)),Gue=(e,t)=>U(new N7(e,t)),Kue=(e,t,n)=>U(new F7(F7.DEPTH,e,t,n));var que=class extends F7{static get type(){return`ToonOutlinePassNode`}constructor(e,t,n,r,i){super(F7.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){let{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((e,n,r,i,a,o,s,c)=>{if((a.isMeshToonMaterial||a.isMeshToonNodeMaterial)&&a.wireframe===!1){let l=this._getOutlineMaterial(a);t.renderObject(e,n,r,i,l,o,s,c)}t.renderObject(e,n,r,i,a,o,s,c)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){let e=new Y8;e.isMeshToonOutlineMaterial=!0,e.name=`Toon_Outline`,e.side=eJ;let t=m6.negate(),n=J3.mul(n6),r=q(1),i=n.mul(i0(a6,1)),a=n.mul(i0(a6.add(t),1)),o=e4(i.sub(a));return e.vertexNode=i.add(o.mul(this.thicknessNode).mul(i.w).mul(r)),e.colorNode=i0(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}};const Jue=(e,t,n=new SZ(0,0,0),r=.003,i=1)=>U(new que(e,t,U(n),U(r),U(i))),Yue=K(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Xue=K(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:`reinhardToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Zue=K(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);let n=e.mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(r).pow(2.2)}).setLayout({name:`cineonToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Que=K(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)}),$ue=K(([e,t])=>{let n=l0(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=l0(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=Que(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),ede=l0(X(1.6605,-.1246,-.0182),X(-.5876,1.1329,-.1006),X(-.0728,-.0083,1.1187)),tde=l0(X(.6274,.0691,.0164),X(.3293,.9195,.088),X(.0433,.0113,.8956)),nde=K(([e])=>{let t=X(e).toVar(),n=X(t.mul(t)).toVar(),r=X(n.mul(n)).toVar();return q(15.5).mul(r.mul(n)).sub(p2(40.14,r.mul(t))).add(p2(31.96,r).sub(p2(6.868,n.mul(t))).add(p2(.4298,n).add(p2(.1191,t).sub(.00232))))}),rde=K(([e,t])=>{let n=X(e).toVar(),r=l0(X(.856627153315983,.137318972929847,.11189821299995),X(.0951212405381588,.761241990602591,.0767994186031903),X(.0482516061458583,.101439036467562,.811302368396859)),i=l0(X(1.1271005818144368,-.1413297634984383,-.14132976349843826),X(-.11060664309660323,1.157823702216272,-.11060664309660294),X(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=q(-12.47393),o=q(4.026069);return n.mulAssign(t),n.assign(tde.mul(n)),n.assign(r.mul(n)),n.assign(C4(n,1e-10)),n.assign(Y2(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign(R4(n,0,1)),n.assign(nde(n)),n.assign(i.mul(n)),n.assign(A4(C4(X(0),n),X(2.2))),n.assign(ede.mul(n)),n.assign(R4(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),ide=K(([e,t])=>{let n=q(.76),r=q(.15);e=e.mul(t);let i=S4(e.r,S4(e.g,e.b)),a=X4(i.lessThan(.08),i.sub(p2(6.25,i.mul(i))),.04);e.subAssign(a);let o=C4(e.r,C4(e.g,e.b));K1(o.lessThan(n),()=>e);let s=f2(1,n),c=f2(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=f2(1,m2(1,r.mul(o.sub(c)).add(1)));return L4(e,X(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]});var I7=class extends Q${static get type(){return`CodeNode`}constructor(e=``,t=[],n=``){super(`code`),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e);let n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}};const L7=W(I7).setParameterLength(1,3),ade=(e,t)=>L7(e,t,`js`),ode=(e,t)=>L7(e,t,`wgsl`),sde=(e,t)=>L7(e,t,`glsl`);var cde=class extends I7{static get type(){return`FunctionNode`}constructor(e=``,t=[],n=``){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);let n=this.getNodeFunction(e),r=n.name,i=n.type,a=e.getCodeFromNode(this,i);r!==``&&(a.name=r);let o=e.getPropertyName(a),s=this.getNodeFunction(e).getCode(o);return a.code=s+`
431
+ `,t===`property`?o:e.format(`${o}()`,i,t)}};const R7=(e,t=[],n=``)=>{for(let e=0;e<t.length;e++){let n=t[e];typeof n==`function`&&(t[e]=n.functionNode)}let r=U(new cde(e,t,n)),i=(...e)=>r.call(...e);return i.functionNode=r,i},lde=(e,t)=>R7(e,t,`glsl`),ude=(e,t)=>R7(e,t,`wgsl`);var dde=class extends Q${static get type(){return`ScriptableValueNode`}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new nY,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType===`URL`&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:`change`}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:`refresh`})}getValue(){let e=this.value;if(e&&this._cache===null&&this.inputType===`URL`&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType===`URL`||this.inputType===`String`)&&typeof e.value==`string`||this.inputType===`Number`&&typeof e.value==`number`||this.inputType===`Vector2`&&e.value.isVector2||this.inputType===`Vector3`&&e.value.isVector3||this.inputType===`Vector4`&&e.value.isVector4||this.inputType===`Color`&&e.value.isColor||this.inputType===`Matrix3`&&e.value.isMatrix3||this.inputType===`Matrix4`&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):`float`}setup(){return this.value&&this.value.isNode?this.value:q()}serialize(e){super.serialize(e),this.value===null?e.value=null:this.inputType===`ArrayBuffer`?e.value=B$(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(t=e.inputType===`ArrayBuffer`?V$(e.value):e.inputType===`Texture`?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}};const z7=W(dde).setParameterLength(1);var B7=class extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){let r=t(...n);return this.set(e,r),r}}},fde=class{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){let t=this.parameters[e],n=t?t.getValue():null;return n}};const V7=new B7;var pde=class extends Q${static get type(){return`ScriptableNode`}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new B7,this._output=z7(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:``}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(let t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(let t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){let n=this._outputs;return n[e]===void 0?n[e]=z7(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){let n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener(`refresh`,this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener(`refresh`,this.onRefresh)):n[e]===void 0?(n[e]=z7(t),n[e].events.addEventListener(`refresh`,this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener(`refresh`,this.onRefresh)),this}clearParameters(){for(let e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){let n=this.getObject(),r=n[e];if(typeof r==`function`)return r(...t)}async callAsync(e,...t){let n=this.getObject(),r=n[e];if(typeof r==`function`)return r.constructor.name===`AsyncFunction`?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e===null?this._refresh():this.getOutput(e).refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;let e=()=>this.refresh(),t=(e,t)=>this.setOutput(e,t),n=new fde(this),r=V7.get(`THREE`),i=V7.get(`TSL`),a=this.getMethod(),o=[n,this._local,V7,e,t,r,i];this._object=a(...o);let s=this._object.layout;if(s&&(s.cache===!1&&this._local.clear(),this._output.outputType=s.outputType||null,Array.isArray(s.elements)))for(let e of s.elements){let t=e.id||e.name;e.inputType&&(this.getParameter(t)===void 0&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(this.getOutput(t)===void 0&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){for(let t in super.deserialize(e),this.parameters){let e=this.parameters[t];e.isScriptableNode&&(e=e.getDefaultOutput()),e.events.addEventListener(`refresh`,this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){let e=this.getDefaultOutput().value;return e&&e.isNode?e:q()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;let e=[`parameters`,`local`,`global`,`refresh`,`setOutput`,`THREE`,`TSL`],t=[`layout`,`init`,`main`,`dispose`],n=t.join(`, `),r=`var `+n+`; var output = {};
432
432
  `,i=`
433
- return { ...output, `+n+` };`,a=r+this.codeNode.code+i;return this._method=Function(...e,a),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose==`function`&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){let t=[T$(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(let n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return E$(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call(`main`),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}};const pde=W(fde).setParameterLength(1,2);function H7(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||l6.z).negate()}const U7=K(([e,t],n)=>{let r=H7(n);return V4(e,t,r)}),W7=K(([e],t)=>{let n=H7(t);return e.mul(e,n,n).negate().exp().oneMinus()}),G7=K(([e,t])=>i0(t.toFloat().mix(z0.rgb,e.toVec3()),z0.a));function mde(e,t,n){return console.warn(`THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.`),G7(e,U7(t,n))}function hde(e,t){return console.warn(`THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.`),G7(e,W7(t))}let K7=null,q7=null;var gde=class extends Q${static get type(){return`RangeNode`}constructor(e=q(),t=q()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=e.getTypeLength(L$(this.minNode.value)),n=e.getTypeLength(L$(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):`float`}setup(e){let t=e.object,n=null;if(t.count>1){let r=this.minNode.value,i=this.maxNode.value,a=e.getTypeLength(L$(r)),o=e.getTypeLength(L$(i));K7||=new TX,q7||=new TX,K7.setScalar(0),q7.setScalar(0),a===1?K7.setScalar(r):r.isColor?K7.set(r.r,r.g,r.b,1):K7.set(r.x,r.y,r.z||0,r.w||0),o===1?q7.setScalar(i):i.isColor?q7.set(i.r,i.g,i.b,1):q7.set(i.x,i.y,i.z||0,i.w||0);let s=4,c=s*t.count,l=new Float32Array(c);for(let e=0;e<c;e++){let t=e%s,n=K7.getComponent(t),r=q7.getComponent(t);l[e]=eX.lerp(n,r,Math.random())}let u=this.getNodeType(e);if(t.count<=4096)n=V3(l,`vec4`,t.count).element(s8).convert(u);else{let t=new LQ(l,4);e.geometry.setAttribute(`__range`+this.id,t),n=v3(t).convert(u)}}else n=q(0);return n}};const _de=W(gde).setParameterLength(2);var vde=class extends Q${static get type(){return`ComputeBuiltinNode`}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){return e.hasBuiltin(this._builtinName)}generate(e,t){let n=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage===`compute`?e.format(n,r,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${n} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}};const J7=(e,t)=>U(new vde(e,t)),yde=J7(`numWorkgroups`,`uvec3`),bde=J7(`workgroupId`,`uvec3`),xde=J7(`globalId`,`uvec3`),Sde=J7(`localId`,`uvec3`),Cde=J7(`subgroupSize`,`uint`);var wde=class extends Q${constructor(e){super(),this.scope=e}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}};const Y7=W(wde),Tde=()=>Y7(`workgroup`).toStack(),Ede=()=>Y7(`storage`).toStack(),Dde=()=>Y7(`texture`).toStack();var Ode=class extends $${constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n,r=e.context.assign;if(n=super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}},kde=class extends Q${constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return U(new Ode(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}};const Ade=(e,t)=>U(new kde(`Workgroup`,e,t));var X7=class extends Q${static get type(){return`AtomicFunctionNode`}constructor(e,t,n){super(`uint`),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),n=t.parents,r=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,s=this.valueNode,c=[];c.push(`&${o.build(e,a)}`),s!==null&&c.push(s.build(e,a));let l=`${e.getMethod(r,i)}( ${c.join(`, `)} )`,u=n.length===1&&n[0].isStackNode===!0;if(u)e.addLineFlowCode(l,this);else return t.constNode===void 0&&(t.constNode=D3(l,i).toConst()),t.constNode.build(e)}};X7.ATOMIC_LOAD=`atomicLoad`,X7.ATOMIC_STORE=`atomicStore`,X7.ATOMIC_ADD=`atomicAdd`,X7.ATOMIC_SUB=`atomicSub`,X7.ATOMIC_MAX=`atomicMax`,X7.ATOMIC_MIN=`atomicMin`,X7.ATOMIC_AND=`atomicAnd`,X7.ATOMIC_OR=`atomicOr`,X7.ATOMIC_XOR=`atomicXor`;const jde=W(X7),Z7=(e,t,n)=>jde(e,t,n).toStack(),Mde=e=>Z7(X7.ATOMIC_LOAD,e,null),Nde=(e,t)=>Z7(X7.ATOMIC_STORE,e,t),Pde=(e,t)=>Z7(X7.ATOMIC_ADD,e,t),Fde=(e,t)=>Z7(X7.ATOMIC_SUB,e,t),Ide=(e,t)=>Z7(X7.ATOMIC_MAX,e,t),Lde=(e,t)=>Z7(X7.ATOMIC_MIN,e,t),Rde=(e,t)=>Z7(X7.ATOMIC_AND,e,t),zde=(e,t)=>Z7(X7.ATOMIC_OR,e,t),Bde=(e,t)=>Z7(X7.ATOMIC_XOR,e,t);let Q7;function $7(e){Q7||=new WeakMap;let t=Q7.get(e);return t===void 0&&Q7.set(e,t={}),t}function e9(e){let t=$7(e);return t.shadowMatrix||=n2(`mat4`).setGroup($0).onRenderUpdate(t=>((e.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&e.shadow.updateMatrices(e),e.shadow.matrix))}function Vde(e,t=s6){let n=e9(e).mul(t),r=n.xyz.div(n.w);return r}function t9(e){let t=$7(e);return t.position||=n2(new V).setGroup($0).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))}function n9(e){let t=$7(e);return t.targetPosition||=n2(new V).setGroup($0).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))}function Hde(e){let t=$7(e);return t.viewPosition||=n2(new V).setGroup($0).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new V,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)})}const Ude=e=>Y3.transformDirection(t9(e).sub(n9(e))),Wde=e=>e.sort((e,t)=>e.id-t.id),Gde=(e,t)=>{for(let n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},r9=new WeakMap,i9=[];var Kde=class extends Q${static get type(){return`LightsNode`}constructor(){super(`vec3`),this.totalDiffuseNode=X().toVar(),this.totalSpecularNode=X().toVar(),this.outgoingLightNode=X().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t<e.length;t++){let n=e[t];if(i9.push(n.id),i9.push(n.castShadow?1:0),n.isSpotLight===!0){let e=n.map===null?-1:n.map.id,t=n.colorNode?n.colorNode.getCacheKey():-1;i9.push(e,t)}}let t=E$(i9);return i9.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);let t=[];for(let e of this._lightNodes)t.push(e.getSelf().getHash());this._lightNodesHash=`lights-`+t.join(`,`)}return this._lightNodesHash}analyze(e){let t=e.getNodeProperties(this);for(let n of t.nodes)n.build(e);t.outputNode.build(e)}setupLightsNode(e){let t=[],n=this._lightNodes,r=Wde(this._lights),i=e.renderer.library;for(let e of r)if(e.isNode)t.push(U(e));else{let r=null;if(n!==null&&(r=Gde(e.id,n)),r===null){let n=i.getLightNodeClass(e.constructor);if(n===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let r=null;r9.has(e)?r=r9.get(e):(r=U(new n(e)),r9.set(e,r)),t.push(r)}}this._lightNodes=t}setupDirectLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.direct({...n,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.directRectArea({...n,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(let n of t)n.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let n=this.outgoingLightNode,r=e.context,i=r.lightingModel,a=e.getNodeProperties(this);if(i){let{totalDiffuseNode:t,totalSpecularNode:o}=this;r.outgoingLight=n;let s=e.addStack();a.nodes=s.nodes,i.start(e);let{backdrop:c,backdropAlpha:l}=r,{directDiffuse:u,directSpecular:d,indirectDiffuse:f,indirectSpecular:p}=r.reflectedLight,m=u.add(f);c!==null&&(m=X(l===null?c:l.mix(m,c)),r.material.transparent=!0),t.assign(m),o.assign(d.add(p)),n.assign(t.add(o)),i.finish(e),n=n.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,n}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}};const qde=(e=[])=>U(new Kde).setLights(e);var Jde=class extends Q${static get type(){return`ShadowBaseNode`}constructor(e){super(),this.light=e,this.updateBeforeType=U$.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){a9.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||s6)}};const a9=y0(`vec3`,`shadowPositionWorld`);function Yde(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new qZ),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function Xde(e,t){return t=Yde(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function Zde(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function Qde(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function $de(e,t){return t=Qde(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function efe(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function tfe(e,t,n){return n=Xde(e,n),n=$de(t,n),n}function nfe(e,t,n){Zde(e,n),efe(t,n)}const o9=new WeakMap,s9=K(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=R3(e,t.xy).label(`t_basic`);return e.isArrayTexture&&(r=r.depth(n)),r.compare(t.z)}),c9=K(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=R3(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=P6(`mapSize`,`vec2`,n).setGroup($0),o=P6(`radius`,`float`,n).setGroup($0),s=Y(1).div(a),c=s.x.negate().mul(o),l=s.y.negate().mul(o),u=s.x.mul(o),d=s.y.mul(o),f=c.div(2),p=l.div(2),m=u.div(2),h=d.div(2);return d2(i(t.xy.add(Y(c,l)),t.z),i(t.xy.add(Y(0,l)),t.z),i(t.xy.add(Y(u,l)),t.z),i(t.xy.add(Y(f,p)),t.z),i(t.xy.add(Y(0,p)),t.z),i(t.xy.add(Y(m,p)),t.z),i(t.xy.add(Y(c,0)),t.z),i(t.xy.add(Y(f,0)),t.z),i(t.xy,t.z),i(t.xy.add(Y(m,0)),t.z),i(t.xy.add(Y(u,0)),t.z),i(t.xy.add(Y(f,h)),t.z),i(t.xy.add(Y(0,h)),t.z),i(t.xy.add(Y(m,h)),t.z),i(t.xy.add(Y(c,d)),t.z),i(t.xy.add(Y(0,d)),t.z),i(t.xy.add(Y(u,d)),t.z)).mul(1/17)}),l9=K(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=R3(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=P6(`mapSize`,`vec2`,n).setGroup($0),o=Y(1).div(a),s=o.x,c=o.y,l=t.xy,u=t4(l.mul(a).add(.5));return l.subAssign(u.mul(o)),d2(i(l,t.z),i(l.add(Y(s,0)),t.z),i(l.add(Y(0,c)),t.z),i(l.add(o),t.z),L4(i(l.add(Y(s.negate(),0)),t.z),i(l.add(Y(s.mul(2),0)),t.z),u.x),L4(i(l.add(Y(s.negate(),c)),t.z),i(l.add(Y(s.mul(2),c)),t.z),u.x),L4(i(l.add(Y(0,c.negate())),t.z),i(l.add(Y(0,c.mul(2))),t.z),u.y),L4(i(l.add(Y(s,c.negate())),t.z),i(l.add(Y(s,c.mul(2))),t.z),u.y),L4(L4(i(l.add(Y(s.negate(),c.negate())),t.z),i(l.add(Y(s.mul(2),c.negate())),t.z),u.x),L4(i(l.add(Y(s.negate(),c.mul(2))),t.z),i(l.add(Y(s.mul(2),c.mul(2))),t.z),u.x),u.y)).mul(1/9)}),u9=K(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=q(1).toVar(),i=R3(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(n)),i=i.rg;let a=w4(t.z,i.x);return K1(a.notEqual(q(1)),()=>{let e=t.z.sub(i.x),n=C4(0,i.y.mul(i.y)),o=n.div(n.add(e.mul(e)));o=R4(f2(o,.3).div(.6499999999999999)),r.assign(R4(C4(a,o)))}),r}),rfe=K(([e,t,n])=>{let r=s6.sub(e).length();return r=r.sub(t).div(n.sub(t)),r=r.saturate(),r}),ife=e=>{let t=e.shadow.camera,n=P6(`near`,`float`,t).setGroup($0),r=P6(`far`,`float`,t).setGroup($0),i=Q3(e);return rfe(i,n,r)},d9=e=>{let t=o9.get(e);if(t===void 0){let n=e.isPointLight?ife(e):null;t=new Y8,t.colorNode=i0(0,0,0,1),t.depthNode=n,t.isShadowPassMaterial=!0,t.name=`ShadowMaterial`,t.fog=!1,o9.set(e,t)}return t},f9=new yle,p9=[],m9=(e,t,n,r)=>{p9[0]=e,p9[1]=t;let i=f9.get(p9);return(i===void 0||i.shadowType!==n||i.useVelocity!==r)&&(i=(i,a,o,s,c,l,...u)=>{(i.castShadow===!0||i.receiveShadow&&n===CJ)&&(r&&(z$(i).useVelocity=!0),i.onBeforeShadow(e,i,o,t.camera,s,a.overrideMaterial,l),e.renderObject(i,a,o,s,c,l,...u),i.onAfterShadow(e,i,o,t.camera,s,a.overrideMaterial,l))},i.shadowType=n,i.useVelocity=r,f9.set(p9,i)),p9[0]=null,p9[1]=null,i},afe=K(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=q(0).toVar(`meanVertical`),o=q(0).toVar(`squareMeanVertical`),s=e.lessThanEqual(q(1)).select(q(0),q(2).div(e.sub(1))),c=e.lessThanEqual(q(1)).select(q(0),q(-1));g8({start:J(0),end:J(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(q(e).mul(s)),u=r.sample(d2(k8.xy,Y(0,l).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),u=u.x,a.addAssign(u),o.addAssign(u.mul(u))}),a.divAssign(e),o.divAssign(e);let l=X2(o.sub(a.mul(a)));return Y(a,l)}),ofe=K(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=q(0).toVar(`meanHorizontal`),o=q(0).toVar(`squareMeanHorizontal`),s=e.lessThanEqual(q(1)).select(q(0),q(2).div(e.sub(1))),c=e.lessThanEqual(q(1)).select(q(0),q(-1));g8({start:J(0),end:J(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(q(e).mul(s)),u=r.sample(d2(k8.xy,Y(l,0).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),a.addAssign(u.x),o.addAssign(d2(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),o.divAssign(e);let l=X2(o.sub(a.mul(a)));return Y(a,l)}),sfe=[s9,c9,l9,u9];let h9;const g9=new _7;var _9=class extends Jde{static get type(){return`ShadowNode`}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a}){let o=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),s=t({depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a});return o.select(s,q(1))}setupShadowCoord(e,t){let{shadow:n}=this,{renderer:r}=e,i=P6(`bias`,`float`,n).setGroup($0),a=t,o;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z,r.coordinateSystem===EY&&(o=o.mul(2).sub(1));else{let e=a.w;a=a.xy.div(e);let t=P6(`near`,`float`,n.camera).setGroup($0),r=P6(`far`,`float`,n.camera).setGroup($0);o=V8(e.negate(),t,r)}return a=X(a.x,a.y.oneMinus(),o.add(i)),a}getShadowFilterFn(e){return sfe[e]}setupRenderTarget(e,t){let n=new UQ(e.mapSize.width,e.mapSize.height);n.name=`ShadowDepthTexture`,n.compareFunction=gY;let r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name=`ShadowMap`,r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){let{renderer:t}=e,{light:n,shadow:r}=this,i=t.shadowMap.type,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(r,e);if(r.camera.updateProjectionMatrix(),i===CJ&&r.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:$J,type:YJ,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name=`VSMVertical`),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:$J,type:YJ,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name=`VSMHorizontal`),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:$J,type:YJ,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:$J,type:YJ,depthBuffer:!1}));let t=R3(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let n=R3(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(n=n.depth(this.depthLayer));let i=P6(`blurSamples`,`float`,r).setGroup($0),s=P6(`radius`,`float`,r).setGroup($0),c=P6(`mapSize`,`vec2`,r).setGroup($0),l=this.vsmMaterialVertical||=new Y8;l.fragmentNode=afe({samples:i,radius:s,size:c,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMVertical`,l=this.vsmMaterialHorizontal||=new Y8,l.fragmentNode=ofe({samples:i,radius:s,size:c,shadowPass:n,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMHorizontal`}let s=P6(`intensity`,`float`,r).setGroup($0),c=P6(`normalBias`,`float`,r).setGroup($0),l=e9(n).mul(a9.add(y6.mul(c))),u=this.setupShadowCoord(e,l),d=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(d===null)throw Error(`THREE.WebGPURenderer: Shadow map type not supported yet.`);let f=i===CJ&&r.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,p=this.setupShadowFilter(e,{filterFn:d,shadowTexture:o.texture,depthTexture:f,shadowCoord:u,shadow:r,depthLayer:this.depthLayer}),m=R3(o.texture,u);a.isArrayTexture&&(m=m.depth(this.depthLayer));let h=L4(1,p.rgb.mix(m,1),s.mul(m.a)).toVar();return this.shadowMap=o,this.shadow.map=o,h}setup(e){if(e.renderer.shadowMap.enabled!==!1)return K(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn(`THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.`),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth),i.render(a,t.camera)}updateShadow(e){let{shadowMap:t,light:n,shadow:r}=this,{renderer:i,scene:a,camera:o}=e,s=i.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;let l=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=o.layers.mask);let u=i.getRenderObjectFunction(),d=i.getMRT(),f=d?d.has(`velocity`):!1;h9=tfe(i,a,h9),a.overrideMaterial=d9(n),i.setRenderObjectFunction(m9(i,r,s,f)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(u),s===CJ&&r.isPointLightShadow!==!0&&this.vsmPass(i),r.camera.layers.mask=l,nfe(i,a,h9)}vsmPass(e){let{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),g9.material=this.vsmMaterialVertical,g9.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),g9.material=this.vsmMaterialHorizontal,g9.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){let{shadow:t}=this,n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}};const cfe=(e,t)=>U(new _9(e,t)),lfe=new qZ,v9=K(([e,t])=>{let n=e.toVar(),r=c4(n),i=m2(1,C4(r.x,C4(r.y,r.z)));r.mulAssign(i),n.mulAssign(i.mul(t.mul(2).oneMinus()));let a=Y(n.xy).toVar(),o=t.mul(1.5),s=o.oneMinus();return K1(r.z.greaterThanEqual(s),()=>{K1(n.z.greaterThan(0),()=>{a.x.assign(f2(4,n.x))})}).ElseIf(r.x.greaterThanEqual(s),()=>{let e=l4(n.x);a.x.assign(n.z.mul(e).add(e.mul(2)))}).ElseIf(r.y.greaterThanEqual(s),()=>{let e=l4(n.y);a.x.assign(n.x.add(e.mul(2)).add(2)),a.y.assign(n.z.mul(e).sub(2))}),Y(.125,.25).mul(a).add(Y(.375,.75)).flipY()}).setLayout({name:`cubeToUV`,type:`vec2`,inputs:[{name:`pos`,type:`vec3`},{name:`texelSizeY`,type:`float`}]}),y9=K(({depthTexture:e,bd3D:t,dp:n,texelSize:r})=>R3(e,v9(t,r.y)).compare(n)),b9=K(({depthTexture:e,bd3D:t,dp:n,texelSize:r,shadow:i})=>{let a=P6(`radius`,`float`,i).setGroup($0),o=Y(-1,1).mul(a).mul(r.y);return R3(e,v9(t.add(o.xyy),r.y)).compare(n).add(R3(e,v9(t.add(o.yyy),r.y)).compare(n)).add(R3(e,v9(t.add(o.xyx),r.y)).compare(n)).add(R3(e,v9(t.add(o.yyx),r.y)).compare(n)).add(R3(e,v9(t,r.y)).compare(n)).add(R3(e,v9(t.add(o.xxy),r.y)).compare(n)).add(R3(e,v9(t.add(o.yxy),r.y)).compare(n)).add(R3(e,v9(t.add(o.xxx),r.y)).compare(n)).add(R3(e,v9(t.add(o.yxx),r.y)).compare(n)).mul(1/9)}),ufe=K(({filterFn:e,depthTexture:t,shadowCoord:n,shadow:r})=>{let i=n.xyz.toVar(),a=i.length(),o=n2(`float`).setGroup($0).onRenderUpdate(()=>r.camera.near),s=n2(`float`).setGroup($0).onRenderUpdate(()=>r.camera.far),c=P6(`bias`,`float`,r).setGroup($0),l=n2(r.mapSize).setGroup($0),u=q(1).toVar();return K1(a.sub(s).lessThanEqual(0).and(a.sub(o).greaterThanEqual(0)),()=>{let n=a.sub(o).div(s.sub(o)).toVar();n.addAssign(c);let d=i.normalize(),f=Y(1).div(l.mul(Y(4,2)));u.assign(e({depthTexture:t,bd3D:d,dp:n,texelSize:f,shadow:r}))}),u}),x9=new TX,S9=new tX,C9=new tX;var dfe=class extends _9{static get type(){return`PointShadowNode`}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===SJ?y9:b9}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:a}){return ufe({filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:a})}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e,o=t.getFrameExtents();C9.copy(t.mapSize),C9.multiply(o),n.setSize(C9.width,C9.height),S9.copy(t.mapSize);let s=i.autoClear,c=i.getClearColor(lfe),l=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();let u=t.getViewportCount();for(let e=0;e<u;e++){let o=t.getViewport(e),s=S9.x*o.x,c=C9.y-S9.y-S9.y*o.y;x9.set(s,c,S9.x*o.z,S9.y*o.w),n.viewport.copy(x9),t.updateMatrices(r,e),i.render(a,t.camera)}i.autoClear=s,i.setClearColor(c,l)}};const ffe=(e,t)=>U(new dfe(e,t)),w9=K(({lightDistance:e,cutoffDistance:t,decayExponent:n})=>{let r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),pfe=({color:e,lightVector:t,cutoffDistance:n,decayExponent:r})=>{let i=t.normalize(),a=t.length(),o=w9({lightDistance:a,cutoffDistance:n,decayExponent:r}),s=e.mul(o);return{lightDirection:i,lightColor:s}},mfe=K(([e=N3()])=>{let t=e.mul(2),n=t.x.floor(),r=t.y.floor(),i=n.add(r).mod(2);return i.sign()}),hfe=K(([e=N3()],{renderer:t,material:n})=>{let r=I4(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.samples>1){let e=q(r.fwidth()).toVar();i=V4(e.oneMinus(),e.add(1),r).oneMinus()}else i=X4(r.greaterThan(1),0,1);return i}),T9=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=Z1(e).toVar();return X4(a,i,r)}).setLayout({name:`mx_select`,type:`float`,inputs:[{name:`b`,type:`bool`},{name:`t`,type:`float`},{name:`f`,type:`float`}]}),E9=K(([e,t])=>{let n=Z1(t).toVar(),r=q(e).toVar();return X4(n,r.negate(),r)}).setLayout({name:`mx_negate_if`,type:`float`,inputs:[{name:`val`,type:`float`},{name:`b`,type:`bool`}]}),D9=K(([e])=>{let t=q(e).toVar();return J(Q2(t))}).setLayout({name:`mx_floor`,type:`int`,inputs:[{name:`x`,type:`float`}]}),O9=K(([e,t])=>{let n=q(e).toVar();return t.assign(D9(n)),n.sub(q(t))}),gfe=K(([e,t,n,r,i,a])=>{let o=q(a).toVar(),s=q(i).toVar(),c=q(r).toVar(),l=q(n).toVar(),u=q(t).toVar(),d=q(e).toVar(),f=q(f2(1,s)).toVar();return f2(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`}]}),_fe=K(([e,t,n,r,i,a])=>{let o=q(a).toVar(),s=q(i).toVar(),c=X(r).toVar(),l=X(n).toVar(),u=X(t).toVar(),d=X(e).toVar(),f=q(f2(1,s)).toVar();return f2(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`}]}),k9=$5([gfe,_fe]),vfe=K(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=q(u).toVar(),f=q(l).toVar(),p=q(c).toVar(),m=q(s).toVar(),h=q(o).toVar(),g=q(a).toVar(),_=q(i).toVar(),v=q(r).toVar(),y=q(n).toVar(),b=q(t).toVar(),x=q(e).toVar(),S=q(f2(1,p)).toVar(),ee=q(f2(1,f)).toVar(),te=q(f2(1,d)).toVar();return te.mul(ee.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(ee.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`v4`,type:`float`},{name:`v5`,type:`float`},{name:`v6`,type:`float`},{name:`v7`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]}),yfe=K(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=q(u).toVar(),f=q(l).toVar(),p=q(c).toVar(),m=X(s).toVar(),h=X(o).toVar(),g=X(a).toVar(),_=X(i).toVar(),v=X(r).toVar(),y=X(n).toVar(),b=X(t).toVar(),x=X(e).toVar(),S=q(f2(1,p)).toVar(),ee=q(f2(1,f)).toVar(),te=q(f2(1,d)).toVar();return te.mul(ee.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(ee.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`v4`,type:`vec3`},{name:`v5`,type:`vec3`},{name:`v6`,type:`vec3`},{name:`v7`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]}),A9=$5([vfe,yfe]),bfe=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=X1(e).toVar(),o=X1(a.bitAnd(X1(7))).toVar(),s=q(T9(o.lessThan(X1(4)),i,r)).toVar(),c=q(p2(2,T9(o.lessThan(X1(4)),r,i))).toVar();return E9(s,Z1(o.bitAnd(X1(1)))).add(E9(c,Z1(o.bitAnd(X1(2)))))}).setLayout({name:`mx_gradient_float_0`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),xfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=q(t).toVar(),s=X1(e).toVar(),c=X1(s.bitAnd(X1(15))).toVar(),l=q(T9(c.lessThan(X1(8)),o,a)).toVar(),u=q(T9(c.lessThan(X1(4)),a,T9(c.equal(X1(12)).or(c.equal(X1(14))),o,i))).toVar();return E9(l,Z1(c.bitAnd(X1(1)))).add(E9(u,Z1(c.bitAnd(X1(2)))))}).setLayout({name:`mx_gradient_float_1`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]}),j9=$5([bfe,xfe]),Sfe=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=n0(e).toVar();return X(j9(a.x,i,r),j9(a.y,i,r),j9(a.z,i,r))}).setLayout({name:`mx_gradient_vec3_0`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),Cfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=q(t).toVar(),s=n0(e).toVar();return X(j9(s.x,o,a,i),j9(s.y,o,a,i),j9(s.z,o,a,i))}).setLayout({name:`mx_gradient_vec3_1`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]}),M9=$5([Sfe,Cfe]),wfe=K(([e])=>{let t=q(e).toVar();return p2(.6616,t)}).setLayout({name:`mx_gradient_scale2d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),Tfe=K(([e])=>{let t=q(e).toVar();return p2(.982,t)}).setLayout({name:`mx_gradient_scale3d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),Efe=K(([e])=>{let t=X(e).toVar();return p2(.6616,t)}).setLayout({name:`mx_gradient_scale2d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),N9=$5([wfe,Efe]),Dfe=K(([e])=>{let t=X(e).toVar();return p2(.982,t)}).setLayout({name:`mx_gradient_scale3d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),P9=$5([Tfe,Dfe]),F9=K(([e,t])=>{let n=J(t).toVar(),r=X1(e).toVar();return r.shiftLeft(n).bitOr(r.shiftRight(J(32).sub(n)))}).setLayout({name:`mx_rotl32`,type:`uint`,inputs:[{name:`x`,type:`uint`},{name:`k`,type:`int`}]}),I9=K(([e,t,n])=>{e.subAssign(n),e.bitXorAssign(F9(n,J(4))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(F9(e,J(6))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(F9(t,J(8))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(F9(n,J(16))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(F9(e,J(19))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(F9(t,J(4))),t.addAssign(e)}),L9=K(([e,t,n])=>{let r=X1(n).toVar(),i=X1(t).toVar(),a=X1(e).toVar();return r.bitXorAssign(i),r.subAssign(F9(i,J(14))),a.bitXorAssign(r),a.subAssign(F9(r,J(11))),i.bitXorAssign(a),i.subAssign(F9(a,J(25))),r.bitXorAssign(i),r.subAssign(F9(i,J(16))),a.bitXorAssign(r),a.subAssign(F9(r,J(4))),i.bitXorAssign(a),i.subAssign(F9(a,J(14))),r.bitXorAssign(i),r.subAssign(F9(i,J(24))),r}).setLayout({name:`mx_bjfinal`,type:`uint`,inputs:[{name:`a`,type:`uint`},{name:`b`,type:`uint`},{name:`c`,type:`uint`}]}),R9=K(([e])=>{let t=X1(e).toVar();return q(t).div(q(X1(J(4294967295))))}).setLayout({name:`mx_bits_to_01`,type:`float`,inputs:[{name:`bits`,type:`uint`}]}),z9=K(([e])=>{let t=q(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:`mx_fade`,type:`float`,inputs:[{name:`t`,type:`float`}]}),Ofe=K(([e])=>{let t=J(e).toVar(),n=X1(X1(1)).toVar(),r=X1(X1(J(3735928559)).add(n.shiftLeft(X1(2))).add(X1(13))).toVar();return L9(r.add(X1(t)),r,r)}).setLayout({name:`mx_hash_int_0`,type:`uint`,inputs:[{name:`x`,type:`int`}]}),kfe=K(([e,t])=>{let n=J(t).toVar(),r=J(e).toVar(),i=X1(X1(2)).toVar(),a=X1().toVar(),o=X1().toVar(),s=X1().toVar();return a.assign(o.assign(s.assign(X1(J(3735928559)).add(i.shiftLeft(X1(2))).add(X1(13))))),a.addAssign(X1(r)),o.addAssign(X1(n)),L9(a,o,s)}).setLayout({name:`mx_hash_int_1`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),Afe=K(([e,t,n])=>{let r=J(n).toVar(),i=J(t).toVar(),a=J(e).toVar(),o=X1(X1(3)).toVar(),s=X1().toVar(),c=X1().toVar(),l=X1().toVar();return s.assign(c.assign(l.assign(X1(J(3735928559)).add(o.shiftLeft(X1(2))).add(X1(13))))),s.addAssign(X1(a)),c.addAssign(X1(i)),l.addAssign(X1(r)),L9(s,c,l)}).setLayout({name:`mx_hash_int_2`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),jfe=K(([e,t,n,r])=>{let i=J(r).toVar(),a=J(n).toVar(),o=J(t).toVar(),s=J(e).toVar(),c=X1(X1(4)).toVar(),l=X1().toVar(),u=X1().toVar(),d=X1().toVar();return l.assign(u.assign(d.assign(X1(J(3735928559)).add(c.shiftLeft(X1(2))).add(X1(13))))),l.addAssign(X1(s)),u.addAssign(X1(o)),d.addAssign(X1(a)),I9(l,u,d),l.addAssign(X1(i)),L9(l,u,d)}).setLayout({name:`mx_hash_int_3`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`}]}),Mfe=K(([e,t,n,r,i])=>{let a=J(i).toVar(),o=J(r).toVar(),s=J(n).toVar(),c=J(t).toVar(),l=J(e).toVar(),u=X1(X1(5)).toVar(),d=X1().toVar(),f=X1().toVar(),p=X1().toVar();return d.assign(f.assign(p.assign(X1(J(3735928559)).add(u.shiftLeft(X1(2))).add(X1(13))))),d.addAssign(X1(l)),f.addAssign(X1(c)),p.addAssign(X1(s)),I9(d,f,p),d.addAssign(X1(o)),f.addAssign(X1(a)),L9(d,f,p)}).setLayout({name:`mx_hash_int_4`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`},{name:`yy`,type:`int`}]}),B9=$5([Ofe,kfe,Afe,jfe,Mfe]),Nfe=K(([e,t])=>{let n=J(t).toVar(),r=J(e).toVar(),i=X1(B9(r,n)).toVar(),a=n0().toVar();return a.x.assign(i.bitAnd(J(255))),a.y.assign(i.shiftRight(J(8)).bitAnd(J(255))),a.z.assign(i.shiftRight(J(16)).bitAnd(J(255))),a}).setLayout({name:`mx_hash_vec3_0`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),Pfe=K(([e,t,n])=>{let r=J(n).toVar(),i=J(t).toVar(),a=J(e).toVar(),o=X1(B9(a,i,r)).toVar(),s=n0().toVar();return s.x.assign(o.bitAnd(J(255))),s.y.assign(o.shiftRight(J(8)).bitAnd(J(255))),s.z.assign(o.shiftRight(J(16)).bitAnd(J(255))),s}).setLayout({name:`mx_hash_vec3_1`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),V9=$5([Nfe,Pfe]),Ffe=K(([e])=>{let t=Y(e).toVar(),n=J().toVar(),r=J().toVar(),i=q(O9(t.x,n)).toVar(),a=q(O9(t.y,r)).toVar(),o=q(z9(i)).toVar(),s=q(z9(a)).toVar(),c=q(k9(j9(B9(n,r),i,a),j9(B9(n.add(J(1)),r),i.sub(1),a),j9(B9(n,r.add(J(1))),i,a.sub(1)),j9(B9(n.add(J(1)),r.add(J(1))),i.sub(1),a.sub(1)),o,s)).toVar();return N9(c)}).setLayout({name:`mx_perlin_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),Ife=K(([e])=>{let t=X(e).toVar(),n=J().toVar(),r=J().toVar(),i=J().toVar(),a=q(O9(t.x,n)).toVar(),o=q(O9(t.y,r)).toVar(),s=q(O9(t.z,i)).toVar(),c=q(z9(a)).toVar(),l=q(z9(o)).toVar(),u=q(z9(s)).toVar(),d=q(A9(j9(B9(n,r,i),a,o,s),j9(B9(n.add(J(1)),r,i),a.sub(1),o,s),j9(B9(n,r.add(J(1)),i),a,o.sub(1),s),j9(B9(n.add(J(1)),r.add(J(1)),i),a.sub(1),o.sub(1),s),j9(B9(n,r,i.add(J(1))),a,o,s.sub(1)),j9(B9(n.add(J(1)),r,i.add(J(1))),a.sub(1),o,s.sub(1)),j9(B9(n,r.add(J(1)),i.add(J(1))),a,o.sub(1),s.sub(1)),j9(B9(n.add(J(1)),r.add(J(1)),i.add(J(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar();return P9(d)}).setLayout({name:`mx_perlin_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),H9=$5([Ffe,Ife]),Lfe=K(([e])=>{let t=Y(e).toVar(),n=J().toVar(),r=J().toVar(),i=q(O9(t.x,n)).toVar(),a=q(O9(t.y,r)).toVar(),o=q(z9(i)).toVar(),s=q(z9(a)).toVar(),c=X(k9(M9(V9(n,r),i,a),M9(V9(n.add(J(1)),r),i.sub(1),a),M9(V9(n,r.add(J(1))),i,a.sub(1)),M9(V9(n.add(J(1)),r.add(J(1))),i.sub(1),a.sub(1)),o,s)).toVar();return N9(c)}).setLayout({name:`mx_perlin_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),Rfe=K(([e])=>{let t=X(e).toVar(),n=J().toVar(),r=J().toVar(),i=J().toVar(),a=q(O9(t.x,n)).toVar(),o=q(O9(t.y,r)).toVar(),s=q(O9(t.z,i)).toVar(),c=q(z9(a)).toVar(),l=q(z9(o)).toVar(),u=q(z9(s)).toVar(),d=X(A9(M9(V9(n,r,i),a,o,s),M9(V9(n.add(J(1)),r,i),a.sub(1),o,s),M9(V9(n,r.add(J(1)),i),a,o.sub(1),s),M9(V9(n.add(J(1)),r.add(J(1)),i),a.sub(1),o.sub(1),s),M9(V9(n,r,i.add(J(1))),a,o,s.sub(1)),M9(V9(n.add(J(1)),r,i.add(J(1))),a.sub(1),o,s.sub(1)),M9(V9(n,r.add(J(1)),i.add(J(1))),a,o.sub(1),s.sub(1)),M9(V9(n.add(J(1)),r.add(J(1)),i.add(J(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar();return P9(d)}).setLayout({name:`mx_perlin_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),U9=$5([Lfe,Rfe]),zfe=K(([e])=>{let t=q(e).toVar(),n=J(D9(t)).toVar();return R9(B9(n))}).setLayout({name:`mx_cell_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`float`}]}),Bfe=K(([e])=>{let t=Y(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar();return R9(B9(n,r))}).setLayout({name:`mx_cell_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),Vfe=K(([e])=>{let t=X(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar();return R9(B9(n,r,i))}).setLayout({name:`mx_cell_noise_float_2`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),Hfe=K(([e])=>{let t=i0(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar(),a=J(D9(t.w)).toVar();return R9(B9(n,r,i,a))}).setLayout({name:`mx_cell_noise_float_3`,type:`float`,inputs:[{name:`p`,type:`vec4`}]}),Ufe=$5([zfe,Bfe,Vfe,Hfe]),Wfe=K(([e])=>{let t=q(e).toVar(),n=J(D9(t)).toVar();return X(R9(B9(n,J(0))),R9(B9(n,J(1))),R9(B9(n,J(2))))}).setLayout({name:`mx_cell_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`float`}]}),Gfe=K(([e])=>{let t=Y(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar();return X(R9(B9(n,r,J(0))),R9(B9(n,r,J(1))),R9(B9(n,r,J(2))))}).setLayout({name:`mx_cell_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),Kfe=K(([e])=>{let t=X(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar();return X(R9(B9(n,r,i,J(0))),R9(B9(n,r,i,J(1))),R9(B9(n,r,i,J(2))))}).setLayout({name:`mx_cell_noise_vec3_2`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),qfe=K(([e])=>{let t=i0(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar(),a=J(D9(t.w)).toVar();return X(R9(B9(n,r,i,a,J(0))),R9(B9(n,r,i,a,J(1))),R9(B9(n,r,i,a,J(2))))}).setLayout({name:`mx_cell_noise_vec3_3`,type:`vec3`,inputs:[{name:`p`,type:`vec4`}]}),W9=$5([Wfe,Gfe,Kfe,qfe]),G9=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=q(0).toVar(),l=q(1).toVar();return g8(o,()=>{c.addAssign(l.mul(H9(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_float`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),K9=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=X(0).toVar(),l=q(1).toVar();return g8(o,()=>{c.addAssign(l.mul(U9(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_vec3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),Jfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar();return Y(G9(s,o,a,i),G9(s.add(X(J(19),J(193),J(17))),o,a,i))}).setLayout({name:`mx_fractal_noise_vec2`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),Yfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=X(K9(s,o,a,i)).toVar(),l=q(G9(s.add(X(J(19),J(193),J(17))),o,a,i)).toVar();return i0(c,l)}).setLayout({name:`mx_fractal_noise_vec4`,type:`vec4`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),Xfe=K(([e,t,n,r,i,a,o])=>{let s=J(o).toVar(),c=q(a).toVar(),l=J(i).toVar(),u=J(r).toVar(),d=J(n).toVar(),f=J(t).toVar(),p=Y(e).toVar(),m=X(W9(Y(f.add(u),d.add(l)))).toVar(),h=Y(m.x,m.y).toVar();h.subAssign(.5),h.mulAssign(c),h.addAssign(.5);let g=Y(Y(q(f),q(d)).add(h)).toVar(),_=Y(g.sub(p)).toVar();return K1(s.equal(J(2)),()=>c4(_.x).add(c4(_.y))),K1(s.equal(J(3)),()=>C4(c4(_.x),c4(_.y))),O4(_,_)}).setLayout({name:`mx_worley_distance_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Zfe=K(([e,t,n,r,i,a,o,s,c])=>{let l=J(c).toVar(),u=q(s).toVar(),d=J(o).toVar(),f=J(a).toVar(),p=J(i).toVar(),m=J(r).toVar(),h=J(n).toVar(),g=J(t).toVar(),_=X(e).toVar(),v=X(W9(X(g.add(p),h.add(f),m.add(d)))).toVar();v.subAssign(.5),v.mulAssign(u),v.addAssign(.5);let y=X(X(q(g),q(h),q(m)).add(v)).toVar(),b=X(y.sub(_)).toVar();return K1(l.equal(J(2)),()=>c4(b.x).add(c4(b.y)).add(c4(b.z))),K1(l.equal(J(3)),()=>C4(c4(b.x),c4(b.y),c4(b.z))),O4(b,b)}).setLayout({name:`mx_worley_distance_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`zoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),q9=$5([Xfe,Zfe]),Qfe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=q(1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();l.assign(S4(l,n))})}),K1(r.equal(J(0)),()=>{l.assign(X2(l))}),l}).setLayout({name:`mx_worley_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),$fe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=Y(1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();K1(n.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.y.assign(n)})})}),K1(r.equal(J(0)),()=>{l.assign(X2(l))}),l}).setLayout({name:`mx_worley_noise_vec2_0`,type:`vec2`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),epe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=X(1e6,1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();K1(n.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(n)}).ElseIf(n.lessThan(l.z),()=>{l.z.assign(n)})})}),K1(r.equal(J(0)),()=>{l.assign(X2(l))}),l}).setLayout({name:`mx_worley_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),tpe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=q(1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();u.assign(S4(u,a))})})}),K1(r.equal(J(0)),()=>{u.assign(X2(u))}),u}).setLayout({name:`mx_worley_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),npe=$5([Qfe,tpe]),rpe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=Y(1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();K1(a.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.y.assign(a)})})})}),K1(r.equal(J(0)),()=>{u.assign(X2(u))}),u}).setLayout({name:`mx_worley_noise_vec2_1`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),ipe=$5([$fe,rpe]),ape=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=X(1e6,1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();K1(a.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(a)}).ElseIf(a.lessThan(u.z),()=>{u.z.assign(a)})})})}),K1(r.equal(J(0)),()=>{u.assign(X2(u))}),u}).setLayout({name:`mx_worley_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),ope=$5([epe,ape]),spe=K(([e])=>{let t=e.y,n=e.z,r=X().toVar();return K1(t.lessThan(1e-4),()=>{r.assign(X(n,n,n))}).Else(()=>{let i=e.x;i=i.sub(Q2(i)).mul(6).toVar();let a=J(_4(i)),o=i.sub(q(a)),s=n.mul(t.oneMinus()),c=n.mul(t.mul(o).oneMinus()),l=n.mul(t.mul(o.oneMinus()).oneMinus());K1(a.equal(J(0)),()=>{r.assign(X(n,l,s))}).ElseIf(a.equal(J(1)),()=>{r.assign(X(c,n,s))}).ElseIf(a.equal(J(2)),()=>{r.assign(X(s,n,l))}).ElseIf(a.equal(J(3)),()=>{r.assign(X(s,c,n))}).ElseIf(a.equal(J(4)),()=>{r.assign(X(l,s,n))}).Else(()=>{r.assign(X(n,s,c))})}),r}).setLayout({name:`mx_hsvtorgb`,type:`vec3`,inputs:[{name:`hsv`,type:`vec3`}]}),cpe=K(([e])=>{let t=X(e).toVar(),n=q(t.x).toVar(),r=q(t.y).toVar(),i=q(t.z).toVar(),a=q(S4(n,S4(r,i))).toVar(),o=q(C4(n,C4(r,i))).toVar(),s=q(o.sub(a)).toVar(),c=q().toVar(),l=q().toVar(),u=q().toVar();return u.assign(o),K1(o.greaterThan(0),()=>{l.assign(s.div(o))}).Else(()=>{l.assign(0)}),K1(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{K1(n.greaterThanEqual(o),()=>{c.assign(r.sub(i).div(s))}).ElseIf(r.greaterThanEqual(o),()=>{c.assign(d2(2,i.sub(n).div(s)))}).Else(()=>{c.assign(d2(4,n.sub(r).div(s)))}),c.mulAssign(1/6),K1(c.lessThan(0),()=>{c.addAssign(1)})}),X(c,l,u)}).setLayout({name:`mx_rgbtohsv`,type:`vec3`,inputs:[{name:`c`,type:`vec3`}]}),lpe=K(([e])=>{let t=X(e).toVar(),n=r0(y2(t,X(.04045))).toVar(),r=X(t.div(12.92)).toVar(),i=X(A4(C4(t.add(X(.055)),X(0)).div(1.055),X(2.4))).toVar();return L4(r,i,n)}).setLayout({name:`mx_srgb_texture_to_lin_rec709`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),J9=(e,t)=>{e=q(e),t=q(t);let n=Y(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return V4(e.sub(n),e.add(n),t)},Y9=(e,t,n,r)=>L4(e,t,n[r].clamp()),upe=(e,t,n=N3())=>Y9(e,t,n,`x`),dpe=(e,t,n=N3())=>Y9(e,t,n,`y`),X9=(e,t,n,r,i)=>L4(e,t,J9(n,r[i])),fpe=(e,t,n,r=N3())=>X9(e,t,n,r,`x`),ppe=(e,t,n,r=N3())=>X9(e,t,n,r,`y`),mpe=(e=1,t=0,n=N3())=>n.mul(e).add(t),hpe=(e,t=1)=>(e=q(e),e.abs().pow(t).mul(e.sign())),gpe=(e,t=1,n=.5)=>q(e).sub(n).mul(t).add(n),_pe=(e=N3(),t=1,n=0)=>H9(e.convert(`vec2|vec3`)).mul(t).add(n),vpe=(e=N3(),t=1,n=0)=>U9(e.convert(`vec2|vec3`)).mul(t).add(n),ype=(e=N3(),t=1,n=0)=>{e=e.convert(`vec2|vec3`);let r=i0(U9(e),H9(e.add(Y(19,73))));return r.mul(t).add(n)},bpe=(e=N3(),t=1)=>npe(e.convert(`vec2|vec3`),t,J(1)),xpe=(e=N3(),t=1)=>ipe(e.convert(`vec2|vec3`),t,J(1)),Spe=(e=N3(),t=1)=>ope(e.convert(`vec2|vec3`),t,J(1)),Cpe=(e=N3())=>Ufe(e.convert(`vec2|vec3`)),wpe=(e=N3(),t=3,n=2,r=.5,i=1)=>G9(e,J(t),n,r).mul(i),Tpe=(e=N3(),t=3,n=2,r=.5,i=1)=>Jfe(e,J(t),n,r).mul(i),Epe=(e=N3(),t=3,n=2,r=.5,i=1)=>K9(e,J(t),n,r).mul(i),Dpe=(e=N3(),t=3,n=2,r=.5,i=1)=>Yfe(e,J(t),n,r).mul(i),Ope=K(([e,t,n])=>{let r=e4(e).toVar(),i=f2(q(.5).mul(t.sub(n)),s6).div(r).toVar(),a=f2(q(-.5).mul(t.sub(n)),s6).div(r).toVar(),o=X().toVar();o.x=r.x.greaterThan(q(0)).select(i.x,a.x),o.y=r.y.greaterThan(q(0)).select(i.y,a.y),o.z=r.z.greaterThan(q(0)).select(i.z,a.z);let s=S4(o.x,o.y,o.z).toVar(),c=s6.add(r.mul(s)).toVar();return c.sub(n)}),kpe=K(([e,t])=>{let n=e.x,r=e.y,i=e.z,a=t.element(0).mul(.886227);return a=a.add(t.element(1).mul(2*.511664).mul(r)),a=a.add(t.element(2).mul(2*.511664).mul(i)),a=a.add(t.element(3).mul(2*.511664).mul(n)),a=a.add(t.element(4).mul(2*.429043).mul(n).mul(r)),a=a.add(t.element(5).mul(2*.429043).mul(r).mul(i)),a=a.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),a=a.add(t.element(7).mul(2*.429043).mul(n).mul(i)),a=a.add(t.element(8).mul(.429043).mul(p2(n,n).sub(p2(r,r)))),a});var $=Object.freeze({__proto__:null,BRDF_GGX:Uce,BRDF_Lambert:Rce,BasicPointShadowFilter:y9,BasicShadowFilter:s9,Break:_8,Const:r3,Continue:uce,DFGApprox:Wce,D_GGX:t5,Discard:O3,EPSILON:R2,F_Schlick:Q8,Fn:K,INFINITY:z2,If:K1,Loop:g8,NodeAccess:G$,NodeShaderStage:H$,NodeType:W$,NodeUpdateType:U$,PCFShadowFilter:c9,PCFSoftShadowFilter:l9,PI:B2,PI2:V2,PointShadowFilter:b9,Return:Doe,Schlick_to_F0:Gce,ScriptableNodeResources:V7,ShaderNode:B1,Stack:J1,Switch:q1,TBNViewMatrix:G6,VSMShadowFilter:u9,V_GGX_SmithCorrelated:e5,Var:n3,abs:c4,acesFilmicToneMapping:Que,acos:o4,add:d2,addMethodChaining:H,addNodeElement:Aoe,agxToneMapping:nde,all:H2,alphaT:M0,and:S2,anisotropy:N0,anisotropyB:F0,anisotropyT:P0,any:U2,append:g0,array:i2,arrayBuffer:f0,asin:a4,assign:o2,atan:s4,atan2:K4,atomicAdd:Pde,atomicAnd:Rde,atomicFunc:Z7,atomicLoad:Mde,atomicMax:Ide,atomicMin:Lde,atomicOr:zde,atomicStore:Nde,atomicSub:Fde,atomicXor:Bde,attenuationColor:q0,attenuationDistance:K0,attribute:M3,attributeArray:pue,backgroundBlurriness:_ue,backgroundIntensity:vue,backgroundRotation:yue,batch:d8,billboarding:Jle,bitAnd:E2,bitNot:D2,bitOr:O2,bitXor:k2,bitangentGeometry:dse,bitangentLocal:fse,bitangentView:U6,bitangentWorld:pse,bitcast:b4,blendBurn:D7,blendColor:kue,blendDodge:O7,blendOverlay:A7,blendScreen:k7,blur:E5,bool:Z1,buffer:V3,bufferAttribute:g3,bumpMap:J6,burn:Mue,bvec2:e0,bvec3:r0,bvec4:s0,bypass:C3,cache:x3,call:c2,cameraFar:q3,cameraIndex:G3,cameraNear:K3,cameraNormalMatrix:Hoe,cameraPosition:Uoe,cameraProjectionMatrix:J3,cameraProjectionMatrixInverse:Boe,cameraViewMatrix:Y3,cameraWorldMatrix:Voe,cbrt:F4,cdl:Bue,ceil:$2,checker:mfe,cineonToneMapping:Xue,clamp:R4,clearcoat:T0,clearcoatRoughness:E0,code:L7,color:Y1,colorSpaceToWorking:f3,colorToDirection:Ice,compute:b3,computeSkinning:cce,cond:Z4,context:$4,convert:m0,convertColorSpace:_oe,convertToTexture:cue,cos:r4,cross:k4,cubeTexture:M6,cubeTextureBase:j6,cubeToUV:v9,dFdx:p4,dFdy:m4,dashSize:B0,debug:A3,decrement:F2,decrementBefore:N2,defaultBuildStages:q$,defaultShaderStages:K$,defined:R1,degrees:G2,deltaTime:t7,densityFog:hde,densityFogFactor:W7,depth:U8,depthPass:Gue,difference:D4,diffuseColor:x0,directPointLight:pfe,directionToColor:Fce,dispersion:J0,distance:E4,div:m2,dodge:Nue,dot:O4,drawIndex:c8,dynamicBufferAttribute:_3,element:p0,emissive:S0,equal:g2,equals:x4,equirectUV:Z8,exp:K2,exp2:q2,expression:D3,faceDirection:f6,faceForward:H4,faceforward:q4,float:q,floor:Q2,fog:G7,fract:t4,frameGroup:Q0,frameId:Rle,frontFacing:d6,fwidth:v4,gain:jle,gapSize:V0,getConstNodeType:z1,getCurrentStack:G1,getDirection:S5,getDistanceAttenuation:w9,getGeometryRoughness:$8,getNormalFromDepth:uue,getParallaxCorrectNormal:Ope,getRoughness:zce,getScreenPosition:lue,getShIrradianceAt:kpe,getShadowMaterial:d9,getShadowRenderObjectFunction:m9,getTextureIndex:Y5,getViewPosition:y7,globalId:xde,glsl:ode,glslFn:cde,grayscale:Iue,greaterThan:y2,greaterThanEqual:x2,hash:Ale,highpModelNormalViewMatrix:nse,highpModelViewMatrix:tse,hue:zue,increment:P2,incrementBefore:M2,instance:tce,instanceIndex:s8,instancedArray:mue,instancedBufferAttribute:v3,instancedDynamicBufferAttribute:y3,instancedMesh:u8,int:J,inverseSqrt:Z2,inversesqrt:J4,invocationLocalIndex:ece,invocationSubgroupIndex:$se,ior:U0,iridescence:k0,iridescenceIOR:A0,iridescenceThickness:j0,ivec2:Q1,ivec3:t0,ivec4:a0,js:ide,label:e3,length:u4,lengthSq:I4,lessThan:v2,lessThanEqual:b2,lightPosition:t9,lightProjectionUV:Vde,lightShadowMatrix:e9,lightTargetDirection:Ude,lightTargetPosition:n9,lightViewPosition:Hde,lightingContext:C8,lights:qde,linearDepth:W8,linearToneMapping:Jue,localId:Sde,log:J2,log2:Y2,logarithmicDepthToViewZ:Tce,loop:dce,luminance:j7,mat2:c0,mat3:l0,mat4:u0,matcapUV:mle,materialAO:n8,materialAlphaTest:X6,materialAnisotropy:Ise,materialAnisotropyVector:r8,materialAttenuationColor:Wse,materialAttenuationDistance:Use,materialClearcoat:Ase,materialClearcoatNormal:Mse,materialClearcoatRoughness:jse,materialColor:Z6,materialDispersion:Zse,materialEmissive:Q6,materialEnvIntensity:ase,materialEnvRotation:T6,materialIOR:Hse,materialIridescence:Lse,materialIridescenceIOR:Rse,materialIridescenceThickness:zse,materialLightMap:t8,materialLineDashOffset:Yse,materialLineDashSize:Kse,materialLineGapSize:qse,materialLineScale:Gse,materialLineWidth:Jse,materialMetalness:kse,materialNormal:e8,materialOpacity:$6,materialPointSize:Xse,materialReference:I6,materialReflectivity:Dse,materialRefractionRatio:w6,materialRotation:Nse,materialRoughness:Ose,materialSheen:Pse,materialSheenRoughness:Fse,materialShininess:Sse,materialSpecular:Cse,materialSpecularColor:Tse,materialSpecularIntensity:wse,materialSpecularStrength:Ese,materialThickness:Vse,materialTransmission:Bse,max:C4,maxMipLevel:F3,mediumpModelViewMatrix:r6,metalness:w0,min:S4,mix:L4,mixElement:W4,mod:h2,modInt:L2,modelDirection:Yoe,modelNormalMatrix:t6,modelPosition:Xoe,modelRadius:$oe,modelScale:Zoe,modelViewMatrix:n6,modelViewPosition:Qoe,modelViewProjection:i8,modelWorldMatrix:e6,modelWorldMatrixInverse:ese,morphReference:x8,mrt:X5,mul:p2,mx_aastep:J9,mx_cell_noise_float:Cpe,mx_contrast:gpe,mx_fractal_noise_float:wpe,mx_fractal_noise_vec2:Tpe,mx_fractal_noise_vec3:Epe,mx_fractal_noise_vec4:Dpe,mx_hsvtorgb:spe,mx_noise_float:_pe,mx_noise_vec3:vpe,mx_noise_vec4:ype,mx_ramplr:upe,mx_ramptb:dpe,mx_rgbtohsv:cpe,mx_safepower:hpe,mx_splitlr:fpe,mx_splittb:ppe,mx_srgb_texture_to_lin_rec709:lpe,mx_transform_uv:mpe,mx_worley_noise_float:bpe,mx_worley_noise_vec2:xpe,mx_worley_noise_vec3:Spe,namespace:S3,negate:d4,neutralToneMapping:rde,nodeArray:H1,nodeImmutable:G,nodeObject:U,nodeObjects:V1,nodeProxy:W,normalFlat:h6,normalGeometry:p6,normalLocal:m6,normalMap:q6,normalView:g6,normalWorld:_6,normalize:e4,not:w2,notEqual:_2,numWorkgroups:yde,objectDirection:Woe,objectGroup:e2,objectPosition:Q3,objectRadius:Joe,objectScale:Koe,objectViewPosition:qoe,objectWorldMatrix:Goe,oneMinus:f4,or:C2,orthographicDepthToViewZ:wce,oscSawtooth:Gle,oscSine:Hle,oscSquare:Ule,oscTriangle:Wle,output:z0,outputStruct:Ole,overlay:Fue,overloadingFn:$5,parabola:Z5,parallaxDirection:K6,parallaxUV:hse,parameter:xle,pass:Uue,passTexture:Wue,pcurve:Mle,perspectiveDepthToViewZ:B8,pmremTexture:fle,pointShadow:ffe,pointUV:gue,pointWidth:H0,positionGeometry:i6,positionLocal:a6,positionPrevious:o6,positionView:l6,positionViewDirection:u6,positionWorld:s6,positionWorldDirection:c6,posterize:Hue,pow:A4,pow2:j4,pow3:M4,pow4:N4,premult:Aue,property:y0,radians:W2,rand:U4,range:_de,rangeFog:mde,rangeFogFactor:U7,reciprocal:g4,reference:P6,referenceBuffer:F6,reflect:T4,reflectVector:O6,reflectView:E6,reflector:rue,refract:B4,refractVector:k6,refractView:D6,reinhardToneMapping:Yue,remainder:I2,remap:T3,remapClamp:E3,renderGroup:$0,renderOutput:k3,rendererReference:p3,rotate:q5,rotateUV:Kle,roughness:C0,round:h4,rtt:v7,sRGBTransferEOTF:s3,sRGBTransferOETF:c3,sampler:Foe,samplerComparison:Ioe,saturate:z4,saturation:Lue,screen:Pue,screenCoordinate:k8,screenSize:O8,screenUV:D8,scriptable:pde,scriptableValue:z7,select:X4,setCurrentStack:W1,shaderStages:J$,shadow:cfe,shadowPositionWorld:a9,shapeCircle:hfe,sharedUniformGroup:Z0,sheen:D0,sheenRoughness:O0,shiftLeft:A2,shiftRight:j2,shininess:R0,sign:l4,sin:n4,sinc:Nle,skinning:h8,smoothstep:V4,smoothstepElement:G4,specularColor:I0,specularF90:L0,spherizeUV:qle,split:h0,spritesheetUV:Zle,sqrt:X2,stack:Cle,step:w4,storage:f8,storageBarrier:Ede,storageObject:sce,storageTexture:C7,string:d0,struct:Dle,sub:f2,subgroupIndex:Qse,subgroupSize:Cde,tan:i4,tangentGeometry:L6,tangentLocal:R6,tangentView:z6,tangentWorld:B6,temp:i3,texture:R3,texture3D:wue,textureBarrier:Dde,textureBicubic:Kce,textureCubeUV:C5,textureLoad:z3,textureSize:P3,textureStore:xue,thickness:G0,time:e7,timerDelta:Vle,timerGlobal:Ble,timerLocal:zle,toneMapping:m3,toneMappingExposure:h3,toonOutlinePass:que,transformDirection:P4,transformNormal:b6,transformNormalToView:x6,transformedBentNormalView:gse,transformedBitangentView:W6,transformedBitangentWorld:mse,transformedClearcoatNormalView:ise,transformedNormalView:v6,transformedNormalWorld:y6,transformedTangentView:V6,transformedTangentWorld:use,transmission:W0,transpose:y4,triNoise3D:Fle,triplanarTexture:$le,triplanarTextures:n7,trunc:_4,tslFn:_0,uint:X1,uniform:n2,uniformArray:U3,uniformCubeTexture:sse,uniformGroup:X0,uniformTexture:Poe,uniforms:Roe,unpremult:jue,userData:Eue,uv:N3,uvec2:$1,uvec3:n0,uvec4:o0,varying:a3,varyingProperty:b0,vec2:Y,vec3:X,vec4:i0,vectorComponents:Y$,velocity:Oue,vertexColor:J8,vertexIndex:o8,vertexStage:o3,vibrance:Rue,viewZToLogarithmicDepth:V8,viewZToOrthographicDepth:R8,viewZToPerspectiveDepth:z8,viewport:A8,viewportBottomLeft:bce,viewportCoordinate:M8,viewportDepthTexture:I8,viewportLinearDepth:Ece,viewportMipTexture:Sce,viewportResolution:vce,viewportSafeUV:Yle,viewportSharedTexture:Pce,viewportSize:j8,viewportTexture:xce,viewportTopLeft:yce,viewportUV:_ce,wgsl:ade,wgslFn:lde,workgroupArray:Ade,workgroupBarrier:Tde,workgroupId:bde,workingToColorSpace:d3,xor:T2}),Ape=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};Ape.isNodeFunctionInput=!0;var jpe=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn(`Abstract function.`)}};jpe.isNodeFunction=!0;const Mpe={[hY]:`never`,[gY]:`less`,[_Y]:`equal`,[vY]:`less-equal`,[yY]:`greater`,[xY]:`greater-equal`,[SY]:`always`,[bY]:`not-equal`},Z9=typeof self<`u`?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},Npe={[G$.READ_ONLY]:`read`,[G$.WRITE_ONLY]:`write`,[G$.READ_WRITE]:`read_write`},Ppe={[RJ]:`repeat`,[zJ]:`clamp`,[BJ]:`mirror`},Fpe={vertex:Z9?Z9.VERTEX:1,fragment:Z9?Z9.FRAGMENT:2,compute:Z9?Z9.COMPUTE:4},Q9={tsl_xor:new I7(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),mod_float:new I7(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),mod_vec2:new I7(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),mod_vec3:new I7(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),mod_vec4:new I7(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),equals_bool:new I7(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),equals_bvec2:new I7(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }`),equals_bvec3:new I7(`fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }`),equals_bvec4:new I7(`fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }`),repeatWrapping_float:new I7(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),mirrorWrapping_float:new I7(`fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }`),clampWrapping_float:new I7(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),biquadraticTexture:new I7(`
433
+ return { ...output, `+n+` };`,a=r+this.codeNode.code+i;return this._method=Function(...e,a),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose==`function`&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){let t=[T$(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(let n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return E$(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call(`main`),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}};const mde=W(pde).setParameterLength(1,2);function H7(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||l6.z).negate()}const U7=K(([e,t],n)=>{let r=H7(n);return V4(e,t,r)}),W7=K(([e],t)=>{let n=H7(t);return e.mul(e,n,n).negate().exp().oneMinus()}),G7=K(([e,t])=>i0(t.toFloat().mix(z0.rgb,e.toVec3()),z0.a));function hde(e,t,n){return console.warn(`THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.`),G7(e,U7(t,n))}function gde(e,t){return console.warn(`THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.`),G7(e,W7(t))}let K7=null,q7=null;var _de=class extends Q${static get type(){return`RangeNode`}constructor(e=q(),t=q()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=e.getTypeLength(L$(this.minNode.value)),n=e.getTypeLength(L$(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):`float`}setup(e){let t=e.object,n=null;if(t.count>1){let r=this.minNode.value,i=this.maxNode.value,a=e.getTypeLength(L$(r)),o=e.getTypeLength(L$(i));K7||=new eX,q7||=new eX,K7.setScalar(0),q7.setScalar(0),a===1?K7.setScalar(r):r.isColor?K7.set(r.r,r.g,r.b,1):K7.set(r.x,r.y,r.z||0,r.w||0),o===1?q7.setScalar(i):i.isColor?q7.set(i.r,i.g,i.b,1):q7.set(i.x,i.y,i.z||0,i.w||0);let s=4,c=s*t.count,l=new Float32Array(c);for(let e=0;e<c;e++){let t=e%s,n=K7.getComponent(t),r=q7.getComponent(t);l[e]=kY.lerp(n,r,Math.random())}let u=this.getNodeType(e);if(t.count<=4096)n=V3(l,`vec4`,t.count).element(s8).convert(u);else{let t=new pQ(l,4);e.geometry.setAttribute(`__range`+this.id,t),n=v3(t).convert(u)}}else n=q(0);return n}};const vde=W(_de).setParameterLength(2);var yde=class extends Q${static get type(){return`ComputeBuiltinNode`}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){return e.hasBuiltin(this._builtinName)}generate(e,t){let n=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage===`compute`?e.format(n,r,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${n} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}};const J7=(e,t)=>U(new yde(e,t)),bde=J7(`numWorkgroups`,`uvec3`),xde=J7(`workgroupId`,`uvec3`),Sde=J7(`globalId`,`uvec3`),Cde=J7(`localId`,`uvec3`),wde=J7(`subgroupSize`,`uint`);var Tde=class extends Q${constructor(e){super(),this.scope=e}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}};const Y7=W(Tde),Ede=()=>Y7(`workgroup`).toStack(),Dde=()=>Y7(`storage`).toStack(),Ode=()=>Y7(`texture`).toStack();var kde=class extends $${constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n,r=e.context.assign;if(n=super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}},Ade=class extends Q${constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return U(new kde(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}};const jde=(e,t)=>U(new Ade(`Workgroup`,e,t));var X7=class extends Q${static get type(){return`AtomicFunctionNode`}constructor(e,t,n){super(`uint`),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),n=t.parents,r=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,s=this.valueNode,c=[];c.push(`&${o.build(e,a)}`),s!==null&&c.push(s.build(e,a));let l=`${e.getMethod(r,i)}( ${c.join(`, `)} )`,u=n.length===1&&n[0].isStackNode===!0;if(u)e.addLineFlowCode(l,this);else return t.constNode===void 0&&(t.constNode=D3(l,i).toConst()),t.constNode.build(e)}};X7.ATOMIC_LOAD=`atomicLoad`,X7.ATOMIC_STORE=`atomicStore`,X7.ATOMIC_ADD=`atomicAdd`,X7.ATOMIC_SUB=`atomicSub`,X7.ATOMIC_MAX=`atomicMax`,X7.ATOMIC_MIN=`atomicMin`,X7.ATOMIC_AND=`atomicAnd`,X7.ATOMIC_OR=`atomicOr`,X7.ATOMIC_XOR=`atomicXor`;const Mde=W(X7),Z7=(e,t,n)=>Mde(e,t,n).toStack(),Nde=e=>Z7(X7.ATOMIC_LOAD,e,null),Pde=(e,t)=>Z7(X7.ATOMIC_STORE,e,t),Fde=(e,t)=>Z7(X7.ATOMIC_ADD,e,t),Ide=(e,t)=>Z7(X7.ATOMIC_SUB,e,t),Lde=(e,t)=>Z7(X7.ATOMIC_MAX,e,t),Rde=(e,t)=>Z7(X7.ATOMIC_MIN,e,t),zde=(e,t)=>Z7(X7.ATOMIC_AND,e,t),Bde=(e,t)=>Z7(X7.ATOMIC_OR,e,t),Vde=(e,t)=>Z7(X7.ATOMIC_XOR,e,t);let Q7;function $7(e){Q7||=new WeakMap;let t=Q7.get(e);return t===void 0&&Q7.set(e,t={}),t}function e9(e){let t=$7(e);return t.shadowMatrix||=n2(`mat4`).setGroup($0).onRenderUpdate(t=>((e.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&e.shadow.updateMatrices(e),e.shadow.matrix))}function Hde(e,t=s6){let n=e9(e).mul(t),r=n.xyz.div(n.w);return r}function t9(e){let t=$7(e);return t.position||=n2(new V).setGroup($0).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))}function n9(e){let t=$7(e);return t.targetPosition||=n2(new V).setGroup($0).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))}function Ude(e){let t=$7(e);return t.viewPosition||=n2(new V).setGroup($0).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new V,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)})}const Wde=e=>Y3.transformDirection(t9(e).sub(n9(e))),Gde=e=>e.sort((e,t)=>e.id-t.id),Kde=(e,t)=>{for(let n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},r9=new WeakMap,i9=[];var qde=class extends Q${static get type(){return`LightsNode`}constructor(){super(`vec3`),this.totalDiffuseNode=X().toVar(),this.totalSpecularNode=X().toVar(),this.outgoingLightNode=X().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t<e.length;t++){let n=e[t];if(i9.push(n.id),i9.push(n.castShadow?1:0),n.isSpotLight===!0){let e=n.map===null?-1:n.map.id,t=n.colorNode?n.colorNode.getCacheKey():-1;i9.push(e,t)}}let t=E$(i9);return i9.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);let t=[];for(let e of this._lightNodes)t.push(e.getSelf().getHash());this._lightNodesHash=`lights-`+t.join(`,`)}return this._lightNodesHash}analyze(e){let t=e.getNodeProperties(this);for(let n of t.nodes)n.build(e);t.outputNode.build(e)}setupLightsNode(e){let t=[],n=this._lightNodes,r=Gde(this._lights),i=e.renderer.library;for(let e of r)if(e.isNode)t.push(U(e));else{let r=null;if(n!==null&&(r=Kde(e.id,n)),r===null){let n=i.getLightNodeClass(e.constructor);if(n===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let r=null;r9.has(e)?r=r9.get(e):(r=U(new n(e)),r9.set(e,r)),t.push(r)}}this._lightNodes=t}setupDirectLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.direct({...n,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.directRectArea({...n,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(let n of t)n.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let n=this.outgoingLightNode,r=e.context,i=r.lightingModel,a=e.getNodeProperties(this);if(i){let{totalDiffuseNode:t,totalSpecularNode:o}=this;r.outgoingLight=n;let s=e.addStack();a.nodes=s.nodes,i.start(e);let{backdrop:c,backdropAlpha:l}=r,{directDiffuse:u,directSpecular:d,indirectDiffuse:f,indirectSpecular:p}=r.reflectedLight,m=u.add(f);c!==null&&(m=X(l===null?c:l.mix(m,c)),r.material.transparent=!0),t.assign(m),o.assign(d.add(p)),n.assign(t.add(o)),i.finish(e),n=n.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,n}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}};const Jde=(e=[])=>U(new qde).setLights(e);var Yde=class extends Q${static get type(){return`ShadowBaseNode`}constructor(e){super(),this.light=e,this.updateBeforeType=U$.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){a9.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||s6)}};const a9=y0(`vec3`,`shadowPositionWorld`);function Xde(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new SZ),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function Zde(e,t){return t=Xde(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function Qde(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function $de(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function efe(e,t){return t=$de(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function tfe(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function nfe(e,t,n){return n=Zde(e,n),n=efe(t,n),n}function rfe(e,t,n){Qde(e,n),tfe(t,n)}const o9=new WeakMap,s9=K(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=R3(e,t.xy).label(`t_basic`);return e.isArrayTexture&&(r=r.depth(n)),r.compare(t.z)}),c9=K(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=R3(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=P6(`mapSize`,`vec2`,n).setGroup($0),o=P6(`radius`,`float`,n).setGroup($0),s=Y(1).div(a),c=s.x.negate().mul(o),l=s.y.negate().mul(o),u=s.x.mul(o),d=s.y.mul(o),f=c.div(2),p=l.div(2),m=u.div(2),h=d.div(2);return d2(i(t.xy.add(Y(c,l)),t.z),i(t.xy.add(Y(0,l)),t.z),i(t.xy.add(Y(u,l)),t.z),i(t.xy.add(Y(f,p)),t.z),i(t.xy.add(Y(0,p)),t.z),i(t.xy.add(Y(m,p)),t.z),i(t.xy.add(Y(c,0)),t.z),i(t.xy.add(Y(f,0)),t.z),i(t.xy,t.z),i(t.xy.add(Y(m,0)),t.z),i(t.xy.add(Y(u,0)),t.z),i(t.xy.add(Y(f,h)),t.z),i(t.xy.add(Y(0,h)),t.z),i(t.xy.add(Y(m,h)),t.z),i(t.xy.add(Y(c,d)),t.z),i(t.xy.add(Y(0,d)),t.z),i(t.xy.add(Y(u,d)),t.z)).mul(1/17)}),l9=K(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=R3(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=P6(`mapSize`,`vec2`,n).setGroup($0),o=Y(1).div(a),s=o.x,c=o.y,l=t.xy,u=t4(l.mul(a).add(.5));return l.subAssign(u.mul(o)),d2(i(l,t.z),i(l.add(Y(s,0)),t.z),i(l.add(Y(0,c)),t.z),i(l.add(o),t.z),L4(i(l.add(Y(s.negate(),0)),t.z),i(l.add(Y(s.mul(2),0)),t.z),u.x),L4(i(l.add(Y(s.negate(),c)),t.z),i(l.add(Y(s.mul(2),c)),t.z),u.x),L4(i(l.add(Y(0,c.negate())),t.z),i(l.add(Y(0,c.mul(2))),t.z),u.y),L4(i(l.add(Y(s,c.negate())),t.z),i(l.add(Y(s,c.mul(2))),t.z),u.y),L4(L4(i(l.add(Y(s.negate(),c.negate())),t.z),i(l.add(Y(s.mul(2),c.negate())),t.z),u.x),L4(i(l.add(Y(s.negate(),c.mul(2))),t.z),i(l.add(Y(s.mul(2),c.mul(2))),t.z),u.x),u.y)).mul(1/9)}),u9=K(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=q(1).toVar(),i=R3(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(n)),i=i.rg;let a=w4(t.z,i.x);return K1(a.notEqual(q(1)),()=>{let e=t.z.sub(i.x),n=C4(0,i.y.mul(i.y)),o=n.div(n.add(e.mul(e)));o=R4(f2(o,.3).div(.6499999999999999)),r.assign(R4(C4(a,o)))}),r}),ife=K(([e,t,n])=>{let r=s6.sub(e).length();return r=r.sub(t).div(n.sub(t)),r=r.saturate(),r}),afe=e=>{let t=e.shadow.camera,n=P6(`near`,`float`,t).setGroup($0),r=P6(`far`,`float`,t).setGroup($0),i=Q3(e);return ife(i,n,r)},d9=e=>{let t=o9.get(e);if(t===void 0){let n=e.isPointLight?afe(e):null;t=new Y8,t.colorNode=i0(0,0,0,1),t.depthNode=n,t.isShadowPassMaterial=!0,t.name=`ShadowMaterial`,t.fog=!1,o9.set(e,t)}return t},f9=new ble,p9=[],m9=(e,t,n,r)=>{p9[0]=e,p9[1]=t;let i=f9.get(p9);return(i===void 0||i.shadowType!==n||i.useVelocity!==r)&&(i=(i,a,o,s,c,l,...u)=>{(i.castShadow===!0||i.receiveShadow&&n===Qq)&&(r&&(z$(i).useVelocity=!0),i.onBeforeShadow(e,i,o,t.camera,s,a.overrideMaterial,l),e.renderObject(i,a,o,s,c,l,...u),i.onAfterShadow(e,i,o,t.camera,s,a.overrideMaterial,l))},i.shadowType=n,i.useVelocity=r,f9.set(p9,i)),p9[0]=null,p9[1]=null,i},ofe=K(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=q(0).toVar(`meanVertical`),o=q(0).toVar(`squareMeanVertical`),s=e.lessThanEqual(q(1)).select(q(0),q(2).div(e.sub(1))),c=e.lessThanEqual(q(1)).select(q(0),q(-1));g8({start:J(0),end:J(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(q(e).mul(s)),u=r.sample(d2(k8.xy,Y(0,l).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),u=u.x,a.addAssign(u),o.addAssign(u.mul(u))}),a.divAssign(e),o.divAssign(e);let l=X2(o.sub(a.mul(a)));return Y(a,l)}),sfe=K(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=q(0).toVar(`meanHorizontal`),o=q(0).toVar(`squareMeanHorizontal`),s=e.lessThanEqual(q(1)).select(q(0),q(2).div(e.sub(1))),c=e.lessThanEqual(q(1)).select(q(0),q(-1));g8({start:J(0),end:J(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(q(e).mul(s)),u=r.sample(d2(k8.xy,Y(l,0).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),a.addAssign(u.x),o.addAssign(d2(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),o.divAssign(e);let l=X2(o.sub(a.mul(a)));return Y(a,l)}),cfe=[s9,c9,l9,u9];let h9;const g9=new _7;var _9=class extends Yde{static get type(){return`ShadowNode`}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a}){let o=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),s=t({depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a});return o.select(s,q(1))}setupShadowCoord(e,t){let{shadow:n}=this,{renderer:r}=e,i=P6(`bias`,`float`,n).setGroup($0),a=t,o;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z,r.coordinateSystem===tY&&(o=o.mul(2).sub(1));else{let e=a.w;a=a.xy.div(e);let t=P6(`near`,`float`,n.camera).setGroup($0),r=P6(`far`,`float`,n.camera).setGroup($0);o=V8(e.negate(),t,r)}return a=X(a.x,a.y.oneMinus(),o.add(i)),a}getShadowFilterFn(e){return cfe[e]}setupRenderTarget(e,t){let n=new yQ(e.mapSize.width,e.mapSize.height);n.name=`ShadowDepthTexture`,n.compareFunction=GJ;let r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name=`ShadowMap`,r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){let{renderer:t}=e,{light:n,shadow:r}=this,i=t.shadowMap.type,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(r,e);if(r.camera.updateProjectionMatrix(),i===Qq&&r.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:OJ,type:wJ,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name=`VSMVertical`),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:OJ,type:wJ,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name=`VSMHorizontal`),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:OJ,type:wJ,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:OJ,type:wJ,depthBuffer:!1}));let t=R3(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let n=R3(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(n=n.depth(this.depthLayer));let i=P6(`blurSamples`,`float`,r).setGroup($0),s=P6(`radius`,`float`,r).setGroup($0),c=P6(`mapSize`,`vec2`,r).setGroup($0),l=this.vsmMaterialVertical||=new Y8;l.fragmentNode=ofe({samples:i,radius:s,size:c,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMVertical`,l=this.vsmMaterialHorizontal||=new Y8,l.fragmentNode=sfe({samples:i,radius:s,size:c,shadowPass:n,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMHorizontal`}let s=P6(`intensity`,`float`,r).setGroup($0),c=P6(`normalBias`,`float`,r).setGroup($0),l=e9(n).mul(a9.add(y6.mul(c))),u=this.setupShadowCoord(e,l),d=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(d===null)throw Error(`THREE.WebGPURenderer: Shadow map type not supported yet.`);let f=i===Qq&&r.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,p=this.setupShadowFilter(e,{filterFn:d,shadowTexture:o.texture,depthTexture:f,shadowCoord:u,shadow:r,depthLayer:this.depthLayer}),m=R3(o.texture,u);a.isArrayTexture&&(m=m.depth(this.depthLayer));let h=L4(1,p.rgb.mix(m,1),s.mul(m.a)).toVar();return this.shadowMap=o,this.shadow.map=o,h}setup(e){if(e.renderer.shadowMap.enabled!==!1)return K(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn(`THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.`),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth),i.render(a,t.camera)}updateShadow(e){let{shadowMap:t,light:n,shadow:r}=this,{renderer:i,scene:a,camera:o}=e,s=i.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;let l=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=o.layers.mask);let u=i.getRenderObjectFunction(),d=i.getMRT(),f=d?d.has(`velocity`):!1;h9=nfe(i,a,h9),a.overrideMaterial=d9(n),i.setRenderObjectFunction(m9(i,r,s,f)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(u),s===Qq&&r.isPointLightShadow!==!0&&this.vsmPass(i),r.camera.layers.mask=l,rfe(i,a,h9)}vsmPass(e){let{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),g9.material=this.vsmMaterialVertical,g9.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),g9.material=this.vsmMaterialHorizontal,g9.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){let{shadow:t}=this,n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}};const lfe=(e,t)=>U(new _9(e,t)),ufe=new SZ,v9=K(([e,t])=>{let n=e.toVar(),r=c4(n),i=m2(1,C4(r.x,C4(r.y,r.z)));r.mulAssign(i),n.mulAssign(i.mul(t.mul(2).oneMinus()));let a=Y(n.xy).toVar(),o=t.mul(1.5),s=o.oneMinus();return K1(r.z.greaterThanEqual(s),()=>{K1(n.z.greaterThan(0),()=>{a.x.assign(f2(4,n.x))})}).ElseIf(r.x.greaterThanEqual(s),()=>{let e=l4(n.x);a.x.assign(n.z.mul(e).add(e.mul(2)))}).ElseIf(r.y.greaterThanEqual(s),()=>{let e=l4(n.y);a.x.assign(n.x.add(e.mul(2)).add(2)),a.y.assign(n.z.mul(e).sub(2))}),Y(.125,.25).mul(a).add(Y(.375,.75)).flipY()}).setLayout({name:`cubeToUV`,type:`vec2`,inputs:[{name:`pos`,type:`vec3`},{name:`texelSizeY`,type:`float`}]}),y9=K(({depthTexture:e,bd3D:t,dp:n,texelSize:r})=>R3(e,v9(t,r.y)).compare(n)),b9=K(({depthTexture:e,bd3D:t,dp:n,texelSize:r,shadow:i})=>{let a=P6(`radius`,`float`,i).setGroup($0),o=Y(-1,1).mul(a).mul(r.y);return R3(e,v9(t.add(o.xyy),r.y)).compare(n).add(R3(e,v9(t.add(o.yyy),r.y)).compare(n)).add(R3(e,v9(t.add(o.xyx),r.y)).compare(n)).add(R3(e,v9(t.add(o.yyx),r.y)).compare(n)).add(R3(e,v9(t,r.y)).compare(n)).add(R3(e,v9(t.add(o.xxy),r.y)).compare(n)).add(R3(e,v9(t.add(o.yxy),r.y)).compare(n)).add(R3(e,v9(t.add(o.xxx),r.y)).compare(n)).add(R3(e,v9(t.add(o.yxx),r.y)).compare(n)).mul(1/9)}),dfe=K(({filterFn:e,depthTexture:t,shadowCoord:n,shadow:r})=>{let i=n.xyz.toVar(),a=i.length(),o=n2(`float`).setGroup($0).onRenderUpdate(()=>r.camera.near),s=n2(`float`).setGroup($0).onRenderUpdate(()=>r.camera.far),c=P6(`bias`,`float`,r).setGroup($0),l=n2(r.mapSize).setGroup($0),u=q(1).toVar();return K1(a.sub(s).lessThanEqual(0).and(a.sub(o).greaterThanEqual(0)),()=>{let n=a.sub(o).div(s.sub(o)).toVar();n.addAssign(c);let d=i.normalize(),f=Y(1).div(l.mul(Y(4,2)));u.assign(e({depthTexture:t,bd3D:d,dp:n,texelSize:f,shadow:r}))}),u}),x9=new eX,S9=new AY,C9=new AY;var ffe=class extends _9{static get type(){return`PointShadowNode`}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===Zq?y9:b9}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:a}){return dfe({filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:a})}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e,o=t.getFrameExtents();C9.copy(t.mapSize),C9.multiply(o),n.setSize(C9.width,C9.height),S9.copy(t.mapSize);let s=i.autoClear,c=i.getClearColor(ufe),l=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();let u=t.getViewportCount();for(let e=0;e<u;e++){let o=t.getViewport(e),s=S9.x*o.x,c=C9.y-S9.y-S9.y*o.y;x9.set(s,c,S9.x*o.z,S9.y*o.w),n.viewport.copy(x9),t.updateMatrices(r,e),i.render(a,t.camera)}i.autoClear=s,i.setClearColor(c,l)}};const pfe=(e,t)=>U(new ffe(e,t)),w9=K(({lightDistance:e,cutoffDistance:t,decayExponent:n})=>{let r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),mfe=({color:e,lightVector:t,cutoffDistance:n,decayExponent:r})=>{let i=t.normalize(),a=t.length(),o=w9({lightDistance:a,cutoffDistance:n,decayExponent:r}),s=e.mul(o);return{lightDirection:i,lightColor:s}},hfe=K(([e=N3()])=>{let t=e.mul(2),n=t.x.floor(),r=t.y.floor(),i=n.add(r).mod(2);return i.sign()}),gfe=K(([e=N3()],{renderer:t,material:n})=>{let r=I4(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.samples>1){let e=q(r.fwidth()).toVar();i=V4(e.oneMinus(),e.add(1),r).oneMinus()}else i=X4(r.greaterThan(1),0,1);return i}),T9=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=Z1(e).toVar();return X4(a,i,r)}).setLayout({name:`mx_select`,type:`float`,inputs:[{name:`b`,type:`bool`},{name:`t`,type:`float`},{name:`f`,type:`float`}]}),E9=K(([e,t])=>{let n=Z1(t).toVar(),r=q(e).toVar();return X4(n,r.negate(),r)}).setLayout({name:`mx_negate_if`,type:`float`,inputs:[{name:`val`,type:`float`},{name:`b`,type:`bool`}]}),D9=K(([e])=>{let t=q(e).toVar();return J(Q2(t))}).setLayout({name:`mx_floor`,type:`int`,inputs:[{name:`x`,type:`float`}]}),O9=K(([e,t])=>{let n=q(e).toVar();return t.assign(D9(n)),n.sub(q(t))}),_fe=K(([e,t,n,r,i,a])=>{let o=q(a).toVar(),s=q(i).toVar(),c=q(r).toVar(),l=q(n).toVar(),u=q(t).toVar(),d=q(e).toVar(),f=q(f2(1,s)).toVar();return f2(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`}]}),vfe=K(([e,t,n,r,i,a])=>{let o=q(a).toVar(),s=q(i).toVar(),c=X(r).toVar(),l=X(n).toVar(),u=X(t).toVar(),d=X(e).toVar(),f=q(f2(1,s)).toVar();return f2(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`}]}),k9=$5([_fe,vfe]),yfe=K(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=q(u).toVar(),f=q(l).toVar(),p=q(c).toVar(),m=q(s).toVar(),h=q(o).toVar(),g=q(a).toVar(),_=q(i).toVar(),v=q(r).toVar(),y=q(n).toVar(),b=q(t).toVar(),x=q(e).toVar(),S=q(f2(1,p)).toVar(),ee=q(f2(1,f)).toVar(),te=q(f2(1,d)).toVar();return te.mul(ee.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(ee.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`v4`,type:`float`},{name:`v5`,type:`float`},{name:`v6`,type:`float`},{name:`v7`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]}),bfe=K(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=q(u).toVar(),f=q(l).toVar(),p=q(c).toVar(),m=X(s).toVar(),h=X(o).toVar(),g=X(a).toVar(),_=X(i).toVar(),v=X(r).toVar(),y=X(n).toVar(),b=X(t).toVar(),x=X(e).toVar(),S=q(f2(1,p)).toVar(),ee=q(f2(1,f)).toVar(),te=q(f2(1,d)).toVar();return te.mul(ee.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(ee.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`v4`,type:`vec3`},{name:`v5`,type:`vec3`},{name:`v6`,type:`vec3`},{name:`v7`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]}),A9=$5([yfe,bfe]),xfe=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=X1(e).toVar(),o=X1(a.bitAnd(X1(7))).toVar(),s=q(T9(o.lessThan(X1(4)),i,r)).toVar(),c=q(p2(2,T9(o.lessThan(X1(4)),r,i))).toVar();return E9(s,Z1(o.bitAnd(X1(1)))).add(E9(c,Z1(o.bitAnd(X1(2)))))}).setLayout({name:`mx_gradient_float_0`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),Sfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=q(t).toVar(),s=X1(e).toVar(),c=X1(s.bitAnd(X1(15))).toVar(),l=q(T9(c.lessThan(X1(8)),o,a)).toVar(),u=q(T9(c.lessThan(X1(4)),a,T9(c.equal(X1(12)).or(c.equal(X1(14))),o,i))).toVar();return E9(l,Z1(c.bitAnd(X1(1)))).add(E9(u,Z1(c.bitAnd(X1(2)))))}).setLayout({name:`mx_gradient_float_1`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]}),j9=$5([xfe,Sfe]),Cfe=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=n0(e).toVar();return X(j9(a.x,i,r),j9(a.y,i,r),j9(a.z,i,r))}).setLayout({name:`mx_gradient_vec3_0`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),wfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=q(t).toVar(),s=n0(e).toVar();return X(j9(s.x,o,a,i),j9(s.y,o,a,i),j9(s.z,o,a,i))}).setLayout({name:`mx_gradient_vec3_1`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]}),M9=$5([Cfe,wfe]),Tfe=K(([e])=>{let t=q(e).toVar();return p2(.6616,t)}).setLayout({name:`mx_gradient_scale2d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),Efe=K(([e])=>{let t=q(e).toVar();return p2(.982,t)}).setLayout({name:`mx_gradient_scale3d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),Dfe=K(([e])=>{let t=X(e).toVar();return p2(.6616,t)}).setLayout({name:`mx_gradient_scale2d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),N9=$5([Tfe,Dfe]),Ofe=K(([e])=>{let t=X(e).toVar();return p2(.982,t)}).setLayout({name:`mx_gradient_scale3d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),P9=$5([Efe,Ofe]),F9=K(([e,t])=>{let n=J(t).toVar(),r=X1(e).toVar();return r.shiftLeft(n).bitOr(r.shiftRight(J(32).sub(n)))}).setLayout({name:`mx_rotl32`,type:`uint`,inputs:[{name:`x`,type:`uint`},{name:`k`,type:`int`}]}),I9=K(([e,t,n])=>{e.subAssign(n),e.bitXorAssign(F9(n,J(4))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(F9(e,J(6))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(F9(t,J(8))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(F9(n,J(16))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(F9(e,J(19))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(F9(t,J(4))),t.addAssign(e)}),L9=K(([e,t,n])=>{let r=X1(n).toVar(),i=X1(t).toVar(),a=X1(e).toVar();return r.bitXorAssign(i),r.subAssign(F9(i,J(14))),a.bitXorAssign(r),a.subAssign(F9(r,J(11))),i.bitXorAssign(a),i.subAssign(F9(a,J(25))),r.bitXorAssign(i),r.subAssign(F9(i,J(16))),a.bitXorAssign(r),a.subAssign(F9(r,J(4))),i.bitXorAssign(a),i.subAssign(F9(a,J(14))),r.bitXorAssign(i),r.subAssign(F9(i,J(24))),r}).setLayout({name:`mx_bjfinal`,type:`uint`,inputs:[{name:`a`,type:`uint`},{name:`b`,type:`uint`},{name:`c`,type:`uint`}]}),R9=K(([e])=>{let t=X1(e).toVar();return q(t).div(q(X1(J(4294967295))))}).setLayout({name:`mx_bits_to_01`,type:`float`,inputs:[{name:`bits`,type:`uint`}]}),z9=K(([e])=>{let t=q(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:`mx_fade`,type:`float`,inputs:[{name:`t`,type:`float`}]}),kfe=K(([e])=>{let t=J(e).toVar(),n=X1(X1(1)).toVar(),r=X1(X1(J(3735928559)).add(n.shiftLeft(X1(2))).add(X1(13))).toVar();return L9(r.add(X1(t)),r,r)}).setLayout({name:`mx_hash_int_0`,type:`uint`,inputs:[{name:`x`,type:`int`}]}),Afe=K(([e,t])=>{let n=J(t).toVar(),r=J(e).toVar(),i=X1(X1(2)).toVar(),a=X1().toVar(),o=X1().toVar(),s=X1().toVar();return a.assign(o.assign(s.assign(X1(J(3735928559)).add(i.shiftLeft(X1(2))).add(X1(13))))),a.addAssign(X1(r)),o.addAssign(X1(n)),L9(a,o,s)}).setLayout({name:`mx_hash_int_1`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),jfe=K(([e,t,n])=>{let r=J(n).toVar(),i=J(t).toVar(),a=J(e).toVar(),o=X1(X1(3)).toVar(),s=X1().toVar(),c=X1().toVar(),l=X1().toVar();return s.assign(c.assign(l.assign(X1(J(3735928559)).add(o.shiftLeft(X1(2))).add(X1(13))))),s.addAssign(X1(a)),c.addAssign(X1(i)),l.addAssign(X1(r)),L9(s,c,l)}).setLayout({name:`mx_hash_int_2`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),Mfe=K(([e,t,n,r])=>{let i=J(r).toVar(),a=J(n).toVar(),o=J(t).toVar(),s=J(e).toVar(),c=X1(X1(4)).toVar(),l=X1().toVar(),u=X1().toVar(),d=X1().toVar();return l.assign(u.assign(d.assign(X1(J(3735928559)).add(c.shiftLeft(X1(2))).add(X1(13))))),l.addAssign(X1(s)),u.addAssign(X1(o)),d.addAssign(X1(a)),I9(l,u,d),l.addAssign(X1(i)),L9(l,u,d)}).setLayout({name:`mx_hash_int_3`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`}]}),Nfe=K(([e,t,n,r,i])=>{let a=J(i).toVar(),o=J(r).toVar(),s=J(n).toVar(),c=J(t).toVar(),l=J(e).toVar(),u=X1(X1(5)).toVar(),d=X1().toVar(),f=X1().toVar(),p=X1().toVar();return d.assign(f.assign(p.assign(X1(J(3735928559)).add(u.shiftLeft(X1(2))).add(X1(13))))),d.addAssign(X1(l)),f.addAssign(X1(c)),p.addAssign(X1(s)),I9(d,f,p),d.addAssign(X1(o)),f.addAssign(X1(a)),L9(d,f,p)}).setLayout({name:`mx_hash_int_4`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`},{name:`yy`,type:`int`}]}),B9=$5([kfe,Afe,jfe,Mfe,Nfe]),Pfe=K(([e,t])=>{let n=J(t).toVar(),r=J(e).toVar(),i=X1(B9(r,n)).toVar(),a=n0().toVar();return a.x.assign(i.bitAnd(J(255))),a.y.assign(i.shiftRight(J(8)).bitAnd(J(255))),a.z.assign(i.shiftRight(J(16)).bitAnd(J(255))),a}).setLayout({name:`mx_hash_vec3_0`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),Ffe=K(([e,t,n])=>{let r=J(n).toVar(),i=J(t).toVar(),a=J(e).toVar(),o=X1(B9(a,i,r)).toVar(),s=n0().toVar();return s.x.assign(o.bitAnd(J(255))),s.y.assign(o.shiftRight(J(8)).bitAnd(J(255))),s.z.assign(o.shiftRight(J(16)).bitAnd(J(255))),s}).setLayout({name:`mx_hash_vec3_1`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),V9=$5([Pfe,Ffe]),Ife=K(([e])=>{let t=Y(e).toVar(),n=J().toVar(),r=J().toVar(),i=q(O9(t.x,n)).toVar(),a=q(O9(t.y,r)).toVar(),o=q(z9(i)).toVar(),s=q(z9(a)).toVar(),c=q(k9(j9(B9(n,r),i,a),j9(B9(n.add(J(1)),r),i.sub(1),a),j9(B9(n,r.add(J(1))),i,a.sub(1)),j9(B9(n.add(J(1)),r.add(J(1))),i.sub(1),a.sub(1)),o,s)).toVar();return N9(c)}).setLayout({name:`mx_perlin_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),Lfe=K(([e])=>{let t=X(e).toVar(),n=J().toVar(),r=J().toVar(),i=J().toVar(),a=q(O9(t.x,n)).toVar(),o=q(O9(t.y,r)).toVar(),s=q(O9(t.z,i)).toVar(),c=q(z9(a)).toVar(),l=q(z9(o)).toVar(),u=q(z9(s)).toVar(),d=q(A9(j9(B9(n,r,i),a,o,s),j9(B9(n.add(J(1)),r,i),a.sub(1),o,s),j9(B9(n,r.add(J(1)),i),a,o.sub(1),s),j9(B9(n.add(J(1)),r.add(J(1)),i),a.sub(1),o.sub(1),s),j9(B9(n,r,i.add(J(1))),a,o,s.sub(1)),j9(B9(n.add(J(1)),r,i.add(J(1))),a.sub(1),o,s.sub(1)),j9(B9(n,r.add(J(1)),i.add(J(1))),a,o.sub(1),s.sub(1)),j9(B9(n.add(J(1)),r.add(J(1)),i.add(J(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar();return P9(d)}).setLayout({name:`mx_perlin_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),H9=$5([Ife,Lfe]),Rfe=K(([e])=>{let t=Y(e).toVar(),n=J().toVar(),r=J().toVar(),i=q(O9(t.x,n)).toVar(),a=q(O9(t.y,r)).toVar(),o=q(z9(i)).toVar(),s=q(z9(a)).toVar(),c=X(k9(M9(V9(n,r),i,a),M9(V9(n.add(J(1)),r),i.sub(1),a),M9(V9(n,r.add(J(1))),i,a.sub(1)),M9(V9(n.add(J(1)),r.add(J(1))),i.sub(1),a.sub(1)),o,s)).toVar();return N9(c)}).setLayout({name:`mx_perlin_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),zfe=K(([e])=>{let t=X(e).toVar(),n=J().toVar(),r=J().toVar(),i=J().toVar(),a=q(O9(t.x,n)).toVar(),o=q(O9(t.y,r)).toVar(),s=q(O9(t.z,i)).toVar(),c=q(z9(a)).toVar(),l=q(z9(o)).toVar(),u=q(z9(s)).toVar(),d=X(A9(M9(V9(n,r,i),a,o,s),M9(V9(n.add(J(1)),r,i),a.sub(1),o,s),M9(V9(n,r.add(J(1)),i),a,o.sub(1),s),M9(V9(n.add(J(1)),r.add(J(1)),i),a.sub(1),o.sub(1),s),M9(V9(n,r,i.add(J(1))),a,o,s.sub(1)),M9(V9(n.add(J(1)),r,i.add(J(1))),a.sub(1),o,s.sub(1)),M9(V9(n,r.add(J(1)),i.add(J(1))),a,o.sub(1),s.sub(1)),M9(V9(n.add(J(1)),r.add(J(1)),i.add(J(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar();return P9(d)}).setLayout({name:`mx_perlin_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),U9=$5([Rfe,zfe]),Bfe=K(([e])=>{let t=q(e).toVar(),n=J(D9(t)).toVar();return R9(B9(n))}).setLayout({name:`mx_cell_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`float`}]}),Vfe=K(([e])=>{let t=Y(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar();return R9(B9(n,r))}).setLayout({name:`mx_cell_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),Hfe=K(([e])=>{let t=X(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar();return R9(B9(n,r,i))}).setLayout({name:`mx_cell_noise_float_2`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),Ufe=K(([e])=>{let t=i0(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar(),a=J(D9(t.w)).toVar();return R9(B9(n,r,i,a))}).setLayout({name:`mx_cell_noise_float_3`,type:`float`,inputs:[{name:`p`,type:`vec4`}]}),Wfe=$5([Bfe,Vfe,Hfe,Ufe]),Gfe=K(([e])=>{let t=q(e).toVar(),n=J(D9(t)).toVar();return X(R9(B9(n,J(0))),R9(B9(n,J(1))),R9(B9(n,J(2))))}).setLayout({name:`mx_cell_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`float`}]}),Kfe=K(([e])=>{let t=Y(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar();return X(R9(B9(n,r,J(0))),R9(B9(n,r,J(1))),R9(B9(n,r,J(2))))}).setLayout({name:`mx_cell_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),qfe=K(([e])=>{let t=X(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar();return X(R9(B9(n,r,i,J(0))),R9(B9(n,r,i,J(1))),R9(B9(n,r,i,J(2))))}).setLayout({name:`mx_cell_noise_vec3_2`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Jfe=K(([e])=>{let t=i0(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar(),a=J(D9(t.w)).toVar();return X(R9(B9(n,r,i,a,J(0))),R9(B9(n,r,i,a,J(1))),R9(B9(n,r,i,a,J(2))))}).setLayout({name:`mx_cell_noise_vec3_3`,type:`vec3`,inputs:[{name:`p`,type:`vec4`}]}),W9=$5([Gfe,Kfe,qfe,Jfe]),G9=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=q(0).toVar(),l=q(1).toVar();return g8(o,()=>{c.addAssign(l.mul(H9(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_float`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),K9=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=X(0).toVar(),l=q(1).toVar();return g8(o,()=>{c.addAssign(l.mul(U9(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_vec3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),Yfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar();return Y(G9(s,o,a,i),G9(s.add(X(J(19),J(193),J(17))),o,a,i))}).setLayout({name:`mx_fractal_noise_vec2`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),Xfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=X(K9(s,o,a,i)).toVar(),l=q(G9(s.add(X(J(19),J(193),J(17))),o,a,i)).toVar();return i0(c,l)}).setLayout({name:`mx_fractal_noise_vec4`,type:`vec4`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),Zfe=K(([e,t,n,r,i,a,o])=>{let s=J(o).toVar(),c=q(a).toVar(),l=J(i).toVar(),u=J(r).toVar(),d=J(n).toVar(),f=J(t).toVar(),p=Y(e).toVar(),m=X(W9(Y(f.add(u),d.add(l)))).toVar(),h=Y(m.x,m.y).toVar();h.subAssign(.5),h.mulAssign(c),h.addAssign(.5);let g=Y(Y(q(f),q(d)).add(h)).toVar(),_=Y(g.sub(p)).toVar();return K1(s.equal(J(2)),()=>c4(_.x).add(c4(_.y))),K1(s.equal(J(3)),()=>C4(c4(_.x),c4(_.y))),O4(_,_)}).setLayout({name:`mx_worley_distance_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Qfe=K(([e,t,n,r,i,a,o,s,c])=>{let l=J(c).toVar(),u=q(s).toVar(),d=J(o).toVar(),f=J(a).toVar(),p=J(i).toVar(),m=J(r).toVar(),h=J(n).toVar(),g=J(t).toVar(),_=X(e).toVar(),v=X(W9(X(g.add(p),h.add(f),m.add(d)))).toVar();v.subAssign(.5),v.mulAssign(u),v.addAssign(.5);let y=X(X(q(g),q(h),q(m)).add(v)).toVar(),b=X(y.sub(_)).toVar();return K1(l.equal(J(2)),()=>c4(b.x).add(c4(b.y)).add(c4(b.z))),K1(l.equal(J(3)),()=>C4(c4(b.x),c4(b.y),c4(b.z))),O4(b,b)}).setLayout({name:`mx_worley_distance_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`zoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),q9=$5([Zfe,Qfe]),$fe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=q(1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();l.assign(S4(l,n))})}),K1(r.equal(J(0)),()=>{l.assign(X2(l))}),l}).setLayout({name:`mx_worley_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),epe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=Y(1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();K1(n.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.y.assign(n)})})}),K1(r.equal(J(0)),()=>{l.assign(X2(l))}),l}).setLayout({name:`mx_worley_noise_vec2_0`,type:`vec2`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),tpe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=X(1e6,1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();K1(n.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(n)}).ElseIf(n.lessThan(l.z),()=>{l.z.assign(n)})})}),K1(r.equal(J(0)),()=>{l.assign(X2(l))}),l}).setLayout({name:`mx_worley_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),npe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=q(1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();u.assign(S4(u,a))})})}),K1(r.equal(J(0)),()=>{u.assign(X2(u))}),u}).setLayout({name:`mx_worley_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),rpe=$5([$fe,npe]),ipe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=Y(1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();K1(a.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.y.assign(a)})})})}),K1(r.equal(J(0)),()=>{u.assign(X2(u))}),u}).setLayout({name:`mx_worley_noise_vec2_1`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),ape=$5([epe,ipe]),ope=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=X(1e6,1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();K1(a.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(a)}).ElseIf(a.lessThan(u.z),()=>{u.z.assign(a)})})})}),K1(r.equal(J(0)),()=>{u.assign(X2(u))}),u}).setLayout({name:`mx_worley_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),spe=$5([tpe,ope]),cpe=K(([e])=>{let t=e.y,n=e.z,r=X().toVar();return K1(t.lessThan(1e-4),()=>{r.assign(X(n,n,n))}).Else(()=>{let i=e.x;i=i.sub(Q2(i)).mul(6).toVar();let a=J(_4(i)),o=i.sub(q(a)),s=n.mul(t.oneMinus()),c=n.mul(t.mul(o).oneMinus()),l=n.mul(t.mul(o.oneMinus()).oneMinus());K1(a.equal(J(0)),()=>{r.assign(X(n,l,s))}).ElseIf(a.equal(J(1)),()=>{r.assign(X(c,n,s))}).ElseIf(a.equal(J(2)),()=>{r.assign(X(s,n,l))}).ElseIf(a.equal(J(3)),()=>{r.assign(X(s,c,n))}).ElseIf(a.equal(J(4)),()=>{r.assign(X(l,s,n))}).Else(()=>{r.assign(X(n,s,c))})}),r}).setLayout({name:`mx_hsvtorgb`,type:`vec3`,inputs:[{name:`hsv`,type:`vec3`}]}),lpe=K(([e])=>{let t=X(e).toVar(),n=q(t.x).toVar(),r=q(t.y).toVar(),i=q(t.z).toVar(),a=q(S4(n,S4(r,i))).toVar(),o=q(C4(n,C4(r,i))).toVar(),s=q(o.sub(a)).toVar(),c=q().toVar(),l=q().toVar(),u=q().toVar();return u.assign(o),K1(o.greaterThan(0),()=>{l.assign(s.div(o))}).Else(()=>{l.assign(0)}),K1(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{K1(n.greaterThanEqual(o),()=>{c.assign(r.sub(i).div(s))}).ElseIf(r.greaterThanEqual(o),()=>{c.assign(d2(2,i.sub(n).div(s)))}).Else(()=>{c.assign(d2(4,n.sub(r).div(s)))}),c.mulAssign(1/6),K1(c.lessThan(0),()=>{c.addAssign(1)})}),X(c,l,u)}).setLayout({name:`mx_rgbtohsv`,type:`vec3`,inputs:[{name:`c`,type:`vec3`}]}),upe=K(([e])=>{let t=X(e).toVar(),n=r0(y2(t,X(.04045))).toVar(),r=X(t.div(12.92)).toVar(),i=X(A4(C4(t.add(X(.055)),X(0)).div(1.055),X(2.4))).toVar();return L4(r,i,n)}).setLayout({name:`mx_srgb_texture_to_lin_rec709`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),J9=(e,t)=>{e=q(e),t=q(t);let n=Y(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return V4(e.sub(n),e.add(n),t)},Y9=(e,t,n,r)=>L4(e,t,n[r].clamp()),dpe=(e,t,n=N3())=>Y9(e,t,n,`x`),fpe=(e,t,n=N3())=>Y9(e,t,n,`y`),X9=(e,t,n,r,i)=>L4(e,t,J9(n,r[i])),ppe=(e,t,n,r=N3())=>X9(e,t,n,r,`x`),mpe=(e,t,n,r=N3())=>X9(e,t,n,r,`y`),hpe=(e=1,t=0,n=N3())=>n.mul(e).add(t),gpe=(e,t=1)=>(e=q(e),e.abs().pow(t).mul(e.sign())),_pe=(e,t=1,n=.5)=>q(e).sub(n).mul(t).add(n),vpe=(e=N3(),t=1,n=0)=>H9(e.convert(`vec2|vec3`)).mul(t).add(n),ype=(e=N3(),t=1,n=0)=>U9(e.convert(`vec2|vec3`)).mul(t).add(n),bpe=(e=N3(),t=1,n=0)=>{e=e.convert(`vec2|vec3`);let r=i0(U9(e),H9(e.add(Y(19,73))));return r.mul(t).add(n)},xpe=(e=N3(),t=1)=>rpe(e.convert(`vec2|vec3`),t,J(1)),Spe=(e=N3(),t=1)=>ape(e.convert(`vec2|vec3`),t,J(1)),Cpe=(e=N3(),t=1)=>spe(e.convert(`vec2|vec3`),t,J(1)),wpe=(e=N3())=>Wfe(e.convert(`vec2|vec3`)),Tpe=(e=N3(),t=3,n=2,r=.5,i=1)=>G9(e,J(t),n,r).mul(i),Epe=(e=N3(),t=3,n=2,r=.5,i=1)=>Yfe(e,J(t),n,r).mul(i),Dpe=(e=N3(),t=3,n=2,r=.5,i=1)=>K9(e,J(t),n,r).mul(i),Ope=(e=N3(),t=3,n=2,r=.5,i=1)=>Xfe(e,J(t),n,r).mul(i),kpe=K(([e,t,n])=>{let r=e4(e).toVar(),i=f2(q(.5).mul(t.sub(n)),s6).div(r).toVar(),a=f2(q(-.5).mul(t.sub(n)),s6).div(r).toVar(),o=X().toVar();o.x=r.x.greaterThan(q(0)).select(i.x,a.x),o.y=r.y.greaterThan(q(0)).select(i.y,a.y),o.z=r.z.greaterThan(q(0)).select(i.z,a.z);let s=S4(o.x,o.y,o.z).toVar(),c=s6.add(r.mul(s)).toVar();return c.sub(n)}),Ape=K(([e,t])=>{let n=e.x,r=e.y,i=e.z,a=t.element(0).mul(.886227);return a=a.add(t.element(1).mul(2*.511664).mul(r)),a=a.add(t.element(2).mul(2*.511664).mul(i)),a=a.add(t.element(3).mul(2*.511664).mul(n)),a=a.add(t.element(4).mul(2*.429043).mul(n).mul(r)),a=a.add(t.element(5).mul(2*.429043).mul(r).mul(i)),a=a.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),a=a.add(t.element(7).mul(2*.429043).mul(n).mul(i)),a=a.add(t.element(8).mul(.429043).mul(p2(n,n).sub(p2(r,r)))),a});var $=Object.freeze({__proto__:null,BRDF_GGX:Wce,BRDF_Lambert:zce,BasicPointShadowFilter:y9,BasicShadowFilter:s9,Break:_8,Const:r3,Continue:dce,DFGApprox:Gce,D_GGX:t5,Discard:O3,EPSILON:R2,F_Schlick:Q8,Fn:K,INFINITY:z2,If:K1,Loop:g8,NodeAccess:G$,NodeShaderStage:H$,NodeType:W$,NodeUpdateType:U$,PCFShadowFilter:c9,PCFSoftShadowFilter:l9,PI:B2,PI2:V2,PointShadowFilter:b9,Return:Ooe,Schlick_to_F0:Kce,ScriptableNodeResources:V7,ShaderNode:B1,Stack:J1,Switch:q1,TBNViewMatrix:G6,VSMShadowFilter:u9,V_GGX_SmithCorrelated:e5,Var:n3,abs:c4,acesFilmicToneMapping:$ue,acos:o4,add:d2,addMethodChaining:H,addNodeElement:joe,agxToneMapping:rde,all:H2,alphaT:M0,and:S2,anisotropy:N0,anisotropyB:F0,anisotropyT:P0,any:U2,append:g0,array:i2,arrayBuffer:f0,asin:a4,assign:o2,atan:s4,atan2:K4,atomicAdd:Fde,atomicAnd:zde,atomicFunc:Z7,atomicLoad:Nde,atomicMax:Lde,atomicMin:Rde,atomicOr:Bde,atomicStore:Pde,atomicSub:Ide,atomicXor:Vde,attenuationColor:q0,attenuationDistance:K0,attribute:M3,attributeArray:mue,backgroundBlurriness:vue,backgroundIntensity:yue,backgroundRotation:bue,batch:d8,billboarding:Yle,bitAnd:E2,bitNot:D2,bitOr:O2,bitXor:k2,bitangentGeometry:fse,bitangentLocal:pse,bitangentView:U6,bitangentWorld:mse,bitcast:b4,blendBurn:D7,blendColor:Aue,blendDodge:O7,blendOverlay:A7,blendScreen:k7,blur:E5,bool:Z1,buffer:V3,bufferAttribute:g3,bumpMap:J6,burn:Nue,bvec2:e0,bvec3:r0,bvec4:s0,bypass:C3,cache:x3,call:c2,cameraFar:q3,cameraIndex:G3,cameraNear:K3,cameraNormalMatrix:Uoe,cameraPosition:Woe,cameraProjectionMatrix:J3,cameraProjectionMatrixInverse:Voe,cameraViewMatrix:Y3,cameraWorldMatrix:Hoe,cbrt:F4,cdl:Vue,ceil:$2,checker:hfe,cineonToneMapping:Zue,clamp:R4,clearcoat:T0,clearcoatRoughness:E0,code:L7,color:Y1,colorSpaceToWorking:f3,colorToDirection:Lce,compute:b3,computeSkinning:lce,cond:Z4,context:$4,convert:m0,convertColorSpace:voe,convertToTexture:lue,cos:r4,cross:k4,cubeTexture:M6,cubeTextureBase:j6,cubeToUV:v9,dFdx:p4,dFdy:m4,dashSize:B0,debug:A3,decrement:F2,decrementBefore:N2,defaultBuildStages:q$,defaultShaderStages:K$,defined:R1,degrees:G2,deltaTime:t7,densityFog:gde,densityFogFactor:W7,depth:U8,depthPass:Kue,difference:D4,diffuseColor:x0,directPointLight:mfe,directionToColor:Ice,dispersion:J0,distance:E4,div:m2,dodge:Pue,dot:O4,drawIndex:c8,dynamicBufferAttribute:_3,element:p0,emissive:S0,equal:g2,equals:x4,equirectUV:Z8,exp:K2,exp2:q2,expression:D3,faceDirection:f6,faceForward:H4,faceforward:q4,float:q,floor:Q2,fog:G7,fract:t4,frameGroup:Q0,frameId:zle,frontFacing:d6,fwidth:v4,gain:Mle,gapSize:V0,getConstNodeType:z1,getCurrentStack:G1,getDirection:S5,getDistanceAttenuation:w9,getGeometryRoughness:$8,getNormalFromDepth:due,getParallaxCorrectNormal:kpe,getRoughness:Bce,getScreenPosition:uue,getShIrradianceAt:Ape,getShadowMaterial:d9,getShadowRenderObjectFunction:m9,getTextureIndex:Y5,getViewPosition:y7,globalId:Sde,glsl:sde,glslFn:lde,grayscale:Lue,greaterThan:y2,greaterThanEqual:x2,hash:jle,highpModelNormalViewMatrix:rse,highpModelViewMatrix:nse,hue:Bue,increment:P2,incrementBefore:M2,instance:nce,instanceIndex:s8,instancedArray:hue,instancedBufferAttribute:v3,instancedDynamicBufferAttribute:y3,instancedMesh:u8,int:J,inverseSqrt:Z2,inversesqrt:J4,invocationLocalIndex:tce,invocationSubgroupIndex:ece,ior:U0,iridescence:k0,iridescenceIOR:A0,iridescenceThickness:j0,ivec2:Q1,ivec3:t0,ivec4:a0,js:ade,label:e3,length:u4,lengthSq:I4,lessThan:v2,lessThanEqual:b2,lightPosition:t9,lightProjectionUV:Hde,lightShadowMatrix:e9,lightTargetDirection:Wde,lightTargetPosition:n9,lightViewPosition:Ude,lightingContext:C8,lights:Jde,linearDepth:W8,linearToneMapping:Yue,localId:Cde,log:J2,log2:Y2,logarithmicDepthToViewZ:Ece,loop:fce,luminance:j7,mat2:c0,mat3:l0,mat4:u0,matcapUV:hle,materialAO:n8,materialAlphaTest:X6,materialAnisotropy:Lse,materialAnisotropyVector:r8,materialAttenuationColor:Gse,materialAttenuationDistance:Wse,materialClearcoat:jse,materialClearcoatNormal:Nse,materialClearcoatRoughness:Mse,materialColor:Z6,materialDispersion:Qse,materialEmissive:Q6,materialEnvIntensity:ose,materialEnvRotation:T6,materialIOR:Use,materialIridescence:Rse,materialIridescenceIOR:zse,materialIridescenceThickness:Bse,materialLightMap:t8,materialLineDashOffset:Xse,materialLineDashSize:qse,materialLineGapSize:Jse,materialLineScale:Kse,materialLineWidth:Yse,materialMetalness:Ase,materialNormal:e8,materialOpacity:$6,materialPointSize:Zse,materialReference:I6,materialReflectivity:Ose,materialRefractionRatio:w6,materialRotation:Pse,materialRoughness:kse,materialSheen:Fse,materialSheenRoughness:Ise,materialShininess:Cse,materialSpecular:wse,materialSpecularColor:Ese,materialSpecularIntensity:Tse,materialSpecularStrength:Dse,materialThickness:Hse,materialTransmission:Vse,max:C4,maxMipLevel:F3,mediumpModelViewMatrix:r6,metalness:w0,min:S4,mix:L4,mixElement:W4,mod:h2,modInt:L2,modelDirection:Xoe,modelNormalMatrix:t6,modelPosition:Zoe,modelRadius:ese,modelScale:Qoe,modelViewMatrix:n6,modelViewPosition:$oe,modelViewProjection:i8,modelWorldMatrix:e6,modelWorldMatrixInverse:tse,morphReference:x8,mrt:X5,mul:p2,mx_aastep:J9,mx_cell_noise_float:wpe,mx_contrast:_pe,mx_fractal_noise_float:Tpe,mx_fractal_noise_vec2:Epe,mx_fractal_noise_vec3:Dpe,mx_fractal_noise_vec4:Ope,mx_hsvtorgb:cpe,mx_noise_float:vpe,mx_noise_vec3:ype,mx_noise_vec4:bpe,mx_ramplr:dpe,mx_ramptb:fpe,mx_rgbtohsv:lpe,mx_safepower:gpe,mx_splitlr:ppe,mx_splittb:mpe,mx_srgb_texture_to_lin_rec709:upe,mx_transform_uv:hpe,mx_worley_noise_float:xpe,mx_worley_noise_vec2:Spe,mx_worley_noise_vec3:Cpe,namespace:S3,negate:d4,neutralToneMapping:ide,nodeArray:H1,nodeImmutable:G,nodeObject:U,nodeObjects:V1,nodeProxy:W,normalFlat:h6,normalGeometry:p6,normalLocal:m6,normalMap:q6,normalView:g6,normalWorld:_6,normalize:e4,not:w2,notEqual:_2,numWorkgroups:bde,objectDirection:Goe,objectGroup:e2,objectPosition:Q3,objectRadius:Yoe,objectScale:qoe,objectViewPosition:Joe,objectWorldMatrix:Koe,oneMinus:f4,or:C2,orthographicDepthToViewZ:Tce,oscSawtooth:Kle,oscSine:Ule,oscSquare:Wle,oscTriangle:Gle,output:z0,outputStruct:kle,overlay:Iue,overloadingFn:$5,parabola:Z5,parallaxDirection:K6,parallaxUV:gse,parameter:Sle,pass:Wue,passTexture:Gue,pcurve:Nle,perspectiveDepthToViewZ:B8,pmremTexture:ple,pointShadow:pfe,pointUV:_ue,pointWidth:H0,positionGeometry:i6,positionLocal:a6,positionPrevious:o6,positionView:l6,positionViewDirection:u6,positionWorld:s6,positionWorldDirection:c6,posterize:Uue,pow:A4,pow2:j4,pow3:M4,pow4:N4,premult:jue,property:y0,radians:W2,rand:U4,range:vde,rangeFog:hde,rangeFogFactor:U7,reciprocal:g4,reference:P6,referenceBuffer:F6,reflect:T4,reflectVector:O6,reflectView:E6,reflector:iue,refract:B4,refractVector:k6,refractView:D6,reinhardToneMapping:Xue,remainder:I2,remap:T3,remapClamp:E3,renderGroup:$0,renderOutput:k3,rendererReference:p3,rotate:q5,rotateUV:qle,roughness:C0,round:h4,rtt:v7,sRGBTransferEOTF:s3,sRGBTransferOETF:c3,sampler:Ioe,samplerComparison:Loe,saturate:z4,saturation:Rue,screen:Fue,screenCoordinate:k8,screenSize:O8,screenUV:D8,scriptable:mde,scriptableValue:z7,select:X4,setCurrentStack:W1,shaderStages:J$,shadow:lfe,shadowPositionWorld:a9,shapeCircle:gfe,sharedUniformGroup:Z0,sheen:D0,sheenRoughness:O0,shiftLeft:A2,shiftRight:j2,shininess:R0,sign:l4,sin:n4,sinc:Ple,skinning:h8,smoothstep:V4,smoothstepElement:G4,specularColor:I0,specularF90:L0,spherizeUV:Jle,split:h0,spritesheetUV:Qle,sqrt:X2,stack:wle,step:w4,storage:f8,storageBarrier:Dde,storageObject:cce,storageTexture:C7,string:d0,struct:Ole,sub:f2,subgroupIndex:$se,subgroupSize:wde,tan:i4,tangentGeometry:L6,tangentLocal:R6,tangentView:z6,tangentWorld:B6,temp:i3,texture:R3,texture3D:Tue,textureBarrier:Ode,textureBicubic:qce,textureCubeUV:C5,textureLoad:z3,textureSize:P3,textureStore:Sue,thickness:G0,time:e7,timerDelta:Hle,timerGlobal:Vle,timerLocal:Ble,toneMapping:m3,toneMappingExposure:h3,toonOutlinePass:Jue,transformDirection:P4,transformNormal:b6,transformNormalToView:x6,transformedBentNormalView:_se,transformedBitangentView:W6,transformedBitangentWorld:hse,transformedClearcoatNormalView:ase,transformedNormalView:v6,transformedNormalWorld:y6,transformedTangentView:V6,transformedTangentWorld:dse,transmission:W0,transpose:y4,triNoise3D:Ile,triplanarTexture:eue,triplanarTextures:n7,trunc:_4,tslFn:_0,uint:X1,uniform:n2,uniformArray:U3,uniformCubeTexture:cse,uniformGroup:X0,uniformTexture:Foe,uniforms:zoe,unpremult:Mue,userData:Due,uv:N3,uvec2:$1,uvec3:n0,uvec4:o0,varying:a3,varyingProperty:b0,vec2:Y,vec3:X,vec4:i0,vectorComponents:Y$,velocity:kue,vertexColor:J8,vertexIndex:o8,vertexStage:o3,vibrance:zue,viewZToLogarithmicDepth:V8,viewZToOrthographicDepth:R8,viewZToPerspectiveDepth:z8,viewport:A8,viewportBottomLeft:xce,viewportCoordinate:M8,viewportDepthTexture:I8,viewportLinearDepth:Dce,viewportMipTexture:Cce,viewportResolution:yce,viewportSafeUV:Xle,viewportSharedTexture:Fce,viewportSize:j8,viewportTexture:Sce,viewportTopLeft:bce,viewportUV:vce,wgsl:ode,wgslFn:ude,workgroupArray:jde,workgroupBarrier:Ede,workgroupId:xde,workingToColorSpace:d3,xor:T2}),jpe=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};jpe.isNodeFunctionInput=!0;var Mpe=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn(`Abstract function.`)}};Mpe.isNodeFunction=!0;const Npe={[WJ]:`never`,[GJ]:`less`,[KJ]:`equal`,[qJ]:`less-equal`,[JJ]:`greater`,[XJ]:`greater-equal`,[ZJ]:`always`,[YJ]:`not-equal`},Z9=typeof self<`u`?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},Ppe={[G$.READ_ONLY]:`read`,[G$.WRITE_ONLY]:`write`,[G$.READ_WRITE]:`read_write`},Fpe={[pJ]:`repeat`,[mJ]:`clamp`,[hJ]:`mirror`},Ipe={vertex:Z9?Z9.VERTEX:1,fragment:Z9?Z9.FRAGMENT:2,compute:Z9?Z9.COMPUTE:4},Q9={tsl_xor:new I7(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),mod_float:new I7(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),mod_vec2:new I7(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),mod_vec3:new I7(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),mod_vec4:new I7(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),equals_bool:new I7(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),equals_bvec2:new I7(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }`),equals_bvec3:new I7(`fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }`),equals_bvec4:new I7(`fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }`),repeatWrapping_float:new I7(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),mirrorWrapping_float:new I7(`fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }`),clampWrapping_float:new I7(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),biquadraticTexture:new I7(`
434
434
  fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
435
435
 
436
436
  let res = vec2f( iRes );
@@ -452,5 +452,5 @@ fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, l
452
452
  return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
453
453
 
454
454
  }
455
- `)},$9={dFdx:`dpdx`,dFdy:`- dpdy`,mod_float:`tsl_mod_float`,mod_vec2:`tsl_mod_vec2`,mod_vec3:`tsl_mod_vec3`,mod_vec4:`tsl_mod_vec4`,equals_bool:`tsl_equals_bool`,equals_bvec2:`tsl_equals_bvec2`,equals_bvec3:`tsl_equals_bvec3`,equals_bvec4:`tsl_equals_bvec4`,inversesqrt:`inverseSqrt`,bitcast:`bitcast<f32>`};typeof navigator<`u`&&/Windows/g.test(navigator.userAgent)&&(Q9.pow_float=new I7(`fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }`),Q9.pow_vec2=new I7(`fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }`,[Q9.pow_float]),Q9.pow_vec3=new I7(`fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }`,[Q9.pow_float]),Q9.pow_vec4=new I7(`fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }`,[Q9.pow_float]),$9.pow_float=`tsl_pow_float`,$9.pow_vec2=`tsl_pow_vec2`,$9.pow_vec3=`tsl_pow_vec3`,$9.pow_vec4=`tsl_pow_vec4`);let Ipe=``;(typeof navigator<`u`&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(Ipe+=`diagnostic( off, derivative_uniformity );
456
- `);const Lpe=$.BRDF_GGX,Rpe=$.BRDF_Lambert,zpe=$.BasicShadowFilter,Bpe=$.Break,Vpe=$.Continue,Hpe=$.DFGApprox,Upe=$.D_GGX,Wpe=$.Discard,Gpe=$.EPSILON,Kpe=$.F_Schlick,qpe=$.Fn,Jpe=$.INFINITY,Ype=$.If,Xpe=$.Switch,Zpe=$.Loop,Qpe=$.NodeShaderStage,$pe=$.NodeType,eme=$.NodeUpdateType,tme=$.NodeAccess,nme=$.PCFShadowFilter,rme=$.PCFSoftShadowFilter,ime=$.PI,ame=$.PI2,ome=$.Return,sme=$.Schlick_to_F0,cme=$.ScriptableNodeResources,lme=$.ShaderNode,ume=$.TBNViewMatrix,dme=$.VSMShadowFilter,fme=$.V_GGX_SmithCorrelated,pme=$.abs,mme=$.acesFilmicToneMapping,hme=$.acos,gme=$.add,_me=$.addNodeElement,vme=$.agxToneMapping,yme=$.all,bme=$.alphaT,xme=$.and,Sme=$.anisotropy,Cme=$.anisotropyB,wme=$.anisotropyT,Tme=$.any,Eme=$.append,Dme=$.array,Ome=$.arrayBuffer,kme=$.asin,Ame=$.assign,jme=$.atan,Mme=$.atan2,Nme=$.atomicAdd,Pme=$.atomicAnd,Fme=$.atomicFunc,Ime=$.atomicMax,Lme=$.atomicMin,Rme=$.atomicOr,zme=$.atomicStore,Bme=$.atomicSub,Vme=$.atomicXor,Hme=$.atomicLoad,Ume=$.attenuationColor,Wme=$.attenuationDistance,Gme=$.attribute,Kme=$.attributeArray,qme=$.backgroundBlurriness,Jme=$.backgroundIntensity,Yme=$.backgroundRotation,Xme=$.batch,Zme=$.billboarding,Qme=$.bitAnd,$me=$.bitNot,ehe=$.bitOr,the=$.bitXor,nhe=$.bitangentGeometry,rhe=$.bitangentLocal,ihe=$.bitangentView,ahe=$.bitangentWorld,ohe=$.bitcast,she=$.blendBurn,che=$.blendColor,lhe=$.blendDodge,uhe=$.blendOverlay,dhe=$.blendScreen,fhe=$.blur,phe=$.bool,mhe=$.buffer,hhe=$.bufferAttribute,ghe=$.bumpMap,_he=$.burn,vhe=$.bvec2,yhe=$.bvec3,bhe=$.bvec4,xhe=$.bypass,She=$.cache,Che=$.call,whe=$.cameraFar,The=$.cameraIndex,Ehe=$.cameraNear,Dhe=$.cameraNormalMatrix,Ohe=$.cameraPosition,khe=$.cameraProjectionMatrix,Ahe=$.cameraProjectionMatrixInverse,jhe=$.cameraViewMatrix,Mhe=$.cameraWorldMatrix,Nhe=$.cbrt,Phe=$.cdl,Fhe=$.ceil,Ihe=$.checker,Lhe=$.cineonToneMapping,Rhe=$.clamp,zhe=$.clearcoat,Bhe=$.clearcoatRoughness,Vhe=$.code,Hhe=$.color,Uhe=$.colorSpaceToWorking,Whe=$.colorToDirection,Ghe=$.compute,Khe=$.computeSkinning,qhe=$.cond,Jhe=$.Const,Yhe=$.context,Xhe=$.convert,Zhe=$.convertColorSpace,Qhe=$.convertToTexture,$he=$.cos,ege=$.cross,tge=$.cubeTexture,nge=$.dFdx,rge=$.dFdy,ige=$.dashSize,age=$.debug,oge=$.decrement,sge=$.decrementBefore,cge=$.defaultBuildStages,lge=$.defaultShaderStages,uge=$.defined,dge=$.degrees,fge=$.deltaTime,pge=$.densityFog,mge=$.densityFogFactor,hge=$.depth,gge=$.depthPass,_ge=$.difference,vge=$.diffuseColor,yge=$.directPointLight,bge=$.directionToColor,xge=$.dispersion,Sge=$.distance,Cge=$.div,wge=$.dodge,Tge=$.dot,Ege=$.drawIndex,Dge=$.dynamicBufferAttribute,Oge=$.element,kge=$.emissive,Age=$.equal,jge=$.equals,Mge=$.equirectUV,Nge=$.exp,Pge=$.exp2,Fge=$.expression,Ige=$.faceDirection,Lge=$.faceForward,Rge=$.faceforward,zge=$.float,Bge=$.floor,Vge=$.fog,Hge=$.fract,Uge=$.frameGroup,Wge=$.frameId,Gge=$.frontFacing,Kge=$.fwidth,qge=$.gain,Jge=$.gapSize,Yge=$.getConstNodeType,Xge=$.getCurrentStack,Zge=$.getDirection,Qge=$.getDistanceAttenuation,$ge=$.getGeometryRoughness,e_e=$.getNormalFromDepth,t_e=$.getParallaxCorrectNormal,n_e=$.getRoughness,r_e=$.getScreenPosition,i_e=$.getShIrradianceAt,a_e=$.getTextureIndex,o_e=$.getViewPosition,s_e=$.getShadowMaterial,c_e=$.getShadowRenderObjectFunction,l_e=$.glsl,u_e=$.glslFn,d_e=$.grayscale,f_e=$.greaterThan,p_e=$.greaterThanEqual,m_e=$.hash,h_e=$.highpModelNormalViewMatrix,g_e=$.highpModelViewMatrix,__e=$.hue,v_e=$.increment,y_e=$.incrementBefore,b_e=$.instance,x_e=$.instanceIndex,S_e=$.instancedArray,C_e=$.instancedBufferAttribute,w_e=$.instancedDynamicBufferAttribute,T_e=$.instancedMesh,E_e=$.int,D_e=$.inverseSqrt,O_e=$.inversesqrt,k_e=$.invocationLocalIndex,A_e=$.invocationSubgroupIndex,j_e=$.ior,M_e=$.iridescence,N_e=$.iridescenceIOR,P_e=$.iridescenceThickness,F_e=$.ivec2,I_e=$.ivec3,L_e=$.ivec4,R_e=$.js,z_e=$.label,B_e=$.length,V_e=$.lengthSq,H_e=$.lessThan,U_e=$.lessThanEqual,W_e=$.lightPosition,G_e=$.lightShadowMatrix,K_e=$.lightTargetDirection,q_e=$.lightTargetPosition,J_e=$.lightViewPosition,Y_e=$.lightingContext,X_e=$.lights,Z_e=$.linearDepth,Q_e=$.linearToneMapping,$_e=$.localId,eve=$.globalId,tve=$.log,nve=$.log2,rve=$.logarithmicDepthToViewZ,ive=$.loop,ave=$.luminance,ove=$.mediumpModelViewMatrix,sve=$.mat2,cve=$.mat3,lve=$.mat4,uve=$.matcapUV,dve=$.materialAO,fve=$.materialAlphaTest,pve=$.materialAnisotropy,mve=$.materialAnisotropyVector,hve=$.materialAttenuationColor,gve=$.materialAttenuationDistance,_ve=$.materialClearcoat,vve=$.materialClearcoatNormal,yve=$.materialClearcoatRoughness,bve=$.materialColor,xve=$.materialDispersion,Sve=$.materialEmissive,Cve=$.materialIOR,wve=$.materialIridescence,Tve=$.materialIridescenceIOR,Eve=$.materialIridescenceThickness,Dve=$.materialLightMap,Ove=$.materialLineDashOffset,kve=$.materialLineDashSize,Ave=$.materialLineGapSize,jve=$.materialLineScale,Mve=$.materialLineWidth,Nve=$.materialMetalness,Pve=$.materialNormal,Fve=$.materialOpacity,Ive=$.materialPointSize,Lve=$.materialReference,Rve=$.materialReflectivity,zve=$.materialRefractionRatio,Bve=$.materialRotation,Vve=$.materialRoughness,Hve=$.materialSheen,Uve=$.materialSheenRoughness,Wve=$.materialShininess,Gve=$.materialSpecular,Kve=$.materialSpecularColor,qve=$.materialSpecularIntensity,Jve=$.materialSpecularStrength,Yve=$.materialThickness,Xve=$.materialTransmission,Zve=$.max,Qve=$.maxMipLevel,$ve=$.metalness,eye=$.min,tye=$.mix,nye=$.mixElement,rye=$.mod,iye=$.modInt,aye=$.modelDirection,oye=$.modelNormalMatrix,sye=$.modelPosition,cye=$.modelRadius,lye=$.modelScale,uye=$.modelViewMatrix,dye=$.modelViewPosition,fye=$.modelViewProjection,pye=$.modelWorldMatrix,mye=$.modelWorldMatrixInverse,hye=$.morphReference,gye=$.mrt,_ye=$.mul,vye=$.mx_aastep,yye=$.mx_cell_noise_float,bye=$.mx_contrast,xye=$.mx_fractal_noise_float,Sye=$.mx_fractal_noise_vec2,Cye=$.mx_fractal_noise_vec3,wye=$.mx_fractal_noise_vec4,Tye=$.mx_hsvtorgb,Eye=$.mx_noise_float,Dye=$.mx_noise_vec3,Oye=$.mx_noise_vec4,kye=$.mx_ramplr,Aye=$.mx_ramptb,jye=$.mx_rgbtohsv,Mye=$.mx_safepower,Nye=$.mx_splitlr,Pye=$.mx_splittb,Fye=$.mx_srgb_texture_to_lin_rec709,Iye=$.mx_transform_uv,Lye=$.mx_worley_noise_float,Rye=$.mx_worley_noise_vec2,zye=$.mx_worley_noise_vec3,Bye=$.namespace,Vye=$.negate,Hye=$.neutralToneMapping,Uye=$.nodeArray,Wye=$.nodeImmutable,Gye=$.nodeObject,Kye=$.nodeObjects,qye=$.nodeProxy,Jye=$.normalFlat,Yye=$.normalGeometry,Xye=$.normalLocal,Zye=$.normalMap,Qye=$.normalView,$ye=$.normalWorld,ebe=$.normalize,tbe=$.not,nbe=$.notEqual,rbe=$.numWorkgroups,ibe=$.objectDirection,abe=$.objectGroup,obe=$.objectPosition,sbe=$.objectRadius,cbe=$.objectScale,lbe=$.objectViewPosition,ube=$.objectWorldMatrix,dbe=$.oneMinus,fbe=$.or,pbe=$.orthographicDepthToViewZ,mbe=$.oscSawtooth,hbe=$.oscSine,gbe=$.oscSquare,_be=$.oscTriangle,vbe=$.output,ybe=$.outputStruct,bbe=$.overlay,xbe=$.overloadingFn,Sbe=$.parabola,Cbe=$.parallaxDirection,wbe=$.parallaxUV,Tbe=$.parameter,Ebe=$.pass,Dbe=$.passTexture,Obe=$.pcurve,kbe=$.perspectiveDepthToViewZ,Abe=$.pmremTexture,jbe=$.pointUV,Mbe=$.pointWidth,Nbe=$.positionGeometry,Pbe=$.positionLocal,Fbe=$.positionPrevious,Ibe=$.positionView,Lbe=$.positionViewDirection,Rbe=$.positionWorld,zbe=$.positionWorldDirection,Bbe=$.posterize,Vbe=$.pow,Hbe=$.pow2,Ube=$.pow3,Wbe=$.pow4,Gbe=$.premult,Kbe=$.property,qbe=$.radians,Jbe=$.rand,Ybe=$.range,Xbe=$.rangeFog,Zbe=$.rangeFogFactor,Qbe=$.reciprocal,$be=$.lightProjectionUV,exe=$.reference,txe=$.referenceBuffer,nxe=$.reflect,rxe=$.reflectVector,ixe=$.reflectView,axe=$.reflector,oxe=$.refract,sxe=$.refractVector,cxe=$.refractView,lxe=$.reinhardToneMapping,uxe=$.remainder,dxe=$.remap,fxe=$.remapClamp,pxe=$.renderGroup,mxe=$.renderOutput,hxe=$.rendererReference,gxe=$.rotate,_xe=$.rotateUV,vxe=$.roughness,yxe=$.round,bxe=$.rtt,xxe=$.sRGBTransferEOTF,Sxe=$.sRGBTransferOETF,Cxe=$.sampler,wxe=$.samplerComparison,Txe=$.saturate,Exe=$.saturation,Dxe=$.screen,Oxe=$.screenCoordinate,kxe=$.screenSize,Axe=$.screenUV,jxe=$.scriptable,Mxe=$.scriptableValue,Nxe=$.select,Pxe=$.setCurrentStack,Fxe=$.shaderStages,Ixe=$.shadow,Lxe=$.pointShadow,Rxe=$.shadowPositionWorld,zxe=$.sharedUniformGroup,Bxe=$.shapeCircle,Vxe=$.sheen,Hxe=$.sheenRoughness,Uxe=$.shiftLeft,Wxe=$.shiftRight,Gxe=$.shininess,Kxe=$.sign,qxe=$.sin,Jxe=$.sinc,Yxe=$.skinning,Xxe=$.smoothstep,Zxe=$.smoothstepElement,Qxe=$.specularColor,$xe=$.specularF90,eSe=$.spherizeUV,tSe=$.split,nSe=$.spritesheetUV,rSe=$.sqrt,iSe=$.stack,aSe=$.step,oSe=$.storage,sSe=$.storageBarrier,cSe=$.storageObject,lSe=$.storageTexture,uSe=$.string,dSe=$.struct,fSe=$.sub,pSe=$.subgroupIndex,mSe=$.subgroupSize,hSe=$.tan,gSe=$.tangentGeometry,_Se=$.tangentLocal,vSe=$.tangentView,ySe=$.tangentWorld,bSe=$.temp,xSe=$.texture,SSe=$.texture3D,CSe=$.textureBarrier,wSe=$.textureBicubic,TSe=$.textureCubeUV,ESe=$.textureLoad,DSe=$.textureSize,OSe=$.textureStore,kSe=$.thickness,ASe=$.time,jSe=$.timerDelta,MSe=$.timerGlobal,NSe=$.timerLocal,PSe=$.toneMapping,FSe=$.toneMappingExposure,ISe=$.toonOutlinePass,LSe=$.transformDirection,RSe=$.transformNormal,zSe=$.transformNormalToView,BSe=$.transformedBentNormalView,VSe=$.transformedBitangentView,HSe=$.transformedBitangentWorld,USe=$.transformedClearcoatNormalView,WSe=$.transformedNormalView,GSe=$.transformedNormalWorld,KSe=$.transformedTangentView,qSe=$.transformedTangentWorld,JSe=$.transmission,YSe=$.transpose,XSe=$.triNoise3D,ZSe=$.triplanarTexture,QSe=$.triplanarTextures,$Se=$.trunc,eCe=$.tslFn,tCe=$.uint,nCe=$.uniform,rCe=$.uniformCubeTexture,iCe=$.uniformArray,aCe=$.uniformGroup,oCe=$.uniformTexture,sCe=$.uniforms,cCe=$.unpremult,lCe=$.userData,uCe=$.uv,dCe=$.uvec2,fCe=$.uvec3,pCe=$.uvec4,mCe=$.Var,hCe=$.varying,gCe=$.varyingProperty,_Ce=$.vec2,vCe=$.vec3,yCe=$.vec4,bCe=$.vectorComponents,xCe=$.velocity,SCe=$.vertexColor,CCe=$.vertexIndex,wCe=$.vibrance,TCe=$.viewZToLogarithmicDepth,ECe=$.viewZToOrthographicDepth,DCe=$.viewZToPerspectiveDepth,OCe=$.viewport,kCe=$.viewportBottomLeft,ACe=$.viewportCoordinate,jCe=$.viewportDepthTexture,MCe=$.viewportLinearDepth,NCe=$.viewportMipTexture,PCe=$.viewportResolution,FCe=$.viewportSafeUV,ICe=$.viewportSharedTexture,LCe=$.viewportSize,RCe=$.viewportTexture,zCe=$.viewportTopLeft,BCe=$.viewportUV,VCe=$.wgsl,HCe=$.wgslFn,UCe=$.workgroupArray,WCe=$.workgroupBarrier,GCe=$.workgroupId,KCe=$.workingToColorSpace,qCe=$.xor;var JCe=r({__name:`Shader`,props:{hideNotice:{type:Boolean,default:!1}},setup(e){let r=e,i=f(null),a=f(`ombre-root-`+Math.random().toString(36).substring(7)),o=f(eI());return d(`ombreParentId`,a.value),d(`ombreNodeRegister`,(e,t,n,r,i=null)=>{o.value.registerNode(e,t,n,r,i)}),d(`ombreUniformUpdate`,(e,t,n)=>{o.value.updateUniformValue(e,t,n)}),d(`ombreMetadataUpdate`,(e,t)=>{o.value.updateNodeMetadata(e,t)}),l(async()=>{i.value&&(o.value.registerNode(a.value,({childNode:e})=>e||yCe(0,0,0,0),null,null,{}),await o.value.initialize({canvas:i.value}),r.hideNotice||o.value.showLicenseWarning())}),c(()=>{o.value.cleanup()}),(e,r)=>(u(),t(`div`,null,[n(`canvas`,s({"data-renderer":`ombre`,ref_key:`canvasRef`,ref:i,style:{...e.$attrs.class?{}:{width:`1200px`,height:`800px`},...typeof e.$attrs.style==`object`?e.$attrs.style:{}}},e.$attrs),null,16),p(e.$slots,`default`)]))}}),YCe=JCe;export{DV as Circle,AV as DotGrid,NV as FilmGrain,LV as GlassTiles,Vq as Grayscale,Wq as HueShift,qq as Invert,Xq as LinearGradient,eJ as MouseDistortion,aJ as Posterize,cJ as Saturation,YCe as Shader,dJ as SolidColor,mJ as Swirl,_J as Twirl,bJ as Vibrance};
455
+ `)},$9={dFdx:`dpdx`,dFdy:`- dpdy`,mod_float:`tsl_mod_float`,mod_vec2:`tsl_mod_vec2`,mod_vec3:`tsl_mod_vec3`,mod_vec4:`tsl_mod_vec4`,equals_bool:`tsl_equals_bool`,equals_bvec2:`tsl_equals_bvec2`,equals_bvec3:`tsl_equals_bvec3`,equals_bvec4:`tsl_equals_bvec4`,inversesqrt:`inverseSqrt`,bitcast:`bitcast<f32>`};typeof navigator<`u`&&/Windows/g.test(navigator.userAgent)&&(Q9.pow_float=new I7(`fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }`),Q9.pow_vec2=new I7(`fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }`,[Q9.pow_float]),Q9.pow_vec3=new I7(`fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }`,[Q9.pow_float]),Q9.pow_vec4=new I7(`fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }`,[Q9.pow_float]),$9.pow_float=`tsl_pow_float`,$9.pow_vec2=`tsl_pow_vec2`,$9.pow_vec3=`tsl_pow_vec3`,$9.pow_vec4=`tsl_pow_vec4`);let Lpe=``;(typeof navigator<`u`&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(Lpe+=`diagnostic( off, derivative_uniformity );
456
+ `);const Rpe=$.BRDF_GGX,zpe=$.BRDF_Lambert,Bpe=$.BasicShadowFilter,Vpe=$.Break,Hpe=$.Continue,Upe=$.DFGApprox,Wpe=$.D_GGX,Gpe=$.Discard,Kpe=$.EPSILON,qpe=$.F_Schlick,Jpe=$.Fn,Ype=$.INFINITY,Xpe=$.If,Zpe=$.Switch,Qpe=$.Loop,$pe=$.NodeShaderStage,eme=$.NodeType,tme=$.NodeUpdateType,nme=$.NodeAccess,rme=$.PCFShadowFilter,ime=$.PCFSoftShadowFilter,ame=$.PI,ome=$.PI2,sme=$.Return,cme=$.Schlick_to_F0,lme=$.ScriptableNodeResources,ume=$.ShaderNode,dme=$.TBNViewMatrix,fme=$.VSMShadowFilter,pme=$.V_GGX_SmithCorrelated,mme=$.abs,hme=$.acesFilmicToneMapping,gme=$.acos,_me=$.add,vme=$.addNodeElement,yme=$.agxToneMapping,bme=$.all,xme=$.alphaT,Sme=$.and,Cme=$.anisotropy,wme=$.anisotropyB,Tme=$.anisotropyT,Eme=$.any,Dme=$.append,Ome=$.array,kme=$.arrayBuffer,Ame=$.asin,jme=$.assign,Mme=$.atan,Nme=$.atan2,Pme=$.atomicAdd,Fme=$.atomicAnd,Ime=$.atomicFunc,Lme=$.atomicMax,Rme=$.atomicMin,zme=$.atomicOr,Bme=$.atomicStore,Vme=$.atomicSub,Hme=$.atomicXor,Ume=$.atomicLoad,Wme=$.attenuationColor,Gme=$.attenuationDistance,Kme=$.attribute,qme=$.attributeArray,Jme=$.backgroundBlurriness,Yme=$.backgroundIntensity,Xme=$.backgroundRotation,Zme=$.batch,Qme=$.billboarding,$me=$.bitAnd,ehe=$.bitNot,the=$.bitOr,nhe=$.bitXor,rhe=$.bitangentGeometry,ihe=$.bitangentLocal,ahe=$.bitangentView,ohe=$.bitangentWorld,she=$.bitcast,che=$.blendBurn,lhe=$.blendColor,uhe=$.blendDodge,dhe=$.blendOverlay,fhe=$.blendScreen,phe=$.blur,mhe=$.bool,hhe=$.buffer,ghe=$.bufferAttribute,_he=$.bumpMap,vhe=$.burn,yhe=$.bvec2,bhe=$.bvec3,xhe=$.bvec4,She=$.bypass,Che=$.cache,whe=$.call,The=$.cameraFar,Ehe=$.cameraIndex,Dhe=$.cameraNear,Ohe=$.cameraNormalMatrix,khe=$.cameraPosition,Ahe=$.cameraProjectionMatrix,jhe=$.cameraProjectionMatrixInverse,Mhe=$.cameraViewMatrix,Nhe=$.cameraWorldMatrix,Phe=$.cbrt,Fhe=$.cdl,Ihe=$.ceil,Lhe=$.checker,Rhe=$.cineonToneMapping,zhe=$.clamp,Bhe=$.clearcoat,Vhe=$.clearcoatRoughness,Hhe=$.code,Uhe=$.color,Whe=$.colorSpaceToWorking,Ghe=$.colorToDirection,Khe=$.compute,qhe=$.computeSkinning,Jhe=$.cond,Yhe=$.Const,Xhe=$.context,Zhe=$.convert,Qhe=$.convertColorSpace,$he=$.convertToTexture,ege=$.cos,tge=$.cross,nge=$.cubeTexture,rge=$.dFdx,ige=$.dFdy,age=$.dashSize,oge=$.debug,sge=$.decrement,cge=$.decrementBefore,lge=$.defaultBuildStages,uge=$.defaultShaderStages,dge=$.defined,fge=$.degrees,pge=$.deltaTime,mge=$.densityFog,hge=$.densityFogFactor,gge=$.depth,_ge=$.depthPass,vge=$.difference,yge=$.diffuseColor,bge=$.directPointLight,xge=$.directionToColor,Sge=$.dispersion,Cge=$.distance,wge=$.div,Tge=$.dodge,Ege=$.dot,Dge=$.drawIndex,Oge=$.dynamicBufferAttribute,kge=$.element,Age=$.emissive,jge=$.equal,Mge=$.equals,Nge=$.equirectUV,Pge=$.exp,Fge=$.exp2,Ige=$.expression,Lge=$.faceDirection,Rge=$.faceForward,zge=$.faceforward,Bge=$.float,Vge=$.floor,Hge=$.fog,Uge=$.fract,Wge=$.frameGroup,Gge=$.frameId,Kge=$.frontFacing,qge=$.fwidth,Jge=$.gain,Yge=$.gapSize,Xge=$.getConstNodeType,Zge=$.getCurrentStack,Qge=$.getDirection,$ge=$.getDistanceAttenuation,e_e=$.getGeometryRoughness,t_e=$.getNormalFromDepth,n_e=$.getParallaxCorrectNormal,r_e=$.getRoughness,i_e=$.getScreenPosition,a_e=$.getShIrradianceAt,o_e=$.getTextureIndex,s_e=$.getViewPosition,c_e=$.getShadowMaterial,l_e=$.getShadowRenderObjectFunction,u_e=$.glsl,d_e=$.glslFn,f_e=$.grayscale,p_e=$.greaterThan,m_e=$.greaterThanEqual,h_e=$.hash,g_e=$.highpModelNormalViewMatrix,__e=$.highpModelViewMatrix,v_e=$.hue,y_e=$.increment,b_e=$.incrementBefore,x_e=$.instance,S_e=$.instanceIndex,C_e=$.instancedArray,w_e=$.instancedBufferAttribute,T_e=$.instancedDynamicBufferAttribute,E_e=$.instancedMesh,D_e=$.int,O_e=$.inverseSqrt,k_e=$.inversesqrt,A_e=$.invocationLocalIndex,j_e=$.invocationSubgroupIndex,M_e=$.ior,N_e=$.iridescence,P_e=$.iridescenceIOR,F_e=$.iridescenceThickness,I_e=$.ivec2,L_e=$.ivec3,R_e=$.ivec4,z_e=$.js,B_e=$.label,V_e=$.length,H_e=$.lengthSq,U_e=$.lessThan,W_e=$.lessThanEqual,G_e=$.lightPosition,K_e=$.lightShadowMatrix,q_e=$.lightTargetDirection,J_e=$.lightTargetPosition,Y_e=$.lightViewPosition,X_e=$.lightingContext,Z_e=$.lights,Q_e=$.linearDepth,$_e=$.linearToneMapping,eve=$.localId,tve=$.globalId,nve=$.log,rve=$.log2,ive=$.logarithmicDepthToViewZ,ave=$.loop,ove=$.luminance,sve=$.mediumpModelViewMatrix,cve=$.mat2,lve=$.mat3,uve=$.mat4,dve=$.matcapUV,fve=$.materialAO,pve=$.materialAlphaTest,mve=$.materialAnisotropy,hve=$.materialAnisotropyVector,gve=$.materialAttenuationColor,_ve=$.materialAttenuationDistance,vve=$.materialClearcoat,yve=$.materialClearcoatNormal,bve=$.materialClearcoatRoughness,xve=$.materialColor,Sve=$.materialDispersion,Cve=$.materialEmissive,wve=$.materialIOR,Tve=$.materialIridescence,Eve=$.materialIridescenceIOR,Dve=$.materialIridescenceThickness,Ove=$.materialLightMap,kve=$.materialLineDashOffset,Ave=$.materialLineDashSize,jve=$.materialLineGapSize,Mve=$.materialLineScale,Nve=$.materialLineWidth,Pve=$.materialMetalness,Fve=$.materialNormal,Ive=$.materialOpacity,Lve=$.materialPointSize,Rve=$.materialReference,zve=$.materialReflectivity,Bve=$.materialRefractionRatio,Vve=$.materialRotation,Hve=$.materialRoughness,Uve=$.materialSheen,Wve=$.materialSheenRoughness,Gve=$.materialShininess,Kve=$.materialSpecular,qve=$.materialSpecularColor,Jve=$.materialSpecularIntensity,Yve=$.materialSpecularStrength,Xve=$.materialThickness,Zve=$.materialTransmission,Qve=$.max,$ve=$.maxMipLevel,eye=$.metalness,tye=$.min,nye=$.mix,rye=$.mixElement,iye=$.mod,aye=$.modInt,oye=$.modelDirection,sye=$.modelNormalMatrix,cye=$.modelPosition,lye=$.modelRadius,uye=$.modelScale,dye=$.modelViewMatrix,fye=$.modelViewPosition,pye=$.modelViewProjection,mye=$.modelWorldMatrix,hye=$.modelWorldMatrixInverse,gye=$.morphReference,_ye=$.mrt,vye=$.mul,yye=$.mx_aastep,bye=$.mx_cell_noise_float,xye=$.mx_contrast,Sye=$.mx_fractal_noise_float,Cye=$.mx_fractal_noise_vec2,wye=$.mx_fractal_noise_vec3,Tye=$.mx_fractal_noise_vec4,Eye=$.mx_hsvtorgb,Dye=$.mx_noise_float,Oye=$.mx_noise_vec3,kye=$.mx_noise_vec4,Aye=$.mx_ramplr,jye=$.mx_ramptb,Mye=$.mx_rgbtohsv,Nye=$.mx_safepower,Pye=$.mx_splitlr,Fye=$.mx_splittb,Iye=$.mx_srgb_texture_to_lin_rec709,Lye=$.mx_transform_uv,Rye=$.mx_worley_noise_float,zye=$.mx_worley_noise_vec2,Bye=$.mx_worley_noise_vec3,Vye=$.namespace,Hye=$.negate,Uye=$.neutralToneMapping,Wye=$.nodeArray,Gye=$.nodeImmutable,Kye=$.nodeObject,qye=$.nodeObjects,Jye=$.nodeProxy,Yye=$.normalFlat,Xye=$.normalGeometry,Zye=$.normalLocal,Qye=$.normalMap,$ye=$.normalView,ebe=$.normalWorld,tbe=$.normalize,nbe=$.not,rbe=$.notEqual,ibe=$.numWorkgroups,abe=$.objectDirection,obe=$.objectGroup,sbe=$.objectPosition,cbe=$.objectRadius,lbe=$.objectScale,ube=$.objectViewPosition,dbe=$.objectWorldMatrix,fbe=$.oneMinus,pbe=$.or,mbe=$.orthographicDepthToViewZ,hbe=$.oscSawtooth,gbe=$.oscSine,_be=$.oscSquare,vbe=$.oscTriangle,ybe=$.output,bbe=$.outputStruct,xbe=$.overlay,Sbe=$.overloadingFn,Cbe=$.parabola,wbe=$.parallaxDirection,Tbe=$.parallaxUV,Ebe=$.parameter,Dbe=$.pass,Obe=$.passTexture,kbe=$.pcurve,Abe=$.perspectiveDepthToViewZ,jbe=$.pmremTexture,Mbe=$.pointUV,Nbe=$.pointWidth,Pbe=$.positionGeometry,Fbe=$.positionLocal,Ibe=$.positionPrevious,Lbe=$.positionView,Rbe=$.positionViewDirection,zbe=$.positionWorld,Bbe=$.positionWorldDirection,Vbe=$.posterize,Hbe=$.pow,Ube=$.pow2,Wbe=$.pow3,Gbe=$.pow4,Kbe=$.premult,qbe=$.property,Jbe=$.radians,Ybe=$.rand,Xbe=$.range,Zbe=$.rangeFog,Qbe=$.rangeFogFactor,$be=$.reciprocal,exe=$.lightProjectionUV,txe=$.reference,nxe=$.referenceBuffer,rxe=$.reflect,ixe=$.reflectVector,axe=$.reflectView,oxe=$.reflector,sxe=$.refract,cxe=$.refractVector,lxe=$.refractView,uxe=$.reinhardToneMapping,dxe=$.remainder,fxe=$.remap,pxe=$.remapClamp,mxe=$.renderGroup,hxe=$.renderOutput,gxe=$.rendererReference,_xe=$.rotate,vxe=$.rotateUV,yxe=$.roughness,bxe=$.round,xxe=$.rtt,Sxe=$.sRGBTransferEOTF,Cxe=$.sRGBTransferOETF,wxe=$.sampler,Txe=$.samplerComparison,Exe=$.saturate,Dxe=$.saturation,Oxe=$.screen,kxe=$.screenCoordinate,Axe=$.screenSize,jxe=$.screenUV,Mxe=$.scriptable,Nxe=$.scriptableValue,Pxe=$.select,Fxe=$.setCurrentStack,Ixe=$.shaderStages,Lxe=$.shadow,Rxe=$.pointShadow,zxe=$.shadowPositionWorld,Bxe=$.sharedUniformGroup,Vxe=$.shapeCircle,Hxe=$.sheen,Uxe=$.sheenRoughness,Wxe=$.shiftLeft,Gxe=$.shiftRight,Kxe=$.shininess,qxe=$.sign,Jxe=$.sin,Yxe=$.sinc,Xxe=$.skinning,Zxe=$.smoothstep,Qxe=$.smoothstepElement,$xe=$.specularColor,eSe=$.specularF90,tSe=$.spherizeUV,nSe=$.split,rSe=$.spritesheetUV,iSe=$.sqrt,aSe=$.stack,oSe=$.step,sSe=$.storage,cSe=$.storageBarrier,lSe=$.storageObject,uSe=$.storageTexture,dSe=$.string,fSe=$.struct,pSe=$.sub,mSe=$.subgroupIndex,hSe=$.subgroupSize,gSe=$.tan,_Se=$.tangentGeometry,vSe=$.tangentLocal,ySe=$.tangentView,bSe=$.tangentWorld,xSe=$.temp,SSe=$.texture,CSe=$.texture3D,wSe=$.textureBarrier,TSe=$.textureBicubic,ESe=$.textureCubeUV,DSe=$.textureLoad,OSe=$.textureSize,kSe=$.textureStore,ASe=$.thickness,jSe=$.time,MSe=$.timerDelta,NSe=$.timerGlobal,PSe=$.timerLocal,FSe=$.toneMapping,ISe=$.toneMappingExposure,LSe=$.toonOutlinePass,RSe=$.transformDirection,zSe=$.transformNormal,BSe=$.transformNormalToView,VSe=$.transformedBentNormalView,HSe=$.transformedBitangentView,USe=$.transformedBitangentWorld,WSe=$.transformedClearcoatNormalView,GSe=$.transformedNormalView,KSe=$.transformedNormalWorld,qSe=$.transformedTangentView,JSe=$.transformedTangentWorld,YSe=$.transmission,XSe=$.transpose,ZSe=$.triNoise3D,QSe=$.triplanarTexture,$Se=$.triplanarTextures,eCe=$.trunc,tCe=$.tslFn,nCe=$.uint,rCe=$.uniform,iCe=$.uniformCubeTexture,aCe=$.uniformArray,oCe=$.uniformGroup,sCe=$.uniformTexture,cCe=$.uniforms,lCe=$.unpremult,uCe=$.userData,dCe=$.uv,fCe=$.uvec2,pCe=$.uvec3,mCe=$.uvec4,hCe=$.Var,gCe=$.varying,_Ce=$.varyingProperty,vCe=$.vec2,yCe=$.vec3,bCe=$.vec4,xCe=$.vectorComponents,SCe=$.velocity,CCe=$.vertexColor,wCe=$.vertexIndex,TCe=$.vibrance,ECe=$.viewZToLogarithmicDepth,DCe=$.viewZToOrthographicDepth,OCe=$.viewZToPerspectiveDepth,kCe=$.viewport,ACe=$.viewportBottomLeft,jCe=$.viewportCoordinate,MCe=$.viewportDepthTexture,NCe=$.viewportLinearDepth,PCe=$.viewportMipTexture,FCe=$.viewportResolution,ICe=$.viewportSafeUV,LCe=$.viewportSharedTexture,RCe=$.viewportSize,zCe=$.viewportTexture,BCe=$.viewportTopLeft,VCe=$.viewportUV,HCe=$.wgsl,UCe=$.wgslFn,WCe=$.workgroupArray,GCe=$.workgroupBarrier,KCe=$.workgroupId,qCe=$.workingToColorSpace,JCe=$.xor;var YCe=r({__name:`Shader`,props:{hideNotice:{type:Boolean,default:!1}},setup(e){let r=e,i=f(null),a=f(`ombre-root-`+Math.random().toString(36).substring(7)),o=f($F());return d(`ombreParentId`,a.value),d(`ombreNodeRegister`,(e,t,n,r,i=null)=>{t===null?o.value.removeNode(e):o.value.registerNode(e,t,n,r,i)}),d(`ombreUniformUpdate`,(e,t,n)=>{o.value.updateUniformValue(e,t,n)}),d(`ombreMetadataUpdate`,(e,t)=>{o.value.updateNodeMetadata(e,t)}),l(async()=>{i.value&&(o.value.registerNode(a.value,({childNode:e})=>e||bCe(0,0,0,0),null,null,{}),await o.value.initialize({canvas:i.value}),r.hideNotice||o.value.showLicenseWarning())}),c(()=>{o.value.cleanup()}),(e,r)=>(u(),t(`div`,null,[n(`canvas`,s({"data-renderer":`ombre`,ref_key:`canvasRef`,ref:i,style:{...e.$attrs.class?{}:{width:`1200px`,height:`800px`},...typeof e.$attrs.style==`object`?e.$attrs.style:{}}},e.$attrs),null,16),p(e.$slots,`default`)]))}}),XCe=YCe;export{EV as Circle,kV as DotGrid,MV as FilmGrain,IV as GlassTiles,Bq as Grayscale,Uq as HueShift,Kq as Invert,Yq as LinearGradient,t$ as MouseDistortion,o$ as Posterize,l$ as Saturation,XCe as Shader,f$ as SolidColor,h$ as Swirl,v$ as Twirl,x$ as Vibrance};